org.apache.struts.upload

Class MultipartValueStream

class MultipartValueStream extends InputStream

Deprecated: Use the Commons FileUpload based multipart handler instead. This class will be removed after Struts 1.2.

This class implements an inputStream that reads another stream until a multipart boundary is found. The class reports eof when boundary found. The undelying stream is not closed.

See RFC 1867 (http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1867.txt) for details about the protocol.

Field Summary
byte[]boundaryBytes
byte buffer with the boundary
booleanboundaryReached
have we reached the boundary?
booleanfinalBoundaryReached
is the boundary found a final boundary?
static StringHEADER_ENCODING
InputStreamin
the underlying stream
intmatchedBoundaryBytes
how many curretly matched boundary bytes?
intreadAheadBufferEndI
The end index for the read ahead cyclic buffer (points to the last byte)
intreadAheadBufferStartI
The start index for the read ahead cyclic buffer (points to the first byte)
byte[]readAheadBytes
the read ahead buffer (cyclic)
Constructor Summary
MultipartValueStream(InputStream in, String boundary)
Create a stream that stops reading at the boundary NOTE: the boundary parameter is without the trailing dashes "--".
Method Summary
booleanencounteredFinalBoundary()
intread()
Read the next byte

Field Detail

boundaryBytes

private byte[] boundaryBytes
byte buffer with the boundary

boundaryReached

private boolean boundaryReached
have we reached the boundary?

finalBoundaryReached

private boolean finalBoundaryReached
is the boundary found a final boundary?

HEADER_ENCODING

public static final String HEADER_ENCODING

in

private InputStream in
the underlying stream

matchedBoundaryBytes

private int matchedBoundaryBytes
how many curretly matched boundary bytes?

readAheadBufferEndI

private int readAheadBufferEndI
The end index for the read ahead cyclic buffer (points to the last byte)

readAheadBufferStartI

private int readAheadBufferStartI
The start index for the read ahead cyclic buffer (points to the first byte)

readAheadBytes

private byte[] readAheadBytes
the read ahead buffer (cyclic)

Constructor Detail

MultipartValueStream

public MultipartValueStream(InputStream in, String boundary)
Create a stream that stops reading at the boundary NOTE: the boundary parameter is without the trailing dashes "--".

Method Detail

encounteredFinalBoundary

public boolean encounteredFinalBoundary()

Returns: true if we are the last stream, ie. we encountered a final boundary false otherwise

Throws: ServletException if the boundary has not yet been reached

read

public int read()
Read the next byte

Returns: -1 on boundary reached

Throws: IOException if the ending boundary is never found

Copyright B) 2000-2008 - The Apache Software Foundation