This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new 21349623 Change Class 
"org.apache.commons.net.ftp.parser.MVSFTPEntryParser" to support more datasets 
#182
21349623 is described below

commit 213496234ea0c96f0caeef587022fd497427f68d
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Sep 13 09:30:34 2023 -0400

    Change Class "org.apache.commons.net.ftp.parser.MVSFTPEntryParser" to
    support more datasets #182
    
    - Javadoc
    - Simplify
    - Don't scan entry twice
---
 src/changes/changes.xml                            |  3 ++
 .../commons/net/ftp/parser/MVSFTPEntryParser.java  | 33 ++++++++--------------
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7259d5a4..af119f7e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -145,6 +145,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="David Costanzo, Gary Gregory" 
issue="NET-722">
         Javadoc for FtpClient.setControlKeepAliveReplyTimeout(Duration) says 
timeout is in milliseconds.
       </action>
+      <action type="fix" dev="ggregory" due-to="haegar9766, Gary Gregory">
+        Change class org.apache.commons.net.ftp.parser.MVSFTPEntryParser to 
support more datasets #182.
+      </action>
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">
         Bump commons-parent from 54 to 62 #132, #137, #153.
diff --git 
a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java 
b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
index 1e26bd3f..2af22bec 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
@@ -213,17 +213,10 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
      * scheduler DB2 is used to interact with a DB2 subsystem
      *
      * This parser supports SEQ and JES.
-     *
-     *
-     *
-     *
-     *
-     *
      */
 
     /**
      * The sole constructor for a MVSFTPEntryParser object.
-     *
      */
     public MVSFTPEntryParser() {
         super(""); // note the regex is set in preParse.
@@ -239,8 +232,8 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
     }
 
     /**
-     * Parse entries representing a dataset list.
-     * <p>
+     * Parses entries representing a dataset list.
+     * <pre>
      * Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10
      * Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname
      * B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK
@@ -248,10 +241,11 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
      * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU
      * B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB
      * Migrated                                                HLQ.DATASET.NAME
-     * <p>
+     * </pre>
+     * <pre>
      * ----------------------------------- Group within Regex [1] Volume [2] 
Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record format 
[7]
      * Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg: Dataset 
organisation. Many exists but only support: PS, PO, PO-E [10] Dsname: Dataset 
name
-     * <p>
+     * </pre>
      *
      * @param entry zosDirectoryEntry
      * @return null: entry was not parsed.
@@ -277,18 +271,13 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
             return file;
         }
 
-        if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) {
+        final boolean migrated = entry.startsWith("Migrated");
+        if (migrated || entry.startsWith("ARCIVE")) {
             // Type of file is unknown for migrated datasets
             final FTPFile file = new FTPFile();
             file.setRawListing(entry);
             file.setType(FTPFile.UNKNOWN_TYPE);
-
-            if (entry.startsWith("Migrated")) {
-               file.setName(entry.split("\\s+")[1]);
-            } else {
-               file.setName(entry.split("\\s+")[5]);
-            }
-
+            file.setName(entry.split("\\s+")[migrated ? 1 : 5]);
             return file;
         }
 
@@ -397,7 +386,7 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
     }
 
     /**
-     * Parse entries within a partitioned dataset.
+     * Parses entries within a partitioned dataset.
      *
      * Format of a memberlist within a PDS:
      *
@@ -454,7 +443,7 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
     }
 
     /**
-     * preParse is called as part of the interface. Per definition, it is 
called before the parsing takes place. Three kinds of lists are recognized:
+     * Pre-parses is called as part of the interface. Per definition, it is 
called before the parsing takes place. Three kinds of lists are recognized:
      * <ul>
      *     <li>z/OS-MVS File lists,</li>
      *     <li>z/OS-MVS Member lists,</li>
@@ -497,7 +486,7 @@ public class MVSFTPEntryParser extends 
ConfigurableFTPFileEntryParserImpl {
     }
 
     /**
-     * Explicitly set the type of listing being processed.
+     * Sets the type of listing being processed.
      *
      * @param type The listing type.
      */

Reply via email to