com.sshtools.sftp
Class GlobRegExpMatching

java.lang.Object
  extended bycom.sshtools.sftp.GlobRegExpMatching
All Implemented Interfaces:
RegularExpressionMatching

public class GlobRegExpMatching
extends java.lang.Object
implements RegularExpressionMatching

Implements the RegularExpressionMatching Interface.

matchFileNamesWithPattern performs a Glob regular expression pattern match on the Files passed to it, using fileNameRegExp, then returns the ones that match.

Code example:

 File f=new File("c:\\homefolder");
 File[] someFiles;
 List files in folder f and store in someFiles.
 someFiles=f.listFiles();
 Find the '.doc' files in someFiles that have 'rfc' in their name.
 String[] matchedFiles=matchFileNamesWithPattern(someFiles, "*rfc*.doc");
 

matchFilesWithPattern performs a Glob regular expression pattern match on the SftpFiles passed to it, using fileNameRegExp, then returns the ones that match.


Constructor Summary
GlobRegExpMatching()
           
 
Method Summary
 java.lang.String[] matchFileNamesWithPattern(java.io.File[] files, java.lang.String fileNameRegExp)
          compiles fileNameRegExp into a regular expression and pattern matches on each file's name, and returns those that match.
 SftpFile[] matchFilesWithPattern(SftpFile[] files, java.lang.String fileNameRegExp)
          compiles fileNameRegExp into a regular expression and pattern matches on each file's name, and returns those that match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobRegExpMatching

public GlobRegExpMatching()
Method Detail

matchFileNamesWithPattern

public java.lang.String[] matchFileNamesWithPattern(java.io.File[] files,
                                                    java.lang.String fileNameRegExp)
                                             throws SshException
compiles fileNameRegExp into a regular expression and pattern matches on each file's name, and returns those that match.

Specified by:
matchFileNamesWithPattern in interface RegularExpressionMatching
Parameters:
files -
fileNameRegExp -
Returns:
String[] of files that match the expresion.
Throws:
SshException

matchFilesWithPattern

public SftpFile[] matchFilesWithPattern(SftpFile[] files,
                                        java.lang.String fileNameRegExp)
                                 throws SftpStatusException,
                                        SshException
compiles fileNameRegExp into a regular expression and pattern matches on each file's name, and returns those that match.

Specified by:
matchFilesWithPattern in interface RegularExpressionMatching
Parameters:
files -
fileNameRegExp -
Returns:
SftpFile[] of files that match the expresion.
Throws:
SshException
SftpStatusException


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.