java.lang.Cloneablepublic final class EditableProperties
extends java.util.AbstractMap<java.lang.String,java.lang.String>
implements java.lang.Cloneable
Properties but designed to retain additional
information needed for safe hand-editing.
Useful for various *.properties in a project:
Collections.synchronizedMap(java.util.Map<K, V>).| Constructor | Description |
|---|---|
EditableProperties(boolean alphabetize) |
Creates empty instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.Object |
clone() |
|
EditableProperties |
cloneProperties() |
Create an exact copy of this properties object.
|
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entrySet() |
Returns a set view of the mappings ordered according to their file
position.
|
java.lang.String |
get(java.lang.Object key) |
|
java.lang.String[] |
getComment(java.lang.String key) |
Returns comment associated with the property.
|
java.lang.String |
getProperty(java.lang.String key) |
Convenience method to get a property as a string.
|
void |
load(java.io.InputStream stream) |
Load properties from a stream.
|
java.lang.String |
put(java.lang.String key,
java.lang.String value) |
|
void |
setComment(java.lang.String key,
java.lang.String[] comment,
boolean separate) |
Create comment for the property.
|
java.lang.String |
setProperty(java.lang.String key,
java.lang.String value) |
Convenience method to set a property.
|
java.lang.String |
setProperty(java.lang.String key,
java.lang.String[] value) |
Sets a property to a value broken into segments for readability.
|
void |
store(java.io.OutputStream stream) |
Store properties to a stream.
|
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, valuespublic EditableProperties(boolean alphabetize)
alphabetize - alphabetize new items according to key or notpublic java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
AbstractMap.entrySet() for more details.entrySet in class java.util.AbstractMap<java.lang.String,java.lang.String>public void load(java.io.InputStream stream)
throws java.io.IOException
stream - an input streamjava.io.IOException - if the contents are malformed or the stream could not be readpublic void store(java.io.OutputStream stream)
throws java.io.IOException
stream - an output streamjava.io.IOException - if the stream could not be written topublic java.lang.String get(java.lang.Object key)
get in class java.util.AbstractMap<java.lang.String,java.lang.String>public java.lang.String put(java.lang.String key,
java.lang.String value)
put in class java.util.AbstractMap<java.lang.String,java.lang.String>public java.lang.String getProperty(java.lang.String key)
get(java.lang.Object); only here because of pre-generic code.key - a property name; cannot be null nor emptypublic java.lang.String setProperty(java.lang.String key,
java.lang.String value)
put(java.lang.String, java.lang.String); only here because of pre-generic code.key - a property name; cannot be null nor emptyvalue - the desired value; cannot be nullpublic java.lang.String setProperty(java.lang.String key,
java.lang.String[] value)
setProperty(String,String) with the difference that each item
will be stored on its own line of text. getProperty(java.lang.String) will simply concatenate
all the items into one string, so generally separators
(such as : for path-like properties) must be included in
the items (for example, at the end of all but the last item).key - a property name; cannot be null nor emptyvalue - the desired value; cannot be null; can be empty arraypublic java.lang.String[] getComment(java.lang.String key)
key - a property name; cannot be null nor emptypublic void setComment(java.lang.String key,
java.lang.String[] comment,
boolean separate)
Note: if a comment includes non-ISO-8859-1 characters, they will be written
to disk using Unicode escapes (and getComment(java.lang.String) will interpret
such escapes), but of course they will be unreadable for humans.
key - a property name; cannot be null nor emptycomment - lines of comment which will be written just above
the property; no reformatting; comment lines must start with
comment delimiter; cannot be null; cannot be emty arrayseparate - whether the comment should be separated from previous
item by empty linepublic java.lang.Object clone()
clone in class java.util.AbstractMap<java.lang.String,java.lang.String>public EditableProperties cloneProperties()
Built on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.