com.ibm.portal.resolver.webdav.tree.helper
Class DefaultWebdavTreeModel<T>

java.lang.Object
  extended by com.ibm.portal.resolver.webdav.tree.helper.DefaultWebdavTreeModel<T>
All Implemented Interfaces:
Disposable, WebdavTreeModel<T>
Direct Known Subclasses:
DefaultWebdavTreeModelController

public class DefaultWebdavTreeModel<T>
extends java.lang.Object
implements WebdavTreeModel<T>

Convenience base class for WebdavTreeModel implementations

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

Constructor Summary
DefaultWebdavTreeModel()
           
 
Method Summary
 DataSource createDataSource(T item)
           Creates a new DataSource for the given item.
 void dispose()
          Indicate that the object will no longer be accessed
 T getItem(java.net.URI uri)
          Returns an existing item that corresponds to the URI.
 Localized getLocalized(T item)
           Returns an object that provides the localizations for an arbitrary item out of those items available in the WebdavTreeModel.getTreeModel().
 java.lang.String getName(T item)
           Returns the "friendly" name for for an arbitrary item out of those items available in the WebdavTreeModel.getTreeModel().
 TreeModel<T> getTreeModel()
          Returns the TreeModel that describes the namespace hierarchy of items.
 boolean isCollection(T item)
           Checks if any item is a collection or a 'file'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWebdavTreeModel

public DefaultWebdavTreeModel()
Method Detail

createDataSource

public DataSource createDataSource(T item)
                            throws java.io.IOException
Description copied from interface: WebdavTreeModel

Creates a new DataSource for the given item. This information is used to download a particular resource. The method may also return null to indicate that the item does not have a representation. The data source can implement the ContentDispositionDataSource or ContentLengthDataSource to indicate the size of the data.

Clients of this method must make sure that they call Disposable.dispose() on the created data source when it is no longer needed.

The DataSource is also used to compute the following WebDAV properties:

creationdate
Records the time and date the resource was created.
getcontentlength
Contains the Content-Length header returned by a GET without accept headers. Requires that the DataSource implements the ContentDispositionDataSource or ContentLengthDataSource interface.
getcontenttype
Contains the Content-Type header returned by a GET without accept headers.
getetag
Contains the ETag header returned by a GET without accept headers. Requires that the DataSource implements the DataSourceChecksum interface.
getlastmodified
Contains the Last-Modified header returned by a GET method without accept headers.

Specified by:
createDataSource in interface WebdavTreeModel<T>
Parameters:
item - item, not null
Returns:
the data source or null
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

getItem

public T getItem(java.net.URI uri)
          throws java.io.IOException
Description copied from interface: WebdavTreeModel
Returns an existing item that corresponds to the URI. If the item cannot be found, then this method MUST return null.

Specified by:
getItem in interface WebdavTreeModel<T>
Parameters:
uri - the URI of the item, not null
Returns:
the corresponding item or null
Throws:
java.io.IOException

getLocalized

public Localized getLocalized(T item)
Description copied from interface: WebdavTreeModel

Returns an object that provides the localizations for an arbitrary item out of those items available in the WebdavTreeModel.getTreeModel(). If there are not localizations available the method MAY return null.

The Localized object us used to compute the following WebDAV properties:

displayname
Provides a name for the resource that is suitable for presentation to a user.
getcontentlanguage
Contains the Content-Language header returned by a GET without accept headers

Specified by:
getLocalized in interface WebdavTreeModel<T>
Parameters:
item - item, not null
Returns:
localizations or null

getName

public java.lang.String getName(T item)
Description copied from interface: WebdavTreeModel

Returns the "friendly" name for for an arbitrary item out of those items available in the WebdavTreeModel.getTreeModel(). This name should not contain path separator characters. The final URL path is build from the hierarchy of these names. The WebdavTreeModel.getItem(URI) must be prepared to locate the addressed item based on the path constructed from these names. The name may contain all unicode characters and does not need to be URL encoded, i.e. a name "a b" is perfectly valid and does not need to be encoded to be "a%20b".

Specified by:
getName in interface WebdavTreeModel<T>
Parameters:
item - item, not null
Returns:
the name, must not be null nor the empty string

getTreeModel

public TreeModel<T> getTreeModel()
Description copied from interface: WebdavTreeModel
Returns the TreeModel that describes the namespace hierarchy of items.

Specified by:
getTreeModel in interface WebdavTreeModel<T>
Returns:
the tree model, must not be null

isCollection

public boolean isCollection(T item)
Description copied from interface: WebdavTreeModel

Checks if any item is a collection or a 'file'. Collections may contain children whereas non-collection resources cannot. This information is not redundant to TreeModel.hasChildren(Object) because the tree model checks if a node actually contains children, whereas WebdavTreeModel.isCollection(Object) checks if a node MAY contain children.

This information is used to compute the following WebDAV properties:

resourcetype
Specifies the nature of the resource.

Specified by:
isCollection in interface WebdavTreeModel<T>
Parameters:
item - the item, not null
Returns:
true if the item may contain children, else false