List of usage examples for javax.xml.stream XMLStreamWriter writeEmptyElement
public void writeEmptyElement(String localName) throws XMLStreamException;
From source file:com.github.fritaly.graphml4j.GeneralStyle.java
private void writeFill(XMLStreamWriter writer) throws XMLStreamException { Validate.notNull(writer, "The given stream writer is null"); // y:Fill//from w ww . j a va 2 s .com writer.writeEmptyElement("y:Fill"); if (fillColor != null) { writer.writeAttribute("color", Utils.encode(fillColor)); } if (fillColor2 != null) { writer.writeAttribute("color2", Utils.encode(fillColor2)); } writer.writeAttribute("transparent", Boolean.toString(transparentFill)); }
From source file:com.github.fritaly.graphml4j.GeneralStyle.java
private void writeBorderStyle(XMLStreamWriter writer) throws XMLStreamException { Validate.notNull(writer, "The given stream writer is null"); // y:BorderStyle writer.writeEmptyElement("y:BorderStyle"); writer.writeAttribute("color", Utils.encode(borderColor)); writer.writeAttribute("type", borderType.getValue()); writer.writeAttribute("width", String.format("%.1f", borderWidth)); }
From source file:de.shadowhunt.subversion.internal.ResolveOperation.java
@Override protected HttpUriRequest createRequest() { final Writer body = new StringBuilderWriter(); try {//from w w w . j a va2s . com final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body); writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0); writer.writeStartElement("get-locations"); writer.writeDefaultNamespace(XmlConstants.SVN_NAMESPACE); writer.writeEmptyElement("path"); writer.writeStartElement("peg-revision"); writer.writeCharacters(revision.toString()); writer.writeEndElement(); // peg-revision writer.writeStartElement("location-revision"); writer.writeCharacters(expected.toString()); writer.writeEndElement(); // location-revision writer.writeEndElement(); //get-locations writer.writeEndDocument(); writer.close(); } catch (final XMLStreamException e) { throw new SubversionException("could not create request body", e); } final URI uri = URIUtils.createURI(repository, resource); final DavTemplateRequest request = new DavTemplateRequest("REPORT", uri); request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML)); return request; }
From source file:de.shadowhunt.subversion.internal.ProbeServerOperation.java
@Override protected HttpUriRequest createRequest() { final Writer body = new StringBuilderWriter(); try {//w w w. j a v a 2 s. c o m final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body); writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0); writer.writeStartElement("options"); writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE); writer.writeEmptyElement("activity-collection-set"); writer.writeEndElement(); //options writer.writeEndDocument(); writer.close(); } catch (final XMLStreamException e) { throw new SubversionException("could not create request body: " + e.getMessage(), e); } final DavTemplateRequest request = new DavTemplateRequest("OPTIONS", repository); request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML)); return request; }
From source file:com.github.fritaly.graphml4j.ShapeStyle.java
private void writeDropShadow(XMLStreamWriter writer) throws XMLStreamException { Validate.notNull(writer, "The given stream writer is null"); if ((shadowColor == null) || ((shadowOffsetX == 0) && (shadowOffsetY == 0))) { // Nothing to render return;/*from w w w . java 2 s .co m*/ } // y:DropShadow writer.writeEmptyElement("y:DropShadow"); writer.writeAttribute("color", Utils.encode(shadowColor)); writer.writeAttribute("offsetX", Integer.toString(shadowOffsetX)); writer.writeAttribute("offsetY", Integer.toString(shadowOffsetY)); }
From source file:com.github.fritaly.graphml4j.GeneralStyle.java
private void writeGeometry(XMLStreamWriter writer, float x, float y) throws XMLStreamException { Validate.notNull(writer, "The given stream writer is null"); // y:Geometry (the x & y attributes are computed when laying out the graph in yEd) writer.writeEmptyElement("y:Geometry"); writer.writeAttribute("height", String.format("%.1f", height)); writer.writeAttribute("width", String.format("%.1f", width)); writer.writeAttribute("x", String.format("%.1f", x)); writer.writeAttribute("y", String.format("%.1f", y)); }
From source file:de.shadowhunt.subversion.internal.LockOperation.java
@Override protected HttpUriRequest createRequest() { final URI uri = URIUtils.createURI(repository, resource); final DavTemplateRequest request = new DavTemplateRequest("LOCK", uri); if (steal) {/*from w w w . java 2s. c o m*/ request.addHeader("X-SVN-Options", "lock-steal"); } final Writer body = new StringBuilderWriter(); try { final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body); writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0); writer.writeStartElement("lockinfo"); writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE); writer.writeStartElement("lockscope"); writer.writeEmptyElement("exclusive"); writer.writeEndElement(); // lockscope writer.writeStartElement("locktype"); writer.writeEmptyElement("write"); writer.writeEndElement(); // locktype writer.writeEndElement(); //lockinfo writer.writeEndDocument(); writer.close(); } catch (final XMLStreamException e) { throw new SubversionException("could not create request body", e); } request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML)); return request; }
From source file:com.github.fritaly.graphml4j.EdgeStyle.java
void writeTo(XMLStreamWriter writer) throws XMLStreamException { Validate.notNull(writer, "The given stream writer is null"); // What is the path used for ? // TODO Create properties for sx, sy, tx and ty // y:Path/*from www . ja va2 s.co m*/ writer.writeEmptyElement("y:Path"); writer.writeAttribute("sx", String.format("%.1f", 0.0f)); writer.writeAttribute("sy", String.format("%.1f", 0.0f)); writer.writeAttribute("tx", String.format("%.1f", 0.0f)); writer.writeAttribute("ty", String.format("%.1f", 0.0f)); // y:LineStyle writer.writeEmptyElement("y:LineStyle"); writer.writeAttribute("color", Utils.encode(color)); writer.writeAttribute("type", type.getValue()); writer.writeAttribute("width", String.format("%.1f", width)); // y:Arrows writer.writeEmptyElement("y:Arrows"); writer.writeAttribute("source", sourceArrow.getValue()); writer.writeAttribute("target", targetArrow.getValue()); // y:BendStyle writer.writeEmptyElement("y:BendStyle"); writer.writeAttribute("smoothed", Boolean.toString(smoothed)); }
From source file:de.qucosa.webapi.v1.SearchResource.java
private ResponseEntity<String> errorResponse(String message, HttpStatus status) throws XMLStreamException { StringWriter sw = new StringWriter(); XMLStreamWriter w = xmlOutputFactory.createXMLStreamWriter(sw); w.writeStartDocument("UTF-8", "1.0"); w.writeStartElement("Opus"); w.writeEmptyElement("SearchResult"); w.writeStartElement("Error"); w.writeAttribute("message", message); w.writeEndElement();//from w w w . j a va2 s.c o m w.writeEndElement(); w.writeEndDocument(); w.flush(); return new ResponseEntity<>(sw.toString(), status); }
From source file:de.shadowhunt.subversion.internal.AbstractPropfindOperation.java
@Override protected HttpUriRequest createRequest() { final URI uri = URIUtils.createURI(repository, resource); final DavTemplateRequest request = new DavTemplateRequest("PROPFIND", uri); request.addHeader("Depth", depth.value); final Writer body = new StringBuilderWriter(); try {// w ww.j av a 2 s . co m final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body); writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0); writer.writeStartElement("propfind"); writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE); if (requestedProperties == null) { writer.writeEmptyElement("prop"); } else { if (requestedProperties.length == 0) { writer.writeEmptyElement("allprop"); } else { writer.writeStartElement("prop"); if (contains(XmlConstants.SUBVERSION_DAV_NAMESPACE)) { writer.writeNamespace(XmlConstants.SUBVERSION_DAV_PREFIX, XmlConstants.SUBVERSION_DAV_NAMESPACE); writer.setPrefix(XmlConstants.SUBVERSION_DAV_PREFIX, XmlConstants.SUBVERSION_DAV_NAMESPACE); } if (contains(XmlConstants.SUBVERSION_SVN_NAMESPACE)) { writer.writeNamespace(XmlConstants.SUBVERSION_SVN_PREFIX, XmlConstants.SUBVERSION_SVN_NAMESPACE); writer.setPrefix(XmlConstants.SUBVERSION_SVN_PREFIX, XmlConstants.SUBVERSION_SVN_NAMESPACE); } for (final ResourceProperty.Key requestedProperty : requestedProperties) { writer.writeEmptyElement(requestedProperty.getType().getPrefix(), requestedProperty.getName()); } writer.writeEndElement(); // prop } } writer.writeEndElement(); // propfind writer.writeEndDocument(); writer.close(); } catch (final XMLStreamException e) { throw new SubversionException("could not create request body", e); } request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML)); return request; }