📄 ruleset.java
字号:
/*
* jRevProxy, an opensource Java reverse proxy server
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
* $Id: Ruleset.java,v 2.4 2003/03/27 15:53:53 fnoe Exp $
*/
package cx.noe.jrevproxy;
/**
* Ruleset
*
* Holds a set of reverse proxy rules
* @author <a href="mailto:frederik@noe.cx">Frederik Noe</a>
* @version <tt>$Revision: 2.4 $</tt>
*/
import java.util.Vector;
import java.util.Enumeration;
public class Ruleset {
private Vector rules = null;
/** Creates a new instance of RuleSet */
public Ruleset() {
rules = new Vector();
}
public void addRule(Rule rule) {
// check if the rule has not yet been added
if(isNewRule(rule))
rules.add(rule);
}
private boolean isNewRule(Rule r) {
// walk over the list of rules and find out if it is a new rule
Enumeration enum = rules.elements();
Rule rule = null;
while(enum.hasMoreElements()) {
rule = (Rule) enum.nextElement();
if(rule.getName().equals(r.getName()))
return false;
}
return true;
}
public String toString() {
String newline = System.getProperty( "line.separator" );
StringBuffer buf = new StringBuffer();
buf.append( "--Rules--" ).append( newline );
for( int i=0; i<rules.size(); i++ ){
buf.append( rules.elementAt(i) ).append( newline );
}
return buf.toString();
}
/**
*
*/
public Rule getApplicableRule(String virtualdir) {
Enumeration enum = rules.elements();
Rule rule = null;
while(enum.hasMoreElements()) {
rule = (Rule) enum.nextElement();
if(rule.isApplicable(virtualdir))
return rule;
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -