📄 staxiterateactionfactory.java
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2002 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************/package com.ibm.staf.service.stax;import org.w3c.dom.Node;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.NodeList;public class STAXIterateActionFactory implements STAXActionFactory{ private static String fDTDInfo ="\n" +"<!--================= The Iterate Element ========================= -->\n" +"<!--\n" +" The iterate element iterates through a list of items, performing\n" +" its contained task while substituting each item in the list.\n" +" The iterated tasks are performed in sequence.\n" +"-->\n" +"<!ELEMENT iterate (%task;)>\n" +"<!-- var is the name of the variable which will contain the\n" + " current item in the list or tuple being iterated.\n" + " It is a literal.\n" +" in is the list or tuple to be iterated. It is evaluated\n" +" via Python and must evaluate to be a list or tuple.\n" + " indexvar is the name of a variable which will contain the index of\n" +" the current item in the list or tuple being iterated.\n" +" It is a literal. The value for the first index is 0.\n" +"-->\n" +"<!ATTLIST iterate\n" +" var CDATA #REQUIRED\n" +" in CDATA #REQUIRED\n" +" indexvar CDATA #IMPLIED\n" +">\n"; public String getDTDInfo() { return fDTDInfo; } public String getDTDTaskName() { return "iterate"; } public STAXAction parseAction(STAX staxService, STAXJob job, org.w3c.dom.Node root) throws STAXException { String itemvar = new String(); String in = new String(); String indexvar = new String(); STAXAction iterateAction = null; NamedNodeMap attrs = root.getAttributes(); for (int i = 0; i < attrs.getLength(); ++i) { Node thisAttr = attrs.item(i); String errorInfo = "\n Element: " + root.getNodeName() + " Attribute: " + thisAttr.getNodeName(); if (thisAttr.getNodeName().equals("var")) { itemvar = thisAttr.getNodeValue(); } else if (thisAttr.getNodeName().equals("in")) { in = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); } else if (thisAttr.getNodeName().equals("indexvar")) { indexvar = thisAttr.getNodeValue(); } else { throw new STAXInvalidXMLAttributeException( root.getNodeName() + ": " + thisAttr.getNodeName()); } } NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node thisChild = children.item(i); if (thisChild.getNodeType() == Node.COMMENT_NODE) { /* Do nothing */ } else if (thisChild.getNodeType() == Node.ELEMENT_NODE) { if (iterateAction != null) { throw new STAXInvalidXMLElementCountException( thisChild.getNodeName()); } STAXActionFactory factory = staxService.getActionFactory(thisChild.getNodeName()); if (factory == null) { throw new STAXInvalidXMLElementException( thisChild.getNodeName()); } iterateAction = factory.parseAction(staxService, job, thisChild); } else { throw new STAXInvalidXMLNodeTypeException( Integer.toString(thisChild.getNodeType())); } } return new STAXIterateAction(itemvar, in, indexvar, iterateAction); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -