Class Module

  • All Implemented Interfaces:
    java.io.Serializable, IBasicStoreableObject, ICompositeDataObject

    public class Module
    extends java.lang.Object
    implements ICompositeDataObject, java.io.Serializable
    This class describes a Module, which is a unity that can be stored and identified by the framework. Each module is identified by the tuple (moduleId, ownerId, copyId). The moduleId (or just id) is used to determine the proper factory and storage, the ownerId represents the owner of the module, which could be a user of the system or a content piece by content supporting functions (comments, netlogs, etc) and the copyId is used for multiple copies systems or for context separation.
    A Module shouldn't be used directly, instead it should be extended and enhanced with the methods that are needed for the business logic.
    Version:
    $Id: $Id
    Author:
    another
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Module​(java.lang.String anId)
      Creates a new Module with given moduleId.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected IDHolder _getIdHolder​(java.lang.String docName)
      Returns the id holder for a given document (name).
      void fillFromContainer​(java.util.Hashtable container)
      Restores this module from a container.
      java.lang.String getCopyId()
      Returns the copyId.
      Document getDocument​(java.lang.String name)
      Returns the document with given name (if there is any).
      java.util.Enumeration<java.lang.String> getHolderNames()
      Returns the names of the holders contained in this module.
      java.lang.String getId()
      Returns the id.
      java.util.Enumeration<java.lang.String> getKeys()
      This method is used by the storage to query the underlying data.
      <D extends Document>
      DocumentList<D>
      getList​(java.lang.String name)
      Returns the documentlist with given name (if there is any).
      protected org.slf4j.Logger getLog()
      Returns the current logger.
      IModuleFactory getModuleFactory()
      Returns the moduleFactory.
      java.lang.Object getObject​(java.lang.String key)
      This method is used by the storage to save not only the container, but the underlying data too.
      java.lang.String getOwnerId()
      Returns the ownerId.
      long getSizeInBytes()
      Returns the size of the module in bytes.
      long getStatisticalInformation()
      Overwrite this to return some statistical information for netStats (activity module) which would be save automatically on each module save.
      Return -1 if you don't want to provide any statistical information
      java.lang.String getStorageId()
      Returns the id which is used to store this object.
      void putDocument​(Document aDoc)
      Puts the given document into this module.
      void putList​(DocumentList aList)
      Puts the given list into this module.
      void setCopyId​(java.lang.String copyId)
      Sets the copyId.
      void setModuleFactory​(IModuleFactory myFactory)
      Sets the moduleFactory.
      void setOwnerId​(java.lang.String ownerId)
      Sets the ownerId.
      java.lang.String toString()
      Returns the String representation of this Module entity.
      net.anotheria.util.xml.XMLNode toXMLNode()
      Creates an XMLNode for XML export.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Module

        public Module​(java.lang.String anId)
        Creates a new Module with given moduleId.
        Parameters:
        anId - the id of the module.
    • Method Detail

      • getLog

        protected org.slf4j.Logger getLog()
        Returns the current logger. Creates one if needed.
        Returns:
        a Logger object.
      • putList

        public void putList​(DocumentList aList)
        Puts the given list into this module.
        Parameters:
        aList - a DocumentList object.
      • putDocument

        public void putDocument​(Document aDoc)
        Puts the given document into this module.
        Parameters:
        aDoc - a Document object.
      • getOwnerId

        public java.lang.String getOwnerId()
        Returns the ownerId.
        Returns:
        String
      • setOwnerId

        public void setOwnerId​(java.lang.String ownerId)
        Sets the ownerId.
        Parameters:
        ownerId - The ownerId to set
      • getId

        public java.lang.String getId()
        Returns the id.
        Returns:
        String
      • getCopyId

        public java.lang.String getCopyId()
        Returns the copyId.
        Returns:
        String
      • setCopyId

        public void setCopyId​(java.lang.String copyId)
        Sets the copyId.
        Parameters:
        copyId - The copyId to set
      • toString

        public java.lang.String toString()
        Returns the String representation of this Module entity.
        Overrides:
        toString in class java.lang.Object
      • getKeys

        public java.util.Enumeration<java.lang.String> getKeys()
        This method is used by the storage to query the underlying data. It's also used by debug or administration programs to trace a composite object, such as Document.
        Specified by:
        getKeys in interface ICompositeDataObject
        Returns:
        the keys (ids) of contained elements.
      • getObject

        public java.lang.Object getObject​(java.lang.String key)
        This method is used by the storage to save not only the container, but the underlying data too. It's also used by debug or administration programs to trace a composite object, such as Document.
        Specified by:
        getObject in interface ICompositeDataObject
        Parameters:
        key - the key (id) of the contained element/object.
        Returns:
        the object associated to the key.
      • getStorageId

        public java.lang.String getStorageId()
        Returns the id which is used to store this object. This id should be an unique identifier in the objects environment (container).
        Specified by:
        getStorageId in interface IBasicStoreableObject
        Returns:
        id which is used to store this object
      • fillFromContainer

        public void fillFromContainer​(java.util.Hashtable container)
        Restores this module from a container. When a Module is saved, it's not saved as is, but only it's contents (which recursively matches for contained documents too). If a Module instance is loaded, it have to be reassembled which happens in this function.
        Parameters:
        container - a Hashtable object.
      • getModuleFactory

        public IModuleFactory getModuleFactory()
        Returns the moduleFactory.
        Returns:
        IModuleFactory
      • setModuleFactory

        public void setModuleFactory​(IModuleFactory myFactory)
        Sets the moduleFactory.
        Parameters:
        myFactory - The moduleFactory to set
      • getStatisticalInformation

        public long getStatisticalInformation()
        Overwrite this to return some statistical information for netStats (activity module) which would be save automatically on each module save.
        Return -1 if you don't want to provide any statistical information
        Returns:
        a long.
      • getSizeInBytes

        public long getSizeInBytes()
        Returns the size of the module in bytes. Actually it checks the size of all contained Documents and DocumentLists and returns the cumulated value.
        Returns:
        the size of the data in the module in bytes.
      • getHolderNames

        public java.util.Enumeration<java.lang.String> getHolderNames()
        Returns the names of the holders contained in this module.
        Returns:
        a Enumeration object.
      • _getIdHolder

        protected IDHolder _getIdHolder​(java.lang.String docName)
        Returns the id holder for a given document (name).
        Parameters:
        docName - a String object.
        Returns:
        a IDHolder object.
      • toXMLNode

        public net.anotheria.util.xml.XMLNode toXMLNode()
        Creates an XMLNode for XML export.
        Returns:
        a XMLNode object.