This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-converter. See http://git.nuiton.org/nuiton-converter.git commit f522fa270c89aa5c0fcc5d4efd2590f9b17a0e49 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Jul 20 15:54:06 2014 +0200 fixes #3319 --- .gitignore | 7 + LICENSE.txt | 165 +++++++++++++++++ README.txt | 1 + pom.xml | 166 +++++++++++++++++ .../java/org/nuiton/converter/ColorConverter.java | 80 ++++++++ .../java/org/nuiton/converter/ConverterUtil.java | 204 +++++++++++++++++++++ .../java/org/nuiton/converter/EnumConverter.java | 148 +++++++++++++++ .../org/nuiton/converter/KeyStrokeConverter.java | 72 ++++++++ .../java/org/nuiton/converter/LocaleConverter.java | 133 ++++++++++++++ .../java/org/nuiton/converter/URIConverter.java | 90 +++++++++ .../java/org/nuiton/converter/URLConverter.java | 92 ++++++++++ .../java/org/nuiton/converter/package-info.java | 37 ++++ .../org.apache.commons.beanutils.Converter | 6 + src/site/site_fr.xml | 93 ++++++++++ .../org/nuiton/converter/ConverterUtilTest.java | 81 ++++++++ .../org/nuiton/converter/LocaleConverterTest.java | 135 ++++++++++++++ .../nuiton/converter/UnregistreableConverter.java | 40 ++++ .../org.apache.commons.beanutils.Converter | 1 + src/test/resources/log4j.properties | 31 ++++ 19 files changed, 1582 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..340ab47 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/target +/.idea +/*.ipr +/*.iml +/*.iws +/*~ +/*~ \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..cca7fc2 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..e62547e --- /dev/null +++ b/README.txt @@ -0,0 +1 @@ +To build project just do a mvn clean install. \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..51e9cba --- /dev/null +++ b/pom.xml @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + #%L + Nuiton Converter + %% + Copyright (C) 2014 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% + --> +<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> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>nuitonpom</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>nuiton-converter</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>Nuiton Converter</name> + <description>Thin Converter API Layer on top of common-beanutils Converter API.</description> + <url>http://doc.nuiton.org/nuiton-converter</url> + <inceptionYear>2014</inceptionYear> + + <developers> + + <developer> + <name>Tony Chemit</name> + <id>tchemit</id> + <email>chemit@codelutin.com</email> + <organization>CodeLutin</organization> + <organizationUrl>http://www.codelutin.com/</organizationUrl> + <timezone>Europe/Paris</timezone> + <roles> + <role>developer</role> + </roles> + </developer> + + </developers> + + <scm> + <connection>scm:git:http://git.nuiton.org/nuiton-converter.git</connection> + <developerConnection>scm:git:https://git.nuiton.org/nuiton-converter.git</developerConnection> + <url>https://gitweb.nuiton.org/nuiton-converter.git</url> + </scm> + + <distributionManagement> + <site> + <id>${site.server}</id> + <url>${site.url}</url> + </site> + </distributionManagement> + + <properties> + + <!-- redmine project Id --> + <projectId>nuiton-converter</projectId> + + <!-- extra files to include in release --> + <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles> + + <!-- Post Release configuration --> + <skipPostRelease>false</skipPostRelease> + </properties> + + <dependencies> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.2</version> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + <version>1.9.2</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + <scope>provided</scope> + </dependency> + + </dependencies> + + <profiles> + + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + </profile> + + <!-- create assemblies at release time --> + <profile> + <id>assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <defaultGoal>package</defaultGoal> + <plugins> + + <!-- launch in a release the assembly automaticly --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <attach>false</attach> + <descriptorRefs> + <descriptorRef>deps</descriptorRef> + <descriptorRef>full</descriptorRef> + </descriptorRefs> + </configuration> + </plugin> + + </plugins> + + </build> + </profile> + + </profiles> +</project> diff --git a/src/main/java/org/nuiton/converter/ColorConverter.java b/src/main/java/org/nuiton/converter/ColorConverter.java new file mode 100644 index 0000000..5b9ea94 --- /dev/null +++ b/src/main/java/org/nuiton/converter/ColorConverter.java @@ -0,0 +1,80 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; + +import java.awt.Color; +import java.util.Scanner; + +/** + * Converter of {@link Color}. + * + * @author mallon - mallon@codelutin.com + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +public class ColorConverter implements Converter { + + @Override + public Object convert(Class aClass, Object value) { + if (!isEnabled(aClass)) { + throw new ConversionException("unsupported type: " + aClass); + } + + String valueToString = (String) value; + /* + * To get color from a formatted string + * Two formatting cases : + * - 'java.awt.Color[r=255,g=51,b=51]', for example + * - hexa, like '#000000' + */ + Color result; + try { + if (valueToString.length() == 7 && valueToString.charAt(0) == '#') { + result= new Color(Integer.parseInt(valueToString.substring(1), 16)); + } else { + Scanner sc = new Scanner(valueToString); + sc.useDelimiter("\\D+"); + result = new Color(sc.nextInt(), sc.nextInt(), sc.nextInt()); + } + return result; + } catch (Exception e) { + throw new ConversionException( + "colors must be of the form #xxxxxx ('#' followed by " + + "six hexadecimal digits), or the name of a constant " + + "field in java.awt.Color (found: '" + valueToString + "')", + e); + } + } + + protected boolean isEnabled(Class<?> aClass) { + return Color.class.equals(aClass); + } + + public Class<?> getType() { + return Color.class; + } +} diff --git a/src/main/java/org/nuiton/converter/ConverterUtil.java b/src/main/java/org/nuiton/converter/ConverterUtil.java new file mode 100644 index 0000000..22fbb4e --- /dev/null +++ b/src/main/java/org/nuiton/converter/ConverterUtil.java @@ -0,0 +1,204 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.lang.reflect.Method; +import java.util.ServiceLoader; + +/** + * Une classe contenant des méthodes utiles sur les converters et les conversions + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +public class ConverterUtil { + + /** Logger. */ + static private Log log = LogFactory.getLog(ConverterUtil.class); + + /** + * le paquetage où chercher les implentations de Converter, si non présents + * dans le système + */ + protected static final String CONVERTER_PACKAGE = "org.nuiton.converter"; + + /** un drapeau pour savoir si on doit charger les converters specifiques */ + protected static Boolean WAS_INIT = Boolean.FALSE; + + /** + * Cherche un converter pour un <code>type</code> donné. + * <p/> + * Recherche dans un premier temps dans les converteurs déjà connus. + * <p/> + * Si le type est une énum et qu'aucun converter, n'a été trouvé, on + * enregistre un nouveau convert d'enum. + * <p/> + * Sinon on tente d'instancier un converteur dans le paquetage dédié aux + * converteurs {@link #CONVERTER_PACKAGE}. + * + * @param <T> le type a convertir + * @param type le type a convertir + * @return le converter trouvé, ou null si non trouvé + */ + public static <T> Converter getConverter(Class<T> type) { + if (!WAS_INIT) { + initConverters(); + } + Converter converter = ConvertUtils.lookup(type); + if (converter != null) { + return converter; + } + if (type.isEnum()) { + registerEnumConverter(type); + return ConvertUtils.lookup(type); + } + // on essaye de trouver un converter dans le paquetage des converters + try { + registerConverter0(type); + converter = ConvertUtils.lookup(type); + } catch (Exception e) { + throw new RuntimeException(e); + } + return converter; + } + + /** + * Convertir une valeur! + * + * @param <T> le type de donnee recherchee + * @param type le type de donnee recherchee + * @param toConvert l'object a convertir + * @return la nouvelle instance de l'objet converti type ou null + */ + @SuppressWarnings({"unchecked"}) + public static <T> T convert(Class<T> type, Object toConvert) { + if (!WAS_INIT) { + initConverters(); + } + T result = null; + Converter converter = getConverter(type); + if (converter != null) { + return (T) converter.convert(type, toConvert); + } + return result; + } + + public static void registerConverter(Class<?> type) + throws IllegalAccessException, + InstantiationException, + ClassNotFoundException { + if (ConvertUtils.lookup(type) == null) { + registerConverter0(type); + } + } + + protected static void registerConverter0(Class<?> type) + throws IllegalAccessException, + InstantiationException, + ClassNotFoundException { + Class<?> aClass = Class.forName( + CONVERTER_PACKAGE + "." + type.getSimpleName() + "Converter"); + Converter converter = (Converter) aClass.newInstance(); + log.info("for type : " + type + " : " + converter); + ConvertUtils.register(converter, type); + } + + /** + * Enregistre un nouveau converter pour un type d'enum donné, avec une + * valeur par defaut. + * + * @param type le type d'enum à convertir + * @param defaultValue la valeur par defaut. + */ + public static void registerEnumConverter(Class<?> type, + Object defaultValue) { + if (EnumConverter.isEnabled(type, type) && + ConvertUtils.lookup(type) == null) { + Converter converter = new EnumConverter(type, defaultValue); + log.info("for type : " + type + " : " + converter); + ConvertUtils.register(converter, type); + } + } + + /** + * Enregistre un nouveau converter pour un type d'enum donné, sans utiliser + * de valeur par defaut. + * + * @param type le type d'enum à convertir + */ + public static void registerEnumConverter(Class<?> type) { + registerEnumConverter(type, null); + } + + public static byte[] convert(char[] chars) { + byte[] bytes = new byte[chars.length]; + for (int i = 0; i < chars.length; i++) { + bytes[i] = (byte) (chars[i] & 0xff); + } + return bytes; + } + + public static synchronized void deregister() { + ConvertUtils.deregister(); + WAS_INIT = false; + } + + public static synchronized void initConverters() { + if (WAS_INIT != null && WAS_INIT) { + return; + } + ServiceLoader<Converter> converters = + ServiceLoader.load(Converter.class); + for (Converter converter : converters) { + if (log.isDebugEnabled()) { + log.debug("discovered converter " + converter); + } + try { + Method m = converter.getClass().getDeclaredMethod("getType"); + m.setAccessible(true); + try { + Class<?> returnType = (Class<?>) m.invoke(converter); + log.info("register converter " + converter); + ConvertUtils.register(converter, returnType); + } catch (Exception ex) { + log.warn("could not obtain type of converter " + + converter + " for reason : " + ex.getMessage(), + ex); + } + } catch (NoSuchMethodException ex) { + log.warn("could not find method getType on converter " + + converter + ", will not be registred..."); + } catch (SecurityException ex) { + log.warn("could not find method getType on converter " + + converter + ", will not be registred..."); + } + + } + WAS_INIT = true; + } +} diff --git a/src/main/java/org/nuiton/converter/EnumConverter.java b/src/main/java/org/nuiton/converter/EnumConverter.java new file mode 100644 index 0000000..1d7389b --- /dev/null +++ b/src/main/java/org/nuiton/converter/EnumConverter.java @@ -0,0 +1,148 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; + +import java.util.EnumSet; + +import static org.apache.commons.logging.LogFactory.getLog; + +/** + * classe pour convertir une chaine en un objet Enum type-safe en + * connaissant le type d'enumération utilisée {@link #enumType}. + * <p/> + * Il est possible aussi de convertir une Enum à partir de sa valeur ordinal. + * <p/> + * Pour enregister un nouveau convertissemnt pour un type d'Enum utiliser les + * méthodes * {@link ConverterUtil#registerEnumConverter(Class)}, + * et {@link ConverterUtil#registerEnumConverter(Class, Object)} . + * + * @author Tony Chemit - chemit@codelutin.com + * @see Enum + * @see Enum#ordinal() + */ +public class EnumConverter implements Converter { + + /** Logger. */ + static Log log = getLog(EnumConverter.class); + + /** valeur par default à utiliser, si pas non trouvée et {@link #useDefault} actif. */ + protected Object defaultValue; + + /** flag pour utiliser la valeur par defaut {@link #defaultValue} si non trouvé. */ + protected boolean useDefault; + + /** le type de l'énumération à convertir */ + protected Class<?> enumType; + + @Override + public Object convert(Class aClass, Object value) { + if (value == null) { + if (useDefault) { + return defaultValue; + } + throw new ConversionException(String.format("No value specified for converter %s", this)); + } + if (isEnabled(aClass, enumType)) { + Object result; + if (isEnabled(value.getClass(), enumType)) { + result = value; + return result; + } + if (value instanceof String) { + try { + result = valueOf(aClass, value); + } catch (IllegalArgumentException e) { + // try an ordinal conversion + result = convertFromOrdinal(aClass, value); + } + return result; + } + if (value instanceof Integer) { + // try a ordinal conversion + result = convertFromOrdinal(aClass, value); + return result; + } + } + throw new ConversionException( + String.format("no convertor found for type %2$s and objet '%1$s'", aClass.getName(), value)); + } + + public EnumConverter(Class<?> enumType, Object defaultValue) { + this.enumType = enumType; + this.defaultValue = defaultValue; + useDefault = defaultValue != null; + if (log.isDebugEnabled()) { + log.debug(toString() + '<' + enumType + '>'); + } + } + + public EnumConverter(Class<?> enumType) { + this(enumType, null); + } + + protected static boolean isEnabled(Class<?> aClass, Class<?> enumType) { + return aClass != null && aClass.isEnum() && aClass == enumType; + } + + protected Object convertFromOrdinal(Class<?> aClass, Object value) { + Object result = null; + try { + int ordinal = Integer.valueOf(value + ""); + EnumSet<?> vals = allOf(aClass); + if (ordinal > -1 && ordinal < vals.size()) { + for (Enum<?> val : vals) { + if (val.ordinal() == ordinal) { + result = val; + break; + } + } + } + } catch (NumberFormatException e1) { + // quiet conversion + result = null; + } + return result; + } + + protected Object valueOf(Class<?> aClass, Object value) { + Object result; + result = Enum.valueOf((Class<Enum>) aClass, (String) value); + return result; + } + + protected EnumSet<?> allOf(Class<?> aClass) { + EnumSet<?> vals; + vals = EnumSet.allOf((Class<Enum>) aClass); + return vals; + } + + public Class<?> getType() { + return enumType; + } + + +} diff --git a/src/main/java/org/nuiton/converter/KeyStrokeConverter.java b/src/main/java/org/nuiton/converter/KeyStrokeConverter.java new file mode 100644 index 0000000..6c4f23b --- /dev/null +++ b/src/main/java/org/nuiton/converter/KeyStrokeConverter.java @@ -0,0 +1,72 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; + +import javax.swing.KeyStroke; + +import static org.apache.commons.logging.LogFactory.getLog; + +/** + * Used to convert a {@link String} to {@link KeyStroke}. + * + * @author Sylvain Letellier - letellier@codelutin.com + * @since 1.0 + */ +public class KeyStrokeConverter implements Converter { + + /** Logger. */ + static Log log = getLog(KeyStrokeConverter.class); + + @Override + public Object convert(Class aClass, Object value) { + if (value == null) { + throw new ConversionException( + String.format("No value specified for converter %s", this)); + } + if (isEnabled(aClass)) { + Object result; + if (isEnabled(value.getClass())) { + result = value; + return result; + } + if (value instanceof String) { + result = KeyStroke.getKeyStroke((String) value); + return result; + } + } + throw new ConversionException( + String.format("no convertor found for type %2$s and objet '%1$s'", aClass.getName(), value)); + } + + protected boolean isEnabled(Class<?> aClass) { + return KeyStroke.class.equals(aClass); + } + + public Class<?> getType() { + return KeyStroke.class; + } +} diff --git a/src/main/java/org/nuiton/converter/LocaleConverter.java b/src/main/java/org/nuiton/converter/LocaleConverter.java new file mode 100644 index 0000000..5a7d30a --- /dev/null +++ b/src/main/java/org/nuiton/converter/LocaleConverter.java @@ -0,0 +1,133 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; + +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.apache.commons.logging.LogFactory.getLog; + +/** + * classe pour convertir une chaine en un objet {@link Locale}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +public class LocaleConverter implements Converter { + + private static final Pattern FULL_SCOPE_PATTERN = + Pattern.compile("([a-zA-Z]{2})_([a-zA-Z]{2})"); + + private static final Pattern MEDIUM_SCOPE_PATTERN = + Pattern.compile("([a-zA-Z]{2})"); + + /** Logger. */ + private static final Log log = getLog(LocaleConverter.class); + + @Override + public Object convert(Class aClass, Object value) { + if (value == null) { + throw new ConversionException("can not convert null value in " + + this + " convertor"); + } + if (isEnabled(aClass)) { + Object result; + if (isEnabled(value.getClass())) { + result = value; + return result; + } + if (value instanceof String) { + result = valueOf(((String) value).trim()); + return result; + } + } + throw new ConversionException( + "could not find a convertor for type " + aClass.getName() + + " and value : " + value); + } + + public Locale valueOf(String value) { + try { + Locale result = convertFullScope(value); + + if (result == null) { + result = convertMediumScope(value); + } + + if (result == null) { + throw new ConversionException("could not convert locale " + + value); + } + + return result; + } catch (Exception e) { + throw new ConversionException("could not convert locale " + value + + " for reason " + e.getMessage()); + } + } + + private Locale convertFullScope(String value) { + Matcher m = FULL_SCOPE_PATTERN.matcher(value); + if (m.matches()) { + // found a full scope pattern (language + country) + String language = m.group(1).toLowerCase(); + String country = m.group(2).toUpperCase(); + + return new Locale(language, country); + } + return null; + } + + private Locale convertMediumScope(String value) { + Matcher m = MEDIUM_SCOPE_PATTERN.matcher(value); + if (m.matches()) { + + // found a medium scope pattern (only language) + String language = m.group(1).toLowerCase(); + + return new Locale(language); + } + return null; + } + + + public LocaleConverter() { + if (log.isDebugEnabled()) { + log.debug("init locale converter : " + this); + } + } + + protected boolean isEnabled(Class<?> aClass) { + return Locale.class.equals(aClass); + } + + public Class<?> getType() { + return Locale.class; + } + +} diff --git a/src/main/java/org/nuiton/converter/URIConverter.java b/src/main/java/org/nuiton/converter/URIConverter.java new file mode 100644 index 0000000..d16734d --- /dev/null +++ b/src/main/java/org/nuiton/converter/URIConverter.java @@ -0,0 +1,90 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; + +import java.net.URI; +import java.net.URISyntaxException; + +import static org.apache.commons.logging.LogFactory.getLog; + +/** + * classe pour convertir une chaine en un objet URI. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.3 (replace {@code org.nuiton.util.URIConverter}). + */ +public class URIConverter implements Converter { + + /** Logger. */ + static Log log = getLog(URIConverter.class); + + @Override + public Object convert(Class aClass, Object value) { + if (value == null) { + throw new ConversionException( + String.format("No value specified for converter %s", this)); + } + if (isEnabled(aClass)) { + Object result; + if (isEnabled(value.getClass())) { + result = value; + return result; + } + if (value instanceof String) { + result = valueOf((String) value); + return result; + } + } + throw new ConversionException( + String.format("no convertor found for type %2$s and objet '%1$s'", aClass.getName(), value)); + } + + protected URI valueOf(String value) { + try { + URI result; + result = new URI(value); + return result; + } catch (URISyntaxException e) { + throw new ConversionException( + String.format("a problem occurs while converting value '%s' with url convertor %s for reason %s", value, this, e.getMessage())); + } + } + + public URIConverter() { + if (log.isDebugEnabled()) { + log.debug("init uri converter " + this); + } + } + + protected boolean isEnabled(Class<?> aClass) { + return URI.class.equals(aClass); + } + + public Class<?> getType() { + return URI.class; + } +} diff --git a/src/main/java/org/nuiton/converter/URLConverter.java b/src/main/java/org/nuiton/converter/URLConverter.java new file mode 100644 index 0000000..1b04c9b --- /dev/null +++ b/src/main/java/org/nuiton/converter/URLConverter.java @@ -0,0 +1,92 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.logging.Log; + +import java.net.MalformedURLException; +import java.net.URL; + +import static org.apache.commons.logging.LogFactory.getLog; + +/** + * classe pour convertir une chaine en un objet URL. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.3 (replace {@code org.nuiton.util.URLConverter}). + */ +public class URLConverter implements Converter { + + /** Logger. */ + static Log log = getLog(URLConverter.class); + + @Override + public Object convert(Class aClass, Object value) { + if (value == null) { + throw new ConversionException( + String.format("No value specified for converter %s", this)); + } + if (isEnabled(aClass)) { + Object result; + if (isEnabled(value.getClass())) { + result = value; + return result; + } + if (value instanceof String) { + result = valueOf((String) value); + return result; + } + } + throw new ConversionException( + String.format("no convertor found for type %2$s and objet '%1$s'", aClass.getName(), value)); + } + + protected URL valueOf(String value) { + try { + URL result; + result = new URL(value); + return result; + } catch (MalformedURLException e) { + throw new ConversionException( + String.format("a problem occurs while converting value '%s' with url convertor %s for reason %s", value, this, e.getMessage())); + } + } + + public URLConverter() { + if (log.isDebugEnabled()) { + log.debug("init url converter " + this); + } + } + + protected boolean isEnabled(Class<?> aClass) { + return URL.class.equals(aClass); + } + + public Class<?> getType() { + return URL.class; + } + + +} diff --git a/src/main/java/org/nuiton/converter/package-info.java b/src/main/java/org/nuiton/converter/package-info.java new file mode 100644 index 0000000..13836da --- /dev/null +++ b/src/main/java/org/nuiton/converter/package-info.java @@ -0,0 +1,37 @@ +/** + * + * This package contains the converter api + the format api. + * <p/> + * <h1>Converter api</h1> + * This converter api is based on the + * http://commons.apache.org/beanutils {@code commons-beanutils}. + * <p/> + * Use the {@link org.nuiton.converter.ConverterUtil} to register or obtain a + * converter. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ diff --git a/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter b/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter new file mode 100644 index 0000000..a23f2be --- /dev/null +++ b/src/main/resources/META-INF/services/org.apache.commons.beanutils.Converter @@ -0,0 +1,6 @@ +org.nuiton.converter.ColorConverter +org.nuiton.converter.KeyStrokeConverter +org.nuiton.converter.LocaleConverter +org.nuiton.converter.URIConverter +org.nuiton.converter.URLConverter + diff --git a/src/site/site_fr.xml b/src/site/site_fr.xml new file mode 100644 index 0000000..819cb86 --- /dev/null +++ b/src/site/site_fr.xml @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Converter + %% + Copyright (C) 2014 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% + --> + +<project name="${project.name}" xmlns="http://maven.apache.org/DECORATION/1.4.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd"> + + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>${fluidoSkinVersion}</version> + </skin> + + <custom> + <fluidoSkin> + <topBarEnabled>false</topBarEnabled> + <googleSearch/> + <sideBarEnabled>true</sideBarEnabled> + <searchEnabled>true</searchEnabled> + <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> + <piwik> + <piwikUrl>http://piwik.codelutin.com</piwikUrl> + <idsite>${project.piwikId}</idsite> + </piwik> + </fluidoSkin> + </custom> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <bannerRight> + <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> + <href>https://www.codelutin.com</href> + </bannerRight> + + <publishDate position="right"/> + <version position="right"/> + + <poweredBy> + + <logo href="http://maven.apache.org" name="Maven" + img="${siteCommonResourcesUrl}/images/logos/maven-feather.png"/> + + </poweredBy> + + <body> + + <head> + + <link rel="stylesheet" type="text/css" + href="${siteCommonResourcesUrl}/css/mavenpom-site.css"/> + </head> + + <links> + <item name="Nuiton.org" href="https://forge.nuiton.org"/> + <item name="Code Lutin" href="https://www.codelutin.com"/> + <item name="Libre entreprise" href="http://www.libre-entreprise.org"/> + </links> + + <breadcrumbs> + <item name="${project.name}" + href="${project.url}/index.html"/> + + <item name="${project.version}" + href="${project.url}/${siteDeployClassifier}/index.html"/> + </breadcrumbs> + + <menu ref="reports"/> + + </body> +</project> diff --git a/src/test/java/org/nuiton/converter/ConverterUtilTest.java b/src/test/java/org/nuiton/converter/ConverterUtilTest.java new file mode 100644 index 0000000..83017fe --- /dev/null +++ b/src/test/java/org/nuiton/converter/ConverterUtilTest.java @@ -0,0 +1,81 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; +import org.junit.Assert; +import org.junit.Test; + +import java.net.URI; + +/** + * ConverterUtil Tester. + * + * @author Tony Chemit - chemit@codelutin.com + * @version 1.0 + * @since <pre>02/13/2008</pre> + */ +public class ConverterUtilTest { + + @Test + public void testInitConverters() { + + ConverterUtil.deregister(); + + Converter t = ConvertUtils.lookup(URI.class); + Assert.assertNull(t); + ConverterUtil.initConverters(); + t = ConvertUtils.lookup(URI.class); + Assert.assertNotNull(t); + } + + @Test + public void testConvert() throws Exception { + String s; + s = ""; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "a"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "kZZFIOFEIOFEfdskdfmldsfjklsfjldfldfjdsfiosabcd4567'''`~teAZEst"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "]{}{}{{[#{[{#[#]{][{^#][^]#{^[]{#][#]{]@[{#][^#{][^]#{teAZEst"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + // FIXME following test won't pass + //s = "éééééé]{}{}{{[#{[{#[#]{][{^#][^]#{^[]{#][#]{]@[{#][^#{][^]#{teAZEst"; + //assertEquals(new String(s.getBytes()), new String(ConverterUtil.convert(s.toCharArray()))); + + } +} diff --git a/src/test/java/org/nuiton/converter/LocaleConverterTest.java b/src/test/java/org/nuiton/converter/LocaleConverterTest.java new file mode 100644 index 0000000..05041a5 --- /dev/null +++ b/src/test/java/org/nuiton/converter/LocaleConverterTest.java @@ -0,0 +1,135 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import junit.framework.TestCase; +import org.apache.commons.beanutils.Converter; + +import java.util.Locale; + +/** + * Tests {@link LocaleConverter}. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +public class LocaleConverterTest extends TestCase { + + String toConvert; + + Locale excepted; + + Converter converter; + + @Override + protected void setUp() throws Exception { + super.setUp(); + converter = new LocaleConverter(); + } + + public void testConvertFull() throws Exception { + toConvert = "fr_FR"; + excepted = Locale.FRANCE; + assertEquals(toConvert, excepted); + + toConvert = "fr_fr"; + assertEquals(toConvert, excepted); + + toConvert = "FR_fr"; + assertEquals(toConvert, excepted); + + toConvert = "FR_FR"; + assertEquals(toConvert, excepted); + + toConvert = "\n\tFr_fR "; + assertEquals(toConvert, excepted); + + toConvert = "en_GB"; + excepted = Locale.UK; + assertEquals(toConvert, excepted); + + toConvert = "en_US"; + excepted = Locale.US; + assertEquals(toConvert, excepted); + + //TODO Arch, we must also check coherence ! + toConvert = "fr_GB"; + excepted = new Locale("fr", "GB"); + assertEquals(toConvert, excepted); + } + + public void testConvertMedium() throws Exception { + toConvert = "fr"; + excepted = new Locale("fr"); + assertEquals(toConvert, excepted); + + toConvert = "fR"; + assertEquals(toConvert, excepted); + + toConvert = "FR"; + assertEquals(toConvert, excepted); + + toConvert = " fR \t"; + assertEquals(toConvert, excepted); + + toConvert = "en"; + excepted = new Locale("en"); + assertEquals(toConvert, excepted); + + toConvert = "es"; + excepted = new Locale("es"); + assertEquals(toConvert, excepted); + + } + + public void testConvertFailed() throws Exception { + + toConvert = null; + assertConvertFailed(toConvert); + + toConvert = ""; + assertConvertFailed(toConvert); + + toConvert = "fr_"; + assertConvertFailed(toConvert); + + toConvert = "_FR"; + assertConvertFailed(toConvert); + + } + + protected void assertEquals(String toConvert, Locale expected) { + Object result = converter.convert(Locale.class, toConvert); + assertEquals(expected, result); + } + + protected void assertConvertFailed(String toConvert) { + try { + converter.convert(Locale.class, toConvert); + fail(); + } catch (Exception e) { + assertTrue(true); + } + + } +} diff --git a/src/test/java/org/nuiton/converter/UnregistreableConverter.java b/src/test/java/org/nuiton/converter/UnregistreableConverter.java new file mode 100644 index 0000000..561a4a7 --- /dev/null +++ b/src/test/java/org/nuiton/converter/UnregistreableConverter.java @@ -0,0 +1,40 @@ +package org.nuiton.converter; + +/* + * #%L + * Nuiton Converter + * %% + * Copyright (C) 2014 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% + */ + +import org.apache.commons.beanutils.Converter; + +/** + * A converter with no getType method, so not registreable via {@link ConverterUtil#initConverters()} + * + * @author Tony Chemit - chemit@codelutin.com + * @since 1.0 + */ +public class UnregistreableConverter implements Converter { + + @Override + public Object convert(Class type, Object value) { + return value; + } + +} \ No newline at end of file diff --git a/src/test/resources/META-INF/services/org.apache.commons.beanutils.Converter b/src/test/resources/META-INF/services/org.apache.commons.beanutils.Converter new file mode 100644 index 0000000..c22d6cb --- /dev/null +++ b/src/test/resources/META-INF/services/org.apache.commons.beanutils.Converter @@ -0,0 +1 @@ +org.nuiton.converter.UnregistreableConverter \ No newline at end of file diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties new file mode 100644 index 0000000..5247c86 --- /dev/null +++ b/src/test/resources/log4j.properties @@ -0,0 +1,31 @@ +### +# #%L +# Nuiton Converter +# %% +# Copyright (C) 2014 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% +### +# Global logging configuration +log4j.rootLogger=ERROR, stdout + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n + +# package level +log4j.logger.org.nuiton.converter=INFO -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm