jaxx.runtime.decorator
Class JXPathDecorator<O>

java.lang.Object
  extended by jaxx.runtime.decorator.Decorator<O>
      extended by jaxx.runtime.decorator.JXPathDecorator<O>
Type Parameters:
O - type of data to decorate
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 = 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

Nested Class Summary
static class JXPathDecorator.Context<O>
           
static class JXPathDecorator.JXPathComparator<O>
           
 
Field Summary
protected  JXPathDecorator.Context<O> context
          the computed context of the decorator
protected  java.lang.String initialExpression
          the initial expression used to compute the decorator context.
protected  int nbToken
          nb jxpath tokens to compute
 
Fields inherited from class jaxx.runtime.decorator.Decorator
internalClass
 
Constructor Summary
protected JXPathDecorator(java.lang.Class<O> internalClass, java.lang.String expression, JXPathDecorator.Context<O> context)
           
 
Method Summary
protected static void ensureTokenIndex(JXPathDecorator<?> decorator, int pos)
           
protected  java.util.Comparator<O> getComparator(int pos)
           
 java.lang.String getExpression()
           
 java.lang.String getInitialExpression()
           
 int getNbToken()
           
 java.lang.String getProperty(int pos)
           
 java.lang.String[] getTokens()
           
protected  java.lang.Comparable<java.lang.Comparable<?>> getTokenValue(org.apache.commons.jxpath.JXPathContext jxcontext, java.lang.String token)
           
 void setContext(JXPathDecorator.Context<O> context)
           
 java.lang.String toString()
           
 java.lang.String toString(java.lang.Object bean)
           
 
Methods inherited from class jaxx.runtime.decorator.Decorator
getInternalClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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.

Constructor Detail

JXPathDecorator

protected JXPathDecorator(java.lang.Class<O> internalClass,
                          java.lang.String expression,
                          JXPathDecorator.Context<O> context)
                   throws java.lang.IllegalArgumentException,
                          java.lang.NullPointerException
Throws:
java.lang.IllegalArgumentException
java.lang.NullPointerException
Method Detail

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

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)

getTokenValue

protected java.lang.Comparable<java.lang.Comparable<?>> getTokenValue(org.apache.commons.jxpath.JXPathContext jxcontext,
                                                                      java.lang.String token)

ensureTokenIndex

protected static void ensureTokenIndex(JXPathDecorator<?> decorator,
                                       int pos)


Copyright © 2008-2009 CodeLutin. All Rights Reserved.