public class TLcdASDIMessageInputStream extends FilterInputStream
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.
in
Constructor and Description |
---|
TLcdASDIMessageInputStream(InputStream aInputStream)
Constructs a
TLcdASDIMessageInputStream
that allows to read messages from a specified InputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this stream.
|
String |
getCurrentLine()
Returns the last line read by the
readMessage . |
int |
getCurrentLineNumber()
Returns the line number of the last line read by the
readMessage . |
ILcdFeaturedDescriptor |
getFeaturedDescriptor(ILcdFeatured aFeatured)
Deprecated.
The
readMessage() method returns ILcdDataObject instances, which
have self-described data-types. This method should no longer be needed. |
ILcdASDIMessageFilter |
getMessageFilter()
Returns the filter used for filtering out messages from the ASDI message feed.
|
long |
getStartTime()
Returns the start date of the ASDI message feed.
|
ILcdDataObject |
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. |
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.
|
available, mark, markSupported, read, read, read, reset, skip
public TLcdASDIMessageInputStream(InputStream aInputStream) throws UnsupportedEncodingException
TLcdASDIMessageInputStream
that allows to read messages from a specified InputStream
.aInputStream
- InputStream
for reading messages from.UnsupportedEncodingException
- thrown when the used character set is not supported.public long getStartTime()
setStartTime(long)
for details.Date.getTime()
. Default is today.public void setStartTime(long aStartTime)
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.
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.getStartTime()
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.
readMessage
Line numbering starts from 1, line number 0 indicates no messages are read yet.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.
readMessage
.getCurrentLineNumber()
public ILcdASDIMessageFilter getMessageFilter()
ILcdASDIMessageFilter
for more info on message filters.ILcdASDIMessageFilter
used for filtering out messages from the ASDI message feed.setMessageFilter(ILcdASDIMessageFilter aFilter)
public void setMessageFilter(ILcdASDIMessageFilter aFilter)
ILcdASDIMessageFilter
for more info on message filters.aFilter
- The ILcdASDIMessageFilter
to use for filtering out messages from the ASDI message feed.getMessageFilter()
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).
ILcdDataObject
containing the data of the read message,
or null if the end of the input stream is reached.IOException
- Thrown when an IO exception occurred.TLcdASDIParseException
- When an error occurred while parsing an ASDI message.@Deprecated public ILcdFeaturedDescriptor getFeaturedDescriptor(ILcdFeatured aFeatured)
readMessage()
method returns ILcdDataObject
instances, which
have self-described data-types. This method should no longer be needed.ILcdFeatured
returned
by the readMessage()
.aFeatured
- The ILcdFeatured
for which to retrieve the descriptor.ILcdFeaturedDescriptor
for the features of the
ILcdFeatured
returned by the readMessage
.readMessage()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
- Thrown when an IO exception occured.