asia.redact.bracket.properties
Interface Properties

All Known Implementing Classes:
PropertiesImpl, ServerLocalizedProperties, SortedPropertiesImpl

public interface Properties

 In java, java.util.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.
 
 Properties is also the 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
 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
 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.
 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 put(String key, String... values)
          Add the key and value or values.
 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

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 -


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