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

📄 invalidinputexception.java

📁 一个很好实用的工作流OSWORKFLOW开发例子.有着非常优秀的灵活性.
💻 JAVA
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.workflow;import java.util.*;/** * Exception to indicate the user input is invalid. Handles both general errors and errors specific to an input. * * @author <a href="mailto:plightbo@hotmail.com">Patrick Lightbody</a> * @version $Revision: 1.2 $ */public class InvalidInputException extends WorkflowException {    //~ Instance fields ////////////////////////////////////////////////////////    private List genericErrors = new ArrayList();    private Map errors = new HashMap();    //~ Constructors ///////////////////////////////////////////////////////////    public InvalidInputException() {        super();    }    /**     * Creates a new exception using the supplied Object     * as a generic base. If the object is an instance of     * this exception, all properties are copied to this     * exception. If the object is an instance of Map or     * String[], an errorName->errorMessage mapping will     * be attempted to be extracted. If the object is     * something else, it's toString() method will be     * called and added as a single generic error.     *     * @param o the object     */    public InvalidInputException(Object o) {        if (o instanceof InvalidInputException) {            InvalidInputException iie = (InvalidInputException) o;            errors = iie.errors;            genericErrors = iie.genericErrors;        } else if (o instanceof Map) {            errors = (Map) o;        } else if (o instanceof String[]) {            String[] stringMap = (String[]) o;            int length = stringMap.length;            String name = null;            for (int i = 0; i < length; i++) {                if ((i % 2) == 0) {                    name = stringMap[i];                } else {                    addError(name, stringMap[i]);                }            }        } else {            addError(o.toString());        }    }    /**     * Creates a new exception with an associated generic error.     *     * @param error a generic error message     */    public InvalidInputException(String error) {        super(error);        addError(error);    }    /**     * Creates a new exception with an error specific to an input.     *     * @param name the input name that contains the error     * @param error an error about the given name     */    public InvalidInputException(String name, String error) {        super();        addError(name, error);    }    //~ Methods ////////////////////////////////////////////////////////////////    /**     * Returns a map (String->String) of the input-specific errors.     *     * @return a map (String->String) of the input-specific errors     */    public Map getErrors() {        return errors;    }    /**     * Returns a list (String) of generic errors.     *     * @return A list (String) of generic errors     */    public List getGenericErrors() {        return genericErrors;    }    /**     * Adds a generic error.     *     * @param error the generic error message     */    public void addError(String error) {        genericErrors.add(error);    }    /**     * Adds an input-specific error.     *     * @param name the name of the input     * @param error the error message     */    public void addError(String name, String error) {        errors.put(name, error);    }    public String toString() {        return "[InvalidInputException: [Error map: [" + errors + "]] [Error list: [" + genericErrors + "]]";    }}

⌨️ 快捷键说明

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