1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240 | package Torello.Browser.JsonAST;
import Torello.JavaDoc.Annotations.LinkJavaSource;
import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
import Torello.JSON.ReadJSON;
import Torello.Java.ReadOnly.ReadOnlySet;
import Torello.Java.ReadOnly.ReadOnlyTreeSet;
import Torello.Browser.CDPTypes;
import javax.json.JsonObject;
import java.io.IOException;
import java.util.Objects;
/**
* Contains the data needed to represent a property, parameter or return value.
* <EMBED CLASS='external-html' DATA-FILE-ID=AST_TREES>
*/
@JDHeaderBackgroundImg(EmbedTagFileID="AST_NODES_JDHBI")
public class PPR extends Entity implements java.io.Serializable
{
// ********************************************************************************************
// ********************************************************************************************
// STATIC FINAL FIELDS
// ********************************************************************************************
// ********************************************************************************************
/** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
protected static final long serialVersionUID = 1;
/**
* The list of additional {@link JsonObject} properties that the parser should expect when
* parsing {@code PPR} objects from the JSON CDP specification files.
*/
protected static final ReadOnlySet<String> PPR_JSON_PROPERTIES =
new ReadOnlyTreeSet<>(String::compareTo, "name", "$ref");
// ********************************************************************************************
// ********************************************************************************************
// Constant & Final Instance-Fields (Set by the Constructor)
// ********************************************************************************************
// ********************************************************************************************
/**
* This is a "Back Pointer" to the {@link TCE} (either a {@link TypeNode}, {@link CommandNode}
* or {@link EventNode}) that is the parent or owner of {@code 'this'} PPR instance.
*/
public final TCE ownerTCE;
/**
* Expresses, explicitly, (without requiring an {@code 'instanceof'} operator), whether or not
* {@code 'this'} instance repesents a property, a parameter or a return-value.
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.which>
*/
public final WhichPPR which;
/**
* This field is declared {@code final}, and contains the raw-{@code String} value which is
* retrieved (during JSON parsing) from the {@code "$ref"} {@link JsonObject} property which
* defines {@code 'this' PPR} instance
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.ref>
*/
public final String ref;
/**
* This {@code String} is declared {@code final}, and contains the raw-{@code String} value
* which is retrieved during the parsing of an {@code 'items'} {@link JsonObject} within this
* {@code PPR} definition.
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.refArray>
*/
public final String refArray;
// ********************************************************************************************
// ********************************************************************************************
// Non-Final Fields, set By the Linker
// ********************************************************************************************
// ********************************************************************************************
private TypeNode reference = null;
private TypeNode referenceArray = null;
private String ctas = null;
private byte ctab = 0;
/**
* Returns the value of the {@code private} field {@code 'reference'}; a field that represents
* the resolved target of a {@code '$ref'} property.
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.reference>
*/
public final TypeNode reference() { return reference; }
/**
* Returns the value of the {@code private} field {@code 'referenceArray'}; a field that
* represents the resolved target of a {@code '$ref'} property which was extracted from an
* {@code 'items'} object.
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.referenceArray>
*/
public final TypeNode referenceArray() { return referenceArray; }
/**
* Returns the value of the private field {@code 'ctas'}; a field that represents the
* "Computed Type as String" - the <B STYLE='color:red;'><I>Java Type of this PPR</I></B>, as a
* {@code java.lang.String}).
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.CTAS>
*
* @see CTAB
*/
public final String CTAS() { return ctas; }
/**
* Returns the value of the private field {@code 'ctab'}; a field that represents the "Computed
* Type as Byte".
*
* <EMBED CLASS='external-html' DATA-FILE-ID=PPR.CTAB>
*
* @see CTAS
* @see CDPTypes
*/
public final byte CTAB() { return ctab; }
// ********************************************************************************************
// ********************************************************************************************
// Package-Private Setters; nethods not visible to callers from outside of Java-HTML
// ********************************************************************************************
// ********************************************************************************************
// It is important to realize that 'reference' and 'referenceArray' must be assigned first,
// if they are ever going to be assigned to anything other than null.
private static final String LINK_ERROR_MSG =
"A value has already been assigned to the 'ctas' or 'ctab' fields. These fields " +
"contain the 'Computed Type', and once they have been assigned, reassigning a value " +
"to field 'reference' or 'referenceArray' is not allowed.";
void setReference(final TypeNode reference)
{
// This is a "Space Age UnreachableError" Check.
if ((this.ctas != null) || (this.ctab != 0)) throw new LinkingStateError(LINK_ERROR_MSG);
this.reference = reference;
}
void setReferenceArray(final TypeNode referenceArray)
{
// This is a "Space Age UnreachableError" Check.
if ((this.ctas != null) || (this.ctab != 0)) throw new LinkingStateError(LINK_ERROR_MSG);
this.referenceArray = referenceArray;
}
void setCTAS(final String ctas)
{
if ((this.ctas != null) || (this.ctab != 0)) throw new LinkingStateError
("'ctas' or 'ctab' have already been assigned. They may not be reassigned.");
this.ctas = ctas;
this.ctab = CDPTypes.ctasToByte(ctas, reference != null, referenceArray != null);
}
// ********************************************************************************************
// ********************************************************************************************
// Constructor
// ********************************************************************************************
// ********************************************************************************************
PPR(
final TCE ownerTCE,
final JsonObject jo,
final WhichPPR which,
final int index
)
{
super(
ownerTCE.ownerDomain,
WhichEntity.ClassPPR,
jo,
index,
PPR_JSON_PROPERTIES
);
this.ownerTCE = ownerTCE;
this.which = which;
// getString(JsonObject jo, String propertyName, boolean isOptional, boolean throwOnNull)
this.ref = ReadJSON.getString(jo, "$ref", true, true);
if ((this.typeProp == TypeProp.ARRAY) && (this.arrItemsTypeProp == null))
{
// getJsonObject(jo, propertyName, boolean isOptional, boolean throwOnNull)
final JsonObject arrItemsProp = ReadJSON.getJsonObject(jo, "items", false, true);
// getString jo, propertyName, boolean isOptional, boolean throwOnNull)
this.refArray = ReadJSON.getString(arrItemsProp, "$ref", false, true);
}
else this.refArray = null;
}
// ********************************************************************************************
// ********************************************************************************************
// Cloneable, Comparable, Object
// ********************************************************************************************
// ********************************************************************************************
/** Returns a {@code String} representation of {@code 'this'} instance. */
@LinkJavaSource(handle="StringPPR")
public String toString()
{ return StringPPR.get(this); }
/**
* Returns a brief (shorter than the {@link toString}a output)) {@code String} summary of
* {@code 'this'} instance.
*/
public String toStringShort()
{
return
this.ownerDomain.ownerAPI.name + '.' + // API-Name
this.ownerDomain.name + '.' + // Domain-Name
this.ownerTCE.name + '.' + // TCE-Name
this.name + ' ' + // PPR-Name
"[WhichTCE." + this.ownerTCE.which + ", WhichPPR." + this.which + ']';
}
}
|