org.opencms.file.collectors
Class A_CmsResourceCollector

java.lang.Object
  extended byorg.opencms.file.collectors.A_CmsResourceCollector
All Implemented Interfaces:
java.lang.Comparable, I_CmsResourceCollector
Direct Known Subclasses:
CmsCategoryResourceCollector, CmsDateResourceCollector, CmsDefaultResourceCollector, CmsPriorityResourceCollector, CmsTimeFrameCategoryCollector

public abstract class A_CmsResourceCollector
extends java.lang.Object
implements I_CmsResourceCollector

Provides some helpful base implementations for resource collector classes.

Since:
6.0.0
Version:
$Revision: 1.14 $
Author:
Alexander Kandzior

Field Summary
protected  int m_order
          The collector order of this collector.
 
Constructor Summary
A_CmsResourceCollector()
          Constructor to initialize some default values.
 
Method Summary
protected  void checkParams()
          Checks if the required parameters have been set.
 int compareTo(java.lang.Object obj)
           
 boolean equals(java.lang.Object obj)
          Two collectors are considered to be equal if they are sharing the same implementation class.
protected  java.lang.String getCreateInFolder(CmsObject cms, CmsCollectorData data)
          Returns the link to create a new XML content item in the folder pointed to by the parameter.
protected  java.lang.String getCreateInFolder(CmsObject cms, java.lang.String param)
          Returns the link to create a new XML content item in the folder pointed to by the parameter.
 java.lang.String getCreateLink(CmsObject cms)
          Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the default collector.
 java.lang.String getCreateParam(CmsObject cms)
          Returns the default parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.
 java.lang.String getDefaultCollectorName()
          Returns the default collector name to use for collecting resources.
 java.lang.String getDefaultCollectorParam()
          Returns the default collector parameter to use for collecting resources.
 int getOrder()
          Returns the "order weight" of this collector.
 java.util.List getResults(CmsObject cms)
          Returns a list of CmsResource Objects that are gathered in the VFS using the default collector name and parameter.
 int hashCode()
           
 void setDefaultCollectorName(java.lang.String collectorName)
          Sets the default collector name to use for collecting resources.
 void setDefaultCollectorParam(java.lang.String param)
          Sets the default collector parameter to use for collecting resources.
 void setOrder(int order)
          Sets the "order weight" of this collector.
protected  java.util.List shrinkToFit(java.util.List result, int maxSize)
          Shrinks a List to fit a maximum size.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.file.collectors.I_CmsResourceCollector
getCollectorNames, getCreateLink, getCreateParam, getResults
 

Field Detail

m_order

protected int m_order
The collector order of this collector.

Constructor Detail

A_CmsResourceCollector

public A_CmsResourceCollector()
Constructor to initialize some default values.

Method Detail

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(java.lang.Object obj)
Two collectors are considered to be equal if they are sharing the same implementation class.

See Also:
Object.equals(java.lang.Object)

getCreateLink

public java.lang.String getCreateLink(CmsObject cms)
                               throws CmsException,
                                      CmsDataAccessException
Description copied from interface: I_CmsResourceCollector
Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the default collector.

If this method returns null, it indicated that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateLink in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
the link to execute after a "new" button was clicked
Throws:
CmsDataAccessException - if the parameter attribute of the corresponding collector tag is invalid
CmsException - if something goes wrong
See Also:
I_CmsResourceCollector.getCreateLink(org.opencms.file.CmsObject)

getCreateParam

public java.lang.String getCreateParam(CmsObject cms)
                                throws CmsDataAccessException
Description copied from interface: I_CmsResourceCollector
Returns the default parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.

If this method returns null, it indicates that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateParam in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
the parameter that will be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method, or null
Throws:
CmsDataAccessException - if the param attrib of the corresponding collector tag is invalid
See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject)

getDefaultCollectorName

public java.lang.String getDefaultCollectorName()
Description copied from interface: I_CmsResourceCollector
Returns the default collector name to use for collecting resources.

Specified by:
getDefaultCollectorName in interface I_CmsResourceCollector
Returns:
the default collector name
See Also:
I_CmsResourceCollector.getDefaultCollectorName()

getDefaultCollectorParam

public java.lang.String getDefaultCollectorParam()
Description copied from interface: I_CmsResourceCollector
Returns the default collector parameter to use for collecting resources.

Specified by:
getDefaultCollectorParam in interface I_CmsResourceCollector
Returns:
the default collector parameter
See Also:
I_CmsResourceCollector.getDefaultCollectorParam()

getOrder

public int getOrder()
Description copied from interface: I_CmsResourceCollector
Returns the "order weight" of this collector.

The "order weight" is important because two collector classes may provide a collector with the same name. If this is the case, the collector implementation with the higher order number "overrules" the lower order number class.

Specified by:
getOrder in interface I_CmsResourceCollector
Returns:
the "order weight" of this collector
See Also:
I_CmsResourceCollector.getOrder()

getResults

public java.util.List getResults(CmsObject cms)
                          throws CmsDataAccessException,
                                 CmsException
Description copied from interface: I_CmsResourceCollector
Returns a list of CmsResource Objects that are gathered in the VFS using the default collector name and parameter.

Specified by:
getResults in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
a list of CmsXmlContent objects
Throws:
CmsDataAccessException - if the parameter attribute of the corresponding collector tag is invalid
CmsException - if something goes wrong
See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject)

hashCode

public int hashCode()
See Also:
Object.hashCode()

setDefaultCollectorName

public void setDefaultCollectorName(java.lang.String collectorName)
Description copied from interface: I_CmsResourceCollector
Sets the default collector name to use for collecting resources.

Specified by:
setDefaultCollectorName in interface I_CmsResourceCollector
Parameters:
collectorName - the default collector name
See Also:
I_CmsResourceCollector.setDefaultCollectorName(java.lang.String)

setDefaultCollectorParam

public void setDefaultCollectorParam(java.lang.String param)
Description copied from interface: I_CmsResourceCollector
Sets the default collector parameter to use for collecting resources.

Specified by:
setDefaultCollectorParam in interface I_CmsResourceCollector
Parameters:
param - the default collector parameter
See Also:
I_CmsResourceCollector.setDefaultCollectorParam(java.lang.String)

setOrder

public void setOrder(int order)
Description copied from interface: I_CmsResourceCollector
Sets the "order weight" of this collector.

Specified by:
setOrder in interface I_CmsResourceCollector
Parameters:
order - the order weight to set
See Also:
I_CmsResourceCollector.setOrder(int)

checkParams

protected void checkParams()
Checks if the required parameters have been set.

See Also:
setDefaultCollectorName(String), setDefaultCollectorParam(String)

getCreateInFolder

protected java.lang.String getCreateInFolder(CmsObject cms,
                                             CmsCollectorData data)
                                      throws CmsException
Returns the link to create a new XML content item in the folder pointed to by the parameter.

Parameters:
cms - the current CmsObject
data - the collector data to use
Returns:
the link to create a new XML content item in the folder
Throws:
CmsException - if something goes wrong
Since:
7.0.2

getCreateInFolder

protected java.lang.String getCreateInFolder(CmsObject cms,
                                             java.lang.String param)
                                      throws CmsException
Returns the link to create a new XML content item in the folder pointed to by the parameter.

Parameters:
cms - the current CmsObject
param - the folder name to use
Returns:
the link to create a new XML content item in the folder
Throws:
CmsException - if something goes wrong

shrinkToFit

protected java.util.List shrinkToFit(java.util.List result,
                                     int maxSize)
Shrinks a List to fit a maximum size.

Parameters:
result - a List
maxSize - the maximum size of the List
Returns:
the shrinked list