You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by md...@apache.org on 2004/01/15 17:09:09 UTC

cvs commit: jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/spi MultipartFormDataProvider.java

mdiggory    2004/01/15 08:09:09

  Modified:    codec-multipart/src/java/org/apache/commons/codec/multipart
                        FilePart.java StringPart.java
               codec-multipart/src/java/org/apache/commons/codec/multipart/spi
                        MultipartFormDataProvider.java
  Added:       codec-multipart/src/java/org/apache/commons/codec/ascii
                        AsciiUtils.java
               codec-multipart/src/java/org/apache/commons/codec/multipart
                        AbstractPart.java
  Removed:     codec-multipart/src/java/org/apache/commons/codec/multipart/util
                        AbstractPart.java Constants.java
  Log:
  Some reorganization for extract ascii conversion into possible CharsetEncoder/Decoder
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/ascii/AsciiUtils.java
  
  Index: AsciiUtils.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/ascii/AsciiUtils.java,v 1.1 2004/01/15 16:09:09 mdiggory Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/15 16:09:09 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.commons.codec.ascii;
  
  import java.io.UnsupportedEncodingException;
  
  import org.apache.commons.codec.BinaryDecoder;
  import org.apache.commons.codec.BinaryEncoder;
  import org.apache.commons.codec.DecoderException;
  import org.apache.commons.codec.EncoderException;
  import org.apache.commons.codec.StringDecoder;
  import org.apache.commons.codec.StringEncoder;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  
  /**
   * HTTP content conversion routines.
   *
   * @author Oleg Kalnichevski
   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
   * @author <a href="mailto:mdiggory@latte.harvard.edu">Mark Diggory</a>
   */
  public class AsciiUtils implements StringEncoder, StringDecoder, BinaryEncoder, BinaryDecoder {
  
      /** Character set used to encode HTTP protocol elements */
      public static final String HTTP_ELEMENT_CHARSET = "US-ASCII";
  
      /** Default content encoding chatset */
      public static final String DEFAULT_CONTENT_CHARSET = "ISO-8859-1";
  
      /** Log object for this class. */
      private static final Log LOG = LogFactory.getLog(AsciiUtils.class);
  
      /**
       * Converts the specified string to a byte array of HTTP element characters.
       * This method is to be used when encoding content of HTTP elements (such as
       * request headers)
       *
       * @param data the string to be encoded
       * @return The resulting byte array.
       */
      public static byte[] getBytes(final String data) {
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          try {
              return data.getBytes(HTTP_ELEMENT_CHARSET);
          } catch (UnsupportedEncodingException e) {
  
              if (LOG.isWarnEnabled()) {
                  LOG.warn("Unsupported encoding: " 
                      + HTTP_ELEMENT_CHARSET 
                      + ". System default encoding used");
              }
  
              return data.getBytes();
          }
      }
  
      /**
       * Converts the byte array of HTTP element characters to a string This
       * method is to be used when decoding content of HTTP elements (such as
       * response headers)
       *
       * @param data the byte array to be encoded
       * @param offset the index of the first byte to encode
       * @param length the number of bytes to encode 
       * @return The resulting string.
       */
      public static String getString(final byte[] data, int offset, int length) {
  
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          try {
              return new String(data, offset, length, HTTP_ELEMENT_CHARSET);
          } catch (UnsupportedEncodingException e) {
  
              if (LOG.isWarnEnabled()) {
                  LOG.warn("Unsupported encoding: " 
                      + HTTP_ELEMENT_CHARSET 
                      + ". System default encoding used");
              }
  
              return new String(data, offset, length);
          }
      }
  
      /**
       * Converts the byte array of HTTP element characters to a string This
       * method is to be used when decoding content of HTTP elements (such as
       * response headers)
       *
       * @param data the byte array to be encoded
       * @return The resulting string.
       */
      public static String getString(final byte[] data) {
          return getString(data, 0, data.length);
      }
  
      /**
       * Converts the specified string to a byte array of HTTP content charachetrs
       * This method is to be used when encoding content of HTTP request/response
       * If the specified charset is not supported, default HTTP content encoding
       * (ISO-8859-1) is applied
       *
       * @param data the string to be encoded
       * @param charset the desired character encoding
       * @return The resulting byte array.
       */
      public static byte[] getContentBytes(final String data, String charset) {
  
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          if ((charset == null) || (charset.equals(""))) {
              charset = DEFAULT_CONTENT_CHARSET;
          }
  
          try {
              return data.getBytes(charset);
          } catch (UnsupportedEncodingException e) {
  
              if (LOG.isWarnEnabled()) {
                  LOG.warn("Unsupported encoding: " 
                      + charset 
                      + ". HTTP default encoding used");
              }
  
              try {
                  return data.getBytes(DEFAULT_CONTENT_CHARSET);
              } catch (UnsupportedEncodingException e2) {
  
                  if (LOG.isWarnEnabled()) {
                      LOG.warn("Unsupported encoding: " 
                          + DEFAULT_CONTENT_CHARSET 
                          + ". System encoding used");
                  }
  
                  return data.getBytes();
              }
          }
      }
  
      /**
       * Converts the byte array of HTTP content characters to a string This
       * method is to be used when decoding content of HTTP request/response If
       * the specified charset is not supported, default HTTP content encoding
       * (ISO-8859-1) is applied
       *
       * @param data the byte array to be encoded
       * @param offset the index of the first byte to encode
       * @param length the number of bytes to encode 
       * @param charset the desired character encoding
       * @return The result of the conversion.
       */
      public static String getContentString(
          final byte[] data, 
          int offset, 
          int length, 
          String charset
      ) {
  
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          if ((charset == null) || (charset.equals(""))) {
              charset = DEFAULT_CONTENT_CHARSET;
          }
  
          try {
              return new String(data, offset, length, charset);
          } catch (UnsupportedEncodingException e) {
  
              if (LOG.isWarnEnabled()) {
                  LOG.warn("Unsupported encoding: " 
                      + DEFAULT_CONTENT_CHARSET 
                      + ". Default HTTP encoding used");
              }
  
              try {
                  return new String(data, offset, length, DEFAULT_CONTENT_CHARSET);
              } catch (UnsupportedEncodingException e2) {
  
                  if (LOG.isWarnEnabled()) {
                      LOG.warn("Unsupported encoding: " 
                          + DEFAULT_CONTENT_CHARSET 
                          + ". System encoding used");
                  }
  
                  return new String(data, offset, length);
              }
          }
      }
  
  
      /**
       * Converts the byte array of HTTP content characters to a string This
       * method is to be used when decoding content of HTTP request/response If
       * the specified charset is not supported, default HTTP content encoding
       * (ISO-8859-1) is applied
       *
       * @param data the byte array to be encoded
       * @param charset the desired character encoding
       * @return The result of the conversion.
       */
      public static String getContentString(final byte[] data, String charset) {
          return getContentString(data, 0, data.length, charset);
      }
  
      /**
       * Converts the specified string to a byte array of HTTP content characters
       * using default HTTP content encoding (ISO-8859-1) This method is to be
       * used when encoding content of HTTP request/response
       *
       * @param data the string to be encoded
       * @return The byte array as above.
       */
      public static byte[] getContentBytes(final String data) {
          return getContentBytes(data, null);
      }
  
      /**
       * Converts the byte array of HTTP content characters to a string using
       * default HTTP content encoding (ISO-8859-1) This method is to be used when
       * decoding content of HTTP request/response
       *
       * @param data the byte array to be encoded
       * @param offset the index of the first byte to encode
       * @param length the number of bytes to encode 
       * @return The string representation of the byte array.
       */
      public static String getContentString(final byte[] data, int offset, int length) {
          return getContentString(data, offset, length, null);
      }
  
      /**
       * Converts the byte array of HTTP content characters to a string using
       * default HTTP content encoding (ISO-8859-1) This method is to be used when
       * decoding content of HTTP request/response
       *
       * @param data the byte array to be encoded
       * @return The string representation of the byte array.
       */
      public static String getContentString(final byte[] data) {
          return getContentString(data, null);
      }
  
      /**
       * Converts the specified string to byte array of ASCII characters.
       *
       * @param data the string to be encoded
       * @return The string as a byte array.
       */
      public static byte[] getAsciiBytes(final String data) {
  
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          try {
              return data.getBytes("US-ASCII");
          } catch (UnsupportedEncodingException e) {
              throw new RuntimeException("HttpClient requires ASCII support");
          }
      }
  
      /**
       * Converts the byte array of ASCII characters to a string. This method is
       * to be used when decoding content of HTTP elements (such as response
       * headers)
       *
       * @param data the byte array to be encoded
       * @param offset the index of the first byte to encode
       * @param length the number of bytes to encode 
       * @return The string representation of the byte array
       */
      public static String getAsciiString(final byte[] data, int offset, int length) {
  
          if (data == null) {
              throw new IllegalArgumentException("Parameter may not be null");
          }
  
          try {
              return new String(data, offset, length, "US-ASCII");
          } catch (UnsupportedEncodingException e) {
              throw new RuntimeException("HttpClient requires ASCII support");
          }
      }
  
      /**
       * Converts the byte array of ASCII characters to a string. This method is
       * to be used when decoding content of HTTP elements (such as response
       * headers)
       *
       * @param data the byte array to be encoded
       * @return The string representation of the byte array
       */
      public static String getAsciiString(final byte[] data) {
          return getAsciiString(data, 0, data.length);
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.BinaryDecoder#decode(byte[])
       */
      public byte[] decode(byte[] pArray) throws DecoderException {
          // TODO Auto-generated method stub
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.Decoder#decode(java.lang.Object)
       */
      public Object decode(Object pObject) throws DecoderException {
          // TODO Auto-generated method stub
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.StringEncoder#encode(java.lang.String)
       */
      public String encode(String pString) throws EncoderException {
          // TODO Auto-generated method stub
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.Encoder#encode(java.lang.Object)
       */
      public Object encode(Object pObject) throws EncoderException {
          // TODO Auto-generated method stub
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.StringDecoder#decode(java.lang.String)
       */
      public String decode(String pString) throws DecoderException {
          // TODO Auto-generated method stub
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
       */
      public byte[] encode(byte[] pArray) throws EncoderException {
          // TODO Auto-generated method stub
          return null;
      }
  }
  
  
  
  1.2       +6 -6      jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/FilePart.java
  
  Index: FilePart.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/FilePart.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilePart.java	12 Jan 2004 21:42:35 -0000	1.1
  +++ FilePart.java	15 Jan 2004 16:09:09 -0000	1.2
  @@ -69,7 +69,7 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   
  -import org.apache.commons.codec.multipart.util.*;
  +import org.apache.commons.codec.ascii.*;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -92,7 +92,7 @@
       public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
   
       /** Default charset of file attachments. */
  -    public static final String DEFAULT_CHARSET = Constants.DEFAULT_CONTENT_CHARSET;
  +    public static final String DEFAULT_CHARSET = AsciiUtils.DEFAULT_CONTENT_CHARSET;
   
       /** Default transfer encoding of file attachments. */
       public static final String DEFAULT_TRANSFER_ENCODING = "binary";
  @@ -105,7 +105,7 @@
   
       /** Attachment's file name as a byte array */
       protected static final byte[] FILE_NAME_BYTES = 
  -      Constants.getAsciiBytes(FILE_NAME);
  +      AsciiUtils.getAsciiBytes(FILE_NAME);
   
       /** Source of the file part. */
       private Source source;
  
  
  
  1.2       +5 -5      jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/StringPart.java
  
  Index: StringPart.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/StringPart.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringPart.java	12 Jan 2004 21:42:35 -0000	1.1
  +++ StringPart.java	15 Jan 2004 16:09:09 -0000	1.2
  @@ -66,7 +66,7 @@
   import java.io.OutputStream;
   import java.io.IOException;
   
  -import org.apache.commons.codec.multipart.util.*;
  +import org.apache.commons.codec.ascii.*;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -145,7 +145,7 @@
        */
       private byte[] getContent() {
           if (content == null) {
  -            content = Constants.getContentBytes(value, getCharSet());
  +            content = AsciiUtils.getContentBytes(value, getCharSet());
           }
           return content;
       }
  
  
  
  1.1                  jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/AbstractPart.java
  
  Index: AbstractPart.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/AbstractPart.java,v 1.1 2004/01/15 16:09:09 mdiggory Exp $
   * $Revision: 1.1 $
   * $Date: 2004/01/15 16:09:09 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
   
  package org.apache.commons.codec.multipart;
  
  import java.io.IOException;
  import java.io.OutputStream;
  
  
  
  /**
   * Provides setters and getters for the basic Part properties.
   * 
   * @author Michael Becke
   * @author <a href="mailto:mdiggory@latte.harvard.edu">Mark Diggory</a>
   */
  public abstract class AbstractPart implements Part {
  
      /** Name of the file part. */
      private String name;
          
      /** Content type of the file part. */
      private String contentType;
  
      /** Content encoding of the file part. */
      private String charSet;
      
      /** The transfer encoding. */
      private String transferEncoding;
  
      /**
       * Constructor.
       * 
       * @param name The name of the part
       * @param contentType The content type, or <code>null</code>
       * @param charSet The character encoding, or <code>null</code> 
       * @param transferEncoding The transfer encoding, or <code>null</code>
       */
      public AbstractPart(String name, String contentType, String charSet, String transferEncoding) {
  
          if (name == null) {
              throw new IllegalArgumentException("Name must not be null");
          }
          this.name = name;
          this.contentType = contentType;
          this.charSet = charSet;
          this.transferEncoding = transferEncoding;
      }
  
      /**
       * Returns the name.
       * @return The name.
       * @see org.apache.commons.codec.multipart.multipart.OldPart#getName()
       */
      public String getName() { 
          return this.name; 
      }
  
      /**
       * Returns the content type of this part.
       * @return String The name.
       */
      public String getContentType() {
          return this.contentType;
      }
  
      /**
       * Return the character encoding of this part.
       * @return String The name.
       */
      public String getCharSet() {
          return this.charSet;
      }
  
      /**
       * Returns the transfer encoding of this part.
       * @return String The name.
       */
      public String getTransferEncoding() {
          return transferEncoding;
      }
  
      /**
       * Sets the character encoding.
       * 
       * @param charSet the character encoding, or <code>null</code> to exclude the character 
       * encoding header
       */
      public void setCharSet(String charSet) {
          this.charSet = charSet;
      }
  
      /**
       * Sets the content type.
       * 
       * @param contentType the content type, or <code>null</code> to exclude the content type header
       */
      public void setContentType(String contentType) {
          this.contentType = contentType;
      }
  
      /**
       * Sets the part name.
       * 
       * @param name
       */
      public void setName(String name) {
          if (name == null) {
              throw new IllegalArgumentException("Name must not be null");
          }
          this.name = name;
      }
  
      /**
       * Sets the transfer encoding.
       * 
       * @param transferEncoding the transfer encoding, or <code>null</code> to exclude the 
       * transfer encoding header
       */
      public void setTransferEncoding(String transferEncoding) {
          this.transferEncoding = transferEncoding;
      }
  
      /**
       * Return a string representation of this object.
       * @return A string representation of this object.
       * @see java.lang.Object#toString()
       */    
      public String toString() {
      	return this.getName();
      }
      
      /**
       * Write the data to the specified output stream
       * @param out The output stream
       * @throws IOException If an IO problem occurs.
       */
      public abstract void writeTo(OutputStream out) throws IOException;
      
      /**
       * Return the length of the main content
       * 
       * @return long The length.
       * @throws IOException If an IO problem occurs
       */
      public abstract long length() throws IOException;
      
  }
  
  
  
  1.2       +16 -16    jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/spi/MultipartFormDataProvider.java
  
  Index: MultipartFormDataProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/codec-multipart/src/java/org/apache/commons/codec/multipart/spi/MultipartFormDataProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultipartFormDataProvider.java	12 Jan 2004 21:42:36 -0000	1.1
  +++ MultipartFormDataProvider.java	15 Jan 2004 16:09:09 -0000	1.2
  @@ -68,7 +68,7 @@
   
   import org.apache.commons.codec.multipart.*;
   import org.apache.commons.codec.multipart.Part;
  -import org.apache.commons.codec.multipart.util.*;
  +import org.apache.commons.codec.ascii.*;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -93,25 +93,25 @@
   
   	/** The boundary as a byte array */
   	protected static final byte[] BOUNDARY_BYTES =
  -		Constants.getAsciiBytes(BOUNDARY);
  +		AsciiUtils.getAsciiBytes(BOUNDARY);
   
   	/** Carriage return/linefeed */
   	protected static final String CRLF = "\r\n";
   
   	/** Carriage return/linefeed as a byte array */
  -	protected static final byte[] CRLF_BYTES = Constants.getAsciiBytes(CRLF);
  +	protected static final byte[] CRLF_BYTES = AsciiUtils.getAsciiBytes(CRLF);
   
   	/** Content dispostion characters */
   	protected static final String QUOTE = "\"";
   
   	/** Content dispostion as a byte array */
  -	protected static final byte[] QUOTE_BYTES = Constants.getAsciiBytes(QUOTE);
  +	protected static final byte[] QUOTE_BYTES = AsciiUtils.getAsciiBytes(QUOTE);
   
   	/** Extra characters */
   	protected static final String EXTRA = "--";
   
   	/** Extra characters as a byte array */
  -	protected static final byte[] EXTRA_BYTES = Constants.getAsciiBytes(EXTRA);
  +	protected static final byte[] EXTRA_BYTES = AsciiUtils.getAsciiBytes(EXTRA);
   
   	/** Content dispostion characters */
   	protected static final String CONTENT_DISPOSITION =
  @@ -119,21 +119,21 @@
   
   	/** Content dispostion as a byte array */
   	protected static final byte[] CONTENT_DISPOSITION_BYTES =
  -		Constants.getAsciiBytes(CONTENT_DISPOSITION);
  +		AsciiUtils.getAsciiBytes(CONTENT_DISPOSITION);
   
   	/** Content type header */
   	protected static final String CONTENT_TYPE = "Content-Type: ";
   
   	/** Content type header as a byte array */
   	protected static final byte[] CONTENT_TYPE_BYTES =
  -		Constants.getAsciiBytes(CONTENT_TYPE);
  +		AsciiUtils.getAsciiBytes(CONTENT_TYPE);
   
   	/** Content charset */
   	protected static final String CHARSET = "; charset=";
   
   	/** Content charset as a byte array */
   	protected static final byte[] CHARSET_BYTES =
  -		Constants.getAsciiBytes(CHARSET);
  +		AsciiUtils.getAsciiBytes(CHARSET);
   
   	/** Content type header */
   	protected static final String CONTENT_TRANSFER_ENCODING =
  @@ -141,7 +141,7 @@
   
   	/** Content type header as a byte array */
   	protected static final byte[] CONTENT_TRANSFER_ENCODING_BYTES =
  -		Constants.getAsciiBytes(CONTENT_TRANSFER_ENCODING);
  +		AsciiUtils.getAsciiBytes(CONTENT_TRANSFER_ENCODING);
   
   	/**
   	 * Return the total sum of all parts and that of the last boundary
  @@ -189,7 +189,7 @@
   		log.trace("enter sendDispositionHeader(OutputStream out)");
   		out.write(CONTENT_DISPOSITION_BYTES);
   		out.write(QUOTE_BYTES);
  -		out.write(Constants.getAsciiBytes(part.getName()));
  +		out.write(AsciiUtils.getAsciiBytes(part.getName()));
   		out.write(QUOTE_BYTES);
   	}
   
  @@ -208,11 +208,11 @@
   		if (contentType != null) {
   			out.write(CRLF_BYTES);
   			out.write(CONTENT_TYPE_BYTES);
  -			out.write(Constants.getAsciiBytes(contentType));
  +			out.write(AsciiUtils.getAsciiBytes(contentType));
   			String charSet = part.getCharSet();
   			if (charSet != null) {
   				out.write(CHARSET_BYTES);
  -				out.write(Constants.getAsciiBytes(charSet));
  +				out.write(AsciiUtils.getAsciiBytes(charSet));
   			}
   		}
   	}
  @@ -235,7 +235,7 @@
   		if (transferEncoding != null) {
   			out.write(CRLF_BYTES);
   			out.write(CONTENT_TRANSFER_ENCODING_BYTES);
  -			out.write(Constants.getAsciiBytes(transferEncoding));
  +			out.write(AsciiUtils.getAsciiBytes(transferEncoding));
   		}
   	}
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org