com.ibm.portal.resolver.data
Interface ConvertibleDataSource

All Superinterfaces:
Addressable, DataSource, DataSourceFragment, Disposable, TimeStamped
All Known Implementing Classes:
AbstractDataSource

public interface ConvertibleDataSource
extends DataSource

Describes a DataSource that can be converted to another DataSource interface, typically used for type conversion of the content.

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

Field Summary
 
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
 
Method Summary
<T extends DataSource>
T
convertTo(java.lang.Class<T> dstClass)
          Converts the DataSource to the desired target interface or returns null.
 boolean isConvertibleTo(java.lang.Class<? extends DataSource> dstClass)
          Checks if the DataSource can be converted to the target class.
 
Methods inherited from interface com.ibm.portal.resolver.data.DataSource
getContentType, getCreated, getExpiration, getLastModified
 
Methods inherited from interface com.ibm.portal.resolver.data.Addressable
getParameters, getURI
 
Methods inherited from interface com.ibm.portal.Disposable
dispose
 

Method Detail

convertTo

<T extends DataSource> T convertTo(java.lang.Class<T> dstClass)
                               throws java.io.IOException
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.

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

isConvertibleTo

boolean isConvertibleTo(java.lang.Class<? extends DataSource> dstClass)
Checks if the DataSource can be converted to the target class.

Parameters:
dstClass - target class, not null
Returns:
true if the DataSource can be converted to the target class, else false