org.eclipse.webdav.internal.kernel
Class Precondition

java.lang.Object
  extended by org.eclipse.webdav.internal.kernel.Precondition

public class Precondition
extends Object

A Precondition represents some condition or collection of conditions representing states of a resource. If the state of the resource does not match any of the specified states in any of the conditions, then the method must fail. Conditions in a Precondition are OR'd together while ConditionFactors in a ConditionTerm are AND'ed.


Constructor Summary
Precondition()
          Construct an empty Precondition.
Precondition(String ifHeader)
          Construct a Precondition by parsing the given If header as defined by section 8.4 in the WebDAV spec.
 
Method Summary
 void addCondition(Condition condition)
          Add a Condition to this Precondition.
 void addStateTokenCondition(String resourceURI, String stateToken)
          Add a condition created from the given URI and state token.
static Precondition create(String ifHeader)
          Construct a Precondition by parsing the given If header as defined by section 9.4 in the WebDAV spec.
 Enumeration getConditions()
          Get the Conditions contained in this Precondition.
 boolean matches(Condition condition)
          See if this Precondition contains a matching Condition.
 String toString()
          Return a String representation of this Precondition as defined by section 9.4 of the WebDAV Spec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Precondition

public Precondition()
Construct an empty Precondition. The client must add Conditions.


Precondition

public Precondition(String ifHeader)
             throws WebDAVException
Construct a Precondition by parsing the given If header as defined by section 8.4 in the WebDAV spec.

Parameters:
ifHeader - the contents of a WebDAV If header
Throws:
WebDAVException
Method Detail

addCondition

public void addCondition(Condition condition)
                  throws WebDAVException
Add a Condition to this Precondition. Conditions are OR'd together to check for a matching resource.

Parameters:
condition - the Condition to add
Throws:
WebDAVException - thrown if the precondition already contains this condition

addStateTokenCondition

public void addStateTokenCondition(String resourceURI,
                                   String stateToken)
                            throws WebDAVException
Add a condition created from the given URI and state token. This is a convenience method used primarily to create preconditions for lock tokens that must be provided in the resource context for methods that update the resource.

Parameters:
resourceURI - the URI of the resource the state token applies to. Null implicitly specifies the resource processing the request
stateToken - the state token to match
Throws:
WebDAVException

create

public static Precondition create(String ifHeader)
                           throws WebDAVException
Construct a Precondition by parsing the given If header as defined by section 9.4 in the WebDAV spec.

Parameters:
ifHeader - the contents of a WebDAV If header
Returns:
the parser If header
Throws:
WebDAVException - thrown if there is a syntax error in the If header

getConditions

public Enumeration getConditions()
Get the Conditions contained in this Precondition. At least one must match in order for a valid match to occur.

Returns:
an Enumeration of Conditions

matches

public boolean matches(Condition condition)
See if this Precondition contains a matching Condition.

Parameters:
condition - the condition to match
Returns:
true if this precondition contains atleast one condition matching the given condition

toString

public String toString()
Return a String representation of this Precondition as defined by section 9.4 of the WebDAV Spec. The string is the value of an If header.

Overrides:
toString in class Object
Returns:
a string representation of this precondition


Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.