protected void init(Element restriction) { List conditionNodes = XMLUtil.getChildElements(restriction, "conditions"); int length = conditionNodes.size(); for (int i = 0; i < length; ++i) { Element condition = (Element) conditionNodes.get(i); ConditionsDescriptor conditionDescriptor = DescriptorFactory.getFactory().createConditionsDescriptor(condition); conditionDescriptor.setParent(this); this.conditions.add(conditionDescriptor); } }
public void writeXML(PrintWriter out, int indent) { ConditionsDescriptor conditions = getConditionsDescriptor(); List list = conditions.getConditions(); if (list.size() == 0) { return; } XMLUtil.printIndent(out, indent++); out.println("<restrict-to>"); conditions.writeXML(out, indent); XMLUtil.printIndent(out, --indent); out.println("</restrict-to>"); }
protected void init(Element root) { NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeName().equals("meta")) { Element meta = (Element) child; String value = XMLUtil.getText(meta); this.metaAttributes.put(meta.getAttribute("name"), value); } } // handle registers - OPTIONAL Element r = XMLUtil.getChildElement(root, "registers"); if (r != null) { List registers = XMLUtil.getChildElements(r, "register"); for (int i = 0; i < registers.size(); i++) { Element register = (Element) registers.get(i); RegisterDescriptor registerDescriptor = DescriptorFactory.getFactory().createRegisterDescriptor(register); registerDescriptor.setParent(this); this.registers.add(registerDescriptor); } } // handle global-conditions - OPTIONAL Element globalConditionsElement = XMLUtil.getChildElement(root, "global-conditions"); if (globalConditionsElement != null) { Element globalConditions = XMLUtil.getChildElement(globalConditionsElement, "conditions"); ConditionsDescriptor conditionsDescriptor = DescriptorFactory.getFactory().createConditionsDescriptor(globalConditions); conditionsDescriptor.setParent(this); this.globalConditions = conditionsDescriptor; } // handle initial-steps - REQUIRED Element intialActionsElement = XMLUtil.getChildElement(root, "initial-actions"); List initialActions = XMLUtil.getChildElements(intialActionsElement, "action"); for (int i = 0; i < initialActions.size(); i++) { Element initialAction = (Element) initialActions.get(i); ActionDescriptor actionDescriptor = DescriptorFactory.getFactory().createActionDescriptor(initialAction); actionDescriptor.setParent(this); this.initialActions.add(actionDescriptor); } // handle global-actions - OPTIONAL Element globalActionsElement = XMLUtil.getChildElement(root, "global-actions"); if (globalActionsElement != null) { List globalActions = XMLUtil.getChildElements(globalActionsElement, "action"); for (int i = 0; i < globalActions.size(); i++) { Element globalAction = (Element) globalActions.get(i); ActionDescriptor actionDescriptor = DescriptorFactory.getFactory().createActionDescriptor(globalAction); actionDescriptor.setParent(this); this.globalActions.add(actionDescriptor); } } // handle common-actions - OPTIONAL // - Store actions in HashMap for now. When parsing Steps, we'll resolve // any common actions into local references. Element commonActionsElement = XMLUtil.getChildElement(root, "common-actions"); if (commonActionsElement != null) { List commonActions = XMLUtil.getChildElements(commonActionsElement, "action"); for (int i = 0; i < commonActions.size(); i++) { Element commonAction = (Element) commonActions.get(i); ActionDescriptor actionDescriptor = DescriptorFactory.getFactory().createActionDescriptor(commonAction); actionDescriptor.setParent(this); addCommonAction(actionDescriptor); } } // handle timer-functions - OPTIONAL Element timerFunctionsElement = XMLUtil.getChildElement(root, "trigger-functions"); if (timerFunctionsElement != null) { List timerFunctions = XMLUtil.getChildElements(timerFunctionsElement, "trigger-function"); for (int i = 0; i < timerFunctions.size(); i++) { Element timerFunction = (Element) timerFunctions.get(i); Integer id = new Integer(timerFunction.getAttribute("id")); FunctionDescriptor function = DescriptorFactory.getFactory() .createFunctionDescriptor(XMLUtil.getChildElement(timerFunction, "function")); function.setParent(this); this.timerFunctions.put(id, function); } } // handle steps - REQUIRED Element stepsElement = XMLUtil.getChildElement(root, "steps"); List steps = XMLUtil.getChildElements(stepsElement, "step"); for (int i = 0; i < steps.size(); i++) { Element step = (Element) steps.get(i); StepDescriptor stepDescriptor = DescriptorFactory.getFactory().createStepDescriptor(step, this); this.steps.add(stepDescriptor); } // handle splits - OPTIONAL Element splitsElement = XMLUtil.getChildElement(root, "splits"); if (splitsElement != null) { List split = XMLUtil.getChildElements(splitsElement, "split"); for (int i = 0; i < split.size(); i++) { Element s = (Element) split.get(i); SplitDescriptor splitDescriptor = DescriptorFactory.getFactory().createSplitDescriptor(s); splitDescriptor.setParent(this); this.splits.add(splitDescriptor); } } // handle joins - OPTIONAL: Element joinsElement = XMLUtil.getChildElement(root, "joins"); if (joinsElement != null) { List join = XMLUtil.getChildElements(joinsElement, "join"); for (int i = 0; i < join.size(); i++) { Element s = (Element) join.get(i); JoinDescriptor joinDescriptor = DescriptorFactory.getFactory().createJoinDescriptor(s); joinDescriptor.setParent(this); this.joins.add(joinDescriptor); } } }