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


Java XMLStreamReader.isWhiteSpace方法代码示例

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


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

示例1: nextTagSkipDTD

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
 * A copy of the nextTag algorithm from the XMLStreamReader javadocs,
 * but which also skips over DTD events as well as whitespace,
 * comments and PIs.
 * 
 * @param xsr the reader to advance
 * @return {@link XMLStreamConstants#START_ELEMENT} or
 *         {@link XMLStreamConstants#END_ELEMENT} for the next tag.
 * @throws XMLStreamException
 */
private static int nextTagSkipDTD(XMLStreamReader xsr)
        throws XMLStreamException {
  int eventType = xsr.next();
  while((eventType == XMLStreamConstants.CHARACTERS && xsr.isWhiteSpace())
          || (eventType == XMLStreamConstants.CDATA && xsr.isWhiteSpace())
          || eventType == XMLStreamConstants.SPACE
          || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
          || eventType == XMLStreamConstants.COMMENT
          || eventType == XMLStreamConstants.DTD) {
    eventType = xsr.next();
  }
  if(eventType != XMLStreamConstants.START_ELEMENT
          && eventType != XMLStreamConstants.END_ELEMENT) {
    throw new XMLStreamException("expected start or end tag", xsr
            .getLocation());
  }
  return eventType;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:29,代码来源:DocumentStaxUtils.java

示例2: currentWhiteSpaceContent

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
 * Read spaces from the reader as long as to the next element, starting from
 * current position. Comments are ignored.
 * @param reader
 * @return
 */
public static String currentWhiteSpaceContent(XMLStreamReader reader) {

    // since the there might be several valid chunks (spaces/comment/spaces)
    // StringBuilder must be used; it's initialized lazily, only when needed
    StringBuilder whiteSpaces = null;

    for (;;) {
        switch (reader.getEventType()) {
            case START_ELEMENT:
            case END_ELEMENT:
            case END_DOCUMENT:
                return whiteSpaces == null ? null : whiteSpaces.toString();
            case CHARACTERS:
                if (reader.isWhiteSpace()) {
                    if (whiteSpaces == null) {
                        whiteSpaces = new StringBuilder();
                    }
                    whiteSpaces.append(reader.getText());
                } else {
                    throw new XMLStreamReaderException(
                            "xmlreader.unexpectedCharacterContent", reader.getText());
                }
        }
        next(reader);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:XMLStreamReaderUtil.java

示例3: nextContent

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public static int nextContent(XMLStreamReader reader) {
    for (;;) {
        int state = next(reader);
        switch (state) {
            case START_ELEMENT:
            case END_ELEMENT:
            case END_DOCUMENT:
                return state;
            case CHARACTERS:
                if (!reader.isWhiteSpace()) {
                    return CHARACTERS;
                }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:XMLStreamReaderUtil.java


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