Coverage report

  %line %branch
org.apache.commons.net.ftp.parser.MVSFTPEntryParser
91% 
100% 

 1  
 /*
 2  
  * Copyright 2005 The Apache Software Foundation
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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"; // 2001/11/09
 44  
 
 45  
         
 46  
  	// This is not at all the tightest possible regexp for MVS LIST
 47  
 	// output, but I'm not a mainframe guru so I have little idea what the
 48  
 	// range of valid values are.  I just needed to get the filename (Dsname);
 49  
 	// note that no other FTPFile fields can be filled in with the results of
 50  
 	// a LIST on MVS.  The 'Referred' date seems to be 'last accessed date'
 51  
 	// and not 'last modified date' so I didn't bother parsing it.
 52  
 	//
 53  
 	// Of course it works perfectly as-is and it distinguishes header lines from
 54  
 	// file results so that's the important thing.  
 55  
 	//
 56  
 	// This parser should be used when SYST returns:
 57  
 	// 'MVS is the operating system of this server. FTP Server is running on z/OS.'
 58  
 	//
 59  
 	// Also note that there is no concept of directories in MVS, just datasets,
 60  
 	// which have names composed of four dot separated names of up to 8 chars.
 61  
 	// As a result, FTPFile.FILE_TYPE is always used. -JN 6/2004 jnadler<at>srcginc<dotcom>
 62  
 
 63  
 	// Sample LIST results from MVS:
 64  
 	//
 65  
 	//Volume Unit    Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname
 66  
 	//FPFS42 3390   2004/06/23  1    1  FB     128  6144  PS  INCOMING.RPTBM023.D061704
 67  
 	//FPFS41 3390   2004/06/23  1    1  FB     128  6144  PS  INCOMING.RPTBM056.D061704
 68  
 	//FPFS25 3390   2004/06/23  1    1  FB     128  6144  PS  INCOMING.WTM204.D061704
 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  6
         super(REGEX);
 81  6
     }
 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  17
         FTPFile f = null;
 96  17
         if (matches(entry))          
 97  
         {
 98  14
             f = new FTPFile();
 99  14
             String dataSetName = group(2);
 100  14
             f.setType(FTPFile.FILE_TYPE);
 101  14
 			f.setName(dataSetName);
 102  
 
 103  14
 			return (f);
 104  
         }
 105  3
         return null;
 106  
     }
 107  
 
 108  
     /* 
 109  
      * @return
 110  
      */
 111  
     protected FTPClientConfig getDefaultConfiguration() {
 112  0
         return new FTPClientConfig(
 113  
                 FTPClientConfig.SYST_MVS,
 114  
                 DEFAULT_DATE_FORMAT,
 115  
                 null, class="keyword">null, class="keyword">null, class="keyword">null);
 116  
     }
 117  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.