protected void loadHierarchy(final ConfigurationNode parentNode, final Object obj) { final String parentName = parentNode.getName(); if (obj instanceof Map<?, ?>) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) { final Node childNode = new Node(entry.getKey()); // if parent node is look like "tableS", "userS" or "groupS" if (this.xmlCompatibility && parentName != null && parentName.endsWith("s")) { //this is done to have "users.user[@name='smith'] instead of "users.smith" childNode.setName(parentName.substring(0, parentName.length() - 1)); childNode.addAttribute(new Node("name", entry.getKey())); } childNode.setReference(entry); loadHierarchy(childNode, entry.getValue()); parentNode.addChild(childNode); } } else if (obj instanceof Collection) { for (Object child : (Collection) obj) { final Node childNode = new Node("item"); childNode.setReference(child); loadHierarchy(childNode, child); parentNode.addChild(childNode); } } parentNode.setValue(obj); }
protected void loadHierarchy(final ConfigurationNode parentNode, final Object obj) { final String parentName = parentNode.getName(); if (obj instanceof Map<?, ?>) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) { final Node childNode = new Node(entry.getKey()); // if parent node is look like "tableS", "userS" or "groupS" if (this.xmlCompatibility && parentName != null && parentName.endsWith("s")) { //this is done to have "users.user[@name='smith'] instead of "users.smith" childNode.setName(parentName.substring(0, parentName.length() - 1)); childNode.addAttribute(new Node("name", entry.getKey())); } childNode.setReference(entry); loadHierarchy(childNode, entry.getValue()); parentNode.addChild(childNode); } } else if (obj instanceof Collection) { for (Object child : (Collection) obj) { final Node childNode = new Node("item"); childNode.setReference(child); loadHierarchy(childNode, child); parentNode.addChild(childNode); } } parentNode.setValue(obj); }
protected void loadHierarchy(final ConfigurationNode parentNode, final Object obj) { final String parentName = parentNode.getName(); if (obj instanceof Map<?, ?>) { for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) { final Node childNode = new Node(entry.getKey()); // if parent node is look like "tableS", "userS" or "groupS" if (this.xmlCompatibility && parentName != null && parentName.endsWith("s")) { //this is done to have "users.user[@name='smith'] instead of "users.smith" childNode.setName(parentName.substring(0, parentName.length() - 1)); childNode.addAttribute(new Node("name", entry.getKey())); } childNode.setReference(entry); loadHierarchy(childNode, entry.getValue()); parentNode.addChild(childNode); } } else if (obj instanceof Collection) { for (Object child : (Collection) obj) { final Node childNode = new Node("item"); childNode.setReference(child); loadHierarchy(childNode, child); parentNode.addChild(childNode); } } parentNode.setValue(obj); }
final public Node Property() throws ParseException { String key = null; Object value = null; Node node = new Node(); key = String(); node.setName(key); jj_consume_token(EQUAL); value = Element(); node.setValue(value); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DICT_SEPARATOR: jj_consume_token(DICT_SEPARATOR); break; default: jj_la1[1] = jj_gen; ; } {if (true) return node;} throw new Error("Missing return statement in function"); }
final public Node Property() throws ParseException { String key = null; Object value = null; Node node = new Node(); key = String(); node.setName(key); jj_consume_token(EQUAL); value = Element(); node.setValue(value); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DICT_SEPARATOR: jj_consume_token(DICT_SEPARATOR); break; default: jj_la1[1] = jj_gen; ; } {if (true) return node;} throw new Error("Missing return statement in function"); }
/** * Returns the root node of this hierarchical configuration. This method * exists for backwards compatibility only. New code should use the * {@link #getRootNode()} method instead, which operates on * the preferred data type {@code ConfigurationNode}. * * @return the root node */ public Node getRoot() { if (root == null && rootNode != null) { // Dynamically create a snapshot of the root node return new Node(rootNode); } return root; }
/** * Returns the root node of this hierarchical configuration. This method * exists for backwards compatibility only. New code should use the * {@link #getRootNode()} method instead, which operates on * the preferred data type {@code ConfigurationNode}. * * @return the root node */ public Node getRoot() { if (root == null && rootNode != null) { // Dynamically create a snapshot of the root node return new Node(rootNode); } return root; }
/** * Creates a new {@code Node} object with the specified name. This * method can be overloaded in derived classes if a specific node type is * needed. This base implementation always returns a new object of the * {@code Node} class. * * @param name the name of the new node * @return the new node */ protected Node createNode(String name) { return new Node(name); }
/** * Creates a new {@code Node} object with the specified name. This * method can be overloaded in derived classes if a specific node type is * needed. This base implementation always returns a new object of the * {@code Node} class. * * @param name the name of the new node * @return the new node */ protected Node createNode(String name) { return new Node(name); }
/** * Creates a new instance of {@code HierarchicalConfiguration}. */ public HierarchicalConfiguration() { setRootNode(new Node()); }
/** * Returns a new XML node with the given name. * @param name name of the new XML node * @return new XML node with the given name */ public static ConfigurationNode node(String name){ return new HierarchicalConfiguration.Node(name); }
/** * Returns a new XML node with the given name. * @param name name of the new XML node * @return new XML node with the given name */ public static ConfigurationNode node(String name){ return new HierarchicalConfiguration.Node(name); }
/** * Returns a new XML node with the given name and value. * @param name name of the new XML node * @param value value of the new XML node * @return new XML node with the given name and value */ public static ConfigurationNode node(String name, Object value){ return new HierarchicalConfiguration.Node(name, value); } }
/** * Returns a new XML node. * @return new XML node */ public static ConfigurationNode node(){ return new HierarchicalConfiguration.Node(); }
/** * Creates a new instance of {@code HierarchicalConfiguration}. */ public HierarchicalConfiguration() { setRootNode(new Node()); }
/** * Removes all properties from this configuration. If this configuration * was loaded from a file, the associated DOM document is also cleared. */ @Override public void clear() { super.clear(); setRoot(new Node()); document = null; }
/** * Returns a new XML node with the given name and value. * @param name name of the new XML node * @param value value of the new XML node * @return new XML node with the given name and value */ public static ConfigurationNode node(String name, Object value){ return new HierarchicalConfiguration.Node(name, value); } }
/** * Returns a new XML node. * @return new XML node */ public static ConfigurationNode node(){ return new HierarchicalConfiguration.Node(); }
/** * Removes all properties from this configuration. If this configuration * was loaded from a file, the associated DOM document is also cleared. */ @Override public void clear() { super.clear(); setRoot(new Node()); document = null; }
private void setNameSpace(XMLConfiguration conf) { HierarchicalConfiguration.Node root = new HierarchicalConfiguration.Node( "configuration"); root.addAttribute(new HierarchicalConfiguration.Node("xmlns", "http://namespace.com")); conf.setRootNode(root); }