本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}