jaxx.runtime
Class JXPathDecorator<O>
java.lang.Object
jaxx.runtime.Decorator<O>
jaxx.runtime.JXPathDecorator<O>
- Type Parameters:
O - type of data
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- MultiJXPathDecorator
public class JXPathDecorator<O>
- extends Decorator<O>
JXPath decorator based on String.format(String, Object[]) method.
To use it, give to him a expression where all jxpath to apply on bean are boxed in ${}.
After the jxpath token you must specifiy the formatter to apply of the jxpath token.
For example :
Decorator<Object> d = JXPathDecorator.newDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
assert "expr = %1$s" == d.getExpression();
assert 1 == d.getNbToken();
assert java.util.Arrays.asList("expression") == d.getTokens();
assert "expr = %1$s" == d.toString(d);
- Author:
- chemit
- See Also:
Decorator,
Serialized Form
|
Constructor Summary |
JXPathDecorator(java.lang.Class<O> internalClass,
java.lang.String expression,
boolean creatContext)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
context
protected JXPathDecorator.Context<O> context
- the computed context of the decorator
nbToken
protected int nbToken
- nb jxpath tokens to compute
initialExpression
protected java.lang.String initialExpression
- the initial expression used to compute the decorator context.
JXPathDecorator
public JXPathDecorator(java.lang.Class<O> internalClass,
java.lang.String expression,
boolean creatContext)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
- Throws:
java.lang.IllegalArgumentException
java.lang.NullPointerException
newDecorator
public static <O> JXPathDecorator<O> newDecorator(java.lang.Class<O> internalClass,
java.lang.String expression)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
- Factory method to instanciate a new
JXPathDecorator for the given class O and expression.
- Type Parameters:
O - the generic type of class to be decorated by the new decorator- Parameters:
internalClass - the class of the objects decorated by the new decoratorexpression - the expression to use to decorated objects
- Returns:
- the new instanciated decorator
- Throws:
java.lang.IllegalArgumentException - if the expression is not valid, says:
- a missing right brace was detected.
- a ${ was found in a jxpath token.
java.lang.NullPointerException - if internalClass parameter is null.
sort
public static <O> void sort(JXPathDecorator<O> decorator,
java.util.List<O> datas,
int pos)
- Sort a list of data based on the first token property of a given context
in a given decorator.
- Type Parameters:
O - type of data to sort- Parameters:
decorator - the decorator to use to sortdatas - the list of data to sortpos - the index of context to used in decorator to obtain sorted property.
toString
public java.lang.String toString(java.lang.Object bean)
- Specified by:
toString in class Decorator<O>
- Parameters:
bean - the bean to decorate
- Returns:
- the string value of the given bean
getTokenValue
protected java.lang.Comparable<java.lang.Comparable<?>> getTokenValue(org.apache.commons.jxpath.JXPathContext jxcontext,
java.lang.String token)
getProperty
public java.lang.String getProperty(int pos)
getExpression
public java.lang.String getExpression()
getTokens
public java.lang.String[] getTokens()
getNbToken
public int getNbToken()
getInitialExpression
public java.lang.String getInitialExpression()
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
setContext
public void setContext(JXPathDecorator.Context<O> context)
getComparator
protected java.util.Comparator<O> getComparator(int pos)
createInitialContext
public static <O> JXPathDecorator.Context<O> createInitialContext(java.lang.String expression)
ensureTokenIndex
protected static void ensureTokenIndex(JXPathDecorator<?> decorator,
int pos)
Copyright © 2008-2009 CodeLutin. All Rights Reserved.