Class TLcdASDIMessageInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.luciad.format.asdi.TLcdASDIMessageInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class TLcdASDIMessageInputStream extends FilterInputStream
A TLcdASDIMessageInputStream is a FilterInputStream dedicated to read ASDI messages from an underlying InputStream.

It has a method readMessage() that reads one ASDI message from the underlying input stream and returns an ILcdFeatured containing the bare features of the read message.

The descriptor for the features can be obtained using getFeaturedDescriptor(ILcdFeatured).

The interface ILcdASDIMessageFeatures contains constants for the feature names that are common to all messages, interfaces ILcdASDITrackTZFeatures, ILcdASDITrackTOFeatures and ILcdASDIFlightPlanMessageFeatures contain constants for feature names that are specific for a specific type of message.

To filter out messages from the ASDI feed a filter can be specified, see setMessageFilter(ILcdASDIMessageFilter).

Note that reading an ASDI message corresponds with reading one line in the input stream. The methods getCurrentLineNumber() and getCurrentLine() allow to check for the source line that correspond with the last parsed message, which can be interesting if for instance a TLcdASDIParseException occured.

  • Constructor Details

    • TLcdASDIMessageInputStream

      public TLcdASDIMessageInputStream(InputStream aInputStream) throws UnsupportedEncodingException
      Constructs a TLcdASDIMessageInputStream that allows to read messages from a specified InputStream.
      Parameters:
      aInputStream - InputStream for reading messages from.
      Throws:
      UnsupportedEncodingException - thrown when the used character set is not supported.
  • Method Details

    • getStartTime

      public long getStartTime()
      Returns the start date of the ASDI message feed. See setStartTime(long) for details.
      Returns:
      The start date of the ASDI message feed, specified as a value in milliseconds since 1970, similar to Date.getTime(). Default is today.
    • setStartTime

      public void setStartTime(long aStartTime)
      Sets the start date of the ASDI message feed.

      The start date is used to create absolute dates from the relative date info in the ASDI messages. For instance, ASDI messages come with a header containing message day, hour, minute and second, but no absolute date. The start date is used to create absolute message dates.

      If no start date is set, the current date is used as start date.

      Parameters:
      aStartTime - the start date of the ASDI message feed, it is specified as a value in milliseconds since 1970, similar to Date.getTime(). Set -1 to use today as the start date.
      See Also:
    • getCurrentLineNumber

      public int getCurrentLineNumber()

      Returns the line number of the last line read by the readMessage. All lines read by readMessage are included, also the lines of messages that are filtered out or cause parse exceptions.

      Returns:
      Returns the line number of the last line read by the readMessage Line numbering starts from 1, line number 0 indicates no messages are read yet.
      See Also:
    • getCurrentLine

      public String getCurrentLine()

      Returns the last line read by the readMessage. Normally this corresponds with the source line of the message features returned by the last readMessage. In case no messages are read yet or the end of the input stream is reached null is returned. After a TLcdASDIParseException is thrown it refers to the source line of the message causing the parse exception.

      Returns:
      Returns the last line read by the readMessage.
      See Also:
    • getMessageFilter

      public ILcdASDIMessageFilter getMessageFilter()
      Returns the filter used for filtering out messages from the ASDI message feed. See ILcdASDIMessageFilter for more info on message filters.
      Returns:
      The ILcdASDIMessageFilter used for filtering out messages from the ASDI message feed.
      See Also:
    • setMessageFilter

      public void setMessageFilter(ILcdASDIMessageFilter aFilter)
      Sets the filter to use for filtering out messages from the ASDI message feed. See ILcdASDIMessageFilter for more info on message filters.
      Parameters:
      aFilter - The ILcdASDIMessageFilter to use for filtering out messages from the ASDI message feed.
      See Also:
    • readMessage

      public ILcdDataObject readMessage() throws IOException, TLcdASDIParseException

      Reads an ASDI message from the underlying input stream and returns an ILcdDataObject containing the properties of the read message, or null if the end of the input stream is reached.

      Types and property definitions for the messages can be found in TLcdASDIMessageDataTypes

      If a ILcdASDIDataObjectMessageFilter is specified, the readMessageAsDataObject will continue reading the input stream until an acceptable message is encountered (which is then returned) or the end of the input stream is reached (null returned).

      Returns:
      Returns an ILcdDataObject containing the data of the read message, or null if the end of the input stream is reached.
      Throws:
      IOException - Thrown when an IO exception occurred.
      TLcdASDIParseException - When an error occurred while parsing an ASDI message.
    • getFeaturedDescriptor

      @Deprecated public ILcdFeaturedDescriptor getFeaturedDescriptor(ILcdFeatured aFeatured)
      Deprecated.
      The readMessage() method returns ILcdDataObject instances, which have self-described data-types. This method should no longer be needed.
      Returns the descriptor for the features of the ILcdFeatured returned by the readMessage().
      Parameters:
      aFeatured - The ILcdFeatured for which to retrieve the descriptor.
      Returns:
      Returns the ILcdFeaturedDescriptor for the features of the ILcdFeatured returned by the readMessage.
      See Also:
    • close

      public void close() throws IOException
      Closes this stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException - Thrown when an IO exception occured.