Author: tchemit Date: 2010-04-14 11:26:43 +0200 (Wed, 14 Apr 2010) New Revision: 1825 Log: - Evolution #450: Remove deprecated package org.nuiton.util.config - Evolution #510: [ApplicationConfig] Make option states modifiable Removed: trunk/src/main/java/org/nuiton/util/config/ Modified: trunk/pom.xml trunk/src/main/java/org/nuiton/util/ApplicationConfig.java trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java trunk/src/main/java/org/nuiton/util/CollectionUtil.java trunk/src/main/java/org/nuiton/util/FileUtil.java trunk/src/main/java/org/nuiton/util/Log.java trunk/src/main/java/org/nuiton/util/SortedProperties.java trunk/src/test/java/org/nuiton/util/CategorisedListenerSetTest.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/pom.xml 2010-04-14 09:26:43 UTC (rev 1825) @@ -27,7 +27,9 @@ #L% --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -42,7 +44,7 @@ </parent> <artifactId>nuiton-utils</artifactId> - <version>1.2.3-SNAPSHOT</version> + <version>1.3-SNAPSHOT</version> <dependencies> Modified: trunk/src/main/java/org/nuiton/util/ApplicationConfig.java =================================================================== --- trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -391,9 +391,35 @@ * par exemple pour la version de l'application, ...) */ boolean isFinal(); + + /** + * Changes the default value of the option. + * + * @param defaultValue the new default value of the option + */ + void setDefaultValue(String defaultValue); + + /** + * Changes the transient state of the option. + * + * @param isTransient the new value of the transient state + */ + void setTransient(boolean isTransient); + + /** + * Changes the final state of the option. + * + * @param isFinal the new transient state value + */ + void setFinal(boolean isFinal); } - /** TODO */ + /** + * Defines a runtime action to be launched via the {@link #doAction()} + * method. + * + * @author poussin + */ static public class Action { @Retention(RetentionPolicy.RUNTIME) @@ -600,10 +626,10 @@ * * @param step do action only defined in this step * - * @throws IllegalAccessException TODO - * @throws IllegalArgumentException TODO - * @throws InvocationTargetException TODO - * @throws InstantiationException TODO + * @throws IllegalAccessException if action invocation failed + * @throws IllegalArgumentException if action invocation failed + * @throws InvocationTargetException if action invocation failed + * @throws InstantiationException if action invocation failed * * @see Action.Step */ @@ -728,7 +754,7 @@ * </ul> * * @since 1.2.1 - * @return TODO + * @return the system path */ protected String getSystemConfigurationPath() { @@ -792,7 +818,7 @@ * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html * * @since 1.2.1 - * @return TODO + * @return the user configuration path */ protected String getUserPath() { @@ -1183,13 +1209,13 @@ * if package, class or method missing, default is used * * @param name name of the action - * @param args TODO + * @param args arguments for action invocation * @return the created action - * @throws ArgumentsParserException TODO - * @throws IllegalAccessException TODO - * @throws IllegalArgumentException TODO - * @throws InstantiationException TODO - * @throws InvocationTargetException TODO + * @throws ArgumentsParserException if parsing failed + * @throws IllegalAccessException if could not create action + * @throws IllegalArgumentException if could not create action + * @throws InstantiationException if could not create action + * @throws InvocationTargetException if could not create action */ protected Action createAction(String name, ListIterator<String> args) @@ -1271,7 +1297,7 @@ * Load configuration file and prepare Action. * * @param args argument as main(String[] args) - * @throws ArgumentsParserException TODO + * @throws ArgumentsParserException if parsing failed */ public void parse(String[] args) throws ArgumentsParserException { try { @@ -1526,16 +1552,16 @@ pcs.removePropertyChangeListener(propertyName, listener); } - public synchronized boolean hasListeners(String propertyName) { + public boolean hasListeners(String propertyName) { return pcs.hasListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners( + public PropertyChangeListener[] getPropertyChangeListeners( String propertyName) { return pcs.getPropertyChangeListeners(propertyName); } - public synchronized PropertyChangeListener[] getPropertyChangeListeners() { + public PropertyChangeListener[] getPropertyChangeListeners() { return pcs.getPropertyChangeListeners(); } } Modified: trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java =================================================================== --- trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -67,7 +67,7 @@ * * @param <L> listener type * - * @see org.nuiton.util.ListenerSet + * @see ListenerSet */ public class CategorisedListenerSet<L> { // CategorisedListenerSet @@ -107,23 +107,8 @@ this.isClassCategory = isClassCategory; } - /** - * @param listenerClass la classe dont doit heriter les listeners pour - * etre accepté lors de l'ajout - * @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 - * les peres dans la hierarchie d'heritage de la classe (Super class et - * interfaces) - * - * @deprecated unused same as {@code CategorisedListenerSet(boolean)} - */ - @Deprecated - public CategorisedListenerSet(Class<?> listenerClass, boolean isClassCategory) { - this(isClassCategory); - } - protected void checkCategory(Object category) { - if (category == ALL) { + if (ALL.equals(category)) { throw new IllegalArgumentException( "ALL category can't be use to add listener or add Category"); } @@ -217,12 +202,13 @@ } /** - * Retourne un ListenerSet contenant tous les listeners c'est à dire les + * @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 */ protected ListenerSet<L> getAllListeners(Object category) { ListenerSet<L> result = new ListenerSet<L>(); - if (category == ALL) { + if (ALL.equals(category)) { for (ListenerSet<L> ls : listeners.values()) { result.addAll(ls); } @@ -256,7 +242,8 @@ } /** - * Retourne un ListenerSet contenant seulement les listener de la categorie + * @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éé. */ protected ListenerSet<L> getListeners(Object category) { Modified: trunk/src/main/java/org/nuiton/util/CollectionUtil.java =================================================================== --- trunk/src/main/java/org/nuiton/util/CollectionUtil.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/CollectionUtil.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -92,16 +92,19 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> List<O> toGenericList(List list, Class<O> type) throws IllegalArgumentException { + static public <O> List<O> toGenericList( + List<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { - return list; + return (List<O>) list; } for (Object o : list) { - if (!(type.isAssignableFrom(o.getClass()))) { - throw new IllegalArgumentException("can not cast List with object of type " + o.getClass() + " to " + type + " type!"); + if (!type.isAssignableFrom(o.getClass())) { + throw new IllegalArgumentException( + "can not cast List with object of type " + + o.getClass() + " to " + type + " type!"); } } - return list; + return (List<O>) list; } /** @@ -120,16 +123,19 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> Collection<O> toGenericCollection(Collection list, Class<O> type) throws IllegalArgumentException { + static public <O> Collection<O> toGenericCollection( + Collection<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { - return list; + return (Collection<O>) list; } for (Object o : list) { - if (!(type.isAssignableFrom(o.getClass()))) { - throw new IllegalArgumentException("can not cast Collection with object of type " + o.getClass() + " to " + type + " type!"); + if (!type.isAssignableFrom(o.getClass())) { + throw new IllegalArgumentException( + "can not cast Collection with object of type " + + o.getClass() + " to " + type + " type!"); } } - return list; + return (Collection<O>) list; } /** @@ -148,16 +154,19 @@ * pas en adéquation avec le type voulue. */ @SuppressWarnings({"unchecked"}) - static public <O> Set<O> toGenericSet(Set list, Class<O> type) throws IllegalArgumentException { + static public <O> Set<O> toGenericSet( + Set<?> list, Class<O> type) throws IllegalArgumentException { if (list.isEmpty()) { - return list; + return (Set<O>) list; } for (Object o : list) { - if (!(type.isAssignableFrom(o.getClass()))) { - throw new IllegalArgumentException("can not cast Set with object of type " + o.getClass() + " to " + type + " type!"); + if (!type.isAssignableFrom(o.getClass())) { + throw new IllegalArgumentException( + "can not cast Set with object of type " + + o.getClass() + " to " + type + " type!"); } } - return list; + return (Set<O>) list; } } Modified: trunk/src/main/java/org/nuiton/util/FileUtil.java =================================================================== --- trunk/src/main/java/org/nuiton/util/FileUtil.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/FileUtil.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -614,8 +614,8 @@ return result; } - static public interface FileAction { - public boolean doAction(File f); + public interface FileAction { + boolean doAction(File f); } /** Modified: trunk/src/main/java/org/nuiton/util/Log.java =================================================================== --- trunk/src/main/java/org/nuiton/util/Log.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/Log.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -78,10 +78,10 @@ static private Log LOG_INSTANCE = new Log(); /** L'interface que doivent respecter un listener */ - static public interface LogListener extends EventListener { - public void logMessage(LogEvent e); + public interface LogListener extends EventListener { + void logMessage(LogEvent e); - public void logTask(LogEvent e); + void logTask(LogEvent e); } /** Les events envoyes aux listeners */ Modified: trunk/src/main/java/org/nuiton/util/SortedProperties.java =================================================================== --- trunk/src/main/java/org/nuiton/util/SortedProperties.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/main/java/org/nuiton/util/SortedProperties.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -45,7 +45,6 @@ public SortedProperties() { - super(); } public SortedProperties(Properties defaults) { Modified: trunk/src/test/java/org/nuiton/util/CategorisedListenerSetTest.java =================================================================== --- trunk/src/test/java/org/nuiton/util/CategorisedListenerSetTest.java 2010-04-12 19:25:17 UTC (rev 1824) +++ trunk/src/test/java/org/nuiton/util/CategorisedListenerSetTest.java 2010-04-14 09:26:43 UTC (rev 1825) @@ -83,7 +83,7 @@ } { - CategorisedListenerSet<Object> cls = new CategorisedListenerSet<Object>(null, false); + CategorisedListenerSet<Object> cls = new CategorisedListenerSet<Object>(false); String[] ls = new String[]{"Double", "Long", "Number", "Object", "LoggingException", "Throwable"};