⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filterentry.java

📁 weblogic应用全实例
💻 JAVA
字号:
//声明这个类所在的包
package examples.security.net;
//声明这个类引入的其他类

import java.net.InetAddress;


/**
 * 抽象类,过滤原则
 *
 */
abstract class FilterEntry
{
  //定义三种状态常量
  //允许	
  static final int ALLOW = 0;
  //拒绝
  static final int DENY = 1;
  //忽略
  static final int IGNORE = 2;
  private int protomask;
  private boolean action;
  //构造方法
  protected FilterEntry(boolean action, int protomask)
  {
    this.protomask = protomask;
    this.action = action;
  }
  //检查地址和协议
  int check(InetAddress addr, int protocol)
  {
    if (match(addr) && match(protocol))
    {
      return action ? ALLOW : DENY;
    }
    return IGNORE;
  }
  //匹配地址
  protected abstract boolean match(InetAddress addr);
  //匹配协议
  protected boolean match(int protocol)
  {
    return protomask == 0 || (protocol & protomask) != 0;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -