List of usage examples for org.jdom2 Element getChild
public Element getChild(final String cname)
From source file:TrainNet.java
License:Apache License
public void adjustBias(Element node) throws JDOMException { //adjusted bias = current bias + LEARNING_RATE * errorGradient int lock = java.lang.Integer .parseInt(node.getParentElement().getParentElement().getAttributeValue("ADJUST_LOCK")); Element currentSynapse = (Element) node.getChild("SYNAPSE"); String OrgNodeID = currentSynapse.getAttributeValue("ORG_NEURODE"); if (!"INPUT".equals(OrgNodeID) && lock != 1) { double bias = java.lang.Double.parseDouble(node.getAttributeValue("BIAS")) + (learningRate * java.lang.Double.parseDouble(node.getAttributeValue("NNET_V4"))); //original ver node.setAttribute("BIAS", String.valueOf(bias)); }/* w w w. j a v a2 s. com*/ }
From source file:adruinoSignal.tools.ConfigParser.java
public Level getLogLevel() { Element root = doc.getRootElement(); return Level.parse(root.getChild("logger").getAttributeValue("level")); }
From source file:adruinoSignal.tools.ConfigParser.java
public String getLogPath() { Element root = doc.getRootElement(); return root.getChild("logger").getAttributeValue("file"); }
From source file:adruinoSignal.tools.ConfigParser.java
public String getHost() { Element root = doc.getRootElement(); return root.getChild("socket").getAttributeValue("host"); }
From source file:adruinoSignal.tools.ConfigParser.java
public int getTcpPort() { Element root = doc.getRootElement(); return Integer.parseInt(root.getChild("socket").getAttributeValue("port")); }
From source file:adruinoSignal.tools.ConfigParser.java
public String getSerialPort() { Element root = doc.getRootElement(); return root.getChild("serial").getAttributeValue("port"); }
From source file:adruinoSignal.tools.ConfigParser.java
public int getBaud() { Element root = doc.getRootElement(); return Integer.parseInt(root.getChild("serial").getAttributeValue("baud")); }
From source file:adruinoSignal.tools.ConfigParser.java
public Matcher getMatcher() { Element root = doc.getRootElement(); Element matcherEle = root.getChild("serial").getChild("matcher"); String start = matcherEle.getAttributeValue("start"); String divider = matcherEle.getAttributeValue("divider"); Matcher matcher = new Matcher(start, divider); return matcher; }
From source file:app.simulation.Importer.java
License:MIT License
public void importXML() throws Exception { File file = new File(path); if (!file.exists()) throw new FileNotFoundException(path); if (!getFileFormat().equalsIgnoreCase("xml")) throw new InvalidFileFormatException(getFileFormat()); SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(file); Element root = document.getRootElement(); Element configuration = root.getChild("configuration"); if (configuration != null) { String delayText = configuration.getChildText("delay"); if (delayText == null) throw new AttributeNotFoundException("delay"); String iterationsText = configuration.getChildText("iterations"); if (iterationsText == null) throw new AttributeNotFoundException("iterations"); String agentsText = configuration.getChildText("agents"); if (agentsText == null) throw new AttributeNotFoundException("agents"); String latticeSizeText = configuration.getChildText("latticeSize"); if (latticeSizeText == null) throw new AttributeNotFoundException("latticeSize"); String descriptionText = configuration.getChildText("description"); if (descriptionText == null) throw new AttributeNotFoundException("description"); int delay = Integer.parseInt(delayText); int iterations = Integer.parseInt(iterationsText); int agents = Integer.parseInt(agentsText); int latticeSize = Integer.parseInt(latticeSizeText); this.configuration = new Configuration(delay, iterations, agents, latticeSize, descriptionText); }//from w ww . ja v a2 s.c o m Element initialCell = root.getChild("initialCell"); if (initialCell != null) { String xText = initialCell.getChildText("x"); if (xText == null) throw new AttributeNotFoundException("x"); String yText = initialCell.getChildText("y"); if (yText == null) throw new AttributeNotFoundException("y"); String zText = initialCell.getChildText("z"); if (zText == null) throw new AttributeNotFoundException("z"); String stateText = initialCell.getChildText("state"); if (stateText == null) throw new AttributeNotFoundException("state"); Element colorElement = initialCell.getChild("color"); if (colorElement == null) throw new AttributeNotFoundException("color"); String rText = colorElement.getChildText("r"); if (rText == null) throw new AttributeNotFoundException("r"); String gText = colorElement.getChildText("g"); if (gText == null) throw new AttributeNotFoundException("g"); String bText = colorElement.getChildText("b"); if (bText == null) throw new AttributeNotFoundException("b"); int x = Integer.parseInt(xText); int y = Integer.parseInt(yText); int z = Integer.parseInt(zText); int state = Integer.parseInt(stateText); Color color = new Color(Integer.parseInt(rText), Integer.parseInt(gText), Integer.parseInt(bText)); this.initialCell = new Cell(x, y, z, state, color); } Element tagRules = root.getChild("rules"); rules = new ArrayList<Rule>(); if (tagRules != null) { List<Element> elementRules = tagRules.getChildren("rule"); if (elementRules.size() > 0) { for (Element rule : elementRules) { String neighbourhood = rule.getChildText("neighbourhood"); if (neighbourhood == null) throw new AttributeNotFoundException("neighbourhood"); String stateText = rule.getChildText("state"); if (stateText == null) throw new AttributeNotFoundException("state"); Element colorElement = rule.getChild("color"); if (colorElement == null) throw new AttributeNotFoundException("color"); String rText = colorElement.getChildText("r"); if (rText == null) throw new AttributeNotFoundException("r"); String gText = colorElement.getChildText("g"); if (gText == null) throw new AttributeNotFoundException("g"); String bText = colorElement.getChildText("b"); if (bText == null) throw new AttributeNotFoundException("b"); int state = Integer.parseInt(stateText); Color color = new Color(Integer.parseInt(rText), Integer.parseInt(gText), Integer.parseInt(bText)); rules.add(new Rule(neighbourhood, state, color)); } } } }
From source file:appmain.AppMain.java
private String processTransactionElement(Element e) { StringBuilder result = new StringBuilder(); fields.stream().forEach(field -> result.append(";") .append(field.getConverter().convertElement(e.getChild(field.getTagName())))); return result.substring(1); }