[Lutinutil-commits] r1464 - in lutinutil/trunk: . src/main/java/org/codelutin/i18n src/main/java/org/codelutin/util
Author: chatellier Date: 2009-05-03 08:16:41 +0000 (Sun, 03 May 2009) New Revision: 1464 Modified: lutinutil/trunk/ lutinutil/trunk/pom.xml lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParser.java lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserDefaultOption.java lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserException.java lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserOption.java lutinutil/trunk/src/main/java/org/codelutin/util/CallAnalyse.java lutinutil/trunk/src/main/java/org/codelutin/util/CategorisedListenerSet.java lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java lutinutil/trunk/src/main/java/org/codelutin/util/FileCompletion.java lutinutil/trunk/src/main/java/org/codelutin/util/FormatConverterFactory.java lutinutil/trunk/src/main/java/org/codelutin/util/FormatMap.java lutinutil/trunk/src/main/java/org/codelutin/util/IOUtils.java lutinutil/trunk/src/main/java/org/codelutin/util/ListenerSet.java lutinutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java lutinutil/trunk/src/main/java/org/codelutin/util/Log.java lutinutil/trunk/src/main/java/org/codelutin/util/LoggingPatternFormatter.java lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java lutinutil/trunk/src/main/java/org/codelutin/util/StringUtil.java lutinutil/trunk/src/main/java/org/codelutin/util/StringUtilException.java lutinutil/trunk/src/main/java/org/codelutin/util/TransformedList.java lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java Log: Update javadoc Property changes on: lutinutil/trunk ___________________________________________________________________ Name: svn:ignore - target velocity.log maven.log .eclipse .classpath lutinutil.iml lutinutil.ipr lutinutil.iws .project .settings THIRD-PARTY.txt + target velocity.log maven.log .eclipse .classpath lutinutil.iml lutinutil.ipr lutinutil.iws .settings .project Modified: lutinutil/trunk/pom.xml =================================================================== --- lutinutil/trunk/pom.xml 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/pom.xml 2009-05-03 08:16:41 UTC (rev 1464) @@ -143,6 +143,20 @@ </pluginManagement> </build> + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.5</version> + <configuration> + <links> + <link>http://java.sun.com/javase/6/docs/api/</link> + </links> + </configuration> + </plugin> + </plugins> + </reporting> <!-- ************************************************************* --> <!-- *** Build Environment ************************************** --> Modified: lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/i18n/I18n.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -57,7 +57,7 @@ * * @author poussin * @author chemit - * @created 2 decembre 2003 + * created 2 decembre 2003 */ public class I18n { Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParser.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParser.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParser.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -39,7 +39,8 @@ * et mettre des methodes pour récupérer directement ce type. * * @author poussin - * @deprecated utiliser maintenant {@link ApplicationConfig} + * + * @deprecated since 0.30 , prefer use of {@link ApplicationConfig} instead */ @Deprecated public class ArgumentsParser { @@ -61,7 +62,7 @@ /** * Constructor for the ArgumentsParser object * - * @param name e nom à afficher pour l'usage + * @param name le nom à afficher pour l'usage */ public ArgumentsParser(String name) { this.name = name; @@ -77,7 +78,7 @@ * @param argument le nombre d'argument que cette option a * @param description description de cette option * @return retourne l'option créer et qui sera utilisé - * @see #addOption(javax.swing.text.html.Option) + * @see #addOption(ArgumentsParserOption) */ public ArgumentsParserOption addOption(String optionName, String description, int argument, String... acceptedOption) { @@ -187,7 +188,7 @@ /** * Permet de savoir si une option a ete trouvée sur la ligne de commande * - * @param name le nom de l'option dont il faut vérifier l'existance + * @param optionName le nom de l'option dont il faut vérifier l'existance * @return vrai si l'option existe sur la ligne de commande */ public boolean hasParsedOption(String optionName) { @@ -197,7 +198,7 @@ /** * Retourne le premier argument d'un certain type * - * @param name le nom de l'option à retourner + * @param optionName le nom de l'option à retourner * @return la valeur de l'option si elle existe, null sinon */ public String[] getParsedOption(String optionName) { @@ -222,7 +223,7 @@ /** * Retourne la liste de toutes les options d'un certain type * - * @param name le nom des options à retourner + * @param optionName le nom des options à retourner * @return la liste des options d'un certain nom, ou une liste vide si * aucune option de ce nom existe ou si cette option n'a pas été trouvé * sur la ligne de commande Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserDefaultOption.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserDefaultOption.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserDefaultOption.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,5 +1,4 @@ -/** - * *##% Lutin utilities library +/* *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -34,7 +33,9 @@ * Description of the Class * * @author poussin - * @created 22 août 2003 + * created 22 août 2003 + * + * @deprecated since 0.30 , prefer use of {@link ApplicationConfig} instead */ public class ArgumentsParserDefaultOption implements ArgumentsParserOption {// ArgumentsParserDefaultOption Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserException.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserException.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserException.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -30,6 +30,9 @@ package org.codelutin.util; +/** + * @deprecated since 0.30 , prefer use of {@link ApplicationConfig} instead + */ public class ArgumentsParserException extends Exception { // ArgumentsParserException /** */ Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserOption.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserOption.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ArgumentsParserOption.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,5 +1,4 @@ -/** - * *##% Lutin utilities library +/* *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -17,38 +16,31 @@ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ -/** - * Option.java Created: 22 ao�t 2003 - * - *@author Benjamin Poussin <poussin@codelutin.com> - * - * Copyright Code Lutin - *@version $Revision$ Mise a jour: $Date$ par : $Author$ - */ - package org.codelutin.util; /** - * Cette classe repr�sente une option de la ligne de commande - * - *@author poussin - *@created 22 ao�t 2003 + * Cette classe représente une option de la ligne de commande + * + * @author poussin + * created 22 août 2003 + * + * @deprecated since 0.30 , prefer use of {@link ApplicationConfig} instead */ public interface ArgumentsParserOption extends Cloneable {// Option /** - * Essai de parser un argument. Si cela � fonctionn�, retourne un argument + * Essai de parser un argument. Si cela a fonctionné, retourne un argument * sinon retourne null. * *@param arg liste des arguments de la ligne de commande *@param index l'index ou le parser est rendu - *@return vrai si le parsing a r�ussi + *@return vrai si le parsing a réussi */ public boolean parse(String[] arg, int index); /** * Retourne le nom de l'option * - *@return le nom + * @return le nom */ public String getName(); @@ -62,9 +54,9 @@ public ArgumentsParserOption setRepetitionMax(int repetitionMax); /** - * Retourne l'option utilis�e sur la ligne de commande + * Retourne l'option utilisée sur la ligne de commande * - *@return l'option utilis�e sur la ligne de commende + *@return l'option utilisée sur la ligne de commende */ public String getUsedOption(); @@ -76,7 +68,7 @@ public String[] getArguments(); /** - * Permet de connaitre le nombre d'argument consomm� par cet objet + * Permet de connaitre le nombre d'argument consommé par cet objet * *@return le nombre d'argument */ Modified: lutinutil/trunk/src/main/java/org/codelutin/util/CallAnalyse.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/CallAnalyse.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/CallAnalyse.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -44,11 +44,11 @@ * 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 +* 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> la memore utilisé * <li> le nombre d'appels */ public class CallAnalyse { // CallAnalyse @@ -83,7 +83,7 @@ } /** - * Permet de savoir si les statistiques sont activ�es ou non, pour le + * Permet de savoir si les statistiques sont activées ou non, pour le * thread courant */ static public boolean isActivate(){ @@ -101,9 +101,9 @@ } /** - * Indique la sortie de l'appel, name doit avoir ete utilis� lors d'un 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 + * celui utilisé pour la methode enter */ static public void exit(String name){ ThreadStatistics t = stats.get(); Modified: lutinutil/trunk/src/main/java/org/codelutin/util/CategorisedListenerSet.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/CategorisedListenerSet.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/CategorisedListenerSet.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -155,7 +155,7 @@ * sur les ancètres de la categorie * * @param category la categorie a partir duquel il faut lancer l'evenement - * @param methodeName le nom de la méthode de la classe listener + * @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 */ @@ -181,7 +181,7 @@ * dans plusieurs categories alors il ne recevra qu'une seul notification * * @param category la categorie a partir duquel il faut lancer l'evenement - * @param methodeName le nom de la méthode de la classe listener + * @param methodName le nom de la méthode de la classe listener */ public void fire(Object category, String methodName) throws Exception { for (Listener l : getAllListeners(category)) { Modified: lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/EnumConverter.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -32,7 +32,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 chemit * @see Enum Modified: lutinutil/trunk/src/main/java/org/codelutin/util/FileCompletion.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/FileCompletion.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/FileCompletion.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,4 +1,4 @@ -/** +/* * *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * @@ -16,6 +16,18 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ + +package org.codelutin.util; + +import org.codelutin.i18n.I18n; +import static org.codelutin.i18n.I18n._; + +import java.io.Console; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.Locale; + /** * <p> * Class d'aide a la saisie de chemin de fichier @@ -58,21 +70,9 @@ * <p> * FIXME: Si la sortie est ecive, un fichier "!q" ne peut pas etre utilise * </p> - * @autor Letellier Sylvain + * + * @author Letellier Sylvain */ - -package org.codelutin.util; - -import org.codelutin.i18n.I18n; -import static org.codelutin.i18n.I18n._; - -import java.io.Console; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.Locale; - - public class FileCompletion { private boolean exit; private boolean creation; @@ -81,7 +81,7 @@ private Console console; /** - * private Console console; /** constructeur + * Constructeur * * @param creation TODO * @param exit TODO @@ -89,10 +89,14 @@ public FileCompletion(boolean creation, boolean exit) { this.exit = exit; this.creation = creation; - if (Locale.getDefault().getLanguage().equals("fr")) + + // TODO does this util class init i18n ? + if (Locale.getDefault().getLanguage().equals("fr")) { I18n.init("fr", "FR"); - else + } + else { I18n.init("en", "US"); + } console = System.console(); consoleAvailable = (console != null); @@ -105,10 +109,12 @@ * @throws IOException TODO */ public String read() throws IOException { - if (creation) + if (creation) { System.out.println(_("lutinutil.fileCompletion.save")); - if (exit) + } + if (exit) { System.out.println(_("lutinutil.fileCompletion.exit")); + } System.out.println(_("lutinutil.fileCompletion.cancel")); System.out.println(_("lutinutil.fileCompletion.enter")); String line = System.getProperty("user.dir"); @@ -135,11 +141,13 @@ filtre.setFilter(file); String[] listFichier = fTmp.list(filtre); if (listFichier.length == 1) { - if (!(fTmp.getParentFile() == null)) + if (!(fTmp.getParentFile() == null)) { line = fTmp.getCanonicalPath() + File.separator + listFichier[0]; - else + } + else { line = fTmp.getCanonicalPath() + listFichier[0]; + } } else if (listFichier.length > 1) { afficherListe(listFichier); } else { Modified: lutinutil/trunk/src/main/java/org/codelutin/util/FormatConverterFactory.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/FormatConverterFactory.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/FormatConverterFactory.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -105,7 +105,7 @@ /** * @return retourne null si aucun converter trouvé - * @see #getConverter(Class, Object, FormatConverter) + * @see #getConverter(Class, FormatMap.Format, FormatConverter) */ public FormatConverter getConverter(Class clazz, Format format) { return getConverter(clazz, format, null); @@ -151,7 +151,7 @@ /** * @return retourne null si aucun converter trouvé - * @see #findConverter(Class, Object, FormatConverter) + * @see #findConverter(Class, FormatMap.Format, FormatConverter) */ public FormatConverter findConverter(Class clazz, Format format) { return findConverter(clazz, format, null); Modified: lutinutil/trunk/src/main/java/org/codelutin/util/FormatMap.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/FormatMap.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/FormatMap.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -36,9 +36,9 @@ /** * Classe servant de conteneur pour les différentes representation d'un objet - * Les representations doivents être des instances de {@link #Format}. Le mieux + * Les representations doivents être des instances de {@link Format}. Le mieux * est lors de l'ecriture des convertisseurs pour un nouveau format est de - * créer une instance final static de {@link #Format} Format pour representer + * créer une instance final static de {@link Format} Format pour representer * ce format * <p/> * <h2>Utilisation</h2> Modified: lutinutil/trunk/src/main/java/org/codelutin/util/IOUtils.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/IOUtils.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/IOUtils.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,5 +1,4 @@ -/** - * *##% Lutin utilities library +/* *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -26,13 +25,19 @@ import java.nio.channels.FileChannel; +/** + * IOUtils. + * + * TODO ADD COMMENT HERE ! + * + * @deprecated use {FileUtil} instead + */ public class IOUtils { - /** - * Copy a file - */ - public static void copyFile (File in, File out) throws java.io.IOException { + * Copy a file + */ + public static void copyFile(File in, File out) throws java.io.IOException { FileChannel sourceChannel = new FileInputStream(in).getChannel(); FileChannel destinationChannel = new FileOutputStream(out).getChannel(); @@ -46,24 +51,28 @@ } /** - * Get a temporary file path - */ - public static String getTemporaryFilePath (String tempFilePrefix, File tmpDirectory) throws java.io.IOException { + * Get a temporary file path + */ + public static String getTemporaryFilePath(String tempFilePrefix, + File tmpDirectory) throws java.io.IOException { // Get a File object with given prefix, default suffix is ".tmp" - File temporaryFile = File.createTempFile(tempFilePrefix, null, tmpDirectory); + File temporaryFile = File.createTempFile(tempFilePrefix, null, + tmpDirectory); String temporaryFilePath = temporaryFile.getPath(); return temporaryFilePath; } /** - * Get a ByteArrayOutputStream containing all data that could be read from the given InputStream - */ - public static ByteArrayOutputStream readBytesFrom (InputStream inputStream, int defaultBufferSize) throws java.io.IOException { + * Get a ByteArrayOutputStream containing all data that could be read from the given InputStream + */ + public static ByteArrayOutputStream readBytesFrom(InputStream inputStream, + int defaultBufferSize) throws java.io.IOException { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(defaultBufferSize); - byte[] buffer = new byte [defaultBufferSize]; + ByteArrayOutputStream outputStream = new ByteArrayOutputStream( + defaultBufferSize); + byte[] buffer = new byte[defaultBufferSize]; int readBytes = inputStream.read(buffer); while (readBytes > 0) { @@ -75,4 +84,3 @@ } } - Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ListenerSet.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ListenerSet.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ListenerSet.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -40,7 +40,7 @@ * de la liste des listeners.</p> * <p>Si on souhaite avoir une vérification sur le type de listener ajouté * il faut utiliser le constructeur qui prend une classe en paramètre. Dans ce - * cas la méthode {@link #addListener} vérifie que l'object passé est bien + * cas la méthode {@link #add(Object)} vérifie que l'object passé est bien * du type ou un enfant du type donné en paramètre du constructeur * <p>Il y a deux façon de prévenir les listeners d'un event soit par le * mécanisme inclu dans cette classe en utilisant la méthode {@link #fire} soit Modified: lutinutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,6 +1,6 @@ /* -* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin + * *##% Lutin utilities library + * Copyright (C) 2004 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ + package org.codelutin.util; import org.apache.commons.beanutils.ConversionException; @@ -32,7 +33,6 @@ * * @author chemit */ - public class LocaleConverter implements Converter { private static final Pattern FULL_SCOPE_PATTERN = Pattern.compile("([a-zA-Z]{2})_([a-zA-Z]{2})"); Modified: lutinutil/trunk/src/main/java/org/codelutin/util/Log.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/Log.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/Log.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -43,7 +43,7 @@ * Log.logTask("...", "...", max, value) pour indiquer qu'un traitement est * en cours. * <p/> - * Il suffit ensuite de creer un objet qui herite de {@link #LogListener}, puis + * Il suffit ensuite de creer un objet qui herite de {@link LogListener}, puis * de l'enregistrer sur certaine category d'event il recevra alors les * evenements de l'utilisateur. * <p/> Modified: lutinutil/trunk/src/main/java/org/codelutin/util/LoggingPatternFormatter.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/LoggingPatternFormatter.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/LoggingPatternFormatter.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -87,45 +87,47 @@ */ 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.codelutin.*|25} %M{15:105}: %m%n%e"; + private static final String DEFAULT_PATTERN = "%d{yyyy-MM-dd HH:mm:ss} [free:%o{-7}|total:%O{-7}][%t][%p{7}] %c{org.codelutin.*|25} %M{15:105}: %m%n%e"; protected HashMap<String, Class<?>> arguments = null; protected ArrayList<Argument> compile = null; protected String pattern = null; public LoggingPatternFormatter() { - try{ + try { arguments = new HashMap<String, Class<?>>(); initArguments(); LogManager manager = LogManager.getLogManager(); String cname = this.getClass().getName(); pattern = manager.getProperty(cname + ".pattern"); - if ( pattern == null ) + if (pattern == null) pattern = DEFAULT_PATTERN; compilePattern(pattern); - }catch(Exception eee){ + } catch (Exception eee) { System.err.println("Impossible d'utiliser le PatternFormatter"); eee.printStackTrace(); - throw new LoggingException("Exception durant l'initialisation du PatternFormatter", eee); + throw new LoggingException( + "Exception durant l'initialisation du PatternFormatter", + eee); } } /** - * Methode qui formate le record - */ - public String format(LogRecord record){ + * Methode qui formate le record + */ + public String format(LogRecord record) { StringBuffer result = new StringBuffer(); - for ( Iterator i=compile.iterator(); i.hasNext();) - ((Argument)i.next()).toString(record, result); + for (Iterator i = compile.iterator(); i.hasNext();) { + ((Argument) i.next()).toString(record, result); + } return result.toString(); } /** - * Si vous souhaitez ajouter des type d'argument - * Surcharger cette methode et a la fin fait un super.initArguments() - */ - protected void initArguments(){ + * Si vous souhaitez ajouter des type d'argument + * Surcharger cette methode et a la fin fait un super.initArguments() + */ + protected void initArguments() { arguments.put("d", DateArgument.class); arguments.put("o", FreeMemoryArgument.class); arguments.put("O", TotalMemoryArgument.class); @@ -138,12 +140,12 @@ } /** - * Genere a partir de la chaine la liste des objet Argument. - */ - protected void compilePattern(String pattern){ + * Genere a partir de la chaine la liste des objet Argument. + */ + protected void compilePattern(String pattern) { compile = new ArrayList<Argument>(); String[] match = findNextPattern(pattern); - while(!match[1].equals("")){ + while (!match[1].equals("")) { compile.add(new StringArgument(match[0])); compile.add(patternToArgument(match[1])); match = findNextPattern(match[2]); @@ -152,69 +154,73 @@ } /** - * 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. - */ - protected String [] findNextPattern(String s){ - String [] result = new String[]{"","",""}; - if( s == null ) + * 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. + */ + protected String[] findNextPattern(String s) { + String[] result = new String[] { "", "", "" }; + if (s == null) { return result; + } int d = s.indexOf("%"); - if(d != -1){ // il y a un % - if ( d+2 < s.length() && s.charAt(d+2) == '{' ){ - int f = s.indexOf("}", d); - if(f != -1){ // il y a une pattern %c{pattern} + if (d != -1) { // il y a un % + if (d + 2 < s.length() && s.charAt(d + 2) == '{') { + int f = s.indexOf("}", d); + if (f != -1) { // il y a une pattern %c{pattern} + result[0] = s.substring(0, d); + result[1] = s.substring(d + 1, f); + result[2] = s.substring(f + 1); + } else { + throw new LoggingException("Error, { at position " + + (d + 2) + " not terminated in :" + s); + } + } else { //pas de pattern result[0] = s.substring(0, d); - result[1] = s.substring(d+1, f); - result[2] = s.substring(f+1); + result[1] = s.substring(d + 1, d + 2); + result[2] = s.substring(d + 2); } - else{ - throw new LoggingException("Error, { at position "+(d+2)+" not terminated in :"+s); - } - } - else{ //pas de pattern - result[0] = s.substring(0, d); - result[1] = s.substring(d+1, d+2); - result[2] = s.substring(d+2); - } + } else { + result[0] = s; } - else - result[0] = s; return result; } /** - * Converti un pattern en un objet Argument - */ - protected Argument patternToArgument(String s){ - if ( s.charAt(0) == 'n' ){ // new ligne + * Converti un pattern en un objet Argument + */ + protected Argument patternToArgument(String s) { + if (s.charAt(0) == 'n') { // new ligne return new StringArgument("\n"); - }else if ( s.charAt(0) == '%' ){ // le caractere % + } else if (s.charAt(0) == '%') { // le caractere % return new StringArgument("%"); - }else if ( s.charAt(0) == '{' ){ // le caractere { - return new StringArgument("{"); + } else if (s.charAt(0) == '{') { // le caractere { + return new StringArgument("{"); - }else{ - String code = s.substring(0,1); - Class argumentClass = (Class)arguments.get(code); - if ( argumentClass == null ) - throw new LoggingException("Erreur dans le pattern '" + - code + "' inconnu"); + } else { + String code = s.substring(0, 1); + Class argumentClass = (Class) arguments.get(code); + if (argumentClass == null) + throw new LoggingException("Erreur dans le pattern '" + code + + "' inconnu"); Argument argument = null; - try{ - argument = (Argument)argumentClass.newInstance(); - }catch(InstantiationException eee){ - throw new LoggingException("Erreur lors de l'instanciation de l'objet Argument: "+argumentClass.getName(), eee); - }catch(IllegalAccessException eee){ - throw new LoggingException("Erreur lors de l'instanciation de l'objet Argument: "+argumentClass.getName(), eee); + try { + argument = (Argument) argumentClass.newInstance(); + } catch (InstantiationException eee) { + throw new LoggingException( + "Erreur lors de l'instanciation de l'objet Argument: " + + argumentClass.getName(), eee); + } catch (IllegalAccessException eee) { + throw new LoggingException( + "Erreur lors de l'instanciation de l'objet Argument: " + + argumentClass.getName(), eee); } - if ( s.length() > 1 ) { // on a un pattern + if (s.length() > 1) { // on a un pattern argument.setPattern(s.substring(2)); } @@ -222,142 +228,162 @@ } } - /////////////////////////////////////////////////////////////////////////////// //////////////////////////// Les Classes Argument ///////////////////////////// /////////////////////////////////////////////////////////////////////////////// - static protected abstract class Argument{ + static protected abstract class Argument { protected String pattern; - public Argument(){} - public void setPattern(String pattern){ + + public Argument() { + } + + public void setPattern(String pattern) { this.pattern = pattern; } + abstract public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo); + StringBuffer toAppendTo); } - static protected class StringArgument extends Argument{ + static protected class StringArgument extends Argument { protected String s = null; - public StringArgument(String s){ + + public StringArgument(String s) { super(); this.s = s; } - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { toAppendTo.append(s); return toAppendTo; } } - static protected class DateArgument extends Argument{ + + static protected class DateArgument extends Argument { protected SimpleDateFormat dateFormat = null; - public DateArgument(){super();} - public void setPattern(String pattern){ + public DateArgument() { + super(); + } + + public void setPattern(String pattern) { super.setPattern(pattern); dateFormat = new SimpleDateFormat(pattern); } - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { toAppendTo.append(dateFormat.format(new Date(record.getMillis()))); return toAppendTo; } } - static abstract protected class SizedArgument extends Argument{ + + static abstract protected class SizedArgument extends Argument { protected boolean left = true; protected int width = 0; protected int maxPos = -1; - public SizedArgument(){super();} - public void setPattern(String pattern){ + + public SizedArgument() { + super(); + } + + public void setPattern(String pattern) { super.setPattern(pattern); - if ( pattern.length() > 0 ){ - String [] subpattern = pattern.split(":"); + if (pattern.length() > 0) { + String[] subpattern = pattern.split(":"); pattern = subpattern[0]; char op = pattern.charAt(0); - if ( pattern.charAt(0) == '+' - || pattern.charAt(0) == '-' ) - pattern = pattern.substring(1); + if (pattern.charAt(0) == '+' || pattern.charAt(0) == '-') { + pattern = pattern.substring(1); + } width = Integer.parseInt(pattern); left = op != '-'; - if (subpattern.length > 1){ + if (subpattern.length > 1) { maxPos = Integer.parseInt(subpattern[1]); } } } - protected StringBuffer justify(String s, StringBuffer toAppendTo){ + + protected StringBuffer justify(String s, StringBuffer toAppendTo) { int blanc = width - s.length(); - if ( left ){ + if (left) { toAppendTo.append(s); - while(0<blanc-- - && (maxPos == -1 || toAppendTo.length() < maxPos)) - toAppendTo.append(" "); - }else{ - while(0<blanc-- - && (maxPos == -1 || toAppendTo.length() < maxPos)) - toAppendTo.append(" "); + while (0 < blanc-- + && (maxPos == -1 || toAppendTo.length() < maxPos)) { + toAppendTo.append(" "); + } + } else { + while (0 < blanc-- + && (maxPos == -1 || toAppendTo.length() < maxPos)) { + toAppendTo.append(" "); + } toAppendTo.append(s); } return toAppendTo; } } - static abstract protected class SubStringArgument extends SizedArgument{ + + 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; - public SubStringArgument(){super();} - public void setPattern(String pattern){ - String [] subpattern = pattern.split("\\|"); - for ( int i=0; i<subpattern.length; i++){ - try{ //on essai de voir si le pattern convient au SizedArgument + + public SubStringArgument() { + super(); + } + + public void setPattern(String pattern) { + String[] subpattern = pattern.split("\\|"); + for (int i = 0; i < subpattern.length; i++) { + try { //on essai de voir si le pattern convient au SizedArgument super.setPattern(subpattern[i]); - }catch(NumberFormatException eee){ + } catch (NumberFormatException eee) { // il ne convient pas au SizedArgument // c pour le substring atBeginning = subpattern[i].charAt(0) != '*'; - if ( subpattern[i].charAt(0) == '*'){ + if (subpattern[i].charAt(0) == '*') { removeString = subpattern[i].substring(1); + } else if (subpattern[i].endsWith("*")) { + removeString = subpattern[i].substring(0, subpattern[i] + .length() - 1); } - else if ( subpattern[i].endsWith("*")){ - removeString = - subpattern[i].substring(0, subpattern[i].length()-1); - } } } } - protected String substring(String s){ - if ( atBeginning ){ - if ( s.startsWith(removeString)) + + protected String substring(String s) { + if (atBeginning) { + if (s.startsWith(removeString)) return s.substring(removeString.length()); - }else{ - if ( s.endsWith(removeString)) + } else { + if (s.endsWith(removeString)) return s.substring(0, s.length() - removeString.length()); } return s; } } - static abstract protected class OctetArgument extends SizedArgument{ - protected static final String[] UNITE = - {"o", "Ko", "Mo", "Go", "To", "Po"}; + + static abstract protected class OctetArgument extends SizedArgument { + protected static final String[] UNITE = { "o", "Ko", "Mo", "Go", "To", + "Po" }; protected int diviseur = 1024; - public OctetArgument(){super();} + public OctetArgument() { + super(); + } + /** * 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) - * @param toAppendTo le buffer dans lequel il faut mettre le resultat - * @param width la largeur dont on dispose pour ecrire le resultat - * @param left vrai si on veut que le texte soit justifie a - * gauche, faux pour droit. - * @return le StringBuffer toAppendTo des arguments + * @return la representation */ - protected String toReadableSize(long size, String [] unit, - int diviseur){ + protected String toReadableSize(long size, String[] unit, int diviseur) { int unitIndex = 0; - while(size > 99999 && unitIndex < unit.length){ + while (size > 99999 && unitIndex < unit.length) { size /= diviseur; unitIndex++; } @@ -365,64 +391,87 @@ return result; } } - static protected class FreeMemoryArgument extends OctetArgument{ - public FreeMemoryArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class FreeMemoryArgument extends OctetArgument { + public FreeMemoryArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(toReadableSize(Runtime.getRuntime().freeMemory(), - UNITE, diviseur), toAppendTo); + UNITE, diviseur), toAppendTo); } } - static protected class TotalMemoryArgument extends OctetArgument{ - public TotalMemoryArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class TotalMemoryArgument extends OctetArgument { + public TotalMemoryArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(toReadableSize(Runtime.getRuntime().totalMemory(), - UNITE, diviseur), toAppendTo); + UNITE, diviseur), toAppendTo); } } - static protected class ThreadArgument extends SizedArgument{ - public ThreadArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class ThreadArgument extends SizedArgument { + public ThreadArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(Thread.currentThread().getName(), toAppendTo); } } - static protected class PriorityLevelArgument extends SizedArgument{ - public PriorityLevelArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class PriorityLevelArgument extends SizedArgument { + public PriorityLevelArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(record.getLevel().toString(), toAppendTo); } } - static protected class ClassNameArgument extends SubStringArgument{ - public ClassNameArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class ClassNameArgument extends SubStringArgument { + public ClassNameArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(substring(record.getSourceClassName()), toAppendTo); } } - static protected class MethodNameArgument extends SizedArgument{ - public MethodNameArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class MethodNameArgument extends SizedArgument { + public MethodNameArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(record.getSourceMethodName(), toAppendTo); } } - static protected class MessageArgument extends SizedArgument{ - public MessageArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + + static protected class MessageArgument extends SizedArgument { + public MessageArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { return justify(record.getMessage(), toAppendTo); } } - static protected class ExceptionArgument extends Argument{ - public ExceptionArgument(){super();} - public StringBuffer toString(LogRecord record, - StringBuffer toAppendTo){ + static protected class ExceptionArgument extends Argument { + public ExceptionArgument() { + super(); + } + + public StringBuffer toString(LogRecord record, StringBuffer toAppendTo) { Throwable e = record.getThrown(); - if(e != null){ + if (e != null) { toAppendTo.append(e.getMessage()); toAppendTo.append("\n"); StringWriter st = new StringWriter(); Modified: lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/ObjectUtil.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -170,7 +170,6 @@ /** * Get all methods with name given in argument without check parameters - * @param o object where search is done * @param methodName method name to search * @param ignoreCase if true, ignore difference in method name case * @return Modified: lutinutil/trunk/src/main/java/org/codelutin/util/StringUtil.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/StringUtil.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/StringUtil.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -44,7 +44,7 @@ * Java. * * @author poussin - * @created 21 octobre 2003 + * created 21 octobre 2003 */ public class StringUtil { // StringUtil Modified: lutinutil/trunk/src/main/java/org/codelutin/util/StringUtilException.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/StringUtilException.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/StringUtilException.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,5 +1,4 @@ -/** - * *##% Lutin utilities library +/* *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -16,19 +15,11 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ -/* - * Created on Dec 7, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ + package org.codelutin.util; /** * @author pineau - * <p/> - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public class StringUtilException extends RuntimeException { Modified: lutinutil/trunk/src/main/java/org/codelutin/util/TransformedList.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/TransformedList.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/TransformedList.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -40,8 +40,6 @@ public class TransformedList<E> extends AbstractList<E> implements Serializable { // TransformedList - // private static final long serialVersionUID = ; - /** */ private static final long serialVersionUID = 2354881761407900789L; Modified: lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java =================================================================== --- lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java 2009-05-01 18:12:49 UTC (rev 1463) +++ lutinutil/trunk/src/main/java/org/codelutin/util/URIConverter.java 2009-05-03 08:16:41 UTC (rev 1464) @@ -1,5 +1,4 @@ -/* -* *##% Lutin utilities library +/* *##% Lutin utilities library * Copyright (C) 2004 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -15,6 +14,7 @@ * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ + package org.codelutin.util; import org.apache.commons.beanutils.ConversionException; @@ -30,7 +30,6 @@ * * @author chemit */ - public class URIConverter implements Converter { /** to use log facility, just put in your code: log.info(\"...\"); */
participants (1)
-
chatellier@users.labs.libre-entreprise.org