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


Java XMLEventReader2.getElementText方法代码示例

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


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

示例1: parseCollection

import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private static AtomCollectionInfo parseCollection(String baseUrl, XMLEventReader2 reader, StartElement2 startElement) {
  String href = getAttributeValueIfExists(startElement, "href");
  String url = urlCombine(baseUrl, href);
  String title = null;
  String accept = null;
  while (reader.hasNext()) {
    XMLEvent2 event = reader.nextEvent();
    if (event.isEndElement() && event.asEndElement().getName().equals(startElement.getName())) {
      return new AtomCollectionInfo(href, url, title, accept);
    } else if (isStartElement(event, ATOM_TITLE)) {
      title = reader.getElementText();
    } else if (isStartElement(event, APP_ACCEPT)) {
      accept = reader.getElementText();
    }
  }
  return new AtomCollectionInfo(href, url, title, accept);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:18,代码来源:AtomServiceDocumentFormatParser.java

示例2: parseWorkspace

import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private static AtomWorkspaceInfo parseWorkspace(String baseUrl, XMLEventReader2 reader, StartElement2 startElement) {
  String title = null;
  List<AtomCollectionInfo> collections = new ArrayList<AtomCollectionInfo>();
  while (reader.hasNext()) {
    XMLEvent2 event = reader.nextEvent();
    if (isStartElement(event, ATOM_TITLE)) {
      title = reader.getElementText();
    } else if (event.isEndElement() && event.asEndElement().getName().equals(startElement.getName())) {
      return new AtomWorkspaceInfo(title, collections);
    } else if (isStartElement(event, APP_COLLECTION)) {
      collections.add(parseCollection(baseUrl, reader, event.asStartElement()));
    }
  }
  return new AtomWorkspaceInfo(title, collections);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:16,代码来源:AtomServiceDocumentFormatParser.java

示例3: parse

import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
@Override
public OSimpleObject<?> parse(Reader reader) {
  XMLEventReader2 xmlReader = StaxUtil.newXMLEventReader(reader);
  xmlReader.nextEvent(); // start doc
  xmlReader.nextEvent(); // start element

  String text = xmlReader.getElementText();
  EdmSimpleType<?> type = EdmSimpleType.STRING;
  if (settings != null && settings.parseType != null && settings.parseType.isSimple())
    type = (EdmSimpleType<?>) settings.parseType;
  return OSimpleObjects.parse(type, text);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:13,代码来源:AtomSimpleObjectFormatParser.java

示例4: parse

import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
@Override
public OError parse(Reader reader) {
  String code = null;
  String message = null;
  String innerError = null;
  XMLEventReader2 xmlReader = StaxUtil.newXMLEventReader(reader);
  XMLEvent2 event = xmlReader.nextEvent();
  while (!event.isStartElement())
    event = xmlReader.nextEvent();
  if (!isStartElement(event, ERROR))
    throw new RuntimeException("Bad error response: <" + ERROR.getLocalPart() + "> not found");
  while (!isEndElement(event = xmlReader.nextEvent(), ERROR)) {
    if (isStartElement(event, CODE))
      code = xmlReader.getElementText();
    else if (isStartElement(event, MESSAGE))
      message = xmlReader.getElementText();
    else if (isStartElement(event, INNER_ERROR))
      innerError = StaxUtil.innerXml(event, xmlReader);
    else if (!event.isStartElement() || !event.isEndElement())
      continue;
    else
      throw new RuntimeException("Bad error response: Unexpected structure");
  }
  if (!isEndElement(event, ERROR))
    throw new RuntimeException("Bad error response: Expected </" + ERROR.getLocalPart() + ">");
  if (code == null && message == null && innerError == null)
    throw new RuntimeException("Bad error response: Unknown elements");
  return OErrors.error(code, message, innerError);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:30,代码来源:AtomErrorFormatParser.java

示例5: parse

import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
@Override
public OError parse(Reader reader) {
  String code = null;
  String message = null;
  String innerError = null;
  XMLEventReader2 xmlReader = StaxUtil.newXMLEventReader(reader);
  XMLEvent2 event = xmlReader.nextEvent();
  while (!event.isStartElement())
    event = xmlReader.nextEvent();
  if (!isStartElement(event, ERROR))
    throw new RuntimeException("Bad error response: <" + ERROR.getLocalPart() + "> not found");
  while (!isEndElement(event = xmlReader.nextEvent(), ERROR)) {
    if (isStartElement(event, CODE))
      code = xmlReader.getElementText();
    else if (isStartElement(event, MESSAGE))
      message = xmlReader.getElementText();
    else if (isStartElement(event, INNER_ERROR))
      innerError = StaxUtil.outerXml(event, xmlReader);
    else if (!event.isStartElement() || !event.isEndElement())
      continue;
    else
      throw new RuntimeException("Bad error response: Unexpected structure");
  }
  if (!isEndElement(event, ERROR))
    throw new RuntimeException("Bad error response: Expected </" + ERROR.getLocalPart() + ">");
  if (code == null && message == null && innerError == null)
    throw new RuntimeException("Bad error response: Unknown elements");
  return OErrors.error(code, message, innerError);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:AtomErrorFormatParser.java


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