1 15 package org.josql.filters; 16 17 import java.util.List ; 18 import java.util.ArrayList ; 19 20 import org.josql.Query; 21 import org.josql.QueryParseException; 22 import org.josql.QueryExecutionException; 23 24 44 public class StackTraceElementFilter extends AbstractJoSQLFilter 45 { 46 47 54 public StackTraceElementFilter (String q) 55 throws QueryParseException 56 { 57 58 super (q); 59 60 } 61 62 67 public Class getExpectedClass () 68 { 69 70 return StackTraceElement .class; 71 72 } 73 74 81 public StackTraceElementFilter (Query q) 82 throws IllegalStateException , 83 QueryParseException 84 { 85 86 super (q); 87 88 } 89 90 98 public boolean accept (Object o) 99 { 100 101 try 102 { 103 104 return this.accept ((StackTraceElement ) o); 105 106 } catch (Exception e) { 107 108 this.exp = e; 109 110 return false; 111 112 } 113 114 } 115 116 124 public boolean accept (StackTraceElement s) 125 throws QueryExecutionException 126 { 127 128 return this.q.getWhereClause ().isTrue (s, 129 this.q); 130 131 } 132 133 142 public StackTraceElement [] filterStackTrace (StackTraceElement [] s) 143 throws QueryExecutionException 144 { 145 146 if (s == null) 147 { 148 149 return s; 150 151 } 152 153 List l = new ArrayList (); 154 155 for (int i = 0; i < s.length; i++) 156 { 157 158 if (this.accept (s[i])) 159 { 160 161 l.add (s[i]); 162 163 } 164 165 } 166 167 StackTraceElement [] a = new StackTraceElement [l.size ()]; 170 171 for (int i = 0; i < l.size (); i++) 172 { 173 174 a[i] = (StackTraceElement ) l.get (i); 175 176 } 177 178 return a; 179 180 } 181 182 190 public void filter (Throwable t) 191 throws QueryExecutionException 192 { 193 194 this.filter (t, 195 true); 196 197 } 198 199 208 public void filter (Throwable t, 209 boolean filterCause) 210 throws QueryExecutionException 211 { 212 213 if (filterCause) 214 { 215 216 Throwable c = t.getCause (); 217 218 if (c != null) 219 { 220 221 this.filter (c, 222 filterCause); 223 224 } 225 226 } 227 228 t.setStackTrace (this.filterStackTrace (t.getStackTrace ())); 229 230 } 231 232 233 } 234 | Popular Tags |