当前位置: 首页>>代码示例>>Java>>正文


Java XMLStreamReader.END_DOCUMENT属性代码示例

本文整理汇总了Java中javax.xml.stream.XMLStreamReader.END_DOCUMENT属性的典型用法代码示例。如果您正苦于以下问题:Java XMLStreamReader.END_DOCUMENT属性的具体用法?Java XMLStreamReader.END_DOCUMENT怎么用?Java XMLStreamReader.END_DOCUMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.xml.stream.XMLStreamReader的用法示例。


在下文中一共展示了XMLStreamReader.END_DOCUMENT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storeDocumentAndChildren

private void storeDocumentAndChildren(XMLStreamReader reader) throws XMLStreamException {
    storeStructure(T_DOCUMENT);

    _eventType = reader.next();
    while (_eventType != XMLStreamReader.END_DOCUMENT) {
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                storeElementAndChildren(reader);
                continue;
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
        _eventType = reader.next();
    }

    storeStructure(T_END);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:StreamReaderBufferCreator.java

示例2: readTag

/**
 * Reads the next tag from the pull parser and throws an exception if its name does not
 * match <var>expectedTagName</var>.
 *
 * @param xmlPullParser The pull parser to read from
 * @param expectedTagName The tag name expected
 */
public static void readTag(XMLStreamReader xmlStreamReader, String expectedTagName) {
  // Look for any start tag event
  int event;
  try {
    do {
      event = xmlStreamReader.next();
    } while (event == XMLStreamReader.CHARACTERS || event == XMLStreamReader.END_ELEMENT || event == XMLStreamReader.COMMENT);
  } catch (Exception e) {
    throw new RuntimeException("Error reading data from the XML pull parser", e);
  }

  if (event == XMLStreamReader.START_ELEMENT) {
    if (!expectedTagName.equals(xmlStreamReader.getLocalName())) {
      throw new IllegalArgumentException("Expected tag [" + expectedTagName + "] but got [" + xmlStreamReader.getLocalName() + "]");
    }

  } else if (event == XMLStreamReader.END_DOCUMENT) {
    throw new IllegalStateException("Unexpected end of document while looking for tag [" + expectedTagName + "]");

  } else {
    throw new IllegalStateException("Expecting a tag but found [" + event + "]");
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:30,代码来源:XmlPullProcessor.java

示例3: readNextTagInsideParent

/**
 * Reads the next tag name from the XML parser so long as it lies within the parent tag name.
 * If the close tag event for the parent is read this method will return null. Otherwise it
 * returns the name of the tag read.
 *
 * @param parentTagName The enclosing tag that forms the limit for the read operation.
 * @return The next tag name or null if there are no more tags to read inside the specified parent.
 */
protected String readNextTagInsideParent(String parentTagName) {
  int event;
  try {
    do {
      event = xmlStreamReader.next();
    } while (event == XMLStreamReader.CHARACTERS ||
             event == XMLStreamReader.COMMENT ||
             event == XMLStreamReader.END_ELEMENT && !xmlStreamReader.getLocalName().equals(parentTagName));
  } catch (Exception e) {
    throw new RuntimeException("Error reading data from the XML pull parser", e);
  }

  if (event == XMLStreamReader.START_ELEMENT) {
    return xmlStreamReader.getLocalName();

  } else if (event == XMLStreamReader.END_ELEMENT) {
    return null;

  } else if (event == XMLStreamReader.END_DOCUMENT) {
    throw new IllegalStateException("Unexpected end of document while looking for a tag inside [" + parentTagName + "]");

  } else {
    throw new IllegalStateException("Expecting a tag inside [" + parentTagName + "] but got [" + event + "]");
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:33,代码来源:XmlPullProcessor.java

示例4: binaryInputStreamStreamToReader

private Reader binaryInputStreamStreamToReader(ByteArrayOutputStream out) {

        try {
            // There's got to be an easier way to do this, but I don't feel like coding up Appendix F of the XML Spec myself, when there's a reusable way to do
            // it, and we can warn folks away from BINARY xml streams that have to be parsed to determine the character encoding :P

            String encoding = "UTF-8";

            try {
                ByteArrayInputStream bIn = new ByteArrayInputStream(out.toByteArray());
                XMLStreamReader reader = this.inputFactory.createXMLStreamReader(bIn);

                int eventType = 0;

                while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
                    if (eventType == XMLStreamReader.START_DOCUMENT) {
                        String possibleEncoding = reader.getEncoding();

                        if (possibleEncoding != null) {
                            encoding = possibleEncoding;
                        }

                        break;
                    }
                }
            } catch (Throwable t) {
                // ignore, dealt with later when the string can't be parsed into valid XML
            }

            return new StringReader(new String(out.toByteArray(), encoding));
        } catch (UnsupportedEncodingException badEnc) {
            throw new RuntimeException(badEnc);
        }
    }
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:34,代码来源:JDBC4MysqlSQLXML.java

示例5: moveToFirstChildOfRootElement

private int moveToFirstChildOfRootElement(XMLStreamReader streamReader) throws XMLStreamException {
	// root
	int event = streamReader.next();
	while (event != XMLStreamReader.START_ELEMENT) {
		event = streamReader.next();
	}

	// first child
	event = streamReader.next();
	while ((event != XMLStreamReader.START_ELEMENT) && (event != XMLStreamReader.END_DOCUMENT)) {
		event = streamReader.next();
	}
	return event;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:Jaxb2CollectionHttpMessageConverter.java

示例6: moveToNextElement

private int moveToNextElement(XMLStreamReader streamReader) throws XMLStreamException {
	int event = streamReader.getEventType();
	while (event != XMLStreamReader.START_ELEMENT && event != XMLStreamReader.END_DOCUMENT) {
		event = streamReader.next();
	}
	return event;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:Jaxb2CollectionHttpMessageConverter.java

示例7: createElementFragment

/**
 * Creates the buffer from a stream reader that is an element fragment.
 * <p>
 * The stream reader will be moved to the position of the next start of
 * an element if the stream reader is not already positioned at the start
 * of an element.
 * <p>
 * The element and all its children will be stored and after storing the stream
 * will be positioned at the next event after the end of the element.
 * <p>
 * @param storeInScopeNamespaces true if in-scope namespaces of the element
 *        fragment should be stored.
 * @return the mutable stream buffer.
 * @throws XMLStreamException if the stream reader cannot be positioned at
 *         the start of an element.
 */
public MutableXMLStreamBuffer createElementFragment(XMLStreamReader reader,
        boolean storeInScopeNamespaces) throws XMLStreamException {
    if (_buffer == null) {
        createBuffer();
    }

    if (!reader.hasNext()) {
        return _buffer;
    }

    _storeInScopeNamespacesOnElementFragment = storeInScopeNamespaces;

    _eventType = reader.getEventType();
    if (_eventType != XMLStreamReader.START_ELEMENT) {
        do {
            _eventType = reader.next();
        } while(_eventType != XMLStreamReader.START_ELEMENT && _eventType != XMLStreamReader.END_DOCUMENT);
    }

    if (storeInScopeNamespaces) {
        _inScopePrefixes = new HashMap<String,Integer>();
    }

    storeElementAndChildren(reader);

    return getXMLStreamBuffer();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:StreamReaderBufferCreator.java

示例8: nextTag

@Override
public int nextTag() throws XMLStreamException {
    int e = next();
    if (e == XMLStreamReader.END_DOCUMENT) return e;
    while (e != XMLStreamReader.END_DOCUMENT) {
        if (e == XMLStreamReader.START_ELEMENT) return e;
        if (e == XMLStreamReader.END_ELEMENT) return e;
        e = next();
    }
    return e;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:XMLReaderComposite.java


注:本文中的javax.xml.stream.XMLStreamReader.END_DOCUMENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。