@Override public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException { com.vividsolutions.jts.geom.GeometryFactory gf = new com.vividsolutions.jts.geom.GeometryFactory(); final DefaultDomConverter domConverter = new DefaultDomConverter(Coordinate.class); final DomElement[] children = parentElement.getChildren("coordinate"); List<Coordinate> coordList = new ArrayList<Coordinate>(); for (DomElement child : children) { final Coordinate coordinate = (Coordinate) domConverter.convertDomToValue(child, null); coordList.add(coordinate); } return gf.createPolygon(gf.createLinearRing(coordList.toArray(new Coordinate[coordList.size()])), null); }
@Override public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException { com.vividsolutions.jts.geom.GeometryFactory gf = new com.vividsolutions.jts.geom.GeometryFactory(); final DefaultDomConverter domConverter = new DefaultDomConverter(Coordinate.class); final DomElement[] children = parentElement.getChildren("coordinate"); List<Coordinate> coordList = new ArrayList<Coordinate>(); for (DomElement child : children) { final Coordinate coordinate = (Coordinate) domConverter.convertDomToValue(child, null); coordList.add(coordinate); } return gf.createPolygon(gf.createLinearRing(coordList.toArray(new Coordinate[coordList.size()])), null); }
private static void addDomToMetadata(DomElement parentDE, MetadataElement parentME) { final HashMap<String, List<DomElement>> map = new HashMap<>( parentDE.getChildCount() + 5); for (DomElement childDE : parentDE.getChildren()) { final String name = childDE.getName(); List<DomElement> elementList = map.get(name); if (elementList == null) { elementList = new ArrayList<>(3); map.put(name, elementList); } elementList.add(childDE); } for (Entry<String, List<DomElement>> entry : map.entrySet()) { String name = entry.getKey(); final List<DomElement> elementList = entry.getValue(); if (elementList.size() > 1) { for (int i = 0; i < elementList.size(); i++) { addDomToMetadata(elementList.get(i), name + '.' + i, parentME); } } else { addDomToMetadata(elementList.get(0), name, parentME); } } }
private ProductSetData[] findProductSets(final String readerName) { final List<ProductSetData> productSetDataList = new ArrayList<>(); for (Node n : graph.getNodes()) { if (n.getOperatorName().equalsIgnoreCase(readerName)) { final ProductSetData psData = new ProductSetData(); psData.nodeID = n.getId(); final DomElement config = n.getConfiguration(); final DomElement[] params = config.getChildren(); for (DomElement p : params) { if (p.getName().equals("fileList") && p.getValue() != null) { final StringTokenizer st = new StringTokenizer(p.getValue(), ProductSetHandler.SEPARATOR); int length = st.countTokens(); for (int i = 0; i < length; i++) { final String str = st.nextToken().replace(ProductSetHandler.SEPARATOR_ESC, ProductSetHandler.SEPARATOR); psData.fileList.add(str); } break; } } productSetDataList.add(psData); } } return productSetDataList.toArray(new ProductSetData[productSetDataList.size()]); }
private SubGraphData[] findSubGraphs(final String opName) throws GraphException { try { final List<SubGraphData> dataList = new ArrayList<>(); for (Node n : graph.getNodes()) { if (n.getOperatorName().equalsIgnoreCase(opName)) { final SubGraphData data = new SubGraphData(); data.nodeID = n.getId(); final DomElement config = n.getConfiguration(); final DomElement[] params = config.getChildren(); for (DomElement p : params) { if (p.getName().equals("graphFile") && p.getValue() != null) { data.subGraph = GraphIO.read(new FileReader(p.getValue())); break; } } dataList.add(data); } } return dataList.toArray(new SubGraphData[dataList.size()]); } catch (Exception e) { throw new GraphException(e.getMessage(), e); } }
DomElement[] children = domElement.getChildren();
static void escapeXmlElements(DomElement domElement) { domElement.setValue(StringEscapeUtils.escapeXml(domElement.getValue())); String[] attributeNames = domElement.getAttributeNames(); for (String attributeName : attributeNames) { domElement.setAttribute(attributeName, StringEscapeUtils.escapeXml(domElement.getAttribute(attributeName))); } DomElement[] children = domElement.getChildren(); for (DomElement child : children) { escapeXmlElements(child); } }
final Object[] objArray = new Object[child.getChildCount()]; int c = 0; for (DomElement ch : child.getChildren()) { final String v = ch.getValue();