|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.w3c.tools.resources.AttributeHolder
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).
Attribute
,
Resource
Field Summary | |
protected Attribute[] |
attributes
Pointer to this class registered list of attributes. |
protected boolean |
slowpickle
Turns on/off fast pickling. |
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[] values)
Initialization method for attribute holders. |
int |
lookupAttribute(java.lang.String name)
Lookup up the index of an attribute in our attribute description. |
void |
pickle(java.io.DataOutputStream out)
Pickle this attribute holder to the given stream. |
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. |
static AttributeHolder |
unpickle(java.io.DataInputStream in)
Unpickle an attribute holder from the given input stream. |
static AttributeHolder |
unpickle(java.io.DataInputStream in,
java.util.Hashtable defs)
A short hand for unpickling and initializing a resource. |
static AttributeHolder |
unpickle(java.io.DataInputStream in,
java.util.Hashtable defs,
boolean init)
Unpickle an attribute holder from the given input stream. |
AttributeHolder |
unpickleInstance(java.io.DataInputStream in,
java.util.Hashtable defs)
A short-hand for unpickling and initializing resources. |
AttributeHolder |
unpickleInstance(java.io.DataInputStream in,
java.util.Hashtable defs,
boolean init)
Finish the instance part of the unpickling job. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected boolean slowpickle
Fast pickling is a mode of pickling attribute holders in which evolutivity is lost in favor of speed. With slow pickling obtained by setting that flag to false, resources are dumped in a alist like format, so you can preserve informations if the attribute list changes.
protected Attribute[] attributes
protected java.lang.Object[] values
Constructor Detail |
public AttributeHolder()
Method Detail |
public java.lang.Object getClone(java.lang.Object[] values)
values
- Attribute values to overide in the clone.public java.lang.Object getClone()
public java.lang.Object getClone(java.util.Hashtable defs)
defs
- The attribute values, in a Hashtable.public Attribute[] getAttributes()
Attribute
public int lookupAttribute(java.lang.String name)
name
- The name of the attribute to look for.public void setValue(int idx, java.lang.Object value)
idx
- The attribute index, in the list of attributes advertized by
the resource.value
- The new value for this attribute.public void setValue(java.lang.String name, java.lang.Object value)
name
- The attribute name.value
- The new value for the attribute.public void setBoolean(int idx, boolean b)
public void setChar(int idx, char ch) throws IllegalAttributeAccess
public void setDouble(int idx, double d) throws IllegalAttributeAccess
public void setFloat(int idx, float f) throws IllegalAttributeAccess
public void setInt(int idx, int i) throws IllegalAttributeAccess
public void setLong(int idx, long l) throws IllegalAttributeAccess
public void setString(int idx, java.lang.String s) throws IllegalAttributeAccess
public java.lang.Object getValue(int idx, java.lang.Object def) throws IllegalAttributeAccess
idx
- The index of the attribute whose value is queried.def
- The default value (if the attribute isn't defined).public java.lang.Object getValue(java.lang.String name, java.lang.Object def) throws IllegalAttributeAccess
name
- The name of the queried attribute.def
- The default value.public boolean getBoolean(int idx, boolean def)
public char getChar(int idx, char def)
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 java.lang.String getString(int idx, java.lang.String def)
public boolean definesAttribute(int idx) throws IllegalAttributeAccess
idx
- The index of the attribute to check.public boolean definesAttribute(java.lang.String name) throws IllegalAttributeAccess
name
- The name of the attribute to check.public void pickle(java.io.DataOutputStream out) throws java.io.IOException
out
- The output stream we should pickle ourselve to.public static AttributeHolder unpickle(java.io.DataInputStream in, java.util.Hashtable defs, boolean init) throws java.io.IOException
The second stage restore the instance attributes (and whatever
information the pickle method as written there). This is the
unpickleInstance
method.
defs
- Set of default values for the holder.in
- The input stream to read from.init
- Should the resource be initialized ?public static AttributeHolder unpickle(java.io.DataInputStream in, java.util.Hashtable defs) throws java.io.IOException
defs
- Set of default values for the holder.in
- The input stream to read from.init
- Should the resource be initialized ?public AttributeHolder unpickleInstance(java.io.DataInputStream in, java.util.Hashtable defs, boolean init) throws java.io.IOException
pickle
method, make sure the first
method it calls is it super-method, than pickle whatever additional
infos you want to pickle.
unpickleInstance
method, make
sure ut first calls its super class unpickleInstance
method, and than unpickle the additional informations you have
store at pickling time.
in
- The input stream to read from.defs
- The proposed attribute default values.init
- Should we initialize the resource after unpickling.public AttributeHolder unpickleInstance(java.io.DataInputStream in, java.util.Hashtable defs) throws java.io.IOException
in
- The input stream to read.defs
- The default attribute values.public static AttributeHolder unpickle(java.io.DataInputStream in) throws java.io.IOException
in
- The input stream to read from.public void initialize(java.lang.Object[] values)
initialize
method gets called. The holder should initialize itself with the set
of provided values and perform any additional startup code.values
- The attribute values the holder should initialize from.public void initialize(java.util.Hashtable defs)
defs
- The Hashtable containing the default values.public void print(java.io.PrintStream out)
out
- The print stream to print to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |