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 AnchorPointanchor(Object value, Factory factory)Parses an anchor tuple.static Expressioncolor(Object value, Factory factory)Parses 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 ObjectmakeNumberIfPossible(String str)static StringremoveExpressionBrackets(String s)Removes up to one set of ${ } expression brackets from a YSLD string.static StringserializeColor(Color c)Serializes 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.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 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
public static List<Expression> splitConcatenates(Expression expr)
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
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 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
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 JavaColorto 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.
-
-