1 21 package oracle.toplink.essentials.exceptions; 23 24 import java.io.*; 25 import java.util.*; 26 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 27 28 32 public class IntegrityException extends ValidationException { 33 protected IntegrityChecker integrityChecker; 34 35 39 public IntegrityException() { 40 super(); 41 } 42 43 47 public IntegrityException(IntegrityChecker integrityChecker) { 48 super(); 49 this.integrityChecker = integrityChecker; 50 } 51 52 56 public IntegrityChecker getIntegrityChecker() { 57 return integrityChecker; 58 } 59 60 64 public String getMessage() { 65 String cr = oracle.toplink.essentials.internal.helper.Helper.cr(); 66 java.io.StringWriter swriter = new java.io.StringWriter (); 67 java.io.PrintWriter writer = new java.io.PrintWriter (swriter); 68 writer.println(cr + ExceptionMessageGenerator.getHeader("DescriptorExceptionsHeader")); 69 writer.println("---------------------------------------------------------"); 70 for (Enumeration enumtr = getIntegrityChecker().getCaughtExceptions().elements(); 71 enumtr.hasMoreElements();) { 72 Exception e = (Exception )enumtr.nextElement(); 73 if (e instanceof DescriptorException) { 74 writer.println(cr + e); 75 } 76 } 77 78 if (getIntegrityChecker().hasRuntimeExceptions()) { 79 writer.println(cr + ExceptionMessageGenerator.getHeader("RuntimeExceptionsHeader")); 80 writer.println("---------------------------------------------------------"); 81 for (Enumeration enumtr = getIntegrityChecker().getCaughtExceptions().elements(); 82 enumtr.hasMoreElements();) { 83 Exception e = (Exception )enumtr.nextElement(); 84 if (!(e instanceof DescriptorException)) { 85 writer.println(cr + e); 86 } 87 } 88 } 89 90 writer.flush(); 91 swriter.flush(); 92 return swriter.toString(); 93 } 94 95 99 public void printStackTrace(PrintWriter writer) { 100 super.printStackTrace(writer); 101 String cr = oracle.toplink.essentials.internal.helper.Helper.cr(); 102 writer.println(cr + ExceptionMessageGenerator.getHeader("DescriptorExceptionsHeader")); 103 writer.println("---------------------------------------------------------"); 104 for (Enumeration enumtr = getIntegrityChecker().getCaughtExceptions().elements(); 105 enumtr.hasMoreElements();) { 106 Exception e = (Exception )enumtr.nextElement(); 107 if (e instanceof DescriptorException) { 108 writer.println(cr); 109 e.printStackTrace(writer); 110 } 111 } 112 113 if (getIntegrityChecker().hasRuntimeExceptions()) { 114 writer.println(cr + ExceptionMessageGenerator.getHeader("RuntimeExceptionsHeader")); 115 writer.println("---------------------------------------------------------"); 116 for (Enumeration enumtr = getIntegrityChecker().getCaughtExceptions().elements(); 117 enumtr.hasMoreElements();) { 118 Exception e = (Exception )enumtr.nextElement(); 119 if (!(e instanceof DescriptorException)) { 120 writer.println(cr); 121 e.printStackTrace(writer); 122 } 123 } 124 } 125 126 writer.flush(); 127 } 128 } 129 | Popular Tags |