Class XTCEPosixTimeHandler
- java.lang.Object
-
- org.xtce.toolkit.XTCEPosixTimeHandler
-
- All Implemented Interfaces:
XTCEAbsoluteTimeType
public class XTCEPosixTimeHandler extends Object implements XTCEAbsoluteTimeType
This class implements UNIX POSIX time to support AbsoluteTimeDataType elements in an XTCE document.This class is applicable to AbsoluteTimeType XTCE specifications when three conditions are met by the XML document:
- Encoding size in bits of the type element is equal to 64.
- Encoding is Unsigned Integer
- Epoch of the type element is equal to "1970-01-01" with no specific time of the day specified (midnight assumed).
The EU/Calibrated value is implemented to be a UTC string, with no leap second correction. It is based on the internal system clock of this host. The Uncalibrated value is the microseconds since midnight 1970-01-01 date. The raw value is two POSIX unsigned integers, 32 bits of seconds, followed by 32 bits of microseconds. The BitSet of the raw encoded value will be equal to that of a "struct timeval" in the C programming language foundation of many computing platforms.
Although the POSIX specification carries microseconds, the Java implementation here uses the basic libraries and will only act as far as the milliseconds.
- Author:
- dovereem
-
-
Constructor Summary
Constructors Constructor Description XTCEPosixTimeHandler()Default constructor to initialize a handler with the default time format and time zone.XTCEPosixTimeHandler(String timeFormat, String timeZone)Constructor that permits changing the default time format and the time zone information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCalibratedFromUncalibrated(String uncalValue)Retrieve the EU calibrated value of this time item, which can be a Parameter or Argument, when given the uncalibrated value.BitSetgetRawFromUncalibrated(String uncalValue)Retrieve the raw binary bits for encoding of this time item, which can be a Parameter or Argument, when given the uncalibrated value.StringgetUncalibratedFromCalibrated(String euValue)Retrieve the uncalibrated value for this time item, which can be a Parameter or Argument, when given the EU calibrated value.StringgetUncalibratedFromRaw(BitSet rawValue)Retrieve the uncalibrated value of this time item, which can be a Parameter or Argument, when given the raw binary value.booleanisApplicable(AbsoluteTimeDataType instance)Method to determine if an XTCE AbsoluteTimeType, either Parameter or Argument, is handled by this implementation of the interface.
-
-
-
Constructor Detail
-
XTCEPosixTimeHandler
public XTCEPosixTimeHandler()
Default constructor to initialize a handler with the default time format and time zone.The default time output format is UTC ISO8601 text. This is in the form of YYYY-MM-dd HH:MM:ss.SSS
-
XTCEPosixTimeHandler
public XTCEPosixTimeHandler(String timeFormat, String timeZone)
Constructor that permits changing the default time format and the time zone information.- Parameters:
timeFormat- String containing the time format string suitable for the Java SimpleDateFormat formatter.timeZone- String containing the time zone identifier string, suitable for the TimeZone.getTimeZone method in Java.
-
-
Method Detail
-
isApplicable
public boolean isApplicable(AbsoluteTimeDataType instance)
Method to determine if an XTCE AbsoluteTimeType, either Parameter or Argument, is handled by this implementation of the interface.This method returns true when three conditions are met by the XML that is represented by the JAXB AbsoluteTimeDataType object instance passed by the caller:
- Encoding size in bits of the type element is equal to 64.
- Encoding is Unsigned Integer
- Epoch of the type element is equal to "1970-01-01" with no specific time of the day specified (midnight assumed).
- Specified by:
isApplicablein interfaceXTCEAbsoluteTimeType- Parameters:
instance- AbsoluteTimeDataType object from the JAXB representation of the XTCE XML document.- Returns:
- boolean indicating if this handler supports/implements handling for the user provided Absolute Time Type, as specified in the XML.
-
getUncalibratedFromRaw
public String getUncalibratedFromRaw(BitSet rawValue)
Retrieve the uncalibrated value of this time item, which can be a Parameter or Argument, when given the raw binary value.The raw input value is a BitSet of 64 bits in the form of two 32 bit unsigned integers. The first is the number of seconds since the UNIX epoch of 1970-01-01 and the seconds in the number of microseconds within the second. The output String will be an integral representation of the number of microseconds since 1970-01-01.
This conversion uses only system time capabilities, and as a result is not leap second corrected.
- Specified by:
getUncalibratedFromRawin interfaceXTCEAbsoluteTimeType- Parameters:
rawValue- BitSet containing the raw binary value that would be encoded on the wire or bitfield. The raw binary is always expected to be in the order read from the stream.- Returns:
- String containing the integral microseconds since epoch.
-
getCalibratedFromUncalibrated
public String getCalibratedFromUncalibrated(String uncalValue)
Retrieve the EU calibrated value of this time item, which can be a Parameter or Argument, when given the uncalibrated value.The uncalibrated input string contains an integral number of microseconds since the UNIX epoch. The output string is the UTC string in the form of ISO8601 (YYYY-MM-DD HH:MM:SS.sssss). The timezone is always UTC/GMT.
- Specified by:
getCalibratedFromUncalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
uncalValue- String containing the uncalibrated value that is derived from the encoded value on the wire or bitfield.- Returns:
- String containing the proper EU calibrated representation of the uncalibrated value provided by the caller.
- Throws:
NumberFormatException- in the event that the uncalibrated value cannot be converted to an integral number.
-
getRawFromUncalibrated
public BitSet getRawFromUncalibrated(String uncalValue)
Retrieve the raw binary bits for encoding of this time item, which can be a Parameter or Argument, when given the uncalibrated value.The raw output value is a BitSet of 64 bits in the form of two 32 bit unsigned integers. The first is the number of seconds since the UNIX epoch of 1970-01-01 and the seconds in the number of microseconds within the second. The input String will be an integral representation of the number of microseconds since 1970-01-01.
This conversion uses only system time capabilities, and as a result is not leap second corrected.
- Specified by:
getRawFromUncalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
uncalValue- String containing the uncalibrated representation of the value.- Returns:
- BitSet containing the raw bits.
- Throws:
NumberFormatException- in the event that the uncalibrated value cannot be converted to an integral number.
-
getUncalibratedFromCalibrated
public String getUncalibratedFromCalibrated(String euValue)
Retrieve the uncalibrated value for this time item, which can be a Parameter or Argument, when given the EU calibrated value.The uncalibrated output string contains an integral number of microseconds since the UNIX epoch. The input string is the UTC string in the form of ISO8601 (YYYY-MM-DD HH:MM:SS.sssss).
- Specified by:
getUncalibratedFromCalibratedin interfaceXTCEAbsoluteTimeType- Parameters:
euValue- String containing a value of this item represented in EU/calibrated form.- Returns:
- String containing the uncalibrated value.
- Throws:
RuntimeException- in the event that a checked exception is caught by this function, with the parsing error text copied.
-
-