org.nuiton.util.decorator
Class JXPathDecorator<O>
java.lang.Object
org.nuiton.util.decorator.Decorator<O>
org.nuiton.util.decorator.JXPathDecorator<O>
- Type Parameters:
O - type of data to decorate
- All Implemented Interfaces:
- 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 = DecoratorUtil.newJXPathDecorator(
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);
- Since:
- 2.3
- Author:
- tchemit
- See Also:
Decorator,
Serialized Form
| Fields inherited from class org.nuiton.util.decorator.Decorator |
type |
context
protected JXPathDecorator.Context<O> context
- the computed context of the decorator
nbToken
protected int nbToken
- nb jxpath tokens to compute
initialExpression
protected String initialExpression
- the initial expression used to compute the decorator context.
JXPathDecorator
protected JXPathDecorator(Class<O> internalClass,
String expression,
JXPathDecorator.Context<O> context)
throws IllegalArgumentException,
NullPointerException
- Throws:
IllegalArgumentException
NullPointerException
toString
public String toString(Object bean)
- Specified by:
toString in class Decorator<O>
- Parameters:
bean - the bean to decorate
- Returns:
- the string value of the given bean
getProperty
public String getProperty(int pos)
getExpression
public String getExpression()
getTokens
public String[] getTokens()
getNbToken
public int getNbToken()
getInitialExpression
public String getInitialExpression()
toString
public String toString()
- Overrides:
toString in class Object
setContext
public void setContext(JXPathDecorator.Context<O> context)
getComparator
protected Comparator<O> getComparator(int pos)
getTokenValue
protected Comparable<Comparable<?>> getTokenValue(org.apache.commons.jxpath.JXPathContext jxcontext,
String token)
ensureTokenIndex
protected static void ensureTokenIndex(JXPathDecorator<?> decorator,
int pos)
Copyright © 2004-2011 CodeLutin. All Rights Reserved.