|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fudgemsg.xml.FudgeXMLSettings
org.fudgemsg.xml.FudgeXMLStreamWriter
public class FudgeXMLStreamWriter
Implementation of a FudgeStreamWriter
that writes XML to a text stream. This can be
used for XML output, or can be used to assist in developing/debugging a streaming serializer
without having to inspect the binary output from a FudgeDataOutputStreamWriter.
This code should adhere to the XML Fudge Message specification.
Note that no pretty printing options are available here. This implementation uses the systems default XMLOutputFactory
if only passed
a Writer
object at construction. If you require control over the output, you will need to use a suitable XMLStreamWriter
implementation that allows it. For example javanet.staxutils.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.fudgemsg.xml.FudgeXMLSettings |
---|
FudgeXMLSettings.XMLEnvelopeAttribute, FudgeXMLSettings.XMLFieldAttribute |
Field Summary |
---|
Constructor Summary | |
---|---|
FudgeXMLStreamWriter(FudgeContext fudgeContext,
Writer writer)
Creates a new FudgeXMLStreamWriter for writing to the target XML device. |
|
FudgeXMLStreamWriter(FudgeContext fudgeContext,
XMLStreamWriter writer)
Creates a new FudgeXMLStreamWriter for writing a Fudge stream to an XMLStreamWriter . |
|
FudgeXMLStreamWriter(FudgeXMLSettings settings,
FudgeContext fudgeContext,
Writer writer)
|
|
FudgeXMLStreamWriter(FudgeXMLSettings settings,
FudgeContext fudgeContext,
XMLStreamWriter writer)
|
Method Summary | |
---|---|
void |
close()
Flushes and closes this writer and attempts to close the underlying stream if appropriate. |
protected String |
convertFieldName(String str)
Remove any invalid characters to leave an XML element name. |
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. |
protected void |
fudgeEnvelopeEnd()
|
protected void |
fudgeEnvelopeStart(int processingDirectives,
int schemaVersion)
|
protected void |
fudgeFieldEnd()
|
protected boolean |
fudgeFieldStart(Short ordinal,
String name,
FudgeFieldType type)
|
protected void |
fudgeFieldValue(FudgeFieldType type,
Object fieldValue)
|
FudgeTaxonomy |
getCurrentTaxonomy()
Returns the taxonomy (if any) that is currently being used to encode fields. |
int |
getCurrentTaxonomyId()
Returns the current taxonomy identifier. |
protected FudgeStreamWriter |
getDelegate()
|
FudgeContext |
getFudgeContext()
Returns the bound FudgeContext used for type and taxonomy resolution. |
protected XMLStreamWriter |
getWriter()
Returns the underlying XMLStreamWriter . |
void |
setCurrentTaxonomyId(int taxonomyId)
Sets the current taxonomy, by identifier, to be used to encode fields. |
protected static FudgeRuntimeException |
wrapException(String operation,
XMLStreamException e)
|
protected void |
writeArray(byte[] array)
|
protected void |
writeArray(double[] array)
|
protected void |
writeArray(float[] array)
|
protected void |
writeArray(int[] array)
|
protected void |
writeArray(long[] array)
|
protected void |
writeArray(short[] array)
|
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 msg)
Writes a set of fields. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FudgeXMLStreamWriter(FudgeContext fudgeContext, Writer writer)
FudgeXMLStreamWriter
for writing to the target XML device.
fudgeContext
- the FudgeContext
writer
- the underlying Writer
public FudgeXMLStreamWriter(FudgeXMLSettings settings, FudgeContext fudgeContext, Writer writer)
public FudgeXMLStreamWriter(FudgeContext fudgeContext, XMLStreamWriter writer)
FudgeXMLStreamWriter
for writing a Fudge stream to an XMLStreamWriter
.
fudgeContext
- the FudgeContext
writer
- the underlying Writer
public FudgeXMLStreamWriter(FudgeXMLSettings settings, FudgeContext fudgeContext, XMLStreamWriter writer)
Method Detail |
---|
protected XMLStreamWriter getWriter()
XMLStreamWriter
.
XMLStreamWriter
protected static FudgeRuntimeException wrapException(String operation, XMLStreamException e)
operation
- the operation being attempted when the exception was caughte
- the exception caughtprotected FudgeStreamWriter getDelegate()
public void close()
close
in interface Closeable
close
in interface FudgeStreamWriter
public void flush()
flush
in interface Flushable
flush
in interface FudgeStreamWriter
public FudgeContext getFudgeContext()
FudgeContext
used for type and taxonomy resolution.
getFudgeContext
in interface FudgeStreamWriter
FudgeContext
public FudgeTaxonomy getCurrentTaxonomy()
null
if no taxonomy is specified or the taxonomy identifier cannot be resolved by the bound FudgeContext
.
getCurrentTaxonomy
in interface FudgeStreamWriter
FudgeTaxonomy
public void setCurrentTaxonomyId(int taxonomyId)
setCurrentTaxonomyId
in interface FudgeStreamWriter
taxonomyId
- the taxonomy identifierpublic int getCurrentTaxonomyId()
getCurrentTaxonomyId
in interface FudgeStreamWriter
public void writeEnvelopeHeader(int processingDirectives, int schemaVersion, int messageSize)
writeEnvelopeHeader
in interface FudgeStreamWriter
processingDirectives
- the processing directive flagsschemaVersion
- the schema version valuemessageSize
- the Fudge encoded size of the underlying message, including the message envelopepublic void envelopeComplete()
envelopeComplete
in interface FudgeStreamWriter
public void writeFields(FudgeFieldContainer msg)
writeFields
in interface FudgeStreamWriter
msg
- the fields to write.public void writeField(FudgeField field)
writeField
in interface FudgeStreamWriter
field
- the message field to writepublic void writeField(Short ordinal, String name, FudgeFieldType<?> type, Object fieldValue)
FudgeStreamWriter
writeField
in interface FudgeStreamWriter
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 datafieldValue
- value of the fieldprotected void fudgeEnvelopeStart(int processingDirectives, int schemaVersion) throws XMLStreamException
XMLStreamException
protected String convertFieldName(String str)
protected void writeArray(byte[] array) throws XMLStreamException
XMLStreamException
protected void writeArray(short[] array) throws XMLStreamException
XMLStreamException
protected void writeArray(int[] array) throws XMLStreamException
XMLStreamException
protected void writeArray(long[] array) throws XMLStreamException
XMLStreamException
protected void writeArray(float[] array) throws XMLStreamException
XMLStreamException
protected void writeArray(double[] array) throws XMLStreamException
XMLStreamException
protected boolean fudgeFieldStart(Short ordinal, String name, FudgeFieldType type) throws XMLStreamException
XMLStreamException
protected void fudgeFieldValue(FudgeFieldType type, Object fieldValue) throws XMLStreamException
XMLStreamException
protected void fudgeFieldEnd() throws XMLStreamException
XMLStreamException
protected void fudgeEnvelopeEnd() throws XMLStreamException
XMLStreamException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |