Package org.geotools.ysld.parse
Class Util
Object
Util
Parsing utilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AnchorPointParses an anchor tuple.static ExpressionParses a color from string representation.static <T> TdefaultForNull(T... options) Returns the first non-null parameter or null.static Displacementdisplacement(Object value, Factory factory) Parses an displacement tuple.static Expressionexpression(String value, boolean safe, Factory factory) Parses an expression from its string representation.static Expressionexpression(String value, Factory factory) Parses an expression from its string representation.static float[]floatArray(String value) Parses a float array from a space delimited list.static <T> TforceDefaultForNull(T... options) Returns the first non-null parameter or throws NullPointerException.static ZoomContextgetNamedZoomContext(String name, List<ZoomContextFinder> zCtxtFinders) Finds an applicableZoomContextbased on a namestatic Objectstatic StringRemoves up to one set of ${ } expression brackets from a YSLD string.static StringSerializes a JavaColorto a String representation of the format "#RRGGBB"static List<Expression>splitConcatenates(Expression expr) Splits anExpressioninto a list of expressions by removingConcatenateFunctionandFilterFunction_strConcatFunctions, and listing the children of those functions.static StringstripQuotes(String str) static ExpressionunwrapConcatenates(Expression expr, Factory factory) Simplifies anExpressionwhich may contain multipleConcatenateFunctioninto a single top-levelConcatenateFunctionwith a flat list of parameters.vendorOptions(YamlMap sourceMap) Parse all vendor options (keys starting with 'x-')
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
expression
Parses an expression from its string representation. -
unwrapConcatenates
Simplifies anExpressionwhich may contain multipleConcatenateFunctioninto a single top-levelConcatenateFunctionwith a flat list of parameters.If the passed
Expressionperforms no concatenation, it is returned as-is. If the passedExpressionrepresents an empty value, aLiteralexpression with value null is returned.- Parameters:
factory- Function factory- Returns:
- Simplified expression
-
splitConcatenates
Splits anExpressioninto a list of expressions by removingConcatenateFunctionandFilterFunction_strConcatFunctions, and listing the children of those functions. This is applied recursively, so nested Expressions are also handled. Null-valued or emptyLiteralExpressions are removed.- Returns:
- List of expressions, containing no concatenate functions
-
expression
Parses an expression from its string representation.The safe parameter when set to true will cause null to be returned when the string can not be parsed as a ECQL expression. When false it will result in an exception thrown back.
- Returns:
- The parsed expression, or null if the string value was empty.
-
anchor
Parses an anchor tuple. -
displacement
Parses an displacement tuple. -
color
Parses a color from string representation. -
floatArray
Parses a float array from a space delimited list. -
defaultForNull
Returns the first non-null parameter or null. -
forceDefaultForNull
Returns the first non-null parameter or throws NullPointerException. -
getNamedZoomContext
@Nullable public static ZoomContext getNamedZoomContext(String name, List<ZoomContextFinder> zCtxtFinders) Finds an applicableZoomContextbased on a name- Parameters:
name- Name of the ZoomContext.zCtxtFinders- List of finders for theZoomContext- Returns:
ZoomContextmatching the name.- Throws:
IllegalArgumentException- If name is "EPSG:4326", "EPSG:3857", or "EPSG:900913" (These names cause ambiguities).
-
removeExpressionBrackets
Removes up to one set of ${ } expression brackets from a YSLD string. Escape sequences for the characters $}\ within the brackets are unescaped.- Returns:
- s with brackets and escape sequences removed.
-
makeNumberIfPossible
- Returns:
- A number parsed from the provided string, or the string itself if parsing failed. Also returns null if the string was null.
-
serializeColor
Serializes a JavaColorto a String representation of the format "#RRGGBB"- Parameters:
c- Color- Returns:
- String representation of c
-
stripQuotes
- Returns:
- The string with quotes (') stripped from the beginning and end, or null if the string was null.
-
vendorOptions
Parse all vendor options (keys starting with 'x-')- Parameters:
sourceMap- YamlMap to parse- Returns:
- A map of the vendor options
-