| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.apache.struts.upload.MultipartBoundaryInputStream
This class encapsulates parsing functionality for RFC1867, multipart/form-data. See MultipartBoundaryInputStreamTest and MultipartIterator for usage examples.
| Field Summary | |
| protected  java.lang.String | boundaryThe boundary. | 
| private  byte[] | boundaryBytes | 
| protected  boolean | boundaryEncounteredWhether or not the boundary has been encountered. | 
| protected  long | bytesReadThe total number of bytes read so far. | 
| private static byte | CARRIAGE_RETURN | 
| private static java.lang.String | CONTENT_TYPE_APPLICATION_OCTET_STREAM | 
| private static java.lang.String | CONTENT_TYPE_TEXT_PLAIN | 
| private static byte[] | CRLF | 
| private static java.lang.String | DEFAULT_CONTENT_DISPOSITION | 
| private static int | DEFAULT_LINE_SIZE | 
| private static java.lang.String | DOUBLE_DASH_STRING | 
| protected  java.lang.String | elementCharsetThe character encoding of the element, specified in the element's Content-Type header. | 
| protected  java.lang.String | elementContentDispositionThe Content-Disposition for the current form element being read. | 
| protected  java.lang.String | elementContentTypeThe Content-Type of the current form element being read. | 
| protected  java.lang.String | elementFileNameThe filename of the current form element being read, nullif the current form element is
 text data. | 
| protected  java.lang.String | elementNameThe name of the current form element being read. | 
| protected  boolean | endOfStreamWhether or not the end of the stream has been read. | 
| private  byte[] | finalBoundaryBytes | 
| protected  boolean | finalBoundaryEncounteredWhether or not the final boundary has been encountered. | 
| protected  java.io.InputStream | inputStreamThe InputStream to read from. | 
| private  byte[] | line | 
| private  boolean | lineHasCarriage | 
| private  boolean | lineHasNewline | 
| private  int | lineIndex | 
| private  int | lineLength | 
| private  int | lineSize | 
| protected  long | maxLengthThe maximum length in bytes to read from the stream at a time, or -1 for unlimited length. | 
| protected  boolean | maxLengthMetWhether or not the maximum length has been met. | 
| private static java.lang.String | MESSAGE_INVALID_START | 
| private static byte | NEWLINE_BYTE | 
| private static java.lang.String | PARAMETER_CHARSET | 
| private static java.lang.String | PARAMETER_FILENAME | 
| private static java.lang.String | PARAMETER_NAME | 
| private static char | TOKEN_COLON | 
| private static java.lang.String | TOKEN_EQUALS | 
| private static char | TOKEN_QUOTE | 
| private static char | TOKEN_SEMI_COLON | 
| private static char | TOKEN_SPACE | 
| Fields inherited from class java.io.InputStream | 
|  | 
| Constructor Summary | |
| MultipartBoundaryInputStream() | |
| Method Summary | |
| private  int | availableInLine() | 
| private  void | byteRead() | 
| private  java.lang.String | checkAndFixFilename(java.lang.String filename) | 
| private  void | checkForBoundary() | 
| private  boolean | equals(byte[] comp,
       int offset,
       int length,
       byte[] source)Checks bytes for equality. | 
| private  void | fillLine() | 
| private  void | fillLineBuffer() | 
|  long | getBytesRead() | 
|  java.lang.String | getElementCharset()Gets the character encoding of the current element. | 
|  java.lang.String | getElementContentDisposition()Gets the value for the "Content-Dispositio" header for the current multipart element. | 
|  java.lang.String | getElementContentType()Gets the "Content-Type" of the current element. | 
|  java.lang.String | getElementFileName()Gets the filename of the current element, which will be null if the current element isn't a file. | 
|  java.lang.String | getElementName()Gets the name of the current element. | 
|  long | getMaxLength() | 
|  boolean | isBoundaryEncountered()Returns whether or not the boundary has been encountered while reading data. | 
|  boolean | isElementFile()Gets whether or not the current form element being read is a file. | 
|  boolean | isEndOfStream()Whether or not an EOF has been read on the stream. | 
|  boolean | isFinalBoundaryEncountered()Returns whether or not the final boundary has been encountered. | 
|  boolean | isMaxLengthMet()Whether or not the maximum length has been met. | 
|  void | mark(int i)Marks the underlying stream. | 
| private  java.lang.String | parseForParameter(java.lang.String parameter,
                  java.lang.String parseString) | 
| private  java.lang.String | parseHeaderValue(java.lang.String headerLine) | 
|  int | read()Reads from the stream. | 
|  int | read(byte[] buffer) | 
|  int | read(byte[] buffer,
     int offset,
     int length) | 
| private  void | readContentDisposition() | 
| private  boolean | readContentType() | 
| private  void | readElementHeaders() | 
| private  void | readFirstElement() | 
| private  int | readFromLine() | 
| private  java.lang.String | readLine() | 
|  void | reset()Resets the underlying input stream. | 
| private  void | resetCrlf() | 
|  void | resetForNextBoundary()Resets this stream for use with the next element, to be used after a boundary is encountered. | 
| private  void | resetLine() | 
| private  void | resetStream() | 
|  void | setBoundary(java.lang.String boundary)Sets the boundary that terminates the data for the stream, after adding the prefix "--" | 
|  void | setInputStream(java.io.InputStream stream)Sets the input stream used to read multipart data. | 
|  void | setLineSize(int size) | 
|  void | setMaxLength(long maxLength)Set the maximum length in bytes to read, or -1 for an unlimited length. | 
| private  void | skipCurrentLineIfBlank() | 
| Methods inherited from class java.io.InputStream | 
| available, close, markSupported, skip | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
private static final byte NEWLINE_BYTE
private static final byte CARRIAGE_RETURN
private static final byte[] CRLF
private static final java.lang.String DOUBLE_DASH_STRING
private static final int DEFAULT_LINE_SIZE
private static final java.lang.String TOKEN_EQUALS
private static final char TOKEN_QUOTE
private static final char TOKEN_COLON
private static final char TOKEN_SEMI_COLON
private static final char TOKEN_SPACE
private static final java.lang.String DEFAULT_CONTENT_DISPOSITION
private static final java.lang.String PARAMETER_NAME
private static final java.lang.String PARAMETER_FILENAME
private static final java.lang.String PARAMETER_CHARSET
private static final java.lang.String CONTENT_TYPE_TEXT_PLAIN
private static final java.lang.String CONTENT_TYPE_APPLICATION_OCTET_STREAM
private static final java.lang.String MESSAGE_INVALID_START
protected java.io.InputStream inputStream
protected java.lang.String boundary
protected boolean boundaryEncountered
protected boolean finalBoundaryEncountered
protected boolean endOfStream
protected java.lang.String elementContentDisposition
protected java.lang.String elementName
protected java.lang.String elementContentType
protected java.lang.String elementFileName
null if the current form element is
 text data.
protected java.lang.String elementCharset
protected long maxLength
protected boolean maxLengthMet
protected long bytesRead
private byte[] boundaryBytes
private byte[] finalBoundaryBytes
private byte[] line
private int lineSize
private int lineLength
private boolean lineHasNewline
private boolean lineHasCarriage
private int lineIndex
| Constructor Detail | 
public MultipartBoundaryInputStream()
| Method Detail | 
public void setBoundary(java.lang.String boundary)
public void resetForNextBoundary()
                          throws java.io.IOException
java.io.IOException
public void setInputStream(java.io.InputStream stream)
                    throws java.io.IOException
java.io.IOException
public int read()
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] buffer)
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int i)
mark in class java.io.InputStream
public void reset()
           throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionpublic void setMaxLength(long maxLength)
public long getMaxLength()
public boolean isMaxLengthMet()
public java.lang.String getElementContentDisposition()
public java.lang.String getElementName()
public java.lang.String getElementCharset()
public java.lang.String getElementContentType()
public java.lang.String getElementFileName()
public boolean isElementFile()
public boolean isBoundaryEncountered()
public boolean isFinalBoundaryEncountered()
public boolean isEndOfStream()
public void setLineSize(int size)
public long getBytesRead()
private final void readFirstElement()
                             throws java.io.IOException
java.io.IOException
private final void readElementHeaders()
                               throws java.io.IOException
java.io.IOException
private final void readContentDisposition()
                                   throws java.io.IOException
java.io.IOExceptionprivate final java.lang.String checkAndFixFilename(java.lang.String filename)
private final java.lang.String parseForParameter(java.lang.String parameter,
                                                 java.lang.String parseString)
private final boolean readContentType()
                               throws java.io.IOException
java.io.IOExceptionprivate final java.lang.String parseHeaderValue(java.lang.String headerLine)
private final void skipCurrentLineIfBlank()
                                   throws java.io.IOException
java.io.IOExceptionprivate final void resetCrlf()
private final void resetStream()
private final java.lang.String readLine()
                                 throws java.io.IOException
java.io.IOException
private final int readFromLine()
                        throws java.io.IOException
java.io.IOExceptionprivate final int availableInLine()
private final void fillLine()
                     throws java.io.IOException
java.io.IOExceptionprivate final void resetLine()
private final void fillLineBuffer()
                           throws java.io.IOException
java.io.IOExceptionprivate final void byteRead()
private final void checkForBoundary()
private final boolean equals(byte[] comp,
                             int offset,
                             int length,
                             byte[] source)
comp - The byte to compare to sourceoffset - The offset to start at in complength - The length of comp to compare tosource - The reference byte array to test for equality| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||