ca.uhn.hl7v2.model
Class AbstractPrimitive

java.lang.Object
  extended by ca.uhn.hl7v2.model.AbstractType
      extended by ca.uhn.hl7v2.model.AbstractPrimitive
All Implemented Interfaces:
Primitive, Type, Serializable
Direct Known Subclasses:
AbstractTextPrimitive, DT, GenericPrimitive, ID, IS, NULLDT, TM, TSComponentOne

public abstract class AbstractPrimitive
extends AbstractType
implements Primitive

Base class for Primitives. Performs validation in setValue().

Author:
Bryan Tripp
See Also:
Serialized Form

Constructor Summary
AbstractPrimitive(Message message)
           
 
Method Summary
 void clear()
          Clears all data from this type
 String encode()
          Encodes this type using HL7 encoding.
 String getValue()
          Returns a String representation of the value of this field.
 void parse(String string)
           Parses the string into this type and replaces the current contents with the parsed value.
 void setValue(String theValue)
          Sets the value of this Primitive, first performing validation as specified by getMessage().getValidationContext().
 String toString()
          Returns the value of getValue()
 
Methods inherited from class ca.uhn.hl7v2.model.AbstractType
getExtraComponents, getMessage, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ca.uhn.hl7v2.model.Type
getExtraComponents, getMessage, getName
 

Constructor Detail

AbstractPrimitive

public AbstractPrimitive(Message message)
Parameters:
message - message to which this type belongs
Method Detail

toString

public String toString()
Returns the value of getValue()

Overrides:
toString in class AbstractType
See Also:
Object.toString()

getValue

public String getValue()
Description copied from interface: Primitive
Returns a String representation of the value of this field.

Specified by:
getValue in interface Primitive
See Also:
Primitive.getValue()

setValue

public void setValue(String theValue)
              throws DataTypeException
Sets the value of this Primitive, first performing validation as specified by getMessage().getValidationContext(). No validation is performed if getMessage() returns null.

Specified by:
setValue in interface Primitive
Throws:
DataTypeException - if the given value is not valid in this context.
See Also:
Primitive.setValue(String)

encode

public String encode()
              throws HL7Exception
Encodes this type using HL7 encoding.

Specified by:
encode in interface Type
Overrides:
encode in class AbstractType
Throws:
HL7Exception

parse

public void parse(String string)
           throws HL7Exception

Parses the string into this type and replaces the current contents with the parsed value. This method accepts HL7 encoded text and treats its input as such.

Note that this method is subtly different from calling Primitive.setValue(String), but can be quite powerful. For example, using the argument of "milk&cookies" on an ST datatype:

This method makes use of the parser which is stored within the enclosing Message. At this time, only PipeParsers are supported.

Specified by:
parse in interface Type
Overrides:
parse in class AbstractType
Throws:
HL7Exception

clear

public void clear()
Clears all data from this type

Specified by:
clear in interface Type
Overrides:
clear in class AbstractType


Copyright © 2001-2012 University Health Network. All Rights Reserved.