1 16 17 package org.apache.tomcat.util.compat; 18 19 import java.io.File ; 20 import java.io.IOException ; 21 import java.net.MalformedURLException ; 22 import java.net.URL ; 23 24 27 28 34 public class Jdk14Compat extends JdkCompat { 35 37 40 44 protected Jdk14Compat() { 45 } 46 47 48 50 58 public URL getURI(File file) 59 throws MalformedURLException { 60 61 File realFile = file; 62 try { 63 realFile = realFile.getCanonicalFile(); 64 } catch (IOException e) { 65 } 67 68 return realFile.toURI().toURL(); 69 } 70 71 72 75 public long getMaxMemory() { 76 return Runtime.getRuntime().maxMemory(); 77 } 78 79 80 84 public String getPartialServletStackTrace(Throwable t) { 85 StringBuffer trace = new StringBuffer (); 86 trace.append(t.toString()).append('\n'); 87 StackTraceElement [] elements = t.getStackTrace(); 88 int pos = elements.length; 89 for (int i = 0; i < elements.length; i++) { 90 if ((elements[i].getClassName().startsWith 91 ("org.apache.catalina.core.ApplicationFilterChain")) 92 && (elements[i].getMethodName().equals("internalDoFilter"))) { 93 pos = i; 94 } 95 } 96 for (int i = 0; i < pos; i++) { 97 if (!(elements[i].getClassName().startsWith 98 ("org.apache.catalina.core."))) { 99 trace.append('\t').append(elements[i].toString()).append('\n'); 100 } 101 } 102 return trace.toString(); 103 } 104 105 public String [] split(String path, String pat) { 106 return path.split(pat); 107 } 108 109 110 116 public void chainException(Throwable wrapper, Throwable wrapped) { 117 wrapper.initCause(wrapped); 118 } 119 120 } 121 | Popular Tags |