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 io.ultreia.java4all.i18n.spi;
/*-
* #%L
* I18n :: Spi
* %%
* Copyright (C) 2018 Code Lutin, Ultreia.io
* %%
* 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 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.
*
* Created by tchemit on 06/11/2018.
*
* @author Tony Chemit - [email protected]
*/
@SuppressWarnings("WeakerAccess")
public class I18nProperties extends Properties {
private static final String ENCODING_DEFAULT = "8859_1";
private static final String ENCODING_LATIN1 = "iso-8859-1";
private static final String ENCODING_ASCII = "us-ascii";
private static final long serialVersionUID = -1147150444452577558L;
/** 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'
};
/**
* A flag to write unicode using the a lower letter.
*
* Example : {@code \u00e9} instead of {@code \u00E9}.
*/
private final boolean unicodeLower;
private final char[] hexDigit;
/** l'encoding par defaut a utiliser pour lire et ecrire le properties. */
private String defaultEncoding;
/** un drapeau pour savoir s'il faut enlever l'entete generere */
private boolean removeHeader;
public I18nProperties() {
this(ENCODING_DEFAULT);
}
public I18nProperties(String defaultEncoding) {
this(defaultEncoding, true, false);
}
public I18nProperties(String defaultEncoding, boolean removeHeader) {
this(defaultEncoding, removeHeader, false);
}
public I18nProperties(String defaultEncoding, boolean removeHeader, boolean unicodeLower) {
this.defaultEncoding = defaultEncoding;
this.removeHeader = removeHeader;
this.unicodeLower = unicodeLower;
hexDigit = unicodeLower ? hexDigitLower : hexDigitUpper;
}
public I18nProperties(Properties defaults) {
super(defaults);
defaultEncoding = ENCODING_DEFAULT;
unicodeLower = false;
hexDigit = hexDigitUpper;
}
@Override
public Enumeration