| java.lang.Object org.w3c.tools.resources.AttributeHolder
All known Subclasses: org.w3c.jigedit.filters.PutedEntry, org.w3c.tools.resources.Resource, org.w3c.www.protocol.http.cache.CachedResource, org.w3c.tools.resources.store.ResourceStoreState, org.w3c.www.protocol.http.cache.StoreState,
AttributeHolder | public class AttributeHolder implements Cloneable(Code) | | 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 See Also: Resource |
Method Summary | |
public boolean | definesAttribute(int idx) Does this resource has defined a value for the given attribute.
Parameters: idx - The index of the attribute to check. | public boolean | definesAttribute(String name) Does this resource has defined a value for the given attribute.
Parameters: name - The name of the attribute to check. | 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. | public boolean | getBoolean(int idx, boolean def) | public char | getChar(int idx, char def) | public Object | getClone(Object values) Clone this attribute holder, and init it with the given attributes.
Parameters: values - Attribute values to overide in the clone. | public synchronized Object | getClone() Clone this attribute holder.
The resulting clone will share the attribute values of
the cloned attribute holder. | public synchronized Object | getClone(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. | public double | getDouble(int idx, double def) | public float | getFloat(int idx, float def) | public int | getInt(int idx, int def) | public long | getLong(int idx, long def) | public String | getString(int idx, String def) | public synchronized Object | getValue(int idx, Object def) 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. Parameters: def - The default value (if the attribute isn't defined). | public Object | getValue(String name, Object def) Generic get of an attribute value. | public synchronized void | initialize(Object nvalues) Initialization method for attribute holders.
Each time an attribute holder get restored, its initialize
method gets called. | public synchronized void | initialize(Hashtable defs) Initialization method for attribute holders. | 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. | public synchronized void | pickleValues(Hashtable defs) Set the values. | public void | print(PrintStream out) Debugging purposes only, print this attribute holder. | public void | setBoolean(int idx, boolean b) | public void | setChar(int idx, char ch) | public void | setDouble(int idx, double d) | public void | setFloat(int idx, float f) | public void | setInt(int idx, int i) | public void | setLong(int idx, long l) | public void | setString(int idx, String s) | public synchronized void | setValue(int idx, Object value) Set an attribute value.
This method sets the value of some attribute of the resource. | public void | setValue(String name, Object value) Set an attribute value. | public boolean | unsafeDefinesAttribute(int idx) Does this resource has defined a value for the given attribute.
Parameters: idx - The index of the attribute to check. | public double | unsafeGetDouble(int idx, double def) | public String | unsafeGetString(int idx, String def) | public Object | unsafeGetValue(int idx, Object def) 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. Parameters: def - The default value (if the attribute isn't defined). |
attributes | protected Attribute attributes(Code) | | Pointer to this class registered list of attributes.
|
AttributeHolder | public AttributeHolder()(Code) | | Create an attribute holder.
|
definesAttribute | public boolean definesAttribute(int idx) throws IllegalAttributeAccess(Code) | | Does this resource has defined a value for the given attribute.
Parameters: idx - The index of the attribute to check. A boolean true if the resource has a valuefor this attribute, false otherwise. |
definesAttribute | public boolean definesAttribute(String name) throws IllegalAttributeAccess(Code) | | Does this resource has defined a value for the given attribute.
Parameters: name - The name of the attribute to check. A boolean true if the resource has a valuefor this attribute, false otherwise. |
getAttributes | public Attribute[] getAttributes()(Code) | | 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.
An array of Attribute objects, each one containing thedescription of one single attribute of the resource. See Also: org.w3c.tools.resources.Attribute |
getBoolean | public boolean getBoolean(int idx, boolean def)(Code) | | |
getChar | public char getChar(int idx, char def)(Code) | | |
getClone | public Object getClone(Object values)(Code) | | Clone this attribute holder, and init it with the given attributes.
Parameters: values - Attribute values to overide in the clone. A clone of this resource. |
getClone | public synchronized Object getClone()(Code) | | Clone this attribute holder.
The resulting clone will share the attribute values of
the cloned attribute holder.
An attribute holder sharing its ancestor attribute values. |
getClone | public synchronized Object getClone(Hashtable defs)(Code) | | 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. The clone. |
getDouble | public double getDouble(int idx, double def)(Code) | | |
getFloat | public float getFloat(int idx, float def)(Code) | | |
getInt | public int getInt(int idx, int def)(Code) | | |
getLong | public long getLong(int idx, long def)(Code) | | |
getValue | public synchronized Object getValue(int idx, Object def) throws IllegalAttributeAccess(Code) | | 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. Parameters: def - The default value (if the attribute isn't defined). An object, giving the attribute value, or the provideddefault if this attribute isn't currently define for the resource. exception: IllegalAttributeAccess - if the given index doesn't match anyof the resource's attributes. |
getValue | public Object getValue(String name, Object def) throws IllegalAttributeAccess(Code) | | Generic get of an attribute value.
Get the method of an attribute, by name.
Parameters: name - The name of the queried attribute. Parameters: def - The default value. exception: IllegalAttributeAccess - if the given name doesn't match anyof the attribute's name. |
initialize | public synchronized void initialize(Object nvalues)(Code) | | 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 synchronized void initialize(Hashtable defs)(Code) | | 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. |
lookupAttribute | public int lookupAttribute(String name)(Code) | | Lookup up the index of an attribute in our attribute description.
Parameters: name - The name of the attribute to look for. An integer, positive if found, negative otherwise. |
pickleValues | public synchronized void pickleValues(Hashtable defs)(Code) | | Set the values. (MUST be called before initialize).
Parameters: defs - The Hashtable containing the values. |
print | public void print(PrintStream out)(Code) | | Debugging purposes only, print this attribute holder.
Parameters: out - The print stream to print to. |
setBoolean | public void setBoolean(int idx, boolean b)(Code) | | |
setValue | public synchronized void setValue(int idx, Object value)(Code) | | 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. Parameters: value - The new value for this attribute. exception: IllegalAttributeAccess - if the provided value doesn't match the attribute expected type. |
setValue | public void setValue(String name, Object value)(Code) | | Set an attribute value.
This method sets the value of an attribute, referenced by its name.
Parameters: name - The attribute name. Parameters: value - The new value for the attribute. exception: IllegalAttributeAccess - if the provided value doesn't matchthe attribute expected type. |
unsafeDefinesAttribute | public boolean unsafeDefinesAttribute(int idx) throws IllegalAttributeAccess(Code) | | Does this resource has defined a value for the given attribute.
Parameters: idx - The index of the attribute to check. A boolean true if the resource has a valuefor this attribute, false otherwise. |
unsafeGetDouble | public double unsafeGetDouble(int idx, double def)(Code) | | |
unsafeGetValue | public Object unsafeGetValue(int idx, Object def) throws IllegalAttributeAccess(Code) | | 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. Parameters: def - The default value (if the attribute isn't defined). An object, giving the attribute value, or the provideddefault if this attribute isn't currently define for the resource. exception: IllegalAttributeAccess - if the given index doesn't match anyof the resource's attributes. |
|
|