org.eclipse.rse.services.clientserver
Class FileTypeMatcher
java.lang.Object
org.eclipse.rse.services.clientserver.FileTypeMatcher
-
All Implemented Interfaces:
-
IMatcher
-
public class FileTypeMatcher
- extends
Object
- implements
IMatcher
This class offers file type matching. A file type is the extension part of a file
name, minus the dot. For example, "java" and "class" are types.
Recently added is support for full file names, such as "manifest.mf", and even
extension-less names which use the placeholder ".null" for the extension, as in
"makefile.null" so as to dis-ambiguate from extensions like "cpp".
This supports being given a list of file types, via the constructor, to match on. It
will return true from the
matches(String)
method if the given file name ends
in an extension that matches one of the given types.
By default, all matching is done case-insensitive, but this can be overridden in the
constructor or by calling
setCaseSensitive(boolean)
.
For file name matching, use
NamePatternMatcher
instead.
Field Summary
|
static char
|
SEP_EXTENSION
The delimiter that starts the extension part |
Constructor Summary
|
FileTypeMatcher
(
String[] types)
Constructor for case-insensitive matching |
FileTypeMatcher
(
String[] types,
boolean caseSensitive)
Constructor when specifying if matching is case-sensitive or not |
SEP_EXTENSION
public static final char SEP_EXTENSION
- The delimiter that starts the extension part
-
See Also:
-
Constant Field Values
FileTypeMatcher
public FileTypeMatcher(
String[] types)
- Constructor for case-insensitive matching
-
Parameters:
-
types
- Array of file types to match on. These should not include the dot. Eg, "java"
FileTypeMatcher
public FileTypeMatcher(
String[] types,
boolean caseSensitive)
- Constructor when specifying if matching is case-sensitive or not
-
Parameters:
-
types
- Array of file types to match on. These should not include the dot. Eg, "java" -
caseSensitive
- true if to consider case when matching
setTypes
public void setTypes(
String[] types)
- Reset the types used to match on
-
-
setTypesAndNames
public void setTypesAndNames(
String[] types,
String[] names)
- Reset the types and names used to match on
-
-
setTypesAndNames
public void setTypesAndNames(
String[] typesAndNames)
- Reset the types and names used to match on
-
-
getTypes
public
String[] getTypes()
- Return the types used to match on.
-
-
-
See Also:
-
toString()
getNames
public
String[] getNames()
- Return the names used to match on.
-
-
-
See Also:
-
toString()
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
- Set whether case should be considered when matching
-
-
isCaseSensitive
public boolean isCaseSensitive()
- Return whether case should be considered when matching
-
-
matches
public boolean matches(
String fileName)
- Test if a host name matches the pattern of this generic name.
-
-
Specified by:
-
matches
in interface
IMatcher
-
-
Parameters:
-
fileName
- file name such as MyClass.java
-
Returns:
- true if given extension part of name matches any of the given types
-
See Also:
-
setCaseSensitive(boolean)
toString
public
String toString()
- For writing this object out.
Writes out the list of types given in the constructor, as a comma-separated list.
This is in the format directly usable in org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
-
-
Overrides:
-
toString
in class
Object
-
parseTypes
public static
String[] parseTypes(
String typeList)
- Parse a comma-separated list of strings into an array of strings representing
extensions. This ignores any full-names in the input list, and only parses
out the extensions...
-
-
parseNames
public static
String[] parseNames(
String typeList)
- Parse a comma-separated list of strings into an array of full-names. This ignores
the extensions and only parses out the full names.
-
-
Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.