Class FlexibleStringExpander
- All Implemented Interfaces:
Serializable
,IsEmpty
- Direct Known Subclasses:
FlexibleStringExpander.ArrayOffsetString
,FlexibleStringExpander.ConstSimpleElem
This class extends the UEL by allowing nested expressions.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
An object that represents aString
constant portion of an expression.protected static class
An object that represents aString
constant portion of an expression.protected static class
An object that represents a currency portion of an expression.protected static class
A container object that contains expression fragments.protected static class
An object that represents a nested expression.protected static class
An object that represents a${[groovy|bsh]:}
expression.protected static class
An object that represents a simple, non-nested expression. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returnstrue
iffse
contains aString
constant.static boolean
Returnstrue
iffse
contains an expression.static boolean
Returnstrue
iffse
contains a script.Evaluate this object's expression and return the result as anObject
.Evaluate this object's expression and return the result as anObject
.Evaluate this object's expression and return the result as anObject
.static String
expandString
(String expression, Map<String, ? extends Object> context) Evaluate an expression and return the result as aString
.static String
Evaluate an expression and return the result as aString
.static String
expandString
(String expression, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) Evaluate an expression and return the result as aString
.expandString
(Map<String, ? extends Object> context) Evaluate this object's expression and return the result as aString
.expandString
(Map<String, ? extends Object> context, Locale locale) Evaluate this object's expression and return the result as aString
.Evaluate this object's expression and return the result as aString
.protected abstract Object
char[]
getChars()
Get chars char [ ].int
getHint()
Gets hint.static FlexibleStringExpander
getInstance
(String expression) Returns aFlexibleStringExpander
object.static FlexibleStringExpander
getInstance
(String expression, boolean useCache) abstract String
Returns a copy of the original expression.protected static FlexibleStringExpander[]
getStrElems
(char[] chars, int offset, int length) abstract boolean
isEmpty()
Returnstrue
if the original expression is empty ornull
.void
setHint
(int hint) Sets hint.toString()
Returns a copy of the original expression.
-
Field Details
-
OPEN_BRACKET
- See Also:
-
CLOSE_BRACKET
- See Also:
-
-
Constructor Details
-
FlexibleStringExpander
protected FlexibleStringExpander(char[] chars)
-
-
Method Details
-
containsConstant
Returnstrue
iffse
contains aString
constant.- Parameters:
fse
- TheFlexibleStringExpander
to test- Returns:
true
iffse
contains aString
constant
-
containsExpression
Returnstrue
iffse
contains an expression.- Parameters:
fse
- TheFlexibleStringExpander
to test- Returns:
true
iffse
contains an expression
-
containsScript
Returnstrue
iffse
contains a script.- Parameters:
fse
- TheFlexibleStringExpander
to test- Returns:
true
iffse
contains a script
-
expandString
Evaluate an expression and return the result as aString
. Null expressions returnnull
. A nullcontext
argument will return the original expression.Note that the behavior of this method is not the same as using
FlexibleStringExpander.getInstance(expression).expandString(context)
because it returnsnull
when given a nullexpression
argument, andFlexibleStringExpander.getInstance(expression).expandString(context)
returns an emptyString
.- Parameters:
expression
- The original expressioncontext
- The evaluation context- Returns:
- The original expression's evaluation result as a
String
-
expandString
public static String expandString(String expression, Map<String, ? extends Object> context, Locale locale) Evaluate an expression and return the result as aString
. Null expressions returnnull
. A nullcontext
argument will return the original expression.Note that the behavior of this method is not the same as using
FlexibleStringExpander.getInstance(expression).expandString(context, locale)
because it returnsnull
when given a nullexpression
argument, andFlexibleStringExpander.getInstance(expression).expandString(context, locale)
returns an emptyString
.- Parameters:
expression
- The original expressioncontext
- The evaluation contextlocale
- The locale to be used for localization- Returns:
- The original expression's evaluation result as a
String
-
expandString
public static String expandString(String expression, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) Evaluate an expression and return the result as aString
. Null expressions returnnull
. A nullcontext
argument will return the original expression.Note that the behavior of this method is not the same as using
FlexibleStringExpander.getInstance(expression).expandString(context, timeZone locale)
because it returnsnull
when given a nullexpression
argument, andFlexibleStringExpander.getInstance(expression).expandString(context, timeZone, locale)
returns an emptyString
.- Parameters:
expression
- The original expressioncontext
- The evaluation contexttimeZone
- The time zone to be used for localizationlocale
- The locale to be used for localization- Returns:
- The original expression's evaluation result as a
String
-
getInstance
Returns aFlexibleStringExpander
object.A null or empty argument will return a
FlexibleStringExpander
object that represents an empty expression. That object is a shared singleton, so there is no memory or performance penalty in using it.If the method is passed a
String
argument that doesn't contain an expression, theFlexibleStringExpander
object that is returned does not perform any evaluations on the originalString
- any methods that return aString
will return the originalString
. The object returned by this method is very compact - taking less memory than the originalString
.- Parameters:
expression
- The original expression- Returns:
- A
FlexibleStringExpander
instance
-
getInstance
-
getStrElems
-
getChars
public char[] getChars()Get chars char [ ].- Returns:
- the char [ ]
-
getHint
public int getHint()Gets hint.- Returns:
- the hint
-
setHint
public void setHint(int hint) Sets hint.- Parameters:
hint
- the hint
-
get
-
expandString
Evaluate this object's expression and return the result as aString
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation context- Returns:
- This object's expression result as a
String
-
expandString
Evaluate this object's expression and return the result as aString
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation contextlocale
- The locale to be used for localization- Returns:
- This object's expression result as a
String
-
expandString
Evaluate this object's expression and return the result as aString
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation contexttimeZone
- The time zone to be used for localizationlocale
- The locale to be used for localization- Returns:
- This object's expression result as a
String
-
expand
Evaluate this object's expression and return the result as anObject
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation context- Returns:
- This object's expression result as a
String
-
expand
Evaluate this object's expression and return the result as anObject
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation contextlocale
- The locale to be used for localization- Returns:
- This object's expression result as a
String
-
expand
Evaluate this object's expression and return the result as anObject
. Null or empty expressions return an emptyString
. Anull context
argument will return the original expression.- Parameters:
context
- The evaluation contexttimeZone
- The time zone to be used for localizationlocale
- The locale to be used for localization- Returns:
- This object's expression result as a
String
-
getOriginal
Returns a copy of the original expression.- Returns:
- The original expression
-
isEmpty
public abstract boolean isEmpty()Returnstrue
if the original expression is empty ornull
. -
toString
Returns a copy of the original expression.
-