KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Util > Wildcards


1 /* $Id: Wildcards.java,v 1.1.1.1 2003/02/11 16:19:41 bures Exp $ */
2 package SOFA.Util;
3
4 /** Wildcards (*,?) matcher class.
5   *
6   * @author Petr Hnetynka
7   */

8 public class Wildcards {
9    
10    /** Matches the string with wildcards against a string.
11      * @param str matched string
12      * @param expr string with wildcards
13      * @return <tt>true</tt> if string matched
14      */

15    public static boolean match(String JavaDoc str, String JavaDoc expr) {
16
17      // to be implemented correctly later
18
if (expr.endsWith("*")) {
19
20        return str.startsWith(expr.substring(0, expr.length() - 1));
21      }
22      else
23        return expr.equals(str);
24    }
25 }
26
Popular Tags