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

📄 toolbean.java

📁 java servlet编程源码
💻 JAVA
字号:
import java.util.*;

public class ToolBean {

  private Tool[] tools;
  private String state;

  public ToolBean() { }

  public void setToolsFile(String toolsFile) throws Exception {
    // No way to gain access to the application context directly from a bean
    tools = Tool.loadTools(toolsFile);
  }

  public Tool[] getTools(String state) throws Exception {
    if (tools == null) {
      throw new IllegalStateException(
        "You must always set the toolsFile property on a ToolBean");
    }

    if (state == null) {
      return tools;
    }
    else {
      // Return only tools matching the given "state"
      List list = new LinkedList();
      for (int i = 0; i < tools.length; i++) {
        if (tools[i].getStateFlag().equalsIgnoreCase(state)) {
          list.add(tools[i]);
        }
      }
      return (Tool[]) list.toArray(new Tool[0]);
    }
  }
}

⌨️ 快捷键说明

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