org.vmdb.hl7
Class SimpleElement

java.lang.Object
  |
  +--org.vmdb.hl7.HL7Object
        |
        +--org.vmdb.hl7.HL7Element
              |
              +--org.vmdb.hl7.SimpleElement

public class SimpleElement
extends HL7Element

Single Implementation for All Simple HL7 Data Types.

Description: HL7 Network Connectivity For VMDB.

Copyright: Copyright (c) 2002-2003.

Company: Veterinary Medical Database (VMDB).

This one class handles all the data types that consist of a single string. The actual type is set by the calling program with the constructor or setType() method. Validity checking is left to the calling routine.


Constructor Summary
SimpleElement()
          Construct an Element using the name and type specified in its sNm and sRl constants.
SimpleElement(int iLevel)
          Construct an Element using the name and type specified in its sNm and sRl constants.
SimpleElement(java.lang.String sName, java.lang.String sType)
          Construct an Element of given name and type.
 
Method Summary
 boolean empty()
          Test to see if a value has been set for this simple element.
 HL7Element getComponent(int iLoc)
          Get component based on one based index position.
 java.lang.String getValue()
          Get the value stored in this element as a simple string.
 void setValue(java.lang.String sValue)
          Set the value of this element.
 int size()
          Return the number of components in this element.
 java.lang.String toHL7String()
          Output the value of this element as a string with HL7 escape sequences.
 java.lang.String toString()
          Output the value of this element as a string.
 java.lang.String toXML(int iDepth)
          Output the element as XML.
 
Methods inherited from class org.vmdb.hl7.HL7Element
clear, getLevel, getType, initialize, iterator, makeElement, setComponent, setLevel, setType
 
Methods inherited from class org.vmdb.hl7.HL7Object
getRule
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleElement

public SimpleElement(int iLevel)
Construct an Element using the name and type specified in its sNm and sRl constants.

Parameters:
iLevel - One of the constants for specifying level as FIELD, COMPONENT, or SUBCOMPONENT. Default FIELD.

SimpleElement

public SimpleElement()
Construct an Element using the name and type specified in its sNm and sRl constants. And at the level of a Field.


SimpleElement

public SimpleElement(java.lang.String sName,
                     java.lang.String sType)
Construct an Element of given name and type.

Parameters:
sName - The name of this element relative to its container. Example: "PID.1" for the segquenceID in the pid segment.
sType - The HL7 data type abbreviation. Example "ST" for string or "NM" for numeric. Note: Both of these would be instatiated as SimpleElement objects in this library.
Method Detail

setValue

public void setValue(java.lang.String sValue)
Set the value of this element.

Overrides:
setValue in class HL7Element
Parameters:
sValue - String representing the value. For numeric and coded types, validation is left to the calling routine.

getValue

public java.lang.String getValue()
Get the value stored in this element as a simple string.

Overrides:
getValue in class HL7Element
Returns:
String with value or an empty string object if not set.

getComponent

public HL7Element getComponent(int iLoc)
Get component based on one based index position.

Overrides:
getComponent in class HL7Element
Parameters:
iLoc - location in element to get (one based index).
Returns:
Reference to the HL7Element derived object at the specified location or null if the location does not yet exist.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iLoc points to a field less than one or greater than the number of components allowed in the message rule.

empty

public boolean empty()
Test to see if a value has been set for this simple element.

This is the simplest case of the more complex empty() method inherited from HL7Element.

Overrides:
empty in class HL7Element
Returns:
true if value is not set.

size

public int size()
Return the number of components in this element.

Because this is defined as a single string, the values returned are limite to zero if no value has been set or one if it has a value. This is a simple case of the size() method inherited from HL7Element.

Overrides:
size in class HL7Element
Returns:
integer one if it has a value or integer zero if empty.

toString

public java.lang.String toString()
Output the value of this element as a string.

This is the simplest case of the more general toString() inherited from HL7Object. Ultimately all data end up expressed as SimpleElements and output here. The layers around just organize them via delimiters, XML tags, etc..

TODO: Check value for anything that needs to be converted to escape sequences.

Overrides:
toString in class HL7Element
Returns:
String with value or an empty string if not set.

toHL7String

public java.lang.String toHL7String()
Output the value of this element as a string with HL7 escape sequences.

This is the simplest case of the more general toString() inherited from HL7Object. Ultimately all data end up expressed as SimpleElements and output here.

Overrides:
toHL7String in class HL7Element
Returns:
String with value or an empty string if not set.

toXML

public java.lang.String toXML(int iDepth)
Output the element as XML.

Outputs the DOM element.

Overrides:
toXML in class HL7Element
Parameters:
iDepth - int value for the number of spaces to indent this object. Used just to make the XML easier to read as unformatted text.
Returns:
foratted XML text.

SourceForge.net Logo