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