Class AbstractType

java.lang.Object
ca.uhn.hl7v2.model.AbstractType
All Implemented Interfaces:
Type, Visitable, Serializable
Direct Known Subclasses:
AbstractComposite, AbstractPersonNameComposite, AbstractPrimitive

public abstract class AbstractType extends Object implements Type
An abstract Type that provides a default implementation of getName().
Author:
Bryan Tripp
See Also:
  • Constructor Details

    • AbstractType

      public AbstractType(Message message)
      Creates a new instance of AbstractType
      Parameters:
      message - message to which this type belongs
  • Method Details

    • getName

      public String getName()
      Returns the name of the type (used in XML encoding and profile checking)
      Specified by:
      getName in interface Type
      Returns:
      the name of the type
    • getExtraComponents

      Description copied from interface: Type
      Returns an object containing any extra (non-standard) components that have been added to this type at run-time. This object can also be used to add components.
      Specified by:
      getExtraComponents in interface Type
      Returns:
      an object containing any extra (non-standard) components
      See Also:
    • getMessage

      public Message getMessage()
      Specified by:
      getMessage in interface Type
      Returns:
      the message to which this Type belongs
    • 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:

      • If you are using Primitive.setValue(String), the ampersand is treated as an actual ampersand in the text, and the field will be treated as a single field which is encoded as "milk\T\cookies" (\T\ is the escape sequence for the subcomponent delimiter).
      • If you are using parse(String), the ampersand is treated as a subcomponent delimiter, meaning that the value is set to "milk", and a second component is added with the value of "cookies".

      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
      Parameters:
      string - the message to be parsed
      Throws:
      HL7Exception - if errors occurred while parsing
    • encode

      public String encode() throws HL7Exception
      Encodes this type using HL7 encoding.
      Specified by:
      encode in interface Type
      Returns:
      the encoded message
      Throws:
      HL7Exception - if errors occurred while encoding
    • clear

      public void clear()
      Clears all data from this type
      Specified by:
      clear in interface Type
    • isEmpty

      public boolean isEmpty() throws HL7Exception
      Returns true if this Visitable has actual content
      Specified by:
      isEmpty in interface Visitable
      Returns:
      true if Visitable is empty
      Throws:
      HL7Exception - if an error occurred while determining emptiness
    • toString

      public String toString()
      Returns the datatype and attempts to pipe-encode it. For example, a string implementation might return "ST[Value^Value2]". This is only intended for logging/debugging purposes.
      Overrides:
      toString in class Object
    • provideLocation

      public Location provideLocation(Location location, int index, int repetition)
      Description copied from interface: Visitable
      Reusing the location of this object's parent, this method returns its own location within the message.
      Specified by:
      provideLocation in interface Visitable
      Parameters:
      location - the parents location
      index - index of this object
      repetition - repetition of this object
      Returns:
      this objects location