Class TSComponentOne

All Implemented Interfaces:
Primitive, Type, Visitable, Serializable
Direct Known Subclasses:
DTM, DTM, DTM, DTM, DTM, DTM, DTM, TS, TSComponentOne, TSComponentOne, TSComponentOne, TSComponentOne

public abstract class TSComponentOne extends AbstractPrimitive
Represents an HL7 timestamp, which is related to the HL7 TS type. In version 2.5, TS is a composite type. The first component is type DTM, which corresponds to this class (actually model.v25.datatype.DTM inherits from this class at time of writing). In HL7 versions 2.2-2.4, it wasn't perfectly clear whether TS was composite or primitive. HAPI interprets it as composite, with the first component having a type that isn't defined by HL7, and we call this type TSComponentOne. In v2.1, TS is primitive, and corresponds one-to-one with this class.
Version:
$Revision: 1.2 $ updated on $Date: 2011-02-21 17:55:08 $ by $Author: jamesagnew $
Author:
Neal Acharya, Bryan Tripp
See Also:
  • Constructor Details

    • TSComponentOne

      public TSComponentOne(Message theMessage)
      Parameters:
      theMessage - message to which this Type belongs
  • Method Details

    • setValue

      public void setValue(String theValue) throws DataTypeException
      Description copied from class: AbstractPrimitive
      Sets the value of this Primitive, first performing validation as specified by 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.

      Specified by:
      setValue in interface Primitive
      Overrides:
      setValue in class AbstractPrimitive
      Parameters:
      theValue - the value to be set
      Throws:
      DataTypeException - if the value is incorrectly formatted and either validation is enabled for this primitive or detail setters / getters have been called, forcing further parsing.
      See Also:
    • getValue

      public String getValue()
      Description copied from interface: Primitive
      Returns a String representation of the value of this field.
      Specified by:
      getValue in interface Primitive
      Overrides:
      getValue in class AbstractPrimitive
      Returns:
      a String representation of the value of this field
      See Also:
    • setDatePrecision

      public void setDatePrecision(int yr, int mnth, int dy) throws DataTypeException
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
      See Also:
    • setDateMinutePrecision

      public void setDateMinutePrecision(int yr, int mnth, int dy, int hr, int min) throws DataTypeException
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
      See Also:
    • setDateSecondPrecision

      public void setDateSecondPrecision(int yr, int mnth, int dy, int hr, int min, float sec) throws DataTypeException
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
      See Also:
    • setOffset

      public void setOffset(int signedOffset) throws DataTypeException
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
      See Also:
    • getYear

      public int getYear() throws DataTypeException
      Returns the year as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getMonth

      public int getMonth() throws DataTypeException
      Returns the month as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getDay

      public int getDay() throws DataTypeException
      Returns the day as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getHour

      public int getHour() throws DataTypeException
      Returns the hour as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getMinute

      public int getMinute() throws DataTypeException
      Returns the minute as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getSecond

      public int getSecond() throws DataTypeException
      Returns the second as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getFractSecond

      public float getFractSecond() throws DataTypeException
      Returns the fractional second value as a float.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • getGMTOffset

      public int getGMTOffset() throws DataTypeException
      Returns the GMT offset value as an integer.
      Throws:
      DataTypeException - if the value is incorrectly formatted. If validation is enabled, this exception should be thrown at setValue(), but if not, detailed parsing may be deferred until this method is called.
    • setValue

      public void setValue(Calendar theCalendar) throws DataTypeException
      Convenience setter which sets the value using a Calendar object. Note: Sets fields using precision up to the millisecond, including timezone offset
      Parameters:
      theCalendar - The calendar object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValue

      public void setValue(Date theDate) throws DataTypeException
      Convenience setter which sets the value using a Calendar object. Note: Sets fields using precision up to the millisecond, and sets the timezone offset to the current system offset Note: Date is timezone-agnostic, representing always GMT time
      Parameters:
      theDate - The date object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValueToMinute

      public void setValueToMinute(Calendar theCalendar) throws DataTypeException
      Convenience setter which sets the value using a Calendar object. Note: Sets fields using precision up to the minute
      Parameters:
      theCalendar - The calendar object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValueToMinute

      public void setValueToMinute(Date theDate) throws DataTypeException
      Convenience setter which sets the value using a Date object. Note: Sets fields using precision up to the minute Note: Date is timezone-agnostic, representing always GMT time
      Parameters:
      theDate - The date object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValueToSecond

      public void setValueToSecond(Calendar theCalendar) throws DataTypeException
      Convenience setter which sets the value using a Calendar object. Note: Sets fields using precision up to the second
      Parameters:
      theCalendar - The calendar object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • setValueToSecond

      public void setValueToSecond(Date theDate) throws DataTypeException
      Convenience setter which sets the value using a Date object. Note: Sets fields using precision up to the second
      Parameters:
      theDate - The date object from which to retrieve values
      Throws:
      DataTypeException
      Since:
      1.1
    • getValueAsCalendar

      Return the value as a calendar object
      Throws:
      DataTypeException - If the current underlying string representation can not be parsed into a valid date/time
      Since:
      1.1
    • getValueAsDate

      Return the value as a date object Note: Sets fields using precision up to the second
      Throws:
      DataTypeException - If the current underlying string representation can not be parsed into a valid date/time
      Since:
      1.1
    • isEmpty

      public boolean isEmpty() throws HL7Exception
      Description copied from class: AbstractType
      Returns true if this Visitable has actual content
      Specified by:
      isEmpty in interface Visitable
      Overrides:
      isEmpty in class AbstractPrimitive
      Returns:
      true if Visitable is empty
      Throws:
      HL7Exception - if an error occurred while determining emptiness
    • clear

      public void clear()
      Description copied from class: AbstractPrimitive
      Clears all data from this type
      Specified by:
      clear in interface Type
      Overrides:
      clear in class AbstractPrimitive