1 51 52 package com.lowagie.text; 53 54 62 63 public class DocumentException extends Exception { 64 private static final long serialVersionUID = -2191131489390840739L; 65 private Exception ex; 66 67 71 public DocumentException(Exception ex) { 72 this.ex = ex; 73 } 74 75 77 80 public DocumentException() { 81 super(); 82 } 83 84 89 public DocumentException(String message) { 90 super(message); 91 } 92 93 97 public String getMessage() { 98 if (ex == null) 99 return super.getMessage(); 100 else 101 return ex.getMessage(); 102 } 103 104 108 public String getLocalizedMessage() { 109 if (ex == null) 110 return super.getLocalizedMessage(); 111 else 112 return ex.getLocalizedMessage(); 113 } 114 115 119 public String toString() { 120 if (ex == null) 121 return super.toString(); 122 else 123 return split(getClass().getName()) + ": " + ex; 124 } 125 126 127 public void printStackTrace() { 128 printStackTrace(System.err); 129 } 130 131 136 public void printStackTrace(java.io.PrintStream s) { 137 if (ex == null) 138 super.printStackTrace(s); 139 else { 140 synchronized (s) { 141 s.print(split(getClass().getName()) + ": "); 142 ex.printStackTrace(s); 143 } 144 } 145 } 146 147 151 public void printStackTrace(java.io.PrintWriter s) { 152 if (ex == null) 153 super.printStackTrace(s); 154 else { 155 synchronized (s) { 156 s.print(split(getClass().getName()) + ": "); 157 ex.printStackTrace(s); 158 } 159 } 160 } 161 162 167 private static String split(String s) { 168 int i = s.lastIndexOf('.'); 169 if (i < 0) 170 return s; 171 else 172 return s.substring(i + 1); 173 } 174 } 175 | Popular Tags |