public class AttributeUtil
extends java.lang.Object
AttributeUtil
class provides methods for
evaluating Expressions
that are expected to result in a
specific type.Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
SPEC_SEP |
Separates expressions in attributes that take multiple values.
|
static java.lang.String |
SPEC_SEP_2 |
Separates expressions in attributes that take multiple values at a second
level.
|
Modifier and Type | Method | Description |
---|---|---|
static void |
ensureAtLeastOneExists(Tag tag,
java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues,
java.util.List<java.lang.String> attrNames) |
Ensures that at least one of the given attribute values exists.
|
static void |
ensureAtMostOneExists(Tag tag,
java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues,
java.util.List<java.lang.String> attrNames) |
Ensures that at most one of the given attribute values exists.
|
static void |
ensureExactlyOneExists(Tag tag,
java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues,
java.util.List<java.lang.String> attrNames) |
Ensures that exactly one of the given attribute values exists.
|
static boolean |
evaluateBoolean(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
boolean def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a boolean value from
the result, calling Boolean.parseBoolean() on the result if
necessary. |
static double |
evaluateDouble(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
double def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a double value from
the result, calling toString() on the result and parsing it
if necessary. |
static int |
evaluateInt(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
int def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract an integer value from
the result, calling toString() on the result and parsing it
if necessary. |
static java.util.List<java.lang.Integer> |
evaluateIntegerArray(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.util.List<java.lang.Integer> def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a List of
Integers from the result, accepting an int
array or a Collection or delimited list of numbers. |
static java.util.List<java.util.List<java.lang.Integer>> |
evaluateIntegerArrayArray(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.util.List<java.util.List<java.lang.Integer>> def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a List of
Lists of Integers from the result, accepting a
2D int array or a Collection of
Collections or delimited list of numbers. |
static java.util.List<java.lang.String> |
evaluateList(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.util.List<java.lang.String> def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a List out
of the result, parsing a delimited list to create a list if necessary. |
static double |
evaluateNonNegativeDouble(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
double def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a double value from
the result, calling toString() on the result and parsing it
if necessary. |
static int |
evaluateNonNegativeInt(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
int def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract an integer value from
the result, calling toString() on the result and parsing it
if necessary. |
static int |
evaluateNonZeroInt(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
int def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract an integer value from
the result, calling toString() on the result and parsing it
if necessary. |
static <T> T |
evaluateObject(Tag tag,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
java.lang.Class<T> expectedClass,
T def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a result, and cast it
to the same class as the given expected class. |
static <T> T |
evaluateObject(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
java.lang.Class<T> expectedClass,
T def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a result, and cast it
to the same class as the given expected class. |
static double |
evaluatePositiveDouble(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
double def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a double value from
the result, calling toString() on the result and parsing it
if necessary. |
static int |
evaluatePositiveInt(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
int def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract an integer value from
the result, calling toString() on the result and parsing it
if necessary. |
static java.lang.Object |
evaluateRichTextStringNotNull(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
java.lang.String def) |
Evaluates the given rich text, which may have embedded
Expressions , and attempts to extract the result, which may
be either a RichTextString or a String . |
static java.lang.String |
evaluateString(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a String
result, calling toString() on the result. |
static java.lang.String |
evaluateStringNotNull(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
java.lang.String def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a String
result, calling toString() on the result. |
static java.lang.String |
evaluateStringSpecificValues(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName,
java.util.List<java.lang.String> legalValues,
java.lang.String def) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a String
result, calling toString() on the result. |
static java.lang.String |
evaluateStringVarName(Tag tag,
org.apache.poi.ss.usermodel.RichTextString text,
java.util.Map<java.lang.String,java.lang.Object> beans,
java.lang.String attrName) |
Evaluates the given text, which may have embedded
Expressions , and attempts to extract a String
result, calling toString() on the result. |
public static final java.lang.String SPEC_SEP
public static final java.lang.String SPEC_SEP_2
[[0, 1], [2, 3]]
.public static boolean evaluateBoolean(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, boolean def)
Expressions
, and attempts to extract a boolean value from
the result, calling Boolean.parseBoolean()
on the result if
necessary. If the text is null, then the result defaults to the given
default boolean value.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.def
- The default value if the text is null.public static int evaluateInt(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, int def)
Expressions
, and attempts to extract an integer value from
the result, calling toString()
on the result and parsing it
if necessary. If the text is null, then the result defaults to the given
default integer value.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number.public static int evaluateNonNegativeInt(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, int def)
Expressions
, and attempts to extract an integer value from
the result, calling toString()
on the result and parsing it
if necessary. Enforce the result to be non-negative.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number, or if the result is negative.public static int evaluatePositiveInt(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, int def)
Expressions
, and attempts to extract an integer value from
the result, calling toString()
on the result and parsing it
if necessary. Enforce the result to be positive.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number, or if the result is not positive.public static int evaluateNonZeroInt(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, int def)
Expressions
, and attempts to extract an integer value from
the result, calling toString()
on the result and parsing it
if necessary. Enforce the result to be not zero.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number, or if the result is zero.public static double evaluateDouble(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, double def)
Expressions
, and attempts to extract a double value from
the result, calling toString()
on the result and parsing it
if necessary.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number.public static double evaluateNonNegativeDouble(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, double def)
Expressions
, and attempts to extract a double value from
the result, calling toString()
on the result and parsing it
if necessary. Enforce the result to be non-negative.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number, or if the result is negative.public static double evaluatePositiveDouble(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, double def)
Expressions
, and attempts to extract a double value from
the result, calling toString()
on the result and parsing it
if necessary. Enforce the result to be positive.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.AttributeExpressionException
- If the result of the evaluation of the text is
not a number, or if the result is not positive.public static java.lang.Object evaluateRichTextStringNotNull(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, org.apache.poi.ss.usermodel.CreationHelper helper, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, java.lang.String def)
Expressions
, and attempts to extract the result, which may
be either a RichTextString
or a String
.tag
- The Tag
.text
- Rich text which may have embedded Expressions
.helper
- A CreationHelper
(for creating
RichTextStrings
).beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.String
or RichTextString
result.public static java.lang.String evaluateString(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String def)
Expressions
, and attempts to extract a String
result, calling toString()
on the result.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.def
- The default value if the text is null.String
result.public static java.lang.String evaluateStringNotNull(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, java.lang.String def)
Expressions
, and attempts to extract a String
result, calling toString()
on the result.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.def
- The default value if the text is null.String
result.public static java.lang.String evaluateStringSpecificValues(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, java.util.List<java.lang.String> legalValues, java.lang.String def)
Expressions
, and attempts to extract a String
result, calling toString()
on the result. Enforces that the
result is one of the given expected values, ignoring case.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.legalValues
- A List
of expected values.def
- The default value if the text is null.String
result.AttributeExpressionException
- If the result isn't one of the expected legal
values.public static java.lang.String evaluateStringVarName(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName)
Expressions
, and attempts to extract a String
result, calling toString()
on the result. Enforces that the
result is a valid JEXL variable name, which contains only the following
characters: [A-Z][a-z][0-9][_]
, and not starting with a
number.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.String
result.AttributeExpressionException
- If the result isn't a legal JEXL
variable name.public static <T> T evaluateObject(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, java.lang.Class<T> expectedClass, T def)
Expressions
, and attempts to extract a result, and cast it
to the same class as the given expected class.T
- The Class
of the expected return type.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.expectedClass
- The result is expected to be of the given class or
of a subclass.def
- The default value if the text is null.AttributeExpressionException
- If the result is not of the expected class or
of a subclass.public static <T> T evaluateObject(Tag tag, java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> beans, java.lang.String attrName, java.lang.Class<T> expectedClass, T def)
Expressions
, and attempts to extract a result, and cast it
to the same class as the given expected class.T
- The Class
of the expected return type.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.attrName
- The attribute name. This is only used when constructing
an exception message.expectedClass
- The result is expected to be of the given class or
of a subclass.def
- The default value if the text is null.AttributeExpressionException
- If the result is not of the expected class or
of a subclass.public static java.util.List<java.lang.String> evaluateList(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.util.List<java.lang.String> def)
Expressions
, and attempts to extract a List
out
of the result, parsing a delimited list to create a list if necessary.tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.def
- The default value if the text is null.List
.public static java.util.List<java.lang.Integer> evaluateIntegerArray(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.util.List<java.lang.Integer> def)
Evaluates the given text, which may have embedded
Expressions
, and attempts to extract a List
of
Integers
from the result, accepting an int
array or a Collection
or delimited list of numbers.
Examples of proper input:
tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.def
- The default value if the text is null.List
of Integers
.public static java.util.List<java.util.List<java.lang.Integer>> evaluateIntegerArrayArray(Tag tag, org.apache.poi.ss.usermodel.RichTextString text, java.util.Map<java.lang.String,java.lang.Object> beans, java.util.List<java.util.List<java.lang.Integer>> def)
Evaluates the given text, which may have embedded
Expressions
, and attempts to extract a List
of
Lists
of Integers
from the result, accepting a
2D int
array or a Collection
of
Collections
or delimited list of numbers.
Examples of proper input:
tag
- The Tag
.text
- Text which may have embedded Expressions
.beans
- A Map
of bean names to bean values.def
- The default value if the text is null.List
of Lists
of
Integers
.public static void ensureExactlyOneExists(Tag tag, java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues, java.util.List<java.lang.String> attrNames)
tag
- The Tag
.attrValues
- A List
of attribute values.attrNames
- A List
of attribute names.AttributeExpressionException
- If none of the attribute values is not null, or
if more than one attribute value is not null.public static void ensureAtMostOneExists(Tag tag, java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues, java.util.List<java.lang.String> attrNames)
tag
- The Tag
.attrValues
- A List
of attribute values.attrNames
- A List
of attribute names.AttributeExpressionException
- If more than one of the attribute values is not
null.public static void ensureAtLeastOneExists(Tag tag, java.util.List<org.apache.poi.ss.usermodel.RichTextString> attrValues, java.util.List<java.lang.String> attrNames)
tag
- The Tag
.attrValues
- A List
of attribute values.attrNames
- A List
of attribute names.AttributeExpressionException
- If all of the attribute values are null.Copyright © 2012–2018 Jett Team. All rights reserved.