View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.io;
20  
21  import static javax.ws.rs.core.HttpHeaders.CONTENT_LENGTH;
22  import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE;
23  
24  import java.util.Set;
25  
26  import javax.annotation.Nullable;
27  
28  import com.google.common.collect.ImmutableSet;
29  
30  /**
31   * @author Adrian Cole
32   */
33  public interface ContentMetadata {
34     public static final Set<String> HTTP_HEADERS = ImmutableSet.of(CONTENT_LENGTH, "Content-MD5", CONTENT_TYPE,
35              "Content-Disposition", "Content-Encoding", "Content-Language");
36  
37     /**
38      * Returns the total size of the payload, or the chunk that's available.
39      * <p/>
40      * Chunking is only used when {@link org.jclouds.http.GetOptions} is called with options like
41      * tail, range, or startAt.
42      * 
43      * @return the length in bytes that can be be obtained from {@link #getInput()}
44      * @see javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH
45      * @see org.jclouds.http.options.GetOptions
46      */
47     @Nullable
48     Long getContentLength();
49  
50     /**
51      * Specifies presentational information for the object.
52      * 
53      * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html?sec19.5.1."/>
54      */
55     @Nullable
56     String getContentDisposition();
57  
58     /**
59      * Specifies what content encodings have been applied to the object and thus what decoding
60      * mechanisms must be applied in order to obtain the media-type referenced by the Content-Type
61      * header field.
62      * 
63      * @see <a href= "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html?sec14.11" />
64      */
65     @Nullable
66     String getContentEncoding();
67  
68     /**
69      * 
70      * A standard MIME type describing the format of the contents. If none is provided, the default
71      * is binary/octet-stream.
72      * 
73      * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17"/>
74      */
75     @Nullable
76     String getContentType();
77  
78     @Nullable
79     byte[] getContentMD5();
80  
81     /**
82      * Get Content Language of the payload
83      * <p/>
84      * Not all providers may support it
85      */
86     @Nullable
87     String getContentLanguage();
88  
89     ContentMetadataBuilder toBuilder();
90  
91  }