Package ca.uhn.hl7v2.model
Class AbstractType
java.lang.Object
ca.uhn.hl7v2.model.AbstractType
- All Implemented Interfaces:
Type,Visitable,Serializable
- Direct Known Subclasses:
AbstractComposite,AbstractPersonNameComposite,AbstractPrimitive
An abstract Type that provides a default implementation of getName().
- Author:
- Bryan Tripp
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all data from this typeencode()Encodes this type using HL7 encoding.Returns an object containing any extra (non-standard) components that have been added to this type at run-time.getName()Returns the name of the type (used in XML encoding and profile checking)booleanisEmpty()Returns true if this Visitable has actual contentvoidParses the string into this type and replaces the current contents with the parsed value.provideLocation(Location location, int index, int repetition) Reusing the location of this object's parent, this method returns its own location within the message.toString()Returns the datatype and attempts to pipe-encode it.
-
Constructor Details
-
AbstractType
Creates a new instance of AbstractType- Parameters:
message- message to which this type belongs
-
-
Method Details
-
getName
Returns the name of the type (used in XML encoding and profile checking) -
getExtraComponents
Description copied from interface:TypeReturns 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:
getExtraComponentsin interfaceType- Returns:
- an object containing any extra (non-standard) components
- See Also:
-
getMessage
- Specified by:
getMessagein interfaceType- Returns:
- the message to which this Type belongs
-
parse
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:
parsein interfaceType- Parameters:
string- the message to be parsed- Throws:
HL7Exception- if errors occurred while parsing
-
If you are using
-
encode
Encodes this type using HL7 encoding.- Specified by:
encodein interfaceType- Returns:
- the encoded message
- Throws:
HL7Exception- if errors occurred while encoding
-
clear
Clears all data from this type -
isEmpty
Returns true if this Visitable has actual content- Specified by:
isEmptyin interfaceVisitable- Returns:
- true if Visitable is empty
- Throws:
HL7Exception- if an error occurred while determining emptiness
-
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. -
provideLocation
Description copied from interface:VisitableReusing the location of this object's parent, this method returns its own location within the message.- Specified by:
provideLocationin interfaceVisitable- Parameters:
location- the parents locationindex- index of this objectrepetition- repetition of this object- Returns:
- this objects location
-