viper.api.datatypes
Class InstanceOfConstraint

java.lang.Object
  extended byviper.api.datatypes.InstanceOfConstraint
All Implemented Interfaces:
AttrValueWrapper
Direct Known Subclasses:
AttributeBbox, AttributeEllipse, AttributeObox, AttributeWrapperOmega, Bvalue, CircleWrapper, Dvalue, Fvalue, Point, Polygon, Svalue

public class InstanceOfConstraint
extends java.lang.Object
implements AttrValueWrapper

A simple param for Attributes that constrains the value to instances of a given class or interface. It defaults to java.lang.Object, meaning that it allows any java object as a value.


Constructor Summary
InstanceOfConstraint()
          Constructs a new constraint that accepts any class that is a child of Object.
InstanceOfConstraint(java.lang.Class constraint)
          Creates a new InstanceOfConstraint with the given class as the constraint.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests to see if the specified object contains the same constraint.
 java.lang.Object getObjectValue(java.lang.Object o)
          Returns the specified object, as it is assumed to be of the same type.
 int hashCode()
          Gets a hash code for the type.
 java.lang.Object setAttributeValue(java.lang.Object o)
          Converts the object from external/unencoded form into internal/encoded form, while checking to make sure it is valid.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceOfConstraint

public InstanceOfConstraint(java.lang.Class constraint)
Creates a new InstanceOfConstraint with the given class as the constraint.

Parameters:
constraint - the class that any value must be an instance of

InstanceOfConstraint

public InstanceOfConstraint()
Constructs a new constraint that accepts any class that is a child of Object.

Method Detail

getObjectValue

public java.lang.Object getObjectValue(java.lang.Object o)
Returns the specified object, as it is assumed to be of the same type.

Specified by:
getObjectValue in interface AttrValueWrapper
Parameters:
o -
Returns:
the unencoded value
See Also:
AttrValueWrapper.getObjectValue(Object)

setAttributeValue

public java.lang.Object setAttributeValue(java.lang.Object o)
Description copied from interface: AttrValueWrapper
Converts the object from external/unencoded form into internal/encoded form, while checking to make sure it is valid.

Specified by:
setAttributeValue in interface AttrValueWrapper
Parameters:
o - the new value to set
Returns:
The object in internal format
See Also:
AttrValueWrapper.setAttributeValue(Object)

equals

public boolean equals(java.lang.Object o)
Tests to see if the specified object contains the same constraint.

Parameters:
o - the object to compare with
Returns:
true if o constrians the types to the same class as this one

hashCode

public int hashCode()
Gets a hash code for the type.

Returns:
constraint.hashCode()