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

📄 conditiondescriptor.java

📁 osworkflow修改版本
💻 JAVA
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.workflow.loader;import com.opensymphony.workflow.InvalidWorkflowDescriptorException;import com.opensymphony.workflow.util.Validatable;import org.w3c.dom.Element;import java.io.PrintWriter;import java.util.*;/** * DOCUMENT ME! * * @author $author$ * @version $Revision: 1.7 $ */public class ConditionDescriptor extends AbstractDescriptor implements Validatable {    //~ Instance fields ////////////////////////////////////////////////////////    protected Map args = new HashMap();    /**     * The name field helps the editor identify the condition template used.     */    protected String name;    protected String type;    protected boolean negate = false;    //~ Constructors ///////////////////////////////////////////////////////////    public ConditionDescriptor() {    }    public ConditionDescriptor(Element function) {        init(function);    }    //~ Methods ////////////////////////////////////////////////////////////////    public Map getArgs() {        return args;    }    public void setName(String name) {        this.name = name;    }    public String getName() {        return name;    }    public void setNegate(boolean negate) {        this.negate = negate;    }    public boolean isNegate() {        return negate;    }    public void setType(String type) {        this.type = type;    }    public String getType() {        return type;    }    public void validate() throws InvalidWorkflowDescriptorException {    }    public void writeXML(PrintWriter out, int indent) {        XMLUtil.printIndent(out, indent++);        out.println("<condition " + (hasId() ? ("id=\"" + getId() + "\" ") : "") + (((name != null) && (name.length() > 0)) ? ("name=\"" + getName() + "\" ") : "") + (negate ? ("negate=\"true\" ") : "") + "type=\"" + type + "\">");        Iterator iter = args.entrySet().iterator();        while (iter.hasNext()) {            Map.Entry entry = (Map.Entry) iter.next();            XMLUtil.printIndent(out, indent);            out.print("<arg name=\"");            out.print(entry.getKey());            out.print("\">");            if ("beanshell".equals(type) || "bsf".equals(type)) {                out.print("<![CDATA[");                out.print(entry.getValue());                out.print("]]>");            } else {                out.print(XMLUtil.encode(entry.getValue()));            }            out.println("</arg>");        }        XMLUtil.printIndent(out, --indent);        out.println("</condition>");    }    protected void init(Element condition) {        type = condition.getAttribute("type");        try {            setId(Integer.parseInt(condition.getAttribute("id")));        } catch (NumberFormatException e) {        }        String n = condition.getAttribute("negate");        if ("true".equalsIgnoreCase(n) || "yes".equalsIgnoreCase(n)) {            negate = true;        } else {            negate = false;        }        if (condition.getAttribute("name") != null) {            name = condition.getAttribute("name");        }        List args = XMLUtil.getChildElements(condition, "arg");        for (int l = 0; l < args.size(); l++) {            Element arg = (Element) args.get(l);            this.args.put(arg.getAttribute("name"), XMLUtil.getText(arg));        }    }}

⌨️ 快捷键说明

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