本文整理汇总了Java中org.odata4j.stax2.XMLEventReader2.nextEvent方法的典型用法代码示例。如果您正苦于以下问题:Java XMLEventReader2.nextEvent方法的具体用法?Java XMLEventReader2.nextEvent怎么用?Java XMLEventReader2.nextEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.odata4j.stax2.XMLEventReader2
的用法示例。
在下文中一共展示了XMLEventReader2.nextEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseEdmAssociationSet
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
/**
* parseEdmAssociationSet.
* @param reader reader
* @param associationSetElement associationSetElement
* @return EdmAssociationSet.Builder
*/
private EdmAssociationSet.Builder parseEdmAssociationSet(
XMLEventReader2 reader, StartElement2 associationSetElement) {
String name = associationSetElement.getAttributeByName("Name").getValue();
String associationName = associationSetElement.getAttributeByName("Association").getValue();
List<EdmAssociationSetEnd.Builder> ends = new ArrayList<EdmAssociationSetEnd.Builder>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, EDM2006_END, EDM2007_END, EDM2008_END, EDM2009_END)) {
ends.add(EdmAssociationSetEnd.newBuilder()
.setRoleName(event.asStartElement().getAttributeByName("Role").getValue())
.setEntitySetName(event.asStartElement().getAttributeByName("EntitySet").getValue()));
}
if (isEndElement(event, associationSetElement.getName())) {
return EdmAssociationSet.newBuilder().setName(name)
.setAssociationName(associationName).setEnds(ends.get(0), ends.get(1));
}
}
throw new UnsupportedOperationException();
}
示例2: parseEdmAssociation
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
/**
* parseEdmAssociation.
* @param reader reader
* @param schemaNamespace schemaNamespace
* @param schemaAlias schemaAlias
* @param associationElement associationElement
* @return EdmAssociation.Builder
*/
private EdmAssociation.Builder parseEdmAssociation(
XMLEventReader2 reader, String schemaNamespace, String schemaAlias, StartElement2 associationElement) {
String name = associationElement.getAttributeByName("Name").getValue();
List<EdmAssociationEnd.Builder> ends = new ArrayList<EdmAssociationEnd.Builder>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, EDM2006_END, EDM2007_END, EDM2008_END, EDM2009_END)) {
ends.add(EdmAssociationEnd.newBuilder()
.setRole(event.asStartElement().getAttributeByName("Role").getValue())
.setTypeName(event.asStartElement().getAttributeByName("Type").getValue())
.setMultiplicity(EdmMultiplicity.fromSymbolString(
event.asStartElement().getAttributeByName("Multiplicity").getValue())));
}
if (isEndElement(event, associationElement.getName())) {
return EdmAssociation.newBuilder().setNamespace(schemaNamespace).
setAlias(schemaAlias).setName(name).setEnds(ends.get(0), ends.get(1));
}
}
throw new UnsupportedOperationException();
}
示例3: writeXml
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private static void writeXml(boolean includeCurrent, XMLEvent2 currentEvent, XMLEventReader2 xmlReader, XMLWriter2 xmlWriter) {
if (currentEvent == null || !currentEvent.isStartElement())
throw new IllegalStateException("currentEvent must be a start element");
if (includeCurrent)
writeStartElement(currentEvent.asStartElement(), xmlWriter);
int level = 0;
while (true) {
currentEvent = xmlReader.nextEvent();
if (currentEvent.isStartElement()) {
writeStartElement(currentEvent.asStartElement(), xmlWriter);
level++;
} else if (currentEvent.isEndElement()) {
if (level == 0)
break;
writeEndElement(currentEvent.asEndElement(), xmlWriter);
level--;
} else if (currentEvent.isCharacters()) {
writeCharacters(currentEvent.asCharacters(), xmlWriter);
}
}
if (includeCurrent)
writeEndElement(currentEvent.asEndElement(), xmlWriter);
}
示例4: parseFeed
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
AtomFeed parseFeed(XMLEventReader2 reader, EdmEntitySet entitySet) {
AtomFeed feed = new AtomFeed();
List<AtomEntry> rt = new ArrayList<AtomEntry>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, ATOM_ENTRY)) {
rt.add(parseEntry(reader, event.asStartElement(), entitySet));
} else if (isStartElement(event, ATOM_LINK)) {
if ("next".equals(event.asStartElement().getAttributeByName(new QName2("rel")).getValue())) {
feed.next = event.asStartElement().getAttributeByName(new QName2("href")).getValue();
}
} else if (isEndElement(event, ATOM_FEED)) {
// return from a sub feed, if we went down the hierarchy
break;
}
}
feed.entries = Enumerable.create(rt).cast(Entry.class);
return feed;
}
示例5: innerText
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private static String innerText(XMLEventReader2 reader, StartElement2 element) {
StringWriter sw = new StringWriter();
XMLEventWriter2 writer = XMLFactoryProvider2.getInstance().newXMLOutputFactory2().createXMLEventWriter(sw);
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isEndElement() && event.asEndElement().getName().equals(element.getName())) {
return sw.toString();
} else {
writer.add(event);
}
}
throw new RuntimeException();
}
示例6: parseEdmEntitySet
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private EdmEntitySet.Builder parseEdmEntitySet(XMLEventReader2 reader, String schemaNamespace, StartElement2 entitySetStartElement) {
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
String name = entitySetStartElement.getAttributeByName("Name").getValue();
String entityTypeName = getAttributeValueIfExists(entitySetStartElement, "EntityType");
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isStartElement()) {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
if (isEndElement(event, entitySetStartElement.getName())) {
return EdmEntitySet.newBuilder()
.setName(name)
.setEntityTypeName(entityTypeName)
.setAnnotations(getAnnotations(entitySetStartElement))
.setAnnotationElements(annotElements);
}
}
throw new UnsupportedOperationException();
}
示例7: parseEdmAssociationSetEnd
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private EdmAssociationSetEnd.Builder parseEdmAssociationSetEnd(XMLEventReader2 reader, StartElement2 endStartElement) {
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
String role = endStartElement.getAttributeByName("Role").getValue();
String entitySetName = endStartElement.getAttributeByName("EntitySet").getValue();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isStartElement()) {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
if (isEndElement(event, endStartElement.getName())) {
return EdmAssociationSetEnd.newBuilder().setRoleName(role)
.setEntitySetName(entitySetName)
.setAnnotations(getAnnotations(endStartElement))
.setAnnotationElements(annotElements);
}
}
throw new UnsupportedOperationException();
}
示例8: parseEdmComplexType
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
/**
* parseEdmComplexType.
* @param reader reader
* @param schemaNamespace schemaNamespace
* @param complexTypeElement complexTypeElement
* @return EdmComplexType.Builder
*/
private EdmComplexType.Builder parseEdmComplexType(
XMLEventReader2 reader, String schemaNamespace, StartElement2 complexTypeElement) {
String name = complexTypeElement.getAttributeByName("Name").getValue();
String isAbstractS = getAttributeValueIfExists(complexTypeElement, "Abstract");
List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_PROPERTY, EDM2009_PROPERTY)) {
edmProperties.add(parseEdmProperty(event));
}
if (isEndElement(event, complexTypeElement.getName())) {
EdmComplexType.Builder complexType = EdmComplexType.newBuilder()
.setNamespace(schemaNamespace).setName(name).addProperties(edmProperties);
if (isAbstractS != null) {
complexType.setIsAbstract("true".equals(isAbstractS));
}
return complexType;
}
}
throw new UnsupportedOperationException();
}
示例9: parseEdmComplexType
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private EdmComplexType.Builder parseEdmComplexType(XMLEventReader2 reader, String schemaNamespace, StartElement2 complexTypeElement) {
String name = complexTypeElement.getAttributeByName("Name").getValue();
String isAbstractS = getAttributeValueIfExists(complexTypeElement, "Abstract");
String baseType = getAttributeValueIfExists(complexTypeElement, "BaseType");
List<EdmProperty.Builder> edmProperties = new ArrayList<EdmProperty.Builder>();
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isStartElement()) {
if (isElement(event, EDM2006_PROPERTY, EDM2007_PROPERTY, EDM2008_1_PROPERTY, EDM2008_9_PROPERTY, EDM2009_8_PROPERTY, EDM2009_11_PROPERTY)) {
edmProperties.add(parseEdmProperty(reader, event));
} else {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
}
if (isEndElement(event, complexTypeElement.getName())) {
EdmComplexType.Builder complexType = EdmComplexType.newBuilder()
.setNamespace(schemaNamespace)
.setName(name)
.setBaseType(baseType)
.addProperties(edmProperties)
.setAnnotations(getAnnotations(complexTypeElement))
.setAnnotationElements(annotElements);
if (isAbstractS != null)
complexType.setIsAbstract("true".equals(isAbstractS));
return complexType;
}
}
throw new UnsupportedOperationException();
}
示例10: parseEdmNavigationProperty
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private EdmNavigationProperty.Builder parseEdmNavigationProperty(XMLEventReader2 reader, XMLEvent2 event) {
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
StartElement2 navPropStartElement = event.asStartElement();
String associationName = navPropStartElement.getAttributeByName("Name").getValue();
String relationshipName = navPropStartElement.getAttributeByName("Relationship").getValue();
String fromRoleName = navPropStartElement.getAttributeByName("FromRole").getValue();
String toRoleName = navPropStartElement.getAttributeByName("ToRole").getValue();
Attribute2 containsTargetAttr = navPropStartElement.getAttributeByName("ContainsTarget");
boolean containsTarget = false;
if (containsTargetAttr != null) {
containsTarget = Boolean.parseBoolean(containsTargetAttr.getValue());
}
while (reader.hasNext()) {
event = reader.nextEvent();
if (event.isStartElement()) {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
if (isEndElement(event, navPropStartElement.getName())) {
return EdmNavigationProperty.newBuilder(associationName)
.setRelationshipName(relationshipName)
.setFromToName(fromRoleName, toRoleName)
.setAnnotations(getAnnotations(navPropStartElement))
.setAnnotationElements(annotElements)
.setContainsTarget(containsTarget);
}
}
throw new UnsupportedOperationException();
}
示例11: parseAtomLink
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private AtomLink parseAtomLink(XMLEventReader2 reader, StartElement2 linkElement, EdmEntitySet entitySet) {
AtomLink rt = new AtomLink();
rt.relation = getAttributeValueIfExists(linkElement, "rel");
rt.type = getAttributeValueIfExists(linkElement, "type");
rt.title = getAttributeValueIfExists(linkElement, "title");
rt.href = getAttributeValueIfExists(linkElement, "href");
rt.inlineContentExpected = false;
String navPropertyName = rt.getNavProperty();
EdmNavigationProperty navProperty = null;
if (entitySet != null && navPropertyName != null)
navProperty = entitySet.getType().findNavigationProperty(navPropertyName);
EdmEntitySet targetEntitySet = null;
if (navProperty != null)
targetEntitySet = metadata.getEdmEntitySet(navProperty.getToRole().getType());
// expected cases:
// 1. </link> - no inlined content, i.e. deferred
// 2. <m:inline/></link> - inlined content but null entity or empty feed
// 3. <m:inline><feed>...</m:inline></link> - inlined content with 1 or more items
// 4. <m:inline><entry>..</m:inline></link> - inlined content 1 an item
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isEndElement() && event.asEndElement().getName().equals(linkElement.getName())) {
break;
} else if (isStartElement(event, XmlFormatParser.M_INLINE)) {
rt.inlineContentExpected = true; // may be null content.
} else if (isStartElement(event, ATOM_FEED)) {
rt.inlineFeed = parseFeed(reader, targetEntitySet);
} else if (isStartElement(event, ATOM_ENTRY)) {
rt.inlineEntry = parseEntry(reader, event.asStartElement(), targetEntitySet);
}
}
return rt;
}
示例12: parsePropertyRef
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private List<String> parsePropertyRef(XMLEventReader2 tmpReader, StartElement2 startElement) {
List<String> references = new ArrayList<String>();
while (tmpReader.hasNext()) {
XMLEvent2 event = tmpReader.nextEvent();
if (isStartElement(event, EDM2006_PROPERTYREF, EDM2007_PROPERTYREF, EDM2008_1_PROPERTYREF, EDM2008_9_PROPERTYREF, EDM2009_8_PROPERTYREF, EDM2009_11_PROPERTYREF)) {
references.add(event.asStartElement().getAttributeByName("Name").getValue());
}
if (isEndElement(event, startElement.getName())) {
return references;
}
}
throw new UnsupportedOperationException();
}
示例13: 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);
}
示例14: parseEdmAssociation
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
private EdmAssociation.Builder parseEdmAssociation(XMLEventReader2 reader, String schemaNamespace, String schemaAlias, StartElement2 associationElement) {
String name = associationElement.getAttributeByName("Name").getValue();
List<EdmAssociationEnd.Builder> ends = new ArrayList<EdmAssociationEnd.Builder>();
List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
EdmReferentialConstraint.Builder referentialConstraint = null;
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (event.isStartElement()) {
if (isElement(event, EDM2006_END, EDM2007_END, EDM2008_1_END, EDM2008_9_END, EDM2009_8_END, EDM2009_11_END)) {
EdmAssociationEnd.Builder edmAssociationEnd = parseEdmAssociationEnd(reader, event);
ends.add(edmAssociationEnd);
}
else if (isElement(event, EDM2006_REFCONSTRAINT, EDM2007_REFCONSTRAINT, EDM2008_1_REFCONSTRAINT, EDM2008_9_REFCONSTRAINT, EDM2009_8_REFCONSTRAINT, EDM2009_11_REFCONSTRAINT)) {
StartElement2 constraintElement = event.asStartElement();
referentialConstraint = parseEdmConstraintElement(reader, constraintElement);
}
else {
EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
if (anElement != null) {
annotElements.add(anElement);
}
}
}
if (isEndElement(event, associationElement.getName())) {
return EdmAssociation.newBuilder().setNamespace(schemaNamespace)
.setAlias(schemaAlias).setName(name)
.setEnds(ends.get(0), ends.get(1))
.setRefConstraint(referentialConstraint == null ? null : referentialConstraint)
.setAnnotations(getAnnotations(associationElement))
.setAnnotationElements(annotElements);
}
}
throw new UnsupportedOperationException();
}
示例15: parseMetadata
import org.odata4j.stax2.XMLEventReader2; //导入方法依赖的package包/类
public EdmDataServices parseMetadata(XMLEventReader2 reader) {
List<EdmSchema.Builder> schemas = new ArrayList<EdmSchema.Builder>();
List<PrefixedNamespace> namespaces = null;
ODataVersion version = null;
boolean foundDataServices = false;
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
boolean shouldReturn = false;
if (event.isStartElement()) {
if (isElement(event, XmlFormatParser.EDMX_EDMX)) {
namespaces = getExtensionNamespaces(event.asStartElement());
}
else if (isElement(event, EDMX_DATASERVICES)) {
foundDataServices = true;
String str = getAttributeValueIfExists(event.asStartElement(), new QName2(NS_METADATA, "DataServiceVersion"));
version = str != null
? ODataVersion.parse(str)
: null;
}
else if (isElement(event, EDM2006_SCHEMA, EDM2007_SCHEMA, EDM2008_1_SCHEMA, EDM2008_9_SCHEMA, EDM2009_8_SCHEMA, EDM2009_11_SCHEMA)) {
schemas.add(parseEdmSchema(reader, event.asStartElement()));
if (!foundDataServices) // some dallas services have Schema as the document element!
shouldReturn = true;
}
}
if (isEndElement(event, EDMX_DATASERVICES))
shouldReturn = true;
if (shouldReturn) {
dataServices.setVersion(version).addSchemas(schemas).addNamespaces(namespaces);
resolve();
return dataServices.build();
}
}
throw new UnsupportedOperationException();
}