package it.geosolutions.imageio.plugins.jhdf; import javax.imageio.metadata.IIOMetadataNode; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** * Simple abstract class used to build a String representing the structure * of a IIOMetadataNode tree. * * @author Daniele Romagnoli * */ public abstract class MetadataDisplay { private static int depth=0; public static String buildMetadataFromNode(IIOMetadataNode node) { String localMetadata=""; final String name = node.getNodeName(); final StringBuffer sb = new StringBuffer("<").append(name); NamedNodeMap attributes = node.getAttributes(); if (attributes!=null){ final int nAttributes = attributes.getLength(); if (nAttributes>0){ sb.append(" "); int i=0; for (;i"); localMetadata = sb.toString(); if (node.hasChildNodes()){ depth++; localMetadata = localMetadata + "\n" + setTab(depth) + buildMetadataFromNode((IIOMetadataNode)node.getFirstChild()); } IIOMetadataNode sibling = (IIOMetadataNode) node.getNextSibling(); if (sibling!=null){ localMetadata = localMetadata + "\n" + setTab(depth) + buildMetadataFromNode(sibling); } else depth--; return localMetadata; } private static String setTab(int depth) { final StringBuffer sb = new StringBuffer(); for (int i=0;i