Package de.julielab.xml
Class JulieXMLBuffer
- java.lang.Object
-
- de.julielab.xml.JulieXMLBuffer
-
- All Implemented Interfaces:
com.ximpleware.extended.IByteBuffer
public class JulieXMLBuffer extends Object implements com.ximpleware.extended.IByteBuffer
Copied from the original XMLBuffer in VTD XML version 2.10. Added the "getFragment(long, long)" method which just does what seemingly "getBytes" was meant for but not yet implemented.- Author:
- chew
-
-
Constructor Summary
Constructors Constructor Description JulieXMLBuffer()JulieXMLBuffer(byte[] ba)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description bytebyteAt(long index)voidclose()byte[]getBytes()byte[]getBytes(int offset, int len)Return a byte array filled with content from underlying byte storage.byte[]getFragment(long os, long len)Convenience JULIE Lab method.longlength()Total size in terms of # of bytes.voidreadFile(String fileName)JULIE Lab adopted version of the method.voidwriteToFileOutputStream(FileOutputStream ost, long os, long len)voidwriteToOutputStream(OutputStream ost, long os, long len)Convenience JULIE Lab method.
-
-
-
Method Detail
-
readFile
public void readFile(String fileName) throws IOException, com.ximpleware.extended.ParseExceptionHuge
JULIE Lab adopted version of the method. Does support GZIP files. GZIP files must end with ".gz" or ".gzip" in order to be recognized.- Parameters:
fileName-- Throws:
IOExceptioncom.ximpleware.ParseExceptioncom.ximpleware.extended.ParseExceptionHuge
-
byteAt
public final byte byteAt(long index)
- Specified by:
byteAtin interfacecom.ximpleware.extended.IByteBuffer
-
getBytes
public byte[] getBytes(int offset, int len)Return a byte array filled with content from underlying byte storage.- Specified by:
getBytesin interfacecom.ximpleware.extended.IByteBuffer- Parameters:
offset- int bytes offset (not UTF char unit)len- int- Returns:
- byte[]
-
length
public long length()
Total size in terms of # of bytes.- Specified by:
lengthin interfacecom.ximpleware.extended.IByteBuffer- Returns:
- int
-
getBytes
public byte[] getBytes()
- Specified by:
getBytesin interfacecom.ximpleware.extended.IByteBuffer
-
writeToFileOutputStream
public void writeToFileOutputStream(FileOutputStream ost, long os, long len) throws IOException
- Specified by:
writeToFileOutputStreamin interfacecom.ximpleware.extended.IByteBuffer- Throws:
IOException
-
writeToOutputStream
public void writeToOutputStream(OutputStream ost, long os, long len) throws IOException
Convenience JULIE Lab method. It's basically a copy ofwriteToFileOutputStream(java.io.FileOutputStream, long, long)but allows any kind of output stream as first parameter.- Parameters:
ost- Some OutputStream to write the specified XML buffer portion to.os- The offset, in bytes, to write to ost.len- The number of bytes to write, beginning at offset.- Throws:
IOException- If writing to the OutputStream fails.
-
getFragment
public byte[] getFragment(long os, long len) throws IOExceptionConvenience JULIE Lab method. It useswriteToOutputStream(OutputStream, long, long)with a ByteArrayOutputStream to return the specified buffer portion as a byte array.- Parameters:
os- Offset of the XML buffer to begin extraction, in bytes.len- Number of bytes to extract.- Returns:
- The bytes extracted from the XML buffer.
- Throws:
IOException- If writing to the internal ByteArrayOutputStream fails.
-
close
public void close()
- Specified by:
closein interfacecom.ximpleware.extended.IByteBuffer
-
-