Class ContentDispositionParser

java.lang.Object
org.simpleframework.common.parse.Parser
org.simpleframework.http.parse.ContentDispositionParser
All Implemented Interfaces:
ContentDisposition

public class ContentDispositionParser extends Parser implements 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.
Author:
Niall Gallagher
  • Constructor Details

    • ContentDispositionParser

      public ContentDispositionParser()
      Constructor for the ContentDispositionParser 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(String text)
      Constructor for the ContentDispositionParser 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 Details

    • getFileName

      public 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 interface ContentDisposition
      Returns:
      this returns the file name of the associated part
    • getName

      public 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 interface ContentDisposition
      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 interface ContentDisposition
      Returns:
      this returns true if the associated part is a file
    • init

      protected void init()
      This will initialize the Parser when it is ready to parse a new String. 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 class 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 class Parser