jaxx.runtime.decorator
Class DecoratorUtils

java.lang.Object
  extended by jaxx.runtime.decorator.DecoratorUtils

public class DecoratorUtils
extends java.lang.Object

Some usefull methods on Decorator to create, and sort data with decorators.

To create a new decorator, use one of the methods :

To sort a list of data, using a JXPathDecorator, use the method sort(JXPathDecorator, List, int).

Since:
1.7.2 (was previously jaxx.runtime.DecoratorUtils)
Author:
tony

Constructor Summary
DecoratorUtils()
           
 
Method Summary
static
<O> JXPathDecorator.Context<O>
createJXPathContext(java.lang.String expression)
           
static
<O> JXPathDecorator.Context<O>[]
createMultiJXPathContext(java.lang.String expression, java.lang.String separator, java.lang.String separatorReplacement)
           
protected static
<O> JXPathDecorator.Context<O>[]
newInstance(int size)
           
static
<O> JXPathDecorator<O>
newJXPathDecorator(java.lang.Class<O> internalClass, java.lang.String expression)
          Factory method to instanciate a new JXPathDecorator for the given class internalClass and expression.
static
<O> MultiJXPathDecorator<O>
newMultiJXPathDecorator(java.lang.Class<O> internalClass, java.lang.String expression, java.lang.String separator)
           
static
<O> MultiJXPathDecorator<O>
newMultiJXPathDecorator(java.lang.Class<O> internalClass, java.lang.String expression, java.lang.String separator, java.lang.String separatorReplacement)
           
static
<O> PropertyDecorator<O>
newPropertyDecorator(java.lang.Class<O> internalClass, java.lang.String property)
          Factory method to instanciate a new PropertyDecorator for the given class internlaClass and a readable property name.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecoratorUtils

public DecoratorUtils()
Method Detail

newPropertyDecorator

public static <O> PropertyDecorator<O> newPropertyDecorator(java.lang.Class<O> internalClass,
                                                            java.lang.String property)
                                                 throws java.lang.IllegalArgumentException,
                                                        java.lang.NullPointerException
Factory method to instanciate a new PropertyDecorator for the given class internlaClass and a readable property name.

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 decorator
property - the property
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.

newJXPathDecorator

public static <O> JXPathDecorator<O> newJXPathDecorator(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 internalClass 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 decorator
expression - 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.

newMultiJXPathDecorator

public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(java.lang.Class<O> internalClass,
                                                                  java.lang.String expression,
                                                                  java.lang.String separator)
                                                       throws java.lang.IllegalArgumentException,
                                                              java.lang.NullPointerException
Throws:
java.lang.IllegalArgumentException
java.lang.NullPointerException

newMultiJXPathDecorator

public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(java.lang.Class<O> internalClass,
                                                                  java.lang.String expression,
                                                                  java.lang.String separator,
                                                                  java.lang.String separatorReplacement)
                                                       throws java.lang.IllegalArgumentException,
                                                              java.lang.NullPointerException
Throws:
java.lang.IllegalArgumentException
java.lang.NullPointerException

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 sort
datas - the list of data to sort
pos - the index of context to used in decorator to obtain sorted property.

createJXPathContext

public static <O> JXPathDecorator.Context<O> createJXPathContext(java.lang.String expression)

createMultiJXPathContext

public static <O> JXPathDecorator.Context<O>[] createMultiJXPathContext(java.lang.String expression,
                                                                        java.lang.String separator,
                                                                        java.lang.String separatorReplacement)

newInstance

protected static <O> JXPathDecorator.Context<O>[] newInstance(int size)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.