List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entitySet(final Writer outWriter, final EntityCollection entitySet) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); startDocument(writer, Constants.ATOM_ELEM_FEED); entitySet(writer, entitySet);/*from www . j a va 2s . com*/ writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); startDocument(writer, Constants.ATOM_ELEM_FEED); addContextInfo(writer, entitySet);/*w w w.j av a 2s .c o m*/ entitySet(writer, entitySet.getPayload()); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void link(final Writer outWriter, final Link link) throws XMLStreamException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); writer.writeStartDocument();// ww w .j ava 2s . c o m writer.writeStartElement(Constants.ELEM_LINKS); writer.writeDefaultNamespace(namespaceData); writer.writeStartElement(Constants.ELEM_URI); writer.writeCharacters(link.getHref()); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void reference(final Writer outWriter, final ResWrap<URI> container) throws XMLStreamException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); writer.writeStartDocument();/* w w w .j a va2 s. c o m*/ writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF, Constants.NS_METADATA); writer.writeNamespace(Constants.ATTR_METADATA, Constants.NS_METADATA); writer.writeAttribute(Constants.ATTR_METADATA, Constants.NS_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString()); writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString()); writer.writeEndElement(); writer.writeEndDocument(); }
From source file:org.apache.olingo.commons.core.data.AtomPropertySerializer.java
private void collection(final XMLStreamWriter writer, final CollectionValue value) throws XMLStreamException { for (Value item : value.get()) { writer.writeStartElement(Constants.PREFIX_DATASERVICES, Constants.ELEM_ELEMENT, version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES)); value(writer, item);/*from w w w. ja va 2 s .co m*/ writer.writeEndElement(); } }
From source file:org.apache.olingo.commons.core.data.AtomPropertySerializer.java
public void property(final XMLStreamWriter writer, final Property property, final boolean standalone) throws XMLStreamException { writer.writeStartElement(Constants.PREFIX_DATASERVICES, property.getName(), version.getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES)); if (standalone) { namespaces(writer);/*from ww w . j a v a 2s . com*/ } if (StringUtils.isNotBlank(property.getType())) { writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_TYPE, property.getType()); } if (property.getValue().isNull()) { writer.writeAttribute(Constants.PREFIX_METADATA, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.ATTR_NULL, Boolean.TRUE.toString()); } else { value(writer, property.getValue()); } writer.writeEndElement(); }
From source file:org.apache.olingo.commons.core.data.AtomSerializer.java
private void links(final XMLStreamWriter writer, final List<Link> links) throws XMLStreamException { for (Link link : links) { writer.writeStartElement(Constants.ATOM_ELEM_LINK); if (StringUtils.isNotBlank(link.getRel())) { writer.writeAttribute(Constants.ATTR_REL, link.getRel()); }/*from w w w . jav a 2s . c o m*/ if (StringUtils.isNotBlank(link.getTitle())) { writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle()); } if (StringUtils.isNotBlank(link.getHref())) { writer.writeAttribute(Constants.ATTR_HREF, link.getHref()); } if (StringUtils.isNotBlank(link.getType())) { writer.writeAttribute(Constants.ATTR_TYPE, link.getType()); } if (link.getInlineEntry() != null || link.getInlineFeed() != null) { writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA)); if (link.getInlineEntry() != null) { writer.writeStartElement(Constants.ATOM_ELEM_ENTRY); entry(writer, link.getInlineEntry()); writer.writeEndElement(); } if (link.getInlineFeed() != null) { writer.writeStartElement(Constants.ATOM_ELEM_FEED); feed(writer, link.getInlineFeed()); writer.writeEndElement(); } writer.writeEndElement(); } writer.writeEndElement(); } }
From source file:org.apache.olingo.commons.core.data.AtomSerializer.java
private void common(final XMLStreamWriter writer, final AbstractAtomObject object) throws XMLStreamException { if (StringUtils.isNotBlank(object.getTitle())) { writer.writeStartElement(Constants.ATOM_ELEM_TITLE); writer.writeAttribute(Constants.ATTR_TYPE, TYPE_TEXT); writer.writeCharacters(object.getTitle()); writer.writeEndElement(); }//from ww w . jav a 2s .com if (StringUtils.isNotBlank(object.getSummary())) { writer.writeStartElement(Constants.ATOM_ELEM_SUMMARY); writer.writeAttribute(Constants.ATTR_TYPE, "text"); writer.writeCharacters(object.getSummary()); writer.writeEndElement(); } }
From source file:org.apache.olingo.commons.core.data.AtomSerializer.java
private void entry(final XMLStreamWriter writer, final Entry entry) throws XMLStreamException { if (entry.getBaseURI() != null) { writer.writeAttribute(XMLConstants.XML_NS_URI, Constants.ATTR_XML_BASE, entry.getBaseURI().toASCIIString()); }/*from www. j a v a 2 s.co m*/ if (StringUtils.isNotBlank(entry.getId())) { writer.writeStartElement(Constants.ATOM_ELEM_ID); writer.writeCharacters(entry.getId()); writer.writeEndElement(); } writer.writeStartElement(Constants.ATOM_ELEM_CATEGORY); writer.writeAttribute(Constants.ATOM_ATTR_SCHEME, version.getNamespaceMap().get(ODataServiceVersion.NS_SCHEME)); writer.writeAttribute(Constants.ATOM_ATTR_TERM, entry.getType()); writer.writeEndElement(); if (entry instanceof AbstractAtomObject) { common(writer, (AbstractAtomObject) entry); } links(writer, entry.getAssociationLinks()); links(writer, entry.getNavigationLinks()); links(writer, entry.getMediaEditLinks()); writer.writeStartElement(Constants.ATOM_ELEM_CONTENT); if (entry.isMediaEntry()) { if (StringUtils.isNotBlank(entry.getMediaContentType())) { writer.writeAttribute(Constants.ATTR_TYPE, entry.getMediaContentType()); } if (StringUtils.isNotBlank(entry.getMediaContentSource())) { writer.writeAttribute(Constants.ATOM_ATTR_SRC, entry.getMediaContentSource()); } writer.writeEndElement(); writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES); properties(writer, entry.getProperties()); } else { writer.writeAttribute(Constants.ATTR_TYPE, ContentType.APPLICATION_XML); writer.writeStartElement(version.getNamespaceMap().get(ODataServiceVersion.NS_METADATA), Constants.PROPERTIES); properties(writer, entry.getProperties()); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.apache.olingo.commons.core.data.AtomSerializer.java
private void entry(final Writer outWriter, final Entry entry) throws XMLStreamException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); startDocument(writer, Constants.ATOM_ELEM_ENTRY); entry(writer, entry);//from ww w. j a va2 s . com writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }