Package net.anotheria.anodoc.data
Class Module
- java.lang.Object
-
- net.anotheria.anodoc.data.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).voidfillFromContainer(java.util.Hashtable container)Restores this module from a container.java.lang.StringgetCopyId()Returns the copyId.DocumentgetDocument(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.StringgetId()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.LoggergetLog()Returns the current logger.IModuleFactorygetModuleFactory()Returns the moduleFactory.java.lang.ObjectgetObject(java.lang.String key)This method is used by the storage to save not only the container, but the underlying data too.java.lang.StringgetOwnerId()Returns the ownerId.longgetSizeInBytes()Returns the size of the module in bytes.longgetStatisticalInformation()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 informationjava.lang.StringgetStorageId()Returns the id which is used to store this object.voidputDocument(Document aDoc)Puts the given document into this module.voidputList(DocumentList aList)Puts the given list into this module.voidsetCopyId(java.lang.String copyId)Sets the copyId.voidsetModuleFactory(IModuleFactory myFactory)Sets the moduleFactory.voidsetOwnerId(java.lang.String ownerId)Sets the ownerId.java.lang.StringtoString()Returns the String representation of this Module entity.net.anotheria.util.xml.XMLNodetoXMLNode()Creates an XMLNode for XML export.
-
-
-
Method Detail
-
getLog
protected org.slf4j.Logger getLog()
Returns the current logger. Creates one if needed.- Returns:
- a
Loggerobject.
-
getDocument
public Document getDocument(java.lang.String name) throws NoSuchDocumentException
Returns the document with given name (if there is any).- Parameters:
name- aStringobject.- Returns:
- a
Documentobject. - Throws:
NoSuchDocumentException- if any.
-
getList
public <D extends Document> DocumentList<D> getList(java.lang.String name) throws NoSuchDocumentListException
Returns the documentlist with given name (if there is any).- Parameters:
name- aStringobject.- Returns:
- a
DocumentListobject. - Throws:
NoSuchDocumentListException- if any.
-
putList
public void putList(DocumentList aList)
Puts the given list into this module.- Parameters:
aList- aDocumentListobject.
-
putDocument
public void putDocument(Document aDoc)
Puts the given document into this module.- Parameters:
aDoc- aDocumentobject.
-
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:
toStringin classjava.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:
getKeysin interfaceICompositeDataObject- 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:
getObjectin interfaceICompositeDataObject- 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:
getStorageIdin interfaceIBasicStoreableObject- 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- aHashtableobject.
-
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
Enumerationobject.
-
_getIdHolder
protected IDHolder _getIdHolder(java.lang.String docName)
Returns the id holder for a given document (name).- Parameters:
docName- aStringobject.- Returns:
- a
IDHolderobject.
-
toXMLNode
public net.anotheria.util.xml.XMLNode toXMLNode()
Creates an XMLNode for XML export.- Returns:
- a
XMLNodeobject.
-
-