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
ConstructorDescriptionTLcdASDIMessageInputStream
(InputStream aInputStream) Constructs aTLcdASDIMessageInputStream
that allows to read messages from a specifiedInputStream
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this stream.Returns the last line read by thereadMessage
.int
Returns 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.long
Returns the start date of the ASDI message feed.Reads an ASDI message from the underlying input stream and returns anILcdDataObject
containing the properties of the read message, or null if the end of the input stream is reached.void
setMessageFilter
(ILcdASDIMessageFilter aFilter) Sets the filter to use for filtering out messages from the ASDI message feed.void
setStartTime
(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, skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
TLcdASDIMessageInputStream
Constructs aTLcdASDIMessageInputStream
that allows to read messages from a specifiedInputStream
.- 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. 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 byreadMessage
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
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 reachednull
is returned. After aTLcdASDIParseException
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
Returns the filter used for filtering out messages from the ASDI message feed. SeeILcdASDIMessageFilter
for more info on message filters.- Returns:
- The
ILcdASDIMessageFilter
used 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. SeeILcdASDIMessageFilter
for more info on message filters.- Parameters:
aFilter
- TheILcdASDIMessageFilter
to 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
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, thereadMessageAsDataObject
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.ThereadMessage()
method returnsILcdDataObject
instances, which have self-described data-types. This method should no longer be needed.Returns the descriptor for the features of theILcdFeatured
returned by thereadMessage()
.- Parameters:
aFeatured
- TheILcdFeatured
for which to retrieve the descriptor.- Returns:
- Returns the
ILcdFeaturedDescriptor
for the features of theILcdFeatured
returned by thereadMessage
. - See Also:
-
close
Closes this stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
- Thrown when an IO exception occured.
-
readMessage()
method returnsILcdDataObject
instances, which have self-described data-types.