Package org.nuiton.io
Class SortedProperties
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
Extend
Properties to allow alphabetical order. Encoding could also
be defined, but you must use this class only with Java 1.6.- Author:
- ruchaud - ruchaud@codelutin.com, Tony Chemit - chemit@codelutin.com
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringL'encoding par défaut à utiliser pour lire et écrire le properties.static final Stringstatic final Stringstatic final Stringprotected final char[]protected booleanun drapeau pour savoir s'il faut enlever l'entete generereprotected final booleanA flag to write unicode using the a lower letter.Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionSortedProperties(String defaultEncoding) SortedProperties(String defaultEncoding, boolean removeHeader) SortedProperties(String defaultEncoding, boolean removeHeader, boolean unicodeLower) SortedProperties(Properties defaults) -
Method Summary
Modifier and TypeMethodDescriptionkeys()Load all properties from givensrcfile using defineddefaultEncoding.Load Properties fromsrcfile using givendefaultEncoding.protected StringsaveConvertInternal(String theString, boolean escapeSpace, boolean escapeUnicode) voidSave properties in givendstfile using defineddefaultEncoding.voidStore Properties inoutputfile using givendefaultEncoding.voidstore(OutputStream dst) Save properties in givenstreamfile.voidstore(OutputStream out, String comments) voidprotected voidstoreEncode(OutputStream stream, String encoding) If encoding is not the default Properties one, we will use a writer to use this custom encoding.protected voidstoreInternal(BufferedWriter bw, String comments, boolean escUnicode) protected chartoHex(int nibble) Convert a nibble to a hex character.voidwriteCommentsInternal(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
-
Field Details
-
ENCODING_DEFAULT
- See Also:
-
ENCODING_LATIN1
- See Also:
-
ENCODING_ASCII
- See Also:
-
defaultEncoding
L'encoding par défaut à utiliser pour lire et écrire le properties. -
removeHeader
protected boolean removeHeaderun drapeau pour savoir s'il faut enlever l'entete generere -
unicodeLower
protected final boolean unicodeLowerA flag to write unicode using the a lower letter.Example :
éinstead ofé. -
hexDigit
protected final char[] hexDigit
-
-
Constructor Details
-
SortedProperties
public SortedProperties() -
SortedProperties
-
SortedProperties
-
SortedProperties
-
SortedProperties
-
-
Method Details
-
keys
- Overrides:
keysin classProperties
-
load
Load all properties from givensrcfile using defineddefaultEncoding.- Parameters:
src- source file- Returns:
- this instance
- Throws:
IOException- if any io pb- See Also:
-
load
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
Save properties in givendstfile using defineddefaultEncoding.- Parameters:
dst- output file- Throws:
IOException- if any io pb- See Also:
-
store
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
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
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
- Overrides:
storein classProperties- Throws:
IOException
-
store
- Overrides:
storein classProperties- Throws:
IOException
-
storeInternal
protected void storeInternal(BufferedWriter bw, String comments, boolean escUnicode) throws IOException - Throws:
IOException
-
saveConvertInternal
-
writeCommentsInternal
- Throws:
IOException
-
toHex
protected char toHex(int nibble) Convert a nibble to a hex character.- Parameters:
nibble- the nibble to convert.- Returns:
- the converted nibble
-