XMLGISElementUtil { public static <T extends MapElement> void readGISElementContainer(Element xmlNode, GISElementContainer<T> primitive, PathBuilder pathBuilder, XMLResources resources) throws IOException { readGISElementContainer(xmlNode, primitive, null, pathBuilder, resources); } 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 readGISElementContainerElementGISElementContainerPathBuilderXMLResources() throws Exception { PathBuilder pathBuilder = new SimplePathBuilder(); XMLResources res = new XMLResources(pathBuilder); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc; try (InputStream is = url2.openStream()) { doc = builder.parse(is); } ArrayMapElementLayer<MapPoint> container = new ArrayMapElementLayer(MapPoint.class); XMLGISElementUtil.readGISElementContainer(doc.getDocumentElement(), container, pathBuilder, res); MapPoint point1 = container.getMapElementAt(0); assertNotNull(point1); assertEquals("name1", point1.getName()); assertEpsilonEquals(3, point1.getX()); assertEpsilonEquals(4, point1.getY()); MapPoint point2 = container.getMapElementAt(1); assertNotNull(point2); assertEquals("name2", point2.getName()); assertEpsilonEquals(34, point2.getX()); assertEpsilonEquals(55, point2.getY()); }
@Test public void readGISElementContainerElementGISElementContainerStringPathBuilderXMLResources() throws Exception { PathBuilder pathBuilder = new SimplePathBuilder(); XMLResources res = new XMLResources(pathBuilder); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc; try (InputStream is = url2.openStream()) { doc = builder.parse(is); } ArrayMapElementLayer<MapPoint> container = new ArrayMapElementLayer(MapPoint.class); XMLGISElementUtil.readGISElementContainer(doc.getDocumentElement(), container, "point", pathBuilder, res); MapPoint point1 = container.getMapElementAt(0); assertNotNull(point1); assertEquals("name1", point1.getName()); assertEpsilonEquals(3, point1.getX()); assertEpsilonEquals(4, point1.getY()); MapPoint point2 = container.getMapElementAt(1); assertNotNull(point2); assertEquals("name2", point2.getName()); assertEpsilonEquals(34, point2.getX()); assertEpsilonEquals(55, point2.getY()); }