Modifier and Type | Class and 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.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
Properties() |
Properties(boolean substitute) |
Properties(File location) |
Properties(File location,
boolean substitute) |
Properties(File location,
org.osgi.framework.BundleContext context) |
Properties(File location,
InterpolationHelper.SubstitutionCallback callback) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
static boolean |
contains(char[] array,
char valueToFind)
Checks if the value is in the given array.
|
Set<Map.Entry<String,String>> |
entrySet() |
protected static String |
escapeJava(String str)
Escapes the characters in a
String using Java String rules. |
List<String> |
getComments(String key) |
List<String> |
getFooter()
Return the comment footer.
|
List<String> |
getHeader()
Return the comment header.
|
String |
getProperty(String key)
Searches for the property with the specified key in this property list.
|
String |
getProperty(String key,
String defaultValue)
Searches for the property with the specified key in this property list.
|
List<String> |
getRaw(String key) |
protected static String |
hex(char ch)
Returns an upper case hexadecimal
String for the given
character. |
void |
load(File location) |
void |
load(InputStream is) |
void |
load(Reader reader) |
void |
load(URL location) |
protected void |
loadLayout(Reader in,
boolean maybeTyped)
Reads a properties file and stores its internal structure.
|
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.
|
String |
put(String key,
List<String> commentLines,
List<String> valueLines) |
String |
put(String key,
List<String> commentLines,
String value) |
String |
put(String key,
String value) |
String |
put(String key,
String comment,
String value) |
String |
remove(Object key) |
void |
save() |
void |
save(File location) |
void |
save(OutputStream os) |
void |
save(Writer writer) |
protected void |
saveLayout(Writer out,
boolean typed)
Writes the properties file to the given writer, preserving as much of its
structure as possible.
|
void |
setFooter(List<String> footer)
Set the comment footer.
|
void |
setHeader(List<String> header)
Set the comment header.
|
Object |
setProperty(String key,
String value)
Calls the map method put.
|
void |
store(OutputStream os,
String comment)
Store a properties into a output stream, preserving comments, special character, etc.
|
void |
substitute() |
void |
substitute(InterpolationHelper.SubstitutionCallback callback) |
protected static String |
unescapeJava(String str)
Unescapes any Java literals found in the
String to a
Writer . |
boolean |
update(Map<String,String> props) |
boolean |
update(Properties properties) |
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public Properties()
public Properties(File location) throws IOException
IOException
public Properties(File location, org.osgi.framework.BundleContext context) throws IOException
IOException
public Properties(File location, InterpolationHelper.SubstitutionCallback callback) throws IOException
IOException
public Properties(boolean substitute)
public Properties(File location, boolean substitute)
public void load(File location) throws IOException
IOException
public void load(URL location) throws IOException
IOException
public void load(InputStream is) throws IOException
IOException
public void load(Reader reader) throws IOException
IOException
public void save() throws IOException
IOException
public void save(File location) throws IOException
IOException
public void save(OutputStream os) throws IOException
IOException
public void save(Writer writer) throws IOException
IOException
public void store(OutputStream os, String comment) throws IOException
os
- an output stream.comment
- this parameter is ignored as this PropertiesIOException
- If storing failspublic String getProperty(String key)
key
- the property key.public String getProperty(String key, String defaultValue)
key
- the property key.defaultValue
- a default value.public Enumeration<?> propertyNames()
public Object setProperty(String key, String value)
key
- the key to be placed into this property list.value
- the value corresponding to the key.public boolean update(Properties properties)
public void clear()
public void setHeader(List<String> header)
header
- the header to usepublic void setFooter(List<String> footer)
footer
- the footer to useprotected void loadLayout(Reader in, boolean maybeTyped) throws IOException
in
- the reader to the properties fileIOException
- if an error occurspublic void substitute()
public void substitute(InterpolationHelper.SubstitutionCallback callback)
protected void saveLayout(Writer out, boolean typed) throws IOException
out
- the writerIOException
- if an error occursprotected static String unescapeJava(String str)
Unescapes any Java literals found in the String
to a
Writer
.
str
- the String
to unescape, may be nullIllegalArgumentException
- if the Writer is null
protected static String escapeJava(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 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 objectCopyright © 2006–2022 The Apache Software Foundation. All rights reserved.