public class Properties extends ObservableMap<String,List<String>> implements Serializable
This class is a enhanced version of Properties
that enforces the use of String keys and values internally, but offers many
convenience methods for storing and retrieving multiple values of different
types (e.g. Integer, Locale, File, etc). It also supports properties with
multiple values. You can also see this class as a
string-based multi-value map with helpful methods. While it does not extend
Properties
, it offers similar load and store
methods and can be used as a replacement for it in many cases. It also
adds support for storing/loading as JSON, XML, and Java Bean.
This class extends ObservableMap
which means you can listen
for property changes.
To insert values, there are set and add methods.
The set methods will first remove any existing value(s) under the
given key before inserting the new one(s).
It is essentially the same behavior as
Map.put(Object, Object)
. The add method will add the
new value(s) to the list of already existing ones (if any).
The storing of entries with multiple values will create one file entry per value. To preserve old behavior and force multiple values to be on the same line, use the store/load method accepting a joining delimiter.
Upon encountering a problem in parsing a value to
its desired type, a PropertiesException
is thrown.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_JAVA_PROPERTIES_DELIMITER |
Constructor and Description |
---|
Properties()
Create a new instance with case-sensitive keys.
|
Properties(boolean caseInsensitiveKeys)
Creates a new instance.
|
Properties(Map<String,List<String>> map)
Decorates
Map as a Properties . |
Properties(Map<String,List<String>> map,
boolean caseInsensitiveKeys)
Decorates a
Map argument as a Properties . |
Modifier and Type | Method and Description |
---|---|
<T> void |
add(String key,
T... values)
Adds one or multiple string values.
|
void |
addBigDecimal(String key,
BigDecimal... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addBoolean(String key,
boolean... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addClass(String key,
Class<?>... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addDate(String key,
Date... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addDouble(String key,
double... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addFile(String key,
File... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addFloat(String key,
float... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addInt(String key,
int... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
<T> void |
addList(String key,
List<T> values)
Adds one or multiple values as strings.
|
void |
addLocale(String key,
Locale... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addLong(String key,
long... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
void |
addString(String key,
String... values)
Deprecated.
Since 2.0.0, use
add(String, Object...) |
boolean |
equals(Object other) |
void |
fromString(String str)
Reads a property list (key and element pairs) from the input
string.
|
List<String> |
get(Object key) |
<T> T |
get(String key,
Class<T> type)
Gets a single value, converted to the given type.
|
<T> T |
get(String key,
Class<T> type,
T defaultValue)
Gets a single value, converted to the given type.
|
BigDecimal |
getBigDecimal(String key)
Gets value as a BigDecimal.
|
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
Gets value as a BigDecimal.
|
List<BigDecimal> |
getBigDecimals(String key)
Gets values as a list of BigDecimals.
|
Boolean |
getBoolean(String key)
Gets value as a boolean.
|
Boolean |
getBoolean(String key,
Boolean defaultValue)
Gets value as a boolean.
|
List<Boolean> |
getBooleans(String key)
Gets values as a list of booleans.
|
Class<?> |
getClass(String key)
Gets a class, assuming key value is a fully qualified class name
available in the classloader.
|
Class<?> |
getClass(String key,
Class<?> defaultValue)
Gets a class, assuming key value is a fully qualified class name
available in the classloader.
|
List<Class> |
getClasses(String key)
Gets values as a list of initialized classes.
|
Date |
getDate(String key)
Gets value as a date.
|
Date |
getDate(String key,
Date defaultValue)
Gets value as a date.
|
List<Date> |
getDates(String key)
Gets values as a list of dates.
|
Double |
getDouble(String key)
Gets value as a double.
|
Double |
getDouble(String key,
Double defaultValue)
Gets value as a double.
|
List<Double> |
getDoubles(String key)
Gets values as a list of doubles.
|
File |
getFile(String key)
Gets a file, assuming key value is a file system path.
|
File |
getFile(String key,
File defaultValue)
Gets a file, assuming key value is a file system path.
|
List<File> |
getFiles(String key)
Gets values as a list of files.
|
Float |
getFloat(String key)
Gets value as a float.
|
Float |
getFloat(String key,
Float defaultValue)
Gets value as a float.
|
List<Float> |
getFloats(String key)
Gets values as a list of floats.
|
Instant |
getInstant(String key)
Gets value as a UTC date-time
Instant . |
Instant |
getInstant(String key,
Instant defaultValue)
Gets value as a UTC date-time
Instant . |
List<Instant> |
getInstants(String key)
Gets values as a list of UTC date-time
Instant s. |
Integer |
getInteger(String key)
Gets value as an integer.
|
Integer |
getInteger(String key,
Integer defaultValue)
Gets value as an integer.
|
List<Integer> |
getIntegers(String key)
Gets values as a list of integers.
|
<T> List<T> |
getList(String key,
Class<T> type)
Gets a list of values, with its elements converted to the given type.
|
<T> List<T> |
getList(String key,
Class<T> type,
List<T> defaultValues)
Gets a list of values, with its elements converted to the given type.
|
LocalDateTime |
getLocalDateTime(String key)
Gets value as a local date-time.
|
LocalDateTime |
getLocalDateTime(String key,
LocalDateTime defaultValue)
Gets value as a local date-time.
|
List<LocalDateTime> |
getLocalDateTimes(String key)
Gets values as a list of local date-times.
|
Locale |
getLocale(String key)
Gets value as a locale.
|
Locale |
getLocale(String key,
Locale defaultValue)
Gets value as a locale.
|
List<Locale> |
getLocales(String key)
Gets values as a list of locales.
|
Long |
getLong(String key)
Gets value as a long.
|
Long |
getLong(String key,
Long defaultValue)
Gets value as a long.
|
List<Long> |
getLongs(String key)
Gets values as a list of longs.
|
String |
getString(String key)
Gets value as string.
|
String |
getString(String key,
String defaultValue)
Gets value as string.
|
List<String> |
getStrings(String key)
Gets values as a list of strings.
|
int |
hashCode() |
boolean |
isCaseInsensitiveKeys()
Gets whether keys are case sensitive or not.
|
void |
load(InputStream inStream)
Deprecated.
Since 2.0.0, use
loadFromProperties(...) |
void |
load(InputStream inStream,
String encoding)
Deprecated.
Since 2.0.0, use
loadFromProperties(...) |
void |
load(InputStream inStream,
String encoding,
String delimiter)
Deprecated.
Since 2.0.0, use
loadFromProperties(...) |
void |
load(Reader reader)
Deprecated.
Since 2.0.0, use
loadFromProperties(...) |
void |
load(Reader reader,
String delimiter)
Deprecated.
Since 2.0.0, use
loadFromProperties(...) |
void |
loadFromBean(Object bean)
Converts all the bean properties into entries in this instance.
|
void |
loadFromJSON(InputStream in)
Loads all of the properties from the JSON document input stream
(UTF-8) into this instance.
|
void |
loadFromJSON(Reader reader)
Loads all of the properties from the JSON document reader
into this instance.
|
void |
loadFromMap(Map<?,?> map)
Reads all key/value pairs in the given map, and
add them to this
Map . |
void |
loadFromProperties(InputStream inStream)
Loads this
Map from an input of a format
compatible with Properties.load(InputStream) . |
void |
loadFromProperties(InputStream inStream,
String delimiter)
Loads this
Map from an input of a format
compatible with Properties.load(InputStream) . |
void |
loadFromProperties(Reader reader)
Loads this
Map from an input of a format
compatible with Properties.load(Reader) . |
void |
loadFromProperties(Reader reader,
String delimiter)
Loads this
Map from an input of a format
compatible with Properties.load(Reader) . |
void |
loadFromXML(InputStream in)
Loads this
Map from an input of a format
compatible with Properties.loadFromXML(InputStream) . |
void |
loadFromXML(InputStream in,
String delimiter)
Loads this
Map from an input of a format
compatible with Properties.load(InputStream) . |
void |
loadFromXML(Reader reader)
Loads this
Map from an input of a format
compatible with Properties.loadFromXML(InputStream) . |
void |
loadFromXML(Reader reader,
String delimiter)
Loads this
Map from an input of a format
compatible with Properties.load(InputStream) . |
Properties |
match(PropertyMatcher propertyMatcher)
Gets a properties subset for keys and values matched by the property
matcher.
|
Properties |
match(TextMatcher fieldMatcher,
TextMatcher valueMatcher)
Gets a properties subset for matching keys and values.
|
Properties |
matchKeys(TextMatcher keyMatcher)
Gets a properties subset for keys matched by the key matcher.
|
Properties |
matchValues(TextMatcher valueMatcher)
Gets a properties subset for values matched by the value matcher.
|
List<String> |
put(String key,
List<String> values) |
void |
putAll(Map<? extends String,? extends List<String>> m) |
List<String> |
remove(Object key) |
<T> void |
set(String key,
T... values)
Sets one or multiple values as strings replacing existing ones.
|
void |
setBigDecimal(String key,
BigDecimal... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setBoolean(String key,
boolean... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setClass(String key,
Class<?>... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setDate(String key,
Date... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setDouble(String key,
double... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setFile(String key,
File... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setFloat(String key,
float... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setInt(String key,
int... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
<T> void |
setList(String key,
List<T> values)
Sets one or multiple values as strings replacing existing ones.
|
void |
setLocale(String key,
Locale... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setLong(String key,
long... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
setString(String key,
String... values)
Deprecated.
Since 2.0.0, use
set(String, Object...) |
void |
store(OutputStream out)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
store(OutputStream out,
String comments)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
store(OutputStream out,
String comments,
String delimiter)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
store(Writer writer)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
store(Writer writer,
String comments)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
store(Writer writer,
String comments,
String delimiter)
Deprecated.
Since 2.0.0, use
storeToProperties(...) |
void |
storeToBean(Object bean)
Copy all properties in this map to the given bean, mapping keys
to setter methods of the same name.
|
void |
storeToJSON(OutputStream os)
Writes this
Map as JSON to the output stream as UTF-8 in a format
suitable for using the loadFromJSON(InputStream) method. |
void |
storeToJSON(Writer writer)
Writes this
Map as JSON to the writer in a format
suitable for using the
loadFromJSON(Reader) method. |
void |
storeToProperties(OutputStream out)
Stores this
Map in a format
compatible with Properties.store(OutputStream, String) . |
void |
storeToProperties(OutputStream out,
String delimiter)
Stores this
Map in a format
compatible with Properties.store(OutputStream, String) . |
void |
storeToProperties(Writer writer)
Stores this
Map in a format
compatible with Properties.store(Writer, String) . |
void |
storeToProperties(Writer writer,
String delimiter)
Stores this
Map in a format
compatible with Properties.store(Writer, String) . |
void |
storeToXML(OutputStream os)
Stores this
Map in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String) . |
void |
storeToXML(OutputStream os,
String delimiter)
Stores this
Map in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String) . |
void |
storeToXML(Writer writer)
Stores this
Map in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String) . |
void |
storeToXML(Writer writer,
String delimiter)
Stores this
Map in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String) . |
Properties |
toProperties()
Converts this
Map to a new Java Properties
instance. |
String |
toString()
Returns this
Map in a format
compatible with Properties.store(Writer, String) . |
List<String> |
valueList()
Returns all property values merged into a single list.
|
addMapChangeListener, clear, containsKey, containsValue, entrySet, isEmpty, keySet, removeMapChangeListener, size, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static final String DEFAULT_JAVA_PROPERTIES_DELIMITER
public Properties()
HashMap
to store keys and values.public Properties(boolean caseInsensitiveKeys)
HashMap
to
store keys and values.caseInsensitiveKeys
- when true
methods taking a
key argument will consider the key being passed without
consideration for character case.public Properties(Map<String,List<String>> map)
Map
as a Properties
.
As of version 1.4 the Map
argument is decorated so that
modifications to this instance will also modify the supplied Map
.
To use a Map
to initialize values only, use the
loadFromMap(Map)
method.map
- the Map to decoratepublic Properties(Map<String,List<String>> map, boolean caseInsensitiveKeys)
Map
argument as a Properties
.
As of version 1.4 the Map
argument is decorated so that
modifications to this instance will also modify the supplied Map
.
To use a Map
to initialize values only, use the
loadFromMap(Map)
method.map
- the Map to decoratecaseInsensitiveKeys
- when true
methods taking a
key argument will consider the key being passed without
consideration for character case.public boolean isCaseInsensitiveKeys()
true
if case insensitivepublic Properties matchKeys(TextMatcher keyMatcher)
keyMatcher
- keys to matchnull
)public Properties matchValues(TextMatcher valueMatcher)
valueMatcher
- values to matchnull
)public Properties match(PropertyMatcher propertyMatcher)
match(TextMatcher, TextMatcher)
.propertyMatcher
- property matchernull
)public Properties match(TextMatcher fieldMatcher, TextMatcher valueMatcher)
match(PropertyMatcher)
.fieldMatcher
- property matchervalueMatcher
- property valuenull
)public String toString()
Map
in a format
compatible with Properties.store(Writer, String)
.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).toString
in class ObservableMap<String,List<String>>
public void storeToProperties(Writer writer) throws IOException
Map
in a format
compatible with Properties.store(Writer, String)
.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).writer
- an output character stream writer.IOException
- i/o problempublic void storeToProperties(Writer writer, String delimiter) throws IOException
Map
in a format
compatible with Properties.store(Writer, String)
.
Multi-value properties
are merged, joined by the supplied delimiter character.
If the delimiter is null
, the
symbol for record separator (U+241E) is used.writer
- an output character stream writer.delimiter
- string to used as a separator when joining
multiple values for the same key.IOException
- i/o problempublic void storeToProperties(OutputStream out) throws IOException
Map
in a format
compatible with Properties.store(OutputStream, String)
.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).out
- an output stream.IOException
- i/o problempublic void storeToProperties(OutputStream out, String delimiter) throws IOException
Map
in a format
compatible with Properties.store(OutputStream, String)
.
Multi-value properties
are merged, joined by the supplied delimiter character.
If the delimiter is null
, the
symbol for record separator (U+241E) is used.out
- an output stream.delimiter
- delimiter string to used as a separator when joining
multiple values for the same key.IOException
- i/o problempublic void storeToXML(OutputStream os) throws IOException
Map
in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String)
.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).os
- the output stream on which to store the XML document.IOException
- i/o problempublic void storeToXML(OutputStream os, String delimiter) throws IOException
Map
in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String)
.
Multi-value properties
are merged, joined by the supplied delimiter character.
If the delimiter is null
, the
symbol for record separator (U+241E) is used.os
- the output stream on which to store the XML document.delimiter
- delimiter string to used as a separator when joining
multiple values for the same key.IOException
- i/o problempublic void storeToXML(Writer writer) throws IOException
Map
in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String)
.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).writer
- writer on which to store the XML document.IOException
- i/o problempublic void storeToXML(Writer writer, String delimiter) throws IOException
Map
in a UTF-8 format compatible with
Properties.storeToXML(OutputStream, String)
.
Multi-value properties
are merged, joined by the supplied delimiter character.
If the delimiter is null
, the
symbol for record separator (U+241E) is used.writer
- the writer on which to store the XML document.delimiter
- delimiter string to used as a separator when joining
multiple values for the same key.IOException
- i/o problempublic void storeToJSON(OutputStream os) throws IOException
Map
as JSON to the output stream as UTF-8 in a format
suitable for using the loadFromJSON(InputStream)
method.os
- the output stream on which to store the properties.IOException
- i/o problempublic void storeToJSON(Writer writer) throws IOException
Map
as JSON to the writer in a format
suitable for using the
loadFromJSON(Reader)
method.writer
- the writer on which to store the XML document.IOException
- i/o problempublic void storeToBean(Object bean)
null
beans are ignored.bean
- the object to store properties intopublic void fromString(String str)
loadFromProperties(InputStream)
apply.str
- the string to loadpublic Properties toProperties()
Map
to a new Java Properties
instance.
Multi-value properties
are merged, joined by the symbol for record separator (U+241E).java.util.Properties
instanceloadFromMap(Map)
public void loadFromMap(Map<?,?> map)
Reads all key/value pairs in the given map, and
add them to this Map
. Keys and values are converted to
strings using their toString() method, with exception
of values being arrays or collections. In such case, the entry
is considered a multi-value one and each value will be converted
to individual strings. null
keys are ignored.
null
values are converted to an empty string.
Changes to this instance
won't be reflected in the given Map
. If you want otherwise,
use invoke the constructor with a Map
argument.
You can use this method to populate this Map
from a Properties
.
map
- the map containing values to loadpublic void loadFromProperties(Reader reader) throws IOException
Map
from an input of a format
compatible with Properties.load(Reader)
.
Multi-value properties
are split using the symbol for record separator (U+241E).reader
- the input character stream.IOException
- i/o problempublic void loadFromProperties(Reader reader, String delimiter) throws IOException
Map
from an input of a format
compatible with Properties.load(Reader)
.
Multi-value properties
are split using the supplied delimiter string.
If the delimiter is null
, the symbol for record separator
(U+241E) is used.reader
- the input character stream.delimiter
- delimiter string to used to parse a multi-value key.IOException
- i/o problempublic void loadFromProperties(InputStream inStream) throws IOException
Map
from an input of a format
compatible with Properties.load(InputStream)
.
Multi-value properties
are split using the symbol for record separator (U+241E).inStream
- the input stream.IOException
- i/o problempublic void loadFromProperties(InputStream inStream, String delimiter) throws IOException
Map
from an input of a format
compatible with Properties.load(InputStream)
.
Multi-value properties
are split using the supplied delimiter string.
If the delimiter is null
, the symbol for record separator
(U+241E) is used.inStream
- the input stream.delimiter
- delimiter string to used to parse a multi value
key.IOException
- i/o problempublic void loadFromXML(InputStream in) throws IOException
Map
from an input of a format
compatible with Properties.loadFromXML(InputStream)
.
Multi-value properties
are split using the symbol for record separator (U+241E).in
- in the input stream from which to read the XML document.IOException
- i/o problempublic void loadFromXML(InputStream in, String delimiter) throws IOException
Map
from an input of a format
compatible with Properties.load(InputStream)
.
Multi-value properties
are split using the supplied delimiter string.
If the delimiter is null
, the symbol for record separator
(U+241E) is used.in
- in the input stream from which to read the XML document.delimiter
- delimiter string to used to parse a multi-value key.IOException
- i/o problempublic void loadFromXML(Reader reader) throws IOException
Map
from an input of a format
compatible with Properties.loadFromXML(InputStream)
.
Multi-value properties
are split using the symbol for record separator (U+241E).reader
- the reader from which to read the XML document.IOException
- i/o problempublic void loadFromXML(Reader reader, String delimiter) throws IOException
Map
from an input of a format
compatible with Properties.load(InputStream)
.
Multi-value properties
are split using the supplied delimiter string.
If the delimiter is null
, the symbol for record separator
(U+241E) is used.reader
- reader from which to read the XML document.delimiter
- delimiter string to used to parse a multi-value key.IOException
- i/o problempublic void loadFromJSON(InputStream in) throws IOException
in
- the input stream from which to read the JSON document.IOException
- i/o problempublic void loadFromJSON(Reader reader) throws IOException
reader
- the reader from which to read the JSON document.IOException
- i/o problempublic void loadFromBean(Object bean)
null
beans are ignored.bean
- the object to load properties frompublic final <T> T get(String key, Class<T> type)
T
- returned value typekey
- the key of the value to gettype
- target class of valuepublic final <T> T get(String key, Class<T> type, T defaultValue)
T
- returned value typekey
- the key of the value to gettype
- target class of valuedefaultValue
- default value if key has no value.public final <T> List<T> getList(String key, Class<T> type)
T
- returned list typekey
- the key of the values to gettype
- target class of valuespublic final <T> List<T> getList(String key, Class<T> type, List<T> defaultValues)
T
- returned list typekey
- the key of the values to gettype
- target class of valuesdefaultValues
- default values if the key returns
null
or an empty list@SafeVarargs public final <T> void set(String key, T... values)
null
value or an empty array is
the same as calling remove(Object)
with the same key.
When setting multiple values, null
values are converted
to empty strings.T
- values typekey
- the key of the value to setvalues
- the values to set@SafeVarargs public final <T> void add(String key, T... values)
null
value has no effect.
When adding multiple values, null
values are converted
to blank strings.T
- values typekey
- the key of the value to setvalues
- the values to setpublic final <T> void setList(String key, List<T> values)
null
value or an empty array is
the same as calling remove(Object)
with the same key.
When setting multiple values, null
values are converted
to empty strings.T
- values typekey
- the key of the value to setvalues
- the values to setpublic final <T> void addList(String key, List<T> values)
null
list has no effect.
When adding multiple values, null
values are converted
to empty strings.T
- values typekey
- the key of the value to setvalues
- the values to setpublic final String getString(String key)
key
- property keypublic final String getString(String key, String defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<String> getStrings(String key)
key
- property key@Deprecated public final void setString(String key, String... values)
set(String, Object...)
null
value or an empty string array is
the same as calling remove(Object)
with the same key.
When setting multiple values, null
values are converted
to blank strings.key
- the key of the value to setvalues
- the values to set@Deprecated public final void addString(String key, String... values)
add(String, Object...)
null
value has no effect.
When adding multiple values, null
values are converted
to blank strings.key
- the key of the value to setvalues
- the values to setpublic final Integer getInteger(String key)
key
- property keypublic final Integer getInteger(String key, Integer defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Integer> getIntegers(String key)
key
- property key@Deprecated public final void setInt(String key, int... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addInt(String key, int... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Double getDouble(String key)
key
- property keypublic final Double getDouble(String key, Double defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Double> getDoubles(String key)
key
- property key@Deprecated public final void setDouble(String key, double... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addDouble(String key, double... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Long getLong(String key)
key
- property keypublic final Long getLong(String key, Long defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Long> getLongs(String key)
key
- property key@Deprecated public final void setLong(String key, long... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addLong(String key, long... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Float getFloat(String key)
key
- property keypublic final Float getFloat(String key, Float defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Float> getFloats(String key)
key
- property key@Deprecated public final void setFloat(String key, float... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addFloat(String key, float... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final BigDecimal getBigDecimal(String key)
key
- property keypublic final BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<BigDecimal> getBigDecimals(String key)
key
- property key@Deprecated public final void setBigDecimal(String key, BigDecimal... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addBigDecimal(String key, BigDecimal... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final LocalDateTime getLocalDateTime(String key)
DateTimeFormatter.ISO_LOCAL_DATE_TIME
.key
- property keypublic final LocalDateTime getLocalDateTime(String key, LocalDateTime defaultValue)
DateTimeFormatter.ISO_LOCAL_DATE_TIME
.key
- property keydefaultValue
- default value to return when original value is null.public final List<LocalDateTime> getLocalDateTimes(String key)
DateTimeFormatter.ISO_LOCAL_DATE_TIME
.key
- property keypublic final Instant getInstant(String key)
Instant
.
The date must be a valid date-time
as defined by DateTimeFormatter.ISO_INSTANT
.key
- property keypublic final Instant getInstant(String key, Instant defaultValue)
Instant
.
The date must be a valid date-time
as defined by DateTimeFormatter.ISO_INSTANT
.key
- property keydefaultValue
- default value to return when original value is null.public final List<Instant> getInstants(String key)
Instant
s.
Each date must be a valid
date-time as defined by DateTimeFormatter.ISO_INSTANT
.key
- property keypublic final Date getDate(String key)
key
- property keypublic final Date getDate(String key, Date defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Date> getDates(String key)
key
- property key@Deprecated public final void setDate(String key, Date... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addDate(String key, Date... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Boolean getBoolean(String key)
true
. Any other value (including null
)
will return false
.key
- property keypublic final Boolean getBoolean(String key, Boolean defaultValue)
true
. Any other value (including null
)
will return false
. If there are no entries for the given
key, the default value is returned instead.key
- property keydefaultValue
- default value to return when original value is null.public final List<Boolean> getBooleans(String key)
key
- property key@Deprecated public final void setBoolean(String key, boolean... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addBoolean(String key, boolean... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Locale getLocale(String key)
key
- property keypublic final Locale getLocale(String key, Locale defaultValue)
key
- property keydefaultValue
- default value to return when original value is null.public final List<Locale> getLocales(String key)
key
- property key@Deprecated public final void setLocale(String key, Locale... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addLocale(String key, Locale... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final File getFile(String key)
key
- properties keypublic final File getFile(String key, File defaultValue)
key
- properties keydefaultValue
- default file being returned if no file has been
defined for the given key in the properties.public final List<File> getFiles(String key)
key
- property key@Deprecated public final void setFile(String key, File... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addFile(String key, File... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic final Class<?> getClass(String key)
key
- properties keypublic final Class<?> getClass(String key, Class<?> defaultValue)
key
- properties keydefaultValue
- default file being returned if no class has been
defined for the given key in the properties.public final List<Class> getClasses(String key)
key
- property key@Deprecated public final void setClass(String key, Class<?>... values)
set(String, Object...)
key
- the key of the values to setvalues
- the values to set@Deprecated public final void addClass(String key, Class<?>... values)
add(String, Object...)
key
- the key of the values to setvalues
- the values to setpublic List<String> valueList()
null
)@Deprecated public void load(Reader reader) throws IOException
loadFromProperties(...)
reader
- the input character stream.IOException
- i/o problem@Deprecated public void load(Reader reader, String delimiter) throws IOException
loadFromProperties(...)
reader
- the input character stream.delimiter
- delimiter string to used to parse a multi-value key.IOException
- i/o problemload(Reader)
@Deprecated public void load(InputStream inStream) throws IOException
loadFromProperties(...)
inStream
- the input stream.IOException
- i/o problemload(InputStream)
@Deprecated public void load(InputStream inStream, String encoding) throws IOException
loadFromProperties(...)
inStream
- the input stream.encoding
- delimiter string to used to parse a multi-value key.IOException
- i/o problemload(InputStream)
@Deprecated public void load(InputStream inStream, String encoding, String delimiter) throws IOException
loadFromProperties(...)
inStream
- the input stream.encoding
- delimiter string to used to parse a multi-value key.delimiter
- delimiter string to used to parse a multi value
key.IOException
- i/o problem@Deprecated public void store(Writer writer) throws IOException
storeToProperties(...)
writer
- an output character stream writer.IOException
- i/o problem@Deprecated public void store(Writer writer, String comments) throws IOException
storeToProperties(...)
writer
- an output character stream writer.comments
- a description of the property list.IOException
- i/o problem@Deprecated public void store(Writer writer, String comments, String delimiter) throws IOException
storeToProperties(...)
writer
- an output character stream writer.comments
- a description of the property list.delimiter
- string to used as a separator when joining
multiple values for the same key.IOException
- i/o problem@Deprecated public void store(OutputStream out) throws IOException
storeToProperties(...)
out
- an output stream.IOException
- i/o problem@Deprecated public void store(OutputStream out, String comments) throws IOException
storeToProperties(...)
out
- an output stream.comments
- a description of the property list.IOException
- i/o problem@Deprecated public void store(OutputStream out, String comments, String delimiter) throws IOException
storeToProperties(...)
out
- an output stream.comments
- a description of the property list.delimiter
- delimiter string to used as a separator when joining
multiple values for the same key.IOException
- i/o problempublic boolean equals(Object other)
Copyright © 2008–2023 Norconex Inc.. All rights reserved.