@Test public void testParseVDB() throws Exception { FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml"); VDBMetadataParser.validate(in); in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml"); VDBMetaData vdb = VDBMetadataParser.unmarshall(in); TestVDBUtility.validateVDB(vdb); ByteArrayOutputStream baos = new ByteArrayOutputStream(); VDBMetadataParser.marshall(vdb, baos); baos.close(); VDBMetaData parsed = VDBMetadataParser.unmarshall(new ByteArrayInputStream(baos.toByteArray())); TestVDBUtility.validateVDB(parsed); }
private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: parseProperty(reader, vdb); break; case MODEL: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: VDBImportMetadata vdbImport = new VDBImportMetadata(); Properties props = getAttributes(reader); vdbImport.setName(props.getProperty(Element.NAME.getLocalName())); String version = props.getProperty(Element.VERSION.getLocalName()); if (version != null) { vdbImport.setVersion(version); } vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true"))); vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break; case ENTRY: EntryMetaData entry = new EntryMetaData(); parseEntry(reader, entry); vdb.getEntries().add(entry); break; default: throw new XMLStreamException(AdminPlugin.Util.gs("unexpected_element5",reader.getName(), Element.DESCRIPTION.getLocalName(), Element.PROPERTY.getLocalName(), Element.MODEL.getLocalName(), Element.TRANSLATOR.getLocalName(), Element.DATA_ROLE.getLocalName()), reader.getLocation()); } } }
VDBMetadataParser { private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: parseProperty(reader, vdb); break; case MODEL: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: VDBImportMetadata vdbImport = new VDBImportMetadata(); Properties props = getAttributes(reader); vdbImport.setName(props.getProperty(Element.NAME.getLocalName())); String version = props.getProperty(Element.VERSION.getLocalName()); if (version != null) { vdbImport.setVersion(version); } vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true"))); vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break; case ENTRY: EntryMetaData entry = new EntryMetaData(); parseEntry(reader, entry); vdb.getEntries().add(entry); break; default: throw new XMLStreamException(AdminPlugin.Util.gs("unexpected_element5",reader.getName(), Element.DESCRIPTION.getLocalName(), Element.PROPERTY.getLocalName(), Element.MODEL.getLocalName(), Element.TRANSLATOR.getLocalName(), Element.DATA_ROLE.getLocalName()), reader.getLocation()); } } } }
VDBMetadataParser { private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: parseProperty(reader, vdb); break; case MODEL: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: VDBImportMetadata vdbImport = new VDBImportMetadata(); Properties props = getAttributes(reader); vdbImport.setName(props.getProperty(Element.NAME.getLocalName())); String version = props.getProperty(Element.VERSION.getLocalName()); if (version != null) { vdbImport.setVersion(version); } vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true"))); vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break; case ENTRY: EntryMetaData entry = new EntryMetaData(); parseEntry(reader, entry); vdb.getEntries().add(entry); break; default: throw new XMLStreamException(AdminPlugin.Util.gs("unexpected_element5",reader.getName(), Element.DESCRIPTION.getLocalName(), Element.PROPERTY.getLocalName(), Element.MODEL.getLocalName(), Element.TRANSLATOR.getLocalName(), Element.DATA_ROLE.getLocalName()), reader.getLocation()); } } }  }
VDBMetadataParser { private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: parseProperty(reader, vdb); break; case MODEL: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: VDBImportMetadata vdbImport = new VDBImportMetadata(); Properties props = getAttributes(reader); vdbImport.setName(props.getProperty(Element.NAME.getLocalName())); String version = props.getProperty(Element.VERSION.getLocalName()); if (version != null) { vdbImport.setVersion(version); } vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true"))); vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break; case ENTRY: EntryMetaData entry = new EntryMetaData(); parseEntry(reader, entry); vdb.getEntries().add(entry); break; default: throw new XMLStreamException(AdminPlugin.Util.gs("unexpected_element5",reader.getName(), Element.DESCRIPTION.getLocalName(), Element.PROPERTY.getLocalName(), Element.MODEL.getLocalName(), Element.TRANSLATOR.getLocalName(), Element.DATA_ROLE.getLocalName()), reader.getLocation()); } } }  @Deprecated static VDBMetaData unmarshell(InputStream content); static VDBMetaData unmarshall(InputStream content); static void validate(InputStream content); @Deprecated static void marshell(VDBMetaData vdb, OutputStream out); static void marshall(VDBMetaData vdb, OutputStream out); }
VDBMetadataParser { private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException { while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { Element element = Element.forName(reader.getLocalName()); switch (element) { case DESCRIPTION: vdb.setDescription(reader.getElementText()); break; case CONNECTION_TYPE: vdb.setConnectionType(reader.getElementText()); break; case PROPERTY: parseProperty(reader, vdb); break; case MODEL: ModelMetaData model = new ModelMetaData(); parseModel(reader, model); vdb.addModel(model); break; case TRANSLATOR: VDBTranslatorMetaData translator = new VDBTranslatorMetaData(); parseTranslator(reader, translator); vdb.addOverideTranslator(translator); break; case DATA_ROLE: DataPolicyMetadata policy = new DataPolicyMetadata(); parseDataRole(reader, policy); vdb.addDataPolicy(policy); break; case IMPORT_VDB: VDBImportMetadata vdbImport = new VDBImportMetadata(); Properties props = getAttributes(reader); vdbImport.setName(props.getProperty(Element.NAME.getLocalName())); String version = props.getProperty(Element.VERSION.getLocalName()); if (version != null) { vdbImport.setVersion(version); } vdbImport.setImportDataPolicies(Boolean.parseBoolean(props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true"))); vdb.getVDBImports().add(vdbImport); ignoreTillEnd(reader); break; case ENTRY: EntryMetaData entry = new EntryMetaData(); parseEntry(reader, entry); vdb.getEntries().add(entry); break; default: throw new XMLStreamException(AdminPlugin.Util.gs("unexpected_element5",reader.getName(), Element.DESCRIPTION.getLocalName(), Element.PROPERTY.getLocalName(), Element.MODEL.getLocalName(), Element.TRANSLATOR.getLocalName(), Element.DATA_ROLE.getLocalName()), reader.getLocation()); } } }  @Deprecated static VDBMetaData unmarshell(InputStream content); static VDBMetaData unmarshall(InputStream content); static void validate(InputStream content); @Deprecated static void marshell(VDBMetaData vdb, OutputStream out); static void marshall(VDBMetaData vdb, OutputStream out);  }