Package au.id.villar.web.mfd
Class Part
java.lang.Object
au.id.villar.web.mfd.Part
Object representing a part detected when parsing an HTTP multipart request body.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the stream representing this part's body.Returns the field "filename" from the Content-Disposition header.Retrieves all headers found when parsing the part represented by this object.getHeaderValue(String headerName) Retrieves the first value found for a header.getHeaderValues(String headerName) Retrieves all the values found for a given header.getName()Returns the field "name" from the Content-Disposition header.Convenience method to read this part's body into a singleString.readBodyText(Charset charset) Convenience method to read this part's body into a singleString.
-
Method Details
-
getHeaderValue
Retrieves the first value found for a header.- Parameters:
headerName- the name of the header whose value is requested.- Returns:
- The first value found for the given header.
-
getHeaderValues
Retrieves all the values found for a given header.- Parameters:
headerName- the name of the header whose values are requested.- Returns:
- A list containing all values found for the given header.
-
getHeaderNames
Retrieves all headers found when parsing the part represented by this object.- Returns:
- A
Listcontaining all headers found when parsing the part represented by this object.
-
getName
Returns the field "name" from the Content-Disposition header.- Returns:
- The value of the field "name" from the Content-Disposition header, or
nullif it wasn't found.
-
getFilename
Returns the field "filename" from the Content-Disposition header.- Returns:
- The value of the field "filename" from the Content-Disposition header, or
nullotherwise.
-
getBodyStream
Returns the stream representing this part's body. ThisInputStreamis not reset every time this method is called, it rather returns the same instance every time. This instance may return EOF (-1) if it has been already consumed by one of the convenience methodsreadBodyText()orreadBodyText(Charset).- Returns:
- the
InputStreamrepresenting this part's body.
-
readBodyText
Convenience method to read this part's body into a singleString.- Returns:
- A
Stringcontaining this part's body. - Throws:
IOException- If the underlyingInputStreamthrows this exception.
-
readBodyText
Convenience method to read this part's body into a singleString.- Parameters:
charset- TheCharsetused to parse this Part's body into aString- Returns:
- A
Stringcontaining this part's body. - Throws:
IOException- If the underlyingInputStreamthrows this exception.
-