: Class AttributeHolder

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

## org.w3c.tools.resources
Class AttributeHolder

    java.lang.Object
      |
      +--org.w3c.tools.resources.AttributeHolder

Direct Known Subclasses:
  CachedResource, NewStoreEntry, PutedEntry, Resource, ResourceStoreState, StoreState

public class AttributeHolder
extends java.lang.Object
implements java.lang.Cloneable

An attribute holder is an object that holds a list of attributes. Each of the attributes maintained by a holder are described by an Attribute object, wich is able to pickle/unpickle its value, provides the status of the attribute (eg mandatory, editable, etc), etc.

Given this, an attribute holder is able to pickle its state (made of its attribute values), and unpickle it to any DataOutputStream (resp. DataInputStream).

See Also:
  `Attribute`, `Resource`

Field Summary
`protected Attribute[]` | `attributes` Pointer to this class registered list of attributes.
`protected java.lang.Object[]` | `values` Attribute values.

Constructor Summary
`AttributeHolder()` Create an attribute holder.

Method Summary
`boolean` | `definesAttribute(int idx)` Does this resource has defined a value for the given attribute.
`boolean` | `definesAttribute(java.lang.String name)` Does this resource has defined a value for the given attribute.
`Attribute[]` | `getAttributes()` Get this attribute holders attributes description.
`boolean` | `getBoolean(int idx, boolean def)`
`char` | `getChar(int idx, char def)`
`java.lang.Object` | `getClone()` Clone this attribute holder.
`java.lang.Object` | `getClone(java.util.Hashtable defs)` Clone this AttributeHolder instance, and initialize it with defaults.
`java.lang.Object` | `getClone(java.lang.Object[] values)` Clone this attribute holder, and init it with the given attributes.
`double` | `getDouble(int idx, double def)`
`float` | `getFloat(int idx, float def)`
`int` | `getInt(int idx, int def)`
`long` | `getLong(int idx, long def)`
`java.lang.String` | `getString(int idx, java.lang.String def)`
`java.lang.Object` | `getValue(int idx, java.lang.Object def)` Generic get of an attribute value.
`java.lang.Object` | `getValue(java.lang.String name, java.lang.Object def)` Generic get of an attribute value.
`void` | `initialize(java.util.Hashtable defs)` Initialization method for attribute holders.
`void` | `initialize(java.lang.Object[] nvalues)` Initialization method for attribute holders.
`int` | `lookupAttribute(java.lang.String name)` Lookup up the index of an attribute in our attribute description.
`void` | `pickleValues(java.util.Hashtable defs)` Set the values.
`void` | `print(java.io.PrintStream out)` Debugging purposes only, print this attribute holder.
`void` | `setBoolean(int idx, boolean b)`
`void` | `setChar(int idx, char ch)`
`void` | `setDouble(int idx, double d)`
`void` | `setFloat(int idx, float f)`
`void` | `setInt(int idx, int i)`
`void` | `setLong(int idx, long l)`
`void` | `setString(int idx, java.lang.String s)`
`void` | `setValue(int idx, java.lang.Object value)` Set an attribute value.
`void` | `setValue(java.lang.String name, java.lang.Object value)` Set an attribute value.
`java.lang.Object` | `unsafeGetValue(int idx, java.lang.Object def)` Generic get of an attribute value.

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

Field Detail

### attributes

    protected Attribute[] attributes

  Pointer to this class registered list of attributes.

### values

    protected java.lang.Object[] values

  Attribute values.

Constructor Detail

### AttributeHolder

    public AttributeHolder()

  Create an attribute holder.

Method Detail

### getClone

    public java.lang.Object getClone(java.lang.Object[] values)

  Clone this attribute holder, and init it with the given attributes.
  Parameters:
    `values` - Attribute values to overide in the clone.
  Returns:
    A clone of this resource.

### getClone

    public java.lang.Object getClone()

  Clone this attribute holder. The resulting clone will share the attribute values of the cloned attribute holder.
  Returns:
    An attribute holder sharing its ancestor attribute values.

### getClone

    public java.lang.Object getClone(java.util.Hashtable defs)

  Clone this AttributeHolder instance, and initialize it with defaults. This method first clones the receiving attribute holder, and then uses the defaults provided to finish the initialization.
  Parameters:
    `defs` - The attribute values, in a Hashtable.
  Returns:
    The clone.

### getAttributes

    public Attribute[] getAttributes()

  Get this attribute holders attributes description. The attribute list is guaranteed to be returned always in the same order, wich is fixed at compilation time. This allows for fast access to resource by their position rather than by name.
  Returns:
    An array of Attribute objects, each one containing the description of one single attribute of the resource.
  See Also:
    `Attribute`

### lookupAttribute

    public int lookupAttribute(java.lang.String name)

  Lookup up the index of an attribute in our attribute description.
  Parameters:
    `name` - The name of the attribute to look for.
  Returns:
    An integer, positive if found, negative otherwise.

### setValue

    public void setValue(int idx,
                         java.lang.Object value)

  Set an attribute value. This method sets the value of some attribute of the resource. It marks the resource as being modified, and alert its resource store (so that it knows it will have to save the object at some time in the future).
  Parameters:
    `idx` - The attribute index, in the list of attributes advertized by the resource.
    `value` - The new value for this attribute.
  Throws:
    IllegalAttributeAccess - if the provided value doesn't match the attribute expected type.

### setValue

    public void setValue(java.lang.String name,
                         java.lang.Object value)

  Set an attribute value. This method sets the value of an attribute, referenced by its name.
  Parameters:
    `name` - The attribute name.
    `value` - The new value for the attribute.
  Throws:
    IllegalAttributeAccess - if the provided value doesn't match the attribute expected type.

### setBoolean

    public void setBoolean(int idx,
                           boolean b)

### setChar

    public void setChar(int idx,
                        char ch)
                 throws IllegalAttributeAccess

### setDouble

    public void setDouble(int idx,
                          double d)
                   throws IllegalAttributeAccess

### setFloat

    public void setFloat(int idx,
                         float f)
                  throws IllegalAttributeAccess

### setInt

    public void setInt(int idx,
                       int i)
                throws IllegalAttributeAccess

### setLong

    public void setLong(int idx,
                        long l)
                 throws IllegalAttributeAccess

### setString

    public void setString(int idx,
                          java.lang.String s)
                   throws IllegalAttributeAccess

### getValue

    public java.lang.Object getValue(int idx,
                                     java.lang.Object def)
                              throws IllegalAttributeAccess

  Generic get of an attribute value. Retreive an attribute value from its index in the resource's attribute list.
  Parameters:
    `idx` - The index of the attribute whose value is queried.
    `def` - The default value (if the attribute isn't defined).
  Returns:
    An object, giving the attribute value, or the provided default if this attribute isn't currently define for the resource.
  Throws:
    IllegalAttributeAccess - if the given index doesn't match any of the resource's attributes.

### unsafeGetValue

    public java.lang.Object unsafeGetValue(int idx,
                                           java.lang.Object def)
                                    throws IllegalAttributeAccess

  Generic get of an attribute value. Retreive an attribute value from its index in the resource's attribute list. THIS VERSION IS NOT SYNCHRONIZED AND THEREFORE SHOULD BE USED ONLY WHEN YOU ARE SURE YOU SHOULD USE THIS, WHICH MEANS ALMOST NEVER!
  Parameters:
    `idx` - The index of the attribute whose value is queried.
    `def` - The default value (if the attribute isn't defined).
  Returns:
    An object, giving the attribute value, or the provided default if this attribute isn't currently define for the resource.
  Throws:
    IllegalAttributeAccess - if the given index doesn't match any of the resource's attributes.

### getValue

    public java.lang.Object getValue(java.lang.String name,
                                     java.lang.Object def)
                              throws IllegalAttributeAccess

  Generic get of an attribute value. Get the method of an attribute, by name.
  Parameters:
    `name` - The name of the queried attribute.
    `def` - The default value.
  Throws:
    IllegalAttributeAccess - if the given name doesn't match any of the attribute's name.

### getBoolean

    public boolean getBoolean(int idx,
                              boolean def)

### getChar

    public char getChar(int idx,
                        char def)

### getDouble

    public double getDouble(int idx,
                            double def)

### getFloat

    public float getFloat(int idx,
                          float def)

### getInt

    public int getInt(int idx,
                      int def)

### getLong

    public long getLong(int idx,
                        long def)

### getString

    public java.lang.String getString(int idx,
                                      java.lang.String def)

### definesAttribute

    public boolean definesAttribute(int idx)
                             throws IllegalAttributeAccess

  Does this resource has defined a value for the given attribute.
  Parameters:
    `idx` - The index of the attribute to check.
  Returns:
    A boolean true if the resource has a value for this attribute, false otherwise.

### definesAttribute

    public boolean definesAttribute(java.lang.String name)
                             throws IllegalAttributeAccess

  Does this resource has defined a value for the given attribute.
  Parameters:
    `name` - The name of the attribute to check.
  Returns:
    A boolean true if the resource has a value for this attribute, false otherwise.

### pickleValues

    public void pickleValues(java.util.Hashtable defs)

  Set the values. (MUST be called before initialize).
  Parameters:
    `defs` - The Hashtable containing the values.

### initialize

    public void initialize(java.lang.Object[] nvalues)

  Initialization method for attribute holders. Each time an attribute holder get restored, its `initialize` method gets called. The holder should initialize itself with the set of provided values and perform any additional startup code.
  Parameters:
    `values` - The attribute values the holder should initialize from.

### initialize

    public void initialize(java.util.Hashtable defs)

  Initialization method for attribute holders. This method allows to initialize an attribute holder by providing its attributes values through a Hashtable mapping attribute names to attribute values.
  Parameters:
    `defs` - The Hashtable containing the default values.

### print

    public void print(java.io.PrintStream out)

  Debugging purposes only, print this attribute holder.
  Parameters:
    `out` - The print stream to print to.

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