Interface Segment

All Known Subinterfaces:
Header
All Known Implementing Classes:
HeaderConsumer, PartHeaderConsumer, RequestConsumer, SegmentConsumer

public interface Segment
The Segment object represents a collection of header values that is followed by a body. This is used to represent the header of a multipart upload part. The raw value of each header for the part can be acquired using this interface, also the type and the disposition of the body can be determined from this.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    This is a convenience method that can be used to determine the length of the message body.
    This is a convenience method that can be used to determine the content type of the message body.
    This is a convenience method that can be used to determine the content type of the message body.
    This method is used to acquire the file name of the part.
    This method is used to acquire the name of the part.
    This is a convenience method that can be used to determine the content type of the message body.
    This can be used to get the value of the first message header that has the specified name.
    getValue(String name, int index)
    This can be used to get the value of the first message header that has the specified name.
    This can be used to get the values of HTTP message headers that have the specified name.
    boolean
    This method is used to determine the type of a part.
  • Method Details

    • isFile

      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.
      Returns:
      this returns true if the associated part is a file
    • getName

      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.
      Returns:
      this returns the name of the associated part
    • getFileName

      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.
      Returns:
      this returns the file name of the associated part
    • getValue

      String getValue(String name)
      This can be used to get the value of the first message header that has the specified name. The value provided from this will be trimmed so there is no need to modify the value, also if the header name specified refers to a comma separated list of values the value returned is the first value in that list. This returns null if there is no HTTP message header.
      Parameters:
      name - the HTTP message header to get the value from
      Returns:
      this returns the value that the HTTP message header
    • getValue

      String getValue(String name, int index)
      This can be used to get the value of the first message header that has the specified name. The value provided from this will be trimmed so there is no need to modify the value, also if the header name specified refers to a comma separated list of values the value returned is the first value in that list. This returns null if there is no HTTP message header.
      Parameters:
      name - the HTTP message header to get the value from
      index - acquires a specific header value from multiple
      Returns:
      this returns the value that the HTTP message header
    • getValues

      List<String> getValues(String name)
      This can be used to get the values of HTTP message headers that have the specified name. This is a convenience method that will present that values as tokens extracted from the header. This has obvious performance benefits as it avoids having to deal with substring and trim calls.

      The tokens returned by this method are ordered according to there HTTP quality values, or "q" values, see RFC 2616 section 3.9. This also strips out the quality parameter from tokens returned. So "image/html; q=0.9" results in "image/html". If there are no "q" values present then order is by appearance.

      The result from this is either the trimmed header value, that is, the header value with no leading or trailing whitespace or an array of trimmed tokens ordered with the most preferred in the lower indexes, so index 0 is has highest preference.

      Parameters:
      name - the name of the headers that are to be retrieved
      Returns:
      ordered array of tokens extracted from the header(s)
    • getContentType

      ContentType getContentType()
      This is a convenience method that can be used to determine the content type of the message body. This will determine whether there is a Content-Type header, if there is then this will parse that header and represent it as a typed object which will expose the various parts of the HTTP header.
      Returns:
      this returns the content type value if it exists
    • getDisposition

      ContentDisposition getDisposition()
      This is a convenience method that can be used to determine the content type of the message body. This will determine whether there is a Content-Disposition header, if there is this will parse that header and represent it as a typed object which will expose the various parts of the HTTP header.
      Returns:
      this returns the content disposition value if it exists
    • getTransferEncoding

      String getTransferEncoding()
      This is a convenience method that can be used to determine the content type of the message body. This will determine whether there is a Transfer-Encoding header, if there is then this will parse that header and return the first token in the comma separated list of values, which is the primary value.
      Returns:
      this returns the transfer encoding value if it exists
    • getContentLength

      long getContentLength()
      This is a convenience method that can be used to determine the length of the message body. This will determine if there is a Content-Length header, if it does then the length can be determined, if not then this returns -1.
      Returns:
      the content length, or -1 if it cannot be determined