|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xbis.XBISWriter
XML Binary Information Set output handler. This writes a compact representation of the data in an XML document, with the advantages of reduced document size and lower processing overhead as compared to the standard text document representation.
This class provides basic output handling, but the driver methods for walking a document representation and writing the corresponding serial form must be implemented by a subclass specific to the model used. The generated serial form is independent of the original model, and may be read by the input handlers for models other than the one from which it was generated.
Nested Class Summary | |
protected static class |
XBISWriter.OutputNamespace
Extended namespace information for output processing. |
Field Summary | |
static int |
DEFAULT_BUFFER_SIZE
Default size of output buffer. |
static int |
INITIAL_NAMESPACE_COUNT
Number of namespace declarations allowed for in default allocation. |
static int |
MINIMUM_BUFFER_SIZE
Minimum size for output buffer. |
static int |
SHORT_STRING_LIMIT
Limit for accessing String data a byte at a time. |
static int |
STRING_ARRAY_SIZE
Size of String character buffer (must be larger than short limit, but less than one third of the buffer size). |
Constructor Summary | |
XBISWriter(int size)
Constructor. |
Method Summary | |
protected void |
clearMark()
Clear buffer mark. |
protected void |
clearReset()
Clear reset state. |
void |
closeNamespaces(int count)
Close some number of active namespace declarations. |
protected abstract void |
defineAttribute(java.lang.Object obj)
Add attribute definition. |
void |
flush()
Write buffer to output stream. |
protected abstract int |
getAttributeHandle(java.lang.Object obj)
Get handle for attribute. |
XBISWriter.OutputNamespace |
getNamespace(java.lang.String prefix,
java.lang.String uri)
Get namespace declaration. |
protected abstract void |
initState()
Initialize state information used during the serialization process. |
protected boolean |
isReset()
Check reset state. |
protected int |
readMarked()
Read marked byte. |
void |
reset()
Reset state information used during the serialization process. |
protected void |
setMark()
Set buffer mark for later access. |
void |
setSharedAttributes(int limit)
Set shared attribute text parameter. |
void |
setSharedContent(int limit)
Set shared content text limit. |
protected void |
setStream(java.io.OutputStream os,
int id)
Set output stream. |
protected void |
writeAttribute(java.lang.Object obj,
java.lang.String value)
Write attribute to stream. |
protected void |
writeByte(int value)
Write byte to buffer. |
protected void |
writeChars(char[] buff,
int offset,
int length)
Write string of characters to stream. |
protected void |
writeMarked(int value)
Write marked byte. |
protected void |
writeNameDef(java.lang.String local,
XBISWriter.OutputNamespace ns)
Write name definition to stream. |
void |
writeNamespaceDecl(XBISWriter.OutputNamespace ns)
Write namespace declaration to stream. |
void |
writeNamespaceDef(XBISWriter.OutputNamespace ns)
Write namespace definition to stream. |
protected void |
writeQuickValue(int value,
int initial,
int mask)
Write non-negative integer value with partial lead byte to stream. |
protected void |
writeString(java.lang.String text)
Write String directly to stream. |
protected void |
writeStringChars(char[] buff,
int offset,
int length)
Write character string directly to stream. |
protected void |
writeStringData(java.lang.String text)
Write String data to stream. |
protected void |
writeText(char[] buff,
int offset,
int length)
Write content text to stream. |
protected void |
writeText(java.lang.String text)
Write content text to stream. |
protected void |
writeValue(int value)
Write non-negative integer value to stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_BUFFER_SIZE
public static final int SHORT_STRING_LIMIT
public static final int STRING_ARRAY_SIZE
public static final int MINIMUM_BUFFER_SIZE
public static final int INITIAL_NAMESPACE_COUNT
Constructor Detail |
public XBISWriter(int size)
size
- output buffer sizeMethod Detail |
protected final void setStream(java.io.OutputStream os, int id) throws java.io.IOException
os
- serialization output streamid
- output adapter identifier
java.io.IOException
- on error writing to streampublic final void setSharedContent(int limit)
String
s of no more than the limit length are
assigned handles and checked for duplication so the same content will
only be sent once.
limit
- maximum number of characters for sharing (zero to disable)public final void setSharedAttributes(int limit)
String
s of no more than the limit
length are assigned handles and checked for duplication so the same
value will only be sent once.
limit
- maximum number of characters for sharing (zero to disable)protected final void setMark() throws java.io.IOException
java.io.IOException
- on error writing to streamprotected final int readMarked()
protected final void writeMarked(int value)
value
- value to be written to byteprotected final void clearMark()
public void flush() throws java.io.IOException
java.io.IOException
- on error writing to streamprotected final void writeByte(int value) throws java.io.IOException
value
- byte to be stored to buffer
java.io.IOException
- on error writing to streamprotected void writeValue(int value) throws java.io.IOException
value
- value to be written to stream
java.io.IOException
- on error writing to streamprotected final void writeQuickValue(int value, int initial, int mask) throws java.io.IOException
value
- value to be written to streaminitial
- byte containing high bits of valuemask
- value mask within first byte (right justified)
java.io.IOException
- on error writing to streamprotected final void writeChars(char[] buff, int offset, int length) throws java.io.IOException
buff
- array containing characters to be writtenoffset
- starting offset in bufferlength
- number of characters in string
java.io.IOException
- on error writing to streamprotected final void writeStringData(java.lang.String text) throws java.io.IOException
String
data to stream. This method uses a dual
approach to retrieving the array of characters in the
String
, depending on the number of characters. If the count
is low, the code first makes sure there's enough space in the buffer to
hold all the encoded characters and then accesses them one at a time for
conversion. If the count is high, we retrieve the entire array of
characters and then encode them in chunks guaranteed to fit in the
buffer. This approach creates some duplicate code, but gives the best
performance.
text
- String
to be written
java.io.IOException
- on error writing to streamprotected final void writeStringChars(char[] buff, int offset, int length) throws java.io.IOException
buff
- array containing characters to be written
(non-null
)offset
- starting offset in bufferlength
- number of characters in string
java.io.IOException
- on error writing to streamwriteChars(char[], int, int)
protected final void writeString(java.lang.String text) throws java.io.IOException
String
directly to stream. This handles encoding of
the String
value representation used in the serial form.
The character count plus one is first encoded in the standard integer
value format (with the value zero reserved for use with null
String
s), followed by the specified number of characters.
text
- String
to be written (may be null
)
java.io.IOException
- on error writing to streamwriteStringData(java.lang.String)
protected final void writeText(char[] buff, int offset, int length) throws java.io.IOException
buff
- array containing characters to be writtenoffset
- starting offset in bufferlength
- number of characters in string
java.io.IOException
- on error writing to streamprotected final void writeText(java.lang.String text) throws java.io.IOException
text
- content text to be written
java.io.IOException
- on error writing to streampublic void writeNamespaceDef(XBISWriter.OutputNamespace ns) throws java.io.IOException
ns
- namespace to be declared
java.io.IOException
- on error writing to streampublic void writeNamespaceDecl(XBISWriter.OutputNamespace ns) throws java.io.IOException
ns
- namespace to be declared
java.io.IOException
- on error writing to streamprotected final void writeNameDef(java.lang.String local, XBISWriter.OutputNamespace ns) throws java.io.IOException
local
- local name to be writtenns
- namespace object for name
java.io.IOException
- on error writing to streamprotected final void writeAttribute(java.lang.Object obj, java.lang.String value) throws java.io.IOException
obj
- attribute to be writtenvalue
- text of value to be written
java.io.IOException
- on error writing to streampublic XBISWriter.OutputNamespace getNamespace(java.lang.String prefix, java.lang.String uri) throws XBISException
prefix
- element namespace prefixuri
- element namespace URI
XBISException
- on namespace errorpublic void closeNamespaces(int count)
count
- number of active namespace declarations to be closedprotected void clearReset()
protected boolean isReset()
true
if reset, false
if notpublic void reset()
protected abstract void initState()
protected abstract int getAttributeHandle(java.lang.Object obj)
obj
- attribute object for which handle is to be found
protected abstract void defineAttribute(java.lang.Object obj) throws java.io.IOException
obj
- attribute object to be defined
java.io.IOException
- on error writing to stream
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |