1 17 18 21 package org.quartz.xml; 22 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.Collections ; 26 import java.util.Iterator ; 27 28 33 public class ValidationException extends Exception { 34 41 42 private Collection validationExceptions = new ArrayList (); 43 44 51 52 55 public ValidationException() { 56 super(); 57 } 58 59 65 public ValidationException(String message) { 66 super(message); 67 } 68 69 75 public ValidationException(Collection errors) { 76 this(); 77 this.validationExceptions = Collections 78 .unmodifiableCollection(validationExceptions); 79 } 80 81 88 89 94 public Collection getValidationExceptions() { 95 return validationExceptions; 96 } 97 98 103 public String getMessage() { 104 if (getValidationExceptions().size() == 0) { return super.getMessage(); } 105 106 StringBuffer sb = new StringBuffer (); 107 108 boolean first = true; 109 110 for (Iterator iter = getValidationExceptions().iterator(); iter 111 .hasNext(); ) { 112 Exception e = (Exception ) iter.next(); 113 114 if (!first) { 115 sb.append('\n'); 116 first = false; 117 } 118 119 sb.append(e.getMessage()); 120 } 121 122 return sb.toString(); 123 } 124 } 125 | Popular Tags |