org.apache.struts.upload

Class MultipartValueStream


(package private) class MultipartValueStream
extends InputStream

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

static String
HEADER_ENCODING
private byte[]
boundaryBytes
byte buffer with the boundary
private boolean
boundaryReached
have we reached the boundary?
private boolean
finalBoundaryReached
is the boundary found a final boundary?
private InputStream
in
the underlying stream
private int
matchedBoundaryBytes
how many curretly matched boundary bytes?
private int
readAheadBufferEndI
The end index for the read ahead cyclic buffer (points to the last byte)
private int
readAheadBufferStartI
The start index for the read ahead cyclic buffer (points to the first byte)
private 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

boolean
encounteredFinalBoundary()
int
read()
Read the next byte

Field Details

HEADER_ENCODING

public static final String HEADER_ENCODING

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?

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 Details

MultipartValueStream

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

Method Details

encounteredFinalBoundary

public boolean encounteredFinalBoundary()
            throws ServletException
Returns:
true if we are the last stream, ie. we encountered a final boundary

read

public int read()
            throws IOException
Read the next byte
Returns:
-1 on boundary reached

Copyright B) 2000-2007 - The Apache Software Foundation