org.openfast.template
Class Scalar

java.lang.Object
  extended by org.openfast.template.Field
      extended by org.openfast.template.Scalar
All Implemented Interfaces:
java.io.Serializable

public class Scalar
extends Field

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openfast.template.Field
id, key, name, optional
 
Constructor Summary
Scalar(QName name, Type type, OperatorCodec operatorCodec, ScalarValue defaultValue, boolean optional)
          Scalar constructor - sets the dictionary as global and validates the entries
Scalar(QName name, Type type, Operator operator, ScalarValue defaultValue, boolean optional)
           
Scalar(java.lang.String name, Type type, Operator operator, ScalarValue defaultValue, boolean optional)
          Scalar constructor - sets the dictionary as global and validates the entries
 
Method Summary
 FieldValue createValue(java.lang.String value)
          createValue method declaration
 FieldValue decode(java.io.InputStream in, Group template, Context context, BitVectorReader presenceMapReader)
          FieldValue decode method declaration
 ScalarValue decode(ScalarValue previousValue)
           
 ScalarValue decodeValue(ScalarValue newValue, ScalarValue previousValue)
           
 byte[] encode(FieldValue fieldValue, Group template, Context context, BitVectorBuilder presenceMapBuilder)
          byte[] encode method declaration
 boolean equals(java.lang.Object other)
           
 ScalarValue getBaseValue()
           
 ScalarValue getDefaultValue()
           
 java.lang.String getDictionary()
           
 Operator getOperator()
           
 OperatorCodec getOperatorCodec()
           
 Type getType()
           
 TypeCodec getTypeCodec()
           
 java.lang.String getTypeName()
          getTypeName method declaration
 java.lang.Class getValueType()
          getValueType method declaration
 int hashCode()
           
 boolean isPresenceMapBitSet(byte[] encoding, FieldValue fieldValue)
          isPresenceMapBitSet method declaration
 java.lang.String serialize(ScalarValue value)
           
 void setDictionary(java.lang.String dictionary)
          Sets the dictionary to the passed string
 java.lang.String toString()
           
 boolean usesPresenceMapBit()
          usesPresenceMapBit method declaration
 
Methods inherited from class org.openfast.template.Field
addAttribute, getAttribute, getId, getKey, getName, getQName, hasAttribute, isOptional, isPresent, setId, setKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scalar

public Scalar(java.lang.String name,
              Type type,
              Operator operator,
              ScalarValue defaultValue,
              boolean optional)
Scalar constructor - sets the dictionary as global and validates the entries

Parameters:
name - The name of Scalar as a string
type - The type of this Scalar
operator - Which operator object is being used
defaultValue - The default value of the ScalarValue
optional - Determines if the Scalar is required or not for the data

Scalar

public Scalar(QName name,
              Type type,
              Operator operator,
              ScalarValue defaultValue,
              boolean optional)

Scalar

public Scalar(QName name,
              Type type,
              OperatorCodec operatorCodec,
              ScalarValue defaultValue,
              boolean optional)
Scalar constructor - sets the dictionary as global and validates the entries

Parameters:
name - The name of Scalar as a string
type - The type of the scalar field
operatorCodec - Which operatorCodec object is being used
defaultValue - The default value of the ScalarValue
optional - Determines if the Scalar is required or not for the data
Method Detail

getType

public Type getType()
Returns:
Returns the type as a string

getOperatorCodec

public OperatorCodec getOperatorCodec()
Returns:
Returns the Operator object

getOperator

public Operator getOperator()
Returns:
Returns the operator name as a string

encode

public byte[] encode(FieldValue fieldValue,
                     Group template,
                     Context context,
                     BitVectorBuilder presenceMapBuilder)
Description copied from class: Field
byte[] encode method declaration

Specified by:
encode in class Field
Parameters:
fieldValue - The Field value
template - The Group object
context - The previous object to keep the data in sync
presenceMapBuilder - The BitVector builder
Returns:
byte encoding of field
Throws:
Throws - RuntimeException if the encoding fails - will print to console the name of the scalar to fail

getDictionary

public java.lang.String getDictionary()
Returns:
Returns the dictionary as a string

decodeValue

public ScalarValue decodeValue(ScalarValue newValue,
                               ScalarValue previousValue)
Parameters:
newValue -
previousValue - the previous value that was decoded
Returns:
the actual value given the previous value and newly decoded value

getDefaultValue

public ScalarValue getDefaultValue()
Returns:
Returns the defaultValue of the current ScalarValue

decode

public ScalarValue decode(ScalarValue previousValue)
Parameters:
previousValue - The previousValue of the ScalarValue
Returns:
Depending on the operator, various ScalarValues could be returned

usesPresenceMapBit

public boolean usesPresenceMapBit()
Description copied from class: Field
usesPresenceMapBit method declaration

Specified by:
usesPresenceMapBit in class Field
Returns:
Returns true

isPresenceMapBitSet

public boolean isPresenceMapBitSet(byte[] encoding,
                                   FieldValue fieldValue)
Description copied from class: Field
isPresenceMapBitSet method declaration

Specified by:
isPresenceMapBitSet in class Field
Parameters:
encoding - The byte array to check if it is present
fieldValue - The fieldValue object
Returns:
Returns true if the byte array has a length

decode

public FieldValue decode(java.io.InputStream in,
                         Group template,
                         Context context,
                         BitVectorReader presenceMapReader)
Description copied from class: Field
FieldValue decode method declaration

Specified by:
decode in class Field
Parameters:
in - The InputStream to be decoded
template - The Group object
context - The previous object to keep the data in sync
presenceMapReader -
Returns:
Returns the null if the Operator is constant and the optional boolean is true and the present boolean is true, otherwise decodes the previousValue and returns the FieldValue object after decoding

setDictionary

public void setDictionary(java.lang.String dictionary)
Sets the dictionary to the passed string

Parameters:
dictionary - The string to be stored as the dictionary

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
Returns the string 'Scalar [name=X, operator=X, dictionary=X]'

getValueType

public java.lang.Class getValueType()
Description copied from class: Field
getValueType method declaration

Specified by:
getValueType in class Field
Returns:
Returns the class of the current ScalarValue

createValue

public FieldValue createValue(java.lang.String value)
Description copied from class: Field
createValue method declaration

Specified by:
createValue in class Field
Parameters:
value - Creates a FieldValue of the passed value
Returns:
Returns the FieldValue object with the passed value

getTypeName

public java.lang.String getTypeName()
Description copied from class: Field
getTypeName method declaration

Specified by:
getTypeName in class Field
Returns:
Returns the string 'scalar'

getBaseValue

public ScalarValue getBaseValue()
Returns:
Returns the initialValue of the current ScalarValue object

getTypeCodec

public TypeCodec getTypeCodec()
Returns:
Returns the type of the Codec

serialize

public java.lang.String serialize(ScalarValue value)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2006-2008 The LaSalle Technology Group, LLC. All Rights Reserved.