Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
August 2011
- 5 participants
- 40 discussions
r2167 - in trunk: nuiton-profiling/src/license nuiton-utils/src/license nuiton-validator/src/license
by tchemit@users.nuiton.org 18 Aug '11
by tchemit@users.nuiton.org 18 Aug '11
18 Aug '11
Author: tchemit
Date: 2011-08-18 07:42:41 +0200 (Thu, 18 Aug 2011)
New Revision: 2167
Url: http://nuiton.org/repositories/revision/nuiton-utils/2167
Log:
update third-parties
Modified:
trunk/nuiton-profiling/src/license/THIRD-PARTY.properties
trunk/nuiton-utils/src/license/THIRD-PARTY.properties
trunk/nuiton-validator/src/license/THIRD-PARTY.properties
Modified: trunk/nuiton-profiling/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-profiling/src/license/THIRD-PARTY.properties 2011-08-16 23:12:42 UTC (rev 2166)
+++ trunk/nuiton-profiling/src/license/THIRD-PARTY.properties 2011-08-18 05:42:41 UTC (rev 2167)
@@ -1,13 +1,16 @@
-# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - ASM License
# - Apache Software License
# - Apache Software License, Version 2.0
# - BSD License
-# - GNU Lesser General Public License
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Jaxen license
# - Lesser General Public License (LGPL)
+# - Lesser General Public License (LPGL)
+# - Lesser General Public License (LPGL) v 2.1
# - MIT License
# - SAXPath License
# - The Apache Software License, Version 2.0
@@ -15,19 +18,19 @@
# Please fill the missing licenses for dependencies :
#
#
-#Thu Dec 30 11:34:10 CET 2010
-aspectwerkz--aspectwerkz--2.0--jar=GNU Lesser General Public License
-aspectwerkz--aspectwerkz-core--2.0--jar=GNU Lesser General Public License
-aspectwerkz--aspectwerkz-jdk5--2.0--jar=GNU Lesser General Public License
-dom4j--dom4j--1.4--jar=BSD License
-isorelax--isorelax--20020414--jar=MIT License
-jaxen--jaxen--1.0-FCS--jar=Jaxen license
-jrexx--jrexx--1.1.1--jar=Apache Software License
-msv--msv--20020414--jar=BSD License
-org.nuiton.thirdparty--asm--1.5.4-snapshot--jar=ASM License
-org.nuiton.thirdparty--asm-attrs--1.5.4-snapshot--jar=ASM License
-org.nuiton.thirdparty--asm-util--1.5.4-snapshot--jar=ASM License
-qdox--qdox--1.4--jar=Apache Software License, Version 2.0
-relaxngDatatype--relaxngDatatype--20020414--jar=BSD License
-saxpath--saxpath--1.0-FCS--jar=SAXPath License
-trove--trove--1.0.2--jar=Lesser General Public License (LGPL)
+#Thu Aug 18 07:42:25 CEST 2011
+aspectwerkz--aspectwerkz--2.0=GNU Lesser General Public License
+aspectwerkz--aspectwerkz-core--2.0=GNU Lesser General Public License
+aspectwerkz--aspectwerkz-jdk5--2.0=GNU Lesser General Public License
+dom4j--dom4j--1.4=BSD License
+isorelax--isorelax--20020414=MIT License
+jaxen--jaxen--1.0-FCS=Jaxen license
+jrexx--jrexx--1.1.1=Apache Software License
+msv--msv--20020414=BSD License
+org.nuiton.thirdparty--asm--1.5.4-snapshot=ASM License
+org.nuiton.thirdparty--asm-attrs--1.5.4-snapshot=ASM License
+org.nuiton.thirdparty--asm-util--1.5.4-snapshot=ASM License
+qdox--qdox--1.4=Apache Software License, Version 2.0
+relaxngDatatype--relaxngDatatype--20020414=BSD License
+saxpath--saxpath--1.0-FCS=SAXPath License
+trove--trove--1.0.2=Lesser General Public License (LGPL)
Modified: trunk/nuiton-utils/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-utils/src/license/THIRD-PARTY.properties 2011-08-16 23:12:42 UTC (rev 2166)
+++ trunk/nuiton-utils/src/license/THIRD-PARTY.properties 2011-08-18 05:42:41 UTC (rev 2167)
@@ -1,13 +1,18 @@
-# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - BSD License
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Public License Version 1.0
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
+# - Lesser General Public License (LPGL)
+# - Lesser General Public License (LPGL) v 2.1
+# - MIT License
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Wed Jan 26 17:11:25 CET 2011
-commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+#Thu Aug 18 07:41:51 CEST 2011
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
Modified: trunk/nuiton-validator/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/nuiton-validator/src/license/THIRD-PARTY.properties 2011-08-16 23:12:42 UTC (rev 2166)
+++ trunk/nuiton-validator/src/license/THIRD-PARTY.properties 2011-08-18 05:42:41 UTC (rev 2167)
@@ -2,19 +2,23 @@
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - BSD License
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Public License Version 1.0
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - Lesser General Public License v2.1,Mozilla Public License 1.1 (MPL)
+# - MIT License
# - The Apache Software License, Version 2.0
+# - http://asm.ow2.org/license.html
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Sun Jul 31 15:22:20 CEST 2011
-asm--asm--3.1--jar=http\://asm.ow2.org/license.html
-asm--asm-commons--3.1--jar=http\://asm.ow2.org/license.html
-asm--asm-tree--3.1--jar=http\://asm.ow2.org/license.html
-commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
-javassist--javassist--3.8.0.GA--jar=Lesser General Public License v2.1,Mozilla Public License 1.1 (MPL)
+#Thu Aug 18 07:42:15 CEST 2011
+asm--asm--3.1=http\://asm.ow2.org/license.html
+asm--asm-commons--3.1=http\://asm.ow2.org/license.html
+asm--asm-tree--3.1=http\://asm.ow2.org/license.html
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+javassist--javassist--3.8.0.GA=Lesser General Public License v2.1,Mozilla Public License 1.1 (MPL)
1
0
Author: tchemit
Date: 2011-08-17 01:12:42 +0200 (Wed, 17 Aug 2011)
New Revision: 2166
Url: http://nuiton.org/repositories/revision/nuiton-utils/2166
Log:
remove snapshot dependecy on license-m-p
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-16 23:11:55 UTC (rev 2165)
+++ trunk/pom.xml 2011-08-16 23:12:42 UTC (rev 2166)
@@ -182,7 +182,6 @@
<properties>
<projectId>nuiton-utils</projectId>
- <licensePluginVersion>1.0-SNAPSHOT</licensePluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<aspectwerkzVersion>2.0</aspectwerkzVersion>
<xworkVersion>2.2.3</xworkVersion>
1
0
Author: tchemit
Date: 2011-08-17 01:11:55 +0200 (Wed, 17 Aug 2011)
New Revision: 2165
Url: http://nuiton.org/repositories/revision/nuiton-utils/2165
Log:
Update mavenpom4redmineAndCentral to 3.0.1.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-04 15:46:36 UTC (rev 2164)
+++ trunk/pom.xml 2011-08-16 23:11:55 UTC (rev 2165)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.0</version>
+ <version>3.0.1</version>
</parent>
<artifactId>nuiton-utils-parent</artifactId>
@@ -182,7 +182,7 @@
<properties>
<projectId>nuiton-utils</projectId>
-
+ <licensePluginVersion>1.0-SNAPSHOT</licensePluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<aspectwerkzVersion>2.0</aspectwerkzVersion>
<xworkVersion>2.2.3</xworkVersion>
1
0
Author: tchemit
Date: 2011-08-04 17:46:36 +0200 (Thu, 04 Aug 2011)
New Revision: 2164
Url: http://nuiton.org/repositories/revision/nuiton-utils/2164
Log:
Evolution #1660: Updates to i18n 2.4.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-04 13:37:03 UTC (rev 2163)
+++ trunk/pom.xml 2011-08-04 15:46:36 UTC (rev 2164)
@@ -183,7 +183,7 @@
<projectId>nuiton-utils</projectId>
- <nuitonI18nVersion>2.4</nuitonI18nVersion>
+ <nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<aspectwerkzVersion>2.0</aspectwerkzVersion>
<xworkVersion>2.2.3</xworkVersion>
1
0
r2163 - in trunk/nuiton-utils/src: main/java/org/nuiton/util/decorator test/java/org/nuiton/util/decorator
by tchemit@users.nuiton.org 04 Aug '11
by tchemit@users.nuiton.org 04 Aug '11
04 Aug '11
Author: tchemit
Date: 2011-08-04 15:37:03 +0200 (Thu, 04 Aug 2011)
New Revision: 2163
Url: http://nuiton.org/repositories/revision/nuiton-utils/2163
Log:
use getType instead of getInternalClass
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-04 12:48:03 UTC (rev 2162)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-04 13:37:03 UTC (rev 2163)
@@ -245,7 +245,7 @@
* Register a new decorator in the cache of the provider.
*
* @param <T> type of data decorated
- * @param locale
+ * @param locale the given locale to use for this decorator
* @param context the name decorator
* @param decorator the decorator to register
*/
@@ -256,7 +256,7 @@
// obtain the decorator context
DecoratorContext<?> result =
getDecoratorContext(locale,
- decorator.getInternalClass(),
+ decorator.getType(),
context,
false
);
@@ -297,7 +297,7 @@
}
public Class<T> getType() {
- return decorator.getInternalClass();
+ return decorator.getType();
}
public boolean accept(Class<?> type, String context) {
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-04 12:48:03 UTC (rev 2162)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-04 13:37:03 UTC (rev 2163)
@@ -179,7 +179,7 @@
// obtain the decorator context
DecoratorContext<?> result =
- getDecoratorContext(decorator.getInternalClass(), context);
+ getDecoratorContext(decorator.getType(), context);
if (result != null) {
throw new IllegalArgumentException(
@@ -246,7 +246,7 @@
}
public Class<T> getType() {
- return decorator.getInternalClass();
+ return decorator.getType();
}
public boolean accept(Class<?> type, String context) {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-04 12:48:03 UTC (rev 2162)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-04 13:37:03 UTC (rev 2163)
@@ -157,7 +157,7 @@
DecoratorProvider provider = new MyDummyDecoratorProvider();
provider.registerMultiJXPathDecorator(MultiJXPathDecorator.class, "(${expression}$s)#${nbToken}$d", "#", " - ");
- decorator = (MultiJXPathDecorator<?>) provider.getDecorator(MultiJXPathDecorator.class);
+ decorator = (MultiJXPathDecorator<?>) provider.getDecoratorByType(MultiJXPathDecorator.class);
assertEquals("(%1$s) - %2$d", decorator.getExpression());
assertTokens("expression", "nbToken");
1
0
r2162 - in trunk/nuiton-utils/src: main/java/org/nuiton/util/decorator test/java/org/nuiton/util/decorator
by tchemit@users.nuiton.org 04 Aug '11
by tchemit@users.nuiton.org 04 Aug '11
04 Aug '11
Author: tchemit
Date: 2011-08-04 14:48:03 +0200 (Thu, 04 Aug 2011)
New Revision: 2162
Url: http://nuiton.org/repositories/revision/nuiton-utils/2162
Log:
Evolution #1643: New decorator api (from jaxx-runtime project)
Added:
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtil.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/package-info.java
Removed:
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java
Modified:
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/Decorator.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/Decorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/Decorator.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/Decorator.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -29,22 +29,22 @@
/**
* A simple contract to define a String decorator on any java object.
*
+ * @param <O> the type of data to decorate
* @author tchemit <chemit(a)codelutin.com>
- * @param <O> the type of data to decorate
- * @since 2.2.1
+ * @since 2.3
*/
public abstract class Decorator<O> implements Serializable {
private static final long serialVersionUID = -1L;
/** Type of the data to decorate */
- protected final Class<O> internalClass;
+ protected final Class<O> type;
- public Decorator(Class<O> internalClass) throws NullPointerException {
- if (internalClass == null) {
- throw new NullPointerException("internalClass can not be null.");
+ public Decorator(Class<O> type) throws NullPointerException {
+ if (type == null) {
+ throw new NullPointerException("type can not be null.");
}
- this.internalClass = internalClass;
+ this.type = type;
}
/**
@@ -53,7 +53,16 @@
*/
public abstract String toString(Object bean);
+ public Class<O> getType() {
+ return type;
+ }
+
+ /**
+ * @return the internal type of object that can be decorated by this decorator.
+ * @deprecated is remplaced by {@link #getType()} and will be removed soon
+ */
+ @Deprecated
public Class<O> getInternalClass() {
- return internalClass;
+ return getType();
}
}
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -44,7 +44,7 @@
* <p/>
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public abstract class DecoratorMulti18nProvider {
@@ -96,7 +96,7 @@
O object,
String name) {
Class<O> k = (Class<O>) object.getClass();
- return getDecorator(locale, k, name);
+ return getDecoratorByType(locale, k, name);
}
/**
@@ -107,9 +107,9 @@
* @param <O> type of decorated object
* @return the decorator or {@code null} if not found
*/
- public <O> Decorator<O> getDecorator(Locale locale,
- Class<O> type) {
- return getDecorator(locale, type, null);
+ public <O> Decorator<O> getDecoratorByType(Locale locale,
+ Class<O> type) {
+ return getDecoratorByType(locale, type, null);
}
/**
@@ -122,9 +122,9 @@
* @param <O> type of decorated object
* @return the decorator or {@code null} if not found
*/
- public <O> Decorator<O> getDecorator(Locale locale,
- Class<O> type,
- String name) {
+ public <O> Decorator<O> getDecoratorByType(Locale locale,
+ Class<O> type,
+ String name) {
DecoratorContext<O> d = getDecoratorContext(locale, type, name, true);
return d == null ? null : d.getDecorator();
}
@@ -211,7 +211,7 @@
String name,
String expression) {
Decorator<?> decorator =
- DecoratorUtils.newPropertyDecorator(klass, expression);
+ DecoratorUtil.newPropertyDecorator(klass, expression);
registerDecorator(locale, name, decorator);
}
@@ -220,7 +220,7 @@
String name,
String expression) {
Decorator<?> decorator =
- DecoratorUtils.newJXPathDecorator(klass, expression);
+ DecoratorUtil.newJXPathDecorator(klass, expression);
registerDecorator(locale, name, decorator);
}
@@ -230,7 +230,7 @@
String expression,
String separator,
String separatorReplacement) {
- Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator(
+ Decorator<?> decorator = DecoratorUtil.newMultiJXPathDecorator(
klass, expression, separator, separatorReplacement
);
registerDecorator(locale, name, decorator);
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -40,7 +40,7 @@
* <p/>
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public abstract class DecoratorProvider {
@@ -81,7 +81,7 @@
@SuppressWarnings({"unchecked"})
public <O> Decorator<O> getDecorator(O object, String name) {
Class<O> k = (Class<O>) object.getClass();
- return getDecorator(k, name);
+ return getDecoratorByType(k, name);
}
/**
@@ -91,8 +91,8 @@
* @param <O> type of decorated object
* @return the decorator or {@code null} if not found
*/
- public <O> Decorator<O> getDecorator(Class<O> type) {
- return getDecorator(type, null);
+ public <O> Decorator<O> getDecoratorByType(Class<O> type) {
+ return getDecoratorByType(type, null);
}
/**
@@ -103,7 +103,7 @@
* @param <O> type of decorated object
* @return the decorator or {@code null} if not found
*/
- public <O> Decorator<O> getDecorator(Class<O> type, String name) {
+ public <O> Decorator<O> getDecoratorByType(Class<O> type, String name) {
DecoratorContext<O> d = getDecoratorContext(type, name);
return d == null ? null : d.getDecorator();
}
@@ -140,7 +140,7 @@
String name,
String expression) {
Decorator<?> decorator =
- DecoratorUtils.newPropertyDecorator(klass, expression);
+ DecoratorUtil.newPropertyDecorator(klass, expression);
registerDecorator(name, decorator);
}
@@ -148,7 +148,7 @@
String name,
String expression) {
Decorator<?> decorator =
- DecoratorUtils.newJXPathDecorator(klass, expression);
+ DecoratorUtil.newJXPathDecorator(klass, expression);
registerDecorator(name, decorator);
}
@@ -157,7 +157,7 @@
String expression,
String separator,
String separatorReplacement) {
- Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator(
+ Decorator<?> decorator = DecoratorUtil.newMultiJXPathDecorator(
klass, expression, separator, separatorReplacement
);
registerDecorator(name, decorator);
Copied: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtil.java (from rev 2160, trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java)
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtil.java (rev 0)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtil.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -0,0 +1,300 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Utils
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.util.decorator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.JXPathDecorator.Context;
+import org.nuiton.util.decorator.JXPathDecorator.JXPathComparator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * 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> <li>{@link
+ * #newPropertyDecorator(Class, String)}</li> <li>{@link
+ * #newJXPathDecorator(Class, String)}</li> <li>
+ * {@link #newMultiJXPathDecorator(Class, String, String)})</li>
+ * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li>
+ * </ul>
+ * <p/>
+ * To sort a list of data, using a {@link JXPathDecorator}, use the method
+ * {@link #sort(JXPathDecorator, List, int)}.
+ * <p/>
+ *
+ * @author tchemit <chemit(a)codelutiln.com>
+ * @since 2.3
+ */
+public class DecoratorUtil {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(DecoratorUtil.class);
+
+
+ /**
+ * Factory method to instanciate a new {@link PropertyDecorator} for the
+ * given class {@code internlaClass} and a readable property name.
+ *
+ * @param type the class of the objects decorated by the new
+ * decorator
+ * @param property the property
+ * @param <O> the generic type of class to be decorated by the new
+ * decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if type parameter is null.
+ */
+ public static <O> PropertyDecorator<O> newPropertyDecorator(
+ Class<O> type,
+ String property)
+ throws IllegalArgumentException, NullPointerException {
+ return new PropertyDecorator<O>(type, property);
+ }
+
+ /**
+ * Factory method to instanciate a new {@link JXPathDecorator} for the given
+ * class {@code internalClass} and expression.
+ *
+ * @param type the class of the objects decorated by the new
+ * decorator
+ * @param expression the expression to use to decorated objects
+ * @param <O> the generic type of class to be decorated by the new
+ * decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if type parameter is null.
+ */
+ public static <O> JXPathDecorator<O> newJXPathDecorator(
+ Class<O> type,
+ String expression)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O> context = createJXPathContext(expression);
+ return new JXPathDecorator<O>(type, expression, context);
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(
+ Class<O> type,
+ String expression,
+ String separator)
+ throws IllegalArgumentException, NullPointerException {
+
+ MultiJXPathDecorator<O> decorator = newMultiJXPathDecorator(
+ type,
+ expression,
+ separator,
+ separator);
+ return decorator;
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(
+ Class<O> type,
+ String expression,
+ String separator,
+ String separatorReplacement)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O>[] contexts = createMultiJXPathContext(
+ expression,
+ separator,
+ separatorReplacement);
+
+ return new MultiJXPathDecorator<O>(
+ type,
+ expression,
+ separator,
+ separatorReplacement,
+ contexts);
+ }
+
+ /**
+ * Sort a list of data based on the first token property of a given context
+ * in a given decorator.
+ *
+ * @param <O> type of data to sort
+ * @param decorator the decorator to use to sort
+ * @param datas the list of data to sort
+ * @param pos the index of context to used in decorator to obtain
+ * sorted property.
+ */
+ public static <O> void sort(JXPathDecorator<O> decorator,
+ List<O> datas,
+ int pos) {
+ sort(decorator, datas, pos, false);
+ }
+
+ /**
+ * Sort a list of data based on the first token property of a given context
+ * in a given decorator.
+ *
+ * @param <O> type of data to sort
+ * @param decorator the decorator to use to sort
+ * @param datas the list of data to sort
+ * @param pos the index of context to used in decorator to obtain
+ * sorted property.
+ * @param reverse flag to sort in reverse order if sets to {@code true}
+ * @since 2.2
+ */
+ public static <O> void sort(JXPathDecorator<O> decorator,
+ List<O> datas,
+ int pos,
+ boolean reverse) {
+ Comparator<O> c = null;
+ boolean cachedComparator = false;
+ try {
+ c = decorator.getComparator(pos);
+ cachedComparator = c instanceof JXPathComparator<?>;
+
+ if (cachedComparator) {
+ ((JXPathComparator<O>) c).init(decorator, datas);
+ }
+ Collections.sort(datas, c);
+ if (reverse) {
+
+ // reverse order
+ Collections.reverse(datas);
+ }
+ } finally {
+ if (cachedComparator) {
+ ((JXPathComparator<?>) c).clear();
+ }
+ }
+ }
+
+ public static <O> Context<O> createJXPathContext(String expression) {
+ List<String> lTokens = new ArrayList<String>();
+ StringBuilder buffer = new StringBuilder();
+ int size = expression.length();
+ int end = -1;
+ int start;
+ while ((start = expression.indexOf("${", end + 1)) > -1) {
+ if (start > end + 1) {
+
+ // prefix of next jxpath token
+ buffer.append(expression.substring(end + 1, start));
+ }
+
+ // seek end of jxpath
+ end = expression.indexOf("}", start + 1);
+ if (end == -1) {
+ throw new IllegalArgumentException(
+ "could not find the rigth brace starting at car " +
+ start + " : " + expression.substring(start + 2));
+ }
+ String jxpath = expression.substring(start + 2, end);
+
+ // not allowed ${ inside a jxpath token
+ if (jxpath.contains("${")) {
+ throw new IllegalArgumentException(
+ "could not find a ${ inside a jxpath expression at " +
+ "car " + (start + 2) + " : " + jxpath);
+ }
+
+ // save the jxpath token
+ lTokens.add(jxpath);
+
+ // replace jxpath token in expresion with a string format variable
+ buffer.append('%').append(lTokens.size());
+ }
+ if (size > end + 1) {
+
+ // suffix after end jxpath (or all expression if no jxpath)
+ buffer.append(expression.substring(end + 1));
+ }
+ String[] tokens = lTokens.toArray(new String[lTokens.size()]);
+ return new Context<O>(buffer.toString(), tokens);
+ }
+
+ public static <O> Context<O>[] createMultiJXPathContext(
+ String expression,
+ String separator,
+ String separatorReplacement) {
+ int sep = expression.indexOf(separator);
+ if (sep == -1) {
+ Context<O>[] result = newInstance(1);
+ result[0] = createJXPathContext(expression);
+ return result;
+ }
+
+ List<String> tokens = new ArrayList<String>();
+ StringTokenizer stk = new StringTokenizer(expression, separator);
+ while (stk.hasMoreTokens()) {
+ tokens.add(stk.nextToken());
+ }
+
+ int nbTokens = tokens.size();
+ Context<O>[] contexts = newInstance(nbTokens);
+ if (log.isDebugEnabled()) {
+ log.debug("Will prepare " + nbTokens + " contexts from [" + expression + "]");
+ }
+ for (int i = 0; i < nbTokens; i++) {
+ StringBuilder buffer = new StringBuilder(expression.length());
+ for (int j = 0; j < nbTokens; j++) {
+ int index = (i + j) % nbTokens;
+ String str = tokens.get(index);
+
+ //replace all '%(index+1)$' pattern with '%(j+1)$'
+ Pattern p = Pattern.compile("\\%(" + (index + 1) + ")\\$");
+ Matcher matcher = p.matcher(str);
+ String safeStr = matcher.replaceAll("\\%" + (j + 1) + "\\$");
+
+ if (log.isDebugEnabled()) {
+ log.debug("[" + (index + 1) + "-->" + (j + 1) + "] " + str +
+ " transformed to " + safeStr);
+ }
+ buffer.append(separatorReplacement).append(safeStr);
+ }
+ String expr = buffer.substring(separatorReplacement.length());
+ if (log.isDebugEnabled()) {
+ log.debug("context [" + i + "] : " + expr);
+ }
+ contexts[i] = createJXPathContext(
+ expr);
+ }
+ return contexts;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static <O> Context<O>[] newInstance(int size) {
+ // fixme how to instanciate a typed array with no checking warning ?
+ return new Context[size];
+ }
+}
Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -1,300 +0,0 @@
-/*
- * #%L
- * Nuiton Utils :: Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.util.decorator;
-
-import org.nuiton.util.decorator.JXPathDecorator.Context;
-import org.nuiton.util.decorator.JXPathDecorator.JXPathComparator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * 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> <li>{@link
- * #newPropertyDecorator(Class, String)}</li> <li>{@link
- * #newJXPathDecorator(Class, String)}</li> <li>
- * {@link #newMultiJXPathDecorator(Class, String, String)})</li>
- * <li>{@link #newMultiJXPathDecorator(Class, String,String, String)})</li>
- * </ul>
- * <p/>
- * To sort a list of data, using a {@link JXPathDecorator}, use the method
- * {@link #sort(JXPathDecorator, List, int)}.
- * <p/>
- *
- * @author tchemit <chemit(a)codelutiln.com>
- * @since 2.2.1
- */
-public class DecoratorUtils {
-
- /** Logger */
- private static final Log log = LogFactory.getLog(DecoratorUtils.class);
-
-
- /**
- * Factory method to instanciate a new {@link PropertyDecorator} for the
- * given class {@code internlaClass} and a readable property name.
- *
- * @param internalClass the class of the objects decorated by the new
- * decorator
- * @param property the property
- * @param <O> the generic type of class to be decorated by the new
- * decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> PropertyDecorator<O> newPropertyDecorator(
- Class<O> internalClass,
- String property)
- throws IllegalArgumentException, NullPointerException {
- return new PropertyDecorator<O>(internalClass, property);
- }
-
- /**
- * Factory method to instanciate a new {@link JXPathDecorator} for the given
- * class {@code internalClass} and expression.
- *
- * @param internalClass the class of the objects decorated by the new
- * decorator
- * @param expression the expression to use to decorated objects
- * @param <O> the generic type of class to be decorated by the new
- * decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> JXPathDecorator<O> newJXPathDecorator(
- Class<O> internalClass,
- String expression)
- throws IllegalArgumentException, NullPointerException {
-
- Context<O> context = createJXPathContext(expression);
- return new JXPathDecorator<O>(internalClass, expression, context);
- }
-
- public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(
- Class<O> internalClass,
- String expression,
- String separator)
- throws IllegalArgumentException, NullPointerException {
-
- MultiJXPathDecorator<O> decorator = newMultiJXPathDecorator(
- internalClass,
- expression,
- separator,
- separator);
- return decorator;
- }
-
- public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(
- Class<O> internalClass,
- String expression,
- String separator,
- String separatorReplacement)
- throws IllegalArgumentException, NullPointerException {
-
- Context<O>[] contexts = createMultiJXPathContext(
- expression,
- separator,
- separatorReplacement);
-
- return new MultiJXPathDecorator<O>(
- internalClass,
- expression,
- separator,
- separatorReplacement,
- contexts);
- }
-
- /**
- * Sort a list of data based on the first token property of a given context
- * in a given decorator.
- *
- * @param <O> type of data to sort
- * @param decorator the decorator to use to sort
- * @param datas the list of data to sort
- * @param pos the index of context to used in decorator to obtain
- * sorted property.
- */
- public static <O> void sort(JXPathDecorator<O> decorator,
- List<O> datas,
- int pos) {
- sort(decorator, datas, pos, false);
- }
-
- /**
- * Sort a list of data based on the first token property of a given context
- * in a given decorator.
- *
- * @param <O> type of data to sort
- * @param decorator the decorator to use to sort
- * @param datas the list of data to sort
- * @param pos the index of context to used in decorator to obtain
- * sorted property.
- * @param reverse flag to sort in reverse order if sets to {@code true}
- * @since 2.2
- */
- public static <O> void sort(JXPathDecorator<O> decorator,
- List<O> datas,
- int pos,
- boolean reverse) {
- Comparator<O> c = null;
- boolean cachedComparator = false;
- try {
- c = decorator.getComparator(pos);
- cachedComparator = c instanceof JXPathComparator<?>;
-
- if (cachedComparator) {
- ((JXPathComparator<O>) c).init(decorator, datas);
- }
- Collections.sort(datas, c);
- if (reverse) {
-
- // reverse order
- Collections.reverse(datas);
- }
- } finally {
- if (cachedComparator) {
- ((JXPathComparator<?>) c).clear();
- }
- }
- }
-
- public static <O> Context<O> createJXPathContext(String expression) {
- List<String> lTokens = new ArrayList<String>();
- StringBuilder buffer = new StringBuilder();
- int size = expression.length();
- int end = -1;
- int start;
- while ((start = expression.indexOf("${", end + 1)) > -1) {
- if (start > end + 1) {
-
- // prefix of next jxpath token
- buffer.append(expression.substring(end + 1, start));
- }
-
- // seek end of jxpath
- end = expression.indexOf("}", start + 1);
- if (end == -1) {
- throw new IllegalArgumentException(
- "could not find the rigth brace starting at car " +
- start + " : " + expression.substring(start + 2));
- }
- String jxpath = expression.substring(start + 2, end);
-
- // not allowed ${ inside a jxpath token
- if (jxpath.contains("${")) {
- throw new IllegalArgumentException(
- "could not find a ${ inside a jxpath expression at " +
- "car " + (start + 2) + " : " + jxpath);
- }
-
- // save the jxpath token
- lTokens.add(jxpath);
-
- // replace jxpath token in expresion with a string format variable
- buffer.append('%').append(lTokens.size());
- }
- if (size > end + 1) {
-
- // suffix after end jxpath (or all expression if no jxpath)
- buffer.append(expression.substring(end + 1));
- }
- String[] tokens = lTokens.toArray(new String[lTokens.size()]);
- return new Context<O>(buffer.toString(), tokens);
- }
-
- public static <O> Context<O>[] createMultiJXPathContext(
- String expression,
- String separator,
- String separatorReplacement) {
- int sep = expression.indexOf(separator);
- if (sep == -1) {
- Context<O>[] result = newInstance(1);
- result[0] = createJXPathContext(expression);
- return result;
- }
-
- List<String> tokens = new ArrayList<String>();
- StringTokenizer stk = new StringTokenizer(expression, separator);
- while (stk.hasMoreTokens()) {
- tokens.add(stk.nextToken());
- }
-
- int nbTokens = tokens.size();
- Context<O>[] contexts = newInstance(nbTokens);
- if (log.isDebugEnabled()) {
- log.debug("Will prepare " + nbTokens + " contexts from [" + expression + "]");
- }
- for (int i = 0; i < nbTokens; i++) {
- StringBuilder buffer = new StringBuilder(expression.length());
- for (int j = 0; j < nbTokens; j++) {
- int index = (i + j) % nbTokens;
- String str = tokens.get(index);
-
- //replace all '%(index+1)$' pattern with '%(j+1)$'
- Pattern p = Pattern.compile("\\%(" + (index + 1) + ")\\$");
- Matcher matcher = p.matcher(str);
- String safeStr = matcher.replaceAll("\\%" + (j + 1) + "\\$");
-
- if (log.isDebugEnabled()) {
- log.debug("[" + (index + 1) + "-->" + (j + 1) + "] " + str +
- " transformed to " + safeStr);
- }
- buffer.append(separatorReplacement).append(safeStr);
- }
- String expr = buffer.substring(separatorReplacement.length());
- if (log.isDebugEnabled()) {
- log.debug("context [" + i + "] : " + expr);
- }
- contexts[i] = createJXPathContext(
- expr);
- }
- return contexts;
- }
-
- @SuppressWarnings("unchecked")
- protected static <O> Context<O>[] newInstance(int size) {
- // fixme how to instanciate a typed array with no checking warning ?
- return new Context[size];
- }
-}
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -46,7 +46,7 @@
* <p/>
* For example :
* <pre>
- * Decorator<Object> d = DecoratorUtils.newJXPathDecorator(
+ * Decorator<Object> d = DecoratorUtil.newJXPathDecorator(
* JXPathDecorator.class,"expr = ${expressions}$s");
* assert "expr = %1$s" == d.getExpression();
* assert 1 == d.getNbToken();
@@ -57,7 +57,7 @@
* @param <O> type of data to decorate
* @author tchemit <chemit(a)codelutin.com>
* @see Decorator
- * @since 2.2.1
+ * @since 2.3
*/
public class JXPathDecorator<O> extends Decorator<O> {
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -52,7 +52,7 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see DynamicPropertyHandler
- * @since 2.2.1
+ * @since 2.3
*/
public class MapPropertyHandler implements DynamicPropertyHandler {
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -35,7 +35,7 @@
* @param <O> type of data to decorate
* @author tchemit <chemit(a)codelutin.com>
* @see Decorator
- * @since 2.2.1
+ * @since 2.3
*/
public class MultiJXPathDecorator<O> extends JXPathDecorator<O> {
@@ -83,9 +83,9 @@
expression,
separator,
separatorReplacement,
- DecoratorUtils.<O>createMultiJXPathContext(expression,
- separator,
- separatorReplacement)
+ DecoratorUtil.<O>createMultiJXPathContext(expression,
+ separator,
+ separatorReplacement)
);
}
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -39,13 +39,13 @@
* <p/>
* For example :
* <pre>
- * Decorator<Object> d = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"property");
+ * Decorator<Object> d = DecoratorUtil.newPropertyDecorator(PropertyDecorator.class,"property");
* </pre>
*
+ * @param <O> type of data to decorate
* @author tchemit <chemit(a)codelutin.com>
- * @param <O> type of data to decorate
* @see Decorator
- * @since 2.2.1
+ * @since 2.3
*/
public class PropertyDecorator<O> extends Decorator<O> {
@@ -86,14 +86,14 @@
protected Method getM() {
if (m == null) {
- for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) {
+ for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(getType())) {
if (propertyDescriptor.getName().equals(property)) {
m = propertyDescriptor.getReadMethod();
break;
}
}
if (m == null) {
- throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass);
+ throw new IllegalArgumentException("could not find the property " + property + " in " + getType());
}
}
return m;
Added: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/package-info.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/package-info.java (rev 0)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/package-info.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -0,0 +1,72 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Utils
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+/**
+ *
+ * This package contains a api to do some decoration over any object.
+ *
+ * <h1>Decorator api</h1>
+ * The {@link org.nuiton.util.decorator.Decorator} has an internal state which
+ * is the type of object to decorate and a method to do the decoration :
+ * {@link org.nuiton.util.decorator.Decorator#toString(Object)}.
+ * <p/>
+ * There is some default implementations of a decorator using a simple property,
+ * or more complex one using jxpath mecanisms.
+ *
+ * <h1>DecoratorProvider api</h1>
+ * The {@link org.nuiton.util.decorator.DecoratorProvider} api is there to
+ * provide some decorators for you,
+ *
+ * There is a second one {@link org.nuiton.util.decorator.DecoratorMulti18nProvider}
+ * which take account of a given locale (so can be used in web context for
+ * example).
+ *
+ * User has to fill method
+ * {@link org.nuiton.util.decorator.DecoratorProvider}#loadDecorators()}
+ * or
+ * {@link org.nuiton.util.decorator.DecoratorMulti18nProvider#loadDecorators(Locale)}
+ * to specify which decorators are available.
+ *
+ * Then it can use the provider using the methods {@code getDecorator(XXX)}
+ *
+ * <strong>Note:</strong> Decorator can be contextualized so for a same type of
+ * object we can provide different way of decorating then.
+ *
+ * <h1>DecoratorUtil class</h1>
+ *
+ * This class offers some usefull method to create new decorator via the
+ * {@code newXXX} methods and also some method to sort list of objects using a
+ * decorator.
+ *
+ * <strong>Note: </strong> This api comes from the jaxx-runtime project.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ * @see org.nuiton.util.decorator.Decorator
+ * @see org.nuiton.util.decorator.DecoratorProvider
+ * @see org.nuiton.util.decorator.DecoratorMulti18nProvider
+ */
+package org.nuiton.util.decorator;
+
+import java.util.Locale;
\ No newline at end of file
Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -29,7 +29,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class Data {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -35,7 +35,7 @@
* Tests the {@link DecoratorMulti18nProvider}
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class DecoratorMulti18nProviderTest {
@@ -80,31 +80,31 @@
Decorator<File> fileDecorator = provider.getDecorator(l_fr, f);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("myFile", fileDecorator.toString(f));
Decorator<?> classDecorator;
classDecorator = provider.getDecorator(l_fr, Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File FR", classDecorator.toString(k));
classDecorator = provider.getDecorator(l_en, Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File GB", classDecorator.toString(k));
Decorator<Data> dataDecorator;
dataDecorator = provider.getDecorator(l_fr, d);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name FR", dataDecorator.toString(d));
dataDecorator = provider.getDecorator(l_en, d);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name GB", dataDecorator.toString(d));
}
@@ -117,19 +117,19 @@
Decorator<File> fileDecorator = provider.getDecorator(l_fr, f, BY_NAME);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("null", fileDecorator.toString(f));
Decorator<Class> classDecorator;
- classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME);
+ classDecorator = provider.getDecoratorByType(l_fr, Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File FR", classDecorator.toString(k));
- classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME);
+ classDecorator = provider.getDecoratorByType(l_en, Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File GB", classDecorator.toString(k));
@@ -143,12 +143,12 @@
dataDecorator = provider.getDecorator(l_fr, d, BY_POS);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0 FR", dataDecorator.toString(d));
dataDecorator = provider.getDecorator(l_en, d, BY_POS);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0 GB", dataDecorator.toString(d));
}
@@ -159,33 +159,33 @@
Data d = new Data(0, "name");
Class<?> k = File.class;
- Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class);
+ Decorator<File> fileDecorator = provider.getDecoratorByType(l_fr, File.class);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("myFile", fileDecorator.toString(f));
Decorator<Class> classDecorator;
- classDecorator = provider.getDecorator(l_fr, Class.class);
+ classDecorator = provider.getDecoratorByType(l_fr, Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File FR", classDecorator.toString(k));
- classDecorator = provider.getDecorator(l_en, Class.class);
+ classDecorator = provider.getDecoratorByType(l_en, Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File GB", classDecorator.toString(k));
Decorator<Data> dataDecorator;
- dataDecorator = provider.getDecorator(l_fr, Data.class);
+ dataDecorator = provider.getDecoratorByType(l_fr, Data.class);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name FR", dataDecorator.toString(d));
- dataDecorator = provider.getDecorator(l_en, Data.class);
+ dataDecorator = provider.getDecoratorByType(l_en, Data.class);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name GB", dataDecorator.toString(d));
}
@@ -195,33 +195,33 @@
Data d = new Data(0, "name");
Class<?> k = File.class;
- Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class, BY_NAME);
+ Decorator<File> fileDecorator = provider.getDecoratorByType(l_fr, File.class, BY_NAME);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("null", fileDecorator.toString(f));
Decorator<Class> classDecorator;
- classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME);
+ classDecorator = provider.getDecoratorByType(l_fr, Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File FR", classDecorator.toString(k));
- classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME);
+ classDecorator = provider.getDecoratorByType(l_en, Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File GB", classDecorator.toString(k));
Decorator<Data> dataDecorator;
- dataDecorator = provider.getDecorator(l_fr, Data.class, BY_POS);
+ dataDecorator = provider.getDecoratorByType(l_fr, Data.class, BY_POS);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0 FR", dataDecorator.toString(d));
- dataDecorator = provider.getDecorator(l_en, Data.class, BY_POS);
+ dataDecorator = provider.getDecoratorByType(l_en, Data.class, BY_POS);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0 GB", dataDecorator.toString(d));
}
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -32,7 +32,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class DecoratorProviderTest {
@@ -70,17 +70,17 @@
Decorator<File> fileDecorator = provider.getDecorator(f);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("myFile", fileDecorator.toString(f));
Decorator<?> classDecorator = provider.getDecorator(Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File", classDecorator.toString(k));
Decorator<Data> dataDecorator = provider.getDecorator(d);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name", dataDecorator.toString(d));
}
@@ -93,18 +93,18 @@
Decorator<File> fileDecorator = provider.getDecorator(f, BY_NAME);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("null", fileDecorator.toString(f));
- Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME);
+ Decorator<Class> classDecorator = provider.getDecoratorByType(Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File", classDecorator.toString(k));
Decorator<Data> dataDecorator = provider.getDecorator(d, BY_NAME);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0", dataDecorator.toString(d));
}
@@ -115,19 +115,19 @@
Data d = new Data(0, "name");
Class<?> k = File.class;
- Decorator<File> fileDecorator = provider.getDecorator(File.class);
+ Decorator<File> fileDecorator = provider.getDecoratorByType(File.class);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("myFile", fileDecorator.toString(f));
- Decorator<Class> classDecorator = provider.getDecorator(Class.class);
+ Decorator<Class> classDecorator = provider.getDecoratorByType(Class.class);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("File", classDecorator.toString(k));
- Decorator<Data> dataDecorator = provider.getDecorator(Data.class);
+ Decorator<Data> dataDecorator = provider.getDecoratorByType(Data.class);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("name", dataDecorator.toString(d));
}
@@ -137,20 +137,20 @@
Data d = new Data(0, "name");
Class<?> k = File.class;
- Decorator<File> fileDecorator = provider.getDecorator(File.class, BY_NAME);
+ Decorator<File> fileDecorator = provider.getDecoratorByType(File.class, BY_NAME);
Assert.assertNotNull(fileDecorator);
- Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals(File.class, fileDecorator.getType());
Assert.assertEquals("null", fileDecorator.toString(f));
- Decorator<Class> classDecorator = provider.getDecorator(Class.class, BY_NAME);
+ Decorator<Class> classDecorator = provider.getDecoratorByType(Class.class, BY_NAME);
Assert.assertNotNull(classDecorator);
- Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals(Class.class, classDecorator.getType());
Assert.assertEquals("java.io.File", classDecorator.toString(k));
- Decorator<Data> dataDecorator = provider.getDecorator(Data.class, BY_NAME);
+ Decorator<Data> dataDecorator = provider.getDecoratorByType(Data.class, BY_NAME);
Assert.assertNotNull(dataDecorator);
- Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals(Data.class, dataDecorator.getType());
Assert.assertEquals("0", dataDecorator.toString(d));
}
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -32,7 +32,7 @@
* A simple class to test JXPath context.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public abstract class JXPathContextTester {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -36,11 +36,10 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class JXPathDecoratorTest {
-
protected JXPathDecorator<?> decorator;
protected String expected;
@@ -54,22 +53,22 @@
@Test(expected = NullPointerException.class)
public void testNullInternalClass() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(null, "hello");
+ decorator = DecoratorUtil.newJXPathDecorator(null, "hello");
}
@Test(expected = IllegalArgumentException.class)
public void testMissingRightBrace() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha");
+ decorator = DecoratorUtil.newJXPathDecorator(Object.class, "${haha");
}
@Test(expected = IllegalArgumentException.class)
public void testMissingRightBrace2() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha${hum}");
+ decorator = DecoratorUtil.newJXPathDecorator(Object.class, "${haha${hum}");
}
@Test
public void testNullBean() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ decorator = DecoratorUtil.newJXPathDecorator(Object.class, "hello");
expected = "hello";
assertEquals(expected, decorator.getExpression());
assertEquals(0, decorator.nbToken);
@@ -81,7 +80,7 @@
@Test
public void testNoJXPath() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ decorator = DecoratorUtil.newJXPathDecorator(Object.class, "hello");
expected = "hello";
assertEquals(expected, decorator.getExpression());
assertEquals(0, decorator.nbToken);
@@ -94,19 +93,25 @@
@Test
public void testDecorator() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
+ decorator = DecoratorUtil.newJXPathDecorator(
+ JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
assertEquals("%1$s - %2$d", decorator.getExpression());
assertDecoratorInternal();
- decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}${nbToken}");
+ decorator = DecoratorUtil.newJXPathDecorator(
+ JXPathDecorator.class, "${expression}${nbToken}");
assertEquals("%1%2", decorator.getExpression());
assertDecoratorInternal();
- decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
+ decorator = DecoratorUtil.newJXPathDecorator(
+ JXPathDecorator.class,
+ "before ${expression}$s - ${nbToken}$d after");
assertEquals("before %1$s - %2$d after", decorator.getExpression());
assertDecoratorInternal();
- decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
+ decorator = DecoratorUtil.newJXPathDecorator(
+ JXPathDecorator.class,
+ "before${expression}$s-${nbToken}$dafter");
assertEquals("before%1$s-%2$dafter", decorator.getExpression());
assertDecoratorInternal();
}
@@ -114,10 +119,10 @@
@Test
public void testDecoratorEspcapeCharacters() throws Exception {
- decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "(${expression}$s) - ${nbToken}$d");
+ decorator = DecoratorUtil.newJXPathDecorator(
+ JXPathDecorator.class, "(${expression}$s) - ${nbToken}$d");
assertEquals("(%1$s) - %2$d", decorator.getExpression());
String s = decorator.toString(decorator);
- System.out.println("s=" + s);
assertDecoratorInternal();
}
@@ -127,10 +132,11 @@
List<Data> datas = Data.generate(10);
- JXPathDecorator<Data> d = DecoratorUtils.newJXPathDecorator(Data.class, "${pos}$d ${name}$s");
+ JXPathDecorator<Data> d = DecoratorUtil.newJXPathDecorator(
+ Data.class, "${pos}$d ${name}$s");
List<Data> sortData = new ArrayList<Data>(datas);
- DecoratorUtils.sort(d, sortData, 0);
+ DecoratorUtil.sort(d, sortData, 0);
for (int i = 0; i < datas.size(); i++) {
Data data = datas.get(i);
Data sData = sortData.get(i);
@@ -144,7 +150,7 @@
});
JXPathDecorator.Context<Data> context = d.context;
context.setComparator(null);
- DecoratorUtils.sort(d, sortData, 1);
+ DecoratorUtil.sort(d, sortData, 1);
for (int i = 0; i < datas.size(); i++) {
Data data = datas.get(i);
Data sData = sortData.get(i);
@@ -155,7 +161,9 @@
public void assertDecoratorInternal(String... tokens) {
assertTokens(tokens);
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
+ expected = String.format(decorator.getExpression(),
+ decorator.getExpression(),
+ decorator.getNbToken());
result = decorator.toString(decorator);
assertEquals(expected, result);
}
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -39,7 +39,7 @@
* Tests the class {@link MapPropertyHandler}.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class MapPropertyHandlerTest extends JXPathContextTester {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-04 09:51:37 UTC (rev 2161)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-04 12:48:03 UTC (rev 2162)
@@ -36,7 +36,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.2.1
+ * @since 2.3
*/
public class MultiJXPathDecoratorTest {
@@ -53,22 +53,22 @@
@Test(expected = NullPointerException.class)
public void testNullInternalClass() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(null, "hello", "#");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(null, "hello", "#");
}
@Test(expected = IllegalArgumentException.class)
public void testMissingRightBrace() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha", "#");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(Object.class, "${haha", "#");
}
@Test(expected = IllegalArgumentException.class)
public void testMissingRightBrace2() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#");
}
@Test
public void testNullBean() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "hello", "");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(Object.class, "hello", "");
expected = "hello";
assertEquals(expected, decorator.getExpression());
assertEquals(0, decorator.nbToken);
@@ -81,7 +81,7 @@
@Test
public void testMultiDecorator() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
assertEquals("%1$s - %2$d", decorator.getExpression());
assertDecoratorInternal();
assertEquals(2, decorator.contexts.length);
@@ -92,7 +92,7 @@
result = decorator.toString(decorator);
assertEquals(expected, result);
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
assertEquals("%1$s - %2$d", decorator.getExpression());
assertDecoratorInternal();
assertEquals(2, decorator.contexts.length);
@@ -107,7 +107,7 @@
@Test
public void testMultiDecorator2() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
assertEquals("%1$s - %2$d - %3$s", decorator.getExpression());
assertTokens("expression", "nbToken", "separator");
@@ -137,7 +137,7 @@
@Test
public void testDecoratorEspcapeCharacters() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "(${expression}$s)#${nbToken}$d", "#", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "(${expression}$s)#${nbToken}$d", "#", " - ");
assertEquals("(%1$s) - %2$d", decorator.getExpression());
assertTokens("expression", "nbToken");
assertEquals(2, decorator.contexts.length);
@@ -146,7 +146,7 @@
System.out.println("s=" + result);
assertEquals(expected, result);
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${nbToken}$d#(${expression}$s)", "#", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "${nbToken}$d#(${expression}$s)", "#", " - ");
assertEquals("%1$d - (%2$s)", decorator.getExpression());
assertTokens("nbToken", "expression");
assertEquals(2, decorator.contexts.length);
@@ -172,7 +172,7 @@
@Test
public void testMultiDecoratorWithMultiRef() throws Exception {
- decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
+ decorator = DecoratorUtil.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression());
assertTokens("expression", "nbToken", "separator");
@@ -203,10 +203,10 @@
List<Data> datas = Data.generate(10);
- MultiJXPathDecorator<Data> d = DecoratorUtils.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-");
+ MultiJXPathDecorator<Data> d = DecoratorUtil.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-");
List<Data> sortData = new ArrayList<Data>(datas);
- DecoratorUtils.sort(d, sortData, 0);
+ DecoratorUtil.sort(d, sortData, 0);
for (int i = 0; i < datas.size(); i++) {
Data data = datas.get(i);
Data sData = sortData.get(i);
@@ -220,7 +220,7 @@
}
});
d.setContextIndex(1);
- DecoratorUtils.sort(d, sortData, 1);
+ DecoratorUtil.sort(d, sortData, 1);
for (int i = 0; i < datas.size(); i++) {
Data data = datas.get(i);
Data sData = sortData.get(i);
1
0
Author: tchemit
Date: 2011-08-04 11:51:37 +0200 (Thu, 04 Aug 2011)
New Revision: 2161
Url: http://nuiton.org/repositories/revision/nuiton-utils/2161
Log:
Update mavenpom4redmineAndCentral to 3.0.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-01 15:40:21 UTC (rev 2160)
+++ trunk/pom.xml 2011-08-04 09:51:37 UTC (rev 2161)
@@ -22,9 +22,7 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
#L%
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -35,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.5.5</version>
+ <version>3.0</version>
</parent>
<artifactId>nuiton-utils-parent</artifactId>
1
0
r2160 - in trunk/nuiton-utils/src: main/java/org/nuiton/util test/java/org/nuiton/util
by tchemit@users.nuiton.org 01 Aug '11
by tchemit@users.nuiton.org 01 Aug '11
01 Aug '11
Author: tchemit
Date: 2011-08-01 17:40:21 +0200 (Mon, 01 Aug 2011)
New Revision: 2160
Url: http://nuiton.org/repositories/revision/nuiton-utils/2160
Log:
Evolution #1650: Remove deprecated api
Removed:
trunk/nuiton-utils/src/main/java/org/nuiton/util/StreamKeywordTokenizer.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeTrace.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/StreamKeywordTokenizerTest.java
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/StreamKeywordTokenizer.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/StreamKeywordTokenizer.java 2011-08-01 15:18:00 UTC (rev 2159)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/StreamKeywordTokenizer.java 2011-08-01 15:40:21 UTC (rev 2160)
@@ -1,101 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-/* *
- * StreamKeywordTokenizer.java
- *
- * Created: 27 mai 2004
- *
- * @author Benjamin Poussin <poussin(a)codelutin.com>
- * Copyright Code Lutin
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : */
-
-package org.nuiton.util;
-
-import java.io.StreamTokenizer;
-import java.util.HashSet;
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * TODO What is it for ?
- * @deprecated since 2.2 : unused, undocumented
- */
-@Deprecated
-public class StreamKeywordTokenizer extends StreamTokenizer { // StreamKeywordTokenizer
-
- public static final int TT_KEYWORD = -101;
- public static final int TT_VARIABLE = -102;
- protected HashSet<String> keywords = new HashSet<String>();
- protected boolean lowerCaseKeyword;
- protected int quoteCharVariable = -1;
-
- public StreamKeywordTokenizer(Reader in){
- super(in);
- }
-
- public int nextToken() throws IOException {
- super.nextToken();
- if(ttype == TT_WORD){
- String keyword = sval;
- if(lowerCaseKeyword){
- keyword = keyword.toLowerCase();
- }
- if(keywords.contains(keyword)){
- sval = keyword;
- ttype = TT_KEYWORD;
- }
- }else if(ttype == quoteCharVariable){
- ttype = TT_VARIABLE;
- }
- return ttype;
- }
-
- public void addKeyword(String keyword){
- if(lowerCaseKeyword){
- keywords.add(keyword.toLowerCase());
- }else{
- keywords.add(keyword);
- }
- }
-
- /**
- * This method must be call before addKeyword.
- * @param fl
- */
- public void lowerCaseKeyword(boolean fl){
- lowerCaseKeyword = fl;
- }
-
- public void quoteCharVariable(int c){
- quoteChar(c);
- quoteCharVariable = c;
- }
-
-} // StreamKeywordTokenizer
-
Deleted: trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeTrace.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeTrace.java 2011-08-01 15:18:00 UTC (rev 2159)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeTrace.java 2011-08-01 15:40:21 UTC (rev 2160)
@@ -1,174 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Cette classe permet de facilement trace le temps d'execution entre deux points
- *
- * usage
- * <pre>
- * TimeTrace timeTrace = new TimeTrace(5000, 1000);
- *
- *
- * long start = timeTrace.getTime();
- * ...
- * // do some work
- * ...
- * timeTrace.add(start, "do some work");
- *
- *
- * System.out.println ("time: " + timeTrace.getCallCount());
- * </pre>
- *
- * @see CallAnalyse
- * @author poussin
- * @version $Revision$
- * @deprecated since 2.1 use {@link org.nuiton.util.TimeLog}
- *
- * Last update: $Date$
- * by : $Author$
- */
-@Deprecated
-public class TimeTrace {
-
- /** Logger. */
- private Log log = LogFactory.getLog(TimeTrace.class);
-
- static public class CallStat {
- long callNumber = 0;
- long callTime = 0;
-
- @Override
- public String toString() {
- String callTimeString =
- StringUtil.convertTime(callTime);
- String avgTimeString =
- StringUtil.convertTime((callTime/ callNumber));
- return String.format("total call %s, total time %s, avg time %s",
- callNumber, callTimeString, avgTimeString);
- }
-
- }
-
- /** time to trigger log time in info level (ns) (default: 1s) */
- protected long timeToLogInfo = 1000l * 1000000l;
- /** time to trigger log time in warn level (ns) (default: 3s) */
- protected long timeToLogWarn = 3000l * 1000000l;
-
- /** for each method of all proxies, keep number of call */
- protected Map<String, CallStat> callCount = new HashMap<String, CallStat>();
-
- public TimeTrace() {
- }
-
- /**
- *
- * @param timeToLogInfo time in milliseconde after that we log info
- * @param timeToLogWarn time in milliseconde after that we log warn
- */
- public TimeTrace(long timeToLogInfo, long timeToLogWarn) {
- setTimeToLogInfo(timeToLogInfo);
- setTimeToLogWarn(timeToLogWarn);
- }
-
- /**
- *
- * @param timeToLogInfoMs time in milliseconde after that we log info
- */
- public void setTimeToLogInfo(long timeToLogInfoMs) {
- this.timeToLogInfo = timeToLogInfoMs * 1000000l; // convert ms -> ns
- }
-
- /**
- *
- * @param timeToWarnInfoMs time in milliseconde after that we log warn
- */
- public void setTimeToLogWarn(long timeToLogWarnMs) {
- this.timeToLogWarn = timeToLogWarnMs * 1000000l; // convert ms -> ns
- }
-
- public Map<String, CallStat> getCallCount() {
- return callCount;
- }
-
- /**
- * return time in format acceptable for {@link #add(timeToLogInfo, timeToLogInfo, null)}
- * @return
- */
- static public long getTime() {
- return System.nanoTime();
- }
-
- /**
- * add new trace, stop time is automaticaly computed
- *
- * @param startNs time returned by {@link #getTime()} method
- * @param methodName key name to store this time
- */
- public void add(long startNs, String methodName) {
- add(startNs, getTime(), methodName);
- }
-
- /**
- * add new trace
- *
- * @param startNs time returned by {@link #getTime()} method
- * @param stopNs time returned by {@link #getTime()} method
- * @param methodName key name to store this time
- */
- public void add(long startNs, long stopNs, String methodName) {
- long time = stopNs - startNs;
-
- // incremente le nombre d'appel pour cette methode
- CallStat calls = callCount.get(methodName);
- if (calls == null) {
- // is not thread safe, but if we lose one or two call, is not importante
- calls = new CallStat();
- callCount.put(methodName, calls);
- }
- calls.callNumber++;
- calls.callTime += time;
-
- // affiche le temps de l'appel si necessaire
- String timeString = StringUtil.convertTime(time);
- String msg = String.format("[%s] for method %s (%s)",
- timeString, methodName, calls);
-
- if (time > timeToLogWarn && log.isWarnEnabled()) {
- log.warn(msg);
- } else if (time > timeToLogInfo && log.isInfoEnabled()) {
- log.info(msg);
- } else if (log.isDebugEnabled()) {
- log.debug(msg);
- }
-
- }
-
-}
Deleted: trunk/nuiton-utils/src/test/java/org/nuiton/util/StreamKeywordTokenizerTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/StreamKeywordTokenizerTest.java 2011-08-01 15:18:00 UTC (rev 2159)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/StreamKeywordTokenizerTest.java 2011-08-01 15:40:21 UTC (rev 2160)
@@ -1,111 +0,0 @@
-/*
- * #%L
- * Nuiton Utils
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-/* *
- * StreamKeywordTokenizer.java
- *
- * Created: 27 mai 2004
- *
- * @author Benjamin Poussin <poussin(a)codelutin.com>
- * Copyright Code Lutin
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : */
-
-package org.nuiton.util;
-
-import junit.framework.TestCase;
-import java.io.StringReader;
-
-public class StreamKeywordTokenizerTest extends TestCase { // StreamKeywordTokenizer
-
- public void testKeywordLower() throws Exception {
- StringReader in = new StringReader("Coucou tOUt TouT lE MONDE");
- StreamKeywordTokenizer parser = new StreamKeywordTokenizer(in);
- parser.resetSyntax();
- parser.commentChar('#');
- parser.eolIsSignificant(false);
- parser.lowerCaseMode(false);
- parser.parseNumbers();
- parser.quoteChar('"');
- parser.slashSlashComments(true);
- parser.slashStarComments(true);
- parser.whitespaceChars(0, ' ');
- parser.wordChars('A', 'Z');
- parser.wordChars('a', 'z');
-
- parser.lowerCaseKeyword(true);
- parser.addKeyword("Coucou");
- parser.addKeyword("TouT");
- parser.addKeyword("mondE");
-
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("coucou"));
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("tout"));
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("tout"));
- assertTrue(StreamKeywordTokenizer.TT_WORD == parser.nextToken()
- && parser.sval.equals("lE"));
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("monde"));
-
- }
-
- public void testKeyword() throws Exception {
- StringReader in = new StringReader("Coucou tOUt TouT lE MONDE");
- StreamKeywordTokenizer parser = new StreamKeywordTokenizer(in);
- parser.resetSyntax();
- parser.commentChar('#');
- parser.eolIsSignificant(false);
- parser.lowerCaseMode(false);
- parser.parseNumbers();
- parser.quoteChar('"');
- parser.slashSlashComments(true);
- parser.slashStarComments(true);
- parser.whitespaceChars(0, ' ');
- parser.wordChars('A', 'Z');
- parser.wordChars('a', 'z');
-
- parser.lowerCaseKeyword(false);
- parser.addKeyword("Coucou");
- parser.addKeyword("TouT");
- parser.addKeyword("mondE");
-
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("Coucou"));
- assertTrue(StreamKeywordTokenizer.TT_WORD == parser.nextToken()
- && parser.sval.equals("tOUt"));
- assertTrue(StreamKeywordTokenizer.TT_KEYWORD == parser.nextToken()
- && parser.sval.equals("TouT"));
- assertTrue(StreamKeywordTokenizer.TT_WORD == parser.nextToken()
- && parser.sval.equals("lE"));
- assertTrue(StreamKeywordTokenizer.TT_WORD == parser.nextToken()
- && parser.sval.equals("MONDE"));
- }
-
-} // StreamKeywordTokenizer
-
1
0
r2159 - in trunk: . nuiton-profiling nuiton-utils nuiton-validator
by tchemit@users.nuiton.org 01 Aug '11
by tchemit@users.nuiton.org 01 Aug '11
01 Aug '11
Author: tchemit
Date: 2011-08-01 17:18:00 +0200 (Mon, 01 Aug 2011)
New Revision: 2159
Url: http://nuiton.org/repositories/revision/nuiton-utils/2159
Log:
change version
Modified:
trunk/nuiton-profiling/pom.xml
trunk/nuiton-utils/pom.xml
trunk/nuiton-validator/pom.xml
trunk/pom.xml
Modified: trunk/nuiton-profiling/pom.xml
===================================================================
--- trunk/nuiton-profiling/pom.xml 2011-08-01 15:14:33 UTC (rev 2158)
+++ trunk/nuiton-profiling/pom.xml 2011-08-01 15:18:00 UTC (rev 2159)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.3-SNAPSHOT</version>
</parent>
<artifactId>nuiton-profiling</artifactId>
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2011-08-01 15:14:33 UTC (rev 2158)
+++ trunk/nuiton-utils/pom.xml 2011-08-01 15:18:00 UTC (rev 2159)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.3-SNAPSHOT</version>
</parent>
<artifactId>nuiton-utils</artifactId>
Modified: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml 2011-08-01 15:14:33 UTC (rev 2158)
+++ trunk/nuiton-validator/pom.xml 2011-08-01 15:18:00 UTC (rev 2159)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.3-SNAPSHOT</version>
</parent>
<artifactId>nuiton-validator</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-01 15:14:33 UTC (rev 2158)
+++ trunk/pom.xml 2011-08-01 15:18:00 UTC (rev 2159)
@@ -39,7 +39,7 @@
</parent>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.2.1-SNAPSHOT</version>
+ <version>2.3-SNAPSHOT</version>
<modules>
<module>nuiton-utils</module>
1
0
r2158 - in trunk/nuiton-utils: . src/main/java/org/nuiton/util/decorator src/test/java/org/nuiton/util/decorator
by tchemit@users.nuiton.org 01 Aug '11
by tchemit@users.nuiton.org 01 Aug '11
01 Aug '11
Author: tchemit
Date: 2011-08-01 17:14:33 +0200 (Mon, 01 Aug 2011)
New Revision: 2158
Url: http://nuiton.org/repositories/revision/nuiton-utils/2158
Log:
add a multi i18n decorator api + test it
fix dependencies
Added:
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java
Modified:
trunk/nuiton-utils/pom.xml
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/pom.xml 2011-08-01 15:14:33 UTC (rev 2158)
@@ -61,6 +61,11 @@
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
Added: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java (rev 0)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -0,0 +1,319 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Utils
+ * *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.util.decorator;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * A decorator provider for multi-i18n locale.
+ * <p/>
+ * Implements the method {@link #loadDecorators(Locale)} to fill the decorators
+ * availables.
+ * <p/>
+ * Then can obtain decorator via the methods {@code getDecorator(...)}
+ * <p/>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2.1
+ */
+public abstract class DecoratorMulti18nProvider {
+
+ /** Logger */
+ private static final Log log = LogFactory.getLog(DecoratorProvider.class);
+
+ /**
+ * Loaded decorators.
+ * <p/>
+ * This map will be lazy loaded as needed via the method
+ * {@link #getDecoratorContexts(Locale, boolean)}.
+ */
+ protected Map<Locale, Collection<DecoratorContext<?>>> decoratorContexts;
+
+
+ /**
+ * Load all decorators of the provider for the given {@code locale}.
+ *
+ * @param locale the locale to use to load decorators.
+ */
+ protected abstract void loadDecorators(Locale locale);
+
+
+ /**
+ * Obtain a decorator for the given object using the given {@code locale}.
+ *
+ * @param locale user locale
+ * @param object object of decorated object
+ * @param <O> object of decorated object
+ * @return the decorator or {@code null} if not found
+ */
+ @SuppressWarnings({"unchecked"})
+ public <O> Decorator<O> getDecorator(Locale locale, O object) {
+ return getDecorator(locale, object, null);
+ }
+
+ /**
+ * Obtain a decorator given a object and an extra name to qualify the
+ * context using the given {@code locale}.
+ *
+ * @param locale user locale
+ * @param object object of decorated object
+ * @param name extra name to qualify the decorator to use
+ * @param <O> object of decorated object
+ * @return the decorator or {@code null} if not found
+ */
+ @SuppressWarnings({"unchecked"})
+ public <O> Decorator<O> getDecorator(Locale locale,
+ O object,
+ String name) {
+ Class<O> k = (Class<O>) object.getClass();
+ return getDecorator(locale, k, name);
+ }
+
+ /**
+ * Obtain a decorator given a type on the given {@code locale}.
+ *
+ * @param locale user locale
+ * @param type type of decorated object
+ * @param <O> type of decorated object
+ * @return the decorator or {@code null} if not found
+ */
+ public <O> Decorator<O> getDecorator(Locale locale,
+ Class<O> type) {
+ return getDecorator(locale, type, null);
+ }
+
+ /**
+ * Obtain a decorator given a type and a extra context name on the given
+ * {@code locale}.
+ *
+ * @param locale user locale
+ * @param type type of decorated object
+ * @param name extra name to qualify the decorator to use
+ * @param <O> type of decorated object
+ * @return the decorator or {@code null} if not found
+ */
+ public <O> Decorator<O> getDecorator(Locale locale,
+ Class<O> type,
+ String name) {
+ DecoratorContext<O> d = getDecoratorContext(locale, type, name, true);
+ return d == null ? null : d.getDecorator();
+ }
+
+ public void clear() {
+ if (decoratorContexts != null) {
+ decoratorContexts.clear();
+ }
+ }
+
+ protected Map<Locale, Collection<DecoratorContext<?>>> getDecoratorContexts() {
+ if (decoratorContexts == null) {
+ decoratorContexts = new HashMap<Locale, Collection<DecoratorContext<?>>>();
+ }
+ return decoratorContexts;
+ }
+
+ protected Collection<DecoratorContext<?>> getDecoratorContexts(Locale locale,
+ boolean doLoad) {
+
+ Collection<DecoratorContext<?>> decoratorContexts =
+ getDecoratorContexts().get(locale);
+
+ if (decoratorContexts == null) {
+ decoratorContexts = new ArrayList<DecoratorContext<?>>();
+ getDecoratorContexts().put(locale, decoratorContexts);
+ if (doLoad) {
+ loadDecorators(locale);
+ }
+ }
+ return decoratorContexts;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected <T> DecoratorContext<T> getDecoratorContext(Locale locale,
+ Class<T> type,
+ String context,
+ boolean doLoad) {
+ DecoratorContext<T> result = null;
+
+ Collection<DecoratorContext<?>> decoratorContexts =
+ getDecoratorContexts(locale, doLoad);
+
+ if (decoratorContexts != null) {
+ for (DecoratorContext<?> d : decoratorContexts) {
+ 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;
+ }
+
+ protected void registerPropertyDecorator(Locale locale,
+ Class<?> klass,
+ String expression) {
+ registerPropertyDecorator(locale, klass, null, expression);
+ }
+
+ protected void registerJXPathDecorator(Locale locale,
+ Class<?> klass, String expression) {
+ registerJXPathDecorator(locale, klass, null, expression);
+ }
+
+ protected void registerMultiJXPathDecorator(Locale locale,
+ Class<?> klass,
+ String expression,
+ String separator,
+ String separatorReplacement) {
+ registerMultiJXPathDecorator(locale, klass, null, expression, separator,
+ separatorReplacement);
+ }
+
+ protected void registerPropertyDecorator(Locale locale,
+ Class<?> klass,
+ String name,
+ String expression) {
+ Decorator<?> decorator =
+ DecoratorUtils.newPropertyDecorator(klass, expression);
+ registerDecorator(locale, name, decorator);
+ }
+
+ protected void registerJXPathDecorator(Locale locale,
+ Class<?> klass,
+ String name,
+ String expression) {
+ Decorator<?> decorator =
+ DecoratorUtils.newJXPathDecorator(klass, expression);
+ registerDecorator(locale, name, decorator);
+ }
+
+ protected void registerMultiJXPathDecorator(Locale locale,
+ Class<?> klass,
+ String name,
+ String expression,
+ String separator,
+ String separatorReplacement) {
+ Decorator<?> decorator = DecoratorUtils.newMultiJXPathDecorator(
+ klass, expression, separator, separatorReplacement
+ );
+ registerDecorator(locale, name, decorator);
+ }
+
+ protected void registerDecorator(Locale locale,
+ Decorator<?> decorator) {
+ registerDecorator(locale, null, decorator);
+ }
+
+ /**
+ * Register a new decorator in the cache of the provider.
+ *
+ * @param <T> type of data decorated
+ * @param locale
+ * @param context the name decorator
+ * @param decorator the decorator to register
+ */
+ protected <T> void registerDecorator(Locale locale,
+ String context,
+ Decorator<T> decorator) {
+
+ // obtain the decorator context
+ DecoratorContext<?> result =
+ getDecoratorContext(locale,
+ decorator.getInternalClass(),
+ context,
+ false
+ );
+
+ if (result != null) {
+ throw new IllegalArgumentException(
+ "there is an already register decorator with context " +
+ result);
+ }
+
+ DecoratorContext<T> decoratorContext =
+ new DecoratorContext<T>(context, decorator);
+ if (log.isDebugEnabled()) {
+ log.debug(decoratorContext);
+ }
+ getDecoratorContexts(locale, false).add(decoratorContext);
+ }
+
+ 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) {
+ boolean accept = getType().isAssignableFrom(type) && accept(context);
+ return accept;
+ }
+
+ 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 + ">";
+ }
+ }
+}
Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorMulti18nProvider.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorProvider.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -45,7 +45,7 @@
public abstract class DecoratorProvider {
/** Logger */
- private static final Log log = LogFactory.getLog(JXPathDecorator.class);
+ private static final Log log = LogFactory.getLog(DecoratorProvider.class);
/** Registred decorators. */
protected List<DecoratorContext<?>> decorators;
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/DecoratorUtils.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/JXPathDecorator.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MapPropertyHandler.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/MultiJXPathDecorator.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/decorator/PropertyDecorator.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/Data.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2004 - 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -27,6 +27,10 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2.1
+ */
public class Data {
int pos;
Added: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java (rev 0)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -0,0 +1,229 @@
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Utils
+ * *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.util.decorator;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Locale;
+
+/**
+ * Tests the {@link DecoratorMulti18nProvider}
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2.1
+ */
+public class DecoratorMulti18nProviderTest {
+
+ private static final String BY_NAME = "name";
+
+ private static final String BY_POS = "pos";
+
+ static protected Locale l_fr = Locale.FRANCE;
+
+ static protected Locale l_en = Locale.UK;
+
+ class MyDecoratorProvider extends DecoratorMulti18nProvider {
+
+ @Override
+ protected void loadDecorators(Locale locale) {
+
+ registerPropertyDecorator(locale, File.class, "name");
+ registerPropertyDecorator(locale, File.class, BY_NAME, "parent");
+
+ registerJXPathDecorator(locale, Class.class, "${simpleName}$s " + locale.getCountry());
+ registerJXPathDecorator(locale, Class.class, BY_NAME, "${name}$s " + locale.getCountry());
+
+ registerMultiJXPathDecorator(locale, Data.class, "${name}$s " + locale.getCountry(), "-", " ");
+ registerMultiJXPathDecorator(locale, Data.class, BY_POS, "${pos}$d " + locale.getCountry(), "-", " ");
+ }
+ }
+
+ MyDecoratorProvider provider;
+
+ @Before
+ public void beforeTest() throws Exception {
+ provider = new MyDecoratorProvider();
+ }
+
+ @Test
+ public void testGetDecoratorByObject() throws Exception {
+
+
+ File f = new File("myFile");
+ Data d = new Data(0, "name");
+ Class<?> k = File.class;
+
+ Decorator<File> fileDecorator = provider.getDecorator(l_fr, f);
+ Assert.assertNotNull(fileDecorator);
+ Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals("myFile", fileDecorator.toString(f));
+
+ Decorator<?> classDecorator;
+
+ classDecorator = provider.getDecorator(l_fr, Class.class);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("File FR", classDecorator.toString(k));
+
+ classDecorator = provider.getDecorator(l_en, Class.class);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("File GB", classDecorator.toString(k));
+
+ Decorator<Data> dataDecorator;
+
+ dataDecorator = provider.getDecorator(l_fr, d);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("name FR", dataDecorator.toString(d));
+
+ dataDecorator = provider.getDecorator(l_en, d);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("name GB", dataDecorator.toString(d));
+ }
+
+ @Test
+ public void testGetDecoratorByObjectAndName() throws Exception {
+
+ File f = new File("myFile");
+ Data d = new Data(0, "name");
+ Class<?> k = File.class;
+
+ Decorator<File> fileDecorator = provider.getDecorator(l_fr, f, BY_NAME);
+ Assert.assertNotNull(fileDecorator);
+ Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals("null", fileDecorator.toString(f));
+
+ Decorator<Class> classDecorator;
+
+ classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("java.io.File FR", classDecorator.toString(k));
+
+ classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("java.io.File GB", classDecorator.toString(k));
+
+
+ Decorator<Data> dataDecorator;
+
+ dataDecorator = provider.getDecorator(l_fr, d, BY_NAME);
+ Assert.assertNull(dataDecorator);
+
+ dataDecorator = provider.getDecorator(l_en, d, BY_NAME);
+ Assert.assertNull(dataDecorator);
+
+ dataDecorator = provider.getDecorator(l_fr, d, BY_POS);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("0 FR", dataDecorator.toString(d));
+
+ dataDecorator = provider.getDecorator(l_en, d, BY_POS);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("0 GB", dataDecorator.toString(d));
+ }
+
+ @Test
+ public void testGetDecoratorByType() throws Exception {
+
+ File f = new File("myFile");
+ Data d = new Data(0, "name");
+ Class<?> k = File.class;
+
+ Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class);
+ Assert.assertNotNull(fileDecorator);
+ Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals("myFile", fileDecorator.toString(f));
+
+ Decorator<Class> classDecorator;
+
+ classDecorator = provider.getDecorator(l_fr, Class.class);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("File FR", classDecorator.toString(k));
+
+ classDecorator = provider.getDecorator(l_en, Class.class);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("File GB", classDecorator.toString(k));
+
+ Decorator<Data> dataDecorator;
+
+ dataDecorator = provider.getDecorator(l_fr, Data.class);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("name FR", dataDecorator.toString(d));
+
+ dataDecorator = provider.getDecorator(l_en, Data.class);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("name GB", dataDecorator.toString(d));
+ }
+
+ @Test
+ public void testGetDecoratorByTypeAndName() throws Exception {
+ File f = new File("myFile");
+ Data d = new Data(0, "name");
+ Class<?> k = File.class;
+
+ Decorator<File> fileDecorator = provider.getDecorator(l_fr, File.class, BY_NAME);
+ Assert.assertNotNull(fileDecorator);
+ Assert.assertEquals(File.class, fileDecorator.getInternalClass());
+ Assert.assertEquals("null", fileDecorator.toString(f));
+
+ Decorator<Class> classDecorator;
+
+ classDecorator = provider.getDecorator(l_fr, Class.class, BY_NAME);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("java.io.File FR", classDecorator.toString(k));
+
+ classDecorator = provider.getDecorator(l_en, Class.class, BY_NAME);
+ Assert.assertNotNull(classDecorator);
+ Assert.assertEquals(Class.class, classDecorator.getInternalClass());
+ Assert.assertEquals("java.io.File GB", classDecorator.toString(k));
+
+ Decorator<Data> dataDecorator;
+
+ dataDecorator = provider.getDecorator(l_fr, Data.class, BY_POS);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("0 FR", dataDecorator.toString(d));
+
+ dataDecorator = provider.getDecorator(l_en, Data.class, BY_POS);
+ Assert.assertNotNull(dataDecorator);
+ Assert.assertEquals(Data.class, dataDecorator.getInternalClass());
+ Assert.assertEquals("0 GB", dataDecorator.toString(d));
+ }
+
+
+}
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorMulti18nProviderTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/DecoratorProviderTest.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -31,11 +31,11 @@
import java.io.File;
/**
- * User: chemit
- * Date: 28 oct. 2009
- * Time: 21:28:46
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2.1
*/
public class DecoratorProviderTest {
+
private static final String BY_NAME = "name";
class MyDecoratorProvider extends DecoratorProvider {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathContextTester.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -32,7 +32,7 @@
* A simple class to test JXPath context.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
+ * @since 2.2.1
*/
public abstract class JXPathContextTester {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/JXPathDecoratorTest.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -36,7 +36,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}).
+ * @since 2.2.1
*/
public class JXPathDecoratorTest {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MapPropertyHandlerTest.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -39,7 +39,7 @@
* Tests the class {@link MapPropertyHandler}.
*
* @author tchemit <chemit(a)codelutin.com>
- * @since 2.0.1
+ * @since 2.2.1
*/
public class MapPropertyHandlerTest extends JXPathContextTester {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-07-31 15:02:22 UTC (rev 2157)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/decorator/MultiJXPathDecoratorTest.java 2011-08-01 15:14:33 UTC (rev 2158)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2004 - 2011 CodeLutin
+ * Copyright (C) 2011 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -36,7 +36,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
- * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}).
+ * @since 2.2.1
*/
public class MultiJXPathDecoratorTest {
1
0