All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.windowsazure.services.blob.models.AccessCondition Maven / Gradle / Ivy

There is a newer version: 0.4.6
Show newest version
/**
 * Copyright 2011 Microsoft Corporation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.microsoft.windowsazure.services.blob.models;

import java.util.Date;

import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter;

/**
 * Represents a set of access conditions to be used for operations against the storage services.
 */
public final class AccessCondition {

    /**
     * Specifies that no access condition is set.
     */
    public static final AccessCondition NONE = new AccessCondition(AccessConditionHeaderType.NONE, null);

    /**
     * Returns an access condition such that an operation will be performed only if the resource's ETag value matches
     * the specified ETag value.
     * 

* Setting this access condition modifies the request to include the HTTP If-Match conditional header. If * this access condition is set, the operation is performed only if the ETag of the resource matches the specified * ETag. *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. * * @param etag * A String that represents the ETag value to check. * * @return An AccessCondition object that represents the If-Match condition. */ public static AccessCondition ifMatch(String etag) { return new AccessCondition(AccessConditionHeaderType.IF_MATCH, etag); } /** * Returns an access condition such that an operation will be performed only if the resource has been modified since * the specified time. *

* Setting this access condition modifies the request to include the HTTP If-Modified-Since conditional * header. If this access condition is set, the operation is performed only if the resource has been modified since * the specified time. *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. * * @param lastMotified * A java.util.Date object that represents the last-modified time to check for the resource. * * @return An AccessCondition object that represents the If-Modified-Since condition. */ public static AccessCondition ifModifiedSince(Date lastMotified) { return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); } /** * Returns an access condition such that an operation will be performed only if the resource's ETag value does not * match the specified ETag value. *

* Setting this access condition modifies the request to include the HTTP If-None-Match conditional header. * If this access condition is set, the operation is performed only if the ETag of the resource does not match the * specified ETag. *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. * * @param etag * A String that represents the ETag value to check. * * @return An AccessCondition object that represents the If-None-Match condition. */ public static AccessCondition ifNoneMatch(String etag) { return new AccessCondition(AccessConditionHeaderType.IF_NONE_MATCH, etag); } /** * Returns an access condition such that an operation will be performed only if the resource has not been modified * since the specified time. *

* Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional * header. If this access condition is set, the operation is performed only if the resource has not been modified * since the specified time. *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. * * @param lastMotified * A java.util.Date object that represents the last-modified time to check for the resource. * * @return An AccessCondition object that represents the If-Unmodified-Since condition. */ public static AccessCondition ifNotModifiedSince(Date lastMotified) { return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); } /** * Represents the header type. */ private AccessConditionHeaderType header = AccessConditionHeaderType.NONE; /** * Represents the header value. */ private String value; /** * Creates an instance of the AccessCondition class. */ protected AccessCondition() { // Empty Default Ctor } /** * Creates an instance of the AccessCondition class using the specified header type and value. * * @param headerType * An {@link AccessConditionHeaderType} value that represents the header type. * @param value * A String that represents the value of the header. */ protected AccessCondition(AccessConditionHeaderType headerType, String value) { this.setHeader(headerType); this.setValue(value); } public AccessConditionHeaderType getHeader() { return header; } public void setHeader(AccessConditionHeaderType header) { this.header = header; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy