org.fudgemsg
Class FudgeMsgReader

java.lang.Object
  extended by org.fudgemsg.FudgeMsgReader

public class FudgeMsgReader
extends Object

A reader for returning whole Fudge messages (FudgeFieldContainer instances) from an underlying FudgeStreamReader instance. This implementation constructs the whole Fudge message in memory before returning to the caller. This is provided for convenience - greater runtime efficiency may be possible by working directly with the FudgeStreamReader to process stream elements as they are decoded.


Constructor Summary
FudgeMsgReader(FudgeStreamReader streamReader)
          Creates a new FudgeMsgReader around an existing FudgeStreamReader.
 
Method Summary
 void close()
          Closes this FudgeMsgReader and the underlying FudgeStreamReader.
 FudgeContext getFudgeContext()
          Returns the FudgeContext associated with the underlying source.
protected  FudgeStreamReader getStreamReader()
          Returns the underlying FudgeStreamReader for this message reader.
 boolean hasNext()
          Returns true if there are more messages to read from the underlying source.
 FudgeFieldContainer nextMessage()
          Reads the next message, discarding the envelope.
 FudgeMsgEnvelope nextMessageEnvelope()
          Reads the next message, returning the envelope.
protected  void processFields(MutableFudgeFieldContainer msg)
          Processes all of the fields from the current message (or sub-message) in the stream, adding them to the supplied container.
protected  FudgeMsgEnvelope readMessageEnvelope()
          Reads the next message envelope from the underlying stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FudgeMsgReader

public FudgeMsgReader(FudgeStreamReader streamReader)
Creates a new FudgeMsgReader around an existing FudgeStreamReader.

Parameters:
streamReader - the source of Fudge stream elements to read
Method Detail

close

public void close()
Closes this FudgeMsgReader and the underlying FudgeStreamReader.


getFudgeContext

public FudgeContext getFudgeContext()
Returns the FudgeContext associated with the underlying source.

Returns:
the FudgeContext

getStreamReader

protected FudgeStreamReader getStreamReader()
Returns the underlying FudgeStreamReader for this message reader.

Returns:
the FudgeStreamReader

hasNext

public boolean hasNext()
Returns true if there are more messages to read from the underlying source.

Returns:
true if nextMessage() or nextMessageEnvelope() will return data

nextMessage

public FudgeFieldContainer nextMessage()
Reads the next message, discarding the envelope.

Returns:
the message read without the envelope

nextMessageEnvelope

public FudgeMsgEnvelope nextMessageEnvelope()
Reads the next message, returning the envelope.

Returns:
the FudgeMsgEnvelope

readMessageEnvelope

protected FudgeMsgEnvelope readMessageEnvelope()
Reads the next message envelope from the underlying stream. No fields are read.

Returns:
the FudgeMsgEnvelope read

processFields

protected void processFields(MutableFudgeFieldContainer msg)
Processes all of the fields from the current message (or sub-message) in the stream, adding them to the supplied container.

Parameters:
msg - container to add fields read to


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