org.w3c.tools.resources.upgrade
Class ObjectAttribute

java.lang.Object
  extended by org.w3c.tools.resources.upgrade.Attribute
      extended by org.w3c.tools.resources.upgrade.ObjectAttribute
All Implemented Interfaces:
java.io.Serializable

public class ObjectAttribute
extends Attribute

A generic Object attribute. This attribute is usefull for attributes that are:

See Also:
Serialized Form

Field Summary
protected  java.lang.Class cls
          The class for values of this attribute.
 
Fields inherited from class org.w3c.tools.resources.upgrade.Attribute
COMPUTED, DONTSAVE, EDITABLE, flags, MANDATORY, name, type
 
Constructor Summary
ObjectAttribute(java.lang.String name, java.lang.Class cls, java.lang.Object def, java.lang.Integer flags)
          Create a new ObjectAttribute instance.
ObjectAttribute(java.lang.String name, java.lang.String cname, java.lang.Object def, java.lang.Integer flags)
          Create a new ObjectAttribute instance.
 
Method Summary
 boolean checkValue(java.lang.Object value)
          Check that a value is allowed for this attribute.
 int getPickleLength(java.lang.Object value)
          Get the number of bytes required to save that attribute value.
 void pickle(java.io.DataOutputStream out, java.lang.Object obj)
          The ObjectAttribute values can't be pickled.
 java.lang.Object unpickle(java.io.DataInputStream in)
          The ObjectAttribute values can't be unpickled.
 
Methods inherited from class org.w3c.tools.resources.upgrade.Attribute
checkFlag, getDefault, getName, getType, stringify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cls

protected java.lang.Class cls
The class for values of this attribute.

Constructor Detail

ObjectAttribute

public ObjectAttribute(java.lang.String name,
                       java.lang.Class cls,
                       java.lang.Object def,
                       java.lang.Integer flags)
Create a new ObjectAttribute instance.

Parameters:
name - The name of the attribute.
cls - The class for this attribute values.
def - The default value for this attribute.
flags - The attribute flags.

ObjectAttribute

public ObjectAttribute(java.lang.String name,
                       java.lang.String cname,
                       java.lang.Object def,
                       java.lang.Integer flags)
Create a new ObjectAttribute instance.

Parameters:
name - The name of the attribute.
cname - The name class for this attribute values.
def - The default value for this attribute.
flags - The attribute flags.
Throws:
java.lang.RuntimeException - If we couldn't resolve the class name.
Method Detail

checkValue

public boolean checkValue(java.lang.Object value)
Check that a value is allowed for this attribute.

Specified by:
checkValue in class Attribute
Parameters:
value - The value to check.
Returns:
A boolean true if value is allowed.

getPickleLength

public final int getPickleLength(java.lang.Object value)
Get the number of bytes required to save that attribute value.

Specified by:
getPickleLength in class Attribute
Parameters:
The - value about to be pickled.
Returns:
The number of bytes needed to pickle that value.
Throws:
java.lang.RuntimeException - Always throw since ObjectAttribute can't be pickled.

pickle

public void pickle(java.io.DataOutputStream out,
                   java.lang.Object obj)
The ObjectAttribute values can't be pickled.

Specified by:
pickle in class Attribute
Parameters:
out - The DataOutputStream to dump the object to.
obj - The object to pickle.

unpickle

public java.lang.Object unpickle(java.io.DataInputStream in)
The ObjectAttribute values can't be unpickled.

Specified by:
unpickle in class Attribute
Parameters:
in - The DataInputStream to read from.
Returns:
The object value.