public class Properties
extends java.util.AbstractMap<java.lang.String,java.lang.String>
Enhancement of the standard Properties
managing the maintain of comments, etc.
Modifier and Type | Class | Description |
---|---|---|
protected static class |
Properties.Layout |
TODO
|
static class |
Properties.PropertiesReader |
This class is used to read properties lines.
|
static class |
Properties.PropertiesWriter |
This class is used to write properties lines.
|
Constructor | Description |
---|---|
Properties() |
|
Properties(boolean substitute) |
|
Properties(java.io.File location) |
|
Properties(java.io.File location,
boolean substitute) |
|
Properties(java.io.File location,
InterpolationHelper.SubstitutionCallback callback) |
|
Properties(java.io.File location,
org.osgi.framework.BundleContext context) |
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
|
static boolean |
contains(char[] array,
char valueToFind) |
Checks if the value is in the given array.
|
java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entrySet() |
|
protected static java.lang.String |
escapeJava(java.lang.String str) |
Escapes the characters in a
String using Java String rules. |
java.util.List<java.lang.String> |
getComments(java.lang.String key) |
|
java.util.List<java.lang.String> |
getFooter() |
Return the comment footer.
|
java.util.List<java.lang.String> |
getHeader() |
Return the comment header.
|
java.lang.String |
getProperty(java.lang.String key) |
Searches for the property with the specified key in this property list.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue) |
Searches for the property with the specified key in this property list.
|
java.util.List<java.lang.String> |
getRaw(java.lang.String key) |
|
protected static java.lang.String |
hex(char ch) |
Returns an upper case hexadecimal
String for the given
character. |
void |
load(java.io.File location) |
|
void |
load(java.io.InputStream is) |
|
void |
load(java.io.Reader reader) |
|
void |
load(java.net.URL location) |
|
protected void |
loadLayout(java.io.Reader in,
boolean maybeTyped) |
Reads a properties file and stores its internal structure.
|
java.util.Enumeration<?> |
propertyNames() |
Returns an enumeration of all the keys in this property list, including distinct keys in the default property
list if a key of the same name has not already been found from the main properties list.
|
java.lang.String |
put(java.lang.String key,
java.lang.String value) |
|
java.lang.String |
put(java.lang.String key,
java.lang.String comment,
java.lang.String value) |
|
java.lang.String |
put(java.lang.String key,
java.util.List<java.lang.String> commentLines,
java.lang.String value) |
|
java.lang.String |
put(java.lang.String key,
java.util.List<java.lang.String> commentLines,
java.util.List<java.lang.String> valueLines) |
|
java.lang.String |
remove(java.lang.Object key) |
|
void |
save() |
|
void |
save(java.io.File location) |
|
void |
save(java.io.OutputStream os) |
|
void |
save(java.io.Writer writer) |
|
protected void |
saveLayout(java.io.Writer out,
boolean typed) |
Writes the properties file to the given writer, preserving as much of its
structure as possible.
|
void |
setFooter(java.util.List<java.lang.String> footer) |
Set the comment footer.
|
void |
setHeader(java.util.List<java.lang.String> header) |
Set the comment header.
|
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value) |
Calls the map method put.
|
void |
store(java.io.OutputStream os,
java.lang.String comment) |
Store a properties into a output stream, preserving comments, special character, etc.
|
void |
substitute() |
|
void |
substitute(InterpolationHelper.SubstitutionCallback callback) |
|
protected static java.lang.String |
unescapeJava(java.lang.String str) |
Unescapes any Java literals found in the
String to a
Writer . |
boolean |
update(java.util.Map<java.lang.String,java.lang.String> props) |
|
boolean |
update(Properties properties) |
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, size, toString, values
public Properties()
public Properties(java.io.File location) throws java.io.IOException
java.io.IOException
public Properties(java.io.File location, org.osgi.framework.BundleContext context) throws java.io.IOException
java.io.IOException
public Properties(java.io.File location, InterpolationHelper.SubstitutionCallback callback) throws java.io.IOException
java.io.IOException
public Properties(boolean substitute)
public Properties(java.io.File location, boolean substitute)
public void load(java.io.File location) throws java.io.IOException
java.io.IOException
public void load(java.net.URL location) throws java.io.IOException
java.io.IOException
public void load(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void load(java.io.Reader reader) throws java.io.IOException
java.io.IOException
public void save() throws java.io.IOException
java.io.IOException
public void save(java.io.File location) throws java.io.IOException
java.io.IOException
public void save(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void save(java.io.Writer writer) throws java.io.IOException
java.io.IOException
public void store(java.io.OutputStream os, java.lang.String comment) throws java.io.IOException
os
- an output stream.comment
- this parameter is ignored as this Propertiesjava.io.IOException
- If storing failspublic java.lang.String getProperty(java.lang.String key)
key
- the property key.public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
key
- the property key.defaultValue
- a default value.public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.String>> entrySet()
entrySet
in class java.util.AbstractMap<java.lang.String,java.lang.String>
public java.util.Enumeration<?> propertyNames()
public java.lang.Object setProperty(java.lang.String key, java.lang.String value)
key
- the key to be placed into this property list.value
- the value corresponding to the key.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 put(java.lang.String key, java.util.List<java.lang.String> commentLines, java.util.List<java.lang.String> valueLines)
public java.lang.String put(java.lang.String key, java.util.List<java.lang.String> commentLines, java.lang.String value)
public java.lang.String put(java.lang.String key, java.lang.String comment, java.lang.String value)
public boolean update(java.util.Map<java.lang.String,java.lang.String> props)
public boolean update(Properties properties)
public java.util.List<java.lang.String> getRaw(java.lang.String key)
public java.util.List<java.lang.String> getComments(java.lang.String key)
public java.lang.String remove(java.lang.Object key)
remove
in class java.util.AbstractMap<java.lang.String,java.lang.String>
public void clear()
clear
in class java.util.AbstractMap<java.lang.String,java.lang.String>
public java.util.List<java.lang.String> getHeader()
public void setHeader(java.util.List<java.lang.String> header)
header
- the header to usepublic java.util.List<java.lang.String> getFooter()
public void setFooter(java.util.List<java.lang.String> footer)
footer
- the footer to useprotected void loadLayout(java.io.Reader in, boolean maybeTyped) throws java.io.IOException
in
- the reader to the properties filejava.io.IOException
- if an error occurspublic void substitute()
public void substitute(InterpolationHelper.SubstitutionCallback callback)
protected void saveLayout(java.io.Writer out, boolean typed) throws java.io.IOException
out
- the writerjava.io.IOException
- if an error occursprotected static java.lang.String unescapeJava(java.lang.String str)
Unescapes any Java literals found in the String
to a
Writer
.
str
- the String
to unescape, may be nulljava.lang.IllegalArgumentException
- if the Writer is null
protected static java.lang.String escapeJava(java.lang.String str)
Escapes the characters in a String
using Java String rules.
Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters '\\'
and
't'
.
The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.
Example:
input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\"
str
- String to escape values in, may be nullnull
if null string inputprotected static java.lang.String hex(char ch)
Returns an upper case hexadecimal String
for the given
character.
ch
- The character to convert.String
public static boolean contains(char[] array, char valueToFind)
Checks if the value is in the given array.
The method returns false
if a null
array is passed in.
array
- the array to search throughvalueToFind
- the value to findtrue
if the array contains the object