Top Description Inners Fields Constructors Methods
org.wildfly.common.expression

public final Class Expression

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .EnumSet, .HashSet, .List, .Set, java.util.function.BiConsumer, org.wildfly.common.Assert, org.wildfly.common._private.CommonMessages, org.wildfly.common.function.ExceptionBiConsumer

A compiled property-expansion expression string. An expression string is a mix of plain strings and expression segments, which are wrapped by the sequence "${ ... }".
Author
David M. Lloyd

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Expression.Flag

Flags that can apply to a property expression compilation

pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Node
private static final Expression
private static final EnumSet<Expression.Flag>
private final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv
Expression(Node content)

Method Summary

Modifier and TypeMethod and Description
public static Expression

Returns:

the compiled expression (not null)
compile
(String
the expression string (must not be null)
string
,
Expression.Flag...
optional flags to apply which affect the compilation
flags
)

Compile an expression string.

public static Expression

Returns:

the compiled expression (not null)
compile
(String
the expression string (must not be null)
string
,
EnumSet<Expression.Flag>
optional flags to apply which affect the compilation (must not be null)
flags
)

Compile an expression string.

public String

Returns:

the expanded string
evaluate
(BiConsumer<ResolveContext<RuntimeException>, StringBuilder>
the expansion function to apply (must not be null)
expandFunction
)

Evaluate the expression with the given expansion function.

public <
the exception type thrown by the expansion function
E extends Exception
>
String

Returns:

the expanded string
evaluateException
(final ExceptionBiConsumer<ResolveContext<E>, StringBuilder, E>
the expansion function to apply (must not be null)
expandFunction
)

Evaluate the expression with the given expansion function, which may throw a checked exception.

public String

Returns:

the expanded string
evaluateWithEnvironment
(boolean
true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string
failOnNoDefault
)

Evaluate the expression using a default expansion function that evaluates environment properties.

public String

Returns:

the expanded string
evaluateWithProperties
(boolean
true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string
failOnNoDefault
)

Evaluate the expression using a default expansion function that evaluates system properties.

public String

Returns:

the expanded string
evaluateWithPropertiesAndEnvironment
(boolean
true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string
failOnNoDefault
)

Evaluate the expression using a default expansion function that evaluates system and environment properties in the JBoss style (i.e. using the prefix "env." to designate an environment property).

public Set<String>

Returns:

the immutable set of strings (not null)
getReferencedStrings
()

Get the immutable set of string keys that are referenced by expressions in this compiled expression.

private static IllegalArgumentException
invalidExpressionSyntax(final String string, final int index)

private static Node
parseString(Expression.Itr itr, final boolean allowExpr, final boolean endOnBrace, final boolean endOnColon, final EnumSet<Expression.Flag> flags)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final Node content
EMPTYback to summary
private static final Expression EMPTY
NO_FLAGSback to summary
private static final EnumSet<Expression.Flag> NO_FLAGS
referencedStringsback to summary
private final Set<String> referencedStrings

Constructor Detail

Expressionback to summary
pack-priv Expression(Node content)

Method Detail

compileback to summary
public static Expression compile(String string, Expression.Flag... flags)

Compile an expression string.

Parameters
string:String

the expression string (must not be null)

flags:Expression.Flag[]

optional flags to apply which affect the compilation

Returns:Expression

the compiled expression (not null)

compileback to summary
public static Expression compile(String string, EnumSet<Expression.Flag> flags)

Compile an expression string.

Parameters
string:String

the expression string (must not be null)

flags:EnumSet<Expression.Flag>

optional flags to apply which affect the compilation (must not be null)

Returns:Expression

the compiled expression (not null)

evaluateback to summary
public String evaluate(BiConsumer<ResolveContext<RuntimeException>, StringBuilder> expandFunction)

Evaluate the expression with the given expansion function. The given "function" is a predicate which returns true if the expansion succeeded or false if it failed (in which case a default value may be used). If expansion succeeds, the expansion function should append the result to the given StringBuilder.

Parameters
expandFunction:BiConsumer<ResolveContext<RuntimeException>, StringBuilder>

the expansion function to apply (must not be null)

Returns:String

the expanded string

evaluateExceptionback to summary
public <E extends Exception> String evaluateException(final ExceptionBiConsumer<ResolveContext<E>, StringBuilder, E> expandFunction) throws ExceptionBiConsumer:E

Evaluate the expression with the given expansion function, which may throw a checked exception. The given "function" is a predicate which returns true if the expansion succeeded or false if it failed (in which case a default value may be used). If expansion succeeds, the expansion function should append the result to the given StringBuilder.

Parameters
<E>
the exception type thrown by the expansion function
expandFunction:ExceptionBiConsumer<ResolveContext<E>, StringBuilder, E>

the expansion function to apply (must not be null)

Returns:String

the expanded string

Exceptions
ExceptionBiConsumer:E:
if the expansion function throws an exception
evaluateWithEnvironmentback to summary
public String evaluateWithEnvironment(boolean failOnNoDefault)

Evaluate the expression using a default expansion function that evaluates environment properties. The caller must have all required security manager permissions.

Parameters
failOnNoDefault:boolean

true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string

Returns:String

the expanded string

evaluateWithPropertiesback to summary
public String evaluateWithProperties(boolean failOnNoDefault)

Evaluate the expression using a default expansion function that evaluates system properties. The caller must have all required security manager permissions.

Parameters
failOnNoDefault:boolean

true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string

Returns:String

the expanded string

evaluateWithPropertiesAndEnvironmentback to summary
public String evaluateWithPropertiesAndEnvironment(boolean failOnNoDefault)

Evaluate the expression using a default expansion function that evaluates system and environment properties in the JBoss style (i.e. using the prefix "env." to designate an environment property). The caller must have all required security manager permissions.

Parameters
failOnNoDefault:boolean

true to throw an IllegalArgumentException if an unresolvable key has no default value; false to expand such keys to an empty string

Returns:String

the expanded string

getReferencedStringsback to summary
public Set<String> getReferencedStrings()

Get the immutable set of string keys that are referenced by expressions in this compiled expression. If there are no expansions in this expression, the set is empty. Note that this will not include any string keys that themselves contain expressions, in the case that Flag#NO_RECURSE_KEY was not specified.

Returns:Set<String>

the immutable set of strings (not null)

invalidExpressionSyntaxback to summary
private static IllegalArgumentException invalidExpressionSyntax(final String string, final int index)
parseStringback to summary
private static Node parseString(Expression.Itr itr, final boolean allowExpr, final boolean endOnBrace, final boolean endOnColon, final EnumSet<Expression.Flag> flags)
org.wildfly.common.expression back to summary

public final Enum Expression.Flag

extends Enum<Expression.Flag>
Class Inheritance

Flags that can apply to a property expression compilation

Field Summary

Modifier and TypeField and Description
public static final Expression.Flag
DOUBLE_COLON

Treat expressions containing a double-colon delimiter as special, encoding the entire content into the key.

public static final Expression.Flag
ESCAPES

Support standard escape sequences in plain text and default value fields, which begin with a backslash ("\") character.

public static final Expression.Flag
GENERAL_EXPANSION

Support Policy file style "general" expansion alternate expression syntax.

public static final Expression.Flag
LENIENT_SYNTAX

Ignore syntax problems instead of throwing an exception.

public static final Expression.Flag
MINI_EXPRS

Support single-character expressions that can be interpreted without wrapping in curly braces.

public static final Expression.Flag
NO_RECURSE_DEFAULT

Do not support recursion in default values.

public static final Expression.Flag
NO_RECURSE_KEY

Do not support recursive expression expansion in the key part of the expression.

public static final Expression.Flag
NO_SMART_BRACES

Do not support smart braces.

public static final Expression.Flag
NO_TRIM

Do not trim leading and trailing whitespace off of the expression string before parsing it.

Constructor Summary

AccessConstructor and Description
private
Flag()

Method Summary

Modifier and TypeMethod and Description
public static Expression.Flag
public static Expression.Flag[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DOUBLE_COLONback to summary
public static final Expression.Flag DOUBLE_COLON

Treat expressions containing a double-colon delimiter as special, encoding the entire content into the key.

ESCAPESback to summary
public static final Expression.Flag ESCAPES

Support standard escape sequences in plain text and default value fields, which begin with a backslash ("\") character.

GENERAL_EXPANSIONback to summary
public static final Expression.Flag GENERAL_EXPANSION

Support Policy file style "general" expansion alternate expression syntax. "Smart" braces will only work if the opening brace is not the first character in the expression key.

LENIENT_SYNTAXback to summary
public static final Expression.Flag LENIENT_SYNTAX

Ignore syntax problems instead of throwing an exception.

MINI_EXPRSback to summary
public static final Expression.Flag MINI_EXPRS

Support single-character expressions that can be interpreted without wrapping in curly braces.

NO_RECURSE_DEFAULTback to summary
public static final Expression.Flag NO_RECURSE_DEFAULT

Do not support recursion in default values.

NO_RECURSE_KEYback to summary
public static final Expression.Flag NO_RECURSE_KEY

Do not support recursive expression expansion in the key part of the expression.

NO_SMART_BRACESback to summary
public static final Expression.Flag NO_SMART_BRACES

Do not support smart braces.

NO_TRIMback to summary
public static final Expression.Flag NO_TRIM

Do not trim leading and trailing whitespace off of the expression string before parsing it.

Constructor Detail

Flagback to summary
private Flag()

Method Detail

valueOfback to summary
public static Expression.Flag valueOf(String name)
valuesback to summary
public static Expression.Flag[] values()
org.wildfly.common.expression back to summary

pack-priv final Class Expression.Itr

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
Itr(final String str)

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv int
pack-priv String
pack-priv boolean
pack-priv int
next()

pack-priv int
pack-priv int
pack-priv int
prev()

pack-priv void
rewind(final int newNext)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

idxback to summary
private int idx
strback to summary
private final String str

Constructor Detail

Itrback to summary
pack-priv Itr(final String str)

Method Detail

getNextIdxback to summary
pack-priv int getNextIdx()
getPrevIdxback to summary
pack-priv int getPrevIdx()
getStrback to summary
pack-priv String getStr()
hasNextback to summary
pack-priv boolean hasNext()
nextback to summary
pack-priv int next()
peekNextback to summary
pack-priv int peekNext()
peekPrevback to summary
pack-priv int peekPrev()
prevback to summary
pack-priv int prev()
rewindback to summary
pack-priv void rewind(final int newNext)