jaxx.runtime.decorator
Class JXPathDecorator<O>
java.lang.Object
jaxx.runtime.decorator.Decorator<O>
jaxx.runtime.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 = DecoratorUtils.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:
- 1.7.2 (was previously
jaxx.runtime.JXPathDecorator)
- Author:
- chemit
- See Also:
Decorator,
Serialized Form
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 © 2008-2010 CodeLutin. All Rights Reserved.