Package io.ultreia.java4all.i18n.spi
Class I18nProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<Object,Object>
-
- java.util.Properties
-
- io.ultreia.java4all.i18n.spi.I18nProperties
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
public class I18nProperties extends Properties
ExtendPropertiesto 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 - dev@tchemit.fr
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.Properties
defaults
-
-
Constructor Summary
Constructors Constructor Description I18nProperties()I18nProperties(String defaultEncoding)I18nProperties(String defaultEncoding, boolean removeHeader)I18nProperties(String defaultEncoding, boolean removeHeader, boolean unicodeLower)I18nProperties(Properties defaults)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Enumeration<Object>keys()I18nPropertiesload(File src)Load all properties from givensrcfile using defineddefaultEncoding.I18nPropertiesload(File src, String encoding)Load Properties fromsrcfile using givendefaultEncoding.protected StringsaveConvert(String theString, boolean escapeSpace, boolean escapeUnicode)voidstore(File dst)Save properties in givendstfile using defineddefaultEncoding.voidstore(File dst, String encoding)Store Properties inoutputfile using givendefaultEncoding.voidstore(OutputStream dst)Save properties in givenstreamfile.voidstore(OutputStream out, String comments)voidstore(Writer writer, String comments)protected voidstore0(BufferedWriter bw, String comments, boolean escUnicode)protected voidstoreEncode(OutputStream stream, String encoding)If encoding is not the default Properties one, we will use a writer to use this custom encoding.voidwriteComments(BufferedWriter bw, String comments)-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Constructor Detail
-
I18nProperties
public I18nProperties()
-
I18nProperties
public I18nProperties(String defaultEncoding)
-
I18nProperties
public I18nProperties(String defaultEncoding, boolean removeHeader)
-
I18nProperties
public I18nProperties(String defaultEncoding, boolean removeHeader, boolean unicodeLower)
-
I18nProperties
public I18nProperties(Properties defaults)
-
-
Method Detail
-
keys
public Enumeration<Object> keys()
- Overrides:
keysin classProperties
-
load
public I18nProperties load(File src) throws IOException
Load all properties from givensrcfile using defineddefaultEncoding.- Parameters:
src- source file- Returns:
- this instance
- Throws:
IOException- if any io pb- See Also:
load(File, String)
-
load
public I18nProperties load(File src, String encoding) throws IOException
Load Properties fromsrcfile using givendefaultEncoding. If thisencodingis different from default onesENCODING_DEFAULT,ENCODING_LATIN1andENCODING_ASCII. A specificReaderwill be used to read the file.- Parameters:
src- File where Properties will be loadedencoding- Encoding to use- Returns:
- this instance
- Throws:
IOException- for any file errors- Since:
- 1.3
-
store
public void store(File dst) throws IOException
Save properties in givendstfile using defineddefaultEncoding.- Parameters:
dst- output file- Throws:
IOException- if any io pb- See Also:
store(File, String)
-
store
public void store(File dst, String encoding) throws IOException
Store Properties inoutputfile using givendefaultEncoding. If thisencodingis different from default onesENCODING_DEFAULT,ENCODING_LATIN1andENCODING_ASCII, a specificWriterwill be used to save the file. Otherwise the default Properties behavior will escape unicode chars with\uxxxx.- Parameters:
dst- File to save Propertiesencoding- Encoding to use- Throws:
IOException- for any file errors- Since:
- 1.3
-
storeEncode
protected void storeEncode(OutputStream stream, String encoding) throws IOException
If encoding is not the default Properties one, we will use a writer to use this custom encoding.We must call the right method depends on encoding, for a custom one the
store(Writer, String)method is used otherwise the default encoding 8859_1 must be used as superclass define it instore(OutputStream, String).Encoding
ENCODING_DEFAULT,ENCODING_LATIN1andENCODING_ASCIIare considered as default Properties one, so the old method will be use escaping unicode chars like\uxxxx.- Parameters:
stream- OutputStream to save inencoding- Encoding to use- Throws:
IOException- For any file errors
-
store
public void store(OutputStream dst) throws IOException
Save properties in givenstreamfile.defaultEncodingdefined will be ignored to store the properties file. The default encoding is the basic Properties one (Latin1 ISO), unicode chars will be escaped like basicstore(OutputStream, String)method.- Parameters:
dst- output file- Throws:
IOException- if any io pb
-
store
public void store(OutputStream out, String comments) throws IOException
- Overrides:
storein classProperties- Throws:
IOException
-
store
public void store(Writer writer, String comments) throws IOException
- Overrides:
storein classProperties- Throws:
IOException
-
store0
protected void store0(BufferedWriter bw, String comments, boolean escUnicode) throws IOException
- Throws:
IOException
-
saveConvert
protected String saveConvert(String theString, boolean escapeSpace, boolean escapeUnicode)
-
writeComments
public void writeComments(BufferedWriter bw, String comments) throws IOException
- Throws:
IOException
-
-