© 2002 BEA Systems, Inc.


com.bea.p13n.property
Class AbstractPropertyDefinition

java.lang.Object
  |
  +--com.bea.p13n.property.AbstractPropertyDefinition

public abstract class AbstractPropertyDefinition
extends java.lang.Object
implements PropertyDefinition, java.io.Serializable

Default implementation of a PropertyDefinition.

See Also:
Serialized Form

Constructor Summary
AbstractPropertyDefinition()
          Default constructor
AbstractPropertyDefinition(java.lang.String descriptionArg, int typeArg, boolean multiValuedArg, boolean restrictedArg, java.util.Collection restrictedValuesArg, java.lang.Object defaultValueArg)
          Constructor to initialize attributes
 
Method Summary
 int compareTo(java.lang.Object o)
          Implementation of Object.compareTo(); returns 0 if the two objects are equal; attempts to determine an ordering otherwise and returns -1 if this object is less than the comparison object, and 1 if this object is greater than the comparison object.
protected  int determinePropertyType(java.lang.Object value)
          Determines if the data type of the property value is a known property type.
 boolean equals(java.lang.Object o)
          Equality operator.
 java.lang.Object getDefaultValue()
          Get the default value for this property.
 java.lang.String getDescription()
          Get the description of this property
 java.util.Collection getRestrictedValues()
          Get the allowable values, if this property is restricted.
 int getType()
          Get the datatype of the property
 int hashCode()
          Computes a hashcode for this object based on its attributes
 boolean isMultiValued()
          Can this property support multiple values?
 boolean isRestricted()
          Is this property restricted to a certain list of values?
 void setDefaultValue(java.lang.Object o)
          Set the default value for this property.
 void setDescription(java.lang.String s)
          Set the description of this property
 void setMultiValued(boolean b)
          Set if this property support multiple values?
 void setRestricted(boolean b)
          Set if this property restricted to a certain list of values?
 void setRestrictedValues(java.util.Collection c)
          Set the allowable values, if this property is restricted
 void setType(int i)
          Set the datatype of the property
 java.lang.String toString()
          Basic toString method
 void validate(java.lang.Object value)
          Validates the given value against the property definition.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPropertyDefinition

public AbstractPropertyDefinition()
Default constructor

AbstractPropertyDefinition

public AbstractPropertyDefinition(java.lang.String descriptionArg,
                                  int typeArg,
                                  boolean multiValuedArg,
                                  boolean restrictedArg,
                                  java.util.Collection restrictedValuesArg,
                                  java.lang.Object defaultValueArg)
Constructor to initialize attributes
Method Detail

getDescription

public java.lang.String getDescription()
Get the description of this property
Specified by:
getDescription in interface PropertyDefinition


setDescription

public void setDescription(java.lang.String s)
Set the description of this property


getType

public int getType()
Get the datatype of the property
Specified by:
getType in interface PropertyDefinition


setType

public void setType(int i)
Set the datatype of the property


isMultiValued

public boolean isMultiValued()
Can this property support multiple values?
Specified by:
isMultiValued in interface PropertyDefinition


setMultiValued

public void setMultiValued(boolean b)
Set if this property support multiple values?


isRestricted

public boolean isRestricted()
Is this property restricted to a certain list of values?
Specified by:
isRestricted in interface PropertyDefinition


setRestricted

public void setRestricted(boolean b)
Set if this property restricted to a certain list of values?


getRestrictedValues

public java.util.Collection getRestrictedValues()
Get the allowable values, if this property is restricted. Note: this does a shallow clone to prevent the collection from being modified, but if any property values are mutable, care must be taken not to modify them.
Specified by:
getRestrictedValues in interface PropertyDefinition

Returns:
a Collection of allowable values, or null if there are none

setRestrictedValues

public void setRestrictedValues(java.util.Collection c)
Set the allowable values, if this property is restricted


getDefaultValue

public java.lang.Object getDefaultValue()
Get the default value for this property. If it is multivalued, this might be a collection of values. Note: this returns a clone of the default value; if it is a collection, and the property values are mutable objects, care must be taken not to modify them.
Specified by:
getDefaultValue in interface PropertyDefinition

Returns:
the default value, or null if there is none

setDefaultValue

public void setDefaultValue(java.lang.Object o)
Set the default value for this property.


validate

public void validate(java.lang.Object value)
              throws PropertyValidationException
Validates the given value against the property definition. Compares datatypes, and checks against allowable values.
Specified by:
validate in interface PropertyDefinition

Throws:
PropertyValidationException - if the value is not valid

equals

public boolean equals(java.lang.Object o)
Equality operator.

Returns:
true if the compareTomethod would return 0 for this target
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Computes a hashcode for this object based on its attributes

Returns:
the calculated hashcode
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Implementation of Object.compareTo(); returns 0 if the two objects are equal; attempts to determine an ordering otherwise and returns -1 if this object is less than the comparison object, and 1 if this object is greater than the comparison object. Because Property Definitions do not have an inherent order, any non-zero value is somewhat arbitrary.


determinePropertyType

protected int determinePropertyType(java.lang.Object value)
Determines if the data type of the property value is a known property type. Defaults to USER_DEFINED if the type of the value cannot be determined.

Parameters:
value -  
Returns:
int which is one of the datatype constants defined in the PropertyDefinition interface

toString

public java.lang.String toString()
Basic toString method

Returns:
a displayable String representing this property definition
Overrides:
toString in class java.lang.Object

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved