XMLGISElementUtil { public static void writeGISElementAttributes(Element element, GISElement primitive, XMLBuilder builder, XMLResources resources) throws IOException { XMLAttributeUtil.writeAttributeContainer(element, primitive, builder, resources, false); element.setAttribute(XMLUtil.ATTR_NAME, primitive.getName()); element.setAttribute(XMLAttributeUtil.ATTR_GEOID, primitive.getGeoId().toString()); element.setAttribute(XMLUtil.ATTR_ID, primitive.getUUID().toString()); } private  XMLGISElementUtil(); static Element writeMapElement(MapElement primitive, XMLBuilder builder, XMLResources resources); @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) static Element writeMapElement(MapElement primitive, String primitiveNodeName,
			XMLBuilder builder, XMLResources resources); static MapElement readMapElement(Element element, String elementNodeName,
			PathBuilder pathBuilder, XMLResources resources); @SuppressWarnings({"unchecked", "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) static T readMapElement(Element element, String elementNodeName,
			Class<T> type, PathBuilder pathBuilder, XMLResources resources); static String getDefaultMapElementNodeName(Class<? extends MapElement> type); static void writeGISElementContainer(Element xmlNode, GISElementContainer<?> primitive,
			XMLBuilder builder, PathBuilder pathBuilder, XMLResources resources); static void writeGISElementContainer(Element xmlNode, GISElementContainer<?> primitive,
			String elementNodeName, XMLBuilder builder, PathBuilder pathBuilder, XMLResources resources); static void readGISElementContainer(Element xmlNode,
			GISElementContainer<T> primitive, PathBuilder pathBuilder, XMLResources resources); @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth", "resource"}) static void readGISElementContainer(Element xmlNode,
			GISElementContainer<T> primitive, String elementNodeName, PathBuilder pathBuilder,
			XMLResources resources); static void writeGISElementAttributes(Element element, GISElement primitive, XMLBuilder builder,
			XMLResources resources); static void readGISElementAttributes(Element element, GISElement primitive, PathBuilder pathBuilder,
			XMLResources resources); static final String NODE_CIRCLE; static final String NODE_ELEMENTS; static final String NODE_GROUP; static final String NODE_GROUPS; static final String NODE_MULTIPOINT; static final String NODE_POINT; static final String NODE_POINTS; static final String NODE_POLYGON; static final String NODE_POLYLINE; static final String ATTR_DOUBLEFRAME; static final String ATTR_FIRSTPOINTINDEX; static final String ATTR_LASTPOINTINDEX; static final String ATTR_RADIUS; static final String ATTR_SIZE; static final String ATTR_WIDE; static final String ATTR_WIDTH; static final String ATTR_X; static final String ATTR_Y; }
@Test public void writeGISElementAttributesElementGISElementXMLBuilderXMLResources() throws Exception { PathBuilder pathBuilder = new SimplePathBuilder(); XMLResources res = new XMLResources(pathBuilder); MapPoint point = new MapPoint(3, 4); point.setName("name1"); point.setAttribute("attr1", "Text"); final String source = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?><root><a><b id=\"v\"/></a></root>"; final Document doc; try (ByteArrayInputStream reader = new ByteArrayInputStream(source.getBytes())) { doc = XMLUtil.readXML(reader); } XMLBuilder xmlBuilder = new XMLBuilder() { @Override public Document getDocument() throws DOMException { return doc; } }; XMLGISElementUtil.writeGISElementAttributes(doc.getDocumentElement(), point, xmlBuilder, res); String actual; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { XMLUtil.writeXML(doc, baos); baos.flush(); actual = new String(baos.toByteArray()); } final String id = point.getUUID().toString(); final String expected = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" + "<root geoId=\"39e072ec9ca6460ee679103fd10d53dc#3;4;3;4\" " + "id=\"" + id + "\" name=\"name1\">" + "<a><b id=\"v\"/></a>" + "<attributes><attribute name=\"attr1\" type=\"STRING\" value=\"Text\"/></attributes>" + "</root>"; assertEquals(expected, actual); }