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

📄 screenflowxmldao.java

📁 J2EE & Tomcat books published by hope
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            for (int innerLoop =0; innerLoop < children.getLength(); innerLoop++) {                Node  child = children.item(innerLoop);                if ((child != null) && (child.getNodeName() != null) && child.getNodeName().equals(PARAMETER) ) {                    if (child instanceof Element) {                        Element childElement = ((Element)child);                        String key = childElement.getAttribute(KEY);                        String value = childElement.getAttribute(VALUE);                        String directString = childElement.getAttribute(DIRECT);                        boolean direct = false;                        if ((directString != null) && directString.equals("true")) {                            direct = true;                        }                        if (!params.containsKey(key)) {                            params.put(key, new Parameter(key, value, direct));                        } else {                            Debug.println("*** Non Fatal errror: " +                                               "Parameter " + key + " is defined more than once");                        }                    }                }            } // end inner loop        }        return params;    }    public static HashMap getExceptionMappings(Element root) {        HashMap exceptionMappings = new HashMap();        NodeList list = root.getElementsByTagName(EXCEPTION_MAPPING);        for (int loop = 0; loop < list.getLength(); loop++) {            Node node = list.item(loop);            if (node != null) {                String exceptionClassName = "";                String screen = null;                // get exception nodes                // need to be a element to get attributes                if (node instanceof Element) {                    Element element = ((Element)node);                    exceptionClassName = element.getAttribute(EXCEPTION_CLASS);       Debug.println("ScreenFlowXmlDAO: adding " + exceptionClassName + " screen=" + screen);                    screen = element.getAttribute(SCREEN);                    exceptionMappings.put(exceptionClassName, screen);                }            }        }        return exceptionMappings;    }    public static HashMap getRequestMappings(Element root) {        HashMap urlMappings = new HashMap();        NodeList list = root.getElementsByTagName(URL_MAPPING);        for (int loop = 0; loop < list.getLength(); loop++) {            Node node = list.item(loop);            if (node != null) {                String url = "";                String screen = null;                String useRequestHandlerString = null;                String useFlowHandlerString = null;                String requiresSigninString = null;                String flowHandler = null;                String requestHandler =null;                HashMap resultMappings = null;                boolean useFlowHandler = false;                boolean useRequestHandler = false;                boolean requiresSignin = false;                // get url mapping attributes                // need to be a element to get attributes                if (node instanceof Element) {                    Element element = ((Element)node);                    url = element.getAttribute(URL);                    screen = element.getAttribute(NEXT_SCREEN);                    useRequestHandlerString = element.getAttribute(USE_REQUEST_HANDLER);                    useFlowHandlerString = element.getAttribute(USE_FLOW_HANDLER);                    requiresSigninString = element.getAttribute(REQUIRES_SIGNIN);                }                if ((useRequestHandlerString != null) && useRequestHandlerString.equals("true")) useRequestHandler = true;                if (useRequestHandler) {                    requestHandler = getSubTagValue(node, REQUEST_HANDLER_CLASS);                }                if ((requiresSigninString != null) && requiresSigninString.equals("true")) requiresSignin = true;                // get request handler                if ((useFlowHandlerString != null) && useFlowHandlerString.equals("true")) useFlowHandler = true;                // get flow handler                if ((useFlowHandlerString != null) && useFlowHandlerString.equals("true")) useFlowHandler = true;                if (useFlowHandler) {                    // need to be a element to find sub nodes by name                    if (node instanceof Element) {                        Element element = (Element)node;                        NodeList children = element.getElementsByTagName(FLOW_HANDLER);                        Node flowHandlerNode = null;                        if (children.getLength() >= 1) {                            flowHandlerNode = children.item(0);                        }                        if (children.getLength() > 1) {                                 Debug.println("Non fatal error: There can be only one <" + FLOW_HANDLER +                                               "> definition in a <" + URL_MAPPING + ">");                        }                        // get the flow handler details                        if (flowHandlerNode != null) {                            if (flowHandlerNode instanceof Element) {                                Element flowElement = (Element)flowHandlerNode;                                flowHandler = flowElement.getAttribute(FLOW_HANDLER_CLASS);                                NodeList results = flowElement.getElementsByTagName(HANDLER_RESULT);                                if (results.getLength() > 0){                                    resultMappings = new HashMap();                                }                                for (int resultLoop=0; resultLoop < results.getLength(); resultLoop++) {                                    Node resultNode = results.item(resultLoop);                                    if (resultNode instanceof Element) {                                        Element resultElement = (Element)resultNode;                                        String key = resultElement.getAttribute(RESULT);                                        String value = resultElement.getAttribute(NEXT_SCREEN);                                        if (!resultMappings.containsKey(key)) {                                            resultMappings.put(key,value);                                            Debug.println("ScreenFlowXmlDao: put maping next screen:" + value);                                        } else {                                            Debug.println("*** Non Fatal errror: Screen " + url + " <" + FLOW_HANDLER +                                                           "> key " + "\"" + key + "\" defined more than one time");                                        }                                    }                                } // end for                            }                        } // end if (flowHandler != null)                    }                } // end if (useFlowHandler)                URLMapping mapping = new URLMapping(url, screen,                                             useRequestHandler,                                             useFlowHandler,                                             requestHandler,                                             flowHandler,                                             resultMappings,                                             requiresSignin);                if (!urlMappings.containsKey(url)) {                    urlMappings.put(url, mapping);                } else {                    Debug.println("*** Non Fatal errror: Screen " + url +                                       " defined more than once in screen definitions file");                }            }        }        return urlMappings;    }    public static String getSubTagValue(Node node, String subTagName) {        String returnString = "";        if (node != null) {            NodeList  children = node.getChildNodes();            for (int innerLoop =0; innerLoop < children.getLength(); innerLoop++) {                Node  child = children.item(innerLoop);                if ((child != null) && (child.getNodeName() != null) && child.getNodeName().equals(subTagName) ) {                    Node grandChild = child.getFirstChild();                    if (grandChild.getNodeValue() != null) return grandChild.getNodeValue();                }            } // end inner loop        }        return returnString;    }    public static String getSubTagValue(Element root, String tagName, String subTagName) {        String returnString = "";        NodeList list = root.getElementsByTagName(tagName);        for (int loop = 0; loop < list.getLength(); loop++) {            Node node = list.item(loop);            if (node != null) {                NodeList  children = node.getChildNodes();                for (int innerLoop =0; innerLoop < children.getLength(); innerLoop++) {                    Node  child = children.item(innerLoop);                    if ((child != null) && (child.getNodeName() != null) && child.getNodeName().equals(subTagName) ) {                        Node grandChild = child.getFirstChild();                        if (grandChild.getNodeValue() != null) return grandChild.getNodeValue();                    }                } // end inner loop            }        }        return returnString;    }    public static String getTagValue(Element root, String tagName) {        String returnString = "";        NodeList list = root.getElementsByTagName(tagName);        for (int loop = 0; loop < list.getLength(); loop++) {            Node node = list.item(loop);            if (node != null) {                Node child = node.getFirstChild();                if ((child != null) && child.getNodeValue() != null) return child.getNodeValue();            }        }        return returnString;    }}

⌨️ 快捷键说明

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