public class PropertyArray
extends java.lang.Object
{"key1", "value1", "key2", "value2", ...}
Modifier and Type | Class and Description |
---|---|
static class |
PropertyArray.PropertyArrayError
A class used to report problems that may occur when using PropertyArray.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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 propertiesjava.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.public static java.lang.String[] getArray(Properties props)
props
- the Properties object from which to get the datapublic 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 addedPropertyArray.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 returnedpublic 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 removedpublic static Properties getProperties(java.lang.String[] data)
data
- an array of sequential name value propertiespublic 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 datajava.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 datajava.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 propertiespublic Properties getProperties()
public boolean isMutable()
public int size()
public java.lang.String get(java.lang.String key)
key
- the name of the desired propertypublic 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 addedPropertyArray.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 datajava.io.IOException
- if an error occurred while writing the dataCopyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.