本文整理汇总了Java中javax.xml.stream.XMLStreamConstants.END_DOCUMENT属性的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamConstants.END_DOCUMENT属性的具体用法?Java XMLStreamConstants.END_DOCUMENT怎么用?Java XMLStreamConstants.END_DOCUMENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.xml.stream.XMLStreamConstants
的用法示例。
在下文中一共展示了XMLStreamConstants.END_DOCUMENT属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pullNextEvent
@Override
protected int pullNextEvent() {
try {
switch (in.next()) {
case XMLStreamConstants.START_DOCUMENT:
case XMLStreamConstants.START_ELEMENT:
return START_NODE;
case XMLStreamConstants.END_DOCUMENT:
case XMLStreamConstants.END_ELEMENT:
return END_NODE;
case XMLStreamConstants.CHARACTERS:
return TEXT;
case XMLStreamConstants.COMMENT:
return COMMENT;
default:
return OTHER;
}
} catch (final XMLStreamException e) {
throw new StreamException(e);
}
}
示例2: getEventTypeName
private static String getEventTypeName(int eventType) {
switch (eventType) {
case XMLStreamConstants.START_ELEMENT:
return "START_ELEMENT";
case XMLStreamConstants.END_ELEMENT:
return "END_ELEMENT";
case XMLStreamConstants.SPACE:
return "SPACE";
case XMLStreamConstants.CHARACTERS:
return "CHARACTERS";
case XMLStreamConstants.PROCESSING_INSTRUCTION:
return "PROCESSING_INSTRUCTION";
case XMLStreamConstants.CDATA:
return "CDATA";
case XMLStreamConstants.COMMENT:
return "COMMENT";
case XMLStreamConstants.ENTITY_REFERENCE:
return "ENTITY_REFERENCE";
case XMLStreamConstants.START_DOCUMENT:
return "START_DOCUMENT";
case XMLStreamConstants.END_DOCUMENT:
return "END_DOCUMENT";
}
return null;
}
示例3: getEventName
/**
* Get the human readable event name for the numeric event id
*/
public static String getEventName(int eventId) {
switch (eventId) {
case XMLStreamConstants.START_ELEMENT:
return "StartElementEvent";
case XMLStreamConstants.END_ELEMENT:
return "EndElementEvent";
case XMLStreamConstants.PROCESSING_INSTRUCTION:
return "ProcessingInstructionEvent";
case XMLStreamConstants.CHARACTERS:
return "CharacterEvent";
case XMLStreamConstants.COMMENT:
return "CommentEvent";
case XMLStreamConstants.START_DOCUMENT:
return "StartDocumentEvent";
case XMLStreamConstants.END_DOCUMENT:
return "EndDocumentEvent";
case XMLStreamConstants.ENTITY_REFERENCE:
return "EntityReferenceEvent";
case XMLStreamConstants.ATTRIBUTE:
return "AttributeBase";
case XMLStreamConstants.DTD:
return "DTDEvent";
case XMLStreamConstants.CDATA:
return "CDATA";
}
return "UNKNOWN_EVENT_TYPE";
}
示例4: getEventTypeString
public final static String getEventTypeString(int eventType) {
switch (eventType){
case XMLStreamConstants.START_ELEMENT:
return "START_ELEMENT";
case XMLStreamConstants.END_ELEMENT:
return "END_ELEMENT";
case XMLStreamConstants.PROCESSING_INSTRUCTION:
return "PROCESSING_INSTRUCTION";
case XMLStreamConstants.CHARACTERS:
return "CHARACTERS";
case XMLStreamConstants.COMMENT:
return "COMMENT";
case XMLStreamConstants.START_DOCUMENT:
return "START_DOCUMENT";
case XMLStreamConstants.END_DOCUMENT:
return "END_DOCUMENT";
case XMLStreamConstants.ENTITY_REFERENCE:
return "ENTITY_REFERENCE";
case XMLStreamConstants.ATTRIBUTE:
return "ATTRIBUTE";
case XMLStreamConstants.DTD:
return "DTD";
case XMLStreamConstants.CDATA:
return "CDATA";
}
return "UNKNOWN_EVENT_TYPE";
}
示例5: unmarshal
private Map<URI, Policy> unmarshal(final XMLEventReader reader, final StartElement parentElement) throws PolicyException {
XMLEvent event = null;
while (reader.hasNext()) {
try {
event = reader.peek();
switch (event.getEventType()) {
case XMLStreamConstants.START_DOCUMENT:
case XMLStreamConstants.COMMENT:
reader.nextEvent();
break;
case XMLStreamConstants.CHARACTERS:
processCharacters(event.asCharacters(), parentElement, map);
reader.nextEvent();
break;
case XMLStreamConstants.END_ELEMENT:
processEndTag(event.asEndElement(), parentElement);
reader.nextEvent();
return map;
case XMLStreamConstants.START_ELEMENT:
final StartElement element = event.asStartElement();
processStartTag(element, parentElement, reader, map);
break;
case XMLStreamConstants.END_DOCUMENT:
return map;
default:
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0087_UNKNOWN_EVENT(event)));
}
} catch (XMLStreamException e) {
final Location location = event == null ? null : event.getLocation();
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0088_FAILED_PARSE(location)), e);
}
}
return map;
}
示例6: readRest
public static void readRest(XMLStreamReader reader) {
try {
while(reader.getEventType() != XMLStreamConstants.END_DOCUMENT) {
reader.next();
}
} catch (XMLStreamException e) {
throw wrapException(e);
}
}
示例7: getElementText
/** 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 {
if(getEventType() != XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException(
"parser must be on START_ELEMENT to read next text", getLocation());
}
int eventType = next();
StringBuffer content = new StringBuffer();
while(eventType != XMLStreamConstants.END_ELEMENT ) {
if(eventType == XMLStreamConstants.CHARACTERS
|| eventType == XMLStreamConstants.CDATA
|| eventType == XMLStreamConstants.SPACE
|| eventType == XMLStreamConstants.ENTITY_REFERENCE) {
content.append(getText());
} else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
|| eventType == XMLStreamConstants.COMMENT) {
// skipping
} else if(eventType == XMLStreamConstants.END_DOCUMENT) {
throw new XMLStreamException("unexpected end of document when reading element text content");
} else if(eventType == XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException(
"elementGetText() function expects text only elment but START_ELEMENT was encountered.", getLocation());
} else {
throw new XMLStreamException(
"Unexpected event type "+ eventType, getLocation());
}
eventType = next();
}
return content.toString();
}
示例8: getElementText
/**
* 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 {
if (getEventType() != XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException(
"parser must be on START_ELEMENT to read next text", getLocation());
}
int eventType = next();
StringBuilder content = new StringBuilder();
while (eventType != XMLStreamConstants.END_ELEMENT) {
if (eventType == XMLStreamConstants.CHARACTERS
|| eventType == XMLStreamConstants.CDATA
|| eventType == XMLStreamConstants.SPACE
|| eventType == XMLStreamConstants.ENTITY_REFERENCE) {
content.append(getText());
} else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
|| eventType == XMLStreamConstants.COMMENT) {
// skipping
} else if (eventType == XMLStreamConstants.END_DOCUMENT) {
throw new XMLStreamException(
"unexpected end of document when reading element text content");
} else if (eventType == XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException("elementGetText() function expects text "
+ "only elment but START_ELEMENT was encountered.", getLocation());
} else {
throw new XMLStreamException(
"Unexpected event type " + eventType, getLocation());
}
eventType = next();
}
return content.toString();
}
示例9: writeAsEncodedUnicode
/**
* The return of XMLEvent writeAsEncodedUnicode method is not defined This
* method merely tests that the output exists
*/
public void writeAsEncodedUnicode(XMLEvent evt) throws XMLStreamException {
if (evt.getEventType() == XMLStreamConstants.END_DOCUMENT) {
return;
}
StringWriter sw = new StringWriter();
evt.writeAsEncodedUnicode(sw);
Assert.assertTrue(sw.toString().length() > 0);
System.out.println(sw.toString());
}
示例10: parse
public void parse(XMLEventReader input) throws XMLStreamException, XNIException {
XMLEvent currentEvent = input.peek();
if (currentEvent != null) {
int eventType = currentEvent.getEventType();
if (eventType != XMLStreamConstants.START_DOCUMENT &&
eventType != XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException();
}
fLocationWrapper.setLocation(currentEvent.getLocation());
fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null);
loop: while (input.hasNext()) {
currentEvent = input.nextEvent();
eventType = currentEvent.getEventType();
switch (eventType) {
case XMLStreamConstants.START_ELEMENT:
++fDepth;
StartElement start = currentEvent.asStartElement();
fillQName(fElementQName, start.getName());
fLocationWrapper.setLocation(start.getLocation());
fNamespaceContext.setNamespaceContext(start.getNamespaceContext());
fillXMLAttributes(start);
fillDeclaredPrefixes(start);
addNamespaceDeclarations();
fNamespaceContext.pushContext();
fSchemaDOMParser.startElement(fElementQName, fAttributes, null);
break;
case XMLStreamConstants.END_ELEMENT:
EndElement end = currentEvent.asEndElement();
fillQName(fElementQName, end.getName());
fillDeclaredPrefixes(end);
fLocationWrapper.setLocation(end.getLocation());
fSchemaDOMParser.endElement(fElementQName, null);
fNamespaceContext.popContext();
--fDepth;
if (fDepth <= 0) {
break loop;
}
break;
case XMLStreamConstants.CHARACTERS:
sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false);
break;
case XMLStreamConstants.SPACE:
sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true);
break;
case XMLStreamConstants.CDATA:
fSchemaDOMParser.startCDATA(null);
sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false);
fSchemaDOMParser.endCDATA(null);
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
ProcessingInstruction pi = (ProcessingInstruction)currentEvent;
fillProcessingInstruction(pi.getData());
fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null);
break;
case XMLStreamConstants.DTD:
/* There shouldn't be a DTD in the schema */
break;
case XMLStreamConstants.ENTITY_REFERENCE:
/* Not needed for schemas */
break;
case XMLStreamConstants.COMMENT:
/* No point in sending comments */
break;
case XMLStreamConstants.START_DOCUMENT:
fDepth++;
/* We automatically call startDocument before the loop */
break;
case XMLStreamConstants.END_DOCUMENT:
/* We automatically call endDocument after the loop */
break;
}
}
fLocationWrapper.setLocation(null);
fNamespaceContext.setNamespaceContext(null);
fSchemaDOMParser.endDocument(null);
}
}
示例11: parse
private void parse(XMLInputFactory xif) throws XMLStreamException {
XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader("<?xml version='1.0'?><!DOCTYPE root PUBLIC 'abc' 'def'><abc />"));
while (xsr.next() != XMLStreamConstants.END_DOCUMENT)
;
}