1 18 package org.apache.activemq.console.filter; 19 20 import java.util.ArrayList ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 24 public abstract class ResultTransformFilter implements QueryFilter { 25 private QueryFilter next; 26 27 31 protected ResultTransformFilter(QueryFilter next) { 32 this.next = next; 33 } 34 35 41 public List query(String query) throws Exception { 42 return transformList(next.query(query)); 43 } 44 45 51 public List query(List queries) throws Exception { 52 return transformList(next.query(queries)); 53 } 54 55 60 protected List transformList(List result) throws Exception { 61 List props = new ArrayList (); 62 63 for (Iterator i=result.iterator(); i.hasNext();) { 64 props.add(transformElement(i.next())); 65 } 66 67 return props; 68 } 69 70 75 protected abstract Object transformElement(Object obj) throws Exception ; 76 77 } 78 | Popular Tags |