Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.java.control.gui » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *   http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    *
   17    */
   18   package org.apache.jmeter.protocol.java.control.gui;
   19   
   20   import java.util.ArrayList;
   21   import java.util.Iterator;
   22   import java.util.List;
   23   
   24   public class ClassFilter {
   25   
   26       protected String[] pkgs = new String[0];
   27       /**
   28        *
   29        */
   30       public ClassFilter() {
   31           super();
   32       }
   33   
   34       public void setPackges(String[] pk) {
   35           this.pkgs = pk;
   36       }
   37   
   38       public void addPackage(String pkg) {
   39           String[] newpkg = new String[pkgs.length + 1];
   40           System.arraycopy(pkgs,0,newpkg,0,pkgs.length);
   41           newpkg[pkgs.length] = pkg;
   42           pkgs = newpkg;
   43       }
   44   
   45       public boolean include(String text) {
   46           boolean inc = false;
   47           for (int idx=0; idx < pkgs.length; idx++) {
   48               if (text.startsWith(pkgs[idx])){
   49                   inc = true;
   50                   break;
   51               }
   52           }
   53           return inc;
   54       }
   55   
   56       public Object[] filterArray(List items) {
   57           Iterator itr = items.iterator();
   58           ArrayList newlist = new ArrayList();
   59           while (itr.hasNext()) {
   60               Object item = itr.next();
   61               if (include((String)item)) {
   62                   newlist.add(item);
   63               }
   64           }
   65           if (newlist.size() > 0) {
   66               return newlist.toArray();
   67           } else {
   68               return new Object[0];
   69           }
   70       }
   71   
   72       public int size(){
   73           return pkgs.length;
   74       }
   75   }

Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.java.control.gui » [javadoc | source]