Sun Adapter for Batch/FTP

com.stc.connector.batchadapter.util
Class FtpDirRegExp

java.lang.Object
  extended by com.stc.connector.batchadapter.util.FtpDirRegExp
All Implemented Interfaces:
DirRegExp

public class FtpDirRegExp
extends java.lang.Object
implements DirRegExp

Provides support for FTP directory name regular expressions. The input is a full directory name made up of some regular expressions, while the output is a set of directories that are qualified against the regular expressions. Use the following rules for FTP directory regular expressions:

        

(1). The directory root, the directory separators should be expressed exclusively, don't express them in regexp. Only directory names are expected to appear as regexp.

(2). Regexp shouldn't go over the directory separators. So between any two directory separators, it would be one whole regexp.

(3). Escape all directory separators in directory pattern if the separator conflicts with regexp special character (one of "*[]()|+{}:.^$?\"). According to FtpHeuristics, the possible directory separators are '\', '/' and '.'. Among them, '\' and '.' are special characters used in regexp. So '\' and '.' should be escaped as "\\" and "\.".

(4). For some ftp servers (for example, MVS PDS, MVS Sequential and MVS GDG), no directory root indicator. In fact, the directory concept is not very clear, a dataset has prefix and name. We will not know if the directory is absolute or relative directory. We will always assume the directory is absolute. So the directory root (the part before the first directory separator) should be expressed exclusively. For example, root\.regexp1\.regexp2.

The expected directory pattern would be like

(1). /regexp1/regexp2/regexp3... (Unix), for example /abc\d/def/ghi (\d means any digit char) /^PRE[0-9]{5}\.dat$/... (Begin with "PRE" followed by a 5 digit number, with a "dat" extension. "\." means a real char '.' instead of any char. So PRE12345.dat will match, PRE123456dat will not match.)

(2). root\.regexp1\.regexp2... (MVS) (\. is escaped dir separator), for example EGATEX\.STC\.SAMPLE ("EGATEX" is not regexp, "STC" and "SAMPLE" are regexps).

(3). \\regexp1\\regexp2\\regexp3... (NT), for example \\abc.efg\\123.456 ('.' means any char).

(4). [regexp1\.regexp2\.regexp3... (VMS) (\. is escaped dir separator), for example [a.b\.c.d\.efg ('.'. in "a.b" or "c.d" is regexp char, means any char).

Version:
cvs revision: $Revision: 1.6 $ Last Modified: $Date: 2008/03/04 03:06:31 $
Author:
Harry Liu

Field Summary
 
Fields inherited from interface com.stc.connector.batchadapter.util.DirRegExp
regExpChars
 
Constructor Summary
FtpDirRegExp(java.lang.String dirPattern, java.lang.String style, DirectoryProvider dp)
          Constructs an object based on the FtpDirRegExp class.
 
Method Summary
 java.util.ArrayList getDirs()
          Get the directory names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpDirRegExp

public FtpDirRegExp(java.lang.String dirPattern,
                    java.lang.String style,
                    DirectoryProvider dp)
             throws java.lang.Exception
Constructs an object based on the FtpDirRegExp class.

Parameters:
dirPattern - The directory pattern that is made up of directory regular expressions.
ftp - An instance of the FtpFileProvider object.
Throws:
java.lang.Exception
Method Detail

getDirs

public java.util.ArrayList getDirs()
                            throws java.lang.Exception
Get the directory names.

Specified by:
getDirs in interface DirRegExp
Returns:
A list of directory names.
Throws:
java.lang.Exception - If some error occurs.

Sun Adapter for Batch/FTP