Package org.geotools.ysld.parse
Class Util
- Object
-
- Util
-
public class Util extends Object
Parsing utilities
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AnchorPoint
anchor(Object value, Factory factory)
Parses an anchor tuple.static Expression
color(Object value, Factory factory)
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
makeNumberIfPossible(String str)
static String
removeExpressionBrackets(String s)
Removes up to one set of ${ } expression brackets from a YSLD string.static String
serializeColor(Color c)
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.static Map<String,String>
vendorOptions(YamlMap sourceMap)
Parse all vendor options (keys starting with 'x-')
-
-
-
Method Detail
-
expression
public static Expression expression(String value, Factory factory)
Parses an expression from its string representation.
-
unwrapConcatenates
public static Expression unwrapConcatenates(Expression expr, Factory factory)
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
public 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. 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
public static Expression expression(String value, boolean safe, Factory factory)
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
public static AnchorPoint anchor(Object value, Factory factory)
Parses an anchor tuple.
-
displacement
public static Displacement displacement(Object value, Factory factory)
Parses an displacement tuple.
-
color
public static Expression color(Object value, Factory factory)
Parses a color from string representation.
-
floatArray
public static float[] floatArray(String value)
Parses a float array from a space delimited list.
-
defaultForNull
@SafeVarargs @Nullable public static <T> T defaultForNull(@Nullable T... options)
Returns the first non-null parameter or null.
-
forceDefaultForNull
@SafeVarargs public static <T> T forceDefaultForNull(@Nullable T... options)
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
public static String removeExpressionBrackets(String s)
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
public static Object makeNumberIfPossible(String str)
- Returns:
- A number parsed from the provided string, or the string itself if parsing failed. Also returns null if the string was null.
-
serializeColor
public static String serializeColor(Color c)
Serializes a JavaColor
to a String representation of the format "#RRGGBB"- Parameters:
c
- Color- Returns:
- String representation of c
-
stripQuotes
public static String stripQuotes(String str)
- Returns:
- The string with quotes (') stripped from the beginning and end, or null if the string was null.
-
-