类javax.xml.stream.events.NotationDeclaration源码实例Demo

下面列出了怎么用javax.xml.stream.events.NotationDeclaration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Bytecoder   文件: XMLStreamReaderImpl.java
protected List<NotationDeclaration> getNotationDecls() {
    if (fEventType == XMLStreamConstants.DTD) {
        if (fScanner.fDTDScanner == null) {
            return null;
        }
        DTDGrammar grammar = ((XMLDTDScannerImpl) (fScanner.fDTDScanner)).getGrammar();
        if (grammar == null) {
            return null;
        }
        List<XMLNotationDecl> notations = grammar.getNotationDecls();
        ArrayList<NotationDeclaration> list = new ArrayList<>();
        for (XMLNotationDecl notation : notations) {
            if (notation != null) {
                list.add(new NotationDeclarationImpl(notation));
            }
        }
        return list;
    }
    return null;
}
 
源代码2 项目: openjdk-jdk9   文件: XMLStreamReaderImpl.java
protected List<NotationDeclaration> getNotationDecls() {
    if (fEventType == XMLStreamConstants.DTD) {
        if (fScanner.fDTDScanner == null) {
            return null;
        }
        DTDGrammar grammar = ((XMLDTDScannerImpl) (fScanner.fDTDScanner)).getGrammar();
        if (grammar == null) {
            return null;
        }
        List<XMLNotationDecl> notations = grammar.getNotationDecls();
        ArrayList<NotationDeclaration> list = new ArrayList<>();
        for (XMLNotationDecl notation : notations) {
            if (notation != null) {
                list.add(new NotationDeclarationImpl(notation));
            }
        }
        return list;
    }
    return null;
}
 
源代码3 项目: woodstox   文件: DTDSubsetImpl.java
private DTDSubsetImpl(boolean cachable,
                      HashMap<String,EntityDecl> genEnt, Set<String> refdGEs,
                      HashMap<String,EntityDecl> paramEnt, Set<String> peRefs,
                      HashMap<String,NotationDeclaration> notations, HashMap<PrefixedName,DTDElement> elements,
                      boolean fullyValidating)
{
    mIsCachable = cachable;
    mGeneralEntities = genEnt;
    mRefdGEs = refdGEs;
    mDefinedPEs = paramEnt;
    mRefdPEs = peRefs;
    mNotations = notations;
    mElements = elements;
    mFullyValidating = fullyValidating;

    boolean anyNsDefs = false;
    if (elements != null) {
    	for (DTDElement elem : elements.values()) {
            if (elem.hasNsDefaults()) {
                anyNsDefs = true;
                break;
            }
        }
    }
    mHasNsDefaults = anyNsDefs;
}
 
源代码4 项目: openjdk-jdk9   文件: Issue48Test.java
/**
 * DTDEvent instances constructed via event reader are missing the notation
 * and entity declaration information
 */
@Test
public void testDTDEvent() {
    String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
            + "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
            + "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";

    try {
        XMLEventReader er = getReader(XML);
        XMLEvent evt = er.nextEvent(); // StartDocument
        evt = er.nextEvent(); // DTD
        if (evt.getEventType() != XMLStreamConstants.DTD) {
            Assert.fail("Expected DTD event");
        }
        DTD dtd = (DTD) evt;
        List entities = dtd.getEntities();
        if (entities == null) {
            Assert.fail("No entity found. Expected 3.");
        } else {
            Assert.assertEquals(entities.size(), 3);
        }
        // Let's also verify they are all of right type...
        testListElems(entities, EntityDeclaration.class);

        List notations = dtd.getNotations();
        if (notations == null) {
            Assert.fail("No notation found. Expected 2.");
        } else {
            Assert.assertEquals(notations.size(), 2);
        }
        // Let's also verify they are all of right type...
        testListElems(notations, NotationDeclaration.class);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
 
源代码5 项目: woodstox   文件: WDTD.java
@Override
public List<NotationDeclaration> getNotations() {
    if (mNotations == null && (mSubset != null)) {
        mNotations = new ArrayList<NotationDeclaration>(mSubset.getNotationList());
    }
    return mNotations;
}
 
源代码6 项目: woodstox   文件: DTDSubsetImpl.java
public static DTDSubsetImpl constructInstance(boolean cachable,
                                              HashMap<String,EntityDecl> genEnt, Set<String> refdGEs,
                                              HashMap<String,EntityDecl> paramEnt, Set<String> refdPEs,
                                              HashMap<String,NotationDeclaration> notations,
                                              HashMap<PrefixedName,DTDElement> elements,
                                              boolean fullyValidating)
{
    return new DTDSubsetImpl(cachable, genEnt, refdGEs,
                             paramEnt, refdPEs,
                             notations, elements,
                             fullyValidating);
}
 
源代码7 项目: woodstox   文件: DTDSubsetImpl.java
@Override
public synchronized List<NotationDeclaration> getNotationList()
{
    List<NotationDeclaration> l = mNotationList;
    if (l == null) {
        if (mNotations == null || mNotations.size() == 0) {
            l = Collections.emptyList();
        } else {
            l = Collections.unmodifiableList(new ArrayList<NotationDeclaration>(mNotations.values()));
        }
        mNotationList = l;
    }

    return l;
}
 
源代码8 项目: woodstox   文件: DTDSubsetImpl.java
public static void throwNotationException(NotationDeclaration oldDecl, NotationDeclaration newDecl)
    throws XMLStreamException
{
    throw new WstxParsingException
        (MessageFormat.format(ErrorConsts.ERR_DTD_NOTATION_REDEFD,
                              new Object[] {
                              newDecl.getName(),
                              oldDecl.getLocation().toString()}),
         newDecl.getLocation());
}
 
源代码9 项目: woodstox   文件: DTDSubsetImpl.java
private static void checkNotations(HashMap<String,NotationDeclaration> fromInt, HashMap<String,NotationDeclaration> fromExt)
    throws XMLStreamException
{
    /* Since it's external subset that would try to redefine things
     * defined in internal subset, let's traverse definitions in
     * the ext. subset first (even though that may not be the fastest
     * way), so that we have a chance of catching the first problem
     * (As long as Maps iterate in insertion order).
     */
	for (Map.Entry<String, NotationDeclaration> en : fromExt.entrySet()) {
        if (fromInt.containsKey(en.getKey())) {
            throwNotationException(fromInt.get(en.getKey()), en.getValue());
        }
    }
}
 
源代码10 项目: woodstox   文件: TestDoctypeDecl.java
public void testSimpleNotation()
    throws XMLStreamException
{
    XMLStreamReader sr = getReader(UNPARSED_ENTITY_XML, true);
    assertTokenType(DTD, sr.next());
    List<?> l = (List<?>) sr.getProperty("javax.xml.stream.notations");
    assertNotNull(l);
    assertEquals(1, l.size());
    NotationDeclaration nd = (NotationDeclaration) l.get(0);
    assertEquals("mynot", nd.getName());
}
 
源代码11 项目: spring-analysis-note   文件: StaxEventXMLReader.java
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
	boolean documentStarted = false;
	boolean documentEnded = false;
	int elementDepth = 0;
	while (this.reader.hasNext() && elementDepth >= 0) {
		XMLEvent event = this.reader.nextEvent();
		if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
			handleStartDocument(event);
			documentStarted = true;
		}
		switch (event.getEventType()) {
			case XMLStreamConstants.START_DOCUMENT:
				handleStartDocument(event);
				documentStarted = true;
				break;
			case XMLStreamConstants.START_ELEMENT:
				elementDepth++;
				handleStartElement(event.asStartElement());
				break;
			case XMLStreamConstants.END_ELEMENT:
				elementDepth--;
				if (elementDepth >= 0) {
					handleEndElement(event.asEndElement());
				}
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				handleProcessingInstruction((ProcessingInstruction) event);
				break;
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA:
				handleCharacters(event.asCharacters());
				break;
			case XMLStreamConstants.END_DOCUMENT:
				handleEndDocument();
				documentEnded = true;
				break;
			case XMLStreamConstants.NOTATION_DECLARATION:
				handleNotationDeclaration((NotationDeclaration) event);
				break;
			case XMLStreamConstants.ENTITY_DECLARATION:
				handleEntityDeclaration((EntityDeclaration) event);
				break;
			case XMLStreamConstants.COMMENT:
				handleComment((Comment) event);
				break;
			case XMLStreamConstants.DTD:
				handleDtd((DTD) event);
				break;
			case XMLStreamConstants.ENTITY_REFERENCE:
				handleEntityReference((EntityReference) event);
				break;
		}
	}
	if (documentStarted && !documentEnded) {
		handleEndDocument();
	}

}
 
源代码12 项目: spring-analysis-note   文件: StaxEventXMLReader.java
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
	if (getDTDHandler() != null) {
		getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
	}
}
 
源代码13 项目: java-technology-stack   文件: StaxEventXMLReader.java
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
	boolean documentStarted = false;
	boolean documentEnded = false;
	int elementDepth = 0;
	while (this.reader.hasNext() && elementDepth >= 0) {
		XMLEvent event = this.reader.nextEvent();
		if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
			handleStartDocument(event);
			documentStarted = true;
		}
		switch (event.getEventType()) {
			case XMLStreamConstants.START_DOCUMENT:
				handleStartDocument(event);
				documentStarted = true;
				break;
			case XMLStreamConstants.START_ELEMENT:
				elementDepth++;
				handleStartElement(event.asStartElement());
				break;
			case XMLStreamConstants.END_ELEMENT:
				elementDepth--;
				if (elementDepth >= 0) {
					handleEndElement(event.asEndElement());
				}
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				handleProcessingInstruction((ProcessingInstruction) event);
				break;
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA:
				handleCharacters(event.asCharacters());
				break;
			case XMLStreamConstants.END_DOCUMENT:
				handleEndDocument();
				documentEnded = true;
				break;
			case XMLStreamConstants.NOTATION_DECLARATION:
				handleNotationDeclaration((NotationDeclaration) event);
				break;
			case XMLStreamConstants.ENTITY_DECLARATION:
				handleEntityDeclaration((EntityDeclaration) event);
				break;
			case XMLStreamConstants.COMMENT:
				handleComment((Comment) event);
				break;
			case XMLStreamConstants.DTD:
				handleDtd((DTD) event);
				break;
			case XMLStreamConstants.ENTITY_REFERENCE:
				handleEntityReference((EntityReference) event);
				break;
		}
	}
	if (documentStarted && !documentEnded) {
		handleEndDocument();
	}

}
 
源代码14 项目: java-technology-stack   文件: StaxEventXMLReader.java
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
	if (getDTDHandler() != null) {
		getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
	}
}
 
源代码15 项目: lams   文件: StaxEventXMLReader.java
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
	boolean documentStarted = false;
	boolean documentEnded = false;
	int elementDepth = 0;
	while (this.reader.hasNext() && elementDepth >= 0) {
		XMLEvent event = this.reader.nextEvent();
		if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
			handleStartDocument(event);
			documentStarted = true;
		}
		switch (event.getEventType()) {
			case XMLStreamConstants.START_DOCUMENT:
				handleStartDocument(event);
				documentStarted = true;
				break;
			case XMLStreamConstants.START_ELEMENT:
				elementDepth++;
				handleStartElement(event.asStartElement());
				break;
			case XMLStreamConstants.END_ELEMENT:
				elementDepth--;
				if (elementDepth >= 0) {
					handleEndElement(event.asEndElement());
				}
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				handleProcessingInstruction((ProcessingInstruction) event);
				break;
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA:
				handleCharacters(event.asCharacters());
				break;
			case XMLStreamConstants.END_DOCUMENT:
				handleEndDocument();
				documentEnded = true;
				break;
			case XMLStreamConstants.NOTATION_DECLARATION:
				handleNotationDeclaration((NotationDeclaration) event);
				break;
			case XMLStreamConstants.ENTITY_DECLARATION:
				handleEntityDeclaration((EntityDeclaration) event);
				break;
			case XMLStreamConstants.COMMENT:
				handleComment((Comment) event);
				break;
			case XMLStreamConstants.DTD:
				handleDtd((DTD) event);
				break;
			case XMLStreamConstants.ENTITY_REFERENCE:
				handleEntityReference((EntityReference) event);
				break;
		}
	}
	if (documentStarted && !documentEnded) {
		handleEndDocument();
	}

}
 
源代码16 项目: lams   文件: StaxEventXMLReader.java
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
	if (getDTDHandler() != null) {
		getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
	}
}
 
源代码17 项目: Bytecoder   文件: DTDEvent.java
public void setNotations(List<NotationDeclaration> notations) {
    fNotations = notations;
}
 
源代码18 项目: Bytecoder   文件: DTDEvent.java
@Override
public List<NotationDeclaration> getNotations() {
    return fNotations;
}
 
源代码19 项目: openjdk-jdk9   文件: DTDEvent.java
public void setNotations(List<NotationDeclaration> notations) {
    fNotations = notations;
}
 
源代码20 项目: openjdk-jdk9   文件: DTDEvent.java
@Override
public List<NotationDeclaration> getNotations() {
    return fNotations;
}
 
源代码21 项目: spring4-understanding   文件: StaxEventXMLReader.java
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
	boolean documentStarted = false;
	boolean documentEnded = false;
	int elementDepth = 0;
	while (this.reader.hasNext() && elementDepth >= 0) {
		XMLEvent event = this.reader.nextEvent();
		if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
			handleStartDocument(event);
			documentStarted = true;
		}
		switch (event.getEventType()) {
			case XMLStreamConstants.START_DOCUMENT:
				handleStartDocument(event);
				documentStarted = true;
				break;
			case XMLStreamConstants.START_ELEMENT:
				elementDepth++;
				handleStartElement(event.asStartElement());
				break;
			case XMLStreamConstants.END_ELEMENT:
				elementDepth--;
				if (elementDepth >= 0) {
					handleEndElement(event.asEndElement());
				}
				break;
			case XMLStreamConstants.PROCESSING_INSTRUCTION:
				handleProcessingInstruction((ProcessingInstruction) event);
				break;
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA:
				handleCharacters(event.asCharacters());
				break;
			case XMLStreamConstants.END_DOCUMENT:
				handleEndDocument();
				documentEnded = true;
				break;
			case XMLStreamConstants.NOTATION_DECLARATION:
				handleNotationDeclaration((NotationDeclaration) event);
				break;
			case XMLStreamConstants.ENTITY_DECLARATION:
				handleEntityDeclaration((EntityDeclaration) event);
				break;
			case XMLStreamConstants.COMMENT:
				handleComment((Comment) event);
				break;
			case XMLStreamConstants.DTD:
				handleDtd((DTD) event);
				break;
			case XMLStreamConstants.ENTITY_REFERENCE:
				handleEntityReference((EntityReference) event);
				break;
		}
	}
	if (documentStarted && !documentEnded) {
		handleEndDocument();
	}

}
 
源代码22 项目: spring4-understanding   文件: StaxEventXMLReader.java
private void handleNotationDeclaration(NotationDeclaration declaration) throws SAXException {
	if (getDTDHandler() != null) {
		getDTDHandler().notationDecl(declaration.getName(), declaration.getPublicId(), declaration.getSystemId());
	}
}
 
源代码23 项目: woodstox   文件: FullDTDReader.java
/**
 * Common initialization part of int/ext subset constructors.
 */
private FullDTDReader(WstxInputSource input, ReaderConfig cfg,
                      boolean isExt, DTDSubset intSubset,
                      boolean constructFully, int xmlVersion)
{
    super(input, cfg, isExt);
    /* What matters here is what the main xml doc had; that determines
     * xml conformance level to use.
     */
    mDocXmlVersion = xmlVersion;
    mXml11 = cfg.isXml11();
    int cfgFlags = cfg.getConfigFlags();
    mConfigFlags = cfgFlags;
    mCfgSupportDTDPP = (cfgFlags & CFG_SUPPORT_DTDPP) != 0;
    mCfgFullyValidating = constructFully;

    mUsesPredefdEntities = false;
    mParamEntities = null;
    mRefdPEs = null;
    mRefdGEs = null;
    mGeneralEntities = null;

    // Did we get any existing parameter entities?
    HashMap<String,EntityDecl> pes = (intSubset == null) ?
        null : intSubset.getParameterEntityMap();
    if (pes == null || pes.isEmpty()) {
        mPredefdPEs = null;
    } else {
        mPredefdPEs = pes;
    }

    // How about general entities (needed only for attr. def. values)
    HashMap<String,EntityDecl> ges = (intSubset == null) ?
        null : intSubset.getGeneralEntityMap();
    if (ges == null || ges.isEmpty()) {
        mPredefdGEs = null;
    } else {
        mPredefdGEs = ges;
    }

    // And finally, notations
    HashMap<String,NotationDeclaration> not = (intSubset == null) ?
        null : intSubset.getNotationMap();
    if (not == null || not.isEmpty()) {
        mPredefdNotations = null;
    } else {
        mPredefdNotations = not;
    }
    mEventListener = mConfig.getDTDEventListener();
}
 
源代码24 项目: woodstox   文件: DTDSubsetImpl.java
/**
 * Method that will combine definitions from internal and external subsets,
 * producing a single DTD set.
 */
@Override
public DTDSubset combineWithExternalSubset(InputProblemReporter rep, DTDSubset extSubset)
    throws XMLStreamException
{
    /* First let's see if we can just reuse GE Map used by int or ext
     * subset; (if only one has contents), or if not, combine them.
     */
    HashMap<String,EntityDecl> ge1 = getGeneralEntityMap();
    HashMap<String,EntityDecl> ge2 = extSubset.getGeneralEntityMap();
    if (ge1 == null || ge1.isEmpty()) {
        ge1 = ge2;
    } else {
        if (ge2 != null && !ge2.isEmpty()) {
            /* Internal subset Objects are never shared or reused (and by
             * extension, neither are objects they contain), so we can just
             * modify GE map if necessary
             */
            combineMaps(ge1, ge2);
        }
    }

    // Ok, then, let's combine notations similarly
    HashMap<String,NotationDeclaration> n1 = getNotationMap();
    HashMap<String,NotationDeclaration> n2 = extSubset.getNotationMap();
    if (n1 == null || n1.isEmpty()) {
        n1 = n2;
    } else {
        if (n2 != null && !n2.isEmpty()) {
            /* First; let's make sure there are no colliding notation
             * definitions: it's an error to try to redefine notations.
             */
            checkNotations(n1, n2);

            /* Internal subset Objects are never shared or reused (and by
             * extension, neither are objects they contain), so we can just
             * modify notation map if necessary
             */
            combineMaps(n1, n2);
        }
    }


    // And finally elements, rather similarly:
    HashMap<PrefixedName,DTDElement> e1 = getElementMap();
    HashMap<PrefixedName,DTDElement> e2 = extSubset.getElementMap();
    if (e1 == null || e1.isEmpty()) {
        e1 = e2;
    } else {
        if (e2 != null && !e2.isEmpty()) {
            /* Internal subset Objects are never shared or reused (and by
             * extension, neither are objects they contain), so we can just
             * modify element map if necessary
             */
            combineElements(rep, e1, e2);
        }
    }

    /* Combos are not cachable, and because of that, there's no point
     * in storing any PE info either.
     */
    return constructInstance(false, ge1, null, null, null, n1, e1,
                             mFullyValidating);
}
 
源代码25 项目: woodstox   文件: DTDSubsetImpl.java
@Override
public HashMap<String,NotationDeclaration> getNotationMap() {
    return mNotations;
}
 
源代码26 项目: entity-fishing   文件: XmlUtils.java
/**
 * Compares two {@link XMLEvent} instances. This method delegates actual
 * matching to the appropriate overloaded method.
 * 
 * @param a
 *            The first event.
 * @param b
 *            The second event.
 * @return <code>true</code> if the events match, <code>false</code>
 *         otherwise.
 */
public static boolean eventsMatch(XMLEvent a, XMLEvent b) {

	if (a == b) {

		return true;

	} else if (a == null || b == null) {

		return false;

	} else if (a.getEventType() == b.getEventType()) {

		switch (a.getEventType()) {

		case XMLEvent.START_ELEMENT:
			return eventsMatch(a.asStartElement(), b.asStartElement());

		case XMLEvent.END_ELEMENT:
			return eventsMatch(a.asEndElement(), b.asEndElement());

		case XMLEvent.CDATA:
		case XMLEvent.SPACE:
		case XMLEvent.CHARACTERS:
			return eventsMatch(a.asCharacters(), b.asCharacters());

		case XMLEvent.COMMENT:
			return eventsMatch((Comment) a, (Comment) b);

		case XMLEvent.ENTITY_REFERENCE:
			return eventsMatch((EntityReference) a, (EntityReference) b);

		case XMLEvent.ATTRIBUTE:
			return eventsMatch((Attribute) a, (Attribute) b);

		case XMLEvent.NAMESPACE:
			return eventsMatch((Namespace) a, (Namespace) b);

		case XMLEvent.START_DOCUMENT:
			return eventsMatch((StartDocument) a, (StartDocument) b);

		case XMLEvent.END_DOCUMENT:
			return eventsMatch((EndDocument) a, (EndDocument) b);

		case XMLEvent.PROCESSING_INSTRUCTION:
			return eventsMatch((ProcessingInstruction) a, (ProcessingInstruction) b);

		case XMLEvent.DTD:
			return eventsMatch((DTD) a, (DTD) b);

		case XMLEvent.ENTITY_DECLARATION:
			return eventsMatch((EntityDeclaration) a, (EntityDeclaration) b);

		case XMLEvent.NOTATION_DECLARATION:
			return eventsMatch((NotationDeclaration) a, (NotationDeclaration) b);

		}

	}

	return false;

}
 
源代码27 项目: woodstox   文件: DTDSubset.java
public abstract HashMap<String,NotationDeclaration> getNotationMap(); 
源代码28 项目: woodstox   文件: DTDSubset.java
public abstract List<NotationDeclaration> getNotationList();