1 23 24 29 30 package com.sun.jdo.api.persistence.support; 31 32 37 public class JDOException extends java.lang.RuntimeException { 38 39 42 Exception nested; 43 44 50 transient Object [] failed; 51 52 55 public JDOException() { 56 } 57 58 59 63 public JDOException(String msg) { 64 super(msg); 65 } 66 67 72 public JDOException(String msg, Exception nested) { 73 super(msg); 74 this.nested = nested; 75 } 76 77 82 public JDOException(String msg, Object [] failed) { 83 super(msg); 84 this.failed = failed; 85 } 86 87 93 public JDOException(String msg, Exception nested, Object [] failed) { 94 super(msg); 95 this.nested = nested; 96 this.failed = failed; 97 } 98 99 102 public void addFailedObject(Object o) { 103 if (failed == null) 104 failed = new Object [] {o}; 106 else { 107 int len = failed.length; 109 Object [] ofailed = failed; 110 failed = new Object [len + 1]; 111 for (int i = 0; i < len; i++) 112 failed[i] = ofailed[i]; 113 114 failed[len] = o; 115 } 116 } 117 118 121 public Object [] getFailedObjectArray() { 122 return failed; 123 } 124 125 128 public Exception getNestedException() { 129 return nested; 130 } 131 132 138 public String toString() { 139 int len = 0; 140 if (failed != null) { 141 len = failed.length; 142 } 143 StringBuffer sb = new StringBuffer (100 + 10 * len); 145 sb.append (super.toString()); 146 if (nested != null) { 148 sb.append ("\nNestedException: "); sb.append (nested.toString()); 150 } 151 if (len > 0) { 153 sb.append ("\nFailedObjectArray: ["); Object ofail = failed[0]; 155 sb.append (JDOHelper.printObject(ofail)); 156 for (int i=1; i<len; ++i) { 157 sb.append (", "); ofail = failed[i]; 159 sb.append (JDOHelper.printObject(ofail)); 160 } 161 sb.append ("]"); } 163 return sb.toString(); 164 } 165 166 171 public void printStackTrace() { 172 printStackTrace(System.err); 173 } 174 175 181 public void printStackTrace(java.io.PrintStream s) { 182 synchronized (s) { 183 super.printStackTrace(s); 184 if (nested != null) { 185 s.println("\nNestedStackTrace: "); nested.printStackTrace(s); 187 } 188 } 189 } 190 191 197 public void printStackTrace(java.io.PrintWriter s) { 198 synchronized (s) { 199 super.printStackTrace(s); 200 if (nested != null) { 201 s.println("\nNestedStackTrace: "); nested.printStackTrace(s); 203 } 204 } 205 } 206 207 } 208 209 | Popular Tags |