Class 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 Detail

      • JulieXMLBuffer

        public JulieXMLBuffer()
      • JulieXMLBuffer

        public JulieXMLBuffer​(byte[] ba)
    • 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:
        IOException
        com.ximpleware.ParseException
        com.ximpleware.extended.ParseExceptionHuge
      • byteAt

        public final byte byteAt​(long index)
        Specified by:
        byteAt in interface com.ximpleware.extended.IByteBuffer
      • getBytes

        public byte[] getBytes​(int offset,
                               int len)
        Return a byte array filled with content from underlying byte storage.
        Specified by:
        getBytes in interface com.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:
        length in interface com.ximpleware.extended.IByteBuffer
        Returns:
        int
      • getBytes

        public byte[] getBytes()
        Specified by:
        getBytes in interface com.ximpleware.extended.IByteBuffer
      • writeToFileOutputStream

        public void writeToFileOutputStream​(FileOutputStream ost,
                                            long os,
                                            long len)
                                     throws IOException
        Specified by:
        writeToFileOutputStream in interface com.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 of writeToFileOutputStream(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 IOException
        Convenience JULIE Lab method. It uses writeToOutputStream(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:
        close in interface com.ximpleware.extended.IByteBuffer