public abstract class OrderedProperties extends Object implements Iterable<Map.Entry<String,String>>, Serializable
Properties except that the keys have a defined order.| Modifier and Type | Class and Description |
|---|---|
protected static class |
OrderedProperties.LineReader
Reads in a "logical line" from an
InputStream or Reader,
skip all comment and blank lines and filter out those leading whitespace
characters ( , and ) from the beginning of a "natural line". |
| Constructor and Description |
|---|
OrderedProperties() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doLoad(OrderedProperties.LineReader lineReader)
Reads the data from the specified
OrderedProperties.LineReader into this
OrderedProperties instance. |
void |
load(BufferedReader reader)
Reads the data from the specified
BufferedReader into this
OrderedProperties instance. |
void |
load(InputStream inputStream)
Reads the data from the specified
InputStream into this
OrderedProperties instance. |
protected static String |
loadConvert(char[] in,
int off,
int len,
char[] convertBuffer)
Converts encoded "\uxxxx" to Unicode
chars and changes
special saved chars to their original form. |
abstract String |
put(String key,
String value)
Associates the specified
value with the specified key. |
protected static String |
saveConvert(String content,
boolean isKey,
boolean escapeUnicode)
Converts Unicode characters to encoded "\uxxxx" and escapes special
characters with a preceding "\".
|
void |
store(BufferedWriter bw,
String comment,
String lineSeparator,
boolean escapeUnicode)
Writes the data from this
OrderedProperties to the specified
BufferedWriter. |
void |
store(OutputStream out,
String comment,
String lineSeparator,
boolean escapeUnicode)
Writes the data from this
OrderedProperties to the specified
OutputStream. |
void |
store(Writer writer,
String comment,
String lineSeparator,
boolean escapeUnicode)
Writes the data from this
OrderedProperties to the specified
Writer. |
static char |
toHex(int nibble)
Converts a nibble to a hexadecimal digit.
|
protected static void |
writeComment(BufferedWriter bw,
String comment,
String lineSeparator)
Writes a comment line to the specified
BufferedWriter. |
static void |
writeNewLine(BufferedWriter bw,
String lineSeparator)
Writes a newline to the specified
BufferedWriter using the
specified line separator sequence. |
public abstract String put(String key, String value)
value with the specified key. If
there previously was a mapping for the key, the old value is replaced.key - the key with which the specified value is to be associatedvalue - value to be associated with the specified key.key, or null
if there was no mapping for key or the previously
associated value was null.public void store(@Nonnull OutputStream out, @Nullable String comment, @Nullable String lineSeparator, boolean escapeUnicode) throws IOException
OrderedProperties to the specified
OutputStream.out - the OutputStream to write to.comment - the comment to add to the start of the output, or
null if no comment should be added.lineSeparator - the line separator sequence to write.escapeUnicode - true if Unicode characters should be written
using the "\uxxxx" notation, false otherwise.IOException - If an error occurs during the operation.public void store(@Nonnull Writer writer, @Nullable String comment, @Nullable String lineSeparator, boolean escapeUnicode) throws IOException
OrderedProperties to the specified
Writer.writer - the Writer to write to.comment - the comment to add to the start of the output, or
null if no comment should be added.lineSeparator - the line separator sequence to write.escapeUnicode - true if Unicode characters should be written
using the "\uxxxx" notation, false otherwise.IOException - If an error occurs during the operation.public void store(@Nonnull BufferedWriter bw, @Nullable String comment, @Nullable String lineSeparator, boolean escapeUnicode) throws IOException
OrderedProperties to the specified
BufferedWriter.bw - the BufferedWriter to write to.comment - the comment to add to the start of the output, or
null if no comment should be added.lineSeparator - the line separator sequence to write.escapeUnicode - true if Unicode characters should be written
using the "\uxxxx" notation, false otherwise.IOException - If an error occurs during the operation.public static void writeNewLine(@Nonnull BufferedWriter bw, @Nullable String lineSeparator) throws IOException
BufferedWriter using the
specified line separator sequence.bw - the BufferedWriter to write to.lineSeparator - the line separator sequence to write.IOException - If an error occurs during the operation.public void load(@Nullable InputStream inputStream) throws IOException
InputStream into this
OrderedProperties instance.inputStream - the InputStream to read from.IOException - If an error occurs during the operation.public void load(@Nullable BufferedReader reader) throws IOException
BufferedReader into this
OrderedProperties instance.reader - the BufferedReader to read from.IOException - If an error occurs during the operation.protected void doLoad(@Nonnull OrderedProperties.LineReader lineReader) throws IOException
OrderedProperties.LineReader into this
OrderedProperties instance.lineReader - the OrderedProperties.LineReader to use.IOException - If an error occurs during the operation.protected static String loadConvert(@Nonnull char[] in, int off, int len, @Nonnull char[] convertBuffer)
chars and changes
special saved chars to their original form.in - the char array to convert.off - the offset to use.len - the length to read.convertBuffer - the conversion buffer to (re-)use.String.@Nullable protected static String saveConvert(@Nullable String content, boolean isKey, boolean escapeUnicode)
Changes from Properties.saveConvert(java.lang.String, boolean, boolean) are that =, :, # and
! are only escaped in keys, and that a StringBuilder is
used instead of a StringBuffer since there's no need for the
added cost of synchronization.
protected static void writeComment(@Nonnull BufferedWriter bw, @Nullable String comment, @Nullable String lineSeparator) throws IOException
BufferedWriter.
Changes from Properties.writeComments(java.io.BufferedWriter, java.lang.String) are that a space is added
between the comment tag and the comment itself and that no date is added.
bw - the BufferedWriter to write to.comment - the comment String.lineSeparator - the line separator sequence to use.IOException - If an error occurs during the operation.public static char toHex(int nibble)
nibble - the nibble to convert.ArrayIndexOutOfBoundsException - If nibble isn't in the
range 0 to 16.Copyright © 2018. All rights reserved.