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


Java XMLStreamReader.hasText方法代码示例

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


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

示例1: printElementState

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/** Used for debugging xml elements **/
static void printElementState(XMLStreamReader xr) {
	StringBuilder sb = new StringBuilder();
	sb.append("ElemState: ")
		.append(xr.getEventType())
		.append("\t")
		.append(xr.hasName())
		.append("\t")
		.append(xr.isStartElement())
		.append("\t")
		.append(xr.isEndElement())
		.append("\t")
		.append(xr.isCharacters());

	if(xr.hasName()){
		sb.append("\t").append(xr.getName());
	}
	if(xr.hasText()){
		sb.append("\t").append(xr.getText());
	}

	System.out.println(sb.toString());
}
 
开发者ID:digitalproteomics,项目名称:dp-mzml,代码行数:24,代码来源:MzMLStAXParser.java

示例2: handleStartElement

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
private void handleStartElement(XMLStreamReader xmlr) {
    output += "<";
    output += xmlr.getLocalName();
    if (xmlr.hasText())
        output += xmlr.getText();
    printAttributes(xmlr);
    output += ">";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EntityTest.java

示例3: parseXmlTestResults

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
/**
 * Parses Xml file entry and public test results.
 * @param xmlEntry Xml file entry
 * @param testSuiteName name of test suite
 */
private void parseXmlTestResults(@NotNull final String xmlEntry, @NotNull final String testSuiteName){
  Boolean isTestXml = false;
  try {
    final XMLInputFactory f = XMLInputFactory.newInstance();
    final XMLStreamReader reader = f.createXMLStreamReader(new StringReader(xmlEntry));
    String testResult = null;
    String testName = null;
    String tempTag = "";
    String testOutput = "";
    while (reader.hasNext()){
      if (!isTestXml && reader.hasName()){
        if (!reader.getLocalName().equalsIgnoreCase("testsuite")){
          break;
        }
        isTestXml = true;
        if (myTestsReporter != null) {
          myTestsReporter.publicTestSuiteStarted(testSuiteName);
        }
      }
      if (reader.isStartElement() && reader.hasName() && reader.getLocalName().equalsIgnoreCase("test")){
        testResult = null;
        testName = null;
      }
      if (reader.isEndElement() && reader.hasName() && reader.getLocalName().equalsIgnoreCase("test")){
        myTestsCount += testResult != null && testName != null ? 1 : 0;
        if (myTestsReporter != null && testResult != null && testName != null){
          myTestsReporter.publicTestCaseInfo(testName, testResult, testOutput);
        }
      }

      if (reader.hasName()){
        tempTag = reader.getLocalName();
      }
      if (reader.hasText()){
        if (tempTag.equalsIgnoreCase("result")){
          testResult = reader.getText();
        }
        else {
          if (tempTag.equalsIgnoreCase("name")) {
            testName = reader.getText();
          } else if (tempTag.equalsIgnoreCase("output")) {
            testOutput = reader.getText();
          }
        }
      }
      reader.next();
    }
    reader.close();
  } catch (final XMLStreamException e) {
    myTestsCount = 0;
    if (myTestsReporter != null) {
      myTestsReporter.reportWarning("DejagnuTestsXMLParser:" + e.getMessage());
    }
    else{
      System.out.println("DejagnuTestsXMLParser: " + e.getMessage());
    }
  }
  finally {
      if (isTestXml && myTestsReporter != null){
      myTestsReporter.publicTestSuiteFinished(testSuiteName);
    }
  }
}
 
开发者ID:unix-junkie,项目名称:teamcity-autotools-plugin,代码行数:69,代码来源:DejagnuTestsXMLParser.java

示例4: printEvent

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
public static void printEvent(XMLStreamReader xmlr, boolean showEvents) {
  if (showEvents) {
    System.out.print("EVENT:[" + xmlr.getLocation().getLineNumber() + "]["
        + xmlr.getLocation().getColumnNumber() + "] [" + getEventTypeName(xmlr.getEventType())
        + "]");
    System.out.print(" [");
  }
  switch (xmlr.getEventType()) {
    case XMLStreamConstants.START_ELEMENT:
      System.out.print("<");
      printName(xmlr);
      printNamespaces(xmlr);
      printAttributes(xmlr);
      System.out.print(">");
      break;
    case XMLStreamConstants.END_ELEMENT:
      System.out.print("</");
      printName(xmlr);
      System.out.print(">");
      break;
    case XMLStreamConstants.SPACE:
    case XMLStreamConstants.CHARACTERS:
      int start = xmlr.getTextStart();
      int length = xmlr.getTextLength();
      System.out.print(new String(xmlr.getTextCharacters(), start, length));
      break;
    case XMLStreamConstants.PROCESSING_INSTRUCTION:
      System.out.print("<?");
      if (xmlr.hasText())
        System.out.print(xmlr.getText());
      System.out.print("?>");
      break;
    case XMLStreamConstants.CDATA:
      System.out.print("<![CDATA[");
      start = xmlr.getTextStart();
      length = xmlr.getTextLength();
      System.out.print(new String(xmlr.getTextCharacters(), start, length));
      System.out.print("]]>");
      break;
    case XMLStreamConstants.COMMENT:
      System.out.print("<!--");
      if (xmlr.hasText())
        System.out.print(xmlr.getText());
      System.out.print("-->");
      break;
    case XMLStreamConstants.ENTITY_REFERENCE:
      System.out.print(xmlr.getLocalName() + "=");
      if (xmlr.hasText())
        System.out.print("[" + xmlr.getText() + "]");
      break;
    case XMLStreamConstants.START_DOCUMENT:
      System.out.print("<?xml");
      System.out.print(" version='" + xmlr.getVersion() + "'");
      System.out.print(" encoding='" + xmlr.getCharacterEncodingScheme() + "'");
      if (xmlr.isStandalone())
        System.out.print(" standalone='yes'");
      else
        System.out.print(" standalone='no'");
      System.out.print("?>");
      break;
  }
  System.out.println("]");
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:64,代码来源:XMLStreamHelper.java

示例5: handleComment

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
private void handleComment(XMLStreamReader xmlr) {
    if (xmlr.hasText())
        output += xmlr.getText();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:EntityTest.java

示例6: handleCharacters

import javax.xml.stream.XMLStreamReader; //导入方法依赖的package包/类
private void handleCharacters(XMLStreamReader xmlr) {
    if (xmlr.hasText())
        output += xmlr.getText();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:EntityTest.java


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