| 1 | |
package org.webslinger.rules; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import javax.servlet.ServletException; |
| 5 | |
import javax.servlet.ServletRequest; |
| 6 | |
|
| 7 | |
import org.webslinger.Webslinger; |
| 8 | |
|
| 9 | |
public class CSSPathSelector extends AbstractSelector { |
| 10 | |
private PathMatcher matcher; |
| 11 | |
|
| 12 | |
public CSSPathSelector(int id) { |
| 13 | 0 | super(id); |
| 14 | 0 | } |
| 15 | |
|
| 16 | |
public CSSPathSelector(Rules p, int id) { |
| 17 | 13 | super(p, id); |
| 18 | 13 | } |
| 19 | |
|
| 20 | |
|
| 21 | |
public Object jjtAccept(RulesVisitor visitor, Object data) { |
| 22 | 0 | return visitor.visit(this, data); |
| 23 | |
} |
| 24 | |
|
| 25 | |
public void updateSpecificity(int[] specificity, boolean[] isConstantHolder) { |
| 26 | 25 | specificity[Selector.PATH.ordinal()]++; |
| 27 | 25 | super.updateSpecificity(specificity, isConstantHolder); |
| 28 | 25 | } |
| 29 | |
|
| 30 | |
void setMatcher(PathMatcher matcher) { |
| 31 | 13 | this.matcher = matcher; |
| 32 | 13 | } |
| 33 | |
|
| 34 | |
public boolean matches(ServletRequest request, Webslinger top) throws IOException, ServletException { |
| 35 | 238 | if (!super.matches(request, top)) return false; |
| 36 | 154 | return matcher.matches(request, top.getServletPath()); |
| 37 | |
} |
| 38 | |
|
| 39 | |
public String toString() { |
| 40 | 0 | return "PathSelector(" + matcher + ")"; |
| 41 | |
} |
| 42 | |
} |