|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.ssonet.io.XMLTools
This class encloses some methods to handle common XML issues.
Field Summary | |
static boolean |
debug
|
Constructor Summary | |
XMLTools()
|
Method Summary | |
static int |
decodeLength(byte[] array)
Decodes the length field of a byte array. |
static byte[] |
encodeInteger(int intValue)
Encodes an Integer into an array of 4 bytes. |
static byte[] |
getLengthEncodingFor(byte[] array)
|
static byte[] |
joinByteArrays(byte[] array1,
byte[] array2)
joins two ByteArrays |
static org.w3c.dom.Element |
parseDocumentElementFromStream(java.io.InputStream xmlStream,
boolean isZipped)
parse a XML document from a stream. |
static org.w3c.dom.Element |
parseDocumentElementFromStream(org.ssonet.io.IOStream xmlStream,
boolean isZipped)
parse an XML document from an IOStream. |
static byte[] |
readByteArrayWithLengthEncoding(java.io.InputStream is)
Reads a byte array from an InputStream . |
static byte[] |
readByteArrayWithLengthEncoding(org.ssonet.io.IOStream ioStream)
Reads a byte array from an IOStream . |
static byte[] |
serializeDocument(org.w3c.dom.Document doc,
boolean isZipped)
Serializes a XML document. |
static void |
writeByteArrayWithLengthEncoding(org.ssonet.io.IOStream ioStream,
byte[] array)
Writes a byte array to an IOStream with a preceeding length encoding. |
static void |
writeByteArrayWithLengthEncoding(java.io.OutputStream os,
byte[] array)
Writes a byte array to a stream with a preceeding length encoding. |
static void |
writeDocumentToStream(org.ssonet.io.IOStream ioStream,
org.w3c.dom.Document doc,
boolean isZipped)
Writes a XML Document to an IOStream. |
static void |
writeDocumentToStream(java.io.OutputStream outputStream,
org.w3c.dom.Document doc,
boolean isZipped)
Writes a XML Document to an OutputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static boolean debug
Constructor Detail |
public XMLTools()
Method Detail |
public static org.w3c.dom.Element parseDocumentElementFromStream(java.io.InputStream xmlStream, boolean isZipped) throws java.io.IOException
xmlStream
- the stream, where the zipped document shall be read fromisZipped
- true, if the Document to be parsed is zipped, false otherwise
java.io.IOException
public static org.w3c.dom.Element parseDocumentElementFromStream(org.ssonet.io.IOStream xmlStream, boolean isZipped) throws java.io.IOException
xmlStream
- the IOStream, where the document shall be read fromisZipped
- true, if the document to be read is zipped, false otherwise
java.io.IOException
public static byte[] readByteArrayWithLengthEncoding(java.io.InputStream is) throws java.io.IOException
InputStream
. The byte array must be
preceeded by a length encoding in the following way:
1. and 2. Byte: length of content: (1.Byte)+(2.Byte)^8
3. to length. Byte: Content
is
- the InputStream
to read from
java.io.IOException
- if an error occures during reading the byte array from streampublic static byte[] readByteArrayWithLengthEncoding(org.ssonet.io.IOStream ioStream) throws java.io.IOException
IOStream
. The byte array must be
preceeded by a length encoding in the following way:
1. and 2. Byte: length of content: (1.Byte)+(2.Byte)^8
3. to length. Byte: Content
ioStream
- the IOStream
to read from
java.io.IOException
- if an error occures during reading the byte array from streampublic static int decodeLength(byte[] array) throws java.lang.IllegalArgumentException
array
- the array holding the length information
java.lang.IllegalArgumentException
- if the array is two short (array.length < 4), or (array==null)public static byte[] encodeInteger(int intValue)
intValue
- the value to encode
public static byte[] getLengthEncodingFor(byte[] array)
public static void writeDocumentToStream(java.io.OutputStream outputStream, org.w3c.dom.Document doc, boolean isZipped) throws java.io.IOException
outputStream
- the stream, where the XML Document shall be written to,doc
- the XML DocumentisZipped
- true, if the document to write shall be zipped, false otherwise
java.io.IOException
- if an error occures during encoding to XML and writing to the stream.public static void writeDocumentToStream(org.ssonet.io.IOStream ioStream, org.w3c.dom.Document doc, boolean isZipped) throws java.io.IOException
ioStream
- the IOStream, where the XML Document shall be written to,doc
- the XML DocumentisZipped
- true, if the document to write shall be zipped, false otherwise
java.io.IOException
- if an error occures during encoding to XML and writing to the stream.public static byte[] serializeDocument(org.w3c.dom.Document doc, boolean isZipped)
doc
- the XML documentisZipped
- true, if the document to serialize shall be zipped, false otherwise
public static void writeByteArrayWithLengthEncoding(java.io.OutputStream os, byte[] array) throws java.io.IOException
os
- the OutputStream
to write toarray
- the byte array
java.io.IOException
- if an error occures during writing the byte array to streampublic static void writeByteArrayWithLengthEncoding(org.ssonet.io.IOStream ioStream, byte[] array) throws java.io.IOException
ioStream
- the IOStream
to write toarray
- the byte array
java.io.IOException
- if an error occures during writing the byte array to streampublic static byte[] joinByteArrays(byte[] array1, byte[] array2)
array1
- first ByteArrayarray2
- second ByteArray
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |