Index: lutinutil/src/java/org/codelutin/util/SortedProperties.java diff -u /dev/null lutinutil/src/java/org/codelutin/util/SortedProperties.java:1.1 --- /dev/null Sun Mar 16 17:52:53 2008 +++ lutinutil/src/java/org/codelutin/util/SortedProperties.java Sun Mar 16 17:52:46 2008 @@ -0,0 +1,62 @@ +/* *##% + * Copyright (C) 2007 + * I18nPlugin, Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.util; + +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Properties; +import java.util.Vector; + +/** + * Permet d'avoir les fichiers de propriétés triés. + * + * @author julien + */ +public class SortedProperties extends Properties { + + private static final long serialVersionUID = -1147150444452577558L; + + + public SortedProperties() { + super(); + } + + public SortedProperties(Properties defaults) { + super(defaults); + } + + @Override + public synchronized Enumeration keys() { + List objects = Collections.list(super.keys()); + Vector result; + try { + // Attention, si les clef ne sont pas des string, ca ne marchera pas + List list = CollectionUtil.toGenericList(objects, String.class); + Collections.sort(list); + result = new Vector(list); + } catch (IllegalArgumentException e) { + // keys are not string !!! + // can not sort keys + result = new Vector(objects); + } + return result.elements(); + } +}