@Test public void basic() throws Exception { javax.xml.parsers.DocumentBuilder builder = DocumentBuilderFactory .newInstance().newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); DataConfig dc = new DataConfig(); dc.readFromXml(doc.getDocumentElement()); Assert.assertEquals("atrimlisting", dc.document.entities.get(0).name); }
public void readFromXml(Element e) { List<Element> n = getChildNodes(e, "document"); if (n.isEmpty()) { throw new DataImportHandlerException(SEVERE, "DataImportHandler " + "configuration file must have one <document> node."); } document = new Document(n.get(0)); n = getChildNodes(e, SCRIPT); if (!n.isEmpty()) { script = new Script(n.get(0)); } n = getChildNodes(e, FUNCTION); if (!n.isEmpty()) { for (Element element : n) { String func = getStringAttribute(element, NAME, null); String clz = getStringAttribute(element, CLASS, null); if (func == null || clz == null){ throw new DataImportHandlerException( SEVERE, "<function> must have a 'name' and 'class' attributes"); } else { functions.add(getAllAttributes(element)); } } } n = getChildNodes(e, DATA_SRC); if (!n.isEmpty()) { for (Element element : n) { Properties p = new Properties(); HashMap<String, String> attrs = getAllAttributes(element); for (Map.Entry<String, String> entry : attrs.entrySet()) { p.setProperty(entry.getKey(), entry.getValue()); } dataSources.put(p.getProperty("name"), p); } } }
DataConfig { public void readFromXml(Element e) { List<Element> n = getChildNodes(e, "document"); if (n.isEmpty()) { throw new DataImportHandlerException(SEVERE, "DataImportHandler " + "configuration file must have one <document> node."); } document = new Document(n.get(0)); n = getChildNodes(e, SCRIPT); if (!n.isEmpty()) { script = new Script(n.get(0)); } n = getChildNodes(e, FUNCTION); if (!n.isEmpty()) { for (Element element : n) { String func = getStringAttribute(element, NAME, null); String clz = getStringAttribute(element, CLASS, null); if (func == null || clz == null){ throw new DataImportHandlerException( SEVERE, "<function> must have a 'name' and 'class' attributes"); } else { functions.add(getAllAttributes(element)); } } } n = getChildNodes(e, DATA_SRC); if (!n.isEmpty()) { for (Element element : n) { Properties p = new Properties(); HashMap<String, String> attrs = getAllAttributes(element); for (Map.Entry<String, String> entry : attrs.entrySet()) { p.setProperty(entry.getKey(), entry.getValue()); } dataSources.put(p.getProperty("name"), p); } } } }
DataConfig { public void readFromXml(Element e) { List<Element> n = getChildNodes(e, "document"); if (n.isEmpty()) { throw new DataImportHandlerException(SEVERE, "DataImportHandler " + "configuration file must have one <document> node."); } document = new Document(n.get(0)); n = getChildNodes(e, SCRIPT); if (!n.isEmpty()) { script = new Script(n.get(0)); } n = getChildNodes(e, FUNCTION); if (!n.isEmpty()) { for (Element element : n) { String func = getStringAttribute(element, NAME, null); String clz = getStringAttribute(element, CLASS, null); if (func == null || clz == null){ throw new DataImportHandlerException( SEVERE, "<function> must have a 'name' and 'class' attributes"); } else { functions.add(getAllAttributes(element)); } } } n = getChildNodes(e, DATA_SRC); if (!n.isEmpty()) { for (Element element : n) { Properties p = new Properties(); HashMap<String, String> attrs = getAllAttributes(element); for (Map.Entry<String, String> entry : attrs.entrySet()) { p.setProperty(entry.getKey(), entry.getValue()); } dataSources.put(p.getProperty("name"), p); } } }  }
DataConfig { public void readFromXml(Element e) { List<Element> n = getChildNodes(e, "document"); if (n.isEmpty()) { throw new DataImportHandlerException(SEVERE, "DataImportHandler " + "configuration file must have one <document> node."); } document = new Document(n.get(0)); n = getChildNodes(e, SCRIPT); if (!n.isEmpty()) { script = new Script(n.get(0)); } n = getChildNodes(e, FUNCTION); if (!n.isEmpty()) { for (Element element : n) { String func = getStringAttribute(element, NAME, null); String clz = getStringAttribute(element, CLASS, null); if (func == null || clz == null){ throw new DataImportHandlerException( SEVERE, "<function> must have a 'name' and 'class' attributes"); } else { functions.add(getAllAttributes(element)); } } } n = getChildNodes(e, DATA_SRC); if (!n.isEmpty()) { for (Element element : n) { Properties p = new Properties(); HashMap<String, String> attrs = getAllAttributes(element); for (Map.Entry<String, String> entry : attrs.entrySet()) { p.setProperty(entry.getKey(), entry.getValue()); } dataSources.put(p.getProperty("name"), p); } } }  void readFromXml(Element e); static String getTxt(Node elem, StringBuilder buffer); static List<Element> getChildNodes(Element e, String byName); void clearCaches(); }
DataConfig { public void readFromXml(Element e) { List<Element> n = getChildNodes(e, "document"); if (n.isEmpty()) { throw new DataImportHandlerException(SEVERE, "DataImportHandler " + "configuration file must have one <document> node."); } document = new Document(n.get(0)); n = getChildNodes(e, SCRIPT); if (!n.isEmpty()) { script = new Script(n.get(0)); } n = getChildNodes(e, FUNCTION); if (!n.isEmpty()) { for (Element element : n) { String func = getStringAttribute(element, NAME, null); String clz = getStringAttribute(element, CLASS, null); if (func == null || clz == null){ throw new DataImportHandlerException( SEVERE, "<function> must have a 'name' and 'class' attributes"); } else { functions.add(getAllAttributes(element)); } } } n = getChildNodes(e, DATA_SRC); if (!n.isEmpty()) { for (Element element : n) { Properties p = new Properties(); HashMap<String, String> attrs = getAllAttributes(element); for (Map.Entry<String, String> entry : attrs.entrySet()) { p.setProperty(entry.getKey(), entry.getValue()); } dataSources.put(p.getProperty("name"), p); } } }  void readFromXml(Element e); static String getTxt(Node elem, StringBuilder buffer); static List<Element> getChildNodes(Element e, String byName); void clearCaches(); public Document document; public List<Map<String, String >> functions; public Script script; public Map<String, Properties> dataSources; public Map<String, SchemaField> lowerNameVsSchemaField; static final String SCRIPT; static final String NAME; static final String PROCESSOR; @Deprecated
  static final String IMPORTER_NS; static final String IMPORTER_NS_SHORT; static final String ROOT_ENTITY; static final String FUNCTION; static final String CLASS; static final String DATA_SRC; }