Skip navigation links

Oracle® WebCenter Content Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-03


oracle.stellent.wcm.common.http
Class MultipartBoundaryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by oracle.stellent.wcm.common.http.MultipartBoundaryInputStream

All Implemented Interfaces:
java.io.Closeable

public class MultipartBoundaryInputStream
extends java.io.InputStream

This class encapsulates parsing functionality for RFC1867, multipart/form-data. See MultipartBoundaryInputStreamTest and MultipartIterator for usage examples.


Field Summary
protected  java.lang.String boundary
          The boundary.
protected  boolean boundaryEncountered
          Whether or not the boundary has been encountered.
protected  long bytesRead
          The total number of bytes read so far.
protected  java.lang.String elementCharset
          The character encoding of the element, specified in the element's Content-Type header.
protected  java.lang.String elementContentDisposition
          The Content-Disposition for the current form element being read.
protected  java.lang.String elementContentType
          The Content-Type of the current form element being read.
protected  java.lang.String elementFileName
          The filename of the current form element being read, null if the current form element is text data.
protected  java.lang.String elementName
          The name of the current form element being read.
protected  boolean endOfStream
          Whether or not the end of the stream has been read.
protected  boolean finalBoundaryEncountered
          Whether or not the final boundary has been encountered.
protected  java.io.InputStream inputStream
          The InputStream to read from.
protected  long maxLength
          The maximum length in bytes to read from the stream at a time, or -1 for unlimited length.
protected  boolean maxLengthMet
          Whether or not the maximum length has been met.

 

Constructor Summary
MultipartBoundaryInputStream()
           

 

Method Summary
 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.
 int read()
          Reads from the stream.
 int read(byte[] buffer)
           
 int read(byte[] buffer, int offset, int length)
           
 void reset()
          Resets the underlying input stream.
 void resetForNextBoundary()
          Resets this stream for use with the next element, to be used after a boundary is encountered.
 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.

 

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

inputStream

protected java.io.InputStream inputStream
The InputStream to read from.

boundary

protected java.lang.String boundary
The boundary.

boundaryEncountered

protected boolean boundaryEncountered
Whether or not the boundary has been encountered.

finalBoundaryEncountered

protected boolean finalBoundaryEncountered
Whether or not the final boundary has been encountered.

endOfStream

protected boolean endOfStream
Whether or not the end of the stream has been read.

elementContentDisposition

protected java.lang.String elementContentDisposition
The Content-Disposition for the current form element being read.

elementName

protected java.lang.String elementName
The name of the current form element being read.

elementContentType

protected java.lang.String elementContentType
The Content-Type of the current form element being read.

elementFileName

protected java.lang.String elementFileName
The filename of the current form element being read, null if the current form element is text data.

elementCharset

protected java.lang.String elementCharset
The character encoding of the element, specified in the element's Content-Type header.

maxLength

protected long maxLength
The maximum length in bytes to read from the stream at a time, or -1 for unlimited length.

maxLengthMet

protected boolean maxLengthMet
Whether or not the maximum length has been met.

bytesRead

protected long bytesRead
The total number of bytes read so far.

Constructor Detail

MultipartBoundaryInputStream

public MultipartBoundaryInputStream()

Method Detail

setBoundary

public void setBoundary(java.lang.String boundary)
Sets the boundary that terminates the data for the stream, after adding the prefix "--"

resetForNextBoundary

public void resetForNextBoundary()
                          throws java.io.IOException
Resets this stream for use with the next element, to be used after a boundary is encountered.
Throws:
java.io.IOException

setInputStream

public void setInputStream(java.io.InputStream stream)
                    throws java.io.IOException
Sets the input stream used to read multipart data. For efficiency purposes, make sure that the stream you set on this class is buffered. The way this class reads lines is that it continually calls the read() method until it reaches a newline character. That would be terrible if you were to set a socket's input stream here, but not as bad on a buffered stream.
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Reads from the stream. Returns -1 if it's the end of the stream or if a boundary is encountered.
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] buffer)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int i)
Marks the underlying stream.
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Resets the underlying input stream.
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

setMaxLength

public void setMaxLength(long maxLength)
Set the maximum length in bytes to read, or -1 for an unlimited length.

getMaxLength

public long getMaxLength()

isMaxLengthMet

public boolean isMaxLengthMet()
Whether or not the maximum length has been met.

getElementContentDisposition

public java.lang.String getElementContentDisposition()
Gets the value for the "Content-Dispositio" header for the current multipart element. Usually "form-data".

getElementName

public java.lang.String getElementName()
Gets the name of the current element. The name corresponds to the value of the "name" attribute of the form element.

getElementCharset

public java.lang.String getElementCharset()
Gets the character encoding of the current element. The character encoding would have been specified in the Content-Type header for this element, if it wasn't this is null.

getElementContentType

public java.lang.String getElementContentType()
Gets the "Content-Type" of the current element. If this is a text element, the content type will probably be "text/plain", otherwise it will be the content type of the file element.

getElementFileName

public java.lang.String getElementFileName()
Gets the filename of the current element, which will be null if the current element isn't a file.

isElementFile

public boolean isElementFile()
Gets whether or not the current form element being read is a file.

isBoundaryEncountered

public boolean isBoundaryEncountered()
Returns whether or not the boundary has been encountered while reading data.

isFinalBoundaryEncountered

public boolean isFinalBoundaryEncountered()
Returns whether or not the final boundary has been encountered.

isEndOfStream

public boolean isEndOfStream()
Whether or not an EOF has been read on the stream.

setLineSize

public void setLineSize(int size)

getBytesRead

public long getBytesRead()

Skip navigation links

Oracle® WebCenter Content Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-03


Copyright © 2010, 2011, Oracle and/or its affiliates. All rights reserved.