1 21 22 package org.continuent.sequoia.common.exceptions.driver.protocol; 23 24 import java.io.IOException ; 25 26 import org.continuent.sequoia.common.stream.DriverBufferedInputStream; 27 import org.continuent.sequoia.common.stream.DriverBufferedOutputStream; 28 29 36 public class SerializableStackTraceElement 37 { 38 private String declaringClass; 39 private String methodName; 40 private String fileName; 41 private int lineNumber; 42 43 57 63 public SerializableStackTraceElement(StackTraceElement st) 64 { 65 this.declaringClass = st.getClassName(); 66 this.methodName = st.getMethodName(); 67 this.fileName = st.getFileName(); 68 this.lineNumber = st.getLineNumber(); 69 } 70 71 78 public SerializableStackTraceElement(DriverBufferedInputStream in) throws IOException 79 { 80 declaringClass = in.readLongUTF(); 81 methodName = in.readLongUTF(); 82 fileName = in.readLongUTF(); 83 lineNumber = in.readInt(); 84 } 85 86 92 public void sendToStream(DriverBufferedOutputStream out) throws IOException 93 { 94 out.writeLongUTF(declaringClass); 95 out.writeLongUTF(methodName); 96 out.writeLongUTF(fileName); 97 out.writeInt(lineNumber); 98 99 } 100 101 105 public int getLineNumber() 106 { 107 return lineNumber; 108 } 109 110 114 public String getClassName() 115 { 116 return declaringClass; 117 } 118 119 123 public String getMethodName() 124 { 125 return methodName; 126 } 127 128 132 public boolean isNativeMethod() 133 { 134 return lineNumber == -2; 135 } 136 137 141 public String toString() 142 { 143 return getClassName() 144 + "." 145 + methodName 146 + (isNativeMethod() ? "(Native Method)" : (fileName != null 147 && lineNumber >= 0 148 ? "(" + fileName + ":" + lineNumber + ")" 149 : (fileName != null ? "(" + fileName + ")" : "(Unknown Source)"))); 150 } 151 152 } 153 | Popular Tags |