com.ibm.dse.base.types
Class AbstractPropertyDescriptor

java.lang.Object
  |
  +--com.ibm.dse.base.types.AbstractPropertyDescriptor
Direct Known Subclasses:
DatePropertyDescriptor, DoublePropertyDescriptor, FloatPropertyDescriptor, ICollPropertyDescriptor, IntegerPropertyDescriptor, KCollPropertyDescriptor, StringPropertyDescriptor

public abstract class AbstractPropertyDescriptor
extends java.lang.Object
implements PropertyDescription, TypeConstants, java.io.Externalizable

This class resides at the top of the PropertyDescriptor hierarchy and provides an abstract implementation of the PropertyDescription interface for Type specific PropertyDescriptors to extend.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable converters
          The converters known to this PropertyDescriptor
protected  java.util.Hashtable keyValuePairs
          The parameterization for this PropertyDescriptor, understood by concrete subclasses
 
Fields inherited from interface com.ibm.dse.base.types.TypeConstants
CONV_TYPE_DEFAULT, CONV_TYPE_HOST, CONV_TYPE_OUTPUT, CONV_TYPE_SER, CONV_TYPE_XML, disabled, hidden, isDisabled, isHidden, isMandatory, isOmitted, isReadOnly, mandatory, omitted, readOnly, TYPE_DEFAULT, TYPE_REGISTRY_INIT_SIZE
 
Constructor Summary
AbstractPropertyDescriptor()
          This constructor creates a AbstractPropertyDescriptor object.
AbstractPropertyDescriptor(java.lang.String name, java.util.Hashtable keyValuePairs)
          This constructor creates a PropertyDescriptor with the name passed.
AbstractPropertyDescriptor(java.lang.String name, java.util.Hashtable keyValuePairs, java.lang.String typeName)
          This constructor creates a PropertyDescriptor with the name passed.
 
Method Summary
 void applyDefaultDescriptor(PropertyDescription defaultDescriptor)
          Forces this PropertyDescriptor to inherit the business rules of the passed descriptor.
 void applyDefaultDescriptorForType(PropertyDescription defaultDescriptor)
          This method can be overwritten by specific subclasses if an additional behaviour is required.
abstract  java.lang.Object cloneDescriptee(java.lang.Object value)
          Returns an independent copy of the Object passed and is to be implementaed by Type specific subclass.
 java.lang.String formatToString(java.lang.Object value, java.lang.String conversionType)
          Returns the value passed as an Object, formatted as a String using the appropriate conversion type.
 java.lang.String formatToString(java.lang.Object value, java.lang.String conversionType, java.util.Locale locale)
          Returns the value passed as an Object, formatted as a String using the specified conversion type and the specified locale.
 void formatToWriter(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer)
          The value passed as an Object is formatted using the specified conversion type and writer passed as argument.
 void formatToWriter(java.lang.Object value, java.lang.String conversionType, java.io.Writer writer, java.util.Locale locale)
          The value passed as an Object is formatted using the specified conversion type and the specified locale by the writer passed as argument.
 Conversion getConversion(java.lang.String conversionType)
          Returns the converter which handles the specified conversion type, or null if the conversion type is not supported.
protected  Conversion getConverterFromConversionType(java.lang.String conversionType)
          Returns the converter for the conversion type passed, or the default converter if the requested conversion type is not supported.
 java.util.Enumeration getConverters()
          Returns an Enumeration of all converters associated with this PropertyDescriptor.
 java.lang.String getDescription()
          Returns the description of business object that this PropertyDescriptor describes.
 java.lang.Class getImplClass()
          Gets the class of the business object descripted by this PropertyDescription This method must be overwritten by specific descriptors.
 ElementState getInitialState()
          Returns the initial business state of the business object described by this PropertyDescriptor.
 java.lang.Object getInitialValue()
          Returns the initial value of the business object described by this PropertyDescriptor.
 java.lang.String getName()
          Returns the name of this PropertyDescriptor.
 java.util.Hashtable getParameters()
          Returns the keyValuePairs hashtable.
 Type getType()
          Returns the Type of business object that this PropertyDescriptor describes.
 Validation getValidator()
          Returns the validator responsible for handling validation of the business object described.
 TypedData initializeInstance(TypedData businessObject)
          Initializes the businessObject attributes
protected  void initializeState(ElementState iniState)
          Initializes the initialState attribute based on the attributes defined in the key value pairs.
 void readExternal(java.io.ObjectInput s)
          Invokes the object creation from an ObjectInput.
 void setConversion(Conversion converter)
          Convenience method to set the converter which handles the default conversion type.
 void setConversion(java.lang.String conversionType, Conversion converter)
          Sets the converter which handles the specified conversion type to that passed as argument.
protected  void setInitialState(ElementState iniState)
          Sets the initial business state for the PropertyDescriptor.
protected  void setInitialValue(java.lang.Object value)
          Sets the initial value for the PropertyDescriptor.
 void setName(java.lang.String aName)
          Sets the name attribute.
 void setValidator(Validation validator)
          Sets the validator to be employed by this PropertyDescriptor to that passed.
 java.lang.Object unformatFromReader(java.io.Reader reader, java.lang.String conversionType)
          Uses the reader passed to construct an Object of the correct Type using the appropriate conversion type.
 java.lang.Object unformatFromReader(java.io.Reader reader, java.lang.String conversionType, java.util.Locale locale)
          Uses the reader passed to construct an Object of the correct Type using the specified conversion type and the specified locale.
 java.lang.Object unformatFromString(java.lang.String value, java.lang.String conversionType)
          Converts the String passed to an Object using the appropriate conversion Type.
 java.lang.Object unformatFromString(java.lang.String value, java.lang.String conversionType, java.util.Locale locale)
          Converts the String passed to an Object using the specified conversion Type and the specified locale.
 java.lang.Object validate(java.lang.Object toValidate)
          Validates the Object passed by first unformatting and then applying business rules
 java.lang.Object validate(java.lang.Object toValidate, boolean useState)
          Validates the Object passed by first unformatting and then applying business rules.
 void writeExternal(java.io.ObjectOutput s)
          Provides concrete serialization handling for AbstractPropertyDescriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

converters

protected java.util.Hashtable converters
The converters known to this PropertyDescriptor

keyValuePairs

protected java.util.Hashtable keyValuePairs
The parameterization for this PropertyDescriptor, understood by concrete subclasses
Constructor Detail

AbstractPropertyDescriptor

public AbstractPropertyDescriptor()
This constructor creates a AbstractPropertyDescriptor object.

AbstractPropertyDescriptor

public AbstractPropertyDescriptor(java.lang.String name,
                                  java.util.Hashtable keyValuePairs)
                           throws DSETypeException
This constructor creates a PropertyDescriptor with the name passed.
Parameters:
name - String
Throws:
DSETypeException - Referenced Type can not be determined from class name.

AbstractPropertyDescriptor

public AbstractPropertyDescriptor(java.lang.String name,
                                  java.util.Hashtable keyValuePairs,
                                  java.lang.String typeName)
                           throws DSETypeException
This constructor creates a PropertyDescriptor with the name passed.
Parameters:
name - String
typeName - String
Throws:
DSETypeException - Referenced Type is not found.
Method Detail

applyDefaultDescriptor

public void applyDefaultDescriptor(PropertyDescription defaultDescriptor)
                            throws DSETypeException
Forces this PropertyDescriptor to inherit the business rules of the passed descriptor.

Any specific business behaviour defined is retained and will override that of the descriptor passed.

Specified by:
applyDefaultDescriptor in interface PropertyDescription
Parameters:
descriptor - PropertyDescription
Throws:
DSETypeException - PropertyDescriptor passed as argument is not valid.

applyDefaultDescriptorForType

public void applyDefaultDescriptorForType(PropertyDescription defaultDescriptor)
This method can be overwritten by specific subclasses if an additional behaviour is required.
Parameters:
descriptor - PropertyDescription

cloneDescriptee

public abstract java.lang.Object cloneDescriptee(java.lang.Object value)
                                          throws DSETypeException
Returns an independent copy of the Object passed and is to be implementaed by Type specific subclass.
Specified by:
cloneDescriptee in interface PropertyDescription
Parameters:
value - Object
Returns:
Object
Throws:
DSETypeException - Cloning is unsuccessful.

formatToString

public java.lang.String formatToString(java.lang.Object value,
                                       java.lang.String conversionType)
                                throws DSETypeException
Returns the value passed as an Object, formatted as a String using the appropriate conversion type.
Specified by:
formatToString in interface PropertyDescription
Parameters:
value - Object
conversionType - String
Returns:
String
Throws:
DSETypeException - Formatting is unsuccessful.

formatToString

public java.lang.String formatToString(java.lang.Object value,
                                       java.lang.String conversionType,
                                       java.util.Locale locale)
                                throws DSETypeException
Returns the value passed as an Object, formatted as a String using the specified conversion type and the specified locale.
Specified by:
formatToString in interface PropertyDescription
Parameters:
value - Object
conversionType - String
locale - Locale
Returns:
String
Throws:
DSETypeException - Formatting is unsuccessful.

formatToWriter

public void formatToWriter(java.lang.Object value,
                           java.lang.String conversionType,
                           java.io.Writer writer)
                    throws DSETypeException
The value passed as an Object is formatted using the specified conversion type and writer passed as argument.
Specified by:
formatToWriter in interface PropertyDescription
Parameters:
value - Object
conversionType - String
writer - Writer

formatToWriter

public void formatToWriter(java.lang.Object value,
                           java.lang.String conversionType,
                           java.io.Writer writer,
                           java.util.Locale locale)
                    throws DSETypeException
The value passed as an Object is formatted using the specified conversion type and the specified locale by the writer passed as argument.
Specified by:
formatToWriter in interface PropertyDescription
Parameters:
value - Object
conversionType - String
writer - Writer
locale - Locale
Throws:
DSETypeException - Formatting is unsuccessful.

getConversion

public Conversion getConversion(java.lang.String conversionType)
Returns the converter which handles the specified conversion type, or null if the conversion type is not supported.
Specified by:
getConversion in interface PropertyDescription
Parameters:
conversionType - String
Returns:
Conversion
Throws:
DSETypeException - Conversion type is not supported.

getConverterFromConversionType

protected Conversion getConverterFromConversionType(java.lang.String conversionType)
                                             throws DSETypeException
Returns the converter for the conversion type passed, or the default converter if the requested conversion type is not supported.

An exception is thrown if default conversion is not supported.

Returns:
java.lang.String

getConverters

public java.util.Enumeration getConverters()
Returns an Enumeration of all converters associated with this PropertyDescriptor.
Specified by:
getConverters in interface PropertyDescription
Returns:
Enumeration

getDescription

public java.lang.String getDescription()
Returns the description of business object that this PropertyDescriptor describes.
Specified by:
getDescription in interface PropertyDescription
Returns:
String

getImplClass

public java.lang.Class getImplClass()
                             throws DSETypeException
Gets the class of the business object descripted by this PropertyDescription This method must be overwritten by specific descriptors.
Specified by:
getImplClass in interface PropertyDescription
Returns:
java.lang.Class

getInitialState

public ElementState getInitialState()
Returns the initial business state of the business object described by this PropertyDescriptor.
Specified by:
getInitialState in interface PropertyDescription
Returns:
int

getInitialValue

public java.lang.Object getInitialValue()
Returns the initial value of the business object described by this PropertyDescriptor.
Specified by:
getInitialValue in interface PropertyDescription
Returns:
Object

getName

public java.lang.String getName()
Returns the name of this PropertyDescriptor.
Specified by:
getName in interface PropertyDescription
Returns:
String

getParameters

public java.util.Hashtable getParameters()
Returns the keyValuePairs hashtable.
Specified by:
getParameters in interface PropertyDescription
Returns:
java.util.Hashtable

getType

public Type getType()
Returns the Type of business object that this PropertyDescriptor describes.
Specified by:
getType in interface PropertyDescription
Returns:
Type

getValidator

public Validation getValidator()
Returns the validator responsible for handling validation of the business object described.
Specified by:
getValidator in interface PropertyDescription
Returns:
Validation

initializeInstance

public TypedData initializeInstance(TypedData businessObject)
                             throws DSETypeException
Initializes the businessObject attributes
Specified by:
initializeInstance in interface PropertyDescription
Parameters:
businessObject - com.ibm.dse.base.TypedData
Returns:
com.ibm.dse.base.TypedData

initializeState

protected void initializeState(ElementState iniState)
Initializes the initialState attribute based on the attributes defined in the key value pairs.

readExternal

public void readExternal(java.io.ObjectInput s)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Invokes the object creation from an ObjectInput.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
s - java.io.ObjectInput
Throws:
java.io.IOException. -  
java.lang.ClassNotFoundException. -  

setConversion

public void setConversion(Conversion converter)
                   throws DSETypeException
Convenience method to set the converter which handles the default conversion type.
Specified by:
setConversion in interface PropertyDescription
Parameters:
conversionType - String
converter - Conversion
Throws:
DSETypeException - Conversion type is already supported.

setConversion

public void setConversion(java.lang.String conversionType,
                          Conversion converter)
                   throws DSETypeException
Sets the converter which handles the specified conversion type to that passed as argument.
Specified by:
setConversion in interface PropertyDescription
Parameters:
conversionType - String
converter - Conversion
Throws:
DSETypeException - Conversion type is already supported.

setInitialState

protected void setInitialState(ElementState iniState)
Sets the initial business state for the PropertyDescriptor.
Parameters:
initialState - int

setInitialValue

protected void setInitialValue(java.lang.Object value)
Sets the initial value for the PropertyDescriptor.
Parameters:
value - Object

setName

public void setName(java.lang.String aName)
Sets the name attribute.
Parameters:
aName - java.lang.String

setValidator

public void setValidator(Validation validator)
                  throws DSETypeException
Sets the validator to be employed by this PropertyDescriptor to that passed.
Specified by:
setValidator in interface PropertyDescription
Parameters:
validator - Validation
Throws:
DSETypeException - Validator cannot validate the business object described.

unformatFromReader

public java.lang.Object unformatFromReader(java.io.Reader reader,
                                           java.lang.String conversionType)
                                    throws DSETypeException
Uses the reader passed to construct an Object of the correct Type using the appropriate conversion type. Parameters required by the specific type converter may be taken from the owner descriptor by using the descriptor passed as argument.
Specified by:
unformatFromReader in interface PropertyDescription
Parameters:
reader - Reader
conversionType - String
Returns:
Object
Throws:
DSETypeException - Unformatting is unsuccessful.

unformatFromReader

public java.lang.Object unformatFromReader(java.io.Reader reader,
                                           java.lang.String conversionType,
                                           java.util.Locale locale)
                                    throws DSETypeException
Uses the reader passed to construct an Object of the correct Type using the specified conversion type and the specified locale.
Specified by:
unformatFromReader in interface PropertyDescription
Parameters:
reader - Reader
conversionType - String
locale - Locale
Returns:
Object
Throws:
DSETypeException - Unformatting is unsuccessful.

unformatFromString

public java.lang.Object unformatFromString(java.lang.String value,
                                           java.lang.String conversionType)
                                    throws DSETypeException
Converts the String passed to an Object using the appropriate conversion Type.
Specified by:
unformatFromString in interface PropertyDescription
Parameters:
value - String
conversionType - String
Returns:
Object
Throws:
DSETypeException - Unformatting is unsuccessful.

unformatFromString

public java.lang.Object unformatFromString(java.lang.String value,
                                           java.lang.String conversionType,
                                           java.util.Locale locale)
                                    throws DSETypeException
Converts the String passed to an Object using the specified conversion Type and the specified locale.
Specified by:
unformatFromString in interface PropertyDescription
Parameters:
value - String
conversionType - String
locale - Locale
Returns:
Object
Throws:
DSETypeException - Unformatting is unsuccessful.

validate

public java.lang.Object validate(java.lang.Object toValidate)
                          throws DSETypeException
Validates the Object passed by first unformatting and then applying business rules

If successful, the Object is returned, otherwise an appropriate exception is thrown.

Specified by:
validate in interface PropertyDescription
Parameters:
toValidate - Object
Returns:
Object
Throws:
DSETypeException - Validation is unsuccessful.

validate

public java.lang.Object validate(java.lang.Object toValidate,
                                 boolean useState)
                          throws DSETypeException
Validates the Object passed by first unformatting and then applying business rules. A previous validation based on the initial state attribute is performed if the boolean passed is true.

If successful, the Object is returned, otherwise an appropriate exception is thrown.

Specified by:
validate in interface PropertyDescription
Parameters:
toValidate - Object
useState - boolean
Returns:
Object
Throws:
DSETypeException - Validation is unsuccessful.

writeExternal

public void writeExternal(java.io.ObjectOutput s)
                   throws java.io.IOException
Provides concrete serialization handling for AbstractPropertyDescriptor.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
s - java.io.ObjectOutput
Throws:
java.io.IOException. -