Class ContentDispositionParser
java.lang.Object
org.simpleframework.common.parse.Parser
org.simpleframework.http.parse.ContentDispositionParser
- All Implemented Interfaces:
ContentDisposition
The
ContentDispositionParser object is used to represent
a parser used to parse the Content-Disposition header. Its used when
there is a multipart form upload to the server and allows the
server to determine the individual part types.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ParseBufferThis is used to capture the name of the file if it is provided.private booleanThis is used to determine if the disposition is a file or form.private ParseBufferThis is used to capture the name of the part if it is provided.private ParseBufferThis is the buffer used to acquire values from the header. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for theContentDispositionParserobject.Constructor for theContentDispositionParserobject. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclear()This is used to clear all previously collected tokens.This method is used to acquire the file name of the part.getName()This method is used to acquire the name of the part.protected voidinit()This will initialize theParserwhen it is ready to parse a newString.booleanisFile()This method is used to determine the type of a part.private voidname()This will simply read all characters from the buffer before the first '=' character.private voidpack()This is used to remove all whitespace characters from theStringexcluding the whitespace within literals.private voidThis will read the parameters from the header value.private voidThis will read the parameters from the header value.protected voidparse()This is the method that should be implemented to read the buffer.private booleanquote(char ch) This method is used to determine if the specified character is a quote character.private voidtype()This is used to determine the type of the disposition header.private voidvalue(ParseBuffer value) This is used to read a parameters value from the buf.
-
Field Details
-
skip
This is the buffer used to acquire values from the header. -
file
This is used to capture the name of the file if it is provided. -
name
This is used to capture the name of the part if it is provided. -
form
private boolean formThis is used to determine if the disposition is a file or form.
-
-
Constructor Details
-
ContentDispositionParser
public ContentDispositionParser()Constructor for theContentDispositionParserobject. This is used to create a parser that can parse a disposition header which is typically sent as part of a multipart upload. It can be used to determine the type of the upload. -
ContentDispositionParser
Constructor for theContentDispositionParserobject. This is used to create a parser that can parse a disposition header which is typically sent as part of a multipart upload. It can be used to determine the type of the upload.- Parameters:
text- this is the header value that is to be parsed
-
-
Method Details
-
getFileName
This method is used to acquire the file name of the part. This is used when the part represents a text parameter rather than a file. However, this can also be used with a file part.- Specified by:
getFileNamein interfaceContentDisposition- Returns:
- this returns the file name of the associated part
-
getName
This method is used to acquire the name of the part. Typically this is used when the part represents a text parameter rather than a file. However, this can also be used with a file part.- Specified by:
getNamein interfaceContentDisposition- Returns:
- this returns the name of the associated part
-
isFile
public boolean isFile()This method is used to determine the type of a part. Typically a part is either a text parameter or a file. If this is true then the content represented by the associated part is a file.- Specified by:
isFilein interfaceContentDisposition- Returns:
- this returns true if the associated part is a file
-
init
protected void init()This will initialize theParserwhen it is ready to parse a newString. This will reset the parser to a ready state. This method is invoked by the parser before the parse method is invoked, it is used to pack the contents of the header and clear any previous tokens used. -
clear
protected void clear()This is used to clear all previously collected tokens. This allows the parser to be reused when there are multiple source strings to be parsed. Clearing of the tokens is performed when the parser is initialized. -
parse
-
pack
private void pack()This is used to remove all whitespace characters from theStringexcluding the whitespace within literals. The definition of a literal can be found in RFC 2616.The definition of a literal for RFC 2616 is anything between 2 quotes but excuding quotes that are prefixed with the backward slash character.
-
type
private void type()This is used to determine the type of the disposition header. This will allow the parser to determine it the header represents form data or a file upload. Once it determines the type of the upload header it sets an internal flag which can be used. -
parameters
private void parameters()This will read the parameters from the header value. This will search for thefilenameparameter within the set of parameters which are given to the type. Thefilenameparam and the thenameare tokenized by this method. -
parameter
private void parameter()This will read the parameters from the header value. This will search for thefilenameparameter within the set of parameters which are given to the type. Thefilenameparam and the thenameare tokenized by this method. -
name
private void name()This will simply read all characters from the buffer before the first '=' character. This represents a parameter name (see RFC 2616 for token). The parameter name is not buffered it is simply read from the buffer. This will not cause anIndexOutOfBoundsExceptionas each offset is checked before it is acccessed. -
value
This is used to read a parameters value from the buf. This will read allchar's upto but excluding the first terminalcharencountered from the off within the buf, or if the value is a literal it will read a literal from the buffer (literal is any data between quotes except if the quote is prefixed with a backward slash character).- Parameters:
value- this is the parse buffer to append the value to
-
quote
private boolean quote(char ch) This method is used to determine if the specified character is a quote character. The quote character is typically used as a boundary for the values within the header. This accepts a single or double quote.- Parameters:
ch- the character to determine if it is a quotation- Returns:
- true if the character provided is a quotation character
-