1 23 24 package org.objectweb.cjdbc.common.exceptions.driver.protocol; 25 26 import java.io.IOException ; 27 28 import org.objectweb.cjdbc.common.stream.CJDBCInputStream; 29 import org.objectweb.cjdbc.common.stream.CJDBCOutputStream; 30 31 38 public class SerializableStackTraceElement 39 { 40 private String declaringClass; 41 private String methodName; 42 private String fileName; 43 private int lineNumber; 44 45 59 65 public SerializableStackTraceElement(StackTraceElement st) 66 { 67 this.declaringClass = st.getClassName(); 68 this.methodName = st.getMethodName(); 69 this.fileName = st.getFileName(); 70 this.lineNumber = st.getLineNumber(); 71 } 72 73 80 public SerializableStackTraceElement(CJDBCInputStream in) throws IOException 81 { 82 declaringClass = in.readUTF(); 83 methodName = in.readUTF(); 84 fileName = in.readUTF(); 85 lineNumber = in.readInt(); 86 } 87 88 94 public void sendToStream(CJDBCOutputStream out) throws IOException 95 { 96 out.writeUTF(declaringClass); 97 out.writeUTF(methodName); 98 out.writeUTF(fileName); 99 out.writeInt(lineNumber); 100 101 } 102 103 107 public int getLineNumber() 108 { 109 return lineNumber; 110 } 111 112 116 public String getClassName() 117 { 118 return declaringClass; 119 } 120 121 125 public String getMethodName() 126 { 127 return methodName; 128 } 129 130 134 public boolean isNativeMethod() 135 { 136 return lineNumber == -2; 137 } 138 139 143 public String toString() 144 { 145 return getClassName() 146 + "." 147 + methodName 148 + (isNativeMethod() ? "(Native Method)" : (fileName != null 149 && lineNumber >= 0 150 ? "(" + fileName + ":" + lineNumber + ")" 151 : (fileName != null ? "(" + fileName + ")" : "(Unknown Source)"))); 152 } 153 154 } 155 | Popular Tags |