本文整理汇总了Java中org.odata4j.stax2.QName2类的典型用法代码示例。如果您正苦于以下问题:Java QName2类的具体用法?Java QName2怎么用?Java QName2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QName2类属于org.odata4j.stax2包,在下文中一共展示了QName2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startElement
import org.odata4j.stax2.QName2; //导入依赖的package包/类
public void startElement(QName2 qname, String xmlns) {
// writer.setDefaultNamespace("http://www.example.com/ns1");
try {
Iterator<?> nsIterator = null;
if (xmlns != null) {
nsIterator = Enumerable.create(eventFactory.createNamespace(xmlns)).iterator();
}
// writer.writeStartElement(prefix,localName,namespaceURI);
XMLEvent event = eventFactory.createStartElement(StaxXMLFactoryProvider2.toQName(qname), null, nsIterator);
eventWriter.add(event);
} catch (XMLStreamException e) {
throw Throwables.propagate(e);
}
}
示例2: endElement
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public void endElement(String localName) {
QName2 startElementName = elements.pop();
if (!startElementName.getLocalPart().equals(localName))
throw new IllegalArgumentException();
if (isStartElementOpen) {
write("/");
write(">");
isStartElementOpen = false;
return;
}
write("</");
if (startElementName.getPrefix() != null) {
write(startElementName.getPrefix());
write(":");
}
write(localName);
write(">");
}
示例3: startElement
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public void startElement(QName2 qname, String xmlns) {
ensureStartElementClosed();
write("<");
if (qname.getPrefix() != null) {
write(qname.getPrefix());
write(":");
}
write(qname.getLocalPart());
if (xmlns != null) {
write(" xmlns=\"" + xmlns + "\"");
}
isStartElementOpen = true;
elements.push(qname);
}
示例4: getAttributeByName
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public Attribute2 getAttributeByName(QName2 qName2) {
final Attr attr = element.getAttributeNodeNS(qName2.getNamespaceUri(), qName2.getLocalPart());
if (attr == null)
return null;
return new Attribute2() {
public String getValue() {
return attr.getValue();
}
@Override
public QName2 getName() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
示例5: writeRequestEntry
import org.odata4j.stax2.QName2; //导入依赖的package包/类
public void writeRequestEntry(Writer w, Entry entry) {
DateTime utc = new DateTime().withZone(DateTimeZone.UTC);
String updated = InternalUtil.toString(utc);
XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
writer.startDocument();
writer.startElement(new QName2("entry"), atom);
writer.writeNamespace("d", d);
writer.writeNamespace("m", m);
OEntity entity = entry.getEntity();
writeEntry(writer, null, entity.getProperties(), entity.getLinks(),
null, updated, entity.getEntitySet(), false);
writer.endDocument();
}
示例6: write
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public void write(UriInfo uriInfo, Writer w, EntityResponse target) {
String baseUri = uriInfo.getBaseUri().toString();
EdmEntitySet ees = target.getEntity().getEntitySet();
DateTime utc = new DateTime().withZone(DateTimeZone.UTC);
String updated = InternalUtil.toString(utc);
XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
writer.startDocument();
writer.startElement(new QName2("entry"), atom);
writer.writeNamespace("m", m);
writer.writeNamespace("d", d);
writer.writeAttribute("xml:base", baseUri);
writeEntry(writer, target.getEntity(), target.getEntity().getProperties(), target.getEntity().getLinks(), baseUri, updated, ees, true);
writer.endDocument();
}
示例7: parseFeed
import org.odata4j.stax2.QName2; //导入依赖的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;
}
示例8: writeError
import org.odata4j.stax2.QName2; //导入依赖的package包/类
private static void writeError(XMLWriter2 writer, OError error, String xmlns) {
writer.startElement(new QName2("error"), xmlns);
writer.startElement("code");
writer.writeText(error.getCode());
writer.endElement("code");
writer.startElement("message");
writer.writeAttribute("lang", "en-US");
writer.writeText(error.getMessage());
writer.endElement("message");
if (error.getInnerError() != null) {
writer.startElement("innererror");
writer.writeText(error.getInnerError());
writer.endElement("innererror");
}
writer.endElement("error");
}
示例9: getAnnotations
import org.odata4j.stax2.QName2; //导入依赖的package包/类
protected List<EdmAnnotation<?>> getAnnotations(StartElement2 element) {
// extract Annotation attributes
try {
Enumerable<Attribute2> atts = element.getAttributes();
List<EdmAnnotation<?>> annots = new ArrayList<EdmAnnotation<?>>();
for (Attribute2 att : atts) {
QName2 q = att.getName();
if (isExtensionNamespace(q.getNamespaceUri())) {
// a user extension
annots.add(EdmAnnotation.attribute(q.getNamespaceUri(), q.getPrefix(), q.getLocalPart(), att.getValue()));
}
}
return annots;
} catch (Exception ex) {
// not all of the xml parsing implementations implement getAttributes() yet.
return null;
}
}
示例10: writeAnnotation
import org.odata4j.stax2.QName2; //导入依赖的package包/类
private static void writeAnnotation(Iterable<? extends NamespacedAnnotation<?>> annotList, XMLWriter2 writer,
String prefix) {
String prefix1 = prefix;
for (NamespacedAnnotation<?> a : annotList) {
if (a instanceof EdmAnnotationAttribute) {
String prefix2 = a.getNamespace().getPrefix();
writer.writeAttribute(
new QName2(a.getNamespace().getUri(), a.getName(), a.getNamespace().getPrefix()),
a.getValue() == null ? "" : a.getValue().toString());
// if (!prefix2.equals(prefix1)) {
// writer.writeNamespace(a.getNamespace().getPrefix(), a.getNamespace().getUri());
// }
// prefix1 = prefix2;
}
}
}
示例11: writeElementInAnnotation
import org.odata4j.stax2.QName2; //导入依赖的package包/类
private static void writeElementInAnnotation(Iterable<? extends NamespacedAnnotation<?>> annotList, XMLWriter2 writer) {
for (NamespacedAnnotation<?> a : annotList) {
if (a instanceof EdmAnnotationElement) {
EdmAnnotationElement<?> elem = (EdmAnnotationElement<?>) a;
writer.startElement(new QName2(elem.getNamespace().getUri(), elem.getName(), elem.getNamespace().getPrefix()));
if (elem.getNamespace().getPrefix() != null && elem.getNamespace().getUri() != null) {
writer.writeNamespace(elem.getNamespace().getPrefix(), elem.getNamespace().getUri());
}
writeAnnotationAttributes(elem, writer, elem.getNamespace().getPrefix());
writer.writeText(elem.getValue().toString().trim());
writeAnnotationElements(elem, writer);
writer.endElement(a.getName());
// TODO: please don't throw an exception here.
// this totally breaks ODataConsumer even thought it doesn't rely
// on annotations. A no-op is a interim approach that allows work
// to proceed by those using queryable metadata to access annotations.
// throw new UnsupportedOperationException("Implement element annotations");
}
}
}
示例12: write
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public void write(UriInfo uriInfo, Writer w, CollectionResponse<?> target) {
XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
writer.startDocument();
writer.startElement(new QName2(d, target.getCollectionName(), "d"));
writer.writeNamespace("d", d);
writer.writeNamespace("m", m);
OCollection<?> coll = target.getCollection();
for (Object e : coll) {
this.writeProperty(writer, "element", coll.getType(), e, false, !coll.getType().isSimple());
}
writer.endElement(target.getCollectionName());
writer.endDocument();
}
示例13: writeAttribute
import org.odata4j.stax2.QName2; //导入依赖的package包/类
public void writeAttribute(QName2 qname, String value) {
try {
// writer.writeAttribute(localName, value);
XMLEvent event = eventFactory.createAttribute(StaxXMLFactoryProvider2.toQName(qname), value);
eventWriter.add(event);
} catch (XMLStreamException e) {
throw Throwables.propagate(e);
}
}
示例14: getAttributeByName
import org.odata4j.stax2.QName2; //导入依赖的package包/类
@Override
public Attribute2 getAttributeByName(QName2 name) {
Attribute att = real.getAttributeByName(toQName(name));
if (att == null)
return null;
return new StaxAttribute2(att);
}
示例15: pred1_byQName
import org.odata4j.stax2.QName2; //导入依赖的package包/类
public static Predicate1<Attribute2> pred1_byQName(final QName2 name) {
return new Predicate1<Attribute2>() {
@Override
public boolean apply(Attribute2 attribute) {
return equal(attribute.getName().getNamespaceUri(), name.getNamespaceUri()) && equal(attribute.getName().getLocalPart(), name.getLocalPart());
}
};
}