asia.redact.bracket.properties
Interface Properties

All Known Implementing Classes:
PropertiesImpl, SortedPropertiesImpl

public interface Properties

 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.
 
 

Author:
Dave

Nested Class Summary
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.
 
Method Summary
 Object beanValue(Class<?> clazz, String keyBase)
           
 BigDecimal bigDecimalValue(String key)
           
 BigInteger bigValue(String key)
           
 BitSet bitsetValue(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.
 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
 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 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, String... values)
          Add the key and value or values.
 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.
 

Method Detail

getPropertyMap

Map<String,ValueModel> getPropertyMap()
Can be used to get direct access to the Entry data structures

Returns:

get

String get(String key)
Get the value.

Parameters:
key -
Returns:

intValue

int intValue(String key)
Coerce to an integer value. Obviously this works better if the value is actually an integer.

Parameters:
key -
Returns:

longValue

long longValue(String key)
Coerce to a long value. Obviously this works better if the value is actually a long.

Parameters:
key -
Returns:

dateValue

Date dateValue(String key)
Date value here is assumed to be a long

Parameters:
key -
Returns:

dateValue

Date dateValue(String key,
               String format)
               throws ParseException
Just syntactical sugar to use a SimpleDateFormat

Parameters:
key -
format -
Returns:
Throws:
ParseException

listValue

List<String> listValue(String key)

listValue

List<String> listValue(String key,
                       String delimiter)

bitsetValue

BitSet bitsetValue(String key)

bigValue

BigInteger bigValue(String key)

bigDecimalValue

BigDecimal bigDecimalValue(String key)

beanValue

Object beanValue(Class<?> clazz,
                 String keyBase)

getTree

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
  

Returns:

getTree

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
 


getComments

List<String> getComments(String key)
Get the list of comments, return an empty list if none

Parameters:
key -
Returns:

getSeparator

char getSeparator(String key)
The char found in the parse, normally '='

Parameters:
key -
Returns:

put

void put(String key,
         String... values)
Add the key and value or values. Useful with multi-line entries

Parameters:
key -
values -

size

int size()
Number of entries in the underlying map

Returns:

clear

void clear()
remove all entries from the underlying map


containsKey

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
 
 

Parameters:
key -
Returns:

hasValue

boolean hasValue(String key)
Returns true if the key exists and has a non-empty value

Parameters:
key -
Returns:

merge

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

Parameters:
props -
Returns:
the merged properties

merge

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

Parameters:
props -
Returns:
the merged properties

synchronize

void synchronize(Node rootNode)
Cause a graph to become the contents of the properties file. Destructive to current entries, so this is not very useful yet

Parameters:
rootNode -

getContentType

ContentType getContentType()
Explicit content type and charset support

Returns:

setContentType

void setContentType(ContentType contentType)

mergeIntoSystemProperties

void mergeIntoSystemProperties()
Convenience method. Put all of these properties into the System properties using System.setProperty() call on each one Not easily reversible, use with great care


getList

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
  
  

Parameters:
key -
Returns:

putList

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).
 
 

Parameters:
list -
rootKey -

getListKeys

List<String> getListKeys(String keyBase)
Return keys which match the pattern keyBase.0, keyBase.1, keyBase.2, etc. The list returned is in natural sorted order.

Parameters:
keyBase -
Returns:

getMapKeys

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



Copyright © 2011-2013 David R. Smith. All Rights Reserved.