Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.nuiton.io;
/*
* #%L
* Helper Maven Plugin :: API
* $Id: SortedProperties.java 876 2012-11-11 08:14:19Z tchemit $
* $HeadURL: http://svn.nuiton.org/svn/maven-helper-plugin/tags/maven-helper-plugin-2.1/helper-maven-plugin-api/src/main/java/org/nuiton/io/SortedProperties.java $
* %%
* Copyright (C) 2009 - 2012 Codelutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import org.nuiton.plugin.PluginHelper;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
/**
* Extend {@link Properties} to allow alphabetical order. Encoding could also
* be defined but you must use this class only with Java 1.6.
*
* @author ruchaud
* @author tchemit
*/
public class SortedProperties extends Properties {
private static final long serialVersionUID = -1147150444452577558L;
public static final String ENCODING_DEFAULT = "8859_1";
public static final String ENCODING_LATIN1 = "iso-8859-1";
public static final String ENCODING_ASCII = "us-ascii";
/** A table of hex digits in upper case */
private static final char[] hexDigitUpper = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
/** A table of hex digits in lower case */
private static final char[] hexDigitLower = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
/** l'encoding par defaut a utiliser pour lire et ecrire le properties. */
protected String defaultEncoding;
/** un drapeau pour savoir s'il faut enlever l'entete generere */
protected boolean removeHeader;
/**
* A flag to write unicode using the a lower letter.
*
* Example : {@code \u00e9} instead of {@code \u00E9}.
*/
final protected boolean unicodeLower;
final protected char[] hexDigit;
public SortedProperties() {
this(ENCODING_DEFAULT);
}
public SortedProperties(String defaultEncoding) {
this(defaultEncoding, true, false);
}
public SortedProperties(String defaultEncoding, boolean removeHeader) {
this(defaultEncoding, removeHeader, false);
}
public SortedProperties(String defaultEncoding, boolean removeHeader, boolean unicodeLower) {
this.defaultEncoding = defaultEncoding;
this.removeHeader = removeHeader;
this.unicodeLower = unicodeLower;
hexDigit = unicodeLower ? hexDigitLower : hexDigitUpper;
}
public SortedProperties(Properties defaults) {
super(defaults);
defaultEncoding = ENCODING_DEFAULT;
unicodeLower = false;
hexDigit = hexDigitUpper;
}
@Override
public Enumeration