public class UTF8Properties extends java.util.Properties implements TaggedStrings, java.io.Serializable
Regular Java Properties must be read and written using the ISO8859-1 character encoding. UTF8Properties reads and writes the properties using the utf-8 character encoding instead.
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
keyValueSeparators
Allowed separators between key and value of a property.
|
| Constructor and Description |
|---|
UTF8Properties()
Create empty property list with no default values.
|
UTF8Properties(java.util.Properties defaults)
Create empty property list with specified defaults.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsString(java.lang.String string)
See if list contains specified string.
|
static java.lang.String |
convertInputString(java.lang.String line)
Replace all characters preceded by a '\' with the corresponding
special character and convert unicode escape sequences to
normal characterS.
|
protected java.lang.String |
formatStringForOutput(java.lang.String line)
Format string for output.
|
java.util.Set<java.lang.String> |
getAllStrings()
Get set of all unique strings.
|
java.util.Set<java.lang.String> |
getAllTags()
Get set of all unique tags.
|
int |
getStringCount()
Get number of strings.
|
java.lang.String |
getTag(java.lang.String string)
Get the tag value associated with a string.
|
protected boolean |
isContinued(java.lang.String line)
Check if property continues on the next line.
|
void |
load(java.io.InputStream inputStream)
Reads a property list (key and element pairs) from a utf-8 encoded
input stream.
|
void |
load(java.io.InputStream inputStream,
java.lang.String defaultValue)
Reads a property list (key and element pairs) from a utf-8 encoded
input stream.
|
void |
putTag(java.lang.String string,
java.lang.String tag)
Set the tag value associated with a string.
|
static java.lang.String |
removeLeadingWhiteSpace(java.lang.String line)
Remove leading white space from a string.
|
void |
save(java.io.OutputStream outputStream,
java.lang.String header)
Deprecated.
Use
store( OutputStream , String )
instead. |
void |
store(java.io.OutputStream outputStream,
java.lang.String header)
Store properties to a file.
|
void |
store(java.io.OutputStream outputStream,
java.lang.String header,
boolean outputOnlyKeys)
Store properties to a file.
|
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, setProperty, store, storeToXML, storeToXML, stringPropertyNamesprotected static final java.lang.String keyValueSeparators
public UTF8Properties()
public UTF8Properties(java.util.Properties defaults)
defaults - Default property values.public void load(java.io.InputStream inputStream,
java.lang.String defaultValue)
throws java.io.IOException
inputStream - The input stream.defaultValue - The default value when none specified.java.io.IOException - When an error occurs while reading
from the input stream.java.lang.IllegalArgumentException - When the input stream contains an invalid Unicode
escape sequence.
The default value is assigned to any key which does not have a value. Assume the default value is the string "missing". Then the input line
x=1
returns a key of "x" with value of "1", while the input line
x
returns a key of "x" with value of "missing" .
public void load(java.io.InputStream inputStream)
throws java.io.IOException
load in class java.util.PropertiesinputStream - The input stream.java.io.IOException - When an error occurs while reading
from the input stream.java.lang.IllegalArgumentException - When the input stream contains an invalid Unicode
escape sequence.
Null is used as the default value for any key without a specified value.
public static java.lang.String removeLeadingWhiteSpace(java.lang.String line)
line - The string from which to remove leading
white space.public static java.lang.String convertInputString(java.lang.String line)
line - String for which to process escape sequences.protected java.lang.String formatStringForOutput(java.lang.String line)
line - String to convert to output format.protected boolean isContinued(java.lang.String line)
line - Beginning of the property that might be continued
on the next line.A trailing "\" character indicates a property value is continued on the next line.
public void save(java.io.OutputStream outputStream,
java.lang.String header)
store( OutputStream , String )
instead.save in class java.util.PropertiesoutputStream - Stream to which to save properties.header - Optionl description of the property list.java.lang.ClassCastException - If any key or value is not a String.public void store(java.io.OutputStream outputStream,
java.lang.String header,
boolean outputOnlyKeys)
throws java.io.IOException
outputStream - Output stream.header - Optional description of property list.outputOnlyKeys - True to output only the keys,
false to output both the keys
and the values.java.io.IOException - When an error occurs while writing
to the output stream.public void store(java.io.OutputStream outputStream,
java.lang.String header)
throws java.io.IOException
store in class java.util.PropertiesoutputStream - Output stream.header - Optional description of the property list.java.io.IOException - When an error occurs while writing
to the output stream.public boolean containsString(java.lang.String string)
containsString in interface TaggedStringsstring - The string.public java.lang.String getTag(java.lang.String string)
getTag in interface TaggedStringsstring - The string.public void putTag(java.lang.String string,
java.lang.String tag)
putTag in interface TaggedStringsstring - The string.tag - The tag.public int getStringCount()
getStringCount in interface TaggedStringspublic java.util.Set<java.lang.String> getAllStrings()
getAllStrings in interface TaggedStringspublic java.util.Set<java.lang.String> getAllTags()
getAllTags in interface TaggedStrings