org.opensourcephysics.tools.minijar
Class Pattern

java.lang.Object
  extended by org.opensourcephysics.tools.minijar.Pattern

public class Pattern
extends java.lang.Object

Creates and uses a file matching pattern to locate files in a directory or in a compressed (ZIP or JAR) file. Patterns for files in compressed files are very simple. The search is true if the file name coincides with an entry in the compressed file. Patterns for regular files (in disk directories) can be more sophisticated by making use of a MAGIC (wild char) character.

Author:
Francisco Esquembre

Field Summary
static java.lang.String DOUBLE_MAGIC
           
static java.lang.String MAGIC
           
 
Constructor Summary
Pattern(java.io.File file)
          Constructs a pattern consisting of a compressed ZIP or JAR file.
Pattern(java.lang.String pattern)
          Constructs a Pattern object for a given pattern.
 
Method Summary
 boolean matches(java.lang.String filename)
          Whether the given file name matches the pattern
 java.lang.String toString()
          Prints a verbose description of the pattern
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAGIC

public static final java.lang.String MAGIC
See Also:
Constant Field Values

DOUBLE_MAGIC

public static final java.lang.String DOUBLE_MAGIC
See Also:
Constant Field Values
Constructor Detail

Pattern

public Pattern(java.lang.String pattern)
Constructs a Pattern object for a given pattern. Subsequent searches will be positive if the path provided matches the pattern.

Parameters:
pattern - A String of any of the following forms:
  • dir1/dir2/filename.ext : The file in the dir1/dir2 directory with the given name and extension.
  • dir1/dir2/+.ext : Any file in the dir1/dir2 directory with the given extension.
  • dir1/dir2/whatever+.ext : Any file in the dir1/dir2 directory, with a name that starts with 'whatever', and with the given extension.
  • dir1/dir2/++.ext : Any file at any level under the dir1/dir2 directory with the given extension.
  • dir1/dir2/++ : Any file at any level under the dir1/dir2 directory.
In all cases, lower and upper case letters are considered different. (Note: We don't use the standard wild char '*' because the operating system converts it before passing it to the java program.)

Pattern

public Pattern(java.io.File file)
Constructs a pattern consisting of a compressed ZIP or JAR file. Subsequent searches for paths will be positive if the compressed file contains an entry with the given path

Parameters:
file -
Method Detail

toString

public java.lang.String toString()
Prints a verbose description of the pattern

Overrides:
toString in class java.lang.Object

matches

public boolean matches(java.lang.String filename)
Whether the given file name matches the pattern

Parameters:
filename -
Returns: