Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.util
Class PropertyArray

    java.lang.Object
      com.sun.javatest.util.PropertyArray

    public class PropertyArray

extends java.lang.Object

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

### PropertyArray

    public PropertyArray()

  Create a mutable object.

### PropertyArray

    public PropertyArray(int initSize)

  Create a mutable object.

  Parameters:
    `initSize` - the initial capacity of the array

### PropertyArray

    public PropertyArray(java.io.Reader in)
                  throws java.io.IOException

  Create a immutable object, from data read from on a stream in the format of a standard Java properties file.

  Parameters:
    `in` - the stream from which to read the properties
  Throws:
    `java.io.IOException` - if a problem occurred while reading the data

### PropertyArray

    public PropertyArray(Properties props)

  Create a immutable PropertyArray object from a standard Properties object.

  Parameters:
    `props` - the object from which to initialize the array

### PropertyArray

    public PropertyArray(java.lang.String[] data)

  Create a immutable PropertyArray object from data in a compact array of names and values.

  Parameters:
    `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

### getArray

    public static java.lang.String[] getArray(Properties props)

  Get a compact array containing the names and values of entries from a standard Properties object.

  Parameters:
    `props` - the Properties object from which to get the data
  Returns:
    an array containing the names of the properties in even-numbered entries, and the corresponding values in the adjacent odd-numbered entries

### put

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

  Parameters:
    `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 added
    `value` - the new value to be added
  Returns:
    an array with the new element added
  Throws:
    `PropertyArray.PropertyArrayError` - May be thrown if a null key or value is supplied.

### get

    public static java.lang.String get(java.lang.String[] data,
                                       java.lang.String key)

  Get a named value from the array of properties. If the given data array is null or zero length, null is returned. If the key paramter is null, null will be returned, no error will occur.

  Parameters:
    `data` - an array containing sequential name value pairs
    `key` - the name of the property to be returned
  Returns:
    the value of the named entry, or null if not found

### remove

    public static java.lang.String[] remove(java.lang.String[] data,
                                            java.lang.String key)

  Remove an entry from an array of properties.

  Parameters:
    `data` - an array of sequential name value properties
    `key` - the name of the entry to be removed
  Returns:
    an array that does not contain the named property

### getProperties

    public static Properties getProperties(java.lang.String[] data)

  Get a standard Properties object from an array of properties.

  Parameters:
    `data` - an array of sequential name value properties
  Returns:
    a Properties object containing data from the array

### save

    public static void save(java.lang.String[] data,
                            java.io.Writer out)
                     throws java.io.IOException

  Write an array of properties to a stream. The data is written using the format for standard Java property files.

  Parameters:
    `data` - an array of sequential name value properties
    `out` - a stream to which to write the data
  Throws:
    `java.io.IOException` - if a problem occurred while writing to the stream
  See Also:
    `load(Reader)`

### load

    public static java.lang.String[] load(java.io.Reader in)
                                   throws java.io.IOException

  Read an array of properties from an input stream. The data will be read according to the standard format for Java property files.

  Parameters:
    `in` - the stream from which to read the data
  Returns:
    an array of sequential name value properties
  Throws:
    `java.io.IOException` - if an error occurred while reading the data
  See Also:
    `save(String[], Writer)`

### enumerate

    public static java.util.Enumeration enumerate(java.lang.String[] props)

  Enumerate the properties in an array.

  Parameters:
    `props` - an array of sequential name value properties
  Returns:
    an enumeration of the properties in the array

### getProperties

    public Properties getProperties()

  Get the data in this PropertyArray as a standard Properties object.

  Returns:
    a Properties object containing the same data as this PropertyArray

### isMutable

    public boolean isMutable()

  Check if the property array is mutable.

  Returns:
    true if data can be stored in this array, and false otherwise

### size

    public int size()

  Get the number of properties stored in the property array.

  Returns:
    the number of properties stored in the property array

### get

    public java.lang.String get(java.lang.String key)

  Get the value of a named property.

  Parameters:
    `key` - the name of the desired property
  Returns:
    the value of the property, or null if it was not found

### getArray

    public java.lang.String[] getArray()

  Get a copy of the data in this PropertyArray.

  Returns:
    a copy of the data, or null if there is no data.

### put

    public java.lang.String put(java.lang.String key,
                                java.lang.String value)

  Put a property into the PropertyArray.

  Parameters:
    `key` - the name of the property to be added
    `value` - the value of the property to be added
  Returns:
    the previous value (if any) of this property
  Throws:
    `PropertyArray.PropertyArrayError` - if a null key or value is supplied.

### remove

    public void remove(java.lang.String key)

  Remove a property.

  Parameters:
    `key` - the name of the property to be removed

### save

    public void save(java.io.Writer out)
              throws java.io.IOException

  Save the properties to a stream. The data is written using the format for a standard Java properties file.

  Parameters:
    `out` - the stream to which to write the data
  Throws:
    `java.io.IOException` - if an error occured while writing the data

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.