|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.javatest.util.PropertyArray
public class PropertyArray
A space-efficient string to string map.
This class is similar to java.util.Properties.
For this class, space is more important than speed. Use this class when
you care much more about wasted space than wasting time doing reference
juggling in memory. Arrays in this class must correspond to this format:
{"key1", "value1", "key2", "value2", ...}
Nested Class Summary | |
---|---|
static class |
PropertyArray.PropertyArrayError
A class used to report problems that may occur when using PropertyArray. |
Constructor Summary | |
---|---|
PropertyArray()
Create a mutable object. |
|
PropertyArray(int initSize)
Create a mutable object. |
|
PropertyArray(Properties props)
Create a immutable PropertyArray object from a standard Properties object. |
|
PropertyArray(java.io.Reader in)
Create a immutable object, from data read from on a stream in the format of a standard Java properties file. |
|
PropertyArray(java.lang.String[] data)
Create a immutable PropertyArray object from data in a compact array of names and values. |
Method Summary | |
---|---|
static java.util.Enumeration |
enumerate(java.lang.String[] props)
Enumerate the properties in an array. |
java.lang.String |
get(java.lang.String key)
Get the value of a named property. |
static java.lang.String |
get(java.lang.String[] data,
java.lang.String key)
Get a named value from the array of properties. |
java.lang.String[] |
getArray()
Get a copy of the data in this PropertyArray. |
static java.lang.String[] |
getArray(Properties props)
Get a compact array containing the names and values of entries from a standard Properties object. |
Properties |
getProperties()
Get the data in this PropertyArray as a standard Properties object. |
static Properties |
getProperties(java.lang.String[] data)
Get a standard Properties object from an array of properties. |
boolean |
isMutable()
Check if the property array is mutable. |
static java.lang.String[] |
load(java.io.Reader in)
Read an array of properties from an input stream. |
static java.lang.String[] |
put(java.lang.String[] data,
java.lang.String key,
java.lang.String value)
Add a mapping to an array, returning a new array. |
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Put a property into the PropertyArray. |
void |
remove(java.lang.String key)
Remove a property. |
static java.lang.String[] |
remove(java.lang.String[] data,
java.lang.String key)
Remove an entry from an array of properties. |
static void |
save(java.lang.String[] data,
java.io.Writer out)
Write an array of properties to a stream. |
void |
save(java.io.Writer out)
Save the properties to a stream. |
int |
size()
Get the number of properties stored in the property array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertyArray()
public PropertyArray(int initSize)
initSize
- the initial capacity of the arraypublic PropertyArray(java.io.Reader in) throws java.io.IOException
in
- the stream from which to read the properties
java.io.IOException
- if a problem occurred while reading the datapublic PropertyArray(Properties props)
props
- the object from which to initialize the arraypublic PropertyArray(java.lang.String[] data)
data
- an array containing pairs of entries: even-numbered entries
identify the names of properties, odd-numbered entries give the value
for the preceding property name.Method Detail |
---|
public static java.lang.String[] getArray(Properties props)
props
- the Properties object from which to get the data
public static java.lang.String[] put(java.lang.String[] data, java.lang.String key, java.lang.String value)
data
- The array to which to the new array is to be added. May be null.key
- the name of the new value to be addedvalue
- the new value to be added
PropertyArray.PropertyArrayError
- May be thrown if a null key or value is
supplied.public static java.lang.String get(java.lang.String[] data, java.lang.String key)
data
- an array containing sequential name value pairskey
- the name of the property to be returned
public static java.lang.String[] remove(java.lang.String[] data, java.lang.String key)
data
- an array of sequential name value propertieskey
- the name of the entry to be removed
public static Properties getProperties(java.lang.String[] data)
data
- an array of sequential name value properties
public static void save(java.lang.String[] data, java.io.Writer out) throws java.io.IOException
data
- an array of sequential name value propertiesout
- a stream to which to write the data
java.io.IOException
- if a problem occurred while writing to the streamload(Reader)
public static java.lang.String[] load(java.io.Reader in) throws java.io.IOException
in
- the stream from which to read the data
java.io.IOException
- if an error occurred while reading the datasave(String[], Writer)
public static java.util.Enumeration enumerate(java.lang.String[] props)
props
- an array of sequential name value properties
public Properties getProperties()
public boolean isMutable()
public int size()
public java.lang.String get(java.lang.String key)
key
- the name of the desired property
public java.lang.String[] getArray()
public java.lang.String put(java.lang.String key, java.lang.String value)
key
- the name of the property to be addedvalue
- the value of the property to be added
PropertyArray.PropertyArrayError
- if a null key or value is supplied.public void remove(java.lang.String key)
key
- the name of the property to be removedpublic void save(java.io.Writer out) throws java.io.IOException
out
- the stream to which to write the data
java.io.IOException
- if an error occurred while writing the data
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |