private XMLStreamReader parse(InputStream is, String systemIdStr, boolean restricted) throws IOException, XMLStreamException { if (!quietmode) { LOG.debug("parsing input stream " + is); } if (is == null) { return null; } SystemId systemId = SystemId.construct(systemIdStr); ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig(); if (restricted) { readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false); } return XML_INPUT_FACTORY.createSR(readerConfig, systemId, StreamBootstrapper.getInstance(null, systemId, is), false, true); }
public int readInto(WstxInputData reader) throws IOException, XMLStreamException { // Need to flush out branched content? if (mBranchBuffer != null) { if (mInputLast > mBranchStartOffset) { appendBranched(mBranchStartOffset, mInputLast); } mBranchStartOffset = 0; } return super.readInto(reader); }
public char[] allocFullCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getFullCBuffer(minSize); if (result != null) { return result; } } return new char[minSize]; }
/** * Method that returns location of the last character returned by this * reader; that is, location "one less" than the currently pointed to * location. */ protected WstxInputLocation getLastCharLocation() { return mInput.getLocation(mCurrInputProcessed + mInputPtr - 1, mCurrInputRow, mInputPtr - mCurrInputRowStart); }
/** * Factory method used when the underlying data provider is an * actual stream. */ public static StreamBootstrapper getInstance(String pubId, SystemId sysId, InputStream in) { return new StreamBootstrapper(pubId, sysId, in); }
/** * Constructor used for reading external subset. */ private FullDTDReader(WstxInputSource input, ReaderConfig cfg, DTDSubset intSubset, boolean constructFully, int xmlVersion) { this(input, cfg, true, intSubset, constructFully, xmlVersion); // Let's make sure line/col offsets are correct... input.initInputLocation(this, mCurrDepth, 0); }
public byte[] allocFullBBuffer(int minSize) { if (mCurrRecycler != null) { byte[] result = mCurrRecycler.getFullBBuffer(minSize); if (result != null) { return result; } } return new byte[minSize]; }
public void closeCompletely() throws IOException { /* Only need to call if the Reader is not yet null... since * buffer may have been cleaned by a call to close() */ if (mReader != null) { // so that it's ok to call multiple times closeAndRecycle(true); } }
protected byte nextByte() throws IOException, WstxException { if (mInputPtr >= mInputEnd) { loadMore(); } return mByteBuffer[mInputPtr++]; }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
protected char nextChar() throws IOException, WstxException { if (mInputPtr >= mInputEnd) { loadMore(); } return mCharBuffer[mInputPtr++]; }
public char[] allocSmallCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getSmallCBuffer(minSize); if (result != null) { return result; } } // Nope; no recycler, or it has no suitable buffers, let's create: return new char[minSize]; }
public char[] allocMediumCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getMediumCBuffer(minSize); if (result != null) { return result; } } return new char[minSize]; }
/** * This method only gets called by the 'child' input source (for example, * contents of an expanded entity), to get the enclosing context location. */ protected final WstxInputLocation getLocation() { // Note: columns are 1-based, need to add 1. return getLocation(mSavedInputProcessed + mSavedInputPtr - 1L, mSavedInputRow, mSavedInputPtr - mSavedInputRowStart + 1); }
public void overrideSource(URL src) { //19-May-2014, tatu: I assume this should also override observed systemId... mSystemId = SystemId.construct(src); }
public static SystemId construct(String systemId, URL url) { if (systemId == null && url == null) { return null; } return new SystemId(systemId, url); }
public WstxInputLocation(WstxInputLocation ctxt, String pubId, SystemId sysId, long charOffset, int row, int col) { mContext = ctxt; mPublicId = pubId; mSystemId = (sysId == null) ? "N/A" : sysId.toString(); mCharOffset = charOffset; mCol = col; mRow = row; }
public XMLStreamLocation2 getCurrentLocation() { return mInput.getLocation(mCurrInputProcessed + mInputPtr, mCurrInputRow, mInputPtr - mCurrInputRowStart + 1); }
public char[] allocFullCBuffer(int minSize) { if (mCurrRecycler != null) { char[] result = mCurrRecycler.getFullCBuffer(minSize); if (result != null) { return result; } } return new char[minSize]; }
/** * Factory method used when the underlying data provider is a pre-allocated * block source, and no stream is used. * Additionally the buffer passed is not owned by the bootstrapper * or Reader that is created, so it is not to be recycled. */ public static StreamBootstrapper getInstance(String pubId, SystemId sysId, byte[] data, int start, int end) { return new StreamBootstrapper(pubId, sysId, data, start, end); }