Package org.geotools.ysld.parse
Class Util
Object
Util
Parsing utilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AnchorPoint
Parses an anchor tuple.static Expression
Parses a color from string representation.static <T> T
defaultForNull
(T... options) Returns the first non-null parameter or null.static Displacement
displacement
(Object value, Factory factory) Parses an displacement tuple.static Expression
expression
(String value, boolean safe, Factory factory) Parses an expression from its string representation.static Expression
expression
(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> T
forceDefaultForNull
(T... options) Returns the first non-null parameter or throws NullPointerException.static ZoomContext
getNamedZoomContext
(String name, List<ZoomContextFinder> zCtxtFinders) Finds an applicableZoomContext
based on a namestatic Object
static String
Removes up to one set of ${ } expression brackets from a YSLD string.static String
Serializes a JavaColor
to a String representation of the format "#RRGGBB"static List<Expression>
splitConcatenates
(Expression expr) Splits anExpression
into a list of expressions by removingConcatenateFunction
andFilterFunction_strConcat
Functions, and listing the children of those functions.static String
stripQuotes
(String str) static Expression
unwrapConcatenates
(Expression expr, Factory factory) Simplifies anExpression
which may contain multipleConcatenateFunction
into a single top-levelConcatenateFunction
with 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 anExpression
which may contain multipleConcatenateFunction
into a single top-levelConcatenateFunction
with a flat list of parameters.If the passed
Expression
performs no concatenation, it is returned as-is. If the passedExpression
represents an empty value, aLiteral
expression with value null is returned.- Parameters:
factory
- Function factory- Returns:
- Simplified expression
-
splitConcatenates
Splits anExpression
into a list of expressions by removingConcatenateFunction
andFilterFunction_strConcat
Functions, and listing the children of those functions. This is applied recursively, so nested Expressions are also handled. Null-valued or emptyLiteral
Expressions 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 applicableZoomContext
based on a name- Parameters:
name
- Name of the ZoomContext.zCtxtFinders
- List of finders for theZoomContext
- Returns:
ZoomContext
matching 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 JavaColor
to 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
-