Pattern.java :  » XML-UI » SwingML » org » swingml » browser » ext » Java Open Source

Java Open Source » XML UI » SwingML 
SwingML » org » swingml » browser » ext » Pattern.java
package org.swingml.browser.ext;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author dpitt
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class Pattern {
  
  List list = new ArrayList();
  
  private String key = null;
  
  
  public void remove(String value) {
    
    list.remove(value);  
    
  }
    
  public void add(String value) {
    
    if (list.indexOf(value) < 0) {
    
      list.add(value);
    }  
  }
    
  public boolean equals(String value) {
    
    for (int i = 0; i < list.size(); i++) {
      
      String ele = (String) list.get(i);
      if (ele.equalsIgnoreCase(value)) {
         return true;  
      }  
      
    }  
    
  return false;

  }
    
  

   public boolean matches(String value) {
  
    Iterator itr = list.iterator();
    while(itr.hasNext()) {
      String pattern = (String) itr.next();
    if (value.toLowerCase().indexOf(pattern.toLowerCase()) == 0) 
    { return true; }  

    } 
   
    return false;  
    
   }
   
   public boolean isEmpty() {
     
     
     return list.isEmpty();
   }

  /**
   * Returns the key.
   * @return String
   */
  public String getKey() {
    return key;
  }

  /**
   * Sets the key.
   * @param key The key to set
   */
  public void setKey(String key) {
    this.key = key;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.