1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.net.ftp.parser;
17
18 import org.apache.commons.net.ftp.FTPClientConfig;
19 import org.apache.commons.net.ftp.FTPFile;
20
21 /**
22 * Implementation of FTPFileEntryParser and FTPFileListParser for IBM MVS Systems.
23 *
24 * @author <a href="jnadler@srcginc.com">Jeff Nadler</a>
25 * @author <a href="wnoto@openfinance.com">William Noto</a>
26 * @version $Id$
27 * @see org.apache.commons.net.ftp.FTPFileEntryParser FTPFileEntryParser (for usage instructions)
28 */
29 public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
30 {
31 /**
32 * This is the regular expression used by this parser.
33 */
34 private static final String REGEX = "(.*)\\s+([^\\s]+)\\s*";
35
36 /**
37 * Although this parser is now ignoring dates, someone may someday
38 * figure out a way to accomodate this and this appears to be the
39 * format used. For now, it won't be used.
40 * SMC 2005/04/08
41 */
42 static final String DEFAULT_DATE_FORMAT
43 = "yyyy/MM/dd";
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 /**
71 * The sole constructor for a MVSFTPEntryParser object.
72 *
73 * @exception IllegalArgumentException
74 * Thrown if the regular expression is unparseable. Should not be seen
75 * under normal conditions. It it is seen, this is a sign that
76 * <code>REGEX</code> is not a valid regular expression.
77 */
78 public MVSFTPEntryParser()
79 {
80 super(REGEX);
81 }
82
83 /**
84 * Parses a line of an MVS FTP server file listing and converts it into a
85 * usable format in the form of an <code> FTPFile </code> instance. If the
86 * file listing line doesn't describe a file, <code> null </code> is
87 * returned, otherwise a <code> FTPFile </code> instance representing the
88 * files in the directory is returned.
89 * <p>
90 * @param entry A line of text from the file listing
91 * @return An FTPFile instance corresponding to the supplied entry
92 */
93 public FTPFile parseFTPEntry(String entry)
94 {
95 FTPFile f = null;
96 if (matches(entry))
97 {
98 f = new FTPFile();
99 String dataSetName = group(2);
100 f.setType(FTPFile.FILE_TYPE);
101 f.setName(dataSetName);
102
103 return (f);
104 }
105 return null;
106 }
107
108
109
110
111 protected FTPClientConfig getDefaultConfiguration() {
112 return new FTPClientConfig(
113 FTPClientConfig.SYST_MVS,
114 DEFAULT_DATE_FORMAT,
115 null, null, null, null);
116 }
117 }