for (int i = 0; i < globalActions.getLength(); i++) { Element globalAction = (Element) globalActions.item(i);
for (int i = 0; i < globalActions.size(); i++) { Element globalAction = (Element) globalActions.get(i);
    protected void init(Element root) {        NodeList children = root.getChildNodes();        for (int i = 0; i < children.getLength(); i++) {            Node child = (Node) 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) {            NodeList registers = r.getElementsByTagName("register");            for (int i = 0; i < registers.getLength(); i++) {                Element register = (Element) registers.item(i);                RegisterDescriptor registerDescriptor = new RegisterDescriptor(register);                registerDescriptor.setParent(this);                this.registers.add(registerDescriptor);            }        }        // handle initial-steps - REQUIRED        Element intialActionsElement = XMLUtil.getChildElement(root, "initial-actions");        NodeList initialActions = intialActionsElement.getElementsByTagName("action");        for (int i = 0; i < initialActions.getLength(); i++) {            Element initialAction = (Element) initialActions.item(i);            ActionDescriptor actionDescriptor = new ActionDescriptor(initialAction);            actionDescriptor.setParent(this);            this.initialActions.add(actionDescriptor);        }        // handle global-actions - OPTIONAL        Element globalActionsElement = XMLUtil.getChildElement(root, "global-actions");        if (globalActionsElement != null) {            NodeList globalActions = globalActionsElement.getElementsByTagName("action");            for (int i = 0; i < globalActions.getLength(); i++) {                Element globalAction = (Element) globalActions.item(i);                ActionDescriptor actionDescriptor = new ActionDescriptor(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) {            NodeList commonActions = commonActionsElement.getElementsByTagName("action");            for (int i = 0; i < commonActions.getLength(); i++) {                Element commonAction = (Element) commonActions.item(i);                ActionDescriptor actionDescriptor = new ActionDescriptor(commonAction);                actionDescriptor.setParent(this);                addCommonAction(actionDescriptor);            }        }        // handle timer-functions - OPTIONAL        Element timerFunctionsElement = XMLUtil.getChildElement(root, "trigger-functions");        if (timerFunctionsElement != null) {            NodeList timerFunctions = timerFunctionsElement.getElementsByTagName("trigger-function");            for (int i = 0; i < timerFunctions.getLength(); i++) {                Element timerFunction = (Element) timerFunctions.item(i);                Integer id = new Integer(timerFunction.getAttribute("id"));                FunctionDescriptor function = new FunctionDescriptor((Element) timerFunction.getElementsByTagName("function").item(0));                function.setParent(this);                this.timerFunctions.put(id, function);            }        }        // handle steps - REQUIRED        Element stepsElement = XMLUtil.getChildElement(root, "steps");        NodeList steps = stepsElement.getElementsByTagName("step");        for (int i = 0; i < steps.getLength(); i++) {            Element step = (Element) steps.item(i);            StepDescriptor stepDescriptor = new StepDescriptor(step, this);            this.steps.add(stepDescriptor);        }        // handle splits - OPTIONAL        Element splitsElement = XMLUtil.getChildElement(root, "splits");        if (splitsElement != null) {            NodeList split = splitsElement.getElementsByTagName("split");            for (int i = 0; i < split.getLength(); i++) {                Element s = (Element) split.item(i);                SplitDescriptor splitDescriptor = new SplitDescriptor(s);                splitDescriptor.setParent(this);                this.splits.add(splitDescriptor);            }        }        // handle joins - OPTIONAL:        Element joinsElement = XMLUtil.getChildElement(root, "joins");        if (joinsElement != null) {            NodeList join = joinsElement.getElementsByTagName("join");            for (int i = 0; i < join.getLength(); i++) {                Element s = (Element) join.item(i);                JoinDescriptor joinDescriptor = new JoinDescriptor(s);                joinDescriptor.setParent(this);                this.joins.add(joinDescriptor);            }        }    }