|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--java.util.Properties
|
+--org.omegahat.Environment.Utils.TrimmedProperties
This class extends the Properties class and differs only in that
the properties are loaded and trimmed in one step to remove
leading and trailing white space. This allows the application to
be more forgiving about the resource files we read and avoids
some annoying conditions when comparing strings.
Also, it can optionally remove the quotes around a phrase
which allows white space to be placed at the beginning
or end of an entry and escaped from the trimming procedure.
Suppliess a merge facility. The add() method is available from super class.
| Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
java.lang.String[][] |
booleanStrings
|
protected boolean |
stripQuotes
Flag indicating whether quotes are removed from the value of each property. |
| Fields inherited from class java.util.Properties |
defaults |
| Constructor Summary | |
TrimmedProperties()
Empty constructor to allocate the object |
|
TrimmedProperties(boolean quotes)
Sets the stripQuotes variable
to the specified value. |
|
TrimmedProperties(java.io.File file)
Create the properties table by reading the name-value pairs from a file |
|
TrimmedProperties(java.io.File file,
boolean quotes)
Specifies whether to strip quotes from the different values and then reads these name-value pairs from the contents of the specified file. |
|
TrimmedProperties(InputFileInt f)
|
|
TrimmedProperties(InputFileInt f,
boolean quotes)
|
|
TrimmedProperties(java.io.InputStream s)
|
|
TrimmedProperties(java.util.Properties props)
Create the trimmed properties from an existing properties object. |
|
TrimmedProperties(java.util.Properties props,
boolean quotes)
Create the trimmed properties from an existing properties object, stripping quotes as specfied by the value of quotes. |
|
TrimmedProperties(java.lang.String txt)
Creates the properties by parsing the supplied string as if it were the contents of a file. |
|
TrimmedProperties(java.lang.String txt,
boolean quotes)
Specifies whether to strip quotes from the different values and then reads these name-value pairs from the contents of the specified text. |
|
| Method Summary | |
boolean |
asBoolean(java.lang.String val)
|
boolean |
isBoolean(java.lang.String v)
|
void |
load(java.io.File file)
|
void |
load(java.io.InputStream in)
|
int |
merge(java.util.Properties alt)
Merge the entries in the specified table with this one, skipping entries already in this table. |
int |
merge(java.util.Properties alt,
boolean override)
Merge the contents of the specified properties table with this one, allowing the entries in that remote table to override the ones in this table iff override is true. |
boolean |
parse(java.lang.String contents)
|
boolean |
processElement(java.lang.String name,
java.lang.String val)
Basic, degenerate method for process which should be overridden to provide any functionality. |
int |
processElements()
Loops over the elements in the table and calls processElement()
on each. |
java.lang.String[] |
stringList(java.lang.String tmp)
|
java.lang.String[] |
stringList(java.lang.String tmp,
char sep)
|
boolean |
stripQuotes()
Determine whether we are intending to remove the quotes from the entries. |
boolean |
stripQuotes(boolean val)
Set the flag that dictates whether we strip the quotes from the entries in the table. |
void |
trim()
Strip the white-space from all entries, except those whose name ends with .separator,
and also remove the quotes if the stripQuotes
variable is set to true. |
| Methods inherited from class java.util.Properties |
getProperty, getProperty, list, list, propertyNames, save, setProperty, store |
| Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public java.lang.String[][] booleanStrings
protected boolean stripQuotes
trim()| Constructor Detail |
public TrimmedProperties()
public TrimmedProperties(boolean quotes)
stripQuotes variable
to the specified value.public TrimmedProperties(java.lang.String txt)
public TrimmedProperties(java.lang.String txt,
boolean quotes)
public TrimmedProperties(java.io.File file)
public TrimmedProperties(java.io.File file,
boolean quotes)
public TrimmedProperties(java.util.Properties props)
public TrimmedProperties(java.util.Properties props,
boolean quotes)
quotes.public TrimmedProperties(java.io.InputStream s)
public TrimmedProperties(InputFileInt f)
public TrimmedProperties(InputFileInt f,
boolean quotes)
| Method Detail |
public boolean parse(java.lang.String contents)
public void load(java.io.InputStream in)
load in class java.util.Propertiespublic void load(java.io.File file)
public void trim()
.separator,
and also remove the quotes if the stripQuotes
variable is set to true.
public int merge(java.util.Properties alt,
boolean override)
override is true.alt - the properties which are to be added to this table.override - whether entries common to both tables
are resolved by using the value in the remote table
altpublic int merge(java.util.Properties alt)
public boolean stripQuotes()
trim()public boolean stripQuotes(boolean val)
public int processElements()
processElement()
on each.
public boolean processElement(java.lang.String name,
java.lang.String val)
public boolean asBoolean(java.lang.String val)
throws java.lang.Exception
public boolean isBoolean(java.lang.String v)
public java.lang.String[] stringList(java.lang.String tmp)
public java.lang.String[] stringList(java.lang.String tmp,
char sep)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||