public interface Properties extends Serializable
In the java.util package, Properties is not an Interface. Bracket Properties has one, which allows (among other things) for both a standard and a sorted implementation. The standard implementation is backed by a LinkedHashMap, which keeps insertion order intact. This is a critical issue for non-trivial use of Properties files. This interface is also home to the static Factory, which is the supported way to instantiate a Bracket Properties object.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Properties.Factory
The default mode is the trivial memory mode, which is BasicToken.
|
static class |
Properties.Mode
Mode is the available combinations of lexer and parser
BasicToken - PropertiesLexer and PropertiesParser.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
beanValue(Class<?> clazz,
String keyBase) |
BigDecimal |
bigDecimalValue(String key) |
BigInteger |
bigValue(String key) |
BitSet |
bitsetValue(String key) |
boolean |
booleanValue(String key) |
void |
clear()
remove all entries from the underlying map
|
boolean |
containsKey(String key)
get(key) will throw a RuntimeException if the key does not
exist.
|
Properties |
convertToLegacyProperties()
Get java.util.Properties from ours
|
Date |
dateValue(String key)
Date value here is assumed to be a long
|
Date |
dateValue(String key,
String format)
Just syntactical sugar to use a SimpleDateFormat
|
String |
get(String key)
Get the value.
|
List<String> |
getComments(String key)
Get the list of comments, return an empty list if none
|
ContentType |
getContentType()
Explicit content type and charset support
|
Map<String,String> |
getFlattenedMap()
Just return Strings
|
List<String> |
getList(String key)
This method relies on the convention of using numbers at
the end of a property key to represent a list member.
|
List<String> |
getListKeys(String keyBase)
Return keys which match the pattern keyBase.0, keyBase.1, keyBase.2, etc.
|
List<String> |
getMapKeys(String keyBase)
Specialty method used with a map that has been serialized in the form keyBase dot integer dot k|v
For example,
0.0.k=a key
0.0.v=a value
|
Map<String,ValueModel> |
getPropertyMap()
Can be used to get direct access to the Entry data structures
|
char |
getSeparator(String key)
The char found in the parse, normally '='
|
Node |
getTree()
Get the properties as a tree of nodes.
|
Node |
getTree(GroupParams params)
Get the properties as a tree of nodes with a selector
a.b.c=something
a.b.c.d=something else
a.b.c.e.f=item
a.b.c.e=item2
|
boolean |
hasKeyLike(String partial)
Like containsKey but matching on the partial
|
boolean |
hasValue(String key)
Returns true if the key exists and has a non-empty value
|
int |
intValue(String key)
Coerce to an integer value.
|
List<String> |
listValue(String key) |
List<String> |
listValue(String key,
String delimiter) |
long |
longValue(String key)
Coerce to a long value.
|
Properties |
merge(Properties props)
Overwrite existing keys with the new ones, keep those existing ones that don't collide
This operation is non-destructive on the input
does not concatenate comments
|
Properties |
merge(Properties props,
boolean mergeComments)
Overwrite existing keys with the new ones, keep those existing ones that don't collide
This operation is non-destructive on the input
|
void |
mergeIntoSystemProperties()
Convenience method.
|
void |
put(String key,
BigDecimal bd) |
void |
put(String key,
BigInteger bi) |
void |
put(String key,
boolean val) |
void |
put(String key,
char val) |
void |
put(String key,
char separator,
Comment comment,
String... values) |
void |
put(String key,
Comment comment,
String... values) |
void |
put(String key,
double val) |
void |
put(String key,
float val) |
void |
put(String key,
int val) |
void |
put(String key,
List<String> list) |
void |
put(String key,
String... values)
Add the key and value or values.
|
void |
putList(List<String> list,
Comment comment,
String rootKey) |
void |
putList(List<String> list,
String rootKey)
create property keys and values based on a root key and a list in the form:
rootKey.0= list.get(0);
rootKey.1= list.get(1);
and so on.
|
void |
setContentType(ContentType contentType) |
int |
size()
Number of entries in the underlying map
|
void |
synchronize(Node rootNode)
Cause a graph to become the contents of the properties file.
|
Map<String,ValueModel> getPropertyMap()
int intValue(String key)
key - boolean booleanValue(String key)
long longValue(String key)
key - Date dateValue(String key)
key - Date dateValue(String key, String format) throws ParseException
key - format - ParseExceptionBigInteger bigValue(String key)
BigDecimal bigDecimalValue(String key)
Node getTree()
Get the properties as a tree of nodes. For example,
a.b.c=something
a.b.c.d=something else
looks like
a
b
c - something
d - something else
This method is identical in results to getTree(regex) where the regex
is "\\.". That is, the separator token in the key is a full stop
Obviously this works better if your keys are delimited by dot characters
Node getTree(GroupParams params)
Get the properties as a tree of nodes with a selector a.b.c=something a.b.c.d=something else a.b.c.e.f=item a.b.c.e=item2
List<String> getComments(String key)
key - char getSeparator(String key)
key - void put(String key, String... values)
key - values - void put(String key, int val)
void put(String key, float val)
void put(String key, double val)
void put(String key, boolean val)
void put(String key, char val)
void put(String key, BigInteger bi)
void put(String key, BigDecimal bd)
int size()
void clear()
boolean containsKey(String key)
get(key) will throw a RuntimeException if the key does not exist. This method can be used to test for a key prior to calling get(). Returns true if the underlying map has this key
key - boolean hasValue(String key)
key - Properties merge(Properties props)
props - Properties merge(Properties props, boolean mergeComments)
props - void synchronize(Node rootNode)
rootNode - ContentType getContentType()
void setContentType(ContentType contentType)
void mergeIntoSystemProperties()
List<String> getList(String key)
This method relies on the convention of using numbers at
the end of a property key to represent a list member. The total
list is the set of all similar keys with key as the base
and dot delimited integers at the end. Suppose the following
(from the Tanukisoft wrapper.conf):
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../lib/myapp.jar
wrapper.java.classpath.3=../lib/mysql.jar
wrapper.java.classpath.4=../classes
Then calling getList("wrapper.java.classpath") would
return all the values above, in numeric order, as a List.
If key does not exist but numbered properties exist, the
key is synthesized. if no numbered properties exist, an
empty list is returned. If the key does not exist and no numbered
keys exist, the method returns an empty list
Numbers need not be sequential
key - void putList(List<String> list, String rootKey)
create property keys and values based on a root key and a list in the form: rootKey.0= list.get(0); rootKey.1= list.get(1); and so on. This method is a complement to using getList(rootKey).
list - rootKey - List<String> getListKeys(String keyBase)
keyBase - List<String> getMapKeys(String keyBase)
boolean hasKeyLike(String partial)
partial - Properties convertToLegacyProperties()
Copyright © 2011-2014 David R. Smith. All Rights Reserved.