Package org.zkoss.zk.xel.impl
Class Utils
- java.lang.Object
-
- org.zkoss.zk.xel.impl.Utils
-
public class Utils extends java.lang.ObjectUtilities to handle the metainfo.- Since:
- 3.0.6
- Author:
- tomyeh
-
-
Field Summary
Fields Modifier and Type Field Description static intLISTUsed withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a vector, i.e., a list separated with comma.static intMAPUsed withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a map, i.e., a map paired with equal and separated with comma.static intSCALARUsed withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a scalar value.
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectevaluateComposite(Evaluator eval, Component comp, java.lang.Object expr)Evaluates the composite expression parsed byparseComposite(java.lang.String, java.lang.Class, int)against a component.static java.lang.ObjectevaluateComposite(Evaluator eval, Page page, java.lang.Object expr)Evaluates the composite expression parsed byparseComposite(java.lang.String, java.lang.Class, int)against a page.static java.lang.ObjectparseComposite(java.lang.String expr, java.lang.Class expcls, int type)Parses an expression which could a scalar, vector or map, depending on the specified type.static ExValue[]parseList(java.lang.String expr, java.lang.Class expcls, boolean ignoreEmpty)Parses a list of expressions that is separated by comma.
-
-
-
Field Detail
-
SCALAR
public static final int SCALAR
Used withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a scalar value. In other words, it won't handle it specially. If a- See Also:
- Constant Field Values
-
LIST
public static final int LIST
Used withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a vector, i.e., a list separated with comma. Example: "first, ${second}".- See Also:
- Constant Field Values
-
MAP
public static final int MAP
Used withparseComposite(java.lang.String, java.lang.Class, int)to indicate the expression is a map, i.e., a map paired with equal and separated with comma. Example: "one=first, two=${second}".- See Also:
- Constant Field Values
-
-
Method Detail
-
parseList
public static ExValue[] parseList(java.lang.String expr, java.lang.Class expcls, boolean ignoreEmpty)
Parses a list of expressions that is separated by comma. For example, parseList("${a}, b, ${c}", Object.class) will return a three-element array.- Parameters:
ignoreEmpty- whether to return null if expr is an empty expression.- Returns:
- an array of the parsed expressions (at least with one element), or null if expr is null.
- See Also:
parseComposite(java.lang.String, java.lang.Class, int)
-
parseComposite
public static java.lang.Object parseComposite(java.lang.String expr, java.lang.Class expcls, int type)Parses an expression which could a scalar, vector or map, depending on the specified type.If type is
SCALAR, it is a simple expression and no special parsing happens. For example, "a, ${b}" will be evaluated to "a, boy" if b is "boy" ifevaluateComposite(org.zkoss.zk.xel.Evaluator, org.zkoss.zk.ui.Component, java.lang.Object)is called.If type is
LIST, the expression is a list separated with comma. For example, "a, ${b}" will be evaluated to a list with two elements: "a" and "boy". It is similar toparseList(java.lang.String, java.lang.Class, boolean).If type is
MAP, the expression is a list of paired entries. For example, "a=apple, b=${b}" will be evaluated to a map with two entries, ("a", "apple") and ("b", "boy").- Parameters:
type- one ofSCALAR,LISTandMAP.- Returns:
- ExValue if
SCALAR, ExValue[] ifLIST, Map(String, ExValue) ifMAP, or null if expr is null. To evaluate it, invokeevaluateComposite(org.zkoss.zk.xel.Evaluator, org.zkoss.zk.ui.Component, java.lang.Object)by passing the returned value as its expr argument.
-
evaluateComposite
public static java.lang.Object evaluateComposite(Evaluator eval, Component comp, java.lang.Object expr)
Evaluates the composite expression parsed byparseComposite(java.lang.String, java.lang.Class, int)against a component.
-
evaluateComposite
public static java.lang.Object evaluateComposite(Evaluator eval, Page page, java.lang.Object expr)
Evaluates the composite expression parsed byparseComposite(java.lang.String, java.lang.Class, int)against a page.
-
-