org.fudgemsg
Interface FudgeStreamReader

All Superinterfaces:
Closeable
All Known Implementing Classes:
FudgeDataInputStreamReader, FudgeJSONStreamReader

public interface FudgeStreamReader
extends Closeable

Abstract interface for reading Fudge elements from a source. This base can be used to build full Fudge message parsers or deserialisers to construct Java objects directly from Fudge streams.


Nested Class Summary
static class FudgeStreamReader.FudgeStreamElement
          Constants for the four stream element types as returned by next() and getCurrentElement().
 
Method Summary
 void close()
          Closes the FudgeStreamReader and attempts to close the underlying data source if appropriate.
 FudgeStreamReader.FudgeStreamElement getCurrentElement()
          Returns the value last returned by next().
 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 next().
 FudgeStreamReader.FudgeStreamElement next()
          Reads the next stream element from the source and returns the element type.
 

Method Detail

hasNext

boolean hasNext()

Returns true if there is at least one more element to be returned by a call to 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:

  1. Return false if the source does not contain any subsequent Fudge messages; or
  2. Return true 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.

Returns:
true if there is at least one more element to read

next

FudgeStreamReader.FudgeStreamElement next()
Reads the next stream element from the source and returns the element type.

Returns:
the type of the next element in the stream, or null if the end of stream has been reached at a message boundary (i.e. attempting to read the first byte of an envelope)

getCurrentElement

FudgeStreamReader.FudgeStreamElement getCurrentElement()
Returns the value last returned by next().

Returns:
the type of the current element in the stream

getFieldValue

Object getFieldValue()
If the current stream element is a field, returns the field value.

Returns:
current field value

getProcessingDirectives

int getProcessingDirectives()
Returns the processing directivies specified in the last envelope header read.

Returns:
current processing directive flags

getSchemaVersion

int getSchemaVersion()
Returns the schema version specified in the last envelope header read.

Returns:
current message schema version

getTaxonomyId

short getTaxonomyId()
Returns the taxonomy identifier specified in the last envelope header read.

Returns:
current taxonomy identifier

getFieldType

FudgeFieldType<?> getFieldType()
If the current stream element is a field, returns the FudgeFieldType.

Returns:
current field type

getFieldOrdinal

Integer getFieldOrdinal()
If the current stream element is a field, returns the ordinal index, or null if the field did not include an ordinal.

Returns:
current field ordinal

getFieldName

String getFieldName()
If the current stream element is a field, returns the field name. If the underlying stream does not specify a field name, but the ordinal can be resolved through a taxonomy, returns the resolved name.

Returns:
current field name

getTaxonomy

FudgeTaxonomy getTaxonomy()
Returns the current 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.

Returns:
current taxonomy if available

getFudgeContext

FudgeContext getFudgeContext()
Returns the FudgeContext bound to the reader used for type and taxonomy resolution.

Returns:
the FudgeContext

close

void close()
Closes the FudgeStreamReader and attempts to close the underlying data source if appropriate.

Specified by:
close in interface Closeable


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0