/** * Implements IterationStrategyNode */ protected final synchronized void addChild( AbstractIterationStrategyNode newChild) { newChild.setParent(this); }
/** * Configure from an XML element * * @param strategyElement */ protected void configureFromXML(Element strategyElement) { inputs.clear(); terminal.clear(); if (strategyElement.getChildren().isEmpty() == false) { nodeForElement((Element) strategyElement.getChildren().get(0)) .setParent(terminal); } }
/** * Configure from an XML element * * @param strategyElement */ @SuppressWarnings("unchecked") protected void configureFromXML(Element strategyElement) { inputs.clear(); terminal.clear(); if (!strategyElement.getChildren().isEmpty()) { for (Element childElement : (List<Element>) strategyElement .getChildren()) { AbstractIterationStrategyNode node = nodeForElement(childElement); node.setParent(terminal); } } }
/** * Configure from an XML element * * @param strategyElement */ @SuppressWarnings("unchecked") protected void configureFromXML(Element strategyElement) { inputs.clear(); terminal.clear(); if (!strategyElement.getChildren().isEmpty()) { for (Element childElement : (List<Element>) strategyElement .getChildren()) { AbstractIterationStrategyNode node = nodeForElement(childElement); node.setParent(terminal); } } }
private static AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); addInput((NamedInputPortNode) node); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); addInput((NamedInputPortNode) node); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, IterationStrategyNode parent, Processor t2Processor) { if (node instanceof LeafNode) { String nodeName = (String) ((LeafNode) node).getUserObject(); for (InputPort ip : t2Processor.getInputPorts()) { if (ip.getName().equals(nodeName)) { NamedInputPortNode inputPortNode = new NamedInputPortNode( nodeName, ip.getDepth()); inputPortNode.setParent(parent); t2IterationStrategy.addInput(inputPortNode); break; } } } else { AbstractIterationStrategyNode strategyNode = null; if (node instanceof DotNode) { strategyNode = new DotProduct(); } else { strategyNode = new CrossProduct(); } strategyNode.setParent(parent); for (Enumeration<?> en = node.children(); en.hasMoreElements();) { addIterationNode((MutableTreeNode) en.nextElement(), t2IterationStrategy, strategyNode, t2Processor); } } }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, AbstractIterationStrategyNode parent, Processor t2Processor) { if (node instanceof LeafNode) { String nodeName = (String) ((LeafNode) node).getUserObject(); for (InputPort ip : t2Processor.getInputPorts()) { if (ip.getName().equals(nodeName)) { NamedInputPortNode inputPortNode = new NamedInputPortNode( nodeName, ip.getDepth()); inputPortNode.setParent(parent); t2IterationStrategy.addInput(inputPortNode); break; } } } else { AbstractIterationStrategyNode strategyNode = null; if (node instanceof DotNode) { strategyNode = new DotProduct(); } else { strategyNode = new CrossProduct(); } strategyNode.setParent(parent); for (Enumeration<?> en = node.children(); en.hasMoreElements();) { addIterationNode((MutableTreeNode) en.nextElement(), t2IterationStrategy, strategyNode, t2Processor); } } }