Class AbstractTextPrimitive

All Implemented Interfaces:
Primitive, Type, Visitable, Serializable
Direct Known Subclasses:
ID, IS

public abstract class AbstractTextPrimitive extends AbstractPrimitive
Base class for a textual primitive datatypes such as FT, TX, ST.
Author:
James Agnew
See Also:
  • Constructor Details

  • Method Details

    • getValueAsHtml

      Returns the value of this type with HL7 defined formatting codes replaced by their HTML equivalent.

      For example, if this type contained the string:

       ABC \.ce\MIDDLE\.br\
       

      This would be returned as:
       ABC <center>MIDDLE<center><br>
       

      The following codes are handled (note that contrary to the HL7 specification, codes are interpreted in a case-insensitive manner):

      • \.br\ (converted to <br>)
      • \.ce\ (converted to <center>)
      • \.sk\ (converted to &nbsp;)
      • \.sp\ (converted to <br> and then multiple &nbsp;)
      • \.sp ###\ (converted to multiple <br> and then multiple &nbsp;)
      • \.fi\ (cancels \.nf\)
      • \.nf\ (converted to <nobr> ... </nobr> around each line)
      • \.in ###\ (converted to <div style="margin-left: ###em;"> ... </div> around each line)
      • \.ti ###\ (treated the same as \.in ###\ but only affects the current line, and the numeric value is added to the value provided by \.in ###\. See section 2.7 of the HL7 specification for more details.)
      • \H\ (converted to <b>)
      • \N\ (converted to </b>)
      • Ampersands (&) are converted to their HTML equivalent (&amp;)
      • Chars over ASCII 160 are HTML encoded (e.g. &#199;)

      Note that the returned value from this method is an HTML snippet, not a complete HTML document.

      See Also:
    • getValueOrEmpty

      Returns the value of the datatype as returned by AbstractPrimitive.getValue() but returns an empty string ("") if the value is null. This method is mostly provided as a convenience in code which maps from one format to another, since it avoids the need for some null checks.