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
+2-2Lines changed: 2 additions & 2 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 or given key contains null!
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 or given key contains null!
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)}
publicstaticString[] splitValues(Strings, intlimit, booleanoneOrMore, char[] splitBreaks, char... splitter)//TODO: This bs is terribly broken! Idk what I was doing back then but its not doing what I would assume at all...
* @param source | Source object to get value of the member from (may or may not be null). Source should not be modified!
38
+
* @param member | Name/key of the member to get.
39
+
*
40
+
* @return The value of member from given source. You can think about this as ekvivalent to <code>source.member</code> in Java. If member with provided name/key is not present in the source or its value is not possible to get, {@link VOID} has to be returned! If source can't be accessed/dereferenced, <code>null</code> has to be returned!<br>
41
+
* Note: This method is meant to be overridden in order to add support for accessing multiple sources because by default it supports only {@link GenericScope}
* @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)!
55
+
* @param str | Source string, should not be null or empty (preferably with some variables to read)!
38
56
* @param scope | Source scope to read from, can't be null!
39
57
* @param args | Some additional args. This can be anything and it demands on implementation of DataParser.
40
58
*
41
59
* @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.
// 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);
91
+
obj = getMemberOperator(sc, path[iLast]);
82
92
break;
83
93
}
84
94
}
@@ -96,8 +106,9 @@ else if (newModif = str.endsWith("::new"))
96
106
97
107
if (obj == null || obj == VOID) // When was not found...
LogProvider.instance.logErr("Variable \"" + tree[tree.length-2] + "\" was not declared as scope in its scope so variable \"" + tree[tree.length-1] +"\" cant be set to \"" + obj + "\"!", null);
LogProvider.instance.logErr("Path \"" + var + "\" cannot be set to \"" + val + "\" because \"" + path[j] + "\" is not a accessible or does not exist!", null);
98
103
}
104
+
else
105
+
setMemberOperator(myHomeRegistry, scope, var, val, genericVar, args);
99
106
}
100
107
101
-
if (arg.charAt(0) == '$')
102
-
returnobj;
103
-
returnVOID;
108
+
returngetValueModif ? val : VOID;
104
109
}
105
110
106
111
returnparse(myHomeRegistry, arg, scope, args); //Reading vars from scope...
Entry<Object, Object> var = (Entry<Object, Object>) obj;
122
+
Entry<?, ?> var = (Entry<?, ?>) obj;
118
123
inttabs = 0;
119
124
if (args.length > 1 && args[1] instanceofInteger)
120
125
tabs = (int) args[1];
@@ -136,6 +141,30 @@ public CharSequence getDescription(ParserRegistry myHomeRegistry, Object objToDe
136
141
returnnewStringBuilder(myHomeRegistry.getConverterFor(ent.getValue(), argsUsedConvert).getDescription(myHomeRegistry, ent.getValue(), argsUsedConvert)).append(" Stored by \"").append(ent.getKey()).append("\" variable!");
137
142
}
138
143
144
+
/**
145
+
* @param myHomeRegistry | {@link ParserRegistry} provided by caller, may or may not be used...
146
+
* @param source | Source object to set the value member.
147
+
* @param member | Name/key of the member to set.
148
+
* @param val | Value to set the member to.
149
+
* @param genericVar | If true, member is expected be generic (not only string) and further parsing is required, may or may not be used...
150
+
* @param args | Some additional args to be used in case of parsing that are provided by called, may or may not be used...
151
+
*
152
+
* @return By default it returns the previous value of the member. If member with provided name/key is not present in the source or its value is not possible to set, {@link VOID} should be returned!
0 commit comments