Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77955200CCA for ; Tue, 13 Jun 2017 14:53:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 76190160BC9; Tue, 13 Jun 2017 12:53:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3697E160BF5 for ; Tue, 13 Jun 2017 14:53:34 +0200 (CEST) Received: (qmail 87618 invoked by uid 500); 13 Jun 2017 12:53:33 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 87311 invoked by uid 99); 13 Jun 2017 12:53:31 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2017 12:53:31 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 422103A262B for ; Tue, 13 Jun 2017 12:53:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1013975 [17/26] - in /websites/production/commons/content/proper/commons-fileupload: ./ apidocs/ apidocs/org/apache/commons/fileupload/ apidocs/org/apache/commons/fileupload/class-use/ apidocs/org/apache/commons/fileupload/disk/ apidocs/or... Date: Tue, 13 Jun 2017 12:53:22 -0000 To: notifications@commons.apache.org From: chtompki@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170613125327.422103A262B@svn01-us-west.apache.org> archived-at: Tue, 13 Jun 2017 12:53:36 -0000 Modified: websites/production/commons/content/proper/commons-fileupload/cobertura/org.apache.commons.fileupload.disk.DiskFileItem.html ============================================================================== --- websites/production/commons/content/proper/commons-fileupload/cobertura/org.apache.commons.fileupload.disk.DiskFileItem.html (original) +++ websites/production/commons/content/proper/commons-fileupload/cobertura/org.apache.commons.fileupload.disk.DiskFileItem.html Tue Jun 13 12:53:17 2017 @@ -12,7 +12,7 @@
 
- +
Classes in this File Line Coverage Branch Coverage Complexity
DiskFileItem
69%
78/112
60%
28/46
2,5
DiskFileItem
69%
78/112
60%
28/46
2.5
 
@@ -174,971 +174,951 @@  78  
     /**
 79   -
      * The UID to use when serializing this instance.
+
      * Default content charset to be used when no explicit charset
 80   -
      */
+
      * parameter is provided by the sender. Media subtypes of the
 81   -
     private static final long serialVersionUID = 2237570099615271025L;
+
      * "text" type are defined to have a default charset value of
 82   -
 
+
      * "ISO-8859-1" when received via HTTP.
 83   -
     /**
+
      */
 84   -
      * Default content charset to be used when no explicit charset
+
     public static final String DEFAULT_CHARSET = "ISO-8859-1";
 85   -
      * parameter is provided by the sender. Media subtypes of the
+
 
 86   -
      * "text" type are defined to have a default charset value of
+
     // ----------------------------------------------------------- Data members
 87   -
      * "ISO-8859-1" when received via HTTP.
+
 
 88   -
      */
+
     /**
 89   -
     public static final String DEFAULT_CHARSET = "ISO-8859-1";
+
      * UID used in unique file name generation.
 90   -
 
+
      */
 91   -
     // ----------------------------------------------------------- Data members
-  92   -
 
+
     private static final String UID =
+  92  1
             UUID.randomUUID().toString().replace('-', '_');
 93   -
     /**
+
 
 94   -
      * UID used in unique file name generation.
+
     /**
 95   -
      */
+
      * Counter used in unique identifier generation.
 96   -
     private static final String UID =
-  97  1
             UUID.randomUUID().toString().replace('-', '_');
+
      */
+  97  1
     private static final AtomicInteger COUNTER = new AtomicInteger(0);
 98  
 
 99  
     /**
 100   -
      * Counter used in unique identifier generation.
+
      * The name of the form field as provided by the browser.
 101  
      */
-  102  1
     private static final AtomicInteger COUNTER = new AtomicInteger(0);
+  102   +
     private String fieldName;
 103  
 
 104  
     /**
 105   -
      * The name of the form field as provided by the browser.
+
      * The content type passed by the browser, or <code>null</code> if
 106   -
      */
+
      * not defined.
 107   -
     private String fieldName;
+
      */
 108   -
 
+
     private final String contentType;
 109   -
     /**
+
 
 110   -
      * The content type passed by the browser, or <code>null</code> if
+
     /**
 111   -
      * not defined.
+
      * Whether or not this item is a simple form field.
 112  
      */
 113   -
     private final String contentType;
+
     private boolean isFormField;
 114  
 
 115  
     /**
 116   -
      * Whether or not this item is a simple form field.
+
      * The original filename in the user's filesystem.
 117  
      */
 118   -
     private boolean isFormField;
+
     private final String fileName;
 119  
 
 120  
     /**
 121   -
      * The original filename in the user's filesystem.
+
      * The size of the item, in bytes. This is used to cache the size when a
 122   -
      */
+
      * file item is moved from its original location.
 123   -
     private final String fileName;
-  124   -
 
+
      */
+  124  2146
     private long size = -1;
 125   -
     /**
+
 
 126   -
      * The size of the item, in bytes. This is used to cache the size when a
+
 
 127   -
      * file item is moved from its original location.
+
     /**
 128   +
      * The threshold above which uploads will be stored on disk.
+  129  
      */
-  129  2146
     private long size = -1;
 130   -
 
+
     private final int sizeThreshold;
 131  
 
 132  
     /**
 133   -
      * The threshold above which uploads will be stored on disk.
+
      * The directory in which uploaded files will be stored, if stored on disk.
 134  
      */
 135   -
     private final int sizeThreshold;
+
     private final File repository;
 136  
 
 137  
     /**
 138   -
      * The directory in which uploaded files will be stored, if stored on disk.
+
      * Cached contents of the file.
 139  
      */
 140   -
     private final File repository;
+
     private byte[] cachedContent;
 141  
 
 142  
     /**
 143   -
      * Cached contents of the file.
+
      * Output stream for this item.
 144  
      */
 145   -
     private byte[] cachedContent;
+
     private transient DeferredFileOutputStream dfos;
 146  
 
 147  
     /**
 148   -
      * Output stream for this item.
+
      * The temporary file to use.
 149  
      */
 150   -
     private transient DeferredFileOutputStream dfos;
+
     private transient File tempFile;
 151  
 
 152  
     /**
 153   -
      * The temporary file to use.
+
      * The file items headers.
 154  
      */
 155   -
     private transient File tempFile;
+
     private FileItemHeaders headers;
 156  
 
 157   -
     /**
-  158   -
      * File to allow for serialization of the content of this item.
-  159   -
      */
-  160   -
     private File dfosFile;
-  161   -
 
-  162   -
     /**
-  163   -
      * The file items headers.
-  164   -
      */
-  165   -
     private FileItemHeaders headers;
-  166   -
 
-  167  
     // ----------------------------------------------------------- Constructors
-  168   +  158  
 
-  169   +  159  
     /**
-  170   +  160  
      * Constructs a new <code>DiskFileItem</code> instance.
-  171   +  161  
      *
-  172   +  162  
      * @param fieldName     The name of the form field.
-  173   +  163  
      * @param contentType   The content type passed by the browser or
-  174   +  164  
      *                      <code>null</code> if not specified.
-  175   +  165  
      * @param isFormField   Whether or not this item is a plain form field, as
-  176   +  166  
      *                      opposed to a file upload.
-  177   +  167  
      * @param fileName      The original filename in the user's filesystem, or
-  178   +  168  
      *                      <code>null</code> if not specified.
-  179   +  169  
      * @param sizeThreshold The threshold, in bytes, below which items will be
-  180   +  170  
      *                      retained in memory and above which they will be
-  181   +  171  
      *                      stored as a file.
-  182   +  172  
      * @param repository    The data repository, which is the directory in
-  183   +  173  
      *                      which files will be created, should the item size
-  184   +  174  
      *                      exceed the threshold.
-  185   +  175  
      */
-  186   +  176  
     public DiskFileItem(String fieldName,
-  187   +  177  
             String contentType, boolean isFormField, String fileName,
-  188  2146
             int sizeThreshold, File repository) {
-  189  2146
         this.fieldName = fieldName;
-  190  2146
         this.contentType = contentType;
-  191  2146
         this.isFormField = isFormField;
-  192  2146
         this.fileName = fileName;
-  193  2146
         this.sizeThreshold = sizeThreshold;
-  194  2146
         this.repository = repository;
-  195  2146
     }
-  196   +  178  2146
             int sizeThreshold, File repository) {
+  179  2146
         this.fieldName = fieldName;
+  180  2146
         this.contentType = contentType;
+  181  2146
         this.isFormField = isFormField;
+  182  2146
         this.fileName = fileName;
+  183  2146
         this.sizeThreshold = sizeThreshold;
+  184  2146
         this.repository = repository;
+  185  2146
     }
+  186  
 
-  197   +  187  
     // ------------------------------- Methods from javax.activation.DataSource
-  198   +  188  
 
-  199   +  189  
     /**
-  200   +  190  
      * Returns an {@link java.io.InputStream InputStream} that can be
-  201   +  191  
      * used to retrieve the contents of the file.
-  202   +  192  
      *
-  203   +  193  
      * @return An {@link java.io.InputStream InputStream} that can be
-  204   +  194  
      *         used to retrieve the contents of the file.
-  205   +  195  
      *
-  206   +  196  
      * @throws IOException if an error occurs.
-  207   +  197  
      */
-  208   +  198  
     public InputStream getInputStream()
-  209   +  199  
         throws IOException {
-  210  0
         if (!isInMemory()) {
-  211  0
             return new FileInputStream(dfos.getFile());
-  212   +  200  0
         if (!isInMemory()) {
+  201  0
             return new FileInputStream(dfos.getFile());
+  202  
         }
-  213   +  203  
 
-  214  0
         if (cachedContent == null) {
-  215  0
             cachedContent = dfos.getData();
-  216   +  204  0
         if (cachedContent == null) {
+  205  0
             cachedContent = dfos.getData();
+  206  
         }
-  217  0
         return new ByteArrayInputStream(cachedContent);
-  218   +  207  0
         return new ByteArrayInputStream(cachedContent);
+  208  
     }
-  219   +  209  
 
-  220   +  210  
     /**
-  221   +  211  
      * Returns the content type passed by the agent or <code>null</code> if
-  222   +  212  
      * not defined.
-  223   +  213  
      *
-  224   +  214  
      * @return The content type passed by the agent or <code>null</code> if
-  225   +  215  
      *         not defined.
-  226   +  216  
      */
-  227   +  217  
     public String getContentType() {
-  228  23
         return contentType;
-  229   +  218  23
         return contentType;
+  219  
     }
-  230   +  220  
 
-  231   +  221  
     /**
-  232   +  222  
      * Returns the content charset passed by the agent or <code>null</code> if
-  233   +  223  
      * not defined.
-  234   +  224  
      *
-  235   +  225  
      * @return The content charset passed by the agent or <code>null</code> if
-  236   +  226  
      *         not defined.
-  237   +  227  
      */
-  238   +  228  
     public String getCharSet() {
-  239  18
         ParameterParser parser = new ParameterParser();
-  240  18
         parser.setLowerCaseNames(true);
-  241   +  229  18
         ParameterParser parser = new ParameterParser();
+  230  18
         parser.setLowerCaseNames(true);
+  231  
         // Parameter parser can handle null input
-  242  18
         Map<String, String> params = parser.parse(getContentType(), ';');
-  243  18
         return params.get("charset");
-  244   +  232  18
         Map<String, String> params = parser.parse(getContentType(), ';');
+  233  18
         return params.get("charset");
+  234  
     }
-  245   +  235  
 
-  246   +  236  
     /**
-  247   +  237  
      * Returns the original filename in the client's filesystem.
-  248   +  238  
      *
-  249   +  239  
      * @return The original filename in the client's filesystem.
-  250   +  240  
      * @throws org.apache.commons.fileupload.InvalidFileNameException The file name contains a NUL character,
-  251   +  241  
      *   which might be an indicator of a security attack. If you intend to
-  252   +  242  
      *   use the file name anyways, catch the exception and use
-  253   +  243  
      *   {@link org.apache.commons.fileupload.InvalidFileNameException#getName()}.
-  254   +  244  
      */
-  255   +  245  
     public String getName() {
-  256  11
         return Streams.checkFileName(fileName);
-  257   +  246  11
         return Streams.checkFileName(fileName);
+  247  
     }
-  258   +  248  
 
-  259   +  249  
     // ------------------------------------------------------- FileItem methods
-  260   +  250  
 
-  261   +  251  
     /**
-  262   +  252  
      * Provides a hint as to whether or not the file contents will be read
-  263   +  253  
      * from memory.
-  264   +  254  
      *
-  265   +  255  
      * @return <code>true</code> if the file contents will be read
-  266   +  256  
      *         from memory; <code>false</code> otherwise.
-  267   +  257  
      */
-  268   +  258  
     public boolean isInMemory() {
-  269  2147
         if (cachedContent != null) {
-  270  1
             return true;
-  271   +  259  2147
         if (cachedContent != null) {
+  260  1
             return true;
+  261  
         }
-  272  2146
         return dfos.isInMemory();
-  273   +  262  2146
         return dfos.isInMemory();
+  263  
     }
-  274   +  264  
 
-  275   +  265  
     /**
-  276   +  266  
      * Returns the size of the file.
-  277   +  267  
      *
-  278   +  268  
      * @return The size of the file, in bytes.
-  279   +  269  
      */
-  280   +  270  
     public long getSize() {
-  281  536
         if (size >= 0) {
-  282  0
             return size;
-  283  536
         } else if (cachedContent != null) {
-  284  0
             return cachedContent.length;
-  285  536
         } else if (dfos.isInMemory()) {
-  286  4
             return dfos.getData().length;
-  287   +  271  536
         if (size >= 0) {
+  272  0
             return size;
+  273  536
         } else if (cachedContent != null) {
+  274  0
             return cachedContent.length;
+  275  536
         } else if (dfos.isInMemory()) {
+  276  4
             return dfos.getData().length;
+  277  
         } else {
-  288  532
             return dfos.getFile().length();
-  289   +  278  532
             return dfos.getFile().length();
+  279  
         }
-  290   +  280  
     }
-  291   +  281  
 
-  292   +  282  
     /**
-  293   +  283  
      * Returns the contents of the file as an array of bytes.  If the
-  294   +  284  
      * contents of the file were not yet cached in memory, they will be
-  295   +  285  
      * loaded from the disk storage and cached.
-  296   +  286  
      *
-  297   +  287  
      * @return The contents of the file as an array of bytes
-  298   +  288  
      * or {@code null} if the data cannot be read
-  299   +  289  
      */
-  300   +  290  
     public byte[] get() {
-  301  1431
         if (isInMemory()) {
-  302  902
             if (cachedContent == null && dfos != null) {
-  303  901
                 cachedContent = dfos.getData();
-  304   +  291  1431
         if (isInMemory()) {
+  292  902
             if (cachedContent == null && dfos != null) {
+  293  901
                 cachedContent = dfos.getData();
+  294  
             }
-  305  902
             return cachedContent;
-  306   +  295  902
             return cachedContent;
+  296  
         }
-  307   +  297  
 
-  308  529
         byte[] fileData = new byte[(int) getSize()];
-  309  529
         InputStream fis = null;
-  310   +  298  529
         byte[] fileData = new byte[(int) getSize()];
+  299  529
         InputStream fis = null;
+  300  
 
-  311   +  301  
         try {
-  312  529
             fis = new FileInputStream(dfos.getFile());
-  313  529
             IOUtils.readFully(fis, fileData);
-  314  0
         } catch (IOException e) {
-  315  0
             fileData = null;
-  316   +  302  529
             fis = new FileInputStream(dfos.getFile());
+  303  529
             IOUtils.readFully(fis, fileData);
+  304  0
         } catch (IOException e) {
+  305  0
             fileData = null;
+  306  
         } finally {
-  317  529
             IOUtils.closeQuietly(fis);
-  318  529
         }
-  319   +  307  529
             IOUtils.closeQuietly(fis);
+  308  529
         }
+  309  
 
-  320  529
         return fileData;
-  321   +  310  529
         return fileData;
+  311  
     }
-  322   +  312  
 
-  323   +  313  
     /**
-  324   +  314  
      * Returns the contents of the file as a String, using the specified
-  325   +  315  
      * encoding.  This method uses {@link #get()} to retrieve the
-  326   +  316  
      * contents of the file.
-  327   +  317  
      *
-  328   +  318  
      * @param charset The charset to use.
-  329   +  319  
      *
-  330   +  320  
      * @return The contents of the file, as a string.
-  331   +  321  
      *
-  332   +  322  
      * @throws UnsupportedEncodingException if the requested character
-  333   +  323  
      *                                      encoding is not available.
-  334   +  324  
      */
-  335   +  325  
     public String getString(final String charset)
-  336   +  326  
         throws UnsupportedEncodingException {
-  337  0
         return new String(get(), charset);
-  338   +  327  0
         return new String(get(), charset);
+  328  
     }
-  339   +  329  
 
-  340   +  330  
     /**
-  341   +  331  
      * Returns the contents of the file as a String, using the default
-  342   +  332  
      * character encoding.  This method uses {@link #get()} to retrieve the
-  343   +  333  
      * contents of the file.
-  344   +  334  
      *
-  345   +  335  
      * <b>TODO</b> Consider making this method throw UnsupportedEncodingException.
-  346   +  336  
      *
-  347   +  337  
      * @return The contents of the file, as a string.
-  348   +  338  
      */
-  349   +  339  
     public String getString() {
-  350  18
         byte[] rawdata = get();
-  351  18
         String charset = getCharSet();
-  352  18
         if (charset == null) {
-  353  18
             charset = DEFAULT_CHARSET;
-  354   +  340  18
         byte[] rawdata = get();
+  341  18
         String charset = getCharSet();
+  342  18
         if (charset == null) {
+  343  18
             charset = DEFAULT_CHARSET;
+  344  
         }
-  355   +  345  
         try {
-  356  18
             return new String(rawdata, charset);
-  357  0
         } catch (UnsupportedEncodingException e) {
-  358  0
             return new String(rawdata);
-  359   +  346  18
             return new String(rawdata, charset);
+  347  0
         } catch (UnsupportedEncodingException e) {
+  348  0
             return new String(rawdata);
+  349  
         }
-  360   +  350  
     }
-  361   +  351  
 
-  362   +  352  
     /**
-  363   +  353   [... 710 lines stripped ...]