|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ofbiz.base.util.string.FlexibleStringExpander
public abstract class FlexibleStringExpander
Expands String values that contain Unified Expression Language (JSR 245) syntax. This class also supports the execution of bsh scripts by using the 'bsh:' prefix, and Groovy scripts by using the 'groovy:' prefix. Further it is possible to control the output by specifying the suffix '?currency(XXX)' to format the output according to the supplied locale and specified (XXX) currency.
This class extends the UEL by allowing nested expressions.
| Nested Class Summary | |
|---|---|
protected static class |
FlexibleStringExpander.ArrayOffsetString
|
protected static class |
FlexibleStringExpander.ConstOffsetElem
An object that represents a String constant portion of an expression. |
protected static class |
FlexibleStringExpander.ConstSimpleElem
An object that represents a String constant portion of an expression. |
protected static class |
FlexibleStringExpander.CurrElem
An object that represents a currency portion of an expression. |
protected static class |
FlexibleStringExpander.Elements
A container object that contains expression fragments. |
protected static class |
FlexibleStringExpander.NestedVarElem
An object that represents a nested expression. |
protected static class |
FlexibleStringExpander.ScriptElem
An object that represents a ${[groovy|bsh]:} expression. |
protected static class |
FlexibleStringExpander.VarElem
An object that represents a simple, non-nested expression. |
| Field Summary | |
|---|---|
protected char[] |
chars
|
static java.lang.String |
closeBracket
|
protected static UtilCache<org.ofbiz.base.util.string.FlexibleStringExpander.Key,FlexibleStringExpander> |
exprCache
|
protected int |
hint
|
static java.lang.String |
module
|
protected static FlexibleStringExpander |
nullExpr
|
static java.lang.String |
openBracket
|
| Constructor Summary | |
|---|---|
protected |
FlexibleStringExpander(char[] chars)
|
| Method Summary | |
|---|---|
static boolean |
containsConstant(FlexibleStringExpander fse)
Returns true if fse contains a String constant. |
static boolean |
containsExpression(FlexibleStringExpander fse)
Returns true if fse contains an expression. |
static boolean |
containsScript(FlexibleStringExpander fse)
Returns true if fse contains a script. |
java.lang.Object |
expand(java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluate this object's expression and return the result as an Object. |
java.lang.Object |
expand(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
Evaluate this object's expression and return the result as an Object. |
java.lang.Object |
expand(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
Evaluate this object's expression and return the result as an Object. |
java.lang.String |
expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluate this object's expression and return the result as a String. |
java.lang.String |
expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
Evaluate this object's expression and return the result as a String. |
java.lang.String |
expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
Evaluate this object's expression and return the result as a String. |
static java.lang.String |
expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context)
Evaluate an expression and return the result as a String. |
static java.lang.String |
expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
Evaluate an expression and return the result as a String. |
static java.lang.String |
expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
Evaluate an expression and return the result as a String. |
protected abstract java.lang.Object |
get(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
|
static FlexibleStringExpander |
getInstance(java.lang.String expression)
Returns a FlexibleStringExpander object. |
static FlexibleStringExpander |
getInstance(java.lang.String expression,
boolean useCache)
|
abstract java.lang.String |
getOriginal()
Returns a copy of the original expression. |
protected static FlexibleStringExpander[] |
getStrElems(char[] chars,
int offset,
int length)
|
abstract boolean |
isEmpty()
Returns true if the original expression is empty
or null. |
java.lang.String |
toString()
Returns a copy of the original expression. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String module
public static final java.lang.String openBracket
public static final java.lang.String closeBracket
protected static final UtilCache<org.ofbiz.base.util.string.FlexibleStringExpander.Key,FlexibleStringExpander> exprCache
protected static final FlexibleStringExpander nullExpr
protected final char[] chars
protected int hint
| Constructor Detail |
|---|
protected FlexibleStringExpander(char[] chars)
| Method Detail |
|---|
public static boolean containsConstant(FlexibleStringExpander fse)
true if fse contains a String constant.
fse - The FlexibleStringExpander to test
true if fse contains a String constantpublic static boolean containsExpression(FlexibleStringExpander fse)
true if fse contains an expression.
fse - The FlexibleStringExpander to test
true if fse contains an expressionpublic static boolean containsScript(FlexibleStringExpander fse)
true if fse contains a script.
fse - The FlexibleStringExpander to test
true if fse contains a script
public static java.lang.String expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context)
String.
Null expressions return null.
A null context 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 returns null when given a null expression
argument, and
FlexibleStringExpander.getInstance(expression).expandString(context)
returns an empty String.
expression - The original expressioncontext - The evaluation context
String
public static java.lang.String expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
String.
Null expressions return null.
A null context 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 returns null when given a null expression
argument, and
FlexibleStringExpander.getInstance(expression).expandString(context, locale)
returns an empty String.
expression - The original expressioncontext - The evaluation contextlocale - The locale to be used for localization
String
public static java.lang.String expandString(java.lang.String expression,
java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
String.
Null expressions return null.
A null context 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 returns null when given a null expression
argument, and
FlexibleStringExpander.getInstance(expression).expandString(context, timeZone, locale)
returns an empty String.
expression - The original expressioncontext - The evaluation contexttimeZone - The time zone to be used for localizationlocale - The locale to be used for localization
Stringpublic static FlexibleStringExpander getInstance(java.lang.String expression)
FlexibleStringExpander 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, the FlexibleStringExpander object
that is returned does not perform any evaluations on the original
String - any methods that return a String
will return the original String. The object returned by
this method is very compact - taking less memory than the original
String.
expression - The original expression
FlexibleStringExpander instance
public static FlexibleStringExpander getInstance(java.lang.String expression,
boolean useCache)
protected static FlexibleStringExpander[] getStrElems(char[] chars,
int offset,
int length)
protected abstract java.lang.Object get(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
public java.lang.String expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context)
String.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation context
String
public java.lang.String expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
String.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation contextlocale - The locale to be used for localization
String
public java.lang.String expandString(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
String.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation contexttimeZone - The time zone to be used for localizationlocale - The locale to be used for localization
Stringpublic java.lang.Object expand(java.util.Map<java.lang.String,? extends java.lang.Object> context)
Object.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation context
String
public java.lang.Object expand(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.Locale locale)
Object.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation contextlocale - The locale to be used for localization
String
public java.lang.Object expand(java.util.Map<java.lang.String,? extends java.lang.Object> context,
java.util.TimeZone timeZone,
java.util.Locale locale)
Object.
Null or empty expressions return an empty String.
A null context argument will return the original expression.
context - The evaluation contexttimeZone - The time zone to be used for localizationlocale - The locale to be used for localization
Stringpublic abstract java.lang.String getOriginal()
public abstract boolean isEmpty()
true if the original expression is empty
or null.
isEmpty in interface IsEmptytrue if the original expression is empty
or nullpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||