1 61 62 63 package org.jaxen; 64 65 import java.io.PrintStream ; 66 import java.io.PrintWriter ; 67 68 69 76 public class JaxenException extends org.jaxen.saxpath.SAXPathException 77 { 78 79 static double javaVersion = 1.4; 80 81 static { 82 try { 83 String versionString = System.getProperty("java.version"); 84 versionString = versionString.substring(0, 3); 85 javaVersion = Double.valueOf(versionString).doubleValue(); 86 } 87 catch (Exception ex) { 88 } 91 } 92 93 98 public JaxenException( String message ) 99 { 100 super( message ); 101 } 102 103 108 public JaxenException( Throwable rootCause ) 109 { 110 super( rootCause ); 111 } 112 113 120 public JaxenException(String message, Throwable nestedException) { 121 super( message, nestedException ); 122 } 123 124 private Throwable cause; 125 private boolean causeSet = false; 126 127 134 public Throwable getCause() { 135 return cause; 136 } 137 138 139 148 public Throwable initCause(Throwable cause) { 149 if (causeSet) throw new IllegalStateException ("Cause cannot be reset"); 150 if (cause == this) throw new IllegalArgumentException ("Exception cannot be its own cause"); 151 causeSet = true; 152 this.cause = cause; 153 return this; 154 } 155 156 public void printStackTrace( PrintStream s ) { 157 super.printStackTrace( s ); 158 if ( javaVersion < 1.4 && getCause() != null ) 159 { 160 s.print( "Caused by: " ); 161 getCause().printStackTrace( s ); 162 } 163 } 164 165 public void printStackTrace( PrintWriter w ) { 166 super.printStackTrace( w ); 167 if ( javaVersion < 1.4 && getCause() != null ) 169 { 170 w.print( "Caused by: " ); 171 getCause().printStackTrace( w ); 172 } 173 } 174 175 } 176 177 | Popular Tags |