Class TLcdASDIMessageInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
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.
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionTLcdASDIMessageInputStream(InputStream aInputStream) Constructs aTLcdASDIMessageInputStreamthat allows to read messages from a specifiedInputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this stream.Returns the last line read by thereadMessage.intReturns the line number of the last line read by thereadMessage.getFeaturedDescriptor(ILcdFeatured aFeatured) Deprecated.Returns the filter used for filtering out messages from the ASDI message feed.longReturns the start date of the ASDI message feed.Reads an ASDI message from the underlying input stream and returns anILcdDataObjectcontaining the properties of the read message, or null if the end of the input stream is reached.voidsetMessageFilter(ILcdASDIMessageFilter aFilter) Sets the filter to use for filtering out messages from the ASDI message feed.voidsetStartTime(long aStartTime) Sets the start date of the ASDI message feed.Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
TLcdASDIMessageInputStream
Constructs aTLcdASDIMessageInputStreamthat allows to read messages from a specifiedInputStream.- Parameters:
aInputStream-InputStreamfor 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. SeesetStartTime(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 toDate.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 byreadMessageare 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
readMessageLine numbering starts from 1, line number 0 indicates no messages are read yet. - See Also:
-
getCurrentLine
Returns the last line read by the
readMessage. Normally this corresponds with the source line of the message features returned by the lastreadMessage. In case no messages are read yet or the end of the input stream is reachednullis returned. After aTLcdASDIParseExceptionis 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
Returns the filter used for filtering out messages from the ASDI message feed. SeeILcdASDIMessageFilterfor more info on message filters.- Returns:
- The
ILcdASDIMessageFilterused for filtering out messages from the ASDI message feed. - See Also:
-
setMessageFilter
Sets the filter to use for filtering out messages from the ASDI message feed. SeeILcdASDIMessageFilterfor more info on message filters.- Parameters:
aFilter- TheILcdASDIMessageFilterto use for filtering out messages from the ASDI message feed.- See Also:
-
readMessage
Reads an ASDI message from the underlying input stream and returns an
ILcdDataObjectcontaining 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
TLcdASDIMessageDataTypesIf a
ILcdASDIDataObjectMessageFilteris specified, thereadMessageAsDataObjectwill 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
ILcdDataObjectcontaining 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.ThereadMessage()method returnsILcdDataObjectinstances, which have self-described data-types. This method should no longer be needed.Returns the descriptor for the features of theILcdFeaturedreturned by thereadMessage().- Parameters:
aFeatured- TheILcdFeaturedfor which to retrieve the descriptor.- Returns:
- Returns the
ILcdFeaturedDescriptorfor the features of theILcdFeaturedreturned by thereadMessage. - See Also:
-
close
Closes this stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException- Thrown when an IO exception occured.
-
readMessage()method returnsILcdDataObjectinstances, which have self-described data-types.