javax.xml.stream.events.ProcessingInstruction#javax.xml.stream.events.EntityReference源码实例Demo

下面列出了javax.xml.stream.events.ProcessingInstruction#javax.xml.stream.events.EntityReference 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: StaxEventXMLReader.java
private void handleEntityReference(EntityReference reference) throws SAXException {
	if (getLexicalHandler() != null) {
		getLexicalHandler().startEntity(reference.getName());
	}
	if (getLexicalHandler() != null) {
		getLexicalHandler().endEntity(reference.getName());
	}

}
 
private void handleEntityReference(EntityReference reference) throws SAXException {
	if (getLexicalHandler() != null) {
		getLexicalHandler().startEntity(reference.getName());
	}
	if (getLexicalHandler() != null) {
		getLexicalHandler().endEntity(reference.getName());
	}

}
 
源代码3 项目: lams   文件: StaxEventXMLReader.java
private void handleEntityReference(EntityReference reference) throws SAXException {
	if (getLexicalHandler() != null) {
		getLexicalHandler().startEntity(reference.getName());
	}
	if (getLexicalHandler() != null) {
		getLexicalHandler().endEntity(reference.getName());
	}

}
 
源代码4 项目: openjdk-jdk9   文件: Bug6555001.java
@Test
public void testReplacing() throws Exception {
    JAXPTestUtilities.tryRunWithTmpPermission(() -> {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);

        StringReader sr = new StringReader(XML);
        XMLEventReader reader = factory.createXMLEventReader(sr);

        boolean sawUndef = false;
        boolean sawDef = false;

        while (reader.hasNext()) {
            XMLEvent event = reader.nextEvent();
            // System.out.println("Event: " + event);
            if (event.isEntityReference()) {
                EntityReference ref = (EntityReference) event;
                if ("def".equals(ref.getName())) {
                    sawDef = true;
                } else if ("undef".equals(ref.getName())) {
                    sawUndef = true;
                } else {
                    throw new IllegalArgumentException("Unexpected entity name");
                }
            }
        }

        Assert.assertEquals(false, sawDef);
        Assert.assertEquals(true, sawUndef);
        reader.close();
    }, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
}
 
源代码5 项目: openjdk-jdk9   文件: Bug6555001.java
@Test
public void testNotReplacing() throws Exception {
    JAXPTestUtilities.tryRunWithTmpPermission(() -> {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", false);

        StringReader sr = new StringReader(XML);
        XMLEventReader reader = factory.createXMLEventReader(sr);

        boolean sawUndef = false;
        boolean sawDef = false;

        while (reader.hasNext()) {
            XMLEvent event = reader.nextEvent();
            // System.out.println("Event: " + event);
            if (event.isEntityReference()) {
                EntityReference ref = (EntityReference) event;
                if ("def".equals(ref.getName())) {
                    sawDef = true;
                } else if ("undef".equals(ref.getName())) {
                    sawUndef = true;
                } else {
                    throw new IllegalArgumentException("Unexpected entity name");
                }
            }
        }

        Assert.assertEquals(true, sawDef);
        Assert.assertEquals(true, sawUndef);
        reader.close();
    }, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
}
 
private void handleEntityReference(EntityReference reference) throws SAXException {
	if (getLexicalHandler() != null) {
		getLexicalHandler().startEntity(reference.getName());
	}
	if (getLexicalHandler() != null) {
		getLexicalHandler().endEntity(reference.getName());
	}

}
 
源代码7 项目: 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();
	}

}
 
源代码8 项目: TencentKona-8   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
@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();
	}

}
 
源代码10 项目: jdk8u60   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码11 项目: openjdk-jdk8u   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码12 项目: 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();
	}

}
 
源代码13 项目: lams   文件: BaseXMLEventReader.java
@Override
public final String getElementText() throws XMLStreamException {
	XMLEvent event = this.previousEvent;
	if (event == null) {
		throw new XMLStreamException("Must be on START_ELEMENT to read next text, element was null");
	}
	if (!event.isStartElement()) {
		throw new XMLStreamException("Must be on START_ELEMENT to read next text", event.getLocation());
	}

	final StringBuilder text = new StringBuilder();
	while (!event.isEndDocument()) {
		switch (event.getEventType()) {
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA: {
				final Characters characters = event.asCharacters();
				text.append(characters.getData());
				break;
			}
			case XMLStreamConstants.ENTITY_REFERENCE: {
				final EntityReference entityReference = (EntityReference)event;
				final EntityDeclaration declaration = entityReference.getDeclaration();
				text.append(declaration.getReplacementText());
				break;
			}
			case XMLStreamConstants.COMMENT:
			case XMLStreamConstants.PROCESSING_INSTRUCTION: {
				//Ignore
				break;
			}
			default: {
				throw new XMLStreamException("Unexpected event type '" + XMLStreamConstantsUtils.getEventName(event.getEventType()) + "' encountered. Found event: " + event, event.getLocation());
			}
		}

		event = this.nextEvent();
	}

	return text.toString();
}
 
源代码14 项目: lams   文件: BaseXMLEventReader.java
@Override
public final String getElementText() throws XMLStreamException {
	XMLEvent event = this.previousEvent;
	if (event == null) {
		throw new XMLStreamException("Must be on START_ELEMENT to read next text, element was null");
	}
	if (!event.isStartElement()) {
		throw new XMLStreamException("Must be on START_ELEMENT to read next text", event.getLocation());
	}

	final StringBuilder text = new StringBuilder();
	while (!event.isEndDocument()) {
		switch (event.getEventType()) {
			case XMLStreamConstants.CHARACTERS:
			case XMLStreamConstants.SPACE:
			case XMLStreamConstants.CDATA: {
				final Characters characters = event.asCharacters();
				text.append(characters.getData());
				break;
			}
			case XMLStreamConstants.ENTITY_REFERENCE: {
				final EntityReference entityReference = (EntityReference)event;
				final EntityDeclaration declaration = entityReference.getDeclaration();
				text.append(declaration.getReplacementText());
				break;
			}
			case XMLStreamConstants.COMMENT:
			case XMLStreamConstants.PROCESSING_INSTRUCTION: {
				//Ignore
				break;
			}
			default: {
				throw new XMLStreamException("Unexpected event type '" + XMLStreamConstantsUtils.getEventName(event.getEventType()) + "' encountered. Found event: " + event, event.getLocation());
			}
		}

		event = this.nextEvent();
	}

	return text.toString();
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码16 项目: Bytecoder   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while ((type = event.getEventType()) != XMLEvent.END_ELEMENT) {
            if (type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
                type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
                data = null;
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码17 项目: Bytecoder   文件: XMLEventFactoryImpl.java
@Override
public EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
    EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
    if(location != null)event.setLocation(location);
    return event;
}
 
源代码18 项目: openjdk-jdk9   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码19 项目: openjdk-jdk9   文件: XMLEventFactoryImpl.java
@Override
public EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
    EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
    if(location != null)event.setLocation(location);
    return event;
}
 
源代码20 项目: openjdk-jdk9   文件: XMLEventFactoryWrapper.java
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
    return defaultImpl.createEntityReference(name, declaration);
}
 
源代码21 项目: openjdk-jdk9   文件: XMLEventFactoryImpl.java
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
    return null;
}
 
源代码22 项目: hottub   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码23 项目: openjdk-8-source   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码24 项目: 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();
	}

}
 
源代码25 项目: openjdk-8   文件: XMLEventReaderImpl.java
/** Reads the content of a text-only element. Precondition:
 * the current event is START_ELEMENT. Postcondition:
 * The current event is the corresponding END_ELEMENT.
 * @throws XMLStreamException if the current event is not a START_ELEMENT
 * or if a non text element is encountered
 */
public String getElementText() throws XMLStreamException {
    //we have to keep reference to the 'last event' of the stream to be able
    //to make this check - is there another way ? - nb.
    if(fLastEvent.getEventType() != XMLEvent.START_ELEMENT){
        throw new XMLStreamException(
        "parser must be on START_ELEMENT to read next text", fLastEvent.getLocation());
    }

    // STag content ETag
    //[43]   content   ::=   CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*

    //<foo>....some long text say in KB and underlying parser reports multiple character
    // but getElementText() events....</foo>

    String data = null;
    //having a peeked event makes things really worse -- we have to test the first event
    if(fPeekedEvent != null){
        XMLEvent event = fPeekedEvent ;
        fPeekedEvent = null;
        int type = event.getEventType();

        if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
        type == XMLEvent.CDATA){
            data = event.asCharacters().getData();
        }
        else if(type == XMLEvent.ENTITY_REFERENCE){
            data = ((EntityReference)event).getDeclaration().getReplacementText();
        }
        else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
            //ignore
        } else if(type == XMLEvent.START_ELEMENT) {
            throw new XMLStreamException(
            "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
        }else if(type == XMLEvent.END_ELEMENT){
            return "";
        }

        //create the string buffer and add initial data
        StringBuffer buffer = new StringBuffer();
        if(data != null && data.length() > 0 ) {
            buffer.append(data);
        }
        //get the next event -- we should stop at END_ELEMENT but it can be any thing
        //things are worse when implementing this function in XMLEventReader because
        //there isn't any function called getText() which can get values for
        //space, cdata, characters and entity reference
        //nextEvent() would also set the last event.
        event = nextEvent();
        while(event.getEventType() != XMLEvent.END_ELEMENT){
            if(  type == XMLEvent.CHARACTERS || type == XMLEvent.SPACE ||
            type == XMLEvent.CDATA){
                data = event.asCharacters().getData();
            }
            else if(type == XMLEvent.ENTITY_REFERENCE){
                data = ((EntityReference)event).getDeclaration().getReplacementText();
            }
            else if(type == XMLEvent.COMMENT || type == XMLEvent.PROCESSING_INSTRUCTION){
                //ignore
            } else if(type == XMLEvent.END_DOCUMENT) {
                throw new XMLStreamException("unexpected end of document when reading element text content");
            } else if(type == XMLEvent.START_ELEMENT) {
                throw new XMLStreamException(
                "elementGetText() function expects text only elment but START_ELEMENT was encountered.", event.getLocation());
            } else {
                throw new XMLStreamException(
                "Unexpected event type "+ type, event.getLocation());
            }
            //add the data to the buffer
            if(data != null && data.length() > 0 ) {
                buffer.append(data);
            }
            event = nextEvent();
        }
        return buffer.toString();
    }//if (fPeekedEvent != null)

    //if there was no peeked, delegate everything to fXMLReader
    //update the last event before returning the text
    data = fXMLReader.getElementText();
    fLastEvent = fXMLEventAllocator.allocate(fXMLReader);
    return data;
}
 
源代码26 项目: nebula   文件: EntityReplacer.java
/**
 * Returns the String representation of the given {@link EntityReference}.
 * 
 * @param reference
 *            The {@link EntityReference} for which the String representation is requested.
 * @return The String representation for the given {@link EntityReference}.
 */
String getEntityReferenceValue(EntityReference reference);
 
源代码27 项目: 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;

}