|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fudgemsg.FudgeDataInputStreamReader
public class FudgeDataInputStreamReader
An implementation of FudgeStreamReader
for consuming data from a DataInput
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.fudgemsg.FudgeStreamReader |
---|
FudgeStreamReader.FudgeStreamElement |
Constructor Summary | |
---|---|
FudgeDataInputStreamReader(FudgeContext fudgeContext,
DataInput dataInput)
Creates a new FudgeDataInputStreamReader associated with the given FudgeContext and DataInput data source. |
|
FudgeDataInputStreamReader(FudgeContext fudgeContext,
InputStream inputStream)
Creates a new FudgeDataInputStreamReader by wrapping a InputStream with a DataInput . |
Method Summary | |
---|---|
void |
close()
Closes this reader. |
protected void |
consumeFieldData()
Reads the next field (prefix and value) from the input stream, setting internal state to be returned by getFieldName, getFieldOrdinal, getFieldType, getCurrentElement and getFieldValue. |
protected boolean |
consumeMessageEnvelope()
Reads the next message envelope from the input stream, setting internal state go be returned by getCurrentElement, getProcessingDirectives, getSchemaVersion, getTaxonomyId and getEnvelopeSize. |
FudgeStreamReader.FudgeStreamElement |
getCurrentElement()
Returns the value last returned by FudgeStreamReader.next() . |
protected DataInput |
getDataInput()
Returns the underlying DataInput . |
String |
getFieldName()
If the current stream element is a field, returns the field name. |
Integer |
getFieldOrdinal()
If the current stream element is a field, returns the ordinal index, or null if the field did not include an ordinal. |
FudgeFieldType<?> |
getFieldType()
If the current stream element is a field, returns the FudgeFieldType . |
Object |
getFieldValue()
If the current stream element is a field, returns the field value. |
FudgeContext |
getFudgeContext()
Returns the FudgeContext bound to the reader used for type and taxonomy resolution. |
int |
getProcessingDirectives()
Returns the processing directivies specified in the last envelope header read. |
int |
getSchemaVersion()
Returns the schema version specified in the last envelope header read. |
FudgeTaxonomy |
getTaxonomy()
Returns the current FudgeTaxonomy corresponding to the taxonomy identifier specified in the message envelope. |
short |
getTaxonomyId()
Returns the taxonomy identifier specified in the last envelope header read. |
boolean |
hasNext()
Returns true if there is at least one more element to be returned by a call to FudgeStreamReader.next() . |
protected boolean |
isEndOfSubMessage()
Detects the end of a sub-message field; i.e. |
FudgeStreamReader.FudgeStreamElement |
next()
Reads the next stream element from the source and returns the element type. |
static Object |
readFieldValue(DataInput is,
FudgeFieldType<?> type,
int varSize)
Reads a Fudge encoded field value from an input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FudgeDataInputStreamReader(FudgeContext fudgeContext, DataInput dataInput)
FudgeDataInputStreamReader
associated with the given FudgeContext
and DataInput
data source.
The Fudge context is used to hold all decoding parameters such as taxonomy and type resolution.
fudgeContext
- the FudgeContext
to associate withdataInput
- the source of data to read Fudge elements frompublic FudgeDataInputStreamReader(FudgeContext fudgeContext, InputStream inputStream)
FudgeDataInputStreamReader
by wrapping a InputStream
with a DataInput
.
fudgeContext
- the FudgeContext
to associate withinputStream
- the source of data to read Fudge elements fromMethod Detail |
---|
public void close()
Closeable
interface, Closeable.close()
will be called on it.
close
in interface Closeable
close
in interface FudgeStreamReader
public FudgeStreamReader.FudgeStreamElement getCurrentElement()
FudgeStreamReader.next()
.
getCurrentElement
in interface FudgeStreamReader
public String getFieldName()
getFieldName
in interface FudgeStreamReader
public Integer getFieldOrdinal()
null
if the field did not include an ordinal.
getFieldOrdinal
in interface FudgeStreamReader
public FudgeFieldType<?> getFieldType()
FudgeFieldType
.
getFieldType
in interface FudgeStreamReader
public Object getFieldValue()
getFieldValue
in interface FudgeStreamReader
public FudgeContext getFudgeContext()
FudgeContext
bound to the reader used for type and taxonomy resolution.
getFudgeContext
in interface FudgeStreamReader
FudgeContext
public int getProcessingDirectives()
getProcessingDirectives
in interface FudgeStreamReader
public int getSchemaVersion()
getSchemaVersion
in interface FudgeStreamReader
public FudgeTaxonomy getTaxonomy()
FudgeTaxonomy
corresponding to the taxonomy identifier specified in the message envelope. Returns
null
if the message did not specify a taxonomy or the taxonomy identifier cannot be resolved by the bound FudgeContext
.
getTaxonomy
in interface FudgeStreamReader
public short getTaxonomyId()
getTaxonomyId
in interface FudgeStreamReader
public boolean hasNext()
Returns true if there is at least one more element to be returned by a call to FudgeStreamReader.next()
. A return of false
indicates the end of a message (or submessage) has been reached. After the end of a sub-message, the next immediate call will
indicate whether there are further elements or the end of the outer message. After the end of the main message referenced by
the envelope header, the next immediate call may:
false
if the source does not contain any subsequent Fudge messages; ortrue
if the source may contain further Fudge messages. Calling next()
will return the envelope header
of the next message if one is present, or null
if the source does not contain any further messages.
hasNext
in interface FudgeStreamReader
true
if there is at least one more element to readpublic FudgeStreamReader.FudgeStreamElement next()
next
in interface FudgeStreamReader
null
if the end of stream has been reached at a message
boundary (i.e. attempting to read the first byte of an envelope)protected boolean isEndOfSubMessage()
next()
will resume consuming fields from the containing
message again.
true
if the end of the sub-message has been reached, false
otherwise.protected DataInput getDataInput()
DataInput
.
DataInput
protected void consumeFieldData() throws IOException
IOException
- if the underlying stream raises onepublic static Object readFieldValue(DataInput is, FudgeFieldType<?> type, int varSize)
is
- the DataInput
wrapped input steramtype
- the FudgeFieldType
of the data to readvarSize
- number of bytes in a variable width field payload
protected boolean consumeMessageEnvelope() throws IOException
true
if there was an envelope to consume, false
if an EOF was found on reading the first byte
IOException
- if the underlying data source raises an IOException
other than an EOFException
on the first byte of the envelope
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |