org.apache.tuscany.sca.binding.http
Class HTTPCacheContext

java.lang.Object
  extended by org.apache.tuscany.sca.binding.http.HTTPCacheContext

public class HTTPCacheContext
extends java.lang.Object

A class to store cache settings for Atom and HTTP requests and responses. Predicates are statements that work in conjunction with ETags and LastModified dates to determine if a precondition or postcondition is satisfied. See HTTP specification for how predicates wrk: http://tools.ietf.org/html/rfc2616 Example predicates in HTTP include If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since, If-Range.


Field Summary
 boolean enabled
           
 java.lang.String eTag
           
 boolean ifMatch
           
 boolean ifModifiedSince
           
 boolean ifNoneMatch
           
 boolean ifRange
           
 boolean ifUnmodifiedSince
           
 java.lang.String lastModified
           
 java.util.Date lastModifiedDate
           
static java.text.SimpleDateFormat RFC822DateFormat
           
 
Constructor Summary
HTTPCacheContext()
           
 
Method Summary
static HTTPCacheContext getCacheContextFromRequest(HttpServletRequest request)
          Gets the cache context information (ETag, LastModified, predicates) from the Http request.
 java.lang.String getETag()
          An ETag is a unique ID for an item.
 java.lang.String getLastModified()
          The LastModified date is the time the item was last changed.
 java.util.Date getLastModifiedAsDate()
          The LastModified date is the time the item was last changed.
 boolean isEnabled()
          Enabled is true whenever ETag, LastModified, or predicate is set.
 boolean isIfMatch()
           
 boolean isIfModifiedSince()
           
 boolean isIfNoneMatch()
           
 boolean isIfRange()
           
 boolean isIfUnmodifiedSince()
           
 void setEnabled(boolean enabled)
           
 void setETag(java.lang.String tag)
           
 void setIfMatch(boolean ifMatch)
           
 void setIfModifiedSince(boolean ifModifiedSince)
           
 void setIfNoneMatch(boolean ifNoneMatch)
           
 void setIfRange(boolean ifRange)
           
 void setIfUnmodifiedSince(boolean ifUnmodifiedSince)
           
 void setLastModified(java.util.Date updated)
           
 void setLastModified(java.lang.String lastModified)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RFC822DateFormat

public static final java.text.SimpleDateFormat RFC822DateFormat

enabled

public boolean enabled

eTag

public java.lang.String eTag

lastModified

public java.lang.String lastModified

lastModifiedDate

public java.util.Date lastModifiedDate

ifModifiedSince

public boolean ifModifiedSince

ifUnmodifiedSince

public boolean ifUnmodifiedSince

ifMatch

public boolean ifMatch

ifNoneMatch

public boolean ifNoneMatch

ifRange

public boolean ifRange
Constructor Detail

HTTPCacheContext

public HTTPCacheContext()
Method Detail

getETag

public java.lang.String getETag()
An ETag is a unique ID for an item. It changes when a field in the item or the update date changes. See HTTP specification for how ETags work: http://tools.ietf.org/html/rfc2616

Returns:
the eTag

setETag

public void setETag(java.lang.String tag)
Parameters:
tag - the eTag to set

getLastModified

public java.lang.String getLastModified()
The LastModified date is the time the item was last changed. See HTTP specification for how ETags work: http://tools.ietf.org/html/rfc2616

Returns:
the lastModified

getLastModifiedAsDate

public java.util.Date getLastModifiedAsDate()
The LastModified date is the time the item was last changed. See HTTP specification for how ETags work: http://tools.ietf.org/html/rfc2616

Returns:
the lastModified

setLastModified

public void setLastModified(java.lang.String lastModified)
                     throws java.text.ParseException
Parameters:
lastModified - the lastModified to set
Throws:
java.text.ParseException

setLastModified

public void setLastModified(java.util.Date updated)
Parameters:
lastModified - the lastModified to set

isIfModifiedSince

public boolean isIfModifiedSince()
Returns:
the ifModifedSince

setIfModifiedSince

public void setIfModifiedSince(boolean ifModifiedSince)
Parameters:
ifModifedSince - the ifModifedSince to set

isIfUnmodifiedSince

public boolean isIfUnmodifiedSince()
Returns:
the ifUnModifiedSince

setIfUnmodifiedSince

public void setIfUnmodifiedSince(boolean ifUnmodifiedSince)
Parameters:
ifUnModifiedSince - the ifUnModifiedSince to set

isIfMatch

public boolean isIfMatch()
Returns:
the ifMatch

setIfMatch

public void setIfMatch(boolean ifMatch)
Parameters:
ifMatch - the ifMatch to set

isIfNoneMatch

public boolean isIfNoneMatch()
Returns:
the ifNoneMatch

setIfNoneMatch

public void setIfNoneMatch(boolean ifNoneMatch)
Parameters:
ifNoneMatch - the ifNoneMatch to set

isIfRange

public boolean isIfRange()
Returns:
the ifRange

setIfRange

public void setIfRange(boolean ifRange)
Parameters:
ifRange - the ifRange to set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getCacheContextFromRequest

public static HTTPCacheContext getCacheContextFromRequest(HttpServletRequest request)
                                                   throws java.text.ParseException
Gets the cache context information (ETag, LastModified, predicates) from the Http request.

Parameters:
request -
Returns:
Throws:
java.text.ParseException

isEnabled

public boolean isEnabled()
Enabled is true whenever ETag, LastModified, or predicate is set.

Returns:
the enabled

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - the enabled to set