1 24 package org.objectweb.joram.shared.selectors; 25 26 import org.objectweb.joram.shared.excepts.SelectorException; 27 import org.objectweb.joram.shared.messages.Message; 28 29 33 public class Selector 34 { 35 41 public static boolean checks(String selector) throws SelectorException 42 { 43 if (selector == null || selector.equals("")) 44 return true; 45 46 try { 47 Checker checker = new Checker(new Lexer(selector)); 48 return ((Boolean ) checker.parse().value).booleanValue(); 49 } 50 catch (SelectorException sE) { 51 throw sE; 52 } 53 catch (Throwable t) { 54 throw new SelectorException("Invalid selector: " + t.getMessage()); 55 } 56 } 57 58 64 public static boolean matches(Message message, String selector) 65 { 66 if (selector == null || selector.equals("")) 67 return true; 68 69 try { 70 Filter filter = new Filter(new Lexer(selector), message, "JMS"); 71 Boolean result = (Boolean ) filter.parse().value; 72 73 if (result == null) 74 return false; 75 76 return result.booleanValue(); 77 } 78 catch (Throwable t) { 79 return false; 80 } 81 } 82 } 83 84 | Popular Tags |