public class PropertiesImpl extends AbstractMapDerivedPropertiesBase implements Properties
Properties.Factory, Properties.Mode| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID |
mapantStyleVarPattern, dotIdentifierPattern, dotIntegerPattern, dotKeyValuePattern, lock, REF_TOKEN| Constructor and Description |
|---|
PropertiesImpl() |
PropertiesImpl(InputStream in) |
PropertiesImpl(InputStream in,
Charset charset) |
PropertiesImpl(Map map) |
PropertiesImpl(Properties legacy)
Load from a legacy instance.
|
PropertiesImpl(Reader in) |
PropertiesImpl(URL url) |
| Modifier and Type | Method and Description |
|---|---|
Object |
beanValue(Class<?> clazz,
String keyBase)
Serialize an arbitrary object
|
BigDecimal |
bigDecimalValue(String key)
Serialized bigDecimal support
|
BigInteger |
bigValue(String key)
serialized BigInteger support
|
BitSet |
bitsetValue(String key)
Return the value as a BitSet.
|
boolean |
booleanValue(String key)
Works for "true/false", "enabled/disabled", "yes/no"
|
Properties |
convertToLegacyProperties()
Get java.util.Properties from ours
|
Date |
dateValue(String key)
The value is assumed to be a long integer
|
Date |
dateValue(String key,
String format)
I should really deprecate this - you should really use long values as dates in a serialization.
|
void |
delete(String key) |
void |
deobfuscate(String key)
Obverse of the above
|
char[] |
deobfuscateToChar(String key) |
boolean |
equals(Object obj) |
float |
floatValue(String key) |
String |
get(String key)
Get the value of the property; concatenate multiple lines.
|
List<String> |
getComments(String key)
Get the list of comments, return an empty list if none
|
Map<String,String> |
getFlattenedMap()
Just return Strings as the values
|
Properties |
getGroup(GroupParams params) |
List<String> |
getKeyGroup(String keyBase) |
String |
getKeyRef(String key) |
List<String> |
getList(String keyBase)
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
|
List<String> |
getMatchingKeys(String partial)
Return the keys which match the partial key submitted
|
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()
Use "\\." as the separator
|
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
|
int |
hashCode() |
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
|
protected void |
initMap() |
int |
intValue(String key)
Coerce the value to an integer.
|
List<String> |
listValue(String key)
Given a value of the form item1 item2 item3, return a List of those values
|
List<String> |
listValue(String key,
String delimiter)
Like the above but with a specified delimiter such as item1-item2-item3 where the delimiter is -
|
long |
longValue(String key)
Coerce to a long value.
|
Properties |
merge(Properties props)
This is a combine function, existing keys which do not collide
with the incoming are kept, keys that collide are overwritten
with the new values
|
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
|
Properties |
merge(Properties props,
boolean mergeComments,
boolean deobfuscate) |
void |
mergeIntoSystemProperties()
Caution
|
void |
obfuscate(String key)
Obfuscate the value so it is more difficult to read.
|
void |
put(Entry entry) |
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,
char separator,
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> values)
companion of the above.
|
void |
put(String key,
long val) |
void |
put(String key,
String... values)
Yes, multi-valued (multi-lined) properties are in the spec.
|
void |
putKeyRef(String newRefKey,
String existingKey) |
void |
putList(List<String> list,
char sep,
Comment comment,
String rootKey) |
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 |
putList(String key,
char ch,
List<String> list) |
String |
resolve(String key)
System properties and environment variable resolution.
|
Properties |
slice(String root)
Return a Properties object with only the set of keys which match the root.
|
atIndex, clear, containsKey, containsValue, isEmpty, keySet, remove, size, toString, valuesclone, finalize, getClass, notify, notifyAll, wait, wait, waitclear, containsKey, sizeprivate static final long serialVersionUID
public PropertiesImpl()
public PropertiesImpl(Properties legacy)
Load from a legacy instance. Some slight information loss here is unavoidable. For example if a colon is used as the separator in the original, that information will be lost. If you need a more exact translation you can do that with the lexer and parser classes by reading in the data directly from the properties file instead of reading in with java.util.Properties and then converting.
public PropertiesImpl(Map map)
public PropertiesImpl(URL url)
public PropertiesImpl(InputStream in)
public PropertiesImpl(InputStream in, Charset charset)
public PropertiesImpl(Reader in)
protected void initMap()
public String get(String key)
get in interface Propertieskey - RuntimeException - if key is not present.public void put(Entry entry)
put in interface Propertiespublic void put(String key, String... values)
put in interface Propertieskey - values - public void put(String key, List<String> values)
Propertiesput in interface Propertiespublic void put(String key, Comment comment, String... values)
put in interface Propertiespublic void put(String key, char separator, Comment comment, String... values)
put in interface Propertiespublic void put(String key, int val)
put in interface Propertiespublic void put(String key, BigInteger bi)
put in interface Propertiespublic void put(String key, BigDecimal bd)
put in interface Propertiespublic void put(String key, float val)
put in interface Propertiespublic void put(String key, long val)
put in interface Propertiespublic void put(String key, double val)
put in interface Propertiespublic void put(String key, boolean val)
put in interface Propertiespublic void put(String key, char val)
put in interface Propertiespublic Map<String,ValueModel> getPropertyMap()
PropertiesgetPropertyMap in interface Propertiespublic Map<String,String> getFlattenedMap()
PropertiesgetFlattenedMap in interface Propertiespublic List<String> getComments(String key)
PropertiesgetComments in interface Propertiespublic char getSeparator(String key)
PropertiesgetSeparator in interface Propertiespublic int hashCode()
hashCode in class AbstractMapDerivedPropertiesBasepublic boolean equals(Object obj)
equals in class AbstractMapDerivedPropertiesBasepublic Properties merge(Properties props)
merge in interface Propertiesprops - public Properties merge(Properties props, boolean mergeComments)
Propertiesmerge in interface Propertiespublic Properties merge(Properties props, boolean mergeComments, boolean deobfuscate)
merge in interface Propertiespublic void obfuscate(String key)
Propertiesobfuscate in interface Propertiespublic void deobfuscate(String key)
Propertiesdeobfuscate in interface Propertiespublic char[] deobfuscateToChar(String key)
deobfuscateToChar in interface Propertiespublic Node getTree()
getTree in interface Propertiespublic Node getTree(GroupParams params)
PropertiesGet 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
getTree in interface Propertiespublic Properties getGroup(GroupParams params)
public Properties slice(String root)
Propertiesslice in interface Propertiespublic List<String> getMatchingKeys(String partial)
partial - public boolean hasKeyLike(String partial)
PropertieshasKeyLike in interface Propertiespublic int intValue(String key)
PropertiesintValue in interface Propertiespublic boolean booleanValue(String key)
booleanValue in interface Propertiespublic long longValue(String key)
PropertieslongValue in interface Propertiespublic float floatValue(String key)
floatValue in interface Propertiespublic Date dateValue(String key)
dateValue in interface Propertiespublic Date dateValue(String key, String format) throws ParseException
dateValue in interface PropertiesParseExceptionpublic boolean hasValue(String key)
PropertieshasValue in interface Propertiespublic void mergeIntoSystemProperties()
mergeIntoSystemProperties in interface Propertiespublic List<String> getMapKeys(String keyBase)
PropertiesgetMapKeys in interface Propertiespublic List<String> getListKeys(String keyBase)
PropertiesgetListKeys in interface Propertiespublic List<String> getList(String keyBase)
Properties
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, e.g., 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
getList in interface Propertiespublic List<String> listValue(String key)
PropertieslistValue in interface Propertiespublic List<String> listValue(String key, String delimiter)
PropertieslistValue in interface Propertiespublic BitSet bitsetValue(String key)
PropertiesbitsetValue in interface Propertiespublic BigInteger bigValue(String key)
PropertiesbigValue in interface Propertiespublic BigDecimal bigDecimalValue(String key)
PropertiesbigDecimalValue in interface Propertiespublic Object beanValue(Class<?> clazz, String keyBase)
PropertiesbeanValue in interface Propertiespublic void putList(List<String> list, String rootKey)
Propertiescreate 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).
putList in interface Propertiespublic void putList(List<String> list, Comment comment, String rootKey)
putList in interface Propertiespublic Properties convertToLegacyProperties()
PropertiesconvertToLegacyProperties in interface Propertiespublic String resolve(String key)
Properties
System properties and environment variable resolution.
This uses the familiar "ant" style replacement expression ${name}
in the property value.
For example:
localpath=${PATH}
user.home=${user.home}
resolve in interface Propertiespublic void delete(String key)
delete in interface PropertiesCopyright © 2011–2016 David R. Smith. All rights reserved.