viper.descriptors.attributes
Class Attributes

java.lang.Object
  extended byviper.descriptors.attributes.Attributes

public class Attributes
extends java.lang.Object

Some static methods for dealing with Viper Attributes.


Field Summary
static java.lang.String DEFAULT_NAMESPACE_QUALIFIER
          The default namespace qualifier to use with viper data.
static java.lang.String DEFAULT_NAMESPACE_URI
          The viper data URI
 
Constructor Summary
Attributes()
           
 
Method Summary
static void addAttributeType(java.lang.String name, java.lang.Class type)
           
static java.lang.Class getClassForAttribute(java.lang.String type)
           
static boolean isComposable(java.lang.String type)
          Tests to see if the given attribute type is composible.
static boolean isGoodValue(Attribute type, java.lang.String value)
          Tests to see if the string represents a possible value of the given attribute type.
static boolean isType(java.lang.String type)
          Determines if the specified string is a possible Attribute data type.
static java.lang.Object parseValue(Attribute type, java.lang.Object value)
          Converts from a String into the internal data type used by the attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE_URI

public static final java.lang.String DEFAULT_NAMESPACE_URI
The viper data URI

See Also:
Constant Field Values

DEFAULT_NAMESPACE_QUALIFIER

public static final java.lang.String DEFAULT_NAMESPACE_QUALIFIER
The default namespace qualifier to use with viper data. This is important, as xml parsers that don't understand namespaces may be looking for this as part of the element name.

See Also:
Constant Field Values
Constructor Detail

Attributes

public Attributes()
Method Detail

addAttributeType

public static void addAttributeType(java.lang.String name,
                                    java.lang.Class type)
Parameters:
name -
type -

getClassForAttribute

public static java.lang.Class getClassForAttribute(java.lang.String type)
Parameters:
type -
Returns:
Throws:
java.lang.IllegalArgumentException - If the given type isn't registered.

isComposable

public static boolean isComposable(java.lang.String type)
Tests to see if the given attribute type is composible.

Parameters:
type - the type of attribute to check
Returns:
false if it is not composable.
Throws:
java.lang.UnsupportedOperationException - if the type is improperly defined
java.lang.IllegalStateException - if the isComposable method of the type throws an exception.

isType

public static boolean isType(java.lang.String type)
Determines if the specified string is a possible Attribute data type.

Parameters:
type - The string to be tested.
Returns:
true if the string is a proper data type

isGoodValue

public static boolean isGoodValue(Attribute type,
                                  java.lang.String value)
Tests to see if the string represents a possible value of the given attribute type. Depends on the Attribute.possibleValueOf(String) method.

Parameters:
type - the attribute to check
value - the value to check
Returns:
false if it is a bad value or an unknown type.
Throws:
java.lang.UnsupportedOperationException - if possibleValueOf is not defined for the given type
java.lang.IllegalStateException - if the possibleValueOf method of the type throws an exception.

parseValue

public static java.lang.Object parseValue(Attribute type,
                                          java.lang.Object value)
Converts from a String into the internal data type used by the attribute. This works by invoking the appropriate Attribute class's "parseValue" command.

Parameters:
type - The attribute to test against.
value - The data to test. A String in the old format, or a org.w3c.dom.Element in the new format.
Returns:
a internal object
Throws:
java.lang.UnsupportedOperationException - if parseValue is not defined for the given attribute or value type
java.lang.IllegalStateException - if the parseValue method of the type throws an exception.