org.fudgemsg
Interface FudgeStreamWriter

All Superinterfaces:
Closeable, Flushable
All Known Implementing Classes:
AlternativeFudgeStreamWriter, FudgeDataOutputStreamWriter, FudgeJSONStreamWriter, FudgeXMLStreamWriter

public interface FudgeStreamWriter
extends Flushable, Closeable

Abstract interface for writing Fudge elements to a target. This base can be used to build full Fudge message writers or serializers to convert Java objects directly to Fudge streams.


Method Summary
 void close()
          Flushes and closes this writer and attempts to close the underlying stream if appropriate.
 void envelopeComplete()
          Signal the end of the message contained within an envelope.
 void flush()
          Flushes any data from the internal buffers to the target stream and attempts to flush the underlying stream if appropriate.
 FudgeTaxonomy getCurrentTaxonomy()
          Returns the taxonomy (if any) that is currently being used to encode fields.
 int getCurrentTaxonomyId()
          Returns the current taxonomy identifier.
 FudgeContext getFudgeContext()
          Returns the bound FudgeContext used for type and taxonomy resolution.
 void setCurrentTaxonomyId(int taxonomyId)
          Sets the current taxonomy, by identifier, to be used to encode fields.
 void writeEnvelopeHeader(int processingDirectives, int schemaVersion, int messageSize)
          Writes a message envelope header.
 void writeField(FudgeField field)
          Writes a message field.
 void writeField(Short ordinal, String name, FudgeFieldType<?> type, Object fieldValue)
          Writes a message field.
 void writeFields(FudgeFieldContainer fields)
          Writes a set of fields.
 

Method Detail

getFudgeContext

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

Returns:
the FudgeContext

getCurrentTaxonomy

FudgeTaxonomy getCurrentTaxonomy()
Returns the taxonomy (if any) that is currently being used to encode fields. Returns null if no taxonomy is specified or the taxonomy identifier cannot be resolved by the bound FudgeContext.

Returns:
the FudgeTaxonomy

setCurrentTaxonomyId

void setCurrentTaxonomyId(int taxonomyId)
Sets the current taxonomy, by identifier, to be used to encode fields.

Parameters:
taxonomyId - the taxonomy identifier

getCurrentTaxonomyId

int getCurrentTaxonomyId()
Returns the current taxonomy identifier.

Returns:
current taxonomy identifier

writeEnvelopeHeader

void writeEnvelopeHeader(int processingDirectives,
                         int schemaVersion,
                         int messageSize)
Writes a message envelope header.

Parameters:
processingDirectives - the processing directive flags
schemaVersion - the schema version value
messageSize - the Fudge encoded size of the underlying message, including the message envelope

envelopeComplete

void envelopeComplete()
Signal the end of the message contained within an envelope. An implementation may not need to take any action at this point as the end of the envelope can be detected based on the message size in the header.


writeField

void writeField(FudgeField field)
Writes a message field.

Parameters:
field - the message field to write

writeField

void writeField(Short ordinal,
                String name,
                FudgeFieldType<?> type,
                Object fieldValue)
Writes a message field.

Parameters:
ordinal - the ordinal index of the field, or null to omit.
name - the name of the field, null to omit. If the ordinal is omitted and the name matches an entry in the current taxonomy the name will be replaced by the taxonomy resolved ordinal.
type - the type of the underlying data
fieldValue - value of the field

writeFields

void writeFields(FudgeFieldContainer fields)
Writes a set of fields.

Parameters:
fields - the fields to write.

flush

void flush()
Flushes any data from the internal buffers to the target stream and attempts to flush the underlying stream if appropriate.

Specified by:
flush in interface Flushable

close

void close()
Flushes and closes this writer and attempts to close the underlying stream 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