org.fudgemsg
Class FudgeMsgWriter

java.lang.Object
  extended by org.fudgemsg.FudgeMsgWriter
All Implemented Interfaces:
Flushable

public class FudgeMsgWriter
extends Object
implements Flushable

A writer for passing Fudge messages (FudgeFieldContainer instances) to an underlying FudgeStreamWriter instance. This implementation assumes that the whole message (or envelope) is available to the caller before writing starts. This is provided for convenience - greater runtime efficiency may be possible by working directly with a FudgeStreamWriter to emit Fudge stream elements as they are generated.


Constructor Summary
FudgeMsgWriter(FudgeStreamWriter streamWriter)
          Creates a new FudgeMsgWriter around an existing FudgeStreamWriter.
 
Method Summary
 void close()
          Flushes and closes the underlying FudgeStreamWriter.
 void flush()
          Flushes the underlying FudgeStreamWriter.
 int getDefaultMessageProcessingDirectives()
          Returns the current processing directive flags for messages that are passed without an envelope.
 int getDefaultMessageVersion()
          Returns the current schema version used for messages that are passed without an envelope.
 int getDefaultTaxonomyId()
          Returns the current default taxonomy identifier.
 FudgeContext getFudgeContext()
          Returns the FudgeContext of the current underlying FudgeStreamWriter.
protected  FudgeStreamWriter getStreamWriter()
          Returns the underlying FudgeStreamWriter.
 void setDefaultMessageProcessingDirectives(int processingDirectives)
          Sets the processing directive flags to be used for messages that are passed without an envelope.
 void setDefaultMessageVersion(int version)
          Sets the schema version to be used for messages that are passed without an envelope.
 void setDefaultTaxonomyId(int taxonomyId)
          Sets the default taxonomy identifier for messages that are passed without an envelope.
 String toString()
          
 void writeMessage(FudgeFieldContainer message)
          Writes a message.
 void writeMessage(FudgeFieldContainer message, int taxonomyId)
          Writes a message with the given taxonomy.
 void writeMessage(FudgeFieldContainer message, int taxonomyId, int version, int processingDirectives)
          Writes a message with the given taxonomy, schema version and processing directive flags.
 void writeMessageEnvelope(FudgeMsgEnvelope envelope)
          Writes a message envelope using the default taxonomy.
 void writeMessageEnvelope(FudgeMsgEnvelope envelope, int taxonomyId)
          Writes a message envelope with the given taxonomy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FudgeMsgWriter

public FudgeMsgWriter(FudgeStreamWriter streamWriter)
Creates a new FudgeMsgWriter around an existing FudgeStreamWriter.

Parameters:
streamWriter - target to write Fudge stream elements to
Method Detail

flush

public void flush()
Flushes the underlying FudgeStreamWriter.

Specified by:
flush in interface Flushable

close

public void close()
Flushes and closes the underlying FudgeStreamWriter.


getStreamWriter

protected FudgeStreamWriter getStreamWriter()
Returns the underlying FudgeStreamWriter.

Returns:
the FudgeStreamWriter

getFudgeContext

public FudgeContext getFudgeContext()
Returns the FudgeContext of the current underlying FudgeStreamWriter.

Returns:
the FudgeContext

toString

public String toString()

Overrides:
toString in class Object

getDefaultTaxonomyId

public int getDefaultTaxonomyId()
Returns the current default taxonomy identifier.

Returns:
the taxonomy identifier

setDefaultTaxonomyId

public void setDefaultTaxonomyId(int taxonomyId)
Sets the default taxonomy identifier for messages that are passed without an envelope.

Parameters:
taxonomyId - the taxonomy identifier

getDefaultMessageVersion

public int getDefaultMessageVersion()
Returns the current schema version used for messages that are passed without an envelope.

Returns:
the schema version

setDefaultMessageVersion

public void setDefaultMessageVersion(int version)
Sets the schema version to be used for messages that are passed without an envelope.

Parameters:
version - new schema version value

getDefaultMessageProcessingDirectives

public int getDefaultMessageProcessingDirectives()
Returns the current processing directive flags for messages that are passed without an envelope.

Returns:
the processing directive flags

setDefaultMessageProcessingDirectives

public void setDefaultMessageProcessingDirectives(int processingDirectives)
Sets the processing directive flags to be used for messages that are passed without an envelope.

Parameters:
processingDirectives - processing directive flags

writeMessage

public void writeMessage(FudgeFieldContainer message,
                         int taxonomyId,
                         int version,
                         int processingDirectives)
Writes a message with the given taxonomy, schema version and processing directive flags.

Parameters:
message - message to write
taxonomyId - identifier of the taxonomy to use. If the taxonomy is recognized by the FudgeContext it will be used to reduce field names to ordinals where possible.
version - schema version
processingDirectives - processing directive flags

writeMessage

public void writeMessage(FudgeFieldContainer message,
                         int taxonomyId)
Writes a message with the given taxonomy. Default schema version and processing directive flags are used.

Parameters:
message - message to write
taxonomyId - identifier of the taxonomy to use. If the taxonomy is recognized by the FudgeContext it will be used to reduce field names to ordinals where possible.

writeMessage

public void writeMessage(FudgeFieldContainer message)
Writes a message. Default taxonomy, schema version and processing directive flags are used.

Parameters:
message - message to write
Throws:
NullPointerException - if the default taxonomy has not been specified

writeMessageEnvelope

public void writeMessageEnvelope(FudgeMsgEnvelope envelope,
                                 int taxonomyId)
Writes a message envelope with the given taxonomy.

Parameters:
envelope - message envelope to write
taxonomyId - identifier of the taxonomy to use. If the taxonomy is recognized by the FudgeContext it will be used to reduce field names to ordinals where possible.

writeMessageEnvelope

public void writeMessageEnvelope(FudgeMsgEnvelope envelope)
Writes a message envelope using the default taxonomy.

Parameters:
envelope - message envelope to write
Throws:
NullPointerException - if the default taxonomy has not been specified


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