List of usage examples for org.apache.commons.configuration.tree ConfigurationNode getAttributes
List getAttributes(String name);
From source file:hu.ppke.itk.nlpg.purepos.cli.configuration.ConfigurationReader.java
public Configuration read(File f) throws ConfigurationException { XMLConfiguration xconf = new XMLConfiguration(f); List<ConfigurationNode> tagMappings = xconf.getRootNode().getChildren(TAG_MAPPING); LinkedList<StringMapping> tag_ret = new LinkedList<StringMapping>(); for (ConfigurationNode m : tagMappings) { String spat = (String) m.getAttributes(PATTERN).get(0).getValue(); String stag = (String) m.getAttributes(TAG).get(0).getValue(); tag_ret.add(new StringMapping(spat, stag)); }/*from ww w . j a v a 2 s.c o m*/ List<ConfigurationNode> lemmaMappings = xconf.getRootNode().getChildren(LEMMA_MAPPING); LinkedList<StringMapping> lemma_ret = new LinkedList<StringMapping>(); for (ConfigurationNode m : lemmaMappings) { String spat = (String) m.getAttributes(PATTERN).get(0).getValue(); String stag = (String) m.getAttributes(TAG).get(0).getValue(); lemma_ret.add(new StringMapping(spat, stag)); } List<ConfigurationNode> markers = xconf.getRootNode().getChildren(GUESSED_MARKER); String guessedMarker = ""; if (markers.size() > 0) { guessedMarker = (String) markers.get(0).getValue(); } List<ConfigurationNode> params = xconf.getRootNode().getChildren(SUFFIX_MODEL_PARAMETERS); Double weight = null; if (params.size() > 0) { weight = Double.valueOf((String) params.get(0).getValue()); } return new Configuration(tag_ret, lemma_ret, guessedMarker, weight); }
From source file:club.jmint.crossing.config.AclConfig.java
@Override public Config loadConfig() { super.loadConfig(); XMLConfiguration conf = loadXMLConfigFile(configFilePath); ConfigurationNode root = conf.getRootNode(); List<ConfigurationNode> aclenabled = root.getAttributes("enabled"); isAclEnabled = Boolean.parseBoolean(aclenabled.get(0).getValue().toString()); //System.out.println(aclenabled.get(0).getValue().toString()); //System.out.println(isAclEnabled); List<ConfigurationNode> rulesnode = root.getChildren("rules"); List<ConfigurationNode> rulenode = rulesnode.get(0).getChildren(); ConfigurationNode node;//from w w w. j av a 2 s . co m List<ConfigurationNode> name, enabled; String rname; for (int i = 0; i < rulenode.size(); i++) { node = rulenode.get(i); name = node.getAttributes("name"); enabled = node.getAttributes("enabled"); //System.out.println(name.get(0).getValue().toString()); //System.out.println(enabled.get(0).getValue().toString());; rname = name.get(0).getValue().toString(); ruleMap.put(rname, new AclRule(rname, Boolean.parseBoolean(enabled.get(0).getValue().toString()))); } List<ConfigurationNode> gcsnode = root.getChildren("grantedclient"); List<ConfigurationNode> gcnode = gcsnode.get(0).getChildren(); //ConfigurationNode node; List<ConfigurationNode> ip, desc; String iname; for (int i = 0; i < gcnode.size(); i++) { node = gcnode.get(i); name = node.getAttributes("name"); ip = node.getAttributes("ip"); enabled = node.getAttributes("enabled"); desc = node.getAttributes("desc"); //System.out.println(name.get(0).getValue().toString()); //System.out.println(ip.get(0).getValue().toString()); //System.out.println(access.get(0).getValue().toString()); iname = name.get(0).getValue().toString(); gcipMap.put(iname, new GrantedIPair(iname, ip.get(0).getValue().toString(), Boolean.parseBoolean(enabled.get(0).getValue().toString()), desc.get(0).getValue().toString())); } List<ConfigurationNode> gisnode = root.getChildren("grantedif"); List<ConfigurationNode> ginode = gisnode.get(0).getChildren(); ConfigurationNode clientnode; List<ConfigurationNode> client, value; ArrayList<String> al; for (int i = 0; i < ginode.size(); i++) { node = ginode.get(i); name = node.getAttributes("name"); //System.out.println(node.getName()); //System.out.println(name.get(0).getValue().toString()); al = new ArrayList<String>(); client = node.getChildren(); for (int j = 0; j < client.size(); j++) { clientnode = client.get(j); value = clientnode.getAttributes("value"); //System.out.println(value.get(0).getValue().toString()); al.add(value.get(0).getValue().toString()); } gifMap.put(name.get(0).getValue().toString(), al); //System.out.println(gifMap.get(name.get(0).getValue().toString()).get(0)); } return this; }
From source file:club.jmint.crossing.config.CrossingConfig.java
@Override public Config loadConfig() { super.loadConfig(); XMLConfiguration conf = loadXMLConfigFile(configFilePath); ConfigurationNode root = conf.getRootNode(); List<ConfigurationNode> ptypesnode = root.getChildren("providertypes"); List<ConfigurationNode> typenode = ptypesnode.get(0).getChildren(); ConfigurationNode node; List<ConfigurationNode> name, enabled, clazz; for (int i = 0; i < typenode.size(); i++) { node = typenode.get(i);/* w ww . j a v a 2s . c o m*/ name = node.getAttributes("name"); enabled = node.getAttributes("enabled"); clazz = node.getAttributes("class"); //System.out.println(name.get(0).getValue()); //System.out.println(enabled.get(0).getValue()); ptypesMap.put(name.get(0).getValue().toString(), new ProviderPair(name.get(0).getValue().toString(), Boolean.parseBoolean(enabled.get(0).getValue().toString()), clazz.get(0).getValue().toString())); } List<ConfigurationNode> srvsnode = root.getChildren("servers"); List<ConfigurationNode> srvnode = srvsnode.get(0).getChildren(); //ConfigurationNode node; List<ConfigurationNode> type, iplist, port, mp; for (int i = 0; i < srvnode.size(); i++) { node = srvnode.get(i); name = node.getAttributes("name"); type = node.getAttributes("type"); mp = node.getAttributes("methodProxy"); iplist = node.getAttributes("ip"); port = node.getAttributes("port"); serversMap.put(name.get(0).getValue().toString(), new ServerPair(name.get(0).getValue().toString(), type.get(0).getValue().toString(), mp.get(0).getValue().toString(), iplist.get(0).getValue().toString(), Integer.parseInt(port.get(0).getValue().toString()))); } List<ConfigurationNode> infsnode = root.getChildren("interfaces"); List<ConfigurationNode> infnode = infsnode.get(0).getChildren(); ConfigurationNode servernode; List<ConfigurationNode> sname, intf, iname, encrypt; ArrayList<InfPair> al; for (int i = 0; i < infnode.size(); i++) { node = infnode.get(i); sname = node.getAttributes("name"); al = new ArrayList<InfPair>(); intf = node.getChildren(); for (int j = 0; j < intf.size(); j++) { servernode = intf.get(j); iname = servernode.getAttributes("name"); encrypt = servernode.getAttributes("isEncrypt"); al.add(new InfPair(iname.get(0).getValue().toString(), Boolean.parseBoolean(encrypt.get(0).getValue().toString()))); } infsMap.put(sname.get(0).getValue().toString(), al); } return this; }
From source file:org.apache.tinkerpop.gremlin.util.config.YamlConfiguration.java
protected Object saveHierarchy(final ConfigurationNode parentNode) { if (parentNode.getChildrenCount() == 0) return parentNode.getValue(); if (parentNode.getChildrenCount("item") == parentNode.getChildrenCount()) { return parentNode.getChildren().stream().map(this::saveHierarchy).collect(Collectors.toList()); } else {//from w w w. j av a 2 s . c o m final Map<String, Object> map = new LinkedHashMap<>(); for (ConfigurationNode childNode : parentNode.getChildren()) { String nodeName = childNode.getName(); if (this.xmlCompatibility && childNode.getAttributes("name").size() > 0) nodeName = String.valueOf(childNode.getAttributes("name").get(0).getValue()); map.put(nodeName, saveHierarchy(childNode)); } return map; } }