Author: tchemit Date: 2012-06-11 12:24:36 +0200 (Mon, 11 Jun 2012) New Revision: 2360 Url: http://nuiton.org/repositories/revision/nuiton-utils/2360 Log: fixes #2134: Remove deprecated methods clean some code + reformat + deprecates new methods Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ArgumentsParserException.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ArrayUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/BoundedList.java trunk/nuiton-utils/src/main/java/org/nuiton/util/CallAnalyse.java trunk/nuiton-utils/src/main/java/org/nuiton/util/CardinalityHelper.java trunk/nuiton-utils/src/main/java/org/nuiton/util/CategorisedListenerSet.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ClassLoaderUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/CollectionUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/DesktopUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/DigestGenerator.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/FasterCachedResourceResolver.java trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java trunk/nuiton-utils/src/main/java/org/nuiton/util/FileUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtilException.java trunk/nuiton-utils/src/main/java/org/nuiton/util/LRUMapMultiKey.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ListenerSet.java trunk/nuiton-utils/src/main/java/org/nuiton/util/LoggingPatternFormatter.java trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java trunk/nuiton-utils/src/main/java/org/nuiton/util/MatrixMap.java trunk/nuiton-utils/src/main/java/org/nuiton/util/MonthEnum.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/PeriodDates.java trunk/nuiton-utils/src/main/java/org/nuiton/util/PropertiesDateRemoveFilterStream.java trunk/nuiton-utils/src/main/java/org/nuiton/util/RecursiveProperties.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ReflectUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ResourceNotFoundException.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ReverseFileReader.java trunk/nuiton-utils/src/main/java/org/nuiton/util/SortedProperties.java trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtilException.java trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeLog.java trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteSoftReference.java trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteWeakReference.java trunk/nuiton-utils/src/main/java/org/nuiton/util/Version.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipStreamEncoder.java trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/Binder.java trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderFactory.java trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/PropertyDiff.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/ConverterUtil.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/EnumConverter.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverter.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverterFactory.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatMap.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/VersionConverter.java trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/package-info.java trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java trunk/nuiton-utils/src/test/java/org/nuiton/util/FileUtilTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/ObjectUtilTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/StringUtilTest.java trunk/nuiton-utils/src/test/java/org/nuiton/util/ZipUtilTest.java trunk/nuiton-utils/src/test/resources/org/nuiton/util/fileUtilData.txt Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ApplicationConfig.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -99,7 +99,7 @@ * <p/> * <pre> * - * static public ApplicationConfig getConfig( + * public static ApplicationConfig getConfig( * Properties props, String configFilename, String ... args) { * * ApplicationConfig conf = new ApplicationConfig( @@ -476,7 +476,7 @@ /** * On separt l'init du corps du constructeur, car les sous classes ne doivent * pas l'executer. - * + * * @param defaults * @param configFilename * @since 2.4.9 @@ -1071,10 +1071,10 @@ } /** - * Retourne si un option existe ou non + * Teste si un option existe ou non. * - * @param key - * @return + * @param key la clef de l'option à tester + * @return {@code true} si l'option existe, {@code false} sinon. */ public boolean hasOption(String key) { // on est oblige de faire un get, car le containsKey n'est pas recursif @@ -1084,10 +1084,10 @@ } /** - * Retourne si un option existe ou non + * Teste si un option existe ou non * - * @param key - * @return + * @param key la clef de l'option à tester + * @return {@code true} si 'loption existe, {@code false} sinon. */ public boolean hasOption(OptionDef key) { boolean result = hasOption(key.getKey()); @@ -1283,9 +1283,10 @@ } /** - * Return sub config that encapsulate this ApplicationConfig + * Returns a sub config that encapsulate this ApplicationConfig. + * * @param prefix prefix to put automaticaly at beginning of all key - * @return + * @return sub config that encapsulate this ApplicationConfig * @since 2.4.9 */ public SubApplicationConfig getSubConfig(String prefix) { @@ -2193,20 +2194,22 @@ * monOption=toto * monPrefix.monOption=titi * </pre> - * + * <p/> * <li>Si on cree le subApp avec le prefix "monPrefix." et qu'on demande la valeur * de "monOption", la valeur retournee est "titi". * <li>Si on cree le subApp avec le prefix "monAutrePrefix." et qu'on demande la valeur * de "monOption", la valeur retournee est "toto" (valeur par defaut de monOption. - * + * <p/> * Certaines methodes retournees ne sont pas * surchargee et ne masque pas le prefix: * <li>getOptions() + * * @since 2.4.9 */ - static public class SubApplicationConfig extends ApplicationConfig { + public static class SubApplicationConfig extends ApplicationConfig { protected ApplicationConfig parent; + protected String prefix; public SubApplicationConfig(ApplicationConfig parent, String prefix) { @@ -2250,9 +2253,11 @@ /** * Surcharge pour recherche la cle avec le prefix. Si on ne la retrouve * pas, on recherche sans le prefix pour permettre d'avoir des valeurs - * par defaut + * par defaut. + * * @param key La cle de l'option - * @return + * @return l'option trouvé avec le prefix ou sinon celle sans le prefix + * si pas trouvé. */ @Override public String getOption(String key) { @@ -2270,8 +2275,12 @@ * soit modifiee pour qu'elle est la meme cle sans le prefix. Le but * est de garder les autres options et si une option avait le meme nom * qu'elle soit effacee par celle dont on a supprime le prefix - * @param replaceInner - * @return + * + * @param replaceInner le prefix à remplacer + * @return les options commencant par le prefix + * soit modifiee pour qu'elle est la meme cle sans le prefix. Le but + * est de garder les autres options et si une option avait le meme nom + * qu'elle soit effacee par celle dont on a supprime le prefix */ @Override public Properties getFlatOptions(boolean replaceInner) { @@ -2279,10 +2288,10 @@ Properties tmp = new Properties(); int lenght = getPrefix().length(); for (Map.Entry e : result.entrySet()) { - String k = (String)e.getKey(); + String k = (String) e.getKey(); if (k.startsWith(getPrefix())) { k = k.substring(lenght); - String v = (String)e.getValue(); + String v = (String) e.getValue(); tmp.setProperty(k, v); } } @@ -2294,8 +2303,10 @@ * Surcharge pour recupere les valeurs commencant par le prefix demande * en plus du prefix 'sub'. Les options sont ensuite fusionnee pour * permettre aussi les valeurs par defaut - * @param prefix - * @return + * + * @param prefix prefix to use + * @return les valeurs commençant par le prefix demandé en plus du + * prefix 'sub'. */ @Override public Properties getOptionStartsWith(String prefix) { @@ -2303,9 +2314,9 @@ Properties tmp = getParent().getOptionStartsWith(getPrefix() + prefix); int lenght = getPrefix().length(); for (Map.Entry e : tmp.entrySet()) { - String k = (String)e.getKey(); + String k = (String) e.getKey(); k = k.substring(lenght); - String v = (String)e.getValue(); + String v = (String) e.getValue(); // on ajout/ecrase les valeurs de result result.setProperty(k, v); } @@ -2537,7 +2548,7 @@ * * @author poussin */ - static public class Action { + public static class Action { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @@ -2574,7 +2585,7 @@ * * @param <T> */ - static protected class CacheItem<T> { + protected static class CacheItem<T> { /** typed option value */ public T item; @@ -2588,7 +2599,7 @@ } } - static public class OptionList { + public static class OptionList { protected ApplicationConfig config; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ArgumentsParserException.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ArgumentsParserException.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ArgumentsParserException.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -21,19 +21,20 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% - */ + */ package org.nuiton.util; /** * Argument parsing exception. - * + * * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin + * Copyright Code Lutin * @version $Revision$ - * - * Mise a jour: $Date$ - * par : */ + * <p/> + * Mise a jour: $Date$ + * par : + */ public class ArgumentsParserException extends Exception { // ArgumentsParserException /** serialVersionUID. */ @@ -41,7 +42,7 @@ /** * Constructs a new exception with the specified detail message. - * + * * @param msg message */ public ArgumentsParserException(String msg) { @@ -50,7 +51,7 @@ /** * Constructs a new exception with the specified detail message and cause. - * + * * @param msg message * @param eee cause */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ArrayUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ArrayUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ArrayUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,69 +37,11 @@ package org.nuiton.util; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.ObjectUtils; - import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.List; public class ArrayUtil { // ArrayUtil - /** - * empty string array useful when we want passe null, but api want String[] - * - * @deprecated since 2.4.8, use directly {@link ArrayUtils#EMPTY_STRING_ARRAY}. - */ - @Deprecated - static final String[] EMPTY_STRING_ARRAY = ArrayUtils.EMPTY_STRING_ARRAY; - - /** - * Permet de convertir un tableau en une liste, le type primitif - * est encapsulé dans un objet. - * - * @param a le tableau a convertir - * @return la liste - * @deprecated avec l'auto-boxing en java 5 et plus ? - */ - static public List<Double> asList(double[] a) { - ArrayList<Double> result = new ArrayList<Double>(a.length); - for (double anA : a) { - result.add(anA); - } - return result; - } - - /** - * - * @param a - * @param <T> - * @return - * @deprecated since 2.4.8, use directly {@link Arrays#asList(Object[])}. - */ - @Deprecated - static public <T> List<T> asList(T[] a) { - return Arrays.asList(a); - } - - /** - * Permet de convertir un tableau en une liste, le type primitif - * est encapsulé dans un objet. - * - * @param a le tableau a convertir - * @return la liste - * @deprecated avec l'auto-boxing en java 5 et plus ? - */ - static public List<Integer> asList(int[] a) { - ArrayList<Integer> result = new ArrayList<Integer>(a.length); - for (int anA : a) { - result.add(anA); - } - return result; - } - public static int[] asIntArray(String[] a) { int[] result = new int[a.length]; for (int i = 0; i < a.length; i++) { @@ -118,7 +60,7 @@ * @param b le second tableau * @return le tableau des sommes */ - static public int[] sum(int[] a, int[] b) { + public static int[] sum(int[] a, int[] b) { if (a == null || b == null || a.length != b.length) { throw new IllegalArgumentException("Au moins des tableaux est null ou les tableaux ne font pas la même taille"); } @@ -129,7 +71,7 @@ return result; } - static public int[] concat(int[]... tabs) { + public static int[] concat(int[]... tabs) { int length = 0; for (int[] tab : tabs) { if (tab != null) { @@ -157,7 +99,7 @@ * todo essayer de retourner le meilleur type de tableau possible * [Double], [Long] -> [Number] */ - static public Object[] concat(Object[]... tabs) { + public static Object[] concat(Object[]... tabs) { Object[] result = null; Class<?> clazz = null; int length = 0; @@ -199,7 +141,7 @@ * @return un nouveau tableau contenant a la fin les elements souhaites */ @SuppressWarnings("unchecked") - static public <E, F extends E> E[] concatElems(E[] tab, F... elems) { + public static <E, F extends E> E[] concatElems(E[] tab, F... elems) { E[] result; result = (E[]) concat(tab, elems); return result; @@ -213,7 +155,7 @@ * @param clazz la classe de l'objet souhaité * @return un objet de la classe demandé, ou null si aucun ne correspond */ - static public <A> A search(Object[] tab, Class<A> clazz) { + public static <A> A search(Object[] tab, Class<A> clazz) { A result = null; for (Object o : tab) { if (clazz.isInstance(o)) { @@ -224,7 +166,7 @@ } @SuppressWarnings({"unchecked"}) - static public <T> T[] toArray(Collection list, Class<T> clazz) { + public static <T> T[] toArray(Collection list, Class<T> clazz) { T[] result = (T[]) Array.newInstance(clazz, list == null ? 0 : list.size()); int i = 0; for (Object o : list) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/BoundedList.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/BoundedList.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/BoundedList.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -46,7 +46,7 @@ * Created: 10 juin 2005 * * @author athimel <thimel@codelutin.com> - * $Id$ + * $Id$ */ public class BoundedList<E> extends ArrayList<E> { /** */ @@ -54,6 +54,7 @@ //By defaut, maxSize is set to -1 (infinite) private int minSize = 0; + private int maxSize = -1; /** Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/CallAnalyse.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/CallAnalyse.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/CallAnalyse.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,124 +37,120 @@ package org.nuiton.util; +import org.apache.commons.collections.primitives.ArrayLongList; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.apache.commons.collections.primitives.ArrayLongList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** -* Cette classe permet de faire des analyses sur les appels de methode -* En debut de methode on appelle la methode {@link #enter}, et en fin de methode -* la methode {@link #exit}. -* <p> -* Ensuite on peut récuperer les statistiques par Thread ou de tous les threads -* <p> -* On a comme statistique -* <li> le temps d'execution -* <li> la memore utilisé -* <li> le nombre d'appels + * Cette classe permet de faire des analyses sur les appels de methode + * En debut de methode on appelle la methode {@link #enter}, et en fin de methode + * la methode {@link #exit}. + * <p/> + * Ensuite on peut récuperer les statistiques par Thread ou de tous les threads + * <p/> + * On a comme statistique + * <li> le temps d'execution + * <li> la memore utilisé + * <li> le nombre d'appels * * @see TimeLog -*/ + */ public class CallAnalyse { // CallAnalyse /** Logger. */ static private Log log = LogFactory.getLog(CallAnalyse.class); static private List<ThreadStatistics> listThreadStatistics = - new ArrayList<ThreadStatistics>(); + new ArrayList<ThreadStatistics>(); static private ThreadLocal<ThreadStatistics> stats = - new ThreadLocal<ThreadStatistics>(){ - @Override - protected synchronized ThreadStatistics initialValue(){ - ThreadStatistics result = new ThreadStatistics(); - listThreadStatistics.add(result); - return result; - } - }; + new ThreadLocal<ThreadStatistics>() { + @Override + protected synchronized ThreadStatistics initialValue() { + ThreadStatistics result = new ThreadStatistics(); + listThreadStatistics.add(result); + return result; + } + }; - /** - * Permet d'activer les statistiques, pour le thread courant - */ - static public void activate(){ + /** Permet d'activer les statistiques, pour le thread courant */ + public static void activate() { stats.get().setActivated(true); } - /** - * Permet de desactiver les statistiques, pour le thread courant - */ - static public void desactivate(){ + /** Permet de desactiver les statistiques, pour le thread courant */ + public static void desactivate() { stats.get().setActivated(false); } /** - * Permet de savoir si les statistiques sont activées ou non, pour le - * thread courant - */ - static public boolean isActivate(){ + * Permet de savoir si les statistiques sont activées ou non, pour le + * thread courant + */ + public static boolean isActivate() { return stats.get().getActivated(); } - /** - * @param name le nom de l'appel a monitorer - */ - static public void enter(String name){ + /** @param name le nom de l'appel a monitorer */ + public static void enter(String name) { ThreadStatistics t = stats.get(); - if(t.getActivated()){ + if (t.getActivated()) { t.get(name).enter(); } } /** - * Indique la sortie de l'appel, name doit avoir ete utilisé lors d'un enter - * @param name le nom de l'appel a monitorer, doit etre identique a - * celui utilisé pour la methode enter - */ - static public void exit(String name){ + * Indique la sortie de l'appel, name doit avoir ete utilisé lors d'un enter + * + * @param name le nom de l'appel a monitorer, doit etre identique a + * celui utilisé pour la methode enter + */ + public static void exit(String name) { ThreadStatistics t = stats.get(); - if(t.getActivated()){ + if (t.getActivated()) { t.get(name).exit(); } } - /** - * @return the statistics for the current thread - */ - static public ThreadStatistics getThreadStatistics(){ + /** @return the statistics for the current thread */ + public static ThreadStatistics getThreadStatistics() { return stats.get(); } - /** - * @return the statistics for all threads - */ - static public List<ThreadStatistics> getAllThreadStatistics(){ + /** @return the statistics for all threads */ + public static List<ThreadStatistics> getAllThreadStatistics() { return listThreadStatistics; } - static public class ThreadStatistics extends TreeMap<String, CallStatistics>{ + public static class ThreadStatistics extends TreeMap<String, CallStatistics> { /** */ private static final long serialVersionUID = -36051448464013504L; + protected boolean activated = false; - public boolean getActivated(){ + + public boolean getActivated() { return activated; } - public void setActivated(boolean activated){ + + public void setActivated(boolean activated) { this.activated = activated; } - public CallStatistics get(String name){ + + public CallStatistics get(String name) { CallStatistics result = super.get(name); - if(result == null){ + if (result == null) { put(name, result = new CallStatistics(name)); } return result; } - public String toString(){ + + public String toString() { return values().toString(); } } @@ -163,7 +159,7 @@ * This method will get all the statistics from all the threads and put it * all together in a {@link Map} which key is the name of the watched * element and the value is its instance of {@link CallStatisticsSummary} - * + * * @return A map with all collected statistics */ public static Map<String, CallStatisticsSummary> getSummary() { @@ -182,114 +178,134 @@ } /** - * CallStatistics is the class which handles values on excecution time and + * CallStatistics is the class which handles values on excecution time and * memory usage. * Each CallStatistics object is for one particular name. - * + * * @author bpoussin */ - static public class CallStatistics implements Cloneable { + public static class CallStatistics implements Cloneable { protected String name = null; + protected long calls = 0; + protected long minTime = Long.MAX_VALUE; + protected long maxTime = Long.MIN_VALUE; + protected long sumTime = 0; + protected long minMemory = Long.MAX_VALUE; + protected long maxMemory = Long.MIN_VALUE; + protected long sumMemory = 0; + /** pile contenant le temps de appel, util pour les appels recursifs */ protected ArrayLongList times = new ArrayLongList(); + protected ArrayLongList memories = new ArrayLongList(); + protected Runtime runtime = Runtime.getRuntime(); - public CallStatistics(String name){ + public CallStatistics(String name) { this.name = name; } - public void enter(){ + + public void enter() { times.add(System.nanoTime()); memories.add(getMemory()); } - public void exit(){ - calls ++; - if(times.size() == 0){ + public void exit() { + calls++; + + if (times.size() == 0) { log.info("To many exit call for " + name); return; } long time = times.removeElementAt(times.size() - 1); time = System.nanoTime() - time; - if(time < minTime || minTime == Long.MAX_VALUE){ + if (time < minTime || minTime == Long.MAX_VALUE) { minTime = time; } - if(time > maxTime){ + if (time > maxTime) { maxTime = time; } sumTime += time; long memory = memories.removeElementAt(memories.size() - 1); memory = getMemory() - memory; - if(memory < minMemory || minMemory == Long.MAX_VALUE){ + if (memory < minMemory || minMemory == Long.MAX_VALUE) { minMemory = memory; } - if(memory > maxMemory){ + if (memory > maxMemory) { maxMemory = memory; } sumMemory += memory; } - public String getName(){ + + public String getName() { return name; } - public long getCalls(){ + + public long getCalls() { return calls; } - public long getMinTime(){ + public long getMinTime() { return minTime; } - public long getMaxTime(){ + + public long getMaxTime() { return maxTime; } - public long getSumTime(){ + + public long getSumTime() { return sumTime; } - public long getAvgTime(){ - if (calls == 0){ + + public long getAvgTime() { + if (calls == 0) { return 0; } else { return sumTime / calls; } } - public long getMinMemory(){ + public long getMinMemory() { return minMemory; } - public long getMaxMemory(){ + + public long getMaxMemory() { return maxMemory; } - public long getSumMemory(){ + + public long getSumMemory() { return sumMemory; } - public long getAvgMemory(){ - if ( calls == 0) { + + public long getAvgMemory() { + if (calls == 0) { return 0; } else { return sumMemory / calls; } } - protected long getMemory(){ + protected long getMemory() { // runtime.gc(); return runtime.totalMemory() - runtime.freeMemory(); } @Override - public String toString(){ + public String toString() { return getName() + " calls=" + getCalls() - + " time=" + StringUtil.convertTime(getSumTime()) - + "(" + StringUtil.convertTime(getMinTime()) + "/" + StringUtil.convertTime(getAvgTime()) + "/" + StringUtil.convertTime(getMaxTime()) + ")" - + " memory=" + StringUtil.convertMemory(getSumMemory()) - + "(" + StringUtil.convertMemory(getMinMemory()) + "/" + StringUtil.convertMemory(getAvgMemory()) + "/" + StringUtil.convertMemory(getMaxMemory()) + ")" - ; + + " time=" + StringUtil.convertTime(getSumTime()) + + "(" + StringUtil.convertTime(getMinTime()) + "/" + StringUtil.convertTime(getAvgTime()) + "/" + StringUtil.convertTime(getMaxTime()) + ")" + + " memory=" + StringUtil.convertMemory(getSumMemory()) + + "(" + StringUtil.convertMemory(getMinMemory()) + "/" + StringUtil.convertMemory(getAvgMemory()) + "/" + StringUtil.convertMemory(getMaxMemory()) + ")" + ; } } //CallStatistics @@ -297,19 +313,19 @@ /** * This class is collecting data from different CallStatistics classes by * using the method {@link #addCallStats(org.nuiton.util.CallAnalyse.CallStatistics)}. - * + * * @author thimel */ - static public class CallStatisticsSummary extends CallStatistics { + public static class CallStatisticsSummary extends CallStatistics { public CallStatisticsSummary(String name) { super(name); } /** - * This methods read the given {@link CallStatistics} and add values to + * This methods read the given {@link CallStatistics} and add values to * its own - * + * * @param other an other CallStatistics object */ public void addCallStats(CallStatistics other) { @@ -317,19 +333,19 @@ return; } calls += other.getCalls(); - if(other.getMinTime() < minTime || minTime == Long.MAX_VALUE){ + if (other.getMinTime() < minTime || minTime == Long.MAX_VALUE) { minTime = other.getMinTime(); } - if(other.getMaxTime() > maxTime){ + if (other.getMaxTime() > maxTime) { maxTime = other.getMaxTime(); } sumTime += other.getSumTime(); - if(other.getMinMemory() < minMemory || minMemory == Long.MAX_VALUE){ + if (other.getMinMemory() < minMemory || minMemory == Long.MAX_VALUE) { minMemory = other.getMinMemory(); } - if(other.getMaxMemory() > maxMemory){ + if (other.getMaxMemory() > maxMemory) { maxMemory = other.getMaxMemory(); } sumMemory += other.getSumMemory(); Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/CardinalityHelper.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/CardinalityHelper.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/CardinalityHelper.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -61,6 +61,7 @@ public class CardinalityHelper { static final Pattern PATTERN_OPTIONAL = Pattern.compile("\\[.*\\]"); + static final Pattern PATTERN_MANDATORY = Pattern.compile("\\<.*\\>"); /** XXX + ou XXX * */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/CategorisedListenerSet.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -60,9 +60,8 @@ * <p/> * <p> Si les categories sont representees par des Class, alors vous pouvez * utiliser la hierachie de classe pour creer de facon automatique les peres. - * - * @param <L> listener type * + * @param <L> listener type * @see ListenerSet */ public class CategorisedListenerSet<L> { // CategorisedListenerSet @@ -75,23 +74,23 @@ * Si on utilise cette category, alors tous les listeners present * seront utilisé. */ - static public final Object ALL = new Object(); + public static final Object ALL = new Object(); /** * HashMap de ListenerSet, en cle l'objet qui caracterise la categorie * en valeur un ListenerSet */ protected WeakHashMap<Object, ListenerSet<L>> listeners = new WeakHashMap<Object, ListenerSet<L>>(); + protected WeakHashMap<Object, Object> categoryParent = new WeakHashMap<Object, Object>(); + protected boolean isClassCategory = true; - /** - * Empty constructor. - */ + /** Empty constructor. */ public CategorisedListenerSet() { } - + /** * @param isClassCategory si vrai et que les categorie passé en arguement * lors de l'ajout sont de type Class alors lors du fire on recherche aussi @@ -153,10 +152,10 @@ * Permet de lancer un event dans une categorie, l'event est aussi propagé * sur les ancètres de la categorie * - * @param category la categorie a partir duquel il faut lancer l'evenement - * @param methodName le nom de la méthode de la classe listener - * @param event l'objet event a passer en paramètre de la methode du - * listener + * @param category la categorie a partir duquel il faut lancer l'evenement + * @param methodName le nom de la méthode de la classe listener + * @param event l'objet event a passer en paramètre de la methode du + * listener * @throws Exception if event can't be fired */ public void fire(Object category, String methodName, Object event) @@ -173,9 +172,8 @@ * sur les ancètres de la categorie, si un meme objet etait listener * dans plusieurs categories alors il ne recevra qu'une seul notification * - * @param category la categorie a partir duquel il faut lancer l'evenement - * @param methodName le nom de la méthode de la classe listener - * + * @param category la categorie a partir duquel il faut lancer l'evenement + * @param methodName le nom de la méthode de la classe listener * @throws Exception if event can't be fired */ public void fire(Object category, String methodName) throws Exception { @@ -189,7 +187,7 @@ * Retourne un Iterator sur tous les listeners qu'il faut prevenir si on * souhaite prevenir une certaine categorie. Ceci inclue les ancetre de la * categorie - * + * * @param category category to get iterator on * @return iterator */ @@ -200,7 +198,7 @@ /** * @param category categorie demandee * @return un ListenerSet contenant tous les listeners c'est à dire les - * listener de la categorie demandé mais aussi les listeners des ancetres + * listener de la categorie demandé mais aussi les listeners des ancetres */ protected ListenerSet<L> getAllListeners(Object category) { ListenerSet<L> result = new ListenerSet<L>(); @@ -220,7 +218,7 @@ } if (log.isTraceEnabled()) { log.trace("getAllListeners category: " + category + " result: " - + result); + + result); } return result; } @@ -240,7 +238,7 @@ /** * @param category categorie demandee * @return un ListenerSet contenant seulement les listener de la categorie - * demandé. Si la categorie n'existe pas alors elle est créé. + * demandé. Si la categorie n'existe pas alors elle est créé. */ protected ListenerSet<L> getListeners(Object category) { ListenerSet<L> result = listeners.get(category); @@ -249,14 +247,14 @@ } if (log != null && log.isTraceEnabled()) { log.trace("getListeners category: " + category + " result: " - + result); + + result); } return result; } public String toString() { return "Listeners Category: " + categoryParent + "\nListener: " - + listeners; + + listeners; } } // CategorisedListenerSet Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ClassLoaderUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ClassLoaderUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ClassLoaderUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -56,7 +56,7 @@ * @param loader the classloader (if null will use system one) * @return all the url found in the classloader */ - static public URL[] getDeepURLs(URLClassLoader loader) { + public static URL[] getDeepURLs(URLClassLoader loader) { Stack<URL> urlToTreate = new Stack<URL>(); List<URL> urlTreated = new ArrayList<URL>(); @@ -105,7 +105,7 @@ * @param classLoader le class loader a scanner * @return les urls du classloade. */ - static public URL[] getURLs(URLClassLoader classLoader) { + public static URL[] getURLs(URLClassLoader classLoader) { if (classLoader == null) { classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); } @@ -130,7 +130,7 @@ return result; } - static public void printLoader(ClassLoader loader) { + public static void printLoader(ClassLoader loader) { log.info(loader); if (loader instanceof URLClassLoader) { URL[] urls = getURLs((URLClassLoader) loader); Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/CollectionUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/CollectionUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/CollectionUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -54,7 +54,7 @@ * @param e les elements a ajouter * @return la collection passé en parametre */ - static public <A, E extends Collection<A>> E addAll(E col, A... e) { + public static <A, E extends Collection<A>> E addAll(E col, A... e) { Collections.addAll(col, e); return col; } @@ -67,7 +67,7 @@ * @param e les elements a ajouter * @return la liste passé en parametre */ - static public <A, E extends List<A>> E addAll(E col, int pos, A... e) { + public static <A, E extends List<A>> E addAll(E col, int pos, A... e) { col.addAll(pos, Arrays.asList(e)); return col; } @@ -88,7 +88,7 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> List<O> toGenericList( + public static <O> List<O> toGenericList( List<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { return (List<O>) list; @@ -119,7 +119,7 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> Collection<O> toGenericCollection( + public static <O> Collection<O> toGenericCollection( Collection<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { return (Collection<O>) list; @@ -150,7 +150,7 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> Set<O> toGenericSet( + public static <O> Set<O> toGenericSet( Set<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { return (Set<O>) list; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/DateUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -35,8 +35,9 @@ /** * Library for manipulating dates. + * <p/> + * <b>Note: </b> * - * <b>Note: </b> * @author fdesbois * @version $Id$ * @since 1.4.1 @@ -51,7 +52,7 @@ * Format a date using the pattern in argument. The pattern is the same using * for DateFormat object. * - * @param date the date to format + * @param date the date to format * @param pattern the pattern to use * @return a String corresponding to the date formatted * @see DateFormat @@ -60,7 +61,7 @@ SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.format(date); } - + public static String formatDate(Date date, String pattern, Locale locale) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern, locale); return simpleDateFormat.format(date); @@ -70,7 +71,7 @@ * Parse a date using the pattern in argument. The pattern is the same using * for DateFormat object. * - * @param date the String to parse + * @param date the String to parse * @param pattern the pattern to use * @return a Date corresponding to the String argument parsed * @throws ParseException for parsing errors @@ -84,11 +85,12 @@ /** * Create a new date from day, month and year (French version). - * The month is the real month of the year and not the one which is stored + * The month is the real month of the year and not the one which is stored * in Calendar object. - * @param s value of the seconds 1-60 - * @param m value of the minutes 1-60 - * @param h value of the hours 1-24 + * + * @param s value of the seconds 1-60 + * @param m value of the minutes 1-60 + * @param h value of the hours 1-24 * @param dd value of the day 1-31 * @param mm value of the month 1-12 * @param yy value of the year 0-9999 @@ -98,7 +100,7 @@ Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(0L); calendar.set(Calendar.YEAR, yy); - calendar.set(Calendar.MONTH, mm-1); + calendar.set(Calendar.MONTH, mm - 1); calendar.set(Calendar.DAY_OF_MONTH, dd); calendar.set(Calendar.HOUR_OF_DAY, h); calendar.set(Calendar.MINUTE, m); @@ -110,6 +112,7 @@ * Create a new date from day, month and year (French version). * The month is the real month of the year and not the one which is stored * in Calendar object. Time is set to 00:00:00.000 + * * @param dd value of the day 1-31 * @param mm value of the month 1-12 * @param yy value of the year 0-9999 @@ -118,7 +121,7 @@ public static Date createDate(int dd, int mm, int yy) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, yy); - calendar.set(Calendar.MONTH, mm-1); + calendar.set(Calendar.MONTH, mm - 1); calendar.set(Calendar.DAY_OF_MONTH, dd); return setMinTimeOfDay(calendar.getTime()); } @@ -135,8 +138,8 @@ public static Date createDateAfterToday(int ddStep, int mmStep, int yyStep) { Calendar calendar = getDefaultCalendar(new Date()); calendar.add(Calendar.DAY_OF_MONTH, ddStep); - calendar.add(Calendar.MONTH,mmStep); - calendar.add(Calendar.YEAR, yyStep); + calendar.add(Calendar.MONTH, mmStep); + calendar.add(Calendar.YEAR, yyStep); return calendar.getTime(); } @@ -232,9 +235,9 @@ * dates. The argument myDate can be equals to beforeDate or afterDate to * validate the includes. * - * @param myDate the date to test + * @param myDate the date to test * @param beforeDate the first date of the period to test - * @param afterDate the second date of the period to test + * @param afterDate the second date of the period to test * @return true if myDate is included between beforeDate and afterDate */ public static boolean between(Date myDate, Date beforeDate, Date afterDate) { @@ -244,7 +247,7 @@ boolean result = true; result &= myDate.after(beforeDate) || myDate.compareTo(beforeDate) == 0; result &= afterDate == null || myDate.before(afterDate) || - myDate.compareTo(afterDate) == 0; + myDate.compareTo(afterDate) == 0; return result; } @@ -252,9 +255,9 @@ * Check if the current date is between the two dates in argument. * * @param beforeDate the first date of the period - * @param afterDate the second date of the period + * @param afterDate the second date of the period * @return true if the current date is included between the two dates, - * false otherwise + * false otherwise * @see #between(Date, Date, Date) */ public static boolean currentPeriod(Date beforeDate, Date afterDate) { @@ -277,7 +280,7 @@ * of seconds between the two dates. * * @param beginDate first date - * @param endDate second date + * @param endDate second date * @return a number of seconds between beginDate and endDate */ public static int getDifferenceInSeconds(Date beginDate, Date endDate) { @@ -291,13 +294,13 @@ * of minutes between the two dates. * * @param beginDate first date - * @param endDate second date + * @param endDate second date * @return a number of minutes between beginDate and endDate */ public static int getDifferenceInMinutes(Date beginDate, Date endDate) { long begin = beginDate.getTime(); long end = endDate.getTime(); - // 60000 = 60 * 1000 + // 60000 = 60 * 1000 return (int) Math.ceil((end - begin) / 60000); } @@ -306,13 +309,13 @@ * of hours between the two dates. * * @param beginDate first date - * @param endDate second date + * @param endDate second date * @return a number of hours between beginDate and endDate */ public static int getDifferenceInHours(Date beginDate, Date endDate) { long begin = beginDate.getTime(); long end = endDate.getTime(); - // 3600000 = 60 * 60 * 1000 + // 3600000 = 60 * 60 * 1000 return (int) Math.ceil((end - begin) / 3600000); } @@ -322,13 +325,13 @@ * Ex : 28/01/2009 and 08/02/2009 return 11. * * @param beginDate first date - * @param endDate second date + * @param endDate second date * @return a number of days between beginDate and endDate */ public static int getDifferenceInDays(Date beginDate, Date endDate) { long begin = beginDate.getTime(); long end = endDate.getTime(); - // 86400000 = 24 * 60 * 60 * 1000 + // 86400000 = 24 * 60 * 60 * 1000 return (int) Math.ceil((end - begin) / 86400000); } @@ -339,7 +342,7 @@ * Warning, if beginDate is inferior to endDate, the result will be 1 minimum * * @param beginDate first date - * @param endDate second date + * @param endDate second date * @return a number of months between beginDate and endDate */ public static int getDifferenceInMonths(Date beginDate, Date endDate) { @@ -374,16 +377,16 @@ } return count; } - + /** * Get libelle of the month corresponding to the number given in argument. * * @param monthNumber between 1-12 - * @param locale Locale for language support + * @param locale Locale for language support * @return a String corresponding to the libelle of the month */ public static String getMonthLibelle(int monthNumber, Locale locale) { - return new DateFormatSymbols(locale).getMonths()[monthNumber-1]; + return new DateFormatSymbols(locale).getMonths()[monthNumber - 1]; } /** @@ -427,7 +430,7 @@ * and giving {@link java.util.Calendar#DAY_OF_WEEK} argument, but such a call * raise an exception showing that this field is not supported. This method * allows you to bypass this limitation. - * + * * @param date any date * @return a date in the same week as given date, a monday. All field below * (hours, secondes, ms) are zeroed. Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/DesktopUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/DesktopUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/DesktopUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -46,7 +46,7 @@ * Method to open an URI in the user default web browser. It uses the Java * Desktop API on Windows and Gnome environment and xdg-open on other * platforms (non-gnome linux distribution for example). - * + * <p/> * A Bug report have been opened in 2006 so that java.awt.Desktop can * support all environments but it is not fixed yet : * http://bugs.sun.com/view_bug.do?bug_id=6486393 this utility method should @@ -72,7 +72,7 @@ log.debug("Desktop not supported"); } } - } catch(IOException ioe) { + } catch (IOException ioe) { if (log.isDebugEnabled()) { log.debug("Desktop API not supported, launching xdg-open"); } @@ -83,12 +83,12 @@ } catch (IOException e) { if (log.isDebugEnabled()) { log.debug("Could not launch browser, there is maybe no " + - "default browser configured on the system"); + "default browser configured on the system"); } } } } - + } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/DigestGenerator.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/DigestGenerator.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/DigestGenerator.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -21,16 +21,24 @@ * specific language governing permissions and limitations * under the License. */ - + /* - * Modified by Landais Gabriel, Code Lutin 2008 - * - * Works with standard org.w3c.dom XML classes - * - */ - +* Modified by Landais Gabriel, Code Lutin 2008 +* +* Works with standard org.w3c.dom XML classes +* +*/ + package org.nuiton.util; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.ProcessingInstruction; +import org.w3c.dom.Text; + import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -43,18 +51,10 @@ import java.util.SortedMap; import java.util.TreeMap; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; - /** * Helper class to provide the functionality of the digest value generation. This is an implementation of the DHASH * algorithm on . - * + * <p/> * TODO tchemit 2010-08-25 : This class is a nightmare ? we talk about digest mixed with dom nodes ? * TODO tchemit 2010-08-25 : Should have more to explain the purpose (javadoc, author, since...) or (rename | split) this class. */ @@ -63,7 +63,7 @@ /** * This method is an overloaded method for the digest generation for Document - * + * * @param document * @param digestAlgorithm * @return Returns a byte array representing the calculated digest @@ -83,9 +83,8 @@ Node node = (Node) childNode; if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { dos.write(getDigest((ProcessingInstruction) node, - digestAlgorithm)); - } - else if (node.getNodeType() == Node.ELEMENT_NODE) { + digestAlgorithm)); + } else if (node.getNodeType() == Node.ELEMENT_NODE) { dos.write(getDigest((Element) node, digestAlgorithm)); } } @@ -102,7 +101,7 @@ /** * This method is an overloaded method for the digest generation for Node - * + * * @param node * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value @@ -123,7 +122,7 @@ /** * This method is an overloaded method for the digest generation for Element - * + * * @param element * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value @@ -168,7 +167,7 @@ /** * This method is an overloaded method for the digest generation for ProcessingInstruction - * + * * @param pi * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value @@ -198,7 +197,7 @@ /** * This method is an overloaded method for the digest generation for Attr - * + * * @param attribute * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value @@ -232,7 +231,7 @@ /** * This method is an overloaded method for the digest generation for Text - * + * * @param text * @param digestAlgorithm * @return Returns a byte array representing the calculated digest value @@ -259,7 +258,7 @@ /** * This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for * Element - * + * * @param element * @return Returns the expanded name of Element */ @@ -270,7 +269,7 @@ /** * This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for * Attr - * + * * @param attribute * @return Returns the expanded name of the Attr */ @@ -280,7 +279,7 @@ /** * Gets the collection of attributes which are none namespace declarations for an Element - * + * * @param element * @return Returns the collection of attributes which are none namespace declarations */ @@ -298,7 +297,7 @@ /** * Gets the valid element collection of an Document. Element and ProcessingInstruction only - * + * * @param document * @return Returns a collection of ProcessingInstructions and Elements */ @@ -308,7 +307,7 @@ for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE - || node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { + || node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { list.add(node); } } @@ -317,7 +316,7 @@ /** * Gets the String representation of the byte array - * + * * @param array * @return Returns the String of the byte */ @@ -331,7 +330,7 @@ /** * Compares two Nodes for the XML equality - * + * * @param node * @param comparingNode * @param digestAlgorithm @@ -339,14 +338,14 @@ * @throws Exception */ public boolean compareNode(Node node, Node comparingNode, - String digestAlgorithm) throws Exception { + String digestAlgorithm) throws Exception { return Arrays.equals(getDigest(node, digestAlgorithm), getDigest( comparingNode, digestAlgorithm)); } /** * Compares two Documents for the XML equality - * + * * @param document * @param comparingDocument * @param digestAlgorithm @@ -354,7 +353,7 @@ * @throws Exception */ public boolean compareDocument(Document document, - Document comparingDocument, String digestAlgorithm) + Document comparingDocument, String digestAlgorithm) throws Exception { return Arrays.equals(getDigest(document, digestAlgorithm), getDigest( comparingDocument, digestAlgorithm)); @@ -362,7 +361,7 @@ /** * Compares two Attributes for the XML equality - * + * * @param attribute * @param comparingAttribute * @param digestAlgorithm @@ -370,7 +369,7 @@ * @throws Exception */ public boolean compareAttribute(Attr attribute, Attr comparingAttribute, - String digestAlgorithm) throws Exception { + String digestAlgorithm) throws Exception { return Arrays.equals(getDigest(attribute, digestAlgorithm), getDigest( comparingAttribute, digestAlgorithm)); } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ExceptionUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -38,16 +38,22 @@ package org.nuiton.util; +import org.apache.commons.lang3.exception.ExceptionUtils; + import java.io.PrintWriter; import java.io.StringWriter; -public class ExceptionUtil{ // ExceptionUtil +/** @deprecated since 2.5, will be removed and not replaced in version 2.6 */ +@Deprecated +public class ExceptionUtil { // ExceptionUtil protected ExceptionUtil() { } - static public String stackTrace(Throwable eee){ + /** @deprecated since 2.5, prefeur use {@link ExceptionUtils#getStackTrace(Throwable)} */ + @Deprecated + public static String stackTrace(Throwable eee) { StringWriter result = new StringWriter(); eee.printStackTrace(new PrintWriter(result)); return result.toString(); Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/FasterCachedResourceResolver.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/FasterCachedResourceResolver.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/FasterCachedResourceResolver.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -22,42 +22,44 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ - + package org.nuiton.util; -import java.net.URL; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; +import java.net.URL; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * FasterCachedResourceResolver is a URIResolver using a optimized search time algorithm. <br/> * For a given href, will try to search the exact path in classp-ath in the exact directory META-INF/cache. - * + * <p/> * The fact of using META-INF directory is optimized (special jvm directory). - * + * <p/> * The other fact of using an exact directory makes also decrease dramaticly time search. - * + * <p/> * Finally, we spend ten times less time in searching; moreover using the path of * searched resource resolve the probleme of name colision and this is also a good thing... - * + * <p/> * Exemple : * <pre> * href = http://foo/bar/file.txt * search resource : /META-INF/cache/foo/bar/file.txt * </pre> + * * @author chorlet * @version $Revision$ - * - * Last update : $Date$ - * By : */ + * <p/> + * Last update : $Date$ + * By : + */ public class FasterCachedResourceResolver extends ResourceResolver { /** log. */ private static final Log log = LogFactory.getLog(FasterCachedResourceResolver.class); + protected boolean offline; public FasterCachedResourceResolver() { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/FileCompletion.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -26,7 +26,6 @@ package org.nuiton.util; import org.nuiton.i18n.I18n; -import static org.nuiton.i18n.I18n._; import java.io.Console; import java.io.File; @@ -34,6 +33,8 @@ import java.io.IOException; import java.util.Locale; +import static org.nuiton.i18n.I18n._; + /** * <p> * Class d'aide a la saisie de chemin de fichier @@ -76,12 +77,14 @@ * <p> * FIXME: Si la sortie est ecive, un fichier "!q" ne peut pas etre utilise * </p> - * + * * @author Letellier Sylvain */ public class FileCompletion { private boolean exit; + private boolean creation; + private boolean consoleAvailable; private Console console; @@ -139,7 +142,7 @@ String file = f.getName(); if (file.matches("^.*\\!s$") && creation) return f.getCanonicalPath().substring(0, - f.getCanonicalPath().length() - 2); + f.getCanonicalPath().length() - 2); if (file.matches("^.*\\!q$") && exit) return null; if (file.matches("^.*\\.\\.$")) @@ -151,9 +154,8 @@ if (listFichier.length == 1) { if (!(fTmp.getParentFile() == null)) { line = fTmp.getCanonicalPath() + File.separator - + listFichier[0]; - } - else { + + listFichier[0]; + } else { line = fTmp.getCanonicalPath() + listFichier[0]; } } else if (listFichier.length > 1) { @@ -164,12 +166,12 @@ } } else if (f.exists() && f.isDirectory() - && !(f.getParentFile() == null)) { + && !(f.getParentFile() == null)) { Filter filtre = new Filter(); filtre.setFilter(f.getName()); String[] listFichier = f.getParentFile().list(filtre); if (listFichier.length <= 1 - || line.charAt(line.length() - 1) == File.separatorChar) { + || line.charAt(line.length() - 1) == File.separatorChar) { line = f.getCanonicalPath(); isDirectory = true; @@ -182,7 +184,7 @@ moreLastLine = line; f = new File(line); if (f.isDirectory() && isDirectory - && !(line.charAt(line.length() - 1) == File.separatorChar)) + && !(line.charAt(line.length() - 1) == File.separatorChar)) line = line + File.separator; String read = readLine("> " + line); line = line + read; @@ -191,7 +193,7 @@ afficherListe(f.list()); if (line.matches(".* " + File.separator + ".*") - || line.matches(".*" + File.separator + " .*")) + || line.matches(".*" + File.separator + " .*")) line = lastLine; f = new File(line); } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/FileUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/FileUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/FileUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,13 +37,11 @@ package org.nuiton.util; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JFileChooser; import java.awt.Component; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -58,7 +56,6 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; -import java.io.Reader; import java.nio.CharBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; @@ -320,67 +317,6 @@ } /** - * Permet de convertir un fichier en un tableau de byte - * - * @param file le fichier source à convertire - * @return le contenu du fichier sous la forme d'un tableau de bytes. - * @throws IOException if any io pb - * @deprecated since 2.4.6, prefer use method {@link IOUtils#toByteArray(Reader)}. - */ - @Deprecated - public static byte[] fileToByte(File file) throws IOException { - ByteArrayOutputStream result; - InputStream in = new BufferedInputStream(new FileInputStream(file)); - try { - result = new ByteArrayOutputStream(); - BufferedOutputStream tmp = new BufferedOutputStream(result); - try { - for (int b = in.read(); b != -1; b = in.read()) { - tmp.write(b); - } - } finally { - tmp.close(); - } - } finally { - in.close(); - } - return result.toByteArray(); - } - - /** - * Permet de recopier un stream dans un fichier - * - * @param src the incoming stream to grab - * @param dst the dst file - * @return the file filled by incoming input stream - * @throws IOException if any io pb - * @throws NullPointerException if src or dst parameter is null - * @deprecated since 2.4.6, prefer use method {@link FileUtils#copyInputStreamToFile(InputStream, File)}. - */ - @Deprecated - public static File inputStreamToFile(InputStream src, File dst) throws IOException, NullPointerException { - if (src == null) { - throw new NullPointerException("parameter 'src' can not be null"); - } - if (dst == null) { - throw new NullPointerException("parameter 'dst' can not be null"); - } - - ByteArrayOutputStream result = new ByteArrayOutputStream(); - BufferedOutputStream tmp = new BufferedOutputStream(result); - try { - for (int b = src.read(); b != -1; b = src.read()) { - tmp.write(b); - } - src.close(); - } finally { - tmp.close(); - } - byteToFile(result.toByteArray(), dst); - return dst; - } - - /** * Permet de convertir des bytes en fichier, le fichier sera automatiquement * supprimé a la fin de la JVM. * @@ -514,76 +450,8 @@ } /** - * Regarde si le fichier f1 est plus recent que le fichier f2 - * - * @param f1 the first file - * @param f2 the second file - * @return vrai si f1 est plus recent que f2 - * @deprecated since 2.4.6, prefer use method {@link FileUtils#isFileNewer(File, File)}. - */ - @Deprecated - public static boolean isNewer(File f1, File f2) { - boolean result = f1.lastModified() > f2.lastModified(); - return result; - } - - /** - * Permet de lire un fichier et de retourner sont contenu sous forme d'une - * chaine de carateres. - * <p/> - * Warning, this method use {@link #ENCODING} to read file (by default - * in ISO). - * - * @param file le fichier a lire - * @return le contenu du fichier - * @throws IOException if any io pb - * @deprecated since 2.4.6, prefer use method {@link FileUtils#readFileToString(File)}. - */ - @Deprecated - public static String readAsString(File file) throws IOException { - StringBuffer result = new StringBuffer(); - char[] cbuf = new char[2000]; - BufferedReader in = getReader(file); - int nb = in.read(cbuf); - while (nb != -1) { - result.append(cbuf, 0, nb); - nb = in.read(cbuf); - } - in.close(); - return result.toString(); - } - - /** * Permet de sauver une chaine directement dans un fichier - * <p/> - * Warning, this method use {@link #ENCODING} to read file (by default - * in ISO). * - * @param file Le fichier dans lequel il faut ecrire la chaine - * @param content Le texte a ecrire dans le fichier - * @throws IOException if any pb while writing - * @deprecated since 2.4.6, prefer use method {@link FileUtils#writeStringToFile(File, String)}. - */ - @Deprecated - public static void writeString(File file, - String content) throws IOException { - //fixme on doit tester le retour de la méthode, car il se peut que le répertoire - // ne puisse etre cree. - File parentFile = file.getParentFile(); - //TODO tchemit 2011-05-15 Must test if directory was created (use - // the #createDirectoryIfNecessary method). - if (parentFile != null) { - parentFile.mkdirs(); - } - - BufferedWriter out = getWriter(file); - out.write(content); - out.close(); - } - - /** - * Permet de sauver une chaine directement dans un fichier - * * @param file Le fichier dans lequel il faut ecrire la chaine * @param content Le texte a ecrire dans le fichier * @param encoding encoding to use @@ -634,7 +502,7 @@ File result = File.createTempFile("tmp-" + FileUtil.class.getName(), fileSuffix); result.deleteOnExit(); - writeString(result, content); + FileUtils.write(result, content); return result; } @@ -888,37 +756,6 @@ } /** - * Supprime recursivement tout le contenu d'un répertoire. - * - * @param directory le chemin du répertoire à supprimer - * @return vrai si tout se passe bien, false si la suppression d'un élement - * se passe mal - * @deprecated since 2.4.6, prefer use method {@link FileUtils#deleteDirectory(File)}. - */ - @Deprecated - public static boolean deleteRecursively(String directory) { - return deleteRecursively(new File(directory)); - } - - /** - * Supprime recursivement tout le contenu d'un répertoire. - * - * @param directory le répertoire à supprimer - * @return vrai si tout se passe bien, false si la suppression d'un élement - * se passe mal - * @deprecated since 2.4.6, prefer use method {@link FileUtils#deleteDirectory(File)}. - */ - @Deprecated - public static boolean deleteRecursively(File directory) { - return walkBefore(directory, new FileAction() { - @Override - public boolean doAction(File f) { - return f.delete(); - } - }); - } - - /** * Permet de faire une action avant le parcours des fichiers, c-a-d que * l'on fera l'action sur les fichiers contenu dans un répertoire * après l'action sur le répertoire lui même. @@ -963,51 +800,6 @@ } /** - * Permet de copier le fichier source vers le fichier cible. - * - * @param source le fichier source - * @param target le fichier cible - * @throws IOException Erreur de copie - * @deprecated since 2.4.6, prefer use method {@link FileUtils#copyFile(File,File)}. - */ - @Deprecated - public static void copy(File source, File target) throws IOException { - //fixme on doit tester le retour de la méthode, car il se peut que le répertoire - // ne puisse être copié. - //TODO tchemit 2011-05-15 Must test if directory was created (use - // the #createDirectoryIfNecessary method). - target.getParentFile().mkdirs(); - FileInputStream fileInputStream = new FileInputStream(source); - try { - FileChannel sourceChannel = fileInputStream.getChannel(); - FileOutputStream fileOutputStream = new FileOutputStream(target); - try { - FileChannel targetChannel = fileOutputStream.getChannel(); - sourceChannel.transferTo(0, sourceChannel.size(), targetChannel); - // or - // targetChannel.transferFrom(sourceChannel, 0, sourceChannel.size()); - targetChannel.close(); - } finally { - fileOutputStream.close(); - } - sourceChannel.close(); - } finally { - fileInputStream.close(); - } - } - - /** - * Permet de copier le fichier source vers le fichier cible. - * - * @param source le fichier source - * @param target le fichier cible - * @throws IOException Erreur de copie - */ - public static void copy(String source, String target) throws IOException { - copy(new File(source), new File(target)); - } - - /** * Copie recursivement le repertoire source dans le repertoire destination * <p/> * copyRecursively("/truc/titi", "/var/tmp") donnera le repertoire @@ -1104,10 +896,10 @@ log.debug("create directory: " + destFile); //fixme on doit tester le retour de la méthode, car il se peut que le répertoire // ne puisse être copié. - destFile.mkdirs(); + createDirectoryIfNecessary(destFile); } else { log.debug("copy " + path + " to " + destFile); - copy(file, destFile); + FileUtils.copyFile(file, destFile); } } } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -64,8 +64,7 @@ } gz.close(); return sb; - } - catch (IOException eee) { + } catch (IOException eee) { throw new GZUtilException("Probleme dans la decompression", eee); } } @@ -93,8 +92,7 @@ gz.close(); return baos.toByteArray(); - } - catch (IOException eee) { + } catch (IOException eee) { throw new GZUtilException("Probleme dans la compression", eee); } } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtilException.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtilException.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/GZUtilException.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,6 +37,7 @@ package org.nuiton.util; public class GZUtilException extends RuntimeException { // GZUtilException + /** */ private static final long serialVersionUID = -3342417793974741697L; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/LRUMapMultiKey.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/LRUMapMultiKey.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/LRUMapMultiKey.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -58,7 +58,7 @@ private static final Log log = LogFactory.getLog(LRUMapMultiKey.class); /** @author poussin */ - static public class Key extends ArrayList<Object> { + public static class Key extends ArrayList<Object> { private static final long serialVersionUID = 1L; @@ -120,6 +120,7 @@ protected Map<Object, Set<Key>> keys = new HashMap<Object, Set<Key>>(); + protected int maxSize; public LRUMapMultiKey(int maxSize) { @@ -151,7 +152,7 @@ ArrayList<Key> result = new ArrayList<Key>(); Set<Key> list = keys.remove(k); if (list != null) { - for (Iterator<Key> i = list.iterator(); i.hasNext();) { + for (Iterator<Key> i = list.iterator(); i.hasNext(); ) { Key key = i.next(); result.add(key); super.remove(key); @@ -171,7 +172,7 @@ // throw new IllegalArgumentException("key must be Key object"); // } // Key key = (Key)akey; - for (Iterator i = key.iterator(); i.hasNext();) { + for (Iterator i = key.iterator(); i.hasNext(); ) { Object k = i.next(); Set<Key> list = keys.get(k); if (list == null) { @@ -194,7 +195,7 @@ protected boolean removeEldestEntry(Map.Entry<Key, Object> eldest) { if (this.maxSize > 0 && size() > this.maxSize) { Key key = (Key) eldest.getKey(); - for (Iterator i = key.iterator(); i.hasNext();) { + for (Iterator i = key.iterator(); i.hasNext(); ) { Object k = i.next(); Set<Key> list = keys.get(k); if (list != null) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ListenerSet.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ListenerSet.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ListenerSet.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -70,9 +70,8 @@ * Cette deuxième façon de faire est plus sûr car elle n'utilise pas * l'introspection et donc une vérification est faite sur le nom de la méthode * à appeler à la compilation, mais elle est plus verbeuse à écrire. - * + * * @param <L> listeners type - * * @see CategorisedListenerSet */ public class ListenerSet<L> implements Iterable<L> { // ListenerSet @@ -119,16 +118,16 @@ * @throws Exception si un des listeners leve une exception lors de l'appel */ public void fire(String methodName, Object event) throws Exception { - for (Iterator<L> i = iterator(); i.hasNext();) { + for (Iterator<L> i = iterator(); i.hasNext(); ) { L o = i.next(); - Statement stm = new Statement(o, methodName, new Object[] { event }); + Statement stm = new Statement(o, methodName, new Object[]{event}); stm.execute(); } } /** * Appele la méthode du listener sans argument. - * + * <p/> * Cette méthode echoue si la methode ou l'objet contenant la methode a * appeler n'est pas public. * @@ -136,7 +135,7 @@ * @throws Exception si un des listeners leve une exception lors de l'appel */ public void fire(String methodName) throws Exception { - for (Iterator<L> i = iterator(); i.hasNext();) { + for (Iterator<L> i = iterator(); i.hasNext(); ) { L o = i.next(); Statement stm = new Statement(o, methodName, null); stm.execute(); @@ -171,6 +170,7 @@ static class ReferenceIterator<T> implements Iterator<T> { /** DOCUMENTME Description of the Field */ protected Iterator<Reference<T>> iter = null; + /** DOCUMENTME Description of the Field */ protected T nextObject = null; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/LoggingPatternFormatter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/LoggingPatternFormatter.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/LoggingPatternFormatter.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -24,81 +24,83 @@ */ /** -* PatternFormatter.java -* -* Created: Sat Apr 20 2002 -* -* @author POUSSIN Benjamin <bpoussin@free.fr> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ + * PatternFormatter.java + * + * Created: Sat Apr 20 2002 + * + * @author POUSSIN Benjamin <bpoussin@free.fr> + * Copyright Code Lutin + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ package org.nuiton.util; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; -import java.util.logging.LogManager; +import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; -import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Iterator; -import java.util.ArrayList; +import java.util.logging.Formatter; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; /** -* Classe org.nuiton.logging.PatternFormatter. -* -* <ul> -* <li>n: new line</li> -* <li>%: %</li> -* <li>{: {</li> -* </ul> -* -* <ul> -* <li>d: date</li> -* </ul> -* -* Date follow the same pattern as DateFormat. -* -* <ul> Sized -* <li>o: free memory</li> -* <li>O: total memory</li> -* <li>t: thread id</li> -* <li>p: priority level</li> -* <li>c: class name</li> -* <li>m: message</li> -* <li>a: argument</li> -* <li>e: exception</li> -* </ul> -* -* Sized element support justify pattern. -* {[+|-]<size>[:<maxPos>]}. -* '+' is -* left justify, '-' rigth justify, size the prefered size for the element if it is not bigger. -* If maxPos option is present blanc is not add if it go up to maxPos. -* -* <ul> SubString -* <li>M: method name</li> -* </ul> -* -* L'element SubString a les memes possibilites que le pattern justify, -* et permet en plus de suprimer une sous chaine, -* cela permet de supprimer le debut du nom d'une classe. -* Syntaxe : -* {*<substring>|[+|-]<size>[:<maxPos>]} -* {<substring>*|[+|-]<size>[:<maxPos>]} -* L'etoile represente le texte qui restera. -*/ + * Classe org.nuiton.logging.PatternFormatter. + * <p/> + * <ul> + * <li>n: new line</li> + * <li>%: %</li> + * <li>{: {</li> + * </ul> + * <p/> + * <ul> + * <li>d: date</li> + * </ul> + * <p/> + * Date follow the same pattern as DateFormat. + * <p/> + * <ul> Sized + * <li>o: free memory</li> + * <li>O: total memory</li> + * <li>t: thread id</li> + * <li>p: priority level</li> + * <li>c: class name</li> + * <li>m: message</li> + * <li>a: argument</li> + * <li>e: exception</li> + * </ul> + * <p/> + * Sized element support justify pattern. + * {[+|-]<size>[:<maxPos>]}. + * '+' is + * left justify, '-' rigth justify, size the prefered size for the element if it is not bigger. + * If maxPos option is present blanc is not add if it go up to maxPos. + * <p/> + * <ul> SubString + * <li>M: method name</li> + * </ul> + * <p/> + * L'element SubString a les memes possibilites que le pattern justify, + * et permet en plus de suprimer une sous chaine, + * cela permet de supprimer le debut du nom d'une classe. + * Syntaxe : + * {*<substring>|[+|-]<size>[:<maxPos>]} + * {<substring>*|[+|-]<size>[:<maxPos>]} + * L'etoile represente le texte qui restera. + */ public class LoggingPatternFormatter extends Formatter { // PatternFormatter private static final String DEFAULT_PATTERN = "%d{yyyy-MM-dd HH:mm:ss} [free:%o{-7}|total:%O{-7}][%t][%p{7}] %c{org.nuiton.*|25} %M{15:105}: %m%n%e"; protected HashMap<String, Class<?>> arguments = null; + protected ArrayList<Argument> compile = null; + protected String pattern = null; public LoggingPatternFormatter() { @@ -120,12 +122,10 @@ } } - /** - * Methode qui formate le record - */ + /** Methode qui formate le record */ public String format(LogRecord record) { StringBuffer result = new StringBuffer(); - for (Iterator i = compile.iterator(); i.hasNext();) { + for (Iterator i = compile.iterator(); i.hasNext(); ) { ((Argument) i.next()).toString(record, result); } return result.toString(); @@ -147,9 +147,7 @@ arguments.put("e", ExceptionArgument.class); } - /** - * Genere a partir de la chaine la liste des objet Argument. - */ + /** Genere a partir de la chaine la liste des objet Argument. */ protected void compilePattern(String pattern) { compile = new ArrayList<Argument>(); String[] match = findNextPattern(pattern); @@ -163,11 +161,12 @@ /** * Recherche dans la chaine le prochaine pattern. + * * @return un tableau de 3 chaines, [0] ce qu'il y a avant le - * parttern, [1] le parttern, [2] ce qu'il y a apres le pattern. + * parttern, [1] le parttern, [2] ce qu'il y a apres le pattern. */ protected String[] findNextPattern(String s) { - String[] result = new String[] { "", "", "" }; + String[] result = new String[]{"", "", ""}; if (s == null) { return result; } @@ -183,7 +182,7 @@ result[2] = s.substring(f + 1); } else { throw new LoggingException("Error, { at position " - + (d + 2) + " not terminated in :" + s); + + (d + 2) + " not terminated in :" + s); } } else { //pas de pattern result[0] = s.substring(0, d); @@ -197,9 +196,7 @@ return result; } - /** - * Converti un pattern en un objet Argument - */ + /** Converti un pattern en un objet Argument */ protected Argument patternToArgument(String s) { if (s.charAt(0) == 'n') { // new ligne return new StringArgument("\n"); @@ -215,18 +212,18 @@ Class argumentClass = (Class) arguments.get(code); if (argumentClass == null) throw new LoggingException("Erreur dans le pattern '" + code - + "' inconnu"); + + "' inconnu"); Argument argument; try { argument = (Argument) argumentClass.newInstance(); } catch (InstantiationException eee) { throw new LoggingException( "Erreur lors de l'instanciation de l'objet Argument: " - + argumentClass.getName(), eee); + + argumentClass.getName(), eee); } catch (IllegalAccessException eee) { throw new LoggingException( "Erreur lors de l'instanciation de l'objet Argument: " - + argumentClass.getName(), eee); + + argumentClass.getName(), eee); } if (s.length() > 1) { // on a un pattern argument.setPattern(s.substring(2)); @@ -251,7 +248,7 @@ } abstract public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo); + StringBuffer toAppendTo); } static protected class StringArgument extends Argument { @@ -288,7 +285,9 @@ static abstract protected class SizedArgument extends Argument { protected boolean left = true; + protected int width = 0; + protected int maxPos = -1; public SizedArgument() { @@ -317,12 +316,12 @@ if (left) { toAppendTo.append(s); while (0 < blanc-- - && (maxPos == -1 || toAppendTo.length() < maxPos)) { + && (maxPos == -1 || toAppendTo.length() < maxPos)) { toAppendTo.append(" "); } } else { while (0 < blanc-- - && (maxPos == -1 || toAppendTo.length() < maxPos)) { + && (maxPos == -1 || toAppendTo.length() < maxPos)) { toAppendTo.append(" "); } toAppendTo.append(s); @@ -334,6 +333,7 @@ static abstract protected class SubStringArgument extends SizedArgument { /** la chaine qui doit etre supprimee */ protected String removeString = null; + /** vrai si la chaine doit etre retiree du debut, faux pour la fin */ protected boolean atBeginning = true; @@ -354,7 +354,7 @@ removeString = subpattern[i].substring(1); } else if (subpattern[i].endsWith("*")) { removeString = subpattern[i].substring(0, subpattern[i] - .length() - 1); + .length() - 1); } } } @@ -373,8 +373,9 @@ } static abstract protected class OctetArgument extends SizedArgument { - protected static final String[] UNITE = { "o", "Ko", "Mo", "Go", "To", - "Po" }; + protected static final String[] UNITE = {"o", "Ko", "Mo", "Go", "To", + "Po"}; + protected int diviseur = 1024; public OctetArgument() { @@ -382,13 +383,14 @@ } /** - * Methode permettant l'affichage d'un taille avec une representation - * humainement lisible. - * @param size la taille rendre lisible - * @param unit les unites a utiliser (les petits en premier) - * @param diviseur le diviseur entre unite (ex: 1000 ou 1024) - * @return la representation - */ + * Methode permettant l'affichage d'un taille avec une representation + * humainement lisible. + * + * @param size la taille rendre lisible + * @param unit les unites a utiliser (les petits en premier) + * @param diviseur le diviseur entre unite (ex: 1000 ou 1024) + * @return la representation + */ protected String toReadableSize(long size, String[] unit, int diviseur) { int unitIndex = 0; while (size > 99999 && unitIndex < unit.length) { @@ -407,7 +409,7 @@ public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(toReadableSize(Runtime.getRuntime().freeMemory(), - UNITE, diviseur), toAppendTo); + UNITE, diviseur), toAppendTo); } } @@ -418,7 +420,7 @@ public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(toReadableSize(Runtime.getRuntime().totalMemory(), - UNITE, diviseur), toAppendTo); + UNITE, diviseur), toAppendTo); } } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -65,7 +65,7 @@ /** * Compute the MD5 for the given {@code input}. - * + * <p/> * <b>Note:</b> The the stream will be closed after calling the method * even if something was wrong. * @@ -76,7 +76,7 @@ public static byte[] hash(InputStream input) throws IOException { MD5InputStream in = new MD5InputStream(input); try { - while (in.read()!=-1) { + while (in.read() != -1) { // read a caracter on stream } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/MatrixMap.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/MatrixMap.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/MatrixMap.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -24,6 +24,11 @@ */ package org.nuiton.util; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.io.Serializable; import java.util.AbstractList; import java.util.ArrayList; @@ -37,17 +42,13 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.RandomAccess; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Permet de stocker des informations dans une matrix a N dimension * Si lors de l'ajout on indique une dimension qui n'existe pas encore ou * un element dans une dimension qui n'existe pas, la matrice ajoute * automatiquement les elements manquant pour que l'ajout se passe bien. - * <p> + * <p/> * MatrixMap permet de stocker les elements avec des cles de n'importe quel * type. Les coordonnees utilisant ces objets sont converti en coordonnees * numeriques qui est la seul chose que sait gere Matrix. Ces coordonnees @@ -55,62 +56,60 @@ * dans Vector. On decoupe ainsi les problemes et on minimise le stockage et * certain traitement sur les données puisqu'au final toutes les données sont * dans une simple liste. - * <p> + * <p/> * Pour créer une nouvelle matrice, il faut utiliser une des méthodes de * {@link MatrixMap.Factory} * * @author poussin * @version $Revision$ * @since 2.2.1 - * - * Last update: $Date$ - * by : $Author$ + * <p/> + * Last update: $Date$ + * by : $Author$ */ public interface MatrixMap<E> extends Iterable<E> { - /** - * Classe permettant la creation de matrice - */ - static public class Factory { - static public <T> MatrixMap<T> create(List ... semantics) { + /** Classe permettant la creation de matrice */ + public static class Factory { + public static <T> MatrixMap<T> create(List... semantics) { MatrixMap<T> result = new MatrixMapFixed<T>(semantics); return result; } - static public <T> MatrixMap<T> create(String name, List... semantics) { + public static <T> MatrixMap<T> create(String name, List... semantics) { MatrixMap<T> result = new MatrixMapFixed<T>(name, semantics); return result; } - static public <T> MatrixMap<T> create(String name, String[] dimNames, List... semantics) { + public static <T> MatrixMap<T> create(String name, String[] dimNames, List... semantics) { MatrixMap<T> result = new MatrixMapFixed<T>(name, dimNames, semantics); return result; } - static public <T> MatrixMap<T> create(MatrixMap<T> matrix) { + public static <T> MatrixMap<T> create(MatrixMap<T> matrix) { MatrixMap<T> result = new MatrixMapFixed<T>(matrix); return result; } - static public <T> MatrixMap<T> createElastic(List ... semantics) { + public static <T> MatrixMap<T> createElastic(List... semantics) { MatrixMap<T> result = create(semantics); result = createElastic(result); return result; } - static public <T> MatrixMap<T> createElastic(String name, List... semantics) { + public static <T> MatrixMap<T> createElastic(String name, List... semantics) { MatrixMap<T> result = create(name, semantics); result = createElastic(result); return result; } - static public <T> MatrixMap<T> createElastic(String name, String[] dimNames, List... semantics) { + public static <T> MatrixMap<T> createElastic(String name, String[] dimNames, List... semantics) { MatrixMap<T> result = create(name, dimNames, semantics); result = createElastic(result); return result; } - static public <T> MatrixMap<T> createElastic(MatrixMap<T> matrix) { + public static <T> MatrixMap<T> createElastic(MatrixMap<T> matrix) { MatrixMap<T> result = new MatrixMapElastic<T>(matrix); return result; } @@ -156,26 +155,28 @@ * * @param f la fonction a appliquer * @return Retourne la matrice elle meme. Les modifications sont faites directement - * dessus + * dessus */ public MatrixMap<E> map(MapFunction<E> f); /** * Retourne l'element a une certaine position en utilisant des indices * ex: 2,3,1 + * * @param coordinates * @return */ - public E getValueIndex(int ... coordinates); + public E getValueIndex(int... coordinates); /** * Modifie l'element a une certaine position en utilisant des indices * ex: 2,3,1 - * @param value la nouvelle valeur + * + * @param value la nouvelle valeur * @param coordinates * @return */ - public void setValueIndex(E value, int ... coordinates); + public void setValueIndex(E value, int... coordinates); /** * Retourne l'element a une certaine position en utilisant les semantiques @@ -183,20 +184,21 @@ * @param coordinates * @return */ - public E getValue(Object ... coordinates); + public E getValue(Object... coordinates); /** * Modifie l'element a une certaine position en utilisant les semantiques * - * @param value la nouvelle valeur + * @param value la nouvelle valeur * @param coordinates * @return */ - public void setValue(E value, Object ... coordinates); + public void setValue(E value, Object... coordinates); /** * Verifie que deux matrices sont completement equals * (dimension, semantique, nom, valeur, ...) + * * @param mat * @return */ @@ -213,6 +215,7 @@ /** * Representation string de la matrice quelque soit le nombre de dimension + * * @return */ public String toStringGeneric(); @@ -241,14 +244,14 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice + * @param dim la dimension dans lequel on veut une sous matrice * @param start la position dans dim d'ou il faut partir pour prendre la - * sous matrice. 0 <= start < dim.size si start est négatif alors - * la position de départ est calculé par rapport à la fin de la - * dimension, pour avoir le dernier élément il faut passer -1 - * @param nb le nombre d'élément à prendre dans la dimension si nb est - * inférieur ou égal à 0 alors cela indique qu'il faut prendre - * tous les éléments jusqu'à la fin de la dimension. + * sous matrice. 0 <= start < dim.size si start est négatif alors + * la position de départ est calculé par rapport à la fin de la + * dimension, pour avoir le dernier élément il faut passer -1 + * @param nb le nombre d'élément à prendre dans la dimension si nb est + * inférieur ou égal à 0 alors cela indique qu'il faut prendre + * tous les éléments jusqu'à la fin de la dimension. * @return new matrix */ public MatrixMap<E> getSubMatrix(int dim, Object start, int nb); @@ -258,7 +261,7 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice + * @param dim la dimension dans lequel on veut une sous matrice * @param elem les éléments dans la dimension à conserver * @return new matrix */ @@ -266,7 +269,7 @@ /** * Permet de prendre une sous matrice dans la matrice courante. - * + * <p/> * Réalise plusieurs appels à {@link #getSubMatrix(int, Object...)} suivant * l'implémentation. * @@ -294,13 +297,14 @@ * @return une nouvelle matrice */ public MatrixMap<E> reduceDims(int... dims); + /** * Reduit la matrice de sorte que toutes les dimensions qui n'ont qu'un * élement soit supprimée. Au pire cette méthode retourne une matrice à une * seule dimension à un seul élément. * * @param minNbDim le nombre minimum de dimension que l'on souhaite pour la - * matrice résultat + * matrice résultat * @return une nouvelle matrice plus petite que la matrice actuelle ou egal * s'il n'y a aucune dimension à supprimer */ @@ -326,7 +330,7 @@ * Classe contenant des méthodes statiques pour aider a la manipulation * des matrices */ - static public class MatrixHelper { + public static class MatrixHelper { /** * Mais en forme un texte pour qu'il fasse exactement la longueur @@ -334,8 +338,8 @@ * d'ajouter des espaces, ils seront mis devant le texte, sinon il * seront mis apres le texte * - * @param o l'objet a convertir en string - * @param length la longueur de representation souhaite + * @param o l'objet a convertir en string + * @param length la longueur de representation souhaite * @param valueIfNull la valeur a utilise si l'objet est null * @return */ @@ -362,14 +366,14 @@ * Permet de convertir des coordonnées définies par des entiers en coordonnées * semantique par des objets * - * @param semantics la semantique à utilisé pour la conversion + * @param semantics la semantique à utilisé pour la conversion * @param coordinates les coordonnées à convertir * @return un tableau donnant les coordonnées sous forme semantique s'il n'y * a pas de semantique (liste pleine de null) alors un objet Integer * est créer pour représenter la semantique de la dimension. */ public static Object[] dimensionToSemantics(List[] semantics, - int[] coordinates) { + int[] coordinates) { Object[] result = new Object[coordinates.length]; for (int i = 0; i < result.length; i++) { result[i] = semantics[i].get(coordinates[i]); @@ -382,12 +386,12 @@ * des entiers. Cette fonction est l'inverse de * {@link #dimensionToSemantics}. * - * @param semantics la semantique à utiliser pour la conversion + * @param semantics la semantique à utiliser pour la conversion * @param coordinates les coordonnées sémantique * @return les coordonnées en entier. */ public static int[] semanticsToDimension(List[] semantics, - Object[] coordinates) { + Object[] coordinates) { int[] result = new int[coordinates.length]; for (int i = 0; i < coordinates.length; i++) { result[i] = indexOf(semantics, i, coordinates[i]); @@ -399,10 +403,9 @@ * Permet de retrouver la position d'un objet dans une liste * * @param semantics la semantique à utilisé pour la recherche - * @param dim la dimension dans lequel il faut faire la recherche - * @param o l'objet à rechercher + * @param dim la dimension dans lequel il faut faire la recherche + * @param o l'objet à rechercher * @return la position de l'objet dans la dimension demandée - * * @throws NoSuchElementException If element doesn't exists */ public static int indexOf(List[] semantics, int dim, Object o) @@ -437,23 +440,28 @@ * * @param <E> */ - static public interface MatrixMapIterator<E> extends Iterator<E> { + public static interface MatrixMapIterator<E> extends Iterator<E> { public int[] getCoordinates(); + public E getValue(); + public void setValue(E value); + public Object[] getSemanticsCoordinates(); } - static public class MatrixMapIteratorImpl<E> implements MatrixMapIterator<E> { // MatrixMapIteratorImpl + public static class MatrixMapIteratorImpl<E> implements MatrixMapIterator<E> { // MatrixMapIteratorImpl protected MatrixIterator<E> iterator = null; + protected List[] semantics = null; + protected int pos = 0; /** - * @param iterator la matrice sur lequel l'iterator doit travailler + * @param iterator la matrice sur lequel l'iterator doit travailler * @param semantics la semantique de matrix, si matrix n'a pas de semantique - * alors il faut passer null + * alors il faut passer null */ public MatrixMapIteratorImpl(MatrixIterator<E> iterator, List[] semantics) { this.iterator = iterator; @@ -493,7 +501,7 @@ if (semantics != null) { int[] coordinates = getCoordinates(); result = MatrixHelper.dimensionToSemantics(semantics, - coordinates); + coordinates); } return result; } @@ -502,7 +510,7 @@ /** * Collection particuliere utilisee pour la stockage des semantiques. - * <p> + * <p/> * Sert a optimiser la recherche de la position d'une donnee dans la liste. * Permet aussi de verifier qu'on ajoute pas de doublon dans la liste * @@ -511,6 +519,7 @@ public static class SemanticList<T> extends AbstractList<T> implements RandomAccess { protected ArrayList<T> datas = null; + protected Map<T, Integer> index = new HashMap<T, Integer>(); public SemanticList() { @@ -589,22 +598,22 @@ * dimension qui n'existe pas, elle les ajoutes dans les semantiques. Ceci * n'est vrai que pour le set avec des semantiques, le set avec des indices * ne rend pas la matrice elastique. - * <p> + * <p/> * Cette classe fonctionne avec une matrice interne que l'on change lorsque * l'on a besoin de modifier les dimensions. Le changement de dimension * a donc un cout (creation d'une nouvelle matrice, copie des elements) - * <p> + * <p/> * Si on cree une sous matrice, et que l'on modifie la matrice mere * La sous matrice n'est pas impacter, puisqu'elle est base sur l'ancienne * represention interne de la matrice elastique, les deux matrices n'ont donc * plus de lien. - * <p> + * <p/> * Les methodes reduce et extend retourne de nouvelle matrice qui ne sont * pas elastique. Si on veut qu'elle le soit, il faut les reencapsuler * * @param <E> */ - static public class MatrixMapElastic<E> implements MatrixMap<E> { + public static class MatrixMapElastic<E> implements MatrixMap<E> { protected MatrixMap<E> internalMatrixMap; @@ -772,13 +781,13 @@ * Implantation de MatrixMap dont les dimensions sont fixees a la creation * Les dimensions ne change plus par la suite */ - static public class MatrixMapFixed<E> extends AbstractMatrixMap<E> { + public static class MatrixMapFixed<E> extends AbstractMatrixMap<E> { /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(MatrixMapFixed.class); protected Matrix<E> matrix = null; - public MatrixMapFixed(List ... semantics) { + public MatrixMapFixed(List... semantics) { super(semantics); } @@ -799,13 +808,13 @@ this.pasteIndex(matrix); } - protected Matrix<E> getMatrix(){ + protected Matrix<E> getMatrix() { if (matrix == null) { matrix = new Matrix<E>(getDim()); } return matrix; } - + @Override public MatrixMapIterator<E> iterator() { return new MatrixMapIteratorImpl<E>(getMatrix().iterator(), getSemantics()); @@ -818,7 +827,7 @@ } @Override - public E getValueIndex(int ... coordinates) { + public E getValueIndex(int... coordinates) { if (coordinates.length == 0) { throw new IllegalArgumentException("Coordinates must not be empty"); } @@ -828,15 +837,15 @@ /** * Modifie un element de la matrice en fonction des dimensions passé en * paramètre.<br> - * + * <p/> * Exemple: Si on a un matrice 3D.<br> * m.set(v, [1,1,1]) modifie un element de la matrice.<br> * - * @param value la value a inserer + * @param value la value a inserer * @param coordinates les coordonées où faire le remplacement */ @Override - public void setValueIndex(E value, int ... coordinates) { + public void setValueIndex(E value, int... coordinates) { if (coordinates.length == 0) { throw new IllegalArgumentException("Coordinates must not be empty"); } @@ -849,7 +858,7 @@ * éléments pouvant être copier le seront. * * @param origin le point à partir duquel il faut faire la copie - * @param mat la matrice à copier + * @param mat la matrice à copier * @return return la matrice courante. */ public MatrixMap<E> paste(int[] origin, MatrixMap<E> mat) { @@ -864,9 +873,9 @@ origin0 = origin0 && origin[i] == 0; } if (origin0 - && mat instanceof MatrixMapFixed - && Arrays.equals(mat.getDim(), this.getDim())) { - getMatrix().data.paste(((MatrixMapFixed<E>)mat).getMatrix().data); + && mat instanceof MatrixMapFixed + && Arrays.equals(mat.getDim(), this.getDim())) { + getMatrix().data.paste(((MatrixMapFixed<E>) mat).getMatrix().data); } else { super.paste(origin, mat); } @@ -879,10 +888,10 @@ /** * Classe abstraite permettant de facilement implanter les matrice fixe, * elastique et submatrix - * + * * @param <E> */ - static public abstract class AbstractMatrixMap<E> implements MatrixMap<E> { + public static abstract class AbstractMatrixMap<E> implements MatrixMap<E> { /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(AbstractMatrixMap.class); @@ -894,7 +903,7 @@ protected int[] dim = null; protected SemanticList[] semantics = null; - + protected void init(int[] dim) { this.dim = new int[dim.length]; System.arraycopy(dim, 0, this.dim, 0, dim.length); @@ -911,7 +920,7 @@ } } - public AbstractMatrixMap(List ... semantics) { + public AbstractMatrixMap(List... semantics) { int[] dim = new int[semantics.length]; for (int i = 0; i < dim.length; i++) { if (semantics[i] == null) { @@ -1033,13 +1042,13 @@ */ @Override public MatrixMap<E> map(MapFunction<E> f) { - for (MatrixMapIterator<E> i = iterator(); i.hasNext();) { + for (MatrixMapIterator<E> i = iterator(); i.hasNext(); ) { i.setValue(f.apply(i.next())); } return this; } - public E getValue(Object ... coordinates) { + public E getValue(Object... coordinates) { if (coordinates.length == 0) { throw new IllegalArgumentException("Coordinates must not be empty"); } @@ -1049,7 +1058,7 @@ return result; } - public void setValue(E value, Object ... coordinates) { + public void setValue(E value, Object... coordinates) { if (coordinates.length == 0) { throw new IllegalArgumentException("Coordinates must not be empty"); } @@ -1079,7 +1088,7 @@ result = ObjectUtils.equals(dimName1, dimName2); if (log.isTraceEnabled()) { log.trace("dimName1(" + dimName1 + ")==dimName2(" + dimName2 - + ")=" + result); + + ")=" + result); } // System.out.println("dimName1("+dimName1+")==dimName2("+dimName2+ // ")="+result); @@ -1113,7 +1122,7 @@ result = result && MatrixHelper.sameDimension(getDim(), mat.getDim()); // toutes les données doivent être identique - for (MatrixMapIterator<E> i = mat.iterator(); result && i.hasNext();) { + for (MatrixMapIterator<E> i = mat.iterator(); result && i.hasNext(); ) { E v1 = i.next(); E v2 = getValueIndex(i.getCoordinates()); result = v1 == v2; @@ -1133,7 +1142,7 @@ * v1, v2, v3 * ] * </pre> - * + * <p/> * Si la matrice est 2D * <pre> * MaMatrice(matrix2D) [ @@ -1144,7 +1153,7 @@ * DimC v7, v8, v9 * ] * </pre> - * + * <p/> * Pour les autres types de matrice la methode {@link #toStringGeneric() } * est utilise * @@ -1207,6 +1216,7 @@ /** * Representation string de la matrice quelque soit le nombre de dimension + * * @return */ public String toStringGeneric() { @@ -1218,7 +1228,7 @@ result.append(getDim()[i] + ","); } result.append("]\ndata = ["); - for (MatrixMapIterator i = this.iterator(); i.hasNext();) { + for (MatrixMapIterator i = this.iterator(); i.hasNext(); ) { result.append(i.next() + ","); } result.append("]\n"); @@ -1256,7 +1266,7 @@ protected MatrixMap<E> paste(int[] origin, MatrixMap<E> mat) { if (mat != null) { - for (MatrixMapIterator<E> mi = mat.iterator(); mi.hasNext();) { + for (MatrixMapIterator<E> mi = mat.iterator(); mi.hasNext(); ) { E value = mi.next(); int[] coordinates = ArrayUtil.sum(origin, mi.getCoordinates()); if (isValidCoordinates(coordinates)) { @@ -1274,7 +1284,7 @@ */ public MatrixMap<E> paste(MatrixMap<E> mat) { if (mat != null) { - for (MatrixMapIterator<E> mi = mat.iterator(); mi.hasNext();) { + for (MatrixMapIterator<E> mi = mat.iterator(); mi.hasNext(); ) { E value = mi.next(); Object[] sems = mi.getSemanticsCoordinates(); if (isValidCoordinates(sems)) { @@ -1290,15 +1300,15 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice si dim est - * négatif alors la dimension est prise à partir de la fin par - * exemple si l'on veut la derniere dimension il faut passer -1 - * pour dim + * @param dim la dimension dans lequel on veut une sous matrice si dim est + * négatif alors la dimension est prise à partir de la fin par + * exemple si l'on veut la derniere dimension il faut passer -1 + * pour dim * @param start la position dans dim d'ou il faut partir pour prendre la - * sous matrice. - * @param nb le nombre d'élément à prendre dans la dimension. si nb est - * inférieur ou égal à 0 alors cela indique qu'il faut prendre - * tous les éléments jusqu'à la fin de la dimension. + * sous matrice. + * @param nb le nombre d'élément à prendre dans la dimension. si nb est + * inférieur ou égal à 0 alors cela indique qu'il faut prendre + * tous les éléments jusqu'à la fin de la dimension. * @return new matrix */ public MatrixMap<E> getSubMatrix(int dim, int start, int nb) { @@ -1319,14 +1329,14 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice + * @param dim la dimension dans lequel on veut une sous matrice * @param start la position dans dim d'ou il faut partir pour prendre la - * sous matrice. 0 <= start < dim.size si start est négatif alors - * la position de départ est calculé par rapport à la fin de la - * dimension, pour avoir le dernier élément il faut passer -1 - * @param nb le nombre d'élément à prendre dans la dimension si nb est - * inférieur ou égal à 0 alors cela indique qu'il faut prendre - * tous les éléments jusqu'à la fin de la dimension. + * sous matrice. 0 <= start < dim.size si start est négatif alors + * la position de départ est calculé par rapport à la fin de la + * dimension, pour avoir le dernier élément il faut passer -1 + * @param nb le nombre d'élément à prendre dans la dimension si nb est + * inférieur ou égal à 0 alors cela indique qu'il faut prendre + * tous les éléments jusqu'à la fin de la dimension. * @return new matrix */ public MatrixMap<E> getSubMatrix(int dim, Object start, int nb) { @@ -1352,7 +1362,7 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice + * @param dim la dimension dans lequel on veut une sous matrice * @param elem les éléments dans la dimension à conserver * @return new matrix */ @@ -1366,7 +1376,7 @@ /** * Permet de prendre une sous matrice dans la matrice courante. - * + * <p/> * Réalise plusieurs appels à {@link #getSubMatrix(int, Object...)} suivant * l'implémentation. * @@ -1396,7 +1406,7 @@ * matrice a le même nombre de dimensions mais sur une des dimensions on ne * prend que certain élément. * - * @param dim la dimension dans lequel on veut une sous matrice + * @param dim la dimension dans lequel on veut une sous matrice * @param elem les indices des éléments dans la dimension à conserver * @return new matrix */ @@ -1406,7 +1416,7 @@ /** * Permet de prendre une sous matrice dans la matrice courante. - * + * <p/> * Réalise plusieurs appels a {@link #getSubMatrix(int, int[])} suivant * l'implementation. * @@ -1469,7 +1479,7 @@ // si la dimension à plus d'un élément ou qu'il n'est pas dans dims // on garde la dimension if (getDim(j) > 1 || Arrays.binarySearch(dims, j) < 0 - || j < minNbDim) { + || j < minNbDim) { // on ne conserve que les dimensions supérieure à 1 correspondance[sem.size()] = j; sem.add(getSemantic(j)); @@ -1487,7 +1497,7 @@ * seule dimension à un seul élément. * * @param minNbDim le nombre minimum de dimension que l'on souhaite pour la - * matrice résultat + * matrice résultat * @return une nouvelle matrice plus petite que la matrice actuelle ou egal * s'il n'y a aucune dimension à supprimer */ @@ -1523,10 +1533,10 @@ /** * Create new matrice from the current matrix. * - * @param dimName dimension name for new matrix - * @param sem semantic for new matrix + * @param dimName dimension name for new matrix + * @param sem semantic for new matrix * @param correspondance array to do the link between current matrix and - * returned matrix + * returned matrix * @return new matrix */ protected MatrixMap<E> reduce(List<String> dimName, List<List> sem, int[] correspondance) { @@ -1547,7 +1557,7 @@ // on reprend les valeurs int[] newCoordinates = new int[result.getDimCount()]; - for (MatrixMapIterator<E> mi = iterator(); mi.hasNext();) { + for (MatrixMapIterator<E> mi = iterator(); mi.hasNext(); ) { E value = mi.next(); int[] oldCoordinates = mi.getCoordinates(); for (int i = 0; i < newCoordinates.length; i++) { @@ -1579,7 +1589,7 @@ } // si les objets demande n'existe pas dans la semantics on l'ajoute - for (int i = 0; i<sems.length; i++) { + for (int i = 0; i < sems.length; i++) { if (semantics[i].indexOf(sems[i]) == -1) { semantics[i].add(sems[i]); } @@ -1596,12 +1606,13 @@ * Pour l'instant une sous matrice a obligatoirement le meme nombre de dimension * que la matrice qu'elle contient. Elle permet juste de reduire le nombre * d'element d'une dimension. - * + * <p/> * C'est comme une "vue" réduite sur la vraie matrices. */ - static public class SubMatrix<E> extends AbstractMatrixMap<E> { // SubMatrix + public static class SubMatrix<E> extends AbstractMatrixMap<E> { // SubMatrix protected MatrixMap<E> matrix = null; + protected DimensionConverter converter = null; public SubMatrix(MatrixMap<E> matrix, int dim, int start, int nb) { @@ -1634,19 +1645,21 @@ } @Override - public E getValueIndex(int ... coordinates) { + public E getValueIndex(int... coordinates) { return matrix.getValueIndex(converter.convertCoordinates(coordinates)); } @Override - public void setValueIndex(E value, int ... coordinates) { + public void setValueIndex(E value, int... coordinates) { matrix.setValueIndex(value, converter.convertCoordinates(coordinates)); } protected class SubMatrixIterator<E> implements MatrixMapIterator<E> { protected SubMatrix<E> subMatrix = null; + protected int[] cpt = null; + protected int[] last = null; public SubMatrixIterator(SubMatrix<E> subMatrix) { @@ -1711,16 +1724,16 @@ public int[] convertCoordinates(int[] coordinates); } - /** - * La conversion est juste un decalage d'indice - */ + /** La conversion est juste un decalage d'indice */ protected static class ShiftConverter implements DimensionConverter { /** serialVersionUID. */ private static final long serialVersionUID = 1L; protected int dim; + protected int start; + protected int nb; public ShiftConverter(int dim, int start, int nb) { @@ -1744,14 +1757,14 @@ } } - /** - * La conversion est le mapping d'un element vers un autre element. - */ + /** La conversion est le mapping d'un element vers un autre element. */ protected static class MappingConverter implements DimensionConverter { /** serialVersionUID. */ private static final long serialVersionUID = -6367416559713556559L; + protected int dim; + protected int[] elem = null; public MappingConverter(int dim, int[] elem) { @@ -1781,10 +1794,11 @@ * Objet matrice qui ne permet que le stockage avec des positions int * dans une matrice a autant de dimension que l'on souhaite. */ - static public class Matrix<E> implements Iterable<E> { // BasicMatrix + public static class Matrix<E> implements Iterable<E> { // BasicMatrix /** Les dimensions de la matrice */ protected int[] dimensions = null; + /** La matrice en représentation linéaire */ protected Vector<E> data = null; @@ -1862,7 +1876,7 @@ /** * Modifie un élement de la matrice * - * @param pos la position de l'element à modifier + * @param pos la position de l'element à modifier * @param value la nouvelle valeur à mettre dans la matrice */ public void setValue(int[] pos, E value) { @@ -1957,7 +1971,7 @@ * * @param pos les coordonnées souhaitées dans la matrice * @throws NoSuchElementException si les coordonnées ne correspondent pas à - * un élement de la matrice + * un élement de la matrice */ protected void checkPos(int[] pos) { int[] dim = getDim(); @@ -2016,7 +2030,7 @@ if (o instanceof Matrix) { Matrix other = (Matrix) o; return this == o - || (Arrays.equals(this.dimensions, other.dimensions) && this.data + || (Arrays.equals(this.dimensions, other.dimensions) && this.data .equals(other.data)); } return false; @@ -2024,14 +2038,13 @@ } // BasicMatrix - static public class MatrixIterator<E> implements Iterator<E> { // MatrixIteratorImpl + public static class MatrixIterator<E> implements Iterator<E> { // MatrixIteratorImpl protected Matrix<E> matrix = null; + protected int pos = -1; - /** - * @param matrix la matrice sur lequel l'iterator doit travailler - */ + /** @param matrix la matrice sur lequel l'iterator doit travailler */ public MatrixIterator(Matrix<E> matrix) { this.matrix = matrix; pos = -1; @@ -2077,9 +2090,8 @@ * Cette classe ne gére que les données lineaire. L'avantage de cette classe est * de ne conserver que les elements differents de la valeur par defaut, ce qui * minimize la taille du tableau necessaire a conserver les données. - * */ - static public class Vector<E> { // Vector + public static class Vector<E> { // Vector /** maximum number of element, maximum pos value */ protected int capacity = 0; @@ -2089,6 +2101,7 @@ /** contient la position de l'element, le tableau est trie */ protected int[] position; + protected int positionSize = 0; /** contient la valeur de l'element */ @@ -2114,7 +2127,7 @@ public E getMaxOccurrence() { E result = defaultValue; - E[] tmp = (E[])data.toArray(); + E[] tmp = (E[]) data.toArray(); // si potentiellement il y a plus d'element identique dans data // que de valeur par defaut, on recherche la valeur possible @@ -2166,7 +2179,7 @@ protected void checkPos(int pos) { if (pos < 0 || pos >= capacity) { throw new IllegalArgumentException("pos " + pos + " is not in [0, " - + capacity + "]"); + + capacity + "]"); } } @@ -2211,7 +2224,7 @@ if (o instanceof Vector) { Vector other = (Vector) o; result = Arrays.equals(this.position, other.position) - && data.equals(other.data); + && data.equals(other.data); } return result; } @@ -2268,14 +2281,12 @@ this.positionSize = v.positionSize; this.position = new int[v.position.length]; System.arraycopy(v.position, 0, this.position, 0, - this.position.length); + this.position.length); this.data.clear(); this.data.addAll(v.data); } - /** - * on applique sur chaque donnée existante et sur default - */ + /** on applique sur chaque donnée existante et sur default */ public void map(MapFunction<E> f) { // on commence toujours par modifier la valeur par defaut // car les valeurs suivante pourrait prendre cette valeur @@ -2300,7 +2311,7 @@ * Permet de faire un traitement sur des valeurs et d'en retourner * des nouvelles. */ - static public interface MapFunction<E> { // MapFunction + public static interface MapFunction<E> { // MapFunction /** * Permet de faire un traitement sur value et de retourne une nouvelle Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/MonthEnum.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/MonthEnum.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/MonthEnum.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -72,7 +72,7 @@ log.error( _("nuitonutil.error.unfound.month", month, defaultValue), e); - } + } return monthEnum == null ? defaultValue : monthEnum; } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ObjectUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -66,7 +66,7 @@ * Created: 4 novembre 2004 * * @author bpoussin <poussin@codelutin.com> - * $Id$ + * $Id$ */ public class ObjectUtil { // ObjectUtil @@ -74,35 +74,41 @@ static private Log log = LogFactory.getLog(ObjectUtil.class); protected static final Integer ZERO = 0; - protected static final Character ZEROC = (char)0; + + protected static final Character ZEROC = (char) 0; + protected static final Float ZEROF = 0f; + protected static final Long ZEROL = 0l; + protected static final Double ZEROD = 0.; + protected static final Byte ZEROB = 0; /** - * ObjectUtil constructor - * private because of this class is a static class : nobody - * can make an instance of this class - */ - private ObjectUtil() {} + * ObjectUtil constructor + * private because of this class is a static class : nobody + * can make an instance of this class + */ + private ObjectUtil() { + } /** * Invoke constructor on clazz to create new instance. Try to find argument * for constructor in args parameter. * - * @param clazz class of object to instanciate - * @param args all possible parameter that constructor can used + * @param clazz class of object to instanciate + * @param args all possible parameter that constructor can used * @param nullIfMissing if no suitable class or object found in args, - * use null value (no exception) + * use null value (no exception) * @return new instance * @throws IllegalArgumentException if something is wrong during instanciation */ - static public <E> E newInstance(Class<E> clazz, + public static <E> E newInstance(Class<E> clazz, Collection<?> args, boolean nullIfMissing) { Constructor<E>[] constructors = - (Constructor<E>[])clazz.getConstructors(); + (Constructor<E>[]) clazz.getConstructors(); if (constructors.length != 1) { throw new IllegalArgumentException( _("nuitonutil.error.class.with.more.than.one.constructor", @@ -116,7 +122,7 @@ Class<?>[] paramTypes = constructor.getParameterTypes(); Object[] params = new Object[paramTypes.length]; - for (int i=0; i<paramTypes.length; i++) { + for (int i = 0; i < paramTypes.length; i++) { Object o = choiceArgument(paramTypes[i], container, nullIfMissing); params[i] = o; } @@ -127,7 +133,7 @@ } catch (Exception eee) { throw new IllegalArgumentException(_( _("nuitonutil.error.cant.instanciate.class", - clazz, Arrays.toString(params))), eee); + clazz, Arrays.toString(params))), eee); } } @@ -136,8 +142,8 @@ * possible de candidat. Les candidats peuvent etre des classes qu'il faudra * instancier pour satisfaire le type demande. * - * @param clazz le type recherché - * @param args la liste des arguments ou des types + * @param clazz le type recherché + * @param args la liste des arguments ou des types * @param nullIfMissing pour retourner nulle si l'argument n'est pas trouvé * @return le type d'argument trouvé */ @@ -184,19 +190,19 @@ /** * Create new object from string like org.nuiton.Toto(name=machine, int=10) * where machine and int is properties on org.nuiton.Toto object. - * Conversion between 10 in string and 10 as integer as automaticaly done - * + * Conversion between 10 in string and 10 as integer as automaticaly done + * <p/> * For String property you can use ex: * <li> name="my string with , in string" * <li> name='my string with , in string' - * + * * @param classnameAndProperties * @return the instanciated object - * @throws ClassNotFoundException - * @throws IllegalAccessException - * @throws InstantiationException - * @throws NoSuchMethodException - * @throws InvocationTargetException + * @throws ClassNotFoundException + * @throws IllegalAccessException + * @throws InstantiationException + * @throws NoSuchMethodException + * @throws InvocationTargetException */ public static Object create(String classnameAndProperties) throws ClassNotFoundException, @@ -206,7 +212,7 @@ NoSuchMethodException { int p = classnameAndProperties.indexOf('('); int l = classnameAndProperties.lastIndexOf(')'); - String [] properties = null; + String[] properties = null; String classname; if (p != -1) { String tmp = classnameAndProperties.substring(p + 1, l); @@ -222,13 +228,13 @@ for (String prop : properties) { int e = prop.indexOf('='); String propName = prop.substring(0, e).trim(); - String propValue = prop.substring(e+1).trim(); + String propValue = prop.substring(e + 1).trim(); if (propValue.charAt(0) == '"' && - propValue.charAt(propValue.length()-1) == '"') { - propValue = propValue.substring(1, propValue.length()-1); + propValue.charAt(propValue.length() - 1) == '"') { + propValue = propValue.substring(1, propValue.length() - 1); } else if (propValue.charAt(0) == '\'' && - propValue.charAt(propValue.length()-1) == '\'') { - propValue = propValue.substring(1, propValue.length()-1); + propValue.charAt(propValue.length() - 1) == '\'') { + propValue = propValue.substring(1, propValue.length() - 1); } BeanUtils.setProperty(o, propName, propValue); } @@ -240,8 +246,8 @@ Object t = ConvertUtils.convert(v, clazz); if (t != null && - !String.class.getName().equals(clazz.getName()) && - String.class.getName().equals(t.getClass().getName())) { + !String.class.getName().equals(clazz.getName()) && + String.class.getName().equals(t.getClass().getName())) { throw new IllegalArgumentException(String.format( "Can convert argument to correct type. %s can't be" + " converted from String to %s conversion is done to %s", @@ -253,7 +259,7 @@ /** * Clone object by introspection because Cloneable interface don't permit * to call clone :(. This methode replace next code that don't work :( - * + * <p/> * <pre> * if (o instanceof Cloneable) { * Object n = ((Cloneable)o).clone(); @@ -264,7 +270,7 @@ * @return new instance of E * @throws CloneNotSupportedException if some error occur during clone */ - static public <E extends Cloneable> E clone(E e) throws CloneNotSupportedException { + public static <E extends Cloneable> E clone(E e) throws CloneNotSupportedException { try { E result = (E) MethodUtils.invokeExactMethod(e, "clone", null); return result; @@ -278,11 +284,12 @@ /** * Use serialization/deserialization to do deep clone of object + * * @param e object to clone * @return new instance of E * @throws CloneNotSupportedException if some error occur during clone */ - static public <E> E deepClone(E e) throws CloneNotSupportedException { + public static <E> E deepClone(E e) throws CloneNotSupportedException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); @@ -313,8 +320,9 @@ /** * Call method m with params as String. Each param is converted to required type for * method with beanutils converter - * @param o object where method must be call - * @param m method to call + * + * @param o object where method must be call + * @param m method to call * @param params parameters for method call * @return returned method's value * @throws IllegalAccessException @@ -322,7 +330,7 @@ * @throws InvocationTargetException * @throws InstantiationException */ - public static Object call(Object o, Method m, String ... params) + public static Object call(Object o, Method m, String... params) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException { Class<?>[] types = m.getParameterTypes(); if (!m.isVarArgs() && params.length != types.length) { @@ -330,31 +338,31 @@ "Bad number params we have %1$s parameters and waiting %2$s.", params.length, types.length)); } - + int last = types.length; if (m.isVarArgs()) { // on traite le dernier differement last--; } - + Object[] parameters = new Object[types.length]; - for (int i=0; i<last; i++) { + for (int i = 0; i < last; i++) { String v = params[i]; Class<?> clazz = types[i]; Object t = convert(v, clazz); parameters[i] = t; } - + if (m.isVarArgs()) { Class<?> clazz = types[last]; // get var args type clazz = clazz.getComponentType(); // get array component type List<Object> tmp = new ArrayList<Object>(); - for (int i=last; i<params.length; i++) { + for (int i = last; i < params.length; i++) { String v = params[i]; Object t = convert(v, clazz); tmp.add(t); } - parameters[last] = tmp.toArray((Object[])Array.newInstance(clazz, tmp.size())); + parameters[last] = tmp.toArray((Object[]) Array.newInstance(clazz, tmp.size())); } if (log.isDebugEnabled()) { @@ -363,11 +371,11 @@ Object result = m.invoke(o, parameters); return result; } - + /** * Get all methods with name given in argument without check parameters. * - * @param clazz where to search method + * @param clazz where to search method * @param methodName method name to search * @param ignoreCase if true, ignore difference in method name case * @return list of detected methods @@ -376,22 +384,22 @@ String methodName, boolean ignoreCase) { List<Method> result = new ArrayList<Method>(); - + Method[] methods = clazz.getMethods(); for (Method m : methods) { - if(ignoreCase && methodName.equalsIgnoreCase(m.getName()) || - methodName.equals(m.getName())) { + if (ignoreCase && methodName.equalsIgnoreCase(m.getName()) || + methodName.equals(m.getName())) { result.add(m); } } - + return result; } - + public static Object newInstance(String constructorWithParams) throws ClassNotFoundException { int p = constructorWithParams.indexOf('('); int l = constructorWithParams.lastIndexOf(')'); - String [] params = null; + String[] params = null; String classname; if (p != -1) { String tmp = constructorWithParams.substring(p + 1, l); @@ -410,23 +418,23 @@ * Each param is converted to required type for * constructor with beanutils converter, first constructor that permit * instanciation is used - * - * @param <T> type to instanciate - * @param clazz class to instanciate + * + * @param <T> type to instanciate + * @param clazz class to instanciate * @param params parameters for constructor call * @return new instance of clazz - * @throws IllegalArgumentException + * @throws IllegalArgumentException */ - public static <T> T newInstance(Class<T> clazz, String ... params) + public static <T> T newInstance(Class<T> clazz, String... params) throws IllegalArgumentException { if (params == null) { params = StringUtil.EMPTY_STRING_ARRAY; } List<Constructor<T>> constructors = getConstructor(clazz, params.length); - + for (Constructor<T> c : constructors) { try { - Class<?>[] types = c.getParameterTypes(); + Class<?>[] types = c.getParameterTypes(); int last = types.length; if (c.isVarArgs()) { @@ -465,9 +473,9 @@ clazz, Arrays.toString(parameters))); } T result = c.newInstance(parameters); - + return result; - } catch(Exception eee) { + } catch (Exception eee) { // this constructors don't work, try next if (log.isDebugEnabled()) { log.debug("Creation failed try with next constructor"); @@ -476,17 +484,17 @@ } throw new IllegalArgumentException( _("nuitonutil.debug.objectutil.instantiate", - clazz, Arrays.toString(params))); + clazz, Arrays.toString(params))); } - + /** * Get all constructors that support paramNumber as parameters numbers. * Varargs is supported - * - * @param <T> le type de la classe a inspecter - * @param clazz la classe sur lequel rechercher le constructeur + * + * @param <T> le type de la classe a inspecter + * @param clazz la classe sur lequel rechercher le constructeur * @param paramNumber le nombre de parametre souhaite pour le constructeur, - * -1 indique que tous les constructeur sont souhaite. + * -1 indique que tous les constructeur sont souhaite. * @return list of constructors */ @SuppressWarnings("unchecked") @@ -494,115 +502,123 @@ int paramNumber) { List<Constructor<T>> result = new ArrayList<Constructor<T>>(); Constructor<T>[] constructors = - (Constructor<T>[])clazz.getConstructors(); + (Constructor<T>[]) clazz.getConstructors(); for (Constructor<T> c : constructors) { if (paramNumber < 0 || c.isVarArgs() && c.getParameterTypes().length <= paramNumber - 1 || - c.getParameterTypes().length == paramNumber) { + c.getParameterTypes().length == paramNumber) { result.add(c); } } - + return result; } - + /** - * Method toObject - * - * @param o Object to transform - * @return the same object - */ - public static Object toObject(Object o){ + * Method toObject + * + * @param o Object to transform + * @return the same object + */ + public static Object toObject(Object o) { return o; } /** - * Method toObject - * - * transform a char to a Character Object - * @param c the char to transform - * @return the Charactere object corresponding - */ - public static Object toObject(char c){ + * Method toObject + * <p/> + * transform a char to a Character Object + * + * @param c the char to transform + * @return the Charactere object corresponding + */ + public static Object toObject(char c) { return new Character(c); } /** - * Method toObject - * - * transform a byte to a Byte Object - * @param b the byte to transform - * @return the byte object corresponding - */ - public static Object toObject(byte b){ + * Method toObject + * <p/> + * transform a byte to a Byte Object + * + * @param b the byte to transform + * @return the byte object corresponding + */ + public static Object toObject(byte b) { return new Byte(b); } /** - * Method toObject - * - * transform a short to a Short object - * @param s the short to transform - * @return the Short object corresponding - */ - public static Object toObject(short s){ + * Method toObject + * <p/> + * transform a short to a Short object + * + * @param s the short to transform + * @return the Short object corresponding + */ + public static Object toObject(short s) { return new Short(s); } /** - * Method toObject - * - * transform an int to an Integer object - * @param i the int to transform - * @return the Integer Object corresponding - */ - public static Object toObject(int i){ + * Method toObject + * <p/> + * transform an int to an Integer object + * + * @param i the int to transform + * @return the Integer Object corresponding + */ + public static Object toObject(int i) { return new Integer(i); } /** - * Method toObject - * - * transform a long to a Long object - * @param l the long to transform - * @return the Long Object corresponding - */ - public static Object toObject(long l){ + * Method toObject + * <p/> + * transform a long to a Long object + * + * @param l the long to transform + * @return the Long Object corresponding + */ + public static Object toObject(long l) { return new Long(l); } /** - * Method toObject - * - * transform a float to a Float Object - * @param f the float to transform - * @return the Float Object corresponding - */ - public static Object toObject(float f){ + * Method toObject + * <p/> + * transform a float to a Float Object + * + * @param f the float to transform + * @return the Float Object corresponding + */ + public static Object toObject(float f) { return new Float(f); } /** - * Method toObject - * - * transform a double to a Double object - * @param d the double to transform - * @return the Double object corresponding - */ - public static Object toObject(double d){ + * Method toObject + * <p/> + * transform a double to a Double object + * + * @param d the double to transform + * @return the Double object corresponding + */ + public static Object toObject(double d) { return new Double(d); } /** - * Method toObject - * - * transform a boolean to a Boolean object - * @param b the boolean to transform - * @return the Boolean object corresponding - */ - public static Object toObject(boolean b){ - return b?Boolean.TRUE:Boolean.FALSE; + * Method toObject + * <p/> + * transform a boolean to a Boolean object + * + * @param b the boolean to transform + * @return the Boolean object corresponding + */ + public static Object toObject(boolean b) { + return b ? Boolean.TRUE : Boolean.FALSE; } /** @@ -690,7 +706,7 @@ public static boolean isNullValue(boolean value) { return Boolean.FALSE.equals(value); } - + public static boolean isNullValue(byte value) { return value == ZEROB; } @@ -711,7 +727,7 @@ return value == ZEROD; } - /** + /** * Verifie si la classe est de type primitif. * * @param clazz nom de la classe a tester @@ -719,10 +735,10 @@ */ public static boolean isPrimitive(Class<?> clazz) { return clazz.isPrimitive() || clazz == Boolean.class - || clazz == Byte.class || clazz == Character.class - || clazz == Short.class || clazz == Integer.class - || clazz == Long.class || clazz == Float.class - || clazz == Double.class; + || clazz == Byte.class || clazz == Character.class + || clazz == Short.class || clazz == Integer.class + || clazz == Long.class || clazz == Float.class + || clazz == Double.class; } /** Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/PeriodDates.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/PeriodDates.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/PeriodDates.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -34,7 +34,7 @@ /** * TODO tchemit 2010-08-25 JAVADOC + I18N * PeriodDates.java - * + * <p/> * Created on 2009-08-13 * * @author fdesbois @@ -50,7 +50,7 @@ private Calendar thruCalendar; - public PeriodDates() { + public PeriodDates() { } public PeriodDates(Date fromDate, Date thruDate) throws IllegalArgumentException { @@ -60,7 +60,7 @@ setFromDate(fromDate); setThruDate(thruDate); - + pattern = DateUtil.DEFAULT_PATTERN; } @@ -122,13 +122,11 @@ this.pattern = pattern; } - /** - * Set first day of month for dateFrom and last day of month for dateThru - */ + /** Set first day of month for dateFrom and last day of month for dateThru */ public void initDayOfMonthExtremities() { if (fromCalendar == null || thruCalendar == null) { throw new NullPointerException("fromDate or thruDate can't be null to" + - " change dayOfMonth extremities"); + " change dayOfMonth extremities"); } Date fromDate = fromCalendar.getTime(); fromDate = DateUtil.setFirstDayOfMonth(fromDate); @@ -184,10 +182,10 @@ } public List<Date> getMonths() { - List<Date> months = new ArrayList<Date>(); - if (fromCalendar == null || thruCalendar == null) { - return months; - } + List<Date> months = new ArrayList<Date>(); + if (fromCalendar == null || thruCalendar == null) { + return months; + } // Calendar current = (Calendar) fromCalendar.clone(); // current.set(Calendar.DAY_OF_MONTH, 1); @@ -257,14 +255,14 @@ Calendar calendar = DateUtil.getDefaultCalendar(date); return between(calendar); } - + @Override public String toString() { String fromStr = DateUtil.formatDate(getFromDate(), pattern); String thruStr = DateUtil.formatDate(getThruDate(), pattern); return "[ " + getFromDate() + " (pattern: " + fromStr + ") -> " + - getThruDate() + " (pattern: " + thruStr + ") ]"; + getThruDate() + " (pattern: " + thruStr + ") ]"; } } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/PropertiesDateRemoveFilterStream.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/PropertiesDateRemoveFilterStream.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/PropertiesDateRemoveFilterStream.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -32,18 +32,19 @@ /** * Class used to not print first line into delegated {@link OutputStream}. - * + * <p/> * Used to remove first comment line writed by {@link Properties#store(OutputStream, String)}. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class PropertiesDateRemoveFilterStream extends FilterOutputStream { protected boolean firstLineOver; + protected char endChar; public PropertiesDateRemoveFilterStream(OutputStream out) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/RecursiveProperties.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/RecursiveProperties.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/RecursiveProperties.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -48,7 +48,7 @@ * <li>getProperty("namePhrase") renverra "My name is Thimel." * <li>getProperty("instruction") renverra "Put your text like this : ${myText}" * </ul> - * + * * @author Arnaud Thimel <thimel@codelutin.com> */ public class RecursiveProperties extends Properties { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ReflectUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ReflectUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ReflectUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -50,7 +50,7 @@ * Created: 30 décembre 2007 * * @author tchemit <chemit@codelutin.com> - * $Id$ + * $Id$ */ public class ReflectUtil { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/Resource.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -624,13 +624,13 @@ /** * Find pattern resouces in {@link ClassLoader#getSystemClassLoader()}. - * + * <p/> * Usage : * <pre> * List<URL> urls = Resources.getResources("META-INF/.*\\.MF"); * List<URL> urls = Resources.getResources("org/nuiton/util/.?esource\\.class"); * </pre> - * + * * @param pattern java regex style pattern to find * @return url list found * @throws IOException if any IO problem while seeking resources @@ -642,13 +642,13 @@ /** * Find pattern resouces in classloader. - * + * <p/> * Usage : * <pre> * List<URL> urls = Resources.getResources("META-INF/.*\\.MF"); * List<URL> urls = Resources.getResources("org/nuiton/util/.?esource\\.class"); * </pre> - * + * * @param pattern java regex style pattern to find * @param classLoader classLoader * @return url list found @@ -810,7 +810,7 @@ rootEntryPath = rootEntryPath + "/"; } List<URL> result = new HashList<URL>(8); - for (Enumeration<?> entries = jarFile.entries(); entries.hasMoreElements();) { + for (Enumeration<?> entries = jarFile.entries(); entries.hasMoreElements(); ) { JarEntry entry = (JarEntry) entries.nextElement(); String entryPath = entry.getName(); if (entryPath.startsWith(rootEntryPath)) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ResourceNotFoundException.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ResourceNotFoundException.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ResourceNotFoundException.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,7 +37,7 @@ package org.nuiton.util; -public class ResourceNotFoundException extends ResourceException { // ResourceNotFoundException +public class ResourceNotFoundException extends ResourceException { // ResourceNotFoundException /** */ private static final long serialVersionUID = 623160949107461992L; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ReverseFileReader.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ReverseFileReader.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ReverseFileReader.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -32,15 +32,17 @@ /** * Reverse file reader. - * + * <p/> * Read file line by line for end of file to begin of file. - * + * * @author chatellier * @version $ID: $ */ public class ReverseFileReader implements Closeable { protected String filename; + protected RandomAccessFile randomfile; + protected long position; public ReverseFileReader(File file) throws IOException { @@ -67,7 +69,7 @@ /** * Read one line from the current position towards the beginning. - * + * * @return the next line of text from this file, or null if end of file is * encountered before even one byte is read. * @throws IOException if any pb while reading line @@ -83,7 +85,7 @@ return null; } - for (;;) { + for (; ; ) { // we've reached the beginning of the file if (position < 0) { break; @@ -102,7 +104,7 @@ randomfile.seek(position - 1); int nextCode = randomfile.readByte(); if (thisCode == 10 && nextCode == 13 - || thisCode == 13 && nextCode == 10) { + || thisCode == 13 && nextCode == 10) { // If we found another linebreak character, ignore it position = position - 1; } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/SortedProperties.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/SortedProperties.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/SortedProperties.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -35,7 +35,7 @@ * Permet d'avoir les propriétés triées. * * @author jruchaud <ruchaud@codelutin.com> - * $Id$ + * $Id$ */ public class SortedProperties extends Properties { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -31,7 +31,6 @@ import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.MessageFormat; -import java.text.Normalizer; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; @@ -48,7 +47,7 @@ * * @author bpoussin <poussin@codelutin.com> * @author tchemit <chemit@codelutin.com> - * $Id$ + * $Id$ */ public class StringUtil { // StringUtil @@ -59,25 +58,8 @@ } /** - * Cette methode retire les accents. Quand le caractere est connu, elle le - * remplace par une version sans accent sinon, elle le supprime. - * Les caracteres non-alphanumeriques sont supprimes. + * Know if a string is a valid e-mail. * - * @param s la chaine a unaccentuer - * @return la chaine sans accent - * @deprecated since 2.4.2. Use - * {@link org.apache.commons.lang3.StringUtils#stripAccents(String)} - * instead. - */ - @Deprecated - static public String unaccent(String s) { - // this is java 1.6 code - String temp = Normalizer.normalize(s, Normalizer.Form.NFD); - return temp.replaceAll("[^\\p{ASCII}]",""); - } - - /** Know if a string is a valid e-mail. - * * @param str a string * @return true if <code>str</code> is syntactically a valid e-mail address * @since 2.1 @@ -89,18 +71,18 @@ /** * Add cotes if needed to escape special csv chars (',', '\n', '\t', ',', ';') * - * @param value to escape + * @param value to escape * @param csvSeparator separator used for csv * @return escaped if needed value */ public static String escapeCsvValue(String value, String csvSeparator) { boolean valueNeedQuotes = - value.contains("\n") - || value.contains("\t") - || value.contains(",") - || value.contains(";") - || value.contains(csvSeparator); + value.contains("\n") + || value.contains("\t") + || value.contains(",") + || value.contains(";") + || value.contains(csvSeparator); if (valueNeedQuotes) { // escape '"' char to prevent @@ -111,7 +93,7 @@ } /** - * Contract to use in {@link StringUtil#join(Iterable , ToString, String, boolean) } + * Contract to use in {@link StringUtil#join(Iterable, ToString, String, boolean) } * method. This will provide a toString method to convert an object in a * string. * @@ -129,7 +111,7 @@ } /** - * Used to build csv file using {@link StringUtil#join(Iterable , ToString, String, boolean) } + * Used to build csv file using {@link StringUtil#join(Iterable, ToString, String, boolean) } * method. This will provide a toString method to convert an object in a * string and escape csv values if needed. * @@ -166,14 +148,14 @@ * by {@code separator} using the toString() method of each object. * You can specify if the string must be trimmed or not. * - * @param iterable Iterable with objects to treate + * @param iterable Iterable with objects to treate * @param separator to used - * @param trim if each string must be trim + * @param trim if each string must be trim * @return the String chain of all elements separated by separator, never - * return null, will return an empty String for an empty list. + * return null, will return an empty String for an empty list. */ - static public String join(Iterable<?> iterable, String separator, - boolean trim) { + public static String join(Iterable<?> iterable, String separator, + boolean trim) { String result = join(iterable, null, separator, trim); return result; } @@ -186,20 +168,20 @@ * to specify if each string object has to be trimmed. The null elements * in the {@code list} will be ignored. * - * @param <O> type of object in the list - * @param iterable Iterable with objects to treate - * @param ts used to specify how the object is converted in String + * @param <O> type of object in the list + * @param iterable Iterable with objects to treate + * @param ts used to specify how the object is converted in String * @param separator to used between each object string - * @param trim if trim() method need to by apply on each object string + * @param trim if trim() method need to by apply on each object string * @return the String chain of all elements separated by separator, never - * return null, will return an empty String for an empty list. + * return null, will return an empty String for an empty list. * @throws NullPointerException if iterable is {@code null}. */ - static public <O> String join(Iterable<O> iterable, ToString<O> ts, - String separator, boolean trim) throws NullPointerException { + public static <O> String join(Iterable<O> iterable, ToString<O> ts, + String separator, boolean trim) throws NullPointerException { if (iterable == null) { throw new NullPointerException("null iterable can't be used" + - " to join the elements with " + separator); + " to join the elements with " + separator); } // Do nothing for an empty list if (!iterable.iterator().hasNext()) { @@ -215,7 +197,7 @@ // Use ToString contract from argument if (ts != null) { str = ts.toString(o); - // Or call toString() method directly on object + // Or call toString() method directly on object } else { str = o.toString(); } @@ -232,31 +214,31 @@ /** * substring from begin to end of s - * + * <p/> * example: * <li> substring("tatetitotu", -4) => totu * - * @param s the string to substring + * @param s the string to substring * @param begin if begin < 0 then begin start at end of string - begin * @return the result of substring */ - static public String substring(String s, int begin) { + public static String substring(String s, int begin) { String result = substring(s, begin, s.length()); return result; } /** * substring from begin to end of s - * + * <p/> * example: * <li> substring("tatetitotu", -4, -2) => to * - * @param s the string to substring + * @param s the string to substring * @param begin if begin < 0 then begin start at end of string - begin - * @param end if end < 0 then end start at end of string - end + * @param end if end < 0 then end start at end of string - end * @return the result of substring */ - static public String substring(String s, int begin, int end) { + public static String substring(String s, int begin, int end) { if (begin < 0) { begin = s.length() + begin; } @@ -280,17 +262,17 @@ * Split string use 'separator' as separator. If String contains "'()[]{} * this method count the number of open char end close char to split * correctly argument - * + * <p/> * WARNING: cette method ne fonctionne pas si le contenu contient - * des carateres utilisé pour le parsing et présent une seule fois. - * Par exemple: "l'idenfiant" contient ' qui empeche totalement le - * parsing de fonctionner. - * + * des carateres utilisé pour le parsing et présent une seule fois. + * Par exemple: "l'idenfiant" contient ' qui empeche totalement le + * parsing de fonctionner. + * * @param args string to split * @param separator separator use to split string * @return array of string */ - static public String[] split(String args, String separator) { + public static String[] split(String args, String separator) { return split(openingChars, closingChars, args, separator); } @@ -298,16 +280,16 @@ /** * Use to split string array representation in array according with ',' as * default separator. - * + * <p/> * WARNING: cette method ne fonctionne pas si le contenu contient - * des carateres utilisé pour le parsing et présent une seule fois. - * Par exemple: "l'idenfiant" contient ' qui empeche totalement le - * parsing de fonctionner. - * + * des carateres utilisé pour le parsing et présent une seule fois. + * Par exemple: "l'idenfiant" contient ' qui empeche totalement le + * parsing de fonctionner. + * * @param stringList string that represent array * @return array with length > 0 if listAsString != null or null */ - static public String[] split(String stringList) { + public static String[] split(String stringList) { String[] result; result = split(stringList, ","); return result; @@ -319,19 +301,19 @@ * <p/> * this method count the number of open char end close char to split * correctly argument - * + * <p/> * WARNING: cette method ne fonctionne pas si le contenu contient - * des carateres utilisé pour le parsing et présent une seule fois. - * Par exemple: "l'idenfiant" contient ' qui empeche totalement le - * parsing de fonctionner. - * + * des carateres utilisé pour le parsing et présent une seule fois. + * Par exemple: "l'idenfiant" contient ' qui empeche totalement le + * parsing de fonctionner. + * * @param openingChars list of opening caracteres * @param closingChars list of closing caracteres * @param args string to split * @param separator separator use to split string * @return array of string */ - static public String[] split(Character[] openingChars, + public static String[] split(Character[] openingChars, Character[] closingChars, String args, String separator) { if (args == null) { @@ -342,7 +324,7 @@ int start = 0; int end; - StringBuffer op = new StringBuffer(); // stack of {([< currently open + StringBuilder op = new StringBuilder(); // stack of {([< currently open char last = '\0'; // contains " or ' if string is openned List<Character> opening = Arrays.asList(openingChars); @@ -363,8 +345,8 @@ // open string " or ' last = c; } else if (op.length() == 0 && - args.regionMatches(i, separator, 0, - separator.length())) { + args.regionMatches(i, separator, 0, + separator.length())) { // end of one arguement end = i; // pass separator @@ -487,10 +469,11 @@ return result; } - private static final char[] HEX_CHARS = {'0', '1', '2', '3', + private static final char[] HEX_CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',}; + /** * Turns array of bytes into string representing each byte as * unsigned hex number. @@ -498,7 +481,7 @@ * @param hash Array of bytes to convert to hex-string * @return Generated hex string */ - public static String asHex (byte hash[]) { + public static String asHex(byte hash[]) { char buf[] = new char[hash.length * 2]; for (int i = 0, x = 0; i < hash.length; i++) { buf[x++] = HEX_CHARS[hash[i] >>> 4 & 0xf]; @@ -569,7 +552,7 @@ static final protected double[] timeFactors = {1000000, 1000, 60, 60, 24}; static final protected String[] timeUnites = {"ns", "ms", "s", "m", "h", - "d"}; + "d"}; /** * Converts an time delay into a human readable format. @@ -578,26 +561,26 @@ * @return the memory representation of the given value * @see #convert(long, double[], String[]) */ - static public String convertTime(long value) { + public static String convertTime(long value) { return convert(value, timeFactors, timeUnites); } /** * Converts an time period into a human readable format. * - * @param value the begin time + * @param value the begin time * @param value2 the end time * @return the time representation of the given value * @see #convert(long, double[], String[]) */ - static public String convertTime(long value, long value2) { + public static String convertTime(long value, long value2) { return convertTime(value2 - value); } static final protected double[] memoryFactors = {1024, 1024, 1024, 1024}; static final protected String[] memoryUnites = {"o", "Ko", "Mo", "Go", - "To"}; + "To"}; /** * Converts an memory measure into a human readable format. @@ -606,7 +589,7 @@ * @return the memory representation of the given value * @see #convert(long, double[], String[]) */ - static public String convertMemory(long value) { + public static String convertMemory(long value) { return convert(value, memoryFactors, memoryUnites); } @@ -615,12 +598,12 @@ * (the {@link Locale#getDefault()}) in the method * {@link MessageFormat#MessageFormat(String)}. * - * @param value value to convert + * @param value value to convert * @param factors facotrs used form conversion - * @param unites libelle of unites to use + * @param unites libelle of unites to use * @return the converted representation of the given value */ - static public String convert(long value, double[] factors, String[] unites) { + public static String convert(long value, double[] factors, String[] unites) { long sign = value == 0 ? 1 : value / Math.abs(value); int i = 0; double tmp = Math.abs(value); @@ -631,7 +614,7 @@ tmp *= sign; String result; result = MessageFormat.format("{0,number,0.###}{1}", tmp, - unites[i]); + unites[i]); return result; } @@ -737,7 +720,7 @@ hash = MD5InputStream.getMD5Digest().digest(uniqueKey); // hash = MessageDigest.getInstance("MD5").digest(uniqueKey); - StringBuffer hashString = new StringBuffer(); + StringBuilder hashString = new StringBuilder(); for (byte aHash : hash) { String hex = Integer.toHexString(aHash); if (hex.length() == 1) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtilException.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtilException.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/StringUtilException.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,9 +25,7 @@ package org.nuiton.util; -/** - * @author pineau - */ +/** @author pineau */ public class StringUtilException extends RuntimeException { /** */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeLog.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeLog.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TimeLog.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -67,7 +67,7 @@ */ public class TimeLog { - static public class CallStat { + public static class CallStat { protected long callNumber; @@ -165,7 +165,7 @@ * * @return the current time in nanoseconds */ - static public long getTime() { + public static long getTime() { return System.nanoTime(); } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TransformedList.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -46,12 +46,15 @@ /** * TODO Wthat is it for ? + * * @param <E> */ public class TransformedList<E> extends AbstractList<E> implements Serializable { // TransformedList private static final long serialVersionUID = 2354881761407900789L; + protected Transformer<E, ? super Object> transformer; + protected List<Object> inner; public TransformedList(Transformer<E, ? super Object> transformer) { @@ -110,7 +113,7 @@ @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { + ClassNotFoundException { in.defaultReadObject(); transformer = (Transformer<E, Object>) in.readObject(); inner = (List<Object>) in.readObject(); Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/Transformer.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -38,7 +38,9 @@ import java.io.Serializable; -/** Permet de transformer un objet en un autre et inversement +/** + * Permet de transformer un objet en un autre et inversement + * * @param <E> le type de l'objet a transformer * @param <F> le type de l'objet transforme */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteSoftReference.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteSoftReference.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteSoftReference.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -49,6 +49,7 @@ public class TransparenteSoftReference<T> extends SoftReference<T> { protected int hash; + protected String toString; /** @@ -79,7 +80,8 @@ /** * On conserve le hash pour que la Reference puisse encore se faire * passer pour l'objet alors que celui-ci a disparu de la memoire - * @param o TODO + * + * @param o TODO * @param objectToStringUsed TODO */ protected void init(T o, boolean objectToStringUsed) { @@ -119,7 +121,7 @@ boolean result = o == null && local == null - || o != null && o.equals(local); + || o != null && o.equals(local); return result; } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteWeakReference.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteWeakReference.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/TransparenteWeakReference.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -44,12 +44,15 @@ * Cette classe etant WeakReference et surcharge les méthodes equals et * hashCode pour que ces méthodes retournes les mêmes résultat que les objets * contenu. + * * @param <T> type of object */ public class TransparenteWeakReference<T> extends WeakReference<T> { protected int hash; + protected String toString; + protected boolean objectToStringUsed = true; public TransparenteWeakReference(T o) { @@ -61,7 +64,7 @@ } /** - * @param o TODO ? + * @param o TODO ? * @param objectToStringUsed if true, this ref used toString method of * encapsulated object otherwize used default Object toString */ @@ -80,7 +83,8 @@ /** * On conserve le hash pour que la Reference puisse encore se faire * passer pour l'objet alors que celui-ci a disparu de la memoire - * @param o TODO ? + * + * @param o TODO ? * @param objectToStringUsed TODO ? */ protected void init(T o, boolean objectToStringUsed) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/Version.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/Version.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/Version.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -154,7 +154,7 @@ this.numbers = numbers.length == 0 ? new int[]{0} : numbers; // always keep a lower case classifier this.classifier = classifier == null ? null : - classifier.trim().toLowerCase(); + classifier.trim().toLowerCase(); classifierNumber = classiferNumber; this.snapshot = snapshot; } @@ -250,7 +250,7 @@ if (level < 0 || level >= numbers.length) { throw new IllegalArgumentException( "not a valid level " + level + " for the VersionNumber " + - this); + this); } return numbers[level]; } @@ -339,10 +339,10 @@ @Override public boolean equals(Object obj) { return obj != null && obj instanceof Version && - Arrays.equals(numbers, ((Version) obj).numbers) && - ObjectUtils.equals(classifier, ((Version) obj).classifier) && - ObjectUtils.equals(classifierNumber, ((Version) obj).classifierNumber) && - ObjectUtils.equals(snapshot, ((Version) obj).snapshot); + Arrays.equals(numbers, ((Version) obj).numbers) && + ObjectUtils.equals(classifier, ((Version) obj).classifier) && + ObjectUtils.equals(classifierNumber, ((Version) obj).classifierNumber) && + ObjectUtils.equals(snapshot, ((Version) obj).snapshot); } @Override Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipStreamEncoder.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipStreamEncoder.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipStreamEncoder.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,6 +25,9 @@ package org.nuiton.util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -33,17 +36,12 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * The Class ZipStreamEncoder. - */ +/** The Class ZipStreamEncoder. */ public class ZipStreamEncoder extends Thread { /** Logger. */ static private Log log = LogFactory.getLog(ZipStreamEncoder.class); - + /** The Constant BUFFER. */ static final int BUFFER = 2048; @@ -55,11 +53,9 @@ /** * Instantiates a new zip stream encoder. - * - * @param files - * the files - * @param os - * the os + * + * @param files the files + * @param os the os */ public ZipStreamEncoder(Map<String, InputStream> files, OutputStream os) { this.files = files; @@ -94,10 +90,10 @@ try { origin.close(); } catch (IOException ioe) { - log.error("Impossible to close " + kv.getKey()); + log.error("Impossible to close " + kv.getKey()); } } - log.error("Impossible to compress in stream"); + log.error("Impossible to compress in stream"); throw new RuntimeException("Impossible to compress in stream"); } } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/ZipUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,6 +25,7 @@ package org.nuiton.util; +import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,7 +54,7 @@ * Created: 24 août 2006 10:13:35 * * @author bpoussin <poussin@codelutin.com> - * $Id$ + * $Id$ */ public class ZipUtil { @@ -67,7 +68,7 @@ private static final String LOCAL_SEP = File.separator; private static final String LOCAL_SEP_PATTERN = "\\".equals(LOCAL_SEP) ? - LOCAL_SEP + LOCAL_SEP : LOCAL_SEP; + LOCAL_SEP + LOCAL_SEP : LOCAL_SEP; /** Le séparateur zip. */ private static final String ZIP_SEP = "/"; @@ -128,9 +129,9 @@ result = name; File target = new File(targetDir, name); if (entry.isDirectory()) { - target.mkdirs(); + FileUtil.createDirectoryIfNecessary(target); } else { - target.getParentFile().mkdirs(); + FileUtil.createDirectoryIfNecessary(target.getParentFile()); OutputStream out = new BufferedOutputStream(new FileOutputStream(target)); try { byte[] buffer = new byte[BUFFER_SIZE]; @@ -160,7 +161,7 @@ public static void compressFiles(File zipFile, File root, Collection<File> includes) throws - IOException { + IOException { compressFiles(zipFile, root, includes, false); } @@ -168,10 +169,10 @@ * Compress 'includes' files in zipFile. If file in includes is directory * only the directory is put in zipFile, not the file contained in directory * - * @param zipFile the destination zip file - * @param root for all file in includes that is in this directory, then we - * remove this directory in zip entry name (aka -C for tar), can be null; - * @param includes the files to include in zip + * @param zipFile the destination zip file + * @param root for all file in includes that is in this directory, then we + * remove this directory in zip entry name (aka -C for tar), can be null; + * @param includes the files to include in zip * @param createMD5 also create a MD5 file (zip name + .md5). MD5 file is created after zip. * @throws IOException if any problem while compressing */ @@ -180,7 +181,7 @@ Collection<File> includes, boolean createMD5) throws IOException { OutputStream oStream = new FileOutputStream(zipFile); - + // if md5 creation flag if (createMD5) { oStream = new MD5OutputStream(oStream); @@ -203,7 +204,7 @@ new FileInputStream(file), BUFFER_SIZE); try { while ((bytesIn = - bis.read(readBuffer, 0, BUFFER_SIZE)) != -1) { + bis.read(readBuffer, 0, BUFFER_SIZE)) != -1) { zipOStream.write(readBuffer, 0, bytesIn); } } finally { @@ -213,12 +214,12 @@ zipOStream.closeEntry(); } zipOStream.close(); - + // if md5 creation flag if (createMD5) { - String md5hash = StringUtil.asHex(((MD5OutputStream)oStream).hash()); + String md5hash = StringUtil.asHex(((MD5OutputStream) oStream).hash()); File md5File = new File(zipFile.getAbsoluteFile() + ".md5"); - FileUtil.writeString(md5File, md5hash); + FileUtils.write(md5File, md5hash); } } finally { oStream.close(); @@ -269,7 +270,7 @@ * @param zipFile the target zip file * @param fileOrDirectory the file or directory to compress * @param filter used to accept file, if null, all file is accepted - * @param createMD5 also create a MD5 file (zip name + .md5). MD5 file is created after zip. + * @param createMD5 also create a MD5 file (zip name + .md5). MD5 file is created after zip. * @throws IOException if any problem while compressing */ public static void compress(File zipFile, @@ -405,7 +406,7 @@ * If <code>toTreate</code> if not null nor empty, we use it to filter * entries to uncompress : it contains a list of relative local path of * files to uncompress. - * Otherwise just delegate to {@link ZipUtil#uncompress(File,File)}. + * Otherwise just delegate to {@link ZipUtil#uncompress(File, File)}. * * @param file location of zip file * @param targetDir destination directory @@ -451,10 +452,10 @@ } File target = new File(targetDir, result); if (entry.isDirectory()) { - target.mkdirs(); + FileUtil.createDirectoryIfNecessary(target); } else { - target.getParentFile().mkdirs(); - OutputStream out =new BufferedOutputStream( + FileUtil.createDirectoryIfNecessary(target.getParentFile()); + OutputStream out = new BufferedOutputStream( new FileOutputStream(target)); try { byte[] buffer = new byte[BUFFER_SIZE]; @@ -475,11 +476,11 @@ /** * Unzip compressed archive and keep non excluded patterns. - * - * @param file archive file + * + * @param file archive file * @param targetDir destination file - * @param excludes excludes pattern (pattern must match complete entry name including root folder) - * @throws IOException + * @param excludes excludes pattern (pattern must match complete entry name including root folder) + * @throws IOException */ public static void uncompressFiltred(File file, File targetDir, @@ -506,10 +507,10 @@ if (!excludeEntry) { File target = new File(targetDir, name); if (entry.isDirectory()) { - target.mkdirs(); + FileUtil.createDirectoryIfNecessary(target); } else { // get inputstream only here - target.getParentFile().mkdirs(); + FileUtil.createDirectoryIfNecessary(target.getParentFile()); InputStream in = zipFile.getInputStream(entry); try { OutputStream out = new BufferedOutputStream( @@ -537,7 +538,7 @@ * * @param file the file to test * @return {@code true} if the file is a valid zip file, - * {@code false} otherwise. + * {@code false} otherwise. * @throws IOException if could not open zip file * @since 2.4.9 */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -40,7 +40,7 @@ * @since 1.4.1 */ public class BeanUtil { - + public static final String ADD_PROPERTY_CHANGE_LISTENER = "addPropertyChangeListener"; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/Binder.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/Binder.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/Binder.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -434,8 +434,8 @@ * List contains one element per property with different values (according * to the result of an equals() call) * - * @param source a bean of type I - * @param target a bean of type O + * @param source a bean of type I + * @param target a bean of type O * @param propertyNames property names to exclude from the diff * @return a list with all the properties which values differ in source * and target. Properties with equal values and excluded properties Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderFactory.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderFactory.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderFactory.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -204,16 +204,16 @@ /** * Given a {@code model} and a {@code binderType}, instanciate a new binder * and returns it. - * + * <p/> * <strong>Note: </strong> This method will <strong>NOT</strong> register * the model in the factory. If you want to reuse your model, please use * one of the {@code registerBinderModel(XXX)} method. * - * @param model the model used by the binder + * @param model the model used by the binder * @param binderType the type of the binder - * @param <S> the source type - * @param <T> the target type - * @param <B> the type of the binder + * @param <S> the source type + * @param <T> the target type + * @param <B> the type of the binder * @return the new instanciated binder * @since 2.1 */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -340,7 +340,7 @@ if (sourceAndTargetProperties.length % 2 != 0) { throw new IllegalArgumentException( "must have couple(s) of sourceProperty,targetProperty) " + - "but had " + Arrays.toString(sourceAndTargetProperties)); + "but had " + Arrays.toString(sourceAndTargetProperties)); } for (int i = 0, max = sourceAndTargetProperties.length / 2; i < max; i++) { @@ -349,12 +349,12 @@ if (sourceProperty == null) { throw new NullPointerException( "parameter 'sourceAndTargetProperties' can not " + - "contains a null value"); + "contains a null value"); } if (targetProperty == null) { throw new NullPointerException( "parameter 'sourceAndTargetProperties' can not " + - "contains a null value"); + "contains a null value"); } addProperty0(sourceProperty, targetProperty); } @@ -367,7 +367,7 @@ if (!model.containsSourceProperty(propertyName)) { throw new IllegalArgumentException( "source property '" + propertyName + "' " + - " is NOT registred."); + " is NOT registred."); } // check property is the same type of given binder @@ -375,11 +375,11 @@ Class<?> type = descriptor.getPropertyType(); if (!Collection.class.isAssignableFrom(type) && - !binder.model.getSourceType().isAssignableFrom(type)) { + !binder.model.getSourceType().isAssignableFrom(type)) { throw new IllegalStateException( "source property '" + propertyName + - "' has not the same type [" + type + - "] of the binder [" + binder.model.getSourceType() + "]."); + "' has not the same type [" + type + + "] of the binder [" + binder.model.getSourceType() + "]."); } // can safely add the strategy @@ -397,7 +397,7 @@ if (!model.containsSourceProperty(propertyName)) { throw new IllegalArgumentException( "source property '" + propertyName + "' " + - " is NOT registred."); + " is NOT registred."); } // check property is collection type @@ -406,7 +406,7 @@ if (!Collection.class.isAssignableFrom(type)) { throw new IllegalStateException( "source property '" + propertyName + - "' is not a collection type [" + type + "]"); + "' is not a collection type [" + type + "]"); } // can safely add the strategy @@ -432,7 +432,7 @@ if (model != null) { throw new IllegalStateException( "there is already a binderModel in construction, release " + - "it with the method createBinder before using this method." + "it with the method createBinder before using this method." ); } @@ -457,14 +457,14 @@ sourceDescriptors.get(sourceProperty); if (sourceDescriptor == null) { throw new IllegalArgumentException("no property '" + - sourceProperty + "' " + "found on type " + - model.getSourceType()); + sourceProperty + "' " + "found on type " + + model.getSourceType()); } // check srcProperty is readable Method readMethod = sourceDescriptor.getReadMethod(); if (readMethod == null) { throw new IllegalArgumentException("property '" + sourceProperty + - "' " + "is not readable on type " + model.getSourceType()); + "' " + "is not readable on type " + model.getSourceType()); } // obtain dst descriptor @@ -472,14 +472,14 @@ targetDescriptors.get(targetProperty); if (targetDescriptor == null) { throw new IllegalArgumentException("no property '" + - targetProperty + "' " + "found on type " + - model.getTargetType()); + targetProperty + "' " + "found on type " + + model.getTargetType()); } // check dstProperty is writable Method writeMethod = targetDescriptor.getWriteMethod(); if (writeMethod == null) { throw new IllegalArgumentException("property '" + targetProperty + - "' " + "is not writable on type " + model.getTargetType()); + "' " + "is not writable on type " + model.getTargetType()); } // check types are ok @@ -488,9 +488,9 @@ //TODO-TC20100221 : should check if primitive and boxed it in such case if (!sourceType.equals(targetType)) { throw new IllegalArgumentException("source property '" + - sourceProperty + "' and target property '" + - targetProperty + "' are not compatible ( sourceType : " + - sourceType + " vs targetType :" + targetType + ')'); + sourceProperty + "' and target property '" + + targetProperty + "' are not compatible ( sourceType : " + + sourceType + " vs targetType :" + targetType + ')'); } // check srcProperty does not exist @@ -506,7 +506,7 @@ // property for the entry and this is a bit unatural if (model.containsTargetProperty(targetProperty)) { throw new IllegalArgumentException("destination property '" + - targetProperty + "' " + " was already registred."); + targetProperty + "' " + " was already registred."); } // safe to add the binding model.addBinding(sourceDescriptor, targetDescriptor); @@ -537,7 +537,7 @@ } } catch (IntrospectionException e) { throw new RuntimeException("Could not obtain bean properties " + - "descriptors for source type " + type, e); + "descriptors for source type " + type, e); } Class<?>[] interfaces = type.getInterfaces(); for (Class<?> i : interfaces) { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/PropertyDiff.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/PropertyDiff.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/PropertyDiff.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,11 +25,11 @@ package org.nuiton.util.beans; /** -* TODO -* -* @author bleny <leny@codelutin.com> -* @since 2.4 -*/ + * TODO + * + * @author bleny <leny@codelutin.com> + * @since 2.4 + */ public class PropertyDiff { protected Class<?> propertyType; @@ -54,7 +54,7 @@ this.sourceValue = sourceValue; this.targetProperty = targetProperty; this.targetValue = targetValue; - this.propertyType= propertyType; + this.propertyType = propertyType; } public String getSourceProperty() { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/ConverterUtil.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/ConverterUtil.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/ConverterUtil.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,13 +25,14 @@ package org.nuiton.util.converter; -import java.lang.reflect.Method; -import java.util.ServiceLoader; 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 * @@ -63,7 +64,7 @@ * Sinon on tente d'instancier un converteur dans le paquetage dédié aux * converteurs {@link #CONVERTER_PACKAGE}. * - * @param <T> le type a convertir + * @param <T> le type a convertir * @param type le type a convertir * @return le converter trouvé, ou null si non trouvé */ @@ -92,7 +93,7 @@ /** * Convertir une valeur! * - * @param <T> le type de donnee recherchee + * @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 @@ -112,8 +113,8 @@ public static void registerConverter(Class<?> type) throws IllegalAccessException, - InstantiationException, - ClassNotFoundException { + InstantiationException, + ClassNotFoundException { if (ConvertUtils.lookup(type) == null) { registerConverter0(type); } @@ -121,8 +122,8 @@ protected static void registerConverter0(Class<?> type) throws IllegalAccessException, - InstantiationException, - ClassNotFoundException { + InstantiationException, + ClassNotFoundException { Class<?> aClass = Class.forName( CONVERTER_PACKAGE + "." + type.getSimpleName() + "Converter"); Converter converter = (Converter) aClass.newInstance(); Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/EnumConverter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/EnumConverter.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/EnumConverter.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -26,13 +26,14 @@ package org.nuiton.util.converter; 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; import static org.nuiton.i18n.I18n._; -import java.util.EnumSet; -import org.apache.commons.beanutils.Converter; -import org.apache.commons.logging.Log; - /** * classe pour convertir une chaine en un objet Enum type-safe en * connaissant le type d'enumération utilisée {@link #enumType}. @@ -41,7 +42,7 @@ * <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)} . + * et {@link ConverterUtil#registerEnumConverter(Class, Object)} . * * @author tchemit <chemit@codelutin.com> * @see Enum Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverter.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverter.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -45,7 +45,7 @@ * gère et inversement. Pour des raisons d'optimisation, il est possible * qu'un converter sache passé d'un autre type que java vers sa representation * pour eviter une conversion supplémentaire qui pourrait-etre couteuse. - * + * * @param <A> le type de l'objet a convertir */ public interface FormatConverter<A> { // FormatConverter @@ -73,7 +73,7 @@ * Ou s'il manque dans les args des objets utils pour la conversion. */ A convert(FormatConverterFactory factory, - Format format, FormatMap values, Object... args); + Format format, FormatMap values, Object... args); /** * Convertie une valeur vers le Java @@ -97,7 +97,7 @@ * pour la conversion. */ Object unconvert(FormatConverterFactory factory, - Format format, FormatMap values, Object... args); + Format format, FormatMap values, Object... args); } // FormatConverter Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverterFactory.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverterFactory.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatConverterFactory.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -68,7 +68,7 @@ /** <Class, from, to -> FormatConverter> */ protected MultiKeyMap converters = new MultiKeyMap(); - synchronized static public FormatConverterFactory getInstance() { + synchronized public static FormatConverterFactory getInstance() { if (instance == null) { instance = new FormatConverterFactory(); } @@ -141,7 +141,7 @@ // Si on a pas encore trouve de transformer on recherche // un encodeur/decodeur pour les interfaces - for (Iterator<Class<?>> i = interfaces.iterator(); result == null && i.hasNext();) { + for (Iterator<Class<?>> i = interfaces.iterator(); result == null && i.hasNext(); ) { result = getConverter(i.next(), format); } Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatMap.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatMap.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/FormatMap.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -67,7 +67,7 @@ private static final long serialVersionUID = 1L; - static public class Format { + public static class Format { protected String name; Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/VersionConverter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/VersionConverter.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/VersionConverter.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -38,8 +38,8 @@ * classe pour convertir une chaine en un objet Version. * * @author tchemit <chemit@codelutin.com> + * @see Version * @since 1.3 (replace {@code org.nuiton.util.VersionConverter}). - * @see Version */ public class VersionConverter implements Converter { Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/package-info.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/package-info.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/converter/package-info.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -35,7 +35,7 @@ * * <h1<Format api</h1> * see {@link org.nuiton.util.converter.FormatConverter} and others - * + * * @author tchemit <chemit@codelutin.com> * @since 1.3 */ Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteMethodExecutorImpl.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -37,9 +37,7 @@ */ public class RemoteMethodExecutorImpl<T> implements RemoteMethodExecutor { - /** - * The target service on which calls will be made - */ + /** The target service on which calls will be made */ protected T service; /** Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/RemoteProxyFactory.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -48,6 +48,7 @@ // TODO AThimel 12/01/2011 This settings has to be externalized protected final static int PORT = 12345; + protected final static String REGISTRY_IP = "127.0.0.1"; /** Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/rmi/ServiceExporter.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -50,15 +50,13 @@ // TODO AThimel 12/01/2011 This settings has to be externalized private static final int PORT = 12345; - /** - * Does some checks on RMI configuration - */ + /** Does some checks on RMI configuration */ protected static void testRmiConfig() { String rmiHost = System.getProperty("java.rmi.server.hostname"); if ((rmiHost == null || "".equals(rmiHost.trim())) - && log.isWarnEnabled()) { + && log.isWarnEnabled()) { log.warn("Server might not have been initialized properly, " + - "please specify '-Djava.rmi.server.hostname=<IP-address>'"); + "please specify '-Djava.rmi.server.hostname=<IP-address>'"); } } Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/FileUtilTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/FileUtilTest.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/FileUtilTest.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,6 +25,7 @@ package org.nuiton.util; +import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -70,46 +71,6 @@ } @Test - public void testWriteString() throws IOException { - File testFile = new File(System.getProperty("java.io.tmpdir"), "test.txt"); - testFile.deleteOnExit(); - FileUtil.writeString(testFile, "testWriteString"); - - Assert.assertEquals("testWriteString", FileUtil.readAsString(testFile)); - } - - /** - * This test throwed NPE before 1.2.1 with simple file path (current folder). - * - * @throws IOException - */ - @Test - public void testWriteStringRelative() throws IOException { - File testFile = new File("test.txt"); - testFile.deleteOnExit(); - FileUtil.writeString(testFile, "testWriteString"); - - Assert.assertEquals("testWriteString", FileUtil.readAsString(testFile)); - } - - /** - * Test testWriteString method with file containing ".." - * - * @throws IOException - */ - @Test - public void testWriteStringRelativeNonCanonical() throws IOException { - File testFile = new File(".." + File.separator + - "target" + File.separator + - "surefire-workdir" + File.separator + - "testdir" + File.separator + "test.txt"); - testFile.deleteOnExit(); - FileUtil.writeString(testFile, "testWriteString"); - - Assert.assertEquals("testWriteString", FileUtil.readAsString(testFile)); - } - - @Test public void testCopyRecursively() throws Exception { File srcDir = FileUtil.createTempDirectory("test-copyRecursively", "", parent); File destDir1 = FileUtil.createTempDirectory("test-copyRecursively", "", parent); @@ -128,27 +89,11 @@ FileUtil.copyRecursively(srcDir, destDir2, ".*titi$"); // remove created temp dirs : - FileUtil.deleteRecursively(srcDir); - FileUtil.deleteRecursively(destDir1); - FileUtil.deleteRecursively(destDir2); + FileUtils.deleteDirectory(srcDir); + FileUtils.deleteDirectory(destDir1); + FileUtils.deleteDirectory(destDir2); } - @Test - public void testFileToByteToFile() throws Exception { - //FIXME tchemit 20100924 Do tests in target, not in /tmp please! - - String content = "testFileToByteToFile"; - File file = FileUtil.getTempFile(content); - - byte[] bytes = FileUtil.fileToByte(file); - File dest = File.createTempFile("testFileToByteToFile", ".txt"); - dest.deleteOnExit(); - FileUtil.byteToFile(bytes, dest); - - Assert.assertEquals(file.length(), dest.length()); - Assert.assertEquals(content, FileUtil.readAsString(dest)); - } - /** * Test grep on a single file. * <p/> @@ -224,7 +169,7 @@ Assert.assertEquals(9, lines.size()); // clean - FileUtil.deleteRecursively(testDirectory); + FileUtils.deleteDirectory(testDirectory); } /** @@ -259,7 +204,7 @@ // clean - FileUtil.deleteRecursively(testDirectory); + FileUtils.deleteDirectory(testDirectory); } /** @@ -286,7 +231,7 @@ Assert.assertEquals(2, lines2.size()); // clean - FileUtil.deleteRecursively(testDirectory); + FileUtils.deleteDirectory(testDirectory); } static File parent; Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/ObjectUtilTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/ObjectUtilTest.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/ObjectUtilTest.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -156,7 +156,7 @@ assertFalse(ObjectUtil.isNullValue(Byte.valueOf((byte)0))); } - static public class Dummy { + public static class Dummy { String name; int integer; Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/StringUtilTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/StringUtilTest.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/StringUtilTest.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -36,7 +36,6 @@ package org.nuiton.util; -import org.apache.commons.lang3.StringUtils; import org.junit.Test; import java.awt.*; @@ -173,36 +172,7 @@ Locale.setDefault(oldLocale); } - /** - * Since 2.1, this method doesn't not remove whitespaces. - * - * @throws Exception - */ @Test - public void testUnAccent() throws Exception { - assertEquals("-aaaeeeeiioouuuc 0123456789 AAAEEEEIIOOUUUC._", - StringUtil.unaccent("-àâäéèêëîïôöùûüç 0123456789 ÀÂÄÉÈÊËÎÏÔÖÙÛÜÇ._")); - - assertEquals("test en ete", - StringUtil.unaccent("test en été")); - } - - /** - * Tests that {@link StringUtils#stripAccents(String)} is a suitable - * replacement. - * - * @since 2.4.2 - */ - @Test - public void testUnAccentDeprecation() { - assertEquals(StringUtil.unaccent("-àâäéèêëîïôöùûüç 0123456789 ÀÂÄÉÈÊËÎÏÔÖÙÛÜÇ._"), - StringUtils.stripAccents("-àâäéèêëîïôöùûüç 0123456789 ÀÂÄÉÈÊËÎÏÔÖÙÛÜÇ._")); - - assertEquals(StringUtil.unaccent("test en été"), - StringUtils.stripAccents("test en été")); - } - - @Test public void testConvertToConstantName() throws Exception { assertEquals("YES", StringUtil.convertToConstantName("yes")); assertEquals("YES", StringUtil.convertToConstantName("*$$?YEs")); Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/ZipUtilTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/ZipUtilTest.java 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/ZipUtilTest.java 2012-06-11 10:24:36 UTC (rev 2360) @@ -25,6 +25,7 @@ package org.nuiton.util; +import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; @@ -120,7 +121,7 @@ Assert.assertEquals(src.size() + 1, dest.size()); // remove created temp dirs : - FileUtil.deleteRecursively(ucz); + FileUtils.deleteDirectory(ucz); Assert.assertFalse(ucz.isDirectory()); } Modified: trunk/nuiton-utils/src/test/resources/org/nuiton/util/fileUtilData.txt =================================================================== --- trunk/nuiton-utils/src/test/resources/org/nuiton/util/fileUtilData.txt 2012-06-11 09:27:18 UTC (rev 2359) +++ trunk/nuiton-utils/src/test/resources/org/nuiton/util/fileUtilData.txt 2012-06-11 10:24:36 UTC (rev 2360) @@ -90,18 +90,18 @@ /** Encoding utilisé (peut être redéfini) */ // TODO fdesbois 2011-04-16 : Perhaps change ISO encoding by UTF-8 - static public String ENCODING = "ISO-8859-1"; + public static String ENCODING = "ISO-8859-1"; static protected File currentDirectory = new File("."); - static public void setCurrentDirectory(File dir) { + public static void setCurrentDirectory(File dir) { currentDirectory = dir; } - static public File getCurrentDirectory() { + public static File getCurrentDirectory() { return currentDirectory; } - static public class PatternChooserFilter extends javax.swing.filechooser.FileFilter { + public static class PatternChooserFilter extends javax.swing.filechooser.FileFilter { protected String pattern; protected String description; @@ -132,7 +132,7 @@ * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé * @see #getFile(javax.swing.filechooser.FileFilter...) */ - static public File getFile(String... patternOrDescriptionFilters) { + public static File getFile(String... patternOrDescriptionFilters) { File result; result = getFile(null, patternOrDescriptionFilters); return result; @@ -145,7 +145,7 @@ * @param filters les filtres a ajouter * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé */ - static public File getFile(javax.swing.filechooser.FileFilter... filters) { + public static File getFile(javax.swing.filechooser.FileFilter... filters) { File result = getFile(null, filters); return result; } @@ -160,7 +160,7 @@ * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé * @see #getFile(javax.swing.filechooser.FileFilter...) */ - static public File getFile(Component parent, + public static File getFile(Component parent, String... patternOrDescriptionFilters) { File result; result = getFile("Ok", "Ok", parent, patternOrDescriptionFilters); @@ -179,7 +179,7 @@ * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé * @see #getFile(javax.swing.filechooser.FileFilter...) */ - static public File getFile(String title, + public static File getFile(String title, String approvalText, Component parent, String... patternOrDescriptionFilters) { @@ -208,7 +208,7 @@ * @param filters les filtres a ajouter * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé */ - static public File getFile(Component parent, + public static File getFile(Component parent, javax.swing.filechooser.FileFilter... filters) { File result = getFile("Ok", "Ok", parent, filters); return result; @@ -224,7 +224,7 @@ * @param filters les filtres a ajouter * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé */ - static public File getFile(String title, + public static File getFile(String title, String approvalText, Component parent, javax.swing.filechooser.FileFilter... filters) { @@ -263,7 +263,7 @@ * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne * null. */ - static public String getDirectory() { + public static String getDirectory() { return getDirectory(null,"Ok", "Ok"); } @@ -274,7 +274,7 @@ * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne * null. */ - static public String getDirectory(String title, String approvalText) { + public static String getDirectory(String title, String approvalText) { String result = getDirectory(null, title, approvalText); return result; } @@ -287,7 +287,7 @@ * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne * null. */ - static public String getDirectory(Component parent, + public static String getDirectory(Component parent, String title, String approvalText) { try { @@ -320,7 +320,7 @@ * @return le contenu du fichier sous la forme d'un tableau de bytes. * @throws IOException if any io pb */ - static public byte[] fileToByte(File file) throws IOException { + public static byte[] fileToByte(File file) throws IOException { ByteArrayOutputStream result; InputStream in = new BufferedInputStream(new FileInputStream(file)); try { @@ -348,7 +348,7 @@ * @throws IOException if any io pb * @throws NullPointerException if src or dst parameter is null */ - static public File inputStreamToFile(InputStream src, File dst) throws IOException, NullPointerException { + public static File inputStreamToFile(InputStream src, File dst) throws IOException, NullPointerException { if (src == null) { throw new NullPointerException("parameter 'src' can not be null"); } @@ -378,7 +378,7 @@ * @return le fichier temporaire contenant les bytes * @throws IOException if any io pb */ - static public File byteToFile(byte[] bytes) throws IOException { + public static File byteToFile(byte[] bytes) throws IOException { File file = File.createTempFile("FileUtil-byteToFile", ".tmp"); byteToFile(bytes, file); return file; @@ -392,7 +392,7 @@ * @return le fichier passé en parametre * @throws IOException if any io pb */ - static public File byteToFile(byte[] bytes, + public static File byteToFile(byte[] bytes, File file) throws IOException { OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { @@ -410,7 +410,7 @@ * @return the reader on the given file * @throws IOException if any io pb */ - static public BufferedReader getReader(File file) throws IOException { + public static BufferedReader getReader(File file) throws IOException { return getReader(file, ENCODING); } @@ -423,7 +423,7 @@ * @return the buffered reader in the given encoding * @throws IOException if any io pb */ - static public BufferedReader getReader(File file, + public static BufferedReader getReader(File file, String encoding) throws IOException { FileInputStream inf = new FileInputStream(file); InputStreamReader in = new InputStreamReader(inf, encoding); @@ -438,7 +438,7 @@ * @return the writer on the given file * @throws IOException if any io pb */ - static public BufferedWriter getWriter(File file) throws IOException { + public static BufferedWriter getWriter(File file) throws IOException { return getWriter(file, ENCODING); } @@ -451,7 +451,7 @@ * @return the buffered writer on the given file with given encoding * @throws IOException if any io pb */ - static public BufferedWriter getWriter(File file, + public static BufferedWriter getWriter(File file, String encoding) throws IOException { FileOutputStream outf = new FileOutputStream(file); OutputStreamWriter out = new OutputStreamWriter(outf, encoding); @@ -471,7 +471,7 @@ * @return le fichier pointant sur le nouveau repertoire * @throws IOException if any io pb */ - static public File createTempDirectory(String prefix, + public static File createTempDirectory(String prefix, String suffix, File tmpdir) throws IOException { if (tmpdir == null) { @@ -496,7 +496,7 @@ * @return the temprary created file * @throws IOException if any io pb */ - static public File createTempDirectory(String prefix, + public static File createTempDirectory(String prefix, String suffix) throws IOException { return createTempDirectory(prefix, suffix, null); } @@ -508,7 +508,7 @@ * @param f2 the second file * @return vrai si f1 est plus recent que f2 */ - static public boolean isNewer(File f1, File f2) { + public static boolean isNewer(File f1, File f2) { boolean result = f1.lastModified() > f2.lastModified(); return result; } @@ -521,7 +521,7 @@ * @return le contenu du fichier * @throws IOException if any io pb */ - static public String readAsString(File file) throws IOException { + public static String readAsString(File file) throws IOException { StringBuffer result = new StringBuffer(); char[] cbuf = new char[2000]; BufferedReader in = getReader(file); @@ -543,7 +543,7 @@ * @param content Le texte a ecrire dans le fichier * @throws IOException if any pb while writing */ - static public void writeString(File file, + public static void writeString(File file, String content) throws IOException { //fixme on doit tester le retour de la méthode, car il se peut que le répertoire // ne puisse etre cree. @@ -567,7 +567,7 @@ * @param encoding encoding to use * @throws IOException if any pb while writing */ - static public void writeString(File file, + public static void writeString(File file, String content, String encoding) throws IOException { //fixme on doit tester le retour de la méthode, car il se peut que le répertoire @@ -592,7 +592,7 @@ * @return le fichier qui contient content * @throws IOException if any io pb */ - static public File getTempFile(String content) throws IOException { + public static File getTempFile(String content) throws IOException { return getTempFile(content, ""); } @@ -605,7 +605,7 @@ * @return le fichier qui contient content * @throws IOException if any io pb */ - static public File getTempFile(String content, + public static File getTempFile(String content, String fileSuffix) throws IOException { File result = File.createTempFile("tmp-" + FileUtil.class.getName(), fileSuffix); @@ -623,7 +623,7 @@ * s'il est trouvé * @return le nom du fichier sans le suffixe si trouvé. */ - static public String basename(File file, String... suffixes) { + public static String basename(File file, String... suffixes) { String result = basename(file.getName(), suffixes); return result; } @@ -638,7 +638,7 @@ * @return le nom du fichier sans le suffixe si trouvé. * @since 1.4.2 */ - static public String basename(String name, String... suffixes) { + public static String basename(String name, String... suffixes) { String result = name; for (String suffixe : suffixes) { if (result.endsWith(suffixe)) { @@ -659,7 +659,7 @@ * @return l'extension ou la chaine vide si le fichier n'a pas d'extension * l'extension ne contient pas le chaine de delimitation */ - static public String extension(File file, String... extchars) { + public static String extension(File file, String... extchars) { String name = file.getName(); String result = extension(name, extchars); return result; @@ -675,7 +675,7 @@ * l'extension ne contient pas le chaine de delimitation * @since 1.4.2 */ - static public String extension(String name, String... extchars) { + public static String extension(String name, String... extchars) { String result = ""; if (extchars.length == 0) { @@ -702,7 +702,7 @@ * @throws IOException si aucune extension trouvé dans le fichier d'origine * @since 1.4.2 */ - static public File changeExtension(File file, + public static File changeExtension(File file, String newExtension, String... extchars) throws IOException { String name = file.getName(); @@ -721,7 +721,7 @@ * @throws IOException si aucune extension trouvé dans le fichier d'origine * @since 1.4.2 */ - static public String changeExtension(String name, + public static String changeExtension(String name, String newExtension, String... extchars) throws IOException { String extension = extension(name, extchars); @@ -746,7 +746,7 @@ * @return le fichier mirroir dans le répertoire cible * @since 1.4.2 */ - static public File getRelativeFile(File inputDirectory, + public static File getRelativeFile(File inputDirectory, File outputDirectory, File file) { String inputPath = inputDirectory.getAbsolutePath(); @@ -989,7 +989,7 @@ * fichiers/repertoires pour etre copié. Si vide alors tout est copié * @throws IOException if any io pb */ - static public void copyRecursively(File srcDir, + public static void copyRecursively(File srcDir, File destDir, String... includePatterns) throws IOException { copyAndRenameRecursively(srcDir, destDir, null, null, includePatterns); @@ -1010,7 +1010,7 @@ * fichiers/repertoires pour etre copié. Si vide alors tout est copié * @throws IOException if any io pb */ - static public void copyAndRenameRecursively(File srcDir, File destDir, + public static void copyAndRenameRecursively(File srcDir, File destDir, String renameFrom, String renameTo, String... includePatterns) throws IOException { @@ -1042,7 +1042,7 @@ * fichiers/repertoires pour etre copié. Si vide alors tout est copié * @throws IOException if any io pb */ - static public void copyAndRenameRecursively(File srcDir, + public static void copyAndRenameRecursively(File srcDir, File destDir, boolean includeSrcDir, String renameFrom,