com.codestreet.messageforge
Class RFldMsgObjHashtable

java.lang.Object
  extended bycom.codestreet.messageforge.RFld
      extended bycom.codestreet.messageforge.RFldHashtable
          extended bycom.codestreet.messageforge.RFldMsgObjHashtable
All Implemented Interfaces:
RFldInterface, java.io.Serializable

public class RFldMsgObjHashtable
extends RFldHashtable

Class to represent a Hashtable of RMsg.

Author:
Jawaid Hakim.
See Also:
RFldHashtable, Serialized Form

Field Summary
protected  java.lang.Class cls_
           
protected  java.util.Hashtable dataObj_
          Data.
 
Fields inherited from class com.codestreet.messageforge.RFld
desc_, fieldId_, locked_, name_, optional_, propertyName_, tags_, transient_, valSet_
 
Constructor Summary
RFldMsgObjHashtable()
          Default constructor.
RFldMsgObjHashtable(java.lang.Class cls, java.lang.String name, int fieldId)
          Constructor.
RFldMsgObjHashtable(java.lang.Class cls, java.lang.String name, int fieldId, java.lang.String desc)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object anObject)
          Check if another field is equal to this field.
 RMsg get(java.lang.String key)
          Get an element from the hashtable.
 java.lang.Class getClassObject()
          Get the Class of the data for this object.
 java.lang.String getTag()
          Get the XML tag for this field type.
 RFldType getType()
          Get field type.
 java.util.Hashtable getValue()
          Get data.
 java.util.Hashtable getValueAsHashtable()
          Get the field value as a java.util.Hashtable.
 java.lang.Object getValueAsObject()
          Get the field value as an object.
 java.lang.String getValueAsString()
          Get the field value as a string.
 int hashCode()
          Returns the hash code value for the field.
 void reset()
          Reset the field value.
 RFld set(org.jdom.Element newData)
          Set data.
 RFld set(java.util.Hashtable newData)
          Set data.
 RFld set(java.lang.Object newData)
          Set data.
static void setTag(java.lang.String tag)
          Set the XML tag for this field type.
 int size()
          Get the number of elements in the hashtable.
 void validate()
          Validate against constraints.
 
Methods inherited from class com.codestreet.messageforge.RFldHashtable
marshal
 
Methods inherited from class com.codestreet.messageforge.RFld
addConstraint, buildMinMaxConstraintKey, getConstraint, getConstraintCount, getDesc, getId, getName, getOptional, getPropertyName, getTags, getTransient, isConstrained, isLocked, isProperty, isValSet, marshal, setId, setLocked, setName, setOptional, setPropertyName, setTags, setTransient, setXmlAttrNames, setXmlTags
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataObj_

protected java.util.Hashtable dataObj_
Data.


cls_

protected java.lang.Class cls_
Constructor Detail

RFldMsgObjHashtable

public RFldMsgObjHashtable()
Default constructor.


RFldMsgObjHashtable

public RFldMsgObjHashtable(java.lang.Class cls,
                           java.lang.String name,
                           int fieldId)
Constructor.

Parameters:
cls - Class object of hashtable entries.
name - Field name.
fieldId - Field id. Field ids must be either 0 to indicate that there is no id on the field, or greater. In addition, field ids must be unique within a messages - no two fields are allowed to have the same field id.

RFldMsgObjHashtable

public RFldMsgObjHashtable(java.lang.Class cls,
                           java.lang.String name,
                           int fieldId,
                           java.lang.String desc)
Constructor.

Parameters:
cls - Class object of hashtable entries.
name - Field name.
fieldId - Field id. Field ids must be either 0 to indicate that there is no id on the field, or greater. In addition, field ids must be unique within a messages - no two fields are allowed to have the same field id.
desc - Field description.
Method Detail

getType

public final RFldType getType()
Get field type.

Specified by:
getType in interface RFldInterface
Specified by:
getType in class RFld
Returns:
Field type MSGOBJHASHTABLE.
See Also:
RFldType

getClassObject

public java.lang.Class getClassObject()
Get the Class of the data for this object.

Returns:
Class of the data for this object.

equals

public boolean equals(java.lang.Object anObject)
Check if another field is equal to this field. Equality is defined as the fields having the same string representation. A short cut that needs to be fixed for cases where the string representation is rounding off numbers etc.

Specified by:
equals in class RFld
Parameters:
anObject - Another field.
Returns:
true if another field is equal to this field. Otherwise, returns false.

size

public int size()
Get the number of elements in the hashtable.

Returns:
Number of elements in the hashtable. If the value is not set returns -1.

get

public RMsg get(java.lang.String key)
Get an element from the hashtable.

Parameters:
key - Key.
Returns:
Specified element. Returns null if the index is out of bounds of the value is not set;
See Also:
size()

hashCode

public int hashCode()
Returns the hash code value for the field.

Specified by:
hashCode in class RFld
Returns:
A hash code value for the field.

reset

public void reset()
           throws FieldValidationException
Reset the field value.

Specified by:
reset in class RFld
Throws:
FieldValidationException
See Also:
RFld.isValSet()

set

public RFld set(java.lang.Object newData)
         throws FieldValidationException
Set data.

Specified by:
set in interface RFldInterface
Specified by:
set in class RFld
Parameters:
newData - New data.
Returns:
Reference to self so method chaining can be used.
Throws:
FieldValidationException

set

public RFld set(java.util.Hashtable newData)
         throws FieldValidationException
Set data.

Specified by:
set in class RFldHashtable
Parameters:
newData - New value.
Returns:
Reference to self so method chaining can be used.
Throws:
FieldValidationException

set

public RFld set(org.jdom.Element newData)
         throws FieldValidationException
Set data.

Specified by:
set in interface RFldInterface
Specified by:
set in class RFld
Parameters:
newData - New data.
Returns:
Reference to self so method chaining can be used.
Throws:
FieldValidationException

validate

public void validate()
              throws FieldValidationException
Validate against constraints. A field is valid if either it's value is set and satisfies all constraints, or the the field is optional.

Specified by:
validate in class RFld
Throws:
FieldValidationException

getValue

public java.util.Hashtable getValue()
Get data.

Returns:
data Data. If the value of the field has not been set then null is returned.

getValueAsObject

public java.lang.Object getValueAsObject()
Get the field value as an object.

Returns:
Field value as an object. Reference to data is passed out so be very careful about modifying the data. If the value of the field has not been set then null is returned.

getValueAsString

public java.lang.String getValueAsString()
Get the field value as a string. Throws an exception if the field value is not set.

Specified by:
getValueAsString in class RFld
Returns:
Field value as a string.

getValueAsHashtable

public java.util.Hashtable getValueAsHashtable()
                                        throws FieldValidationException
Get the field value as a java.util.Hashtable. Throws an exception if the field value is not set.

Returns:
Field value as a java.util.Hashtable.
Throws:
FieldValidationException

getTag

public final java.lang.String getTag()
Get the XML tag for this field type.

Specified by:
getTag in class RFld
Returns:
XML tag for this field type.

setTag

public static void setTag(java.lang.String tag)
Set the XML tag for this field type.

Parameters:
tag - New XML tag for this field type.


Copyright © 2003-2006 CodeStreet. All Rights Reserved.