You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SerialX-core/src/main/java/org/ugp/serialx/GenericScope.java
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -267,7 +267,7 @@ public <V extends ValT> V get(KeyT variableKey)
267
267
* @param variableKey | Variables name.
268
268
* @param defaultValue | Default value to return.
269
269
*
270
-
* @return Value of variable with name or defaultValue if there is no such a one!
270
+
* @return Value of variable with name or defaultValue if there is no such a one or given key contains null!
271
271
*
272
272
* @since 1.2.5
273
273
*/
@@ -337,7 +337,7 @@ public <V extends ValT> V get(KeyT... pathToValue)
337
337
* @param cls | Default value to return.
338
338
* @param defaultValue | Class that you want the obtained object to be converted into! Exact conversion algorithm can differ based on its implementations.
339
339
*
340
-
* @return Value of variable with name given converted to object of cls or defaultValue if there is no such a one!
340
+
* @return Value of variable with name given converted to object of cls or defaultValue if there is no such a one or given key contains null!
341
341
*
342
342
* @throws Exception | If converting to object of cls failed from some reason! This can differ from implementation to implementation! By default it uses {@link GenericScope#toObject(cls)}
343
343
*
@@ -792,7 +792,7 @@ public boolean isEmpty()
792
792
*/
793
793
public <TextendsGenericScope<?, ?>> TgetParent()
794
794
{
795
-
return(T) getParent(1);
795
+
returngetParent(1);
796
796
}
797
797
798
798
/**
@@ -804,6 +804,7 @@ public boolean isEmpty()
804
804
*
805
805
* @since 1.3.2
806
806
*/
807
+
@SuppressWarnings("unchecked")
807
808
public <TextendsGenericScope<?, ?>> TgetParent(intdepth)
Copy file name to clipboardExpand all lines: SerialX-core/src/main/java/org/ugp/serialx/Scope.java
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -159,7 +159,7 @@ public byte getByte(String variableName)
159
159
* @param variableName | Variables name.
160
160
* @param defaultValue | Default value to return.
161
161
*
162
-
* @return Byte value of variable with name or defaultValue if there is no such a one!
162
+
* @return Byte value of variable with name or defaultValue if there is no such a one or given key contains null!
163
163
* Byte will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
164
164
*
165
165
* @since 1.2.5
@@ -186,7 +186,7 @@ public short getShort(String variableName)
186
186
* @param variableName | Variables name.
187
187
* @param defaultValue | Default value to return.
188
188
*
189
-
* @return Byte value of variable with name or defaultValue if there is no such a one!
189
+
* @return Byte value of variable with name or defaultValue if there is no such a one or given key contains null!
190
190
* Byte will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
191
191
*
192
192
* @since 1.2.5
@@ -213,7 +213,7 @@ public int getInt(String variableName)
213
213
* @param variableName | Variables name.
214
214
* @param defaultValue | Default value to return.
215
215
*
216
-
* @return Int value of variable with name or defaultValue if there is no such a one!
216
+
* @return Int value of variable with name or defaultValue if there is no such a one or given key contains null!
217
217
* Int will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
218
218
*
219
219
* @since 1.2.5
@@ -240,7 +240,7 @@ public int getLong(String variableName)
240
240
* @param variableName | Variables name.
241
241
* @param defaultValue | Default value to return.
242
242
*
243
-
* @return Long value of variable with name or defaultValue if there is no such a one!
243
+
* @return Long value of variable with name or defaultValue if there is no such a one or given key contains null!
244
244
* Long will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
245
245
*
246
246
* @since 1.2.5
@@ -267,7 +267,7 @@ public float getFloat(String variableName)
267
267
* @param variableName | Variables name.
268
268
* @param defaultValue | Default value to return.
269
269
*
270
-
* @return Float value of variable with name or defaultValue if there is no such a one!
270
+
* @return Float value of variable with name or defaultValue if there is no such a one or given key contains null!
271
271
* Float will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
272
272
*
273
273
* @since 1.2.5
@@ -294,7 +294,7 @@ public double getDouble(String variableName)
294
294
* @param variableName | Variables name.
295
295
* @param defaultValue | Default value to return.
296
296
*
297
-
* @return Double value of variable with name or defaultValue if there is no such a one!
297
+
* @return Double value of variable with name or defaultValue if there is no such a one or given key contains null!
298
298
* Double will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
299
299
*
300
300
* @since 1.2.5
@@ -328,7 +328,7 @@ public String getString(String variableName)
328
328
* @param variableName | Variables name.
329
329
* @param defaultValue | Default value to return.
330
330
*
331
-
* @return String value of variable with name or defaultValue if there is no such a one!
331
+
* @return String value of variable with name or defaultValue if there is no such a one or given key contains null!
332
332
* String will be also parsed from any object using {@link Object#toString()}!
333
333
*
334
334
* @since 1.2.5
@@ -355,7 +355,7 @@ public char getChar(String variableName)
355
355
* @param variableName | Variables name.
356
356
* @param defaultValue | Default value to return.
357
357
*
358
-
* @return Char value of variable with name or defaultValue if there is no such a one!
358
+
* @return Char value of variable with name or defaultValue if there is no such a one or given key contains null!
359
359
* Char will be also parsed from {@link Number}, {@link Character} or {@link CharSequence} if possible!
360
360
*
361
361
* @since 1.2.5
@@ -389,7 +389,7 @@ public boolean getBool(String variableName)
389
389
* @param variableName | Variables name.
390
390
* @param defaultValue | Default value to return.
391
391
*
392
-
* @return Boolean value of variable with name or defaultValue if there is no such a one!
392
+
* @return Boolean value of variable with name or defaultValue if there is no such a one or given key contains null!
393
393
* Boolean will be also parsed from {@link Number}, or {@link CharSequence} if possible!
394
394
*
395
395
* @since 1.2.5
@@ -715,7 +715,7 @@ public <T> T toObjectOf(String variableWithscope, Class<T> objClass) throws Exce
715
715
* @param objClass | Object of class to create.
716
716
* @param defaultValue | Default value to return.
717
717
*
718
-
* @return Value of variable with name or defaultValue if there is no such a one! If there is no Scope<Object, ?> stored by variableWithScope this function behaves same as {@link Scope#get(String, Object)}!
718
+
* @return Value of variable with name or defaultValue if there is no such a one or given key contains null! If there is no Scope<Object, ?> stored by variableWithScope this function behaves same as {@link Scope#get(String, Object)}!
719
719
* If variableWithScope contains {@link GenericScope} like it supposed to, then values of scope are parsed to {@link SerializationProtocol} of objClass.
720
720
*
721
721
* @see Serializer#PROTOCOL_REGISTRY
@@ -736,7 +736,7 @@ public <T> T toObjectOf(String variableWithscope, Class<T> objClass, T defaultVa
736
736
* @param defaultValue | Default value to return.
737
737
* @param protocolsToUse | Registry of protocols to use.
738
738
*
739
-
* @return Value of variable with name or defaultValue if there is no such a one! If there is no Scope<Object, ?> stored by variableWithScope this function behaves same as {@link Scope#get(String, Object)}!
739
+
* @return Value of variable with name or defaultValue if there is no such a one or given key contains null! If there is no Scope<Object, ?> stored by variableWithScope this function behaves same as {@link Scope#get(String, Object)}!
740
740
* If variableWithScope contains {@link GenericScope} like it supposed to, then values of scope are parsed to {@link SerializationProtocol} of objClass.
* @param myHomeRegistry | Registry where this parser is registered provided by {@link DataParser#parseObj(Registry, String, boolean, Class[], Object...)} otherwise it demands on implementation (it should not be null)!
* @param myHomeRegistry | Registry where this parser is registered provided by {@link DataParser#parseObj(Registry, String, boolean, Class[], Object...)} otherwise it demands on implementation (it should not be null)!
37
+
* @param str | Source string (preferably with some variables to read)!
38
+
* @param scope | Source scope to read from, can't be null!
39
+
* @param args | Some additional args. This can be anything and it demands on implementation of DataParser.
40
+
*
41
+
* @return Value of variable read from scope is str was suitable. Special return types are {@link DataParser#VOID} and {@link DataParser#CONTINUE}. Continue will ignore this parser and jump to another one in registry.
if (scinstanceofGenericScope) // The first one has to be scope!
67
+
{
68
+
for (inti = 1; i < iLast; i++) // Subscope/forward lookup...
69
+
if (!((sc = ((GenericScope<Object, ?>) sc).get(path[i])) instanceofGenericScope))
70
+
{
71
+
// LogProvider.instance.logErr("Value of path \"" + arg + "\" cannot be dereferenced because \"" + path[i] + "\" is not a scope but " + sc + "!", null);
if (sc != VOID) // = variable was defined in parent but it is not a scope, it means we want to break cos we can't deref that = treat the path as invalid (undefined)...
80
+
{
81
+
// LogProvider.instance.logErr("Value of path \"" + arg + "\" cannot be dereferenced because \"" + path[0] + "\" is not a scope but " + sc + "!", null);
82
+
break;
83
+
}
84
+
}
85
+
while ((scope = scope.getParent()) != null);
86
+
}
87
+
else
88
+
{
89
+
do
90
+
{
91
+
if ((obj = scope.variables().getOrDefault(str, VOID)) != VOID)
92
+
break;
93
+
}
94
+
while ((scope = scope.getParent()) != null);
95
+
}
96
+
97
+
if (obj == null || obj == VOID) // When was not found...
0 commit comments