Package org.simpleframework.http.parse
Class ContentDispositionParser
- java.lang.Object
-
- org.simpleframework.common.parse.Parser
-
- org.simpleframework.http.parse.ContentDispositionParser
-
- All Implemented Interfaces:
ContentDisposition
public class ContentDispositionParser extends org.simpleframework.common.parse.Parser implements ContentDisposition
TheContentDispositionParser
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.- Author:
- Niall Gallagher
-
-
Constructor Summary
Constructors Constructor Description ContentDispositionParser()
Constructor for theContentDispositionParser
object.ContentDispositionParser(java.lang.String text)
Constructor for theContentDispositionParser
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clear()
This is used to clear all previously collected tokens.java.lang.String
getFileName()
This method is used to acquire the file name of the part.java.lang.String
getName()
This method is used to acquire the name of the part.protected void
init()
This will initialize theParser
when it is ready to parse a newString
.boolean
isFile()
This method is used to determine the type of a part.protected void
parse()
This is the method that should be implemented to read the buffer.
-
-
-
Constructor Detail
-
ContentDispositionParser
public ContentDispositionParser()
Constructor for theContentDispositionParser
object. 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
public ContentDispositionParser(java.lang.String text)
Constructor for theContentDispositionParser
object. 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 Detail
-
getFileName
public java.lang.String 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:
getFileName
in interfaceContentDisposition
- Returns:
- this returns the file name of the associated part
-
getName
public java.lang.String 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:
getName
in 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:
isFile
in interfaceContentDisposition
- Returns:
- this returns true if the associated part is a file
-
init
protected void init()
This will initialize theParser
when 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.- Specified by:
init
in classorg.simpleframework.common.parse.Parser
-
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
protected void parse()
This is the method that should be implemented to read the buffer. This method will extract the type from the header and the tries to extract the optional parameters if they are in the header. The optional parts are the file name and name.- Specified by:
parse
in classorg.simpleframework.common.parse.Parser
-
-