當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。