Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.net.ftp.FTPFileEntryParserImpl |
50% |
100% |

1 |  |
     /*
2 |  |
      * Copyright 2001-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;
17 |  |
     import java.io.BufferedReader;
18 |  |
     import java.io.IOException;
19 |  |
     import java.io.InputStream;
20 |  |
     import java.util.Iterator;
21 |  |
     import java.util.List;
22 |  |
23 |  |
     /**
24 |  |
      * This abstract class implements both the older FTPFileListParser and
25 |  |
      * newer FTPFileEntryParser interfaces with default functionality.
26 |  |
      * All the classes in the parser subpackage inherit from this.
27 |  |
      *
28 |  |
      */
29 |  |
     public abstract class FTPFileEntryParserImpl
30 |  |
         implements FTPFileEntryParser, FTPFileListParser
31 |  |
     {
32 |  |
         /**
33 |  |
          * The constructor for a FTPFileEntryParserImpl object.
34 |  |
          */
35 |  |
         public FTPFileEntryParserImpl()
36 | 298 |
         {
37 | 298 |
         }
38 |  |
39 |  |
40 |  |
         /***
41 |  |
          * Parses an FTP server file listing and converts it into a usable format
42 |  |
          * in the form of an array of <code> FTPFile </code> instances.  If the
43 |  |
          * file list contains no files, <code> null </code> should be
44 |  |
          * returned, otherwise an array of <code> FTPFile </code> instances
45 |  |
          * representing the files in the directory is returned.
46 |  |
          * <p>
47 |  |
          * @param listStream The InputStream from which the file list should be
48 |  |
          *        read.
49 |  |
          * @return The list of file information contained in the given path.  null
50 |  |
          *     if the list could not be obtained or if there are no files in
51 |  |
          *     the directory.
52 |  |
          * @exception java.io.IOException  If an I/O error occurs reading the listStream.
53 |  |
          ***/
54 |  |
         public FTPFile[] parseFileList(InputStream listStream, String encoding) throws IOException
55 |  |
         {
56 | 0 |
             FTPFileList ffl = FTPFileList.create(listStream, this, encoding);
57 | 0 |
             return ffl.getFiles();
58 |  |
59 |  |
         }
60 |  |
61 |  |
         /***
62 |  |
          * Parses an FTP server file listing and converts it into a usable format
63 |  |
          * in the form of an array of <code> FTPFile </code> instances.  If the
64 |  |
          * file list contains no files, <code> null </code> should be
65 |  |
          * returned, otherwise an array of <code> FTPFile </code> instances
66 |  |
          * representing the files in the directory is returned.
67 |  |
          * <p>
68 |  |
          * @param listStream The InputStream from which the file list should be
69 |  |
          *        read.
70 |  |
          * @return The list of file information contained in the given path.  null
71 |  |
          *     if the list could not be obtained or if there are no files in
72 |  |
          *     the directory.
73 |  |
          * @exception java.io.IOException  If an I/O error occurs reading the listStream.
74 |  |
          *
75 |  |
          * @deprecated The version of this method which takes an encoding should be used.
76 |  |
         ***/
77 |  |
         public FTPFile[] parseFileList(InputStream listStream) throws IOException
78 |  |
         {
79 | 0 |
         	return parseFileList(listStream, null);
80 |  |
         }
81 |  |
82 |  |
         /**
83 |  |
          * Reads the next entry using the supplied BufferedReader object up to
84 |  |
          * whatever delemits one entry from the next.  This default implementation
85 |  |
          * simply calls BufferedReader.readLine().
86 |  |
          *
87 |  |
          * @param reader The BufferedReader object from which entries are to be
88 |  |
          * read.
89 |  |
          *
90 |  |
          * @return A string representing the next ftp entry or null if none found.
91 |  |
          * @exception java.io.IOException thrown on any IO Error reading from the reader.
92 |  |
          */
93 |  |
         public String readNextEntry(BufferedReader reader) throws IOException
94 |  |
         {
95 | 0 |
             return reader.readLine();
96 |  |
         }
97 |  |
         /**
98 |  |
          * This method is a hook for those implementors (such as
99 |  |
          * VMSVersioningFTPEntryParser, and possibly others) which need to
100 |  |
          * perform some action upon the FTPFileList after it has been created
101 |  |
          * from the server stream, but before any clients see the list.
102 |  |
          *
103 |  |
          * This default implementation is a no-op.
104 |  |
          *
105 |  |
          * @param original Original list after it has been created from the server stream
106 |  |
          *
107 |  |
          * @return <code>original</code> unmodified.
108 |  |
          */
109 |  |
          public List preParse(List original) {
110 | 4 |
              Iterator it = original.iterator();
111 | 4 |
              while (it.hasNext()){
112 | 4 |
                 String entry = (String) it.next();
113 | 4 |
                 if (null == parseFTPEntry(entry)) {
114 | 0 |
                     it.remove();
115 |  |
                 } else {
116 | 0 |
                     break;
117 |  |
                 }
118 |  |
              }
119 | 4 |
              return original;
120 |  |
          }
121 |  |
     }
122 |  |
123 |  |
     /* Emacs configuration
124 |  |
      * Local variables:        **
125 |  |
      * mode:             java  **
126 |  |
      * c-basic-offset:   4     **
127 |  |
      * indent-tabs-mode: nil   **
128 |  |
      * End:                    **
129 |  |
      */

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