public final int getReplacementTextLength() { String str = getReplacementText(); return (str == null) ? 0 : str.length(); }
public static IntEntity create(String id, String repl) { return create(id, repl.toCharArray()); }
public WstxInputSource expand(WstxInputSource parent, XMLResolver res, ReaderConfig cfg, int xmlVersion) throws IOException, XMLStreamException { /* 05-Feb-2006, TSa: If xmlVersion not explicitly known, it defaults * to 1.0 */ if (xmlVersion == XmlConsts.XML_V_UNKNOWN) { xmlVersion = XmlConsts.XML_V_10; } return DefaultInputResolver.resolveEntity (parent, mContext, mName, getPublicId(), getSystemId(), res, cfg, xmlVersion); } }
ent = new IntEntity(evtLoc, id, getSource(), contents, contentLoc); } catch (IOException e) { throw new WstxIOException(e); ent.markAsExternallyDeclared(); EntityDecl oldED = (EntityDecl) old; String str = " entity '"+id+"' defined more than once: first declaration at " + oldED.getLocation(); if (isParam) { str = "Parameter" + str; if (ent.isParsed()) { // Parsed GE or PE } else { // unparsed GE final URL src; throw new WstxIOException(e); mEventListener.dtdUnparsedEntityDecl(id, ent.getPublicId(), ent.getSystemId(), ent.getNotationName(), src);
throws XMLStreamException String id = ed.getName(); if (!ed.isParsed()) { throwParseError("Illegal reference to unparsed external entity \"{0}\"", id, null); boolean isExt = ed.isExternal(); if (isExt) { if (!allowExt) { // never ok in attribute value... WstxInputSource newInput = null; try { newInput = ed.expand(oldInput, mEntityResolver, mConfig, mDocXmlVersion); } catch (FileNotFoundException fex) {
public void writeEnc(Writer w) throws IOException { w.write("<!ENTITY "); w.write(mName); String pubId = getPublicId(); if (pubId != null) { w.write("PUBLIC \""); w.write(pubId); w.write("\" "); } else { w.write("SYSTEM "); } w.write('"'); w.write(getSystemId()); w.write("\" NDATA "); w.write(mNotationId); w.write('>'); }
protected EntityDecl findEntity(String id, Object arg) throws XMLStreamException { EntityDecl ed = (EntityDecl) mConfig.findCustomInternalEntity(id); if (ed == null && mGeneralEntities != null) { ed = (EntityDecl) mGeneralEntities.get(id); } /* 05-Mar-2006, TSa: Externally declared entities are illegal * if we were declared as "standalone='yes'"... */ if (mDocStandalone == DOC_STANDALONE_YES) { if (ed != null && ed.wasDeclaredExternally()) { throwParseError(ErrorConsts.ERR_WF_ENTITY_EXT_DECLARED, ed.getName(), null); } } return ed; }
return new ParsedExtEntity(evtLoc, id, ctxt, pubId, sysId); return new UnparsedExtEntity(evtLoc, id, ctxt, pubId, sysId, notationId);
public String getLocalName() { // Note: for this we need not (yet) finish reading element if (mCurrToken == START_ELEMENT || mCurrToken == END_ELEMENT) { return mElementStack.getLocalName(); } if (mCurrToken == ENTITY_REFERENCE) { /* 30-Sep-2005, TSa: Entity will be null in non-expanding mode * if no definition was found: */ return (mCurrEntity == null) ? mCurrName: mCurrEntity.getName(); } throw new IllegalStateException("Current state not START_ELEMENT, END_ELEMENT or ENTITY_REFERENCE"); }
protected void checkEntity(InputProblemReporter rep, String id, EntityDecl ent) throws XMLStreamException { if (ent == null) { rep.reportValidationProblem("Referenced entity '"+id+"' not defined"); } else if (ent.isParsed()) { rep.reportValidationProblem("Referenced entity '"+id+"' is not an unparsed entity"); } }
public static IntEntity create(String id, char[] val) { WstxInputLocation loc = WstxInputLocation.getEmptyLocation(); return new IntEntity(loc, id, null, val, loc); }
public char[] getTextCharacters() { if (((1 << mCurrToken) & MASK_GET_TEXT_XXX) == 0) { throwNotTextXxx(mCurrToken); } if (mTokenState < mStTextThreshold) { safeFinishToken(); } if (mCurrToken == ENTITY_REFERENCE) { return mCurrEntity.getReplacementChars(); } if (mCurrToken == DTD) { return getDTDInternalSubsetArray(); } return mTextBuffer.getTextBuffer(); }
public void writeEnc(Writer w) throws IOException { w.write("<!ENTITY "); w.write(mName); String pubId = getPublicId(); if (pubId != null) { w.write("PUBLIC \""); w.write(pubId); w.write("\" "); } else { w.write("SYSTEM "); } w.write('"'); w.write(getSystemId()); w.write("\">"); }
public String getText() { if (((1 << mCurrToken) & MASK_GET_TEXT) == 0) { throwNotTextual(mCurrToken); } if (mTokenState < mStTextThreshold) { safeFinishToken(); } if (mCurrToken == ENTITY_REFERENCE) { return (mCurrEntity == null) ? null : mCurrEntity.getReplacementText(); } if (mCurrToken == DTD) { /* 16-Aug-2004, TSa: Hmmh. Specs are bit ambiguous on whether this * should return just the internal subset, or the whole * thing... */ return getDTDInternalSubset(); } return mTextBuffer.contentsAsString(); }
protected EntityDecl findEntityDecl(DTDValidatorBase v, char[] ch, int start, int len, int hash) throws XMLStreamException { Map entMap = v.getEntityMap(); /* !!! 13-Nov-2005, TSa: If this was to become a bottle-neck, we * could use/share a symbol table. Or at least reuse Strings... */ String id = new String(ch, start, len); EntityDecl ent = (EntityDecl) entMap.get(id); if (ent == null) { reportValidationProblem(v, "Referenced entity '"+id+"' not defined"); } else if (ent.isParsed()) { reportValidationProblem(v, "Referenced entity '"+id+"' is not an unparsed entity"); } return ent; }
(oldInput, id, null, null, resolver, mConfig, xmlVersion); if (mCfgTreatCharRefsAsEntities) { return new IntEntity(WstxInputLocation.getEmptyLocation(), newInput.getEntityId(), newInput.getSource(), new char[]{}, WstxInputLocation.getEmptyLocation());
/** * Returns an entity (possibly from cache) for the argument character using the encoded * representation in mInputBuffer[entityStartPos ... mInputPtr-1]. */ protected EntityDecl getIntEntity(int ch, final char[] originalChars) { String cacheKey = new String(originalChars); IntEntity entity = (IntEntity) mCachedEntities.get(cacheKey); if (entity == null) { String repl; if (ch <= 0xFFFF) { repl = Character.toString((char) ch); } else { StringBuffer sb = new StringBuffer(2); ch -= 0x10000; sb.append((char) ((ch >> 10) + 0xD800)); sb.append((char) ((ch & 0x3FF) + 0xDC00)); repl = sb.toString(); } entity = IntEntity.create(new String(originalChars), repl); mCachedEntities.put(cacheKey, entity); } return entity; }
return normalize ? ent.getName() : null;
return mCurrEntity.getReplacementText(w);