@Test public void testGetMetadataType() { try { Document docFgdc = XmlUtil.load(inFgdc); MetadataType mdTypeFgdc = XmlUtil.getMetadataType(docFgdc); Assert.assertEquals(MetadataType.FGDC , mdTypeFgdc); Document docIso19139 = XmlUtil.load(inIso19139); MetadataType mdTypeIso19139 = XmlUtil.getMetadataType(docIso19139); Assert.assertEquals(MetadataType.ISO_19139, mdTypeIso19139); } catch (Exception ex) { ex.printStackTrace(); Assert.fail(); } }
public static MetadataType getMetadataType(Document document) throws UnsupportedMetadataType { MetadataType metadataType = null; String metadataText = ""; try { String metadata = document.getElementsByTagName("metstdn").item(0).getTextContent(); metadataText = metadata; if (metadata.toLowerCase().contains("fgdc")) { metadataType = MetadataType.FGDC; } } catch (Exception e) { } try { NodeList standardNodes = document.getElementsByTagNameNS("*", "metadataStandardName"); if (standardNodes.getLength() > 0) { String metadata = standardNodes.item(0).getTextContent(); metadataText = metadata; if (metadata.contains("19139")) { metadataType = MetadataType.ISO_19139; } } } catch (Exception e) { } if (metadataType == null) { throw new UnsupportedMetadataType("Metadata Type [" + metadataText + "] is not supported."); } return metadataType; }
XmlUtil { public static MetadataType getMetadataType(Document document) throws UnsupportedMetadataType { MetadataType metadataType = null; String metadataText = ""; try { String metadata = document.getElementsByTagName("metstdn").item(0).getTextContent(); metadataText = metadata; if (metadata.toLowerCase().contains("fgdc")) { metadataType = MetadataType.FGDC; } } catch (Exception e) { } try { NodeList standardNodes = document.getElementsByTagNameNS("*", "metadataStandardName"); if (standardNodes.getLength() > 0) { String metadata = standardNodes.item(0).getTextContent(); metadataText = metadata; if (metadata.contains("19139")) { metadataType = MetadataType.ISO_19139; } } } catch (Exception e) { } if (metadataType == null) { throw new UnsupportedMetadataType("Metadata Type [" + metadataText + "] is not supported."); } return metadataType; } }
XmlUtil { public static MetadataType getMetadataType(Document document) throws UnsupportedMetadataType { MetadataType metadataType = null; String metadataText = ""; try { String metadata = document.getElementsByTagName("metstdn").item(0).getTextContent(); metadataText = metadata; if (metadata.toLowerCase().contains("fgdc")) { metadataType = MetadataType.FGDC; } } catch (Exception e) { } try { NodeList standardNodes = document.getElementsByTagNameNS("*", "metadataStandardName"); if (standardNodes.getLength() > 0) { String metadata = standardNodes.item(0).getTextContent(); metadataText = metadata; if (metadata.contains("19139")) { metadataType = MetadataType.ISO_19139; } } } catch (Exception e) { } if (metadataType == null) { throw new UnsupportedMetadataType("Metadata Type [" + metadataText + "] is not supported."); } return metadataType; }  }
XmlUtil { public static MetadataType getMetadataType(Document document) throws UnsupportedMetadataType { MetadataType metadataType = null; String metadataText = ""; try { String metadata = document.getElementsByTagName("metstdn").item(0).getTextContent(); metadataText = metadata; if (metadata.toLowerCase().contains("fgdc")) { metadataType = MetadataType.FGDC; } } catch (Exception e) { } try { NodeList standardNodes = document.getElementsByTagNameNS("*", "metadataStandardName"); if (standardNodes.getLength() > 0) { String metadata = standardNodes.item(0).getTextContent(); metadataText = metadata; if (metadata.contains("19139")) { metadataType = MetadataType.ISO_19139; } } } catch (Exception e) { } if (metadataType == null) { throw new UnsupportedMetadataType("Metadata Type [" + metadataText + "] is not supported."); } return metadataType; }  static Document load(InputStream inputStream); static Document load(String uri); static MetadataType getMetadataType(Document document); static String getFullText(Document document); }
XmlUtil { public static MetadataType getMetadataType(Document document) throws UnsupportedMetadataType { MetadataType metadataType = null; String metadataText = ""; try { String metadata = document.getElementsByTagName("metstdn").item(0).getTextContent(); metadataText = metadata; if (metadata.toLowerCase().contains("fgdc")) { metadataType = MetadataType.FGDC; } } catch (Exception e) { } try { NodeList standardNodes = document.getElementsByTagNameNS("*", "metadataStandardName"); if (standardNodes.getLength() > 0) { String metadata = standardNodes.item(0).getTextContent(); metadataText = metadata; if (metadata.contains("19139")) { metadataType = MetadataType.ISO_19139; } } } catch (Exception e) { } if (metadataType == null) { throw new UnsupportedMetadataType("Metadata Type [" + metadataText + "] is not supported."); } return metadataType; }  static Document load(InputStream inputStream); static Document load(String uri); static MetadataType getMetadataType(Document document); static String getFullText(Document document);  }