package net.sf.saxon.jetonnet; import net.sf.saxon.Configuration; import net.sf.saxon.lib.ParseOptions; import net.sf.saxon.om.NodeInfo; import net.sf.saxon.pull.PullSource; import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.XdmNode; import net.sf.saxon.s9api.XdmValue; import net.sf.saxon.trans.XPathException; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.xpath.XPath; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** * Created by ond1 on 06/03/2018. */ public class JetStream extends InputStream { private Object stream; private String baseURI; long currentOffset; long markedOffset = 0; /** * Create a DocumentBuilder. This is a protected constructor. Users should construct a DocumentBuilder * by calling the factory method {@link Processor#newDocumentBuilder()}. */ public JetStream() { } public JetStream(Object stream, String baseUri) { this.stream = stream; this.baseURI = baseUri; } public Object getPointerObject() { return stream; } public native int Readc(); public native int ReadArray(byte b[], int off, int len); public native boolean get_CanSeek(); public native long Seek(long l, int seekOrigin); public native void Close(); @Override public int read() throws IOException { int i = Readc(); if (i != -1) { currentOffset++; return i; } else { return -1; } } private int tempLen; private int tempOff; private byte [] tempB; public int getLength(){ return tempLen; } public int getOffset(){ return tempOff; } public byte [] getTempB(){ return tempB; } public void setTempB(byte [] b){ tempB = b; } public int read(byte b[], int off, int len) throws IOException { // System.err.println("Java - ReadArrayi off="+off + ", len= "+len); if(len == 0) { return 0; } setTempB(new byte[len]); tempLen = len; int c = ReadArray(b,off,len); for(int i=0;i