Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.services.clientserver
Class FileTypeMatcher

java.lang.Object
  extended by 
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
 
Method Summary
  String[] getNames ()
          Return the names used to match on.
  String[] getTypes ()
          Return the types used to match on.
 boolean isCaseSensitive ()
          Return whether case should be considered when matching
 boolean matches ( String fileName)
          Test if a host name matches the pattern of this generic name.
static  String[] parseNames ( String typeList)
          Parse a comma-separated list of strings into an array of full-names.
static  String[] parseTypes ( String typeList)
          Parse a comma-separated list of strings into an array of strings representing extensions.
 void setCaseSensitive (boolean caseSensitive)
          Set whether case should be considered when matching
 void setTypes ( String[] types)
          Reset the types used to match on
 void setTypesAndNames ( String[] typesAndNames)
          Reset the types and names used to match on
 void setTypesAndNames ( String[] types, String[] names)
          Reset the types and names used to match on
  String toString ()
          For writing this object out.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEP_EXTENSION

public static final char SEP_EXTENSION
The delimiter that starts the extension part

See Also:
Constant Field Values
Constructor Detail

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
Method Detail

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.


RSE
Release 3.0

Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire