1 5 package com.opensymphony.workflow; 6 7 import java.util.*; 8 9 10 16 public class InvalidInputException extends WorkflowException { 17 19 private List genericErrors = new ArrayList(); 20 private Map errors = new HashMap(); 21 22 24 public InvalidInputException() { 25 super(); 26 } 27 28 40 public InvalidInputException(Object o) { 41 if (o instanceof InvalidInputException) { 42 InvalidInputException iie = (InvalidInputException) o; 43 errors = iie.errors; 44 genericErrors = iie.genericErrors; 45 } else if (o instanceof Map) { 46 errors = (Map) o; 47 } else if (o instanceof String []) { 48 String [] stringMap = (String []) o; 49 int length = stringMap.length; 50 String name = null; 51 52 for (int i = 0; i < length; i++) { 53 if ((i % 2) == 0) { 54 name = stringMap[i]; 55 } else { 56 addError(name, stringMap[i]); 57 } 58 } 59 } else { 60 addError(o.toString()); 61 } 62 } 63 64 69 public InvalidInputException(String error) { 70 super(error); 71 addError(error); 72 } 73 74 80 public InvalidInputException(String name, String error) { 81 super(); 82 addError(name, error); 83 } 84 85 87 92 public Map getErrors() { 93 return errors; 94 } 95 96 101 public List getGenericErrors() { 102 return genericErrors; 103 } 104 105 110 public void addError(String error) { 111 genericErrors.add(error); 112 } 113 114 120 public void addError(String name, String error) { 121 errors.put(name, error); 122 } 123 124 public String toString() { 125 return "[InvalidInputException: [Error map: [" + errors + "]] [Error list: [" + genericErrors + "]]"; 126 } 127 } 128 | Popular Tags |