Package org.qdl_lang.variables
Class StemUtility
- java.lang.Object
-
- org.qdl_lang.variables.StemUtility
-
public class StemUtility extends Object
Created by Jeff Gaynor
on 3/24/21 at 12:38 PM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStemUtility.DyadAxisActionAction to be applied at a given axis.static interfaceStemUtility.StemAxisWalkerAction1For operations that return a stem.
-
Field Summary
Fields Modifier and Type Field Description protected static intBOOLEAN_TYPEprotected static intDOUBLE_TYPEprotected static intFLOAT_TYPEprotected static intINT_TYPEstatic LongLAST_AXIS_ARGUMENT_VALUEprotected static intLIST_TYPEprotected static intLONG_TYPEprotected static intMAP_TYPEprotected static intSTRING_TYPEprotected static intUNKNON_TYPE
-
Constructor Summary
Constructors Constructor Description StemUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareAllStems(Object... objects)static booleanareNoneStems(Object... objects)static voidaxisDayadRecursion(QDLStem out0, QDLStem left0, QDLStem right0, int depth, boolean maxDepth, StemUtility.DyadAxisAction axisAction)Apply some action along an axis.static ObjectaxisWalker(QDLStem inStem, int depth, StemUtility.StemAxisWalkerAction1 walker)Recurses through stem that has arbitrary rank.protected static QDLValueconvert(Object value)Converts Java objects to one of the Java objects that QDL uses.static ObjectconvertToPOJO(QDLValue element, boolean escapeNames, int type)For use in filteringQDLValues to POJOs (plain old java object) that can be put into JSON.static voiddoNodeSurgery(ExpressionStemNode ESN, State state)static voidformatList(QDLStem stem)protected static intgetType(Object obj)static booleanisStem(Object o)static QDLValuelistToStem(List list)static voidmain(String[] args)static QDLValuemapToStem(Map map)Convert a generic map to a stemstatic QDLValuemapToStem(QDLStem out, Map map)static voidput(QDLStem stem, Object key, Object value)Since Java's use of generics precludes a generalQDLStemput on Objects, this utility does that.static voidsetStemValue(QDLStem stem, Map<String,Object> values)Floats a map of values toQDLValues in the stem.static StringstemListToString(QDLStem contents, boolean forceToString)Convert a stem list to a string, separated by line feeds.
-
-
-
Field Detail
-
LAST_AXIS_ARGUMENT_VALUE
public static final Long LAST_AXIS_ARGUMENT_VALUE
-
UNKNON_TYPE
protected static final int UNKNON_TYPE
- See Also:
- Constant Field Values
-
INT_TYPE
protected static final int INT_TYPE
- See Also:
- Constant Field Values
-
FLOAT_TYPE
protected static final int FLOAT_TYPE
- See Also:
- Constant Field Values
-
DOUBLE_TYPE
protected static final int DOUBLE_TYPE
- See Also:
- Constant Field Values
-
LONG_TYPE
protected static final int LONG_TYPE
- See Also:
- Constant Field Values
-
BOOLEAN_TYPE
protected static final int BOOLEAN_TYPE
- See Also:
- Constant Field Values
-
STRING_TYPE
protected static final int STRING_TYPE
- See Also:
- Constant Field Values
-
LIST_TYPE
protected static final int LIST_TYPE
- See Also:
- Constant Field Values
-
MAP_TYPE
protected static final int MAP_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isStem
public static boolean isStem(Object o)
-
areNoneStems
public static boolean areNoneStems(Object... objects)
-
areAllStems
public static boolean areAllStems(Object... objects)
-
axisDayadRecursion
public static void axisDayadRecursion(QDLStem out0, QDLStem left0, QDLStem right0, int depth, boolean maxDepth, StemUtility.DyadAxisAction axisAction)
Apply some action along an axis. This will recurse to a given axis and apply an action there- Parameters:
out0-left0-right0-depth-maxDepth-axisAction-
-
axisWalker
public static Object axisWalker(QDLStem inStem, int depth, StemUtility.StemAxisWalkerAction1 walker)
Recurses through stem that has arbitrary rank.- Parameters:
inStem-depth-walker-- Returns:
-
doNodeSurgery
public static void doNodeSurgery(ExpressionStemNode ESN, State state)
-
formatList
public static void formatList(QDLStem stem)
-
main
public static void main(String[] args)
-
stemListToString
public static String stemListToString(QDLStem contents, boolean forceToString)
Convert a stem list to a string, separated by line feeds. IfforceToStringis true, then every elements toString is called, otherwise, if the element is not a string, an exception is thrown.- Parameters:
contents-forceToString-- Returns:
-
mapToStem
public static QDLValue mapToStem(Map map)
Convert a generic map to a stem- Parameters:
map-- Returns:
-
convert
protected static QDLValue convert(Object value)
Converts Java objects to one of the Java objects that QDL uses.- Parameters:
value-- Returns:
-
getType
protected static int getType(Object obj)
-
setStemValue
public static void setStemValue(QDLStem stem, Map<String,Object> values)
Floats a map of values toQDLValues in the stem. This way you don't have to mess with conversions- Parameters:
stem-values-
-
put
public static void put(QDLStem stem, Object key, Object value)
Since Java's use of generics precludes a generalQDLStemput on Objects, this utility does that.- Parameters:
stem-key-value-
-
-