org.wso2.carbon.registry.core
Class CollectionImpl

java.lang.Object
  extended by org.wso2.carbon.registry.core.ResourceImpl
      extended by org.wso2.carbon.registry.core.CollectionImpl
All Implemented Interfaces:
Collection, Resource
Direct Known Subclasses:
CollectionVersionImpl

public class CollectionImpl
extends ResourceImpl
implements Collection

The default registry implementation of the Collection interface.


Field Summary
protected  int childCount
          The number of children in this collection.
 
Fields inherited from class org.wso2.carbon.registry.core.ResourceImpl
authorUserName, content, contentModified, createdTime, dataAccessManager, dbBasedContentID, description, directory, id, lastModified, lastUpdaterUserName, matchingSnapshotID, mediaType, name, parentPath, path, pathID, permanentPath, properties, propertiesModified, resourceDAO, snapshotID, state, tenantId, userName, userRealm, versionableChange, versionNumber
 
Fields inherited from interface org.wso2.carbon.registry.core.Collection
ALLOW_ALL, ALLOW_SELECTED, DENY_SELECTED
 
Constructor Summary
CollectionImpl()
          The default constructor of the CollectionImpl, Create an empty collection with no children.
CollectionImpl(CollectionImpl collection)
          A copy constructor used to create a shallow-copy of this collection.
CollectionImpl(String[] paths)
          Construct a collection with the provided children paths.
CollectionImpl(String path, ResourceDO resourceDO)
          Construct a collection with the provided path and the resource data object.
 
Method Summary
 void fillCollectionCopy(CollectionImpl collection)
          Copy all the values of the current collection attribute to the passed collection.
protected  String[] fixPaths(String[] paths)
          Method to fix duplicated entries in a collection's child paths.
 int getChildCount()
          Method to return the the number of children.
 String[] getChildren()
          Method to return the children.
 String[] getChildren(int start, int pageLen)
          Method to return the paths of the selected range of children.
 Object getContent()
          Collection's content is a string array, which contains paths of its children.
 ResourceImpl getShallowCopy()
          Method to return a shallow copy of a collection.
 void setChildCount(int count)
          Method to set the child count.
 void setChildren(String[] paths)
          Method to set the absolute paths of the children belonging to this collection.
 void setContent(Object content)
          Implementation for the setContent.
 void setContentWithNoUpdate(Object content)
          Set the resource content without marking the collection as updated.Here the content should always be a array of strings which corresponding to the children paths.
 
Methods inherited from class org.wso2.carbon.registry.core.ResourceImpl
addAspect, addProperty, addPropertyWithNoUpdate, clearSessionInformation, discard, editPropertyValue, fillResourceCopy, getAspects, getAuthorUserName, getContentStream, getCreatedTime, getDbBasedContentID, getDescription, getId, getLastModified, getLastUpdaterUserName, getMatchingSnapshotID, getMediaType, getName, getParentPath, getPath, getPathID, getPermanentPath, getProperties, getProperty, getPropertyValues, getResourceDO, getResourceIDImpl, getSnapshotID, getState, getVersionNumber, isContentModified, isPropertiesModified, isVersionableChange, prepareContentForPut, removeAspect, removeProperty, removePropertyValue, removePropertyWithNoUpdate, setAuthorUserName, setContentModified, setContentStream, setContentStreamWithNoUpdate, setCreatedTime, setDataAccessManager, setDbBasedContentID, setDescription, setId, setLastModified, setLastUpdaterUserName, setMatchingSnapshotID, setMediaType, setName, setParentPath, setPath, setPathID, setProperties, setPropertiesModified, setPropertiesModifiedWithNoUpdate, setProperty, setProperty, setSessionInformation, setSnapshotID, setState, setTenantId, setUserName, setUserRealm, setVersionableChange, setVersionNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wso2.carbon.registry.core.Resource
addAspect, addProperty, discard, editPropertyValue, getAspects, getAuthorUserName, getContentStream, getCreatedTime, getDescription, getId, getLastModified, getLastUpdaterUserName, getMediaType, getParentPath, getPath, getPermanentPath, getProperties, getProperty, getPropertyValues, getState, isVersionableChange, removeAspect, removeProperty, removePropertyValue, setContentStream, setDescription, setMediaType, setProperties, setProperty, setProperty, setVersionableChange
 

Field Detail

childCount

protected int childCount
The number of children in this collection.

Constructor Detail

CollectionImpl

public CollectionImpl()
The default constructor of the CollectionImpl, Create an empty collection with no children.


CollectionImpl

public CollectionImpl(String[] paths)
Construct a collection with the provided children paths.

Parameters:
paths - the children paths.

CollectionImpl

public CollectionImpl(String path,
                      ResourceDO resourceDO)
Construct a collection with the provided path and the resource data object.

Parameters:
path - the path of the collection.
resourceDO - the resource data object.

CollectionImpl

public CollectionImpl(CollectionImpl collection)
A copy constructor used to create a shallow-copy of this collection.

Parameters:
collection - the collection of which the copy is created.
Method Detail

setContent

public void setContent(Object content)
                throws RegistryException
Implementation for the setContent. Here the content should always be a array of strings which corresponding to the children paths.

Specified by:
setContent in interface Resource
Overrides:
setContent in class ResourceImpl
Parameters:
content - array of strings which corresponding to the children paths.
Throws:
RegistryException - if the operation fails.

setContentWithNoUpdate

public void setContentWithNoUpdate(Object content)
                            throws RegistryException
Set the resource content without marking the collection as updated.Here the content should always be a array of strings which corresponding to the children paths.

Overrides:
setContentWithNoUpdate in class ResourceImpl
Parameters:
content - array of strings which corresponding to the children paths.
Throws:
RegistryException - if the operation fails.

setChildren

public void setChildren(String[] paths)
                 throws RegistryException
Method to set the absolute paths of the children belonging to this collection. Absolute paths begin from the ROOT collection.

Specified by:
setChildren in interface Collection
Parameters:
paths - the array of absolute paths of the children
Throws:
RegistryException - if the operation fails.

getChildren

public String[] getChildren()
                     throws RegistryException
Method to return the children.

Specified by:
getChildren in interface Collection
Returns:
an array of children paths.
Throws:
RegistryException - if the operation fails.

getChildren

public String[] getChildren(int start,
                            int pageLen)
                     throws RegistryException
Method to return the paths of the selected range of children.

Specified by:
getChildren in interface Collection
Parameters:
start - the starting number of children.
pageLen - the number of entries to retrieve.
Returns:
an array of paths of the selected range of children.
Throws:
RegistryException - if the operation fails.

getChildCount

public int getChildCount()
                  throws RegistryException
Method to return the the number of children.

Specified by:
getChildCount in interface Collection
Returns:
the number of children.
Throws:
RegistryException - if the operation fails.

setChildCount

public void setChildCount(int count)
Method to set the child count.

Parameters:
count - the child count.

getContent

public Object getContent()
                  throws RegistryException
Collection's content is a string array, which contains paths of its children. These paths are loaded on demand to increase performance. It is recommended to use getChildren() method to get child paths of a collection, which provides pagination. Calling this method will load all child paths.

Specified by:
getContent in interface Resource
Overrides:
getContent in class ResourceImpl
Returns:
String array of child paths.
Throws:
RegistryException - On any error.

getShallowCopy

public ResourceImpl getShallowCopy()
                            throws RegistryException
Method to return a shallow copy of a collection.

Overrides:
getShallowCopy in class ResourceImpl
Returns:
the shallow copy of the collection.
Throws:
RegistryException - if the operation fails.

fillCollectionCopy

public void fillCollectionCopy(CollectionImpl collection)
                        throws RegistryException
Copy all the values of the current collection attribute to the passed collection.

Parameters:
collection - the collection to get all the current collection attribute copied.
Throws:
RegistryException - if the operation fails.

fixPaths

protected String[] fixPaths(String[] paths)
Method to fix duplicated entries in a collection's child paths.

Parameters:
paths - the collection's child paths.
Returns:
the distinct set of children.


Copyright © 2011 WSO2 Inc. All Rights Reserved.