| org.netbeans.spi.project.support.ant.EditableProperties
EditableProperties | final public class EditableProperties extends AbstractMap implements Cloneable(Code) | | Similar to
java.util.Properties but designed to retain additional
information needed for safe hand-editing.
Useful for various *.properties in a project:
- Can associate comments with particular entries.
- Order of entries preserved during modifications whenever possible.
- VCS-friendly: lines which are not semantically modified are not textually modified.
- Can automatically insert line breaks in new or modified values at positions
that are likely to be semantically meaningful, e.g. between path components
The file format (including encoding etc.) is compatible with the regular JRE implementation.
Only (non-null) String is supported for keys and values.
This class is not thread-safe; use only from a single thread, or use
java.util.Collections.synchronizedMap .
author: Jesse Glick, David Konecny |
EditableProperties | public EditableProperties()(Code) | | Creates empty instance whose items will not be alphabetized.
|
EditableProperties | public EditableProperties(boolean alphabetize)(Code) | | Creates empty instance.
Parameters: alphabetize - alphabetize new items according to key or not |
EditableProperties | public EditableProperties(Map<String, String> map)(Code) | | Creates instance from an existing map. No comments will be defined.
Any order from the existing map will be retained,
and further additions will not be alphabetized.
Parameters: map - a map from String to String |
cloneProperties | public EditableProperties cloneProperties()(Code) | | Create an exact copy of this properties object.
a clone of this object |
entrySet | public Set<Map.Entry<String, String>> entrySet()(Code) | | Returns a set view of the mappings ordered according to their file
position. Each element in this set is a Map.Entry. See
AbstractMap.entrySet for more details.
set with Map.Entry instances. |
getComment | public String[] getComment(String key)(Code) | | Returns comment associated with the property. The comment lines are
returned as defined in properties file, that is comment delimiter is
included. Comment for property is defined as: continuous block of lines
starting with comment delimiter which are followed by property
declaration (no empty line separator allowed).
Parameters: key - a property name; cannot be null nor empty array of String lines as specified in properties file; commentdelimiter character is included |
getProperty | public String getProperty(String key)(Code) | | Convenience method to get a property as a string.
Same as
EditableProperties.get ; only here because of pre-generic code.
Parameters: key - a property name; cannot be null nor empty the property value, or null if it was not defined |
load | public void load(InputStream stream) throws IOException(Code) | | Load properties from a stream.
Parameters: stream - an input stream throws: IOException - if the contents are malformed or the stream could not be read |
setComment | public void setComment(String key, String[] comment, boolean separate)(Code) | | Create comment for the property.
Note: if a comment includes non-ISO-8859-1 characters, they will be written
to disk using Unicode escapes (and
EditableProperties.getComment will interpret
such escapes), but of course they will be unreadable for humans.
Parameters: key - a property name; cannot be null nor empty Parameters: comment - lines of comment which will be written just abovethe property; no reformatting; comment lines must start with comment delimiter; cannot be null; cannot be emty array Parameters: separate - whether the comment should be separated from previousitem by empty line |
setProperty | public String setProperty(String key, String value)(Code) | | Convenience method to set a property.
Same as
EditableProperties.put ; only here because of pre-generic code.
Parameters: key - a property name; cannot be null nor empty Parameters: value - the desired value; cannot be null previous value of the property or null if there was not any |
setProperty | public String setProperty(String key, String[] value)(Code) | | Sets a property to a value broken into segments for readability.
Same behavior as
EditableProperties.setProperty(String,String) with the difference that each item
will be stored on its own line of text.
EditableProperties.getProperty 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).
Parameters: key - a property name; cannot be null nor empty Parameters: value - the desired value; cannot be null; can be empty array previous value of the property or null if there was not any |
|
|