Class w3c.jigsaw.resources.AttributeHolder
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.resources.AttributeHolder

java.lang.Object
   |
   +----w3c.jigsaw.resources.AttributeHolder

public class AttributeHolder
extends Object
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

Variable Index

 o attributes
Pointer to this class registered list of attributes.
 o values
Attribute values.

Constructor Index

 o AttributeHolder()
Create an attribute holder.

Method Index

 o definesAttribute(int)
Does this resource has defined a value for the given attribute.
 o definesAttribute(String)
Does this resource has defined a value for the given attribute.
 o getAttributes()
Get this attribute holders attributes description.
 o getBoolean(int, boolean)
 o getChar(int, char)
 o getDouble(int, double)
 o getFloat(int, float)
 o getInt(int, int)
 o getLong(int, long)
 o getString(int, String)
 o getValue(int, Object)
Generic get of an attribute value.
 o getValue(String, Object)
Generic get of an attribute value.
 o initialize(Hashtable)
Initialization method for attribute holders.
 o initialize(Object[])
Initialization method for attribute holders.
 o lookupAttribute(String)
Lookup up the index of an attribute in our attribute description.
 o pickle(DataOutputStream)
Pickle this attribute holder to the given stream.
 o print(PrintStream)
Debugging purposes only, print this attribute holder.
 o setBoolean(int, boolean)
 o setChar(int, char)
 o setDouble(int, double)
 o setFloat(int, float)
 o setInt(int, int)
 o setLong(int, long)
 o setString(int, String)
 o setValue(int, Object)
Set an attribute value.
 o setValue(String, Object)
Set an attribute value.
 o unpickle(DataInputStream)
Unpickle an attribute holder from the given input stream.
 o unpickle(DataInputStream, Hashtable)
Unpickle an attribute holder from the given input stream.
 o unpickleInstance(DataInputStream, Hashtable)
Finish the instance part of the unpickling job.

Variables

 o attributes
  protected Attribute attributes[]
Pointer to this class registered list of attributes.
 o values
  protected Object values[]
Attribute values.

Constructors

 o AttributeHolder
  public AttributeHolder()
Create an attribute holder.

Methods

 o 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
 o lookupAttribute
  public int lookupAttribute(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.
 o setValue
  public synchronized void setValue(int idx,
                                    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: IllegalAttributeValue
if the provided value doesn't match the attribute expected type.
Throws: UnknownAttribute
If the provided index doesn't match an attribute of this object.
 o setValue
  public synchronized void setValue(String name,
                                    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: IllegalAttributeValue
if the provided value doesn't match the attribute expected type.
Throws: UnknownAttribute
if the given name doesn't match any of the attribute's name.
 o setBoolean
  public synchronized void setBoolean(int idx,
                                      boolean b)
 o setChar
  public synchronized void setChar(int idx,
                                   char ch) throws IllegalAttributeAccess
 o setDouble
  public synchronized void setDouble(int idx,
                                     double d) throws IllegalAttributeAccess
 o setFloat
  public synchronized void setFloat(int idx,
                                    float f) throws IllegalAttributeAccess
 o setInt
  public synchronized void setInt(int idx,
                                  int i) throws IllegalAttributeAccess
 o setLong
  public synchronized void setLong(int idx,
                                   long l) throws IllegalAttributeAccess
 o setString
  public synchronized void setString(int idx,
                                     String s) throws IllegalAttributeAccess
 o getValue
  public synchronized Object getValue(int idx,
                                      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.
 o getValue
  public synchronized Object getValue(String name,
                                      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.
 o getBoolean
  public synchronized boolean getBoolean(int idx,
                                         boolean def)
 o getChar
  public synchronized char getChar(int idx,
                                   char def)
 o getDouble
  public synchronized double getDouble(int idx,
                                       double def)
 o getFloat
  public synchronized float getFloat(int idx,
                                     float def)
 o getInt
  public synchronized int getInt(int idx,
                                 int def)
 o getLong
  public synchronized long getLong(int idx,
                                   long def)
 o getString
  public synchronized String getString(int idx,
                                       String def)
 o 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.
 o definesAttribute
  public boolean definesAttribute(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.
 o pickle
  public void pickle(DataOutputStream out) throws IOException
Pickle this attribute holder to the given stream.
Parameters:
out - The output stream we should pickle ourselve to.
Throws: IOException
If some IO error occured during pickling.
 o unpickle
  public static AttributeHolder unpickle(DataInputStream in,
                                         Hashtable defs) throws IOException
Unpickle an attribute holder from the given input stream. AttributeHolder unpickling is done in two stage: the first stage wich is not redefinable, consists in recreating an instance of the attribute holder (this method).

The second stage restore the instance attributes (and whatever information the pickle method as written there). This is the unpickleInstance method.

Parameters:
defs - Set of default values for the holder.
in - The input stream to read from.
Returns:
An instance of AttributeHolder of one of its subclass.
Throws: IOException
If some IO error occured while reading the stream.
Throws: AttributeHolderInitException
If we weren't able to restore the attribute holder.
 o unpickleInstance
  public AttributeHolder unpickleInstance(DataInputStream in,
                                          Hashtable defs) throws IOException
Finish the instance part of the unpickling job. The standard way of redefining how your attribute holder should be pickled is as follow:
Parameters:
in - The input stream to read from.
defs - The proposed attribute default values.
 o unpickle
  public static AttributeHolder unpickle(DataInputStream in) throws IOException
Unpickle an attribute holder from the given input stream.
Parameters:
in - The input stream to read from.
Returns:
An instance of AttributeHolder of one of its subclass.
Throws: IOException
If some IO error occured while reading the stream.
Throws: AttributeHolderInitException
If we weren't able to restore the attribute holder.
 o initialize
  public void initialize(Object values[])
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.
Throws: AttributeHolderInitException
If tghe holder wasn't able to initialize itself from the given set of attribute values.
 o initialize
  public void initialize(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.
 o print
  public void print(PrintStream out)
Debugging purposes only, print this attribute holder.
Parameters:
out - The print stream to print to.

All Packages  Class Hierarchy  This Package  Previous  Next  Index