Author: tchemit Date: 2009-10-30 12:09:43 +0100 (Fri, 30 Oct 2009) New Revision: 1620 Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java Log: Evolution #106: Am?\195?\169lioration de l'api des Decorator Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-29 18:21:10 UTC (rev 1619) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-30 11:09:43 UTC (rev 1620) @@ -26,7 +26,7 @@ import java.util.*; /** - * Some usefull methods on {@link Decorator} to create, decorators and obtain decorators. + * Some usefull methods on {@link Decorator} to create, and sort data with decorators. * <p/> * To create a new decorator, use one of the methods : * <ul> @@ -36,13 +36,6 @@ * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li> * </ul> * <p/> - * <p/> - * To register a new decorator, use the method {@link #register(String, Decorator)}. - * <p/> - * To obtain a registred decorator, use the method {@link #get(String)} - * (get the decorator based on his registred name). or the method {@link #get(Class, String)} - * (get the decorator based on the type of decorator and the registred name). - * <p/> * To sort a list of data, using a {@link JXPathDecorator}, use the method * {@link #sort(JXPathDecorator, List, int)}. * <p/> @@ -53,13 +46,6 @@ public class DecoratorUtils { /** - * Registred decorators. - * @deprecated prefer use a {@link DecoratorProvider} - */ - @Deprecated - protected static List<DecoratorContext<?>> decorators; - - /** * Factory method to instanciate a new {@link PropertyDecorator} for the * given class {@code internlaClass} and a readable property name. * @@ -120,49 +106,7 @@ return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts); } - @Deprecated - public static <T> Decorator<T> get(String context) { - Decorator<T> result = get(null, context); - return result; - } - - @Deprecated - public static <T> Decorator<T> get(Class<T> type, String context) { - DecoratorContext<T> decoratorContext = getDecoratorContext(type, context); - Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator(); - return result; - } - /** - * Register a new decorator in the cache. - * - * @param <T> type of data decorated - * @param context the name decorator - * @param decorator the decorator to register - */ - @Deprecated - public static <T> void register(String context, Decorator<T> decorator) { - - DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context); - - if (result != null) { - throw new IllegalArgumentException("there is an already register decorator " + result); - } - - if (decorators == null) { - decorators = new java.util.ArrayList<DecoratorContext<?>>(); - } - decorators.add(new DecoratorContext<T>(context, decorator)); - } - - @Deprecated - public static void clear() { - if (decorators != null) { - decorators.clear(); - } - } - - /** * Sort a list of data based on the first token property of a given context * in a given decorator. * @@ -189,71 +133,6 @@ } } - @SuppressWarnings({"unchecked"}) - @Deprecated - protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) { - DecoratorContext<T> result = null; - if (decorators != null) { - for (DecoratorContext<?> d : decorators) { - if (type == null) { - if (d.accept(context)) { - result = (DecoratorContext<T>) d; - break; - } - continue; - } - if (d.accept(type, context)) { - result = (DecoratorContext<T>) d; - break; - } - } - } - return result; - } - - @Deprecated - public static class DecoratorContext<T> { - - /** - * the context name of the decorator - */ - final String context; - /** - * the decorator - */ - final Decorator<T> decorator; - - public DecoratorContext(String context, Decorator<T> decorator) { - this.context = context; - this.decorator = decorator; - } - - public String getContext() { - return context; - } - - public Decorator<T> getDecorator() { - return decorator; - } - - public Class<T> getType() { - return decorator.getInternalClass(); - } - - public boolean accept(Class<?> type, String context) { - return getType().isAssignableFrom(type) && accept(context); - } - - public boolean accept(String context) { - return ((this.context == null && context == null) || (this.context != null && this.context.equals(context))); - } - - @Override - public String toString() { - return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">"; - } - } - public static <O> Context<O> createJXPathContext(String expression) { List<String> lTokens = new ArrayList<String>(); StringBuilder buffer = new StringBuilder();