org.codehaus.httpcache4j
Class Conditionals

java.lang.Object
  extended by org.codehaus.httpcache4j.Conditionals

public final class Conditionals
extends java.lang.Object

Represents the different conditional types that an HTTP request may have. This are basically 4 things:

Combinations of these conditionals are possible with the following exceptions
ConditionalCan be combined withUnspecified
If-MatchIf-Unmodified-SinceIf-None-Match, If-Modified-Since
If-None-MatchIf-Modified-SinceIf-Match, If-Unmodified-Since
If-Unmodified-SinceIf-MatchIf-None-Match, If-Modified-Since
If-Modified-SinceIf-None-MatchIf-Match, If-Unmodified-Since

Author:
Erlend Hamnaberg

Constructor Summary
Conditionals()
           
Conditionals(java.util.List<Tag> match, java.util.List<Tag> noneMatch, org.joda.time.DateTime modifiedSince, org.joda.time.DateTime unModifiedSince)
           
 
Method Summary
 Conditionals addIfMatch(Tag tag)
          Adds tags to the If-Match header.
 Conditionals addIfNoneMatch(Tag tag)
          Adds tags to the If-None-Match header.
 java.util.List<Tag> getMatch()
           
 org.joda.time.DateTime getModifiedSince()
           
 java.util.List<Tag> getNoneMatch()
           
 org.joda.time.DateTime getUnModifiedSince()
           
 Conditionals ifModifiedSince(org.joda.time.DateTime time)
          You should use the server's time here.
 Conditionals ifUnModifiedSince(org.joda.time.DateTime time)
          You should use the server's time here.
 boolean isUnconditional()
           
 Headers toHeaders()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conditionals

public Conditionals()

Conditionals

public Conditionals(java.util.List<Tag> match,
                    java.util.List<Tag> noneMatch,
                    org.joda.time.DateTime modifiedSince,
                    org.joda.time.DateTime unModifiedSince)
Method Detail

addIfMatch

public Conditionals addIfMatch(Tag tag)
Adds tags to the If-Match header.

Parameters:
tag - the tag to add, may be null. This means the same as adding Tag.ALL
Returns:
a new Conditionals object with the If-Match tag added.
Throws:
java.lang.IllegalArgumentException - if ALL is supplied more than once, or you add a null tag more than once.

addIfNoneMatch

public Conditionals addIfNoneMatch(Tag tag)
Adds tags to the If-None-Match header. The meaning of "If-None-Match: *" is that the method MUST NOT be performed if the representation selected by the origin server (or by a cache, possibly using the Vary mechanism, see section 14.44) exists, and SHOULD be performed if the representation does not exist. This feature is intended to be useful in preventing races between PUT operations.

Parameters:
tag - the tag to add, may be null. This means the same as adding Tag.ALL
Returns:
a new Conditionals object with the If-None-Match tag added.
Throws:
java.lang.IllegalArgumentException - if ALL is supplied more than once, or you add a null tag more than once.

ifModifiedSince

public Conditionals ifModifiedSince(org.joda.time.DateTime time)
You should use the server's time here. Otherwise you might get unexpected results. The typical use case is:
   HTTPResponse response = ....
   HTTPRequest request = createRequest();
   request = request.conditionals(new Conditionals().ifModifiedSince(response.getLastModified());
 

Parameters:
time - the time to check.
Returns:
the conditionals with the If-Modified-Since date set.

ifUnModifiedSince

public Conditionals ifUnModifiedSince(org.joda.time.DateTime time)
You should use the server's time here. Otherwise you might get unexpected results. The typical use case is:
   HTTPResponse response = ....
   HTTPRequest request = createRequest();
   request = request.conditionals(new Conditionals().ifUnModifiedSince(response.getLastModified());
 

Parameters:
time - the time to check.
Returns:
the conditionals with the If-Unmodified-Since date set.

getMatch

public java.util.List<Tag> getMatch()

getNoneMatch

public java.util.List<Tag> getNoneMatch()

getModifiedSince

public org.joda.time.DateTime getModifiedSince()

getUnModifiedSince

public org.joda.time.DateTime getUnModifiedSince()

isUnconditional

public boolean isUnconditional()

toHeaders

public Headers toHeaders()


Copyright © 2008-2009. All Rights Reserved.