|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectasia.redact.bracket.properties.AbstractPropertiesBase
asia.redact.bracket.properties.PropertiesImpl
public class PropertiesImpl
A better Properties class. This implementation class is thread-safe.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface asia.redact.bracket.properties.Properties |
|---|
Properties.Factory, Properties.Mode |
| Field Summary | |
|---|---|
protected Pattern |
dotIdentifierPattern
|
protected Pattern |
dotIntegerPattern
|
protected Pattern |
dotKeyValuePattern
|
| Fields inherited from class asia.redact.bracket.properties.AbstractPropertiesBase |
|---|
contentType, lock, map |
| Constructor Summary | |
|---|---|
PropertiesImpl()
|
|
PropertiesImpl(InputStream in)
|
|
PropertiesImpl(InputStream in,
Charset charset)
|
|
PropertiesImpl(Properties legacy)
TODO - implement compatibility mode Some slight information loss here is unavoidable. |
|
PropertiesImpl(Reader in)
|
|
PropertiesImpl(URL url)
|
|
| Method Summary | |
|---|---|
Object |
beanValue(Class<?> clazz,
String keyBase)
|
BigDecimal |
bigDecimalValue(String key)
|
BigInteger |
bigValue(String key)
|
BitSet |
bitsetValue(String key)
|
Date |
dateValue(String key)
Date value here is assumed to be a long |
Date |
dateValue(String key,
String format)
I should really deprecate this - you should really use long values as dates in a serialization. |
boolean |
equals(Object obj)
|
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 |
Properties |
getGroup(GroupParams params)
|
List<String> |
getKeyGroup(String keyBase)
|
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 |
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 |
hasValue(String key)
Returns true if the key exists and has a non-empty value |
protected void |
initMap()
|
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)
This is a merge function, existing keys which do not collide with the incoming are kept, keys that collide are overwritten with the new values TODO, cause comments to come over as well |
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()
Not easily reversable, use with care |
void |
put(String key,
String... values)
yes, multivalued (multilined) properties are in the spec. |
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 |
synchronize(Node rootNode)
Cause a graph to become the contents of the properties file. |
| Methods inherited from class asia.redact.bracket.properties.AbstractPropertiesBase |
|---|
clear, containsKey, containsValue, getContentType, isEmpty, keySet, remove, setContentType, size, toString, values |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface asia.redact.bracket.properties.Properties |
|---|
clear, containsKey, getContentType, setContentType, size |
| Field Detail |
|---|
protected Pattern dotIntegerPattern
protected Pattern dotIdentifierPattern
protected Pattern dotKeyValuePattern
| Constructor Detail |
|---|
public PropertiesImpl()
public PropertiesImpl(Properties legacy)
TODO - implement compatibility mode 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(URL url)
public PropertiesImpl(InputStream in)
public PropertiesImpl(InputStream in,
Charset charset)
public PropertiesImpl(Reader in)
| Method Detail |
|---|
protected void initMap()
public String get(String key)
get in interface Propertieskey -
RuntimeException - if key is not present.
public void put(String key,
String... values)
put in interface Propertieskey - values - public Map<String,ValueModel> getPropertyMap()
Properties
getPropertyMap in interface Propertiespublic List<String> getComments(String key)
Properties
getComments in interface Propertiespublic char getSeparator(String key)
Properties
getSeparator in interface Propertiespublic List<String> getKeyGroup(String keyBase)
public int hashCode()
hashCode in class AbstractPropertiesBasepublic boolean equals(Object obj)
equals in class AbstractPropertiesBasepublic Properties merge(Properties props)
merge in interface Propertiesprops -
public Properties merge(Properties props,
boolean mergeComments)
Properties
merge 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 int intValue(String key)
Properties
intValue in interface Propertiespublic long longValue(String key)
Properties
longValue in interface Propertiespublic Date dateValue(String key)
Properties
dateValue in interface Properties
public Date dateValue(String key,
String format)
throws ParseException
dateValue in interface PropertiesParseExceptionpublic boolean hasValue(String key)
Properties
hasValue in interface Propertiespublic void synchronize(Node rootNode)
Properties
synchronize in interface Propertiespublic void mergeIntoSystemProperties()
mergeIntoSystemProperties in interface Propertiespublic List<String> getMapKeys(String keyBase)
Properties
getMapKeys in interface Propertiespublic List<String> getListKeys(String keyBase)
Properties
getListKeys 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 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)
listValue in interface Properties
public List<String> listValue(String key,
String delimiter)
listValue in interface Propertiespublic BitSet bitsetValue(String key)
bitsetValue in interface Propertiespublic BigInteger bigValue(String key)
bigValue in interface Propertiespublic BigDecimal bigDecimalValue(String key)
bigDecimalValue in interface Properties
public Object beanValue(Class<?> clazz,
String keyBase)
beanValue in interface Properties
public 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 Properties
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||