public abstract class AbstractPrimitive extends AbstractType implements Primitive
Constructor and Description |
---|
AbstractPrimitive(Message message) |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(MessageVisitor visitor,
Location location)
Callback method for the visitor.
|
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.
|
boolean |
isEmpty()
Returns true if this Visitable has actual content
|
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()
|
getExtraComponents, getMessage, getName, provideLocation
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getExtraComponents, getMessage, getName
provideLocation
public AbstractPrimitive(Message message)
message
- message to which this type belongspublic String toString()
toString
in class AbstractType
Object.toString()
public String getValue()
Primitive
getValue
in interface Primitive
Primitive.getValue()
public void setValue(String theValue) throws DataTypeException
getMessage().getValidationContext()
. No validation is performed
if getMessage() returns null.
Note: as of the next HAPI release, the ValidationContext will be retrieved from getParser().getValidationContext(), which ultimately is the ValidationContext of the active HapiContext.
setValue
in interface Primitive
theValue
- the value to be setDataTypeException
- if the given value is not valid in this context.Primitive.setValue(String)
public String encode() throws HL7Exception
encode
in interface Type
encode
in class AbstractType
HL7Exception
- if errors occurred while encodingpublic 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:
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).
This method makes use of the parser which is stored within the enclosing Message
.
At this time, only PipeParsers are supported.
parse
in interface Type
parse
in class AbstractType
string
- the message to be parsedHL7Exception
- if errors occurred while parsingpublic void clear()
clear
in interface Type
clear
in class AbstractType
public boolean isEmpty() throws HL7Exception
AbstractType
isEmpty
in interface Visitable
isEmpty
in class AbstractType
HL7Exception
- if an error occurred while determining emptinesspublic boolean accept(MessageVisitor visitor, Location location) throws HL7Exception
Visitable
this
as parameter, or
traverse through a hierarchical substructure and call accept(MessageVisitor)
for each visited element.accept
in interface Visitable
visitor
- MessageVisitor instance to be called backlocation
- location of this objecttrue
if the visit process shall continueHL7Exception
- if a problem occurred during visitingCopyright © 2001–2017 University Health Network. All rights reserved.