org.jets3t.service.model
Class BaseStorageItem

java.lang.Object
  extended by org.jets3t.service.model.BaseStorageItem
Direct Known Subclasses:
StorageBucket, StorageObject

public abstract class BaseStorageItem
extends java.lang.Object

Base class to represent storage items that can contain metadata: both objects and buckets.


Field Summary
static java.lang.String METADATA_HEADER_CONTENT_DISPOSITION
           
static java.lang.String METADATA_HEADER_CONTENT_ENCODING
           
static java.lang.String METADATA_HEADER_CONTENT_LANGUAGE
           
static java.lang.String METADATA_HEADER_CONTENT_LENGTH
           
static java.lang.String METADATA_HEADER_CONTENT_MD5
           
static java.lang.String METADATA_HEADER_CONTENT_TYPE
           
static java.lang.String METADATA_HEADER_CREATION_DATE
           
static java.lang.String METADATA_HEADER_DATE
           
static java.lang.String METADATA_HEADER_ETAG
           
static java.lang.String METADATA_HEADER_LAST_MODIFIED_DATE
           
 
Constructor Summary
protected BaseStorageItem()
           
protected BaseStorageItem(java.lang.String name)
           
 
Method Summary
 void addAllMetadata(java.util.Map<java.lang.String,java.lang.Object> metadataToAdd)
          Adds all the items in the provided map to this object's metadata.
 void addMetadata(java.lang.String name, java.util.Date value)
          Adds a Date metadata item to the object.
protected  void addMetadata(java.lang.String name, java.lang.Object value)
          Add a metadata entry with the given name.
 void addMetadata(java.lang.String name, StorageOwner value)
          Adds an owner metadata item to the object.
 void addMetadata(java.lang.String name, java.lang.String value)
          Adds a String metadata item to the object.
 boolean containsMetadata(java.lang.String name)
          Return true if a metdata data item with the given name (case-insensitive) is present.
 java.lang.Object getMetadata(java.lang.String name)
           
 java.util.Map<java.lang.String,java.lang.Object> getMetadataMap()
           
 java.lang.String getName()
           
 StorageOwner getOwner()
           
protected  boolean isMatchingMetadataName(java.lang.String name1, java.lang.String name2)
           
 void removeMetadata(java.lang.String name)
          Removes a metadata item from the object.
 void replaceAllMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
          Removes all the metadata items associated with this object, then adds all the items in the provided map.
 void setName(java.lang.String name)
          Set the name of the bucket.
 void setOwner(StorageOwner owner)
          Set this object's owner object based on information returned from the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METADATA_HEADER_CREATION_DATE

public static final java.lang.String METADATA_HEADER_CREATION_DATE
See Also:
Constant Field Values

METADATA_HEADER_LAST_MODIFIED_DATE

public static final java.lang.String METADATA_HEADER_LAST_MODIFIED_DATE
See Also:
Constant Field Values

METADATA_HEADER_DATE

public static final java.lang.String METADATA_HEADER_DATE
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_MD5

public static final java.lang.String METADATA_HEADER_CONTENT_MD5
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_LENGTH

public static final java.lang.String METADATA_HEADER_CONTENT_LENGTH
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_TYPE

public static final java.lang.String METADATA_HEADER_CONTENT_TYPE
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_ENCODING

public static final java.lang.String METADATA_HEADER_CONTENT_ENCODING
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_DISPOSITION

public static final java.lang.String METADATA_HEADER_CONTENT_DISPOSITION
See Also:
Constant Field Values

METADATA_HEADER_CONTENT_LANGUAGE

public static final java.lang.String METADATA_HEADER_CONTENT_LANGUAGE
See Also:
Constant Field Values

METADATA_HEADER_ETAG

public static final java.lang.String METADATA_HEADER_ETAG
See Also:
Constant Field Values
Constructor Detail

BaseStorageItem

protected BaseStorageItem(java.lang.String name)

BaseStorageItem

protected BaseStorageItem()
Method Detail

getName

public java.lang.String getName()
Returns:
the name of the bucket.

setName

public void setName(java.lang.String name)
Set the name of the bucket.

Parameters:
name - the name for the bucket

getMetadataMap

public java.util.Map<java.lang.String,java.lang.Object> getMetadataMap()
Returns:
an immutable map containing all the metadata associated with this object, with case-sensitive name strings as keys.

isMatchingMetadataName

protected boolean isMatchingMetadataName(java.lang.String name1,
                                         java.lang.String name2)
Parameters:
name1 -
name2 -
Returns:
Return true if the given string Metadata item names are equivalent, i.e. either both are null, or both are a case-insensitive match.

getMetadata

public java.lang.Object getMetadata(java.lang.String name)
Parameters:
name - the metadata item name, case-insensitive.
Returns:
the value of the metadata with the given case-insensitive name, or null if no such metadata item exists.

containsMetadata

public boolean containsMetadata(java.lang.String name)
Return true if a metdata data item with the given name (case-insensitive) is present.

Parameters:
name - the metadata item name, case-insensitive.
Returns:
true if this object contains a metadata item with the given name, false otherwise.

addMetadata

protected void addMetadata(java.lang.String name,
                           java.lang.Object value)
Add a metadata entry with the given name. Metadata item names are treated as case-insensitive when you set/get values. If a name values being set matches an existing metdata item (even if case is different) the original value will be replaced with the new one. The case of metadata item names is preserved when items are stored so the original names are accessible via getMetadataMap(), but case is otherwise ignored. In other words, if you set two metadata items with the names "ETag" and "Etag" only one value will be stored, whichever was set most recently.

Parameters:
name - the metadata item name, case-insensitive.
value - the metadata item value.

addMetadata

public void addMetadata(java.lang.String name,
                        java.lang.String value)
Adds a String metadata item to the object.

Parameters:
name - the metadata item name, case-insensitive.
value - the metadata item's date value.

addMetadata

public void addMetadata(java.lang.String name,
                        java.util.Date value)
Adds a Date metadata item to the object.

Parameters:
name - the metadata item name, case-insensitive.
value - the metadata item's date value.

addMetadata

public void addMetadata(java.lang.String name,
                        StorageOwner value)
Adds an owner metadata item to the object.

Parameters:
name - the metadata item name, case-insensitive.
value - the metadata item's owner value.

addAllMetadata

public void addAllMetadata(java.util.Map<java.lang.String,java.lang.Object> metadataToAdd)
Adds all the items in the provided map to this object's metadata.

Parameters:
metadataToAdd - metadata items to add, names are case-insensitive.

removeMetadata

public void removeMetadata(java.lang.String name)
Removes a metadata item from the object.

Parameters:
name - the name of the metadata item to remove, case-insensitive.

replaceAllMetadata

public void replaceAllMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
Removes all the metadata items associated with this object, then adds all the items in the provided map. After performing this operation, the metadata list will contain only those items in the provided map.

Parameters:
metadata - metadata items to add.

getOwner

public StorageOwner getOwner()
Returns:
this object's owner, or null if the owner is not available.

setOwner

public void setOwner(StorageOwner owner)
Set this object's owner object based on information returned from the service. This method should only by used by code that reads service responses.

Parameters:
owner -