org.simpleframework.http.message
Class HeaderConsumer

java.lang.Object
  extended by org.simpleframework.http.message.ArrayConsumer
      extended by org.simpleframework.http.message.SegmentConsumer
          extended by org.simpleframework.http.message.HeaderConsumer
All Implemented Interfaces:
ByteConsumer, Header, Segment
Direct Known Subclasses:
RequestConsumer

public abstract class HeaderConsumer
extends SegmentConsumer
implements Header

The HeaderConsumer object is used to consume a HTTP header from the cursor. This extends the segment consumer with methods specific to the header. Also this enables session cookies to be created using the cookies extracted from the header.

Author:
Niall Gallagher

Field Summary
 
Fields inherited from class org.simpleframework.http.message.SegmentConsumer
cookies, disposition, encoding, expect, header, language, length, limit, name, pos, scan, type, value
 
Fields inherited from class org.simpleframework.http.message.ArrayConsumer
array, chunk, count, done
 
Constructor Summary
protected HeaderConsumer()
          Constructor for the HeaderConsumer object.
 
Method Summary
 Cookie getCookie(String name)
          This is used to acquire a cookie using the name of that cookie.
 List<Cookie> getCookies()
          This is used to acquire all cookies that were sent in the header.
 long getDate(String name)
          This can be used to get the date of the first message header that has the specified name.
 int getInteger(String name)
          This can be used to get the integer of the first message header that has the specified name.
 List<String> getNames()
          This method is used to get a List of the names for the headers.
 
Methods inherited from class org.simpleframework.http.message.SegmentConsumer
add, adjust, cookie, disposition, encoding, end, equal, expect, getContentLength, getContentType, getDisposition, getFileName, getLocales, getName, getTransferEncoding, getValue, getValue, getValues, headers, isExpectContinue, isFile, language, length, process, resize, scan, space, terminal, toString, type, white
 
Methods inherited from class org.simpleframework.http.message.ArrayConsumer
consume, isFinished
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.simpleframework.http.message.Header
getAddress, getHeader, getLocales, getMajor, getMethod, getMinor, getPath, getQuery, getTarget, isExpectContinue, toString
 
Methods inherited from interface org.simpleframework.http.message.Segment
getContentLength, getContentType, getDisposition, getFileName, getName, getTransferEncoding, getValue, getValue, getValues, isFile
 

Constructor Detail

HeaderConsumer

protected HeaderConsumer()
Constructor for the HeaderConsumer object. This is used to create a consumer capable of reading a header from a provided cursor. All methods of the Header interface are implemented in this object.

Method Detail

getDate

public long getDate(String name)
This can be used to get the date of the first message header that has the specified name. This is a convenience method that avoids having to deal with parsing the value of the requested HTTP message header. This returns -1 if theres no HTTP header value for the specified name.

Specified by:
getDate in interface Header
Parameters:
name - the HTTP message header to get the value from
Returns:
this returns the date as a long from the header value

getInteger

public int getInteger(String name)
This can be used to get the integer of the first message header that has the specified name. This is a convenience method that avoids having to deal with parsing the value of the requested HTTP message header. This returns -1 if theres no HTTP header value for the specified name.

Specified by:
getInteger in interface Header
Parameters:
name - the HTTP message header to get the value from
Returns:
this returns the date as a long from the header value

getNames

public List<String> getNames()
This method is used to get a List of the names for the headers. This will provide the original names for the HTTP headers for the message. Modifications to the provided list will not affect the header, the list is a simple copy.

Specified by:
getNames in interface Header
Returns:
this returns a list of the names within the header

getCookie

public Cookie getCookie(String name)
This is used to acquire a cookie using the name of that cookie. If the cookie exists within the HTTP header then it is returned as a Cookie object. Otherwise this method will return null. Each cookie object will contain the name, value and path of the cookie as well as the optional domain part.

Specified by:
getCookie in interface Header
Parameters:
name - this is the name of the cookie object to acquire
Returns:
this returns a cookie object from the header or null

getCookies

public List<Cookie> getCookies()
This is used to acquire all cookies that were sent in the header. If any cookies exists within the HTTP header they are returned as Cookie objects. Otherwise this method will an empty list. Each cookie object will contain the name, value and path of the cookie as well as the optional domain part.

Specified by:
getCookies in interface Header
Returns:
this returns all cookie objects from the HTTP header


Copyright © 2014. All Rights Reserved.