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

## things.data.impl
Class ReadableAttributes

    java.lang.Object
      things.data.impl.ReadableAttributes

All Implemented Interfaces:
  java.io.Serializable, AttributeReader

Direct Known Subclasses:
  ReadWriteableAttributes

    public class ReadableAttributes

extends java.lang.Object
implements AttributeReader, java.io.Serializable

A set of readable attributes.

Version:
  1.0

  Version History

      EPG - Initial - 23 AUG 05

Author:
  Erich P. Gatejen
See Also:
  Serialized Form

Field Summary
`protected java.util.Hashtable<java.lang.String,java.util.LinkedList<NVImmutable>>` | `mYAttributes` Attributes, if needed.

Constructor Summary
`ReadableAttributes()`

Method Summary
`java.lang.Object` | `get()` Get the underlying attribute data.
`NVImmutable` | `getAttribute(java.lang.String n)` Get an attribute.
`NVImmutable` | `getAttribute(java.lang.String n, int index)` Get an attribute from a multi-attribute by index.
`int` | `getAttributeCount()` Get attribute count.
`int` | `getAttributeCount(java.lang.String n)` Get the total attribute count for a specific name.
`java.util.Collection<java.lang.String>` | `getAttributeNames()` Get a collection of attribute names.
`java.util.Collection<NVImmutable>` | `getAttributes()` Get a collection of the attributes.
`java.util.Collection<NVImmutable>` | `getAttributes(java.lang.String n)` Get a collection of the attributes for the name.
`java.lang.String` | `getAttributeValueToString(java.lang.String n)` Get an attribute value rendered as a string.
`java.lang.String` | `getAttributeValueToString(java.lang.String n, java.lang.String defaultValue)` Get an attribute value rendered as a string.
`Attributes` | `getPrivateSet()` Get a private set that can be manipulated.
`boolean` | `hasAttribute(java.lang.String n)` Check if it has an attribute.
`boolean` | `isMultivalueAllowed()` Ask if multi-value is allowed.
`void` | `set(java.lang.Object o)` Set the underlying attribute data.
`protected void` | `validateAttributes()` Check to see if attributes were defined.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### mYAttributes

    protected java.util.Hashtable<java.lang.String,java.util.LinkedList<NVImmutable>> mYAttributes

  Attributes, if needed.

Constructor Detail

### ReadableAttributes

    public ReadableAttributes()

Method Detail

### isMultivalueAllowed

    public boolean isMultivalueAllowed()

  Ask if multi-value is allowed.

  Specified by:
    `isMultivalueAllowed` in interface `AttributeReader`
  Returns:
    true if it is allowed.

### getAttribute

    public NVImmutable getAttribute(java.lang.String n)

  Get an attribute. If the name of the attribute is null or the attribute does not exist, it should return null. If it is a multi, it will return the first.

  Specified by:
    `getAttribute` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
  Returns:
    the value or null if not set.

### getAttributeValueToString

    public java.lang.String getAttributeValueToString(java.lang.String n)

  Get an attribute value rendered as a string. If the name of the attribute is null or the attribute does not exist, it should return null. If it is a multi, it will return the first.

  Specified by:
    `getAttributeValueToString` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
  Returns:
    the value or null if not set.

### getAttributeValueToString

    public java.lang.String getAttributeValueToString(java.lang.String n,
                                                      java.lang.String defaultValue)

  Get an attribute value rendered as a string. If the name of the attribute is null or the attribute does not exist, it should return null. If it is a multi, it will return the first.

  Specified by:
    `getAttributeValueToString` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
    `defaultValue` - the value it will return if the name maps to a null.
  Returns:
    the value or null if not set.

### hasAttribute

    public boolean hasAttribute(java.lang.String n)

  Check if it has an attribute. It will return false if the name is null.

  Specified by:
    `hasAttribute` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
  Returns:
    true if it has the attribute, otherwise false.

### getAttributes

    public java.util.Collection<NVImmutable> getAttributes(java.lang.String n)

  Get a collection of the attributes for the name.

  Specified by:
    `getAttributes` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
  Returns:
    The collection.

### getAttribute

    public NVImmutable getAttribute(java.lang.String n,
                                    int index)

  Get an attribute from a multi-attribute by index. This will work with single value items, as long as the index is zero. This is not a fast operation, so don't use it in time critical areas. It will always return null rather than throw an exception.

  Specified by:
    `getAttribute` in interface `AttributeReader`
  Parameters:
    `n` - name of the attribute
    `index` - the index of the attribute from 0.
  Returns:
    The NV or a null if it doesn't exist.

### getAttributeNames

    public java.util.Collection<java.lang.String> getAttributeNames()

  Get a collection of attribute names.

  Specified by:
    `getAttributeNames` in interface `AttributeReader`
  Returns:
    The collection.

### getAttributes

    public java.util.Collection<NVImmutable> getAttributes()

  Get a collection of the attributes.

  This version is heavy.

  Specified by:
    `getAttributes` in interface `AttributeReader`
  Returns:
    The collection

### getAttributeCount

    public int getAttributeCount()

  Get attribute count.

  Specified by:
    `getAttributeCount` in interface `AttributeReader`
  Returns:
    count, zero or greater

### getAttributeCount

    public int getAttributeCount(java.lang.String n)

  Get the total attribute count for a specific name. It will return 0 if the name is not found.

  Specified by:
    `getAttributeCount` in interface `AttributeReader`
  Parameters:
    `n` - The name of the attribute.
  Returns:
    count, zero or greater

### getPrivateSet

    public Attributes getPrivateSet()

  Get a private set that can be manipulated. This will make a copy and will not affect the original. This is a slow, heavy operation.

  Specified by:
    `getPrivateSet` in interface `AttributeReader`
  Returns:
    the HashSet of attributes.

### get

    public java.lang.Object get()

  Get the underlying attribute data. This can be dangerous! The data is alterable. We will protect it some by passing it as an Object.

  Returns:
    An object for the underlying data structure.

### set

    public void set(java.lang.Object o)
             throws ThingsException

  Set the underlying attribute data. This can be dangerous! The data is alterable. We will protect it some by passing it as an Object. If it is not the proper type, it will throw a ThingsException. param o The object that will set.

  Throws:
    `ThingsException`

### validateAttributes

    protected void validateAttributes()

  Check to see if attributes were defined. If not, do so.

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

Things.