com.codestreet.messageforge
Class RFldTibrvMsg

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

public class RFldTibrvMsg
extends RFld

Class to represent a TibrvMsg field.

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

Field Summary
protected  com.tibco.tibrv.TibrvMsg dataObj_
          Data.
 
Fields inherited from class com.codestreet.messageforge.RFld
desc_, fieldId_, locked_, name_, optional_, propertyName_, tags_, transient_, valSet_
 
Constructor Summary
RFldTibrvMsg()
          Default constructor.
RFldTibrvMsg(java.lang.String name, int fieldId)
          Constructor.
RFldTibrvMsg(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.
static boolean equals(com.tibco.tibrv.TibrvMsg first, com.tibco.tibrv.TibrvMsg second)
          Recursive method to compare two TibrvMsg.
 java.lang.String getTag()
          Get the XML tag for this field type.
 RFldType getType()
          Get field type.
static RFldType getType(java.lang.String xmlTag)
          Get the RFldType object corresponding to the specified XML field tag.
 com.tibco.tibrv.TibrvMsg getValue()
          Get data.
 java.util.Hashtable getValueAsHashtable()
          Get the field value as a java.util.Hashtable.
protected  java.util.Hashtable getValueAsHashtable(com.tibco.tibrv.TibrvMsg rvMsg)
          Get the value of a TibrvMsg as a java.util.Hashtable.
 java.lang.Object getValueAsObject()
          Get the field value as an object.
 java.lang.Object getValueAsObject(java.lang.String name, java.lang.String separator)
          Get the value of a nested field 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 marshal(java.io.Writer writer, int indentLevel, java.lang.String indent, boolean newLines, boolean expandEmptyElements)
          Write the field as XML to target writer.
 void reset()
          Reset the field value.
 RFld set(byte[] newData)
          Set data.
 RFld set(org.jdom.Element elem)
          Set the field value from a JDOM element.
 RFld set(java.util.Hashtable newData)
          Set data.
static void set(java.util.Hashtable source, com.tibco.tibrv.TibrvMsg target)
          Set data.
 RFld set(java.lang.Object newData)
          Set data.
 RFld set(com.tibco.tibrv.TibrvMsg newData)
          Set data.
static void setTag(java.lang.String tag)
          Set the XML tag for this field type.
 void validate()
          Validate against constraints.
 void validate(java.util.Hashtable newData)
          Check if a new value will satifsy constraints.
 void validate(com.tibco.tibrv.TibrvMsg newData)
          Check if a new value will satifsy constraints.
 
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 com.tibco.tibrv.TibrvMsg dataObj_
Data.

Constructor Detail

RFldTibrvMsg

public RFldTibrvMsg()
Default constructor.


RFldTibrvMsg

public RFldTibrvMsg(java.lang.String name,
                    int fieldId)
Constructor.

Parameters:
name - Field name. Field names must follow the TibrvMsg field naming conventions.
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.
See Also:
TibrvMsg

RFldTibrvMsg

public RFldTibrvMsg(java.lang.String name,
                    int fieldId,
                    java.lang.String desc)
Constructor.

Parameters:
name - Field name. Field names must follow the TibrvMsg field naming conventions.
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.
See Also:
TibrvMsg
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 MSG.
See Also:
RFldType

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.

equals

public static boolean equals(com.tibco.tibrv.TibrvMsg first,
                             com.tibco.tibrv.TibrvMsg second)
Recursive method to compare two TibrvMsg. The native equals method of TibrvMsg compares object references. We want to compare object values. This method compares the value of each field, calling itself recursively when comparing nested TibrvMsg fields.

Parameters:
first - First TibrvMsg.
second - Second TibrvMsg.
Returns:
true if the two TibrvMsg instances have the same number of fields, and each field has identical type and value. Otherwise, returns false.

hashCode

public int hashCode()
Returns the hash code value for the field. Since the equals method is using the comparison of the string representation of the tibrv message then the hashcode is the hashcode of this string.

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(byte[] newData)
         throws FieldValidationException
Set data.

Parameters:
newData - New data.
Throws:
FieldValidationException

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(com.tibco.tibrv.TibrvMsg newData)
         throws FieldValidationException
Set data.

Parameters:
newData - New data.
Throws:
FieldValidationException

set

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

Parameters:
newData - New data.
Throws:
FieldValidationException

set

public static void set(java.util.Hashtable source,
                       com.tibco.tibrv.TibrvMsg target)
                throws ProtocolException
Set data.

Parameters:
source - Source java.util.Hashtable.
target - Target com.tibco.tibrv.TibrvMsg.
Throws:
ProtocolException

set

public final RFld set(org.jdom.Element elem)
               throws FieldValidationException
Set the field value from a JDOM element.

Specified by:
set in interface RFldInterface
Specified by:
set in class RFld
Parameters:
elem - Field value as a JDOM element.
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

validate

public void validate(com.tibco.tibrv.TibrvMsg newData)
              throws FieldValidationException
Check if a new value will satifsy constraints.

Parameters:
newData - New value.
Throws:
FieldValidationException

validate

public void validate(java.util.Hashtable newData)
              throws FieldValidationException
Check if a new value will satifsy constraints.

Parameters:
newData - New value.
Throws:
FieldValidationException

getValue

public com.tibco.tibrv.TibrvMsg getValue()
Get data.

Returns:
data Data. Returns null if the field value is not set.

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. Returns null if the field value is not set

getValueAsObject

public java.lang.Object getValueAsObject(java.lang.String name,
                                         java.lang.String separator)
Get the value of a nested field as an object. The name of the field can indicate nesting of any arbitrary level. For example, if the TibrvMsg field has the following content:
Content
[
X
y [
y
]
]
then calling this method with the field name 'X.y' and separator "." will return the value of the field y nested within X.

Parameters:
name - Field name.
separator - Field name separator.
Returns:
Value of a nested field as an object. Returns null if the field value is not set.

getValueAsString

public java.lang.String getValueAsString()
Get the field value as a string.

Specified by:
getValueAsString in class RFld
Returns:
Field value as a string. Returns null if the field value is not set

getValueAsHashtable

public java.util.Hashtable getValueAsHashtable()
                                        throws FieldValidationException
Get the field value as a java.util.Hashtable. Every field type that is not directly supported within Tibrv - every field with type greater than or equal to RFldType.USER_FIRST - and including fields of type TibrvMsg will implement this method. Throws an exception if the nested field value is not set.

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

getValueAsHashtable

protected java.util.Hashtable getValueAsHashtable(com.tibco.tibrv.TibrvMsg rvMsg)
                                           throws FieldValidationException
Get the value of a TibrvMsg as a java.util.Hashtable.

Returns:
Value of TibrvMsg as java.util.Hashtable. Returns null if the field value is not set.
Throws:
FieldValidationException

marshal

public void marshal(java.io.Writer writer,
                    int indentLevel,
                    java.lang.String indent,
                    boolean newLines,
                    boolean expandEmptyElements)
             throws ConverterException
Write the field as XML to target writer.

Specified by:
marshal in interface RFldInterface
Overrides:
marshal in class RFld
Parameters:
writer - Output target.
indent - Indentation.
newLines - Newlines are inserted after each element if true.
expandEmptyElements - Empty elements - elements with no content - are expanded if true.
Throws:
ConverterException

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.

getType

public static final RFldType getType(java.lang.String xmlTag)
Get the RFldType object corresponding to the specified XML field tag.

Parameters:
xmlTag - XML tag of field.
Returns:
RFldType object corresponding to the specified XML field tag. Returns null if the corresponding RFldType is not defined.


Copyright © 2003-2006 CodeStreet. All Rights Reserved.