ca.uhn.hl7v2.model
Class Varies

java.lang.Object
  extended by ca.uhn.hl7v2.model.Varies
All Implemented Interfaces:
Type, java.io.Serializable

public class Varies
extends java.lang.Object
implements Type

Varies is a Type used as a placeholder for another Type in cases where the appropriate Type is not known until run-time (e.g. OBX-5). Parsers and validators may have logic that enforces restrictions on the Type based on other features of a segment.

If you want to set both the type and the values of a Varies object, you should set the type first by calling setData(Type t), keeping a reference to your Type, and then set values by calling methods on the Type. Here is an example:

CN cn = new CN();
variesObject.setData(cn);
cn.getIDNumber().setValue("foo");

Author:
Bryan Tripp (bryan_tripp@users.sourceforge.net), Andy Pardue
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_OBX2_TYPE_PROP
          System property key.
 
Constructor Summary
Varies(Message message)
          Creates new Varies.
 
Method Summary
 void clear()
          Clears all data from this type
 java.lang.String encode()
          Encodes this message using the parser returned by #getParser()
static void fixOBX5(Segment segment, ModelClassFactory factory)
          Sets the data type of field 5 in the given OBX segment to the value of OBX-2.
 Type getData()
          Returns the data contained by this instance of Varies.
 ExtraComponents getExtraComponents()
          Returns extra components from the underlying Type
 Message getMessage()
           
 java.lang.String getName()
          Returns the name of the type (used in XML encoding and profile checking)
 void parse(java.lang.String string)
          Parses the string into this message using the parser returned by #getParser()
 void setData(Type data)
          Sets the data contained by this instance of Varies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OBX2_TYPE_PROP

public static final java.lang.String DEFAULT_OBX2_TYPE_PROP
System property key. The value may be set to provide a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value.

See Also:
Constant Field Values
Constructor Detail

Varies

public Varies(Message message)
Creates new Varies.

Parameters:
message - message to which this type belongs
Method Detail

getData

public Type getData()
Returns the data contained by this instance of Varies. Returns a GenericPrimitive unless setData() has been called.


getName

public java.lang.String getName()
Description copied from interface: Type
Returns the name of the type (used in XML encoding and profile checking)

Specified by:
getName in interface Type
See Also:
Type.getName()

setData

public void setData(Type data)
             throws DataTypeException
Sets the data contained by this instance of Varies. If a data object already exists, then its values are copied to the incoming data object before the old one is replaced. For example, if getData() returns an ST with the value "19901012" and you call setData(new DT()), then subsequent calls to getData() will return the same DT, with the value set to "19901012".

Throws:
DataTypeException

getExtraComponents

public ExtraComponents getExtraComponents()
Returns extra components from the underlying Type

Specified by:
getExtraComponents in interface Type

getMessage

public Message getMessage()
Specified by:
getMessage in interface Type
Returns:
the message to which this Type belongs

fixOBX5

public static void fixOBX5(Segment segment,
                           ModelClassFactory factory)
                    throws HL7Exception
Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument is a Segment as opposed to a particular OBX because it is meant to work with any version.

Throws:
HL7Exception

parse

public void parse(java.lang.String string)
           throws HL7Exception
Parses the string into this message using the parser returned by #getParser()

Specified by:
parse in interface Type
Throws:
HL7Exception

encode

public java.lang.String encode()
                        throws HL7Exception
Encodes this message using the parser returned by #getParser()

Specified by:
encode in interface Type
Throws:
HL7Exception

clear

public void clear()
Clears all data from this type

Specified by:
clear in interface Type


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