⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staximportactionfactory.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 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 STAXImportActionFactory implements STAXActionFactory{    private static String fDTDInfo ="\n" +"<!--================= The Import Element ========================== -->\n" +"<!--\n" +"     Allows importing of functions from another STAX XML job file.\n" +"-->\n" +"<!ELEMENT import        (import-include?, import-exclude?)?>\n" +"<!ATTLIST import\n" +"          machine     CDATA       #REQUIRED\n" +"          file        CDATA       #REQUIRED\n" +"          mode        CDATA         \"'error'\"\n" +">\n" + "<!ELEMENT import-include          (#PCDATA)>\n" +"<!ELEMENT import-exclude          (#PCDATA)>\n" +"\n";    public String getDTDInfo()    {        return fDTDInfo;    }    public String getDTDTaskName()    {        return "import";    }    public STAXAction parseAction(STAX staxService, STAXJob job,                                  org.w3c.dom.Node root) throws STAXException    {        STAXImportAction staxImport = new STAXImportAction();                    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("machine"))            {                staxImport.setMachine(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("file"))            {                staxImport.setFile(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("mode"))            {                staxImport.setMode(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            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 (thisChild.getNodeName().equals("import-include"))                {                    staxImport.setImportInclude(handleChild(thisChild));                }                else if (thisChild.getNodeName().equals("import-exclude"))                {                    staxImport.setImportExclude(handleChild(thisChild));                }            }            else            {                throw new STAXInvalidXMLNodeTypeException(                    Integer.toString(thisChild.getNodeType()));            }        }        return staxImport;    }        private String handleChild(Node root) throws STAXException    {        NamedNodeMap attrs = root.getAttributes();        for (int i = 0; i < attrs.getLength(); ++i)        {            Node thisAttr = attrs.item(i);            throw new STAXInvalidXMLAttributeException(                root.getNodeName() + ": " + thisAttr.getNodeName());        }        String errorInfo = "\n  Element: " + root.getNodeName();        NodeList children = root.getChildNodes();        for (int i = 0; i < children.getLength(); ++i)        {            Node thisChild = children.item(i);            // XXX: Should I be able to have a COMMENT_NODE here?            if (thisChild.getNodeType() == Node.COMMENT_NODE)            {                /* Do nothing */            }            else if (thisChild.getNodeType() == Node.TEXT_NODE)            {                return STAXUtil.parseAndCompileForPython(                    thisChild.getNodeValue(), errorInfo);            }            else if (thisChild.getNodeType() == Node.CDATA_SECTION_NODE)            {                /* Do nothing */            }            else            {                throw new STAXInvalidXMLNodeTypeException(                          Integer.toString(thisChild.getNodeType()));            }        }        return new String();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -