FilenameMangler.java
Upload User: demmber
Upload Date: 2007-12-22
Package Size: 717k
Code Size: 3k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * @(#)FilenameMangler.java 0.3-3 06/05/2001
  3.  *
  4.  *  This file is part of the HTTPClient package
  5.  *  Copyright (C) 1996-2001 Ronald Tschal鋜
  6.  *
  7.  *  This library is free software; you can redistribute it and/or
  8.  *  modify it under the terms of the GNU Lesser General Public
  9.  *  License as published by the Free Software Foundation; either
  10.  *  version 2 of the License, or (at your option) any later version.
  11.  *
  12.  *  This library is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  *  Lesser General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU Lesser General Public
  18.  *  License along with this library; if not, write to the Free
  19.  *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20.  *  MA 02111-1307, USA
  21.  *
  22.  *  For questions, suggestions, bug-reports, enhancement-requests etc.
  23.  *  I may be contacted at:
  24.  *
  25.  *  ronald@innovation.ch
  26.  *
  27.  *  The HTTPClient's home page is located at:
  28.  *
  29.  *  http://www.innovation.ch/java/HTTPClient/ 
  30.  *
  31.  */
  32. package HTTPClient;
  33. /**
  34.  * {@link Codecs#mpFormDataDecode(byte[], java.lang.String, java.lang.String,
  35.  * HTTPClient.FilenameMangler) Codecs.mpFormDataDecode} and {@link
  36.  * Codecs#mpFormDataEncode(HTTPClient.NVPair[], HTTPClient.NVPair[],
  37.  * HTTPClient.NVPair[], HTTPClient.FilenameMangler) Codecs.mpFormDataEncode}
  38.  * may be handed an instance of a class which implements this interface in
  39.  * order to control names of the decoded files or the names sent in the encoded
  40.  * data.
  41.  *
  42.  * @version 0.3-3  06/05/2001
  43.  * @author Ronald Tschal鋜
  44.  * @since V0.3-1
  45.  */
  46. public interface FilenameMangler
  47. {
  48.     /**
  49.      * This is invoked by {@link Codecs#mpFormDataDecode(byte[],
  50.      * java.lang.String, java.lang.String, HTTPClient.FilenameMangler)
  51.      * Codecs.mpFormDataDecode} for each file found in the data, just before
  52.      * the file is created and written. If null is returned then the file is
  53.      * not created or written. This allows you to control which files are
  54.      * written and the names of the resulting files.
  55.      *
  56.      * <P>For {@link Codecs#mpFormDataEncode(HTTPClient.NVPair[],
  57.      * HTTPClient.NVPair[], HTTPClient.NVPair[], HTTPClient.FilenameMangler)
  58.      * Codecs.mpFormDataEncode} this is also invoked on each filename, allowing
  59.      * you to control the actual name used in the <var>filename</var> attribute
  60.      * of the Content-Disposition header. This does not change the name of the
  61.      * file actually read. If null is returned then the file is ignored.
  62.      *
  63.      * @param filename  the original filename in the Content-Disposition header
  64.      * @param fieldname the name of the this field, i.e. the value of the
  65.      *                  <var>name</var> attribute in Content-Disposition
  66.      *                  header
  67.      * @return the new file name, or null if the file is to be ignored.
  68.      */
  69.     public String mangleFilename(String filename, String fieldname);
  70. }