com.ibm.portal.resolver.helper
Class AbstractDataSource

java.lang.Object
  extended by com.ibm.portal.resolver.helper.AbstractDataSource
All Implemented Interfaces:
Disposable, Addressable, CacheControlDataSource, ContentDispositionDataSource, ContentLengthDataSource, ConvertibleDataSource, DataSource, DataSourceChecksum, DataSourceFragment, ProjectContextDataSource, StatusCodeDataSource, UserContextDataSource, VaryDataSource, VirtualPortalContextDataSource, TimeStamped

public class AbstractDataSource
extends java.lang.Object
implements DataSource, DataSourceChecksum, CacheControlDataSource, ContentDispositionDataSource, VaryDataSource, ContentLengthDataSource, UserContextDataSource, StatusCodeDataSource, ProjectContextDataSource, VirtualPortalContextDataSource, ConvertibleDataSource

Implementation of a DataSource that simply dispatches to another implementation. The methods that relate to the size of the content are not dispatched, because it is likely that subclasses will transform the content, so the filesize will most likely differ.

Since:
8.0
Note:
This interface is designed to be implemented by clients.

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ibm.portal.resolver.data.CacheControlDataSource
CacheControlDataSource.CACHE_POLICY, CacheControlDataSource.CACHE_SCOPE
 
Nested classes/interfaces inherited from interface com.ibm.portal.resolver.data.ContentDispositionDataSource
ContentDispositionDataSource.DISPOSITION
 
Field Summary
 
Fields inherited from interface com.ibm.portal.resolver.data.DataSourceChecksum
NONE
 
Fields inherited from interface com.ibm.portal.resolver.data.CacheControlDataSource
CACHE_CONTROL_EXTENSIONS_UNDEFINED
 
Fields inherited from interface com.ibm.portal.resolver.data.ContentDispositionDataSource
FILE_SIZE_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.VaryDataSource
NO_VARY_HEADERS, VARY_HEADERS_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.ContentLengthDataSource
CONTENT_LENGTH_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.UserContextDataSource
USER_CONTEXT_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.StatusCodeDataSource
SC_UNDEFINED
 
Fields inherited from interface com.ibm.portal.resolver.data.ProjectContextDataSource
PROJECT_CONTEXT_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.VirtualPortalContextDataSource
VIRTUAL_PORTAL_CONTEXT_UNKNOWN
 
Fields inherited from interface com.ibm.portal.resolver.data.DataSource
CONTENT_TYPE_UNKNOWN, CREATION_UNKNOWN, EXPIRATION_UNKNOWN, LAST_MODIFICATION_UNKNOWN, MAX_AGE_INFINITE, MAX_AGE_NONE, ROOT_DATE
 
Fields inherited from interface com.ibm.portal.resolver.data.Addressable
EMPTY_PARAMETERS
 
Constructor Summary
AbstractDataSource()
           
 
Method Summary
<T extends DataSource>
T
convertTo(java.lang.Class<T> dstClass)
          Converts the DataSource to the desired target interface or returns null.
 void dispose()
          Indicate that the object will no longer be accessed
 boolean equals(java.lang.Object obj)
           
 java.util.Map<java.lang.String,java.lang.String> getCacheControlExtensions()
          Returns a map of cache control extensions that get added to the cache control header, as defined in RFC 2616
 CacheControlDataSource.CACHE_POLICY getCachePolicy()
          Returns the caching policy for the data
 CacheControlDataSource.CACHE_SCOPE getCacheScope()
          Returns the cache scope for the data
 long getChecksum()
          Returns the checksum of the data source.
 long getContentLength()
          Returns the number of bytes that this DataSource will produce.
 java.lang.String getContentType()
          Mime type of the data.
 java.util.Date getCreated()
          Returns the creation date of the resource.
protected  DataSource getDelegate()
           
 ContentDispositionDataSource.DISPOSITION getDisposition()
          Returns the content disposition
 java.util.Date getExpiration()
          Absolute timestamp that indicates the time when the data represented by the source will expire.
 java.lang.String getFileName()
          Returns the desired filename
 long getFileSize()
          Returns the approximate file size of the data.
 java.util.Date getLastModified()
          Returns the modification date of the resource.
 java.util.Map<java.lang.String,java.lang.String[]> getParameters()
           Returns an potentially unmodifiable version of the parameters used to address the object, never null, but potentially the empty map.
 int getStatus()
          Returns a suggested HTTP status code.
 java.net.URI getURI()
          Returns the unique identifier of the object.
 java.lang.String[] getVaryHeaders()
          Returns a list of HTTP request headers that the content of the data source depends on.
 int hashCode()
           
 boolean isConvertibleTo(java.lang.Class<? extends DataSource> dstClass)
          Checks if the DataSource can be converted to the target class.
 java.lang.Boolean isPrivate()
          Indicates if the data source depends on the user context (if any).
 java.lang.Boolean isProjectDependent()
          Indicates if the data source depends on the project context (if any).
 java.lang.Boolean isVirtualPortalDependent()
          Indicates if the data source depends on the virtual portal context (if any).
 boolean isWeak()
          Returns whether this is a "strong" or "weak" checksum.
 void reset(DataSource aDelegate)
          Assigns a data source that is used to delegate the standard methods to.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataSource

public AbstractDataSource()
Method Detail

convertTo

public <T extends DataSource> T convertTo(java.lang.Class<T> dstClass)
                               throws java.io.IOException
Description copied from interface: ConvertibleDataSource
Converts the DataSource to the desired target interface or returns null. If the conversion is successful, the result is a wrapper that is to be used instead of this DataSource. In particular the wrapper has to be disposed by calling Disposable.dispose() and this disposal will also dispose the wrapped DataSource, it must not be disposed in addition to the wrapper. If the conversion was not successful, the original DataSource still needs to be disposed. This is also true in case of an exception.

Specified by:
convertTo in interface ConvertibleDataSource
Parameters:
dstClass - target class, not null
Returns:
wrapper that implemente the target interface or null . The wrapper needs to be disposed and its disposal will also dispose the wrapped DataSource
Throws:
java.io.IOException

dispose

public void dispose()
Description copied from interface: Disposable
Indicate that the object will no longer be accessed

Specified by:
dispose in interface Disposable

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getCacheControlExtensions

public java.util.Map<java.lang.String,java.lang.String> getCacheControlExtensions()
Description copied from interface: CacheControlDataSource
Returns a map of cache control extensions that get added to the cache control header, as defined in RFC 2616

Specified by:
getCacheControlExtensions in interface CacheControlDataSource
Returns:
the extensions or null

getCachePolicy

public CacheControlDataSource.CACHE_POLICY getCachePolicy()
Description copied from interface: CacheControlDataSource
Returns the caching policy for the data

Specified by:
getCachePolicy in interface CacheControlDataSource
Returns:
cache policy or null

getCacheScope

public CacheControlDataSource.CACHE_SCOPE getCacheScope()
Description copied from interface: CacheControlDataSource
Returns the cache scope for the data

Specified by:
getCacheScope in interface CacheControlDataSource
Returns:
cache scope or null

getChecksum

public long getChecksum()
Description copied from interface: DataSourceChecksum
Returns the checksum of the data source.

Specified by:
getChecksum in interface DataSourceChecksum
Returns:
the checksum of the data source. The special value DataSourceChecksum.NONE indicates that no checksum has been computed.

getContentLength

public long getContentLength()
Description copied from interface: ContentLengthDataSource
Returns the number of bytes that this DataSource will produce. If the number is unknown the DataSource may return ContentLengthDataSource.CONTENT_LENGTH_UNKNOWN

Specified by:
getContentLength in interface ContentLengthDataSource
Returns:
number of bytes or ContentLengthDataSource.CONTENT_LENGTH_UNKNOWN

getContentType

public java.lang.String getContentType()
Description copied from interface: DataSource
Mime type of the data. The return value must be a registered mime type or DataSource.CONTENT_TYPE_UNKNOWN. A value of DataSource.CONTENT_TYPE_UNKNOWN means that the data source does not contain any content.

Specified by:
getContentType in interface DataSource
Returns:
mime type string, or DataSource.CONTENT_TYPE_UNKNOWN if the data source does not represent content

getCreated

public java.util.Date getCreated()
Description copied from interface: DataSource
Returns the creation date of the resource.

Specified by:
getCreated in interface DataSource
Specified by:
getCreated in interface TimeStamped
Returns:
the creation dateor DataSource.CREATION_UNKNOWN

getDelegate

protected final DataSource getDelegate()
Returns:
Returns the delegate.

getDisposition

public ContentDispositionDataSource.DISPOSITION getDisposition()
Description copied from interface: ContentDispositionDataSource
Returns the content disposition

Specified by:
getDisposition in interface ContentDispositionDataSource
Returns:
the disposition, not null

getExpiration

public java.util.Date getExpiration()
Description copied from interface: DataSource
Absolute timestamp that indicates the time when the data represented by the source will expire.

Specified by:
getExpiration in interface CacheControlDataSource
Specified by:
getExpiration in interface DataSource
Specified by:
getExpiration in interface DataSourceFragment
Returns:
the date the data expires or DataSource.EXPIRATION_UNKNOWN if the value is unknown

getFileName

public java.lang.String getFileName()
Description copied from interface: ContentDispositionDataSource
Returns the desired filename

Specified by:
getFileName in interface ContentDispositionDataSource
Returns:
the filename or null

getFileSize

public long getFileSize()
Description copied from interface: ContentDispositionDataSource
Returns the approximate file size of the data. Note that this is different from the information returned by ContentLengthDataSource.getContentLength().

Specified by:
getFileSize in interface ContentDispositionDataSource
Returns:
the file size, 0 or < 0. A value of < 0 indicates that the filesize is unknown.

getLastModified

public java.util.Date getLastModified()
Description copied from interface: DataSource
Returns the modification date of the resource.

Specified by:
getLastModified in interface DataSource
Specified by:
getLastModified in interface TimeStamped
Returns:
the modification date or DataSource.LAST_MODIFICATION_UNKNOWN

getParameters

public java.util.Map<java.lang.String,java.lang.String[]> getParameters()
Description copied from interface: Addressable

Returns an potentially unmodifiable version of the parameters used to address the object, never null, but potentially the empty map.

The key is of type String, the values of type String[]

Specified by:
getParameters in interface Addressable
Returns:
parameter map

getStatus

public int getStatus()
Description copied from interface: StatusCodeDataSource
Returns a suggested HTTP status code. It is up to the framework to decide if this suggested status code is respected.

Specified by:
getStatus in interface StatusCodeDataSource
Returns:
a status code, may return StatusCodeDataSource.SC_UNDEFINED to indicate that the status code should not be overridden

getURI

public java.net.URI getURI()
                    throws java.net.URISyntaxException
Description copied from interface: Addressable
Returns the unique identifier of the object. The URI must contain valid scheme information and cannot be just a relative URL.

Specified by:
getURI in interface Addressable
Returns:
URI of the object, never null.
Throws:
java.net.URISyntaxException - - if the URL cannot be constructed

getVaryHeaders

public java.lang.String[] getVaryHeaders()
Description copied from interface: VaryDataSource
Returns a list of HTTP request headers that the content of the data source depends on. An empty list indicates that the result is independent on the request headers. A null return value indicates that the data source does not know its vary headers and relies on the framework to assign any.

Specified by:
getVaryHeaders in interface VaryDataSource
Returns:
the list of headers or null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isConvertibleTo

public boolean isConvertibleTo(java.lang.Class<? extends DataSource> dstClass)
Description copied from interface: ConvertibleDataSource
Checks if the DataSource can be converted to the target class.

Specified by:
isConvertibleTo in interface ConvertibleDataSource
Parameters:
dstClass - target class, not null
Returns:
true if the DataSource can be converted to the target class, else false

isPrivate

public java.lang.Boolean isPrivate()
Description copied from interface: UserContextDataSource
Indicates if the data source depends on the user context (if any).

Specified by:
isPrivate in interface UserContextDataSource
Returns:
Boolean.TRUE if the data source depends on the user context, Boolean.FALSE if the data source does not depend on the user context of UserContextDataSource.USER_CONTEXT_UNKNOWN to leave the decision to the framework.

isProjectDependent

public java.lang.Boolean isProjectDependent()
Description copied from interface: ProjectContextDataSource
Indicates if the data source depends on the project context (if any).

Specified by:
isProjectDependent in interface ProjectContextDataSource
Returns:
Boolean.TRUE if the data source depends on the project context, Boolean.FALSE if the data source does not depend on the project context of ProjectContextDataSource.PROJECT_CONTEXT_UNKNOWN to leave the decision to the framework.

isVirtualPortalDependent

public java.lang.Boolean isVirtualPortalDependent()
Description copied from interface: VirtualPortalContextDataSource
Indicates if the data source depends on the virtual portal context (if any).

Specified by:
isVirtualPortalDependent in interface VirtualPortalContextDataSource
Returns:
Boolean.TRUE if the data source depends on the virtual portal context, Boolean.FALSE if the data source does not depend on the virtual portal context of VirtualPortalContextDataSource.VIRTUAL_PORTAL_CONTEXT_UNKNOWN to leave the decision to the framework.

isWeak

public boolean isWeak()
Description copied from interface: DataSourceChecksum
Returns whether this is a "strong" or "weak" checksum. A "strong" checksum changes, whenever any aspect of the resources the data source represents change, the "weak" checksum only changes when significant changes to the resources occured.

Specified by:
isWeak in interface DataSourceChecksum
Returns:
true if the checksum is "weak", false otherwise.

reset

public void reset(DataSource aDelegate)
Assigns a data source that is used to delegate the standard methods to.

Parameters:
aDelegate - delegate that implements the generic methods