Class ContentDispositionParser

  • All Implemented Interfaces:
    ContentDisposition

    public class ContentDispositionParser
    extends org.simpleframework.common.parse.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
    • Field Summary

      • Fields inherited from class org.simpleframework.common.parse.Parser

        buf, count, off
    • Constructor Summary

      Constructors 
      Constructor Description
      ContentDispositionParser()
      Constructor for the ContentDispositionParser object.
      ContentDispositionParser​(java.lang.String text)
      Constructor for the ContentDispositionParser 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 the Parser when it is ready to parse a new String.
      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.
      • Methods inherited from class org.simpleframework.common.parse.Parser

        digit, ensureCapacity, parse, skip, space, toLower
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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​(java.lang.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 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 interface ContentDisposition
        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 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 org.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 class org.simpleframework.common.parse.Parser