/** * @param r Eventual reader that will be reading actual content, after * bootstrapping finishes * @param appEncoding Encoding that application declared; may be null. * If not null, will be compared to actual declaration found; and * incompatibility reported as a potential (but not necessarily fatal) * problem. */ public static ReaderBootstrapper getInstance(String pubId, SystemId sysId, Reader r, String appEncoding) { return new ReaderBootstrapper(pubId, sysId, r, appEncoding); }
private static WstxInputSource sourceFromR(WstxInputSource parent, ReaderConfig cfg, String refName, int xmlVersion, Reader r, String pubId, String sysId) throws IOException, XMLStreamException { /* Last null -> no app-provided encoding (doesn't matter for non- * main-level handling) */ ReaderBootstrapper rbs = ReaderBootstrapper.getInstance(pubId, SystemId.construct(sysId), r, null); // null -> no xml reporter... should have one? Reader r2 = rbs.bootstrapInput(cfg, false, xmlVersion); URL ctxt = (parent == null) ? null : parent.getSource(); if (sysId != null && sysId.length() > 0) { ctxt = URLUtil.urlFromSystemId(sysId, ctxt); } return InputSourceFactory.constructEntitySource (cfg, parent, refName, rbs, pubId, SystemId.construct(sysId, ctxt), xmlVersion, r2); } }
protected void loadMore() throws IOException, WstxException { /* Need to make sure offsets are properly updated for error * reporting purposes, and do this now while previous amounts * are still known. */ mInputProcessed += mInputEnd; mInputRowStart -= mInputEnd; mInputPtr = 0; mInputEnd = mIn.read(mCharBuffer, 0, mCharBuffer.length); if (mInputEnd < 1) { throw new WstxEOFException(ParsingErrorMsgs.SUFFIX_IN_XML_DECL, getLocation()); } }
protected int getNextAfterWs(boolean reqWs) throws IOException, WstxException { int count = 0; while (true) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c > CHAR_SPACE) { if (reqWs && count == 0) { reportUnexpectedChar(c, ERR_XMLDECL_EXP_SPACE); } return c; } if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } ++count; } }
protected int readQuotedValue(char[] kw, int quoteChar) throws IOException, WstxException { int i = 0; int len = kw.length; while (true) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } if (c == quoteChar) { return (i < len) ? i : -1; } // Let's just truncate longer values, but match quote if (i < len) { kw[i++] = c; } } }
/** * @return First character that does not match expected, if any; * CHAR_NULL if match succeeded */ protected int checkKeyword(String exp) throws IOException, WstxException { int len = exp.length(); for (int ptr = 1; ptr < len; ++ptr) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c != exp.charAt(ptr)) { return c; } if (c == CHAR_NULL) { reportNull(); } } return CHAR_NULL; }
initialLoad(7); readXmlDecl(mainDoc, xmlVersion); verifyXmlEncoding(cfg);
protected XMLStreamReader2 createSR(SystemId systemId, Reader r, boolean forER, boolean autoCloseInput) throws XMLStreamException { return createSR(createPrivateConfig(), systemId, ReaderBootstrapper.getInstance (null, systemId, r, null), forER, autoCloseInput); }
protected int getNext() throws IOException, WstxException { return (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); }
protected char nextChar() throws IOException, WstxException { if (mInputPtr >= mInputEnd) { loadMore(); } return mCharBuffer[mInputPtr++]; }
protected int getNextAfterWs(boolean reqWs) throws IOException, WstxException { int count = 0; while (true) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c > CHAR_SPACE) { if (reqWs && count == 0) { reportUnexpectedChar(c, ERR_XMLDECL_EXP_SPACE); } return c; } if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } ++count; } }
initialLoad(7); readXmlDecl(mainDoc, xmlVersion); verifyXmlEncoding(cfg);
protected int readQuotedValue(char[] kw, int quoteChar) throws IOException, WstxException { int i = 0; int len = kw.length; while (true) { char c = (mInputPtr < mInputLen) ? mCharBuffer[mInputPtr++] : nextChar(); if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } if (c == quoteChar) { return (i < len) ? i : -1; } // Let's just truncate longer values, but match quote if (i < len) { kw[i++] = c; } } }
/** * @return First character that does not match expected, if any; * CHAR_NULL if match succeeded */ protected int checkKeyword(String exp) throws IOException, WstxException { int len = exp.length(); for (int ptr = 1; ptr < len; ++ptr) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c != exp.charAt(ptr)) { return c; } if (c == CHAR_NULL) { reportNull(); } } return CHAR_NULL; }
public XMLValidationSchema createSchema(Reader r, String publicId, String systemId) throws XMLStreamException { ReaderConfig rcfg = createPrivateReaderConfig(); return doCreateSchema(rcfg, ReaderBootstrapper.getInstance (publicId, SystemId.construct(systemId), r, null), publicId, systemId, null); }
protected void skipCRLF(char lf) throws IOException, WstxException { if (lf == CHAR_CR) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c != BYTE_LF) { --mInputPtr; // pushback if not 2-char/byte lf } } ++mInputRow; mInputRowStart = mInputPtr; } }
protected char nextChar() throws IOException, WstxException { if (mInputPtr >= mInputLen) { loadMore(); } return mCharBuffer[mInputPtr++]; }
protected int getNextAfterWs(boolean reqWs) throws IOException, WstxException { int count = 0; while (true) { char c = (mInputPtr < mInputLen) ? mCharBuffer[mInputPtr++] : nextChar(); if (c > CHAR_SPACE) { if (reqWs && count == 0) { reportUnexpectedChar(c, ERR_XMLDECL_EXP_SPACE); } return c; } if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } ++count; } }
initialLoad(7); readXmlDecl(mainDoc, xmlVersion); verifyXmlEncoding(cfg);
@Override protected int readQuotedValue(char[] kw, int quoteChar) throws IOException, WstxException { int i = 0; int len = kw.length; while (true) { char c = (mInputPtr < mInputEnd) ? mCharBuffer[mInputPtr++] : nextChar(); if (c == CHAR_CR || c == CHAR_LF) { skipCRLF(c); } else if (c == CHAR_NULL) { reportNull(); } if (c == quoteChar) { return (i < len) ? i : -1; } // Let's just truncate longer values, but match quote if (i < len) { kw[i++] = c; } } }