code: public static Pattern parseFilter( final String spec )
      {
          StringBuffer sb = new StringBuffer();
          for( int j = 0; j < spec.length(); j++ )
          {
              char c = spec.charAt( j );
              switch( c )
              {
                  case '.':
                      sb.append( "\\." );
                      break;
  
                  case '*':
                      // test for ** (all directories)
                      if( j < spec.length() - 1 && spec.charAt( j + 1 ) == '*' )
                      {
                          sb.append( ".*" );
                          j++;
                      }
                      else
                      {
                          sb.append( "[^/]*" );
                      }
                      break;
                  default:
                      sb.append( c );
                      break;
              }
          }
          String s = sb.toString();
          try
          {
              return Pattern.compile( s );
          }
          catch( Exception e )
          {
              throw new IllegalArgumentException( "Invalid character used in the filter name", e );
          }
      }
docs: Parses a usual filter into a regex pattern.
  
  @param spec the filter to be parsed
  
  @return a regexp pattern corresponding to the filter
  
  @throws IllegalArgumentException - If the filter could not be compiled to a pattern