| 1 | |
package org.webslinger.rules; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import java.util.Arrays; |
| 5 | |
import javax.servlet.ServletException; |
| 6 | |
import javax.servlet.ServletRequest; |
| 7 | |
|
| 8 | |
import org.webslinger.Webslinger; |
| 9 | |
|
| 10 | |
public class CSSModeSelector extends AbstractSelector { |
| 11 | |
private Action action; |
| 12 | |
|
| 13 | |
public CSSModeSelector(int id) { |
| 14 | 0 | super(id); |
| 15 | 0 | } |
| 16 | |
|
| 17 | |
public CSSModeSelector(Rules p, int id) { |
| 18 | 20 | super(p, id); |
| 19 | 20 | } |
| 20 | |
|
| 21 | |
|
| 22 | |
public Object jjtAccept(RulesVisitor visitor, Object data) { |
| 23 | 0 | return visitor.visit(this, data); |
| 24 | |
} |
| 25 | |
|
| 26 | |
void setAction(Action action) { |
| 27 | 20 | this.action = action; |
| 28 | 20 | } |
| 29 | |
|
| 30 | |
public Action getAction() { |
| 31 | 0 | return action; |
| 32 | |
} |
| 33 | |
|
| 34 | |
public boolean matches(ServletRequest request, Webslinger top) throws IOException, ServletException { |
| 35 | 297 | return action == top.getType() && super.matches(request, top); |
| 36 | |
} |
| 37 | |
|
| 38 | |
public void updateSpecificity(int[] specificity, boolean[] isConstantHolder) { |
| 39 | 20 | specificity[Selector.ACTION.ordinal()]++; |
| 40 | 20 | super.updateSpecificity(specificity, isConstantHolder); |
| 41 | 20 | } |
| 42 | |
|
| 43 | |
public String toString() { |
| 44 | 0 | return "ModeSelector(" + getAction() + ")" + (restrictions != null ? Arrays.asList(restrictions).toString() : ""); |
| 45 | |
} |
| 46 | |
} |