pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.site.content
Class Content

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.util.entity.AbstractNamedEntity
          extended by org.torweg.pulse.util.entity.AbstractNamableEntity
              extended by org.torweg.pulse.site.content.Content
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Content>, JDOMable, ILinkCorretable, INameable, INamed
Direct Known Subclasses:
AbstractBasicContent

@Entity
public abstract class Content
extends AbstractNamableEntity
implements INameable, ILinkCorretable, java.lang.Comparable<Content>, JDOMable

An abstract base class for Contents referenced by a View in the Sitemap.

Version:
$Revision: 1825 $
Author:
Thomas Weber, Daniel Dietz, Christian Schatt
See Also:
Serialized Form

Constructor Summary
Content()
           
 
Method Summary
 int compareTo(Content pContent)
          Compares two Contents lexicographically.
abstract  Content createCopy(java.util.Locale l, User u)
          creates and returns a non-persistent (therefore id = null) copy of the current Content with a given Locale.
 boolean equals(java.lang.Object pObject)
          Determines whether the given Object is equal to the Content.
 java.util.Set<View> getAssociatedViews()
          Returns the Views of the Content.
 java.util.Set<VirtualFile> getAssociatedVirtualFiles()
          Returns the VirtualFiles of the Content.
 java.util.Set<Attachment> getAttachments()
          Returns the Attachments of the Content.
 Bundle getBundle()
          Returns the Bundle of the Content.
 java.util.Date getCreated()
          Returns the Date of the creation of the content.
 java.lang.Long getCreatedMillis()
          Returns the Date-millis of the creation of the content.
 User getCreator()
          Returns the User which has created the Content.
abstract  java.lang.StringBuilder getFullTextValue()
          Returns the StringBuilder to be indexed for site full text searches.
 java.util.Date getLastModified()
          Returns the Date of the last modification.
 User getLastModifier()
          Returns the User which has last modified the Content.
 java.util.Locale getLocale()
          Returns the Locale of the Content.
 ContentLocalizationMap getLocalizationMap()
          Returns the ContentLocalizationMap of the Content.
protected  ContentLocalizationMap getLocalizationMapJAXB()
          Deprecated. 
 Duration getReferenceDuration()
          returns the reference duration of the Content or null, if no Duration has been set.
 ViewTypes getViewTypes()
          Deprecated. 
 int hashCode()
          Returns a hash code for the Content.
 boolean hasReferenceDuration()
          returns whether the Content has a reference duration.
 void initLazyFields()
          initialises the content for display.
static void initLazyImageGroups(IHasMainImage hasMainImage)
          initialises lazy image groups for contents implementing IHasMainImage and/or IHasAlternativeImages.
static void initLazyVariants(IHasVariants hasVariants)
          initialises lazy variants for contents implementing IHasVariants.
abstract  boolean isGroup()
          Determines whether the Content is a group.
abstract  void onVirtualFileSystemChange(VirtualFile file)
          Is called by the VirtualFileSystem, if any associated VirtualFiles have been moved in the file system.
protected static void processHTML(org.jdom.Element html, java.util.Set<VirtualFile> files, VirtualFileSystem vfs)
          Searches the given Element for VirtualFiles, adds them to the given Set of VirtualFiles and adds a vfs-id attribute to the corresponding Element.
 Duration removeReferenceDuration()
          removes the current reference Duration and returns the previous value.
 void setAssociatedVirtualFiles(java.util.Set<VirtualFile> pVirtualFiles)
          Sets the VirtualFiles of the Content.
 void setAttachments(java.util.Set<Attachment> pAttachments)
          Sets the Attachments of the Content.
 void setBundle(Bundle pBundle)
          Sets the Bundle of the Content.
 void setCreator(User user)
          Sets the User which has created the Content.
 void setLastModifier(User user)
          Sets the User which has last modified the Content.
 void setLocale(java.util.Locale pLocale)
          Sets the Locale of the Content.
 void setLocalizationMap(ContentLocalizationMap pLocalizationMap)
          Sets the ContentLocalizationMap of the Content.
 void setReferenceDuration(Duration rd)
          sets the reference duration of the Content.
 java.lang.String toString()
          returns the Content's name and id.
abstract  void updateAssociatedVirtualFiles()
          is called by the editors upon save actions to update the list of associated VirtualFiles.
protected static org.jdom.Element updateHTML(org.jdom.Element html, VirtualFile file)
          Updates the src and href attributes in the given Element, referencing VirtualFiles by a vfs-id attribute.
protected  void updateLocalizationMap(ContentLocalizationMap pLocalizationMap)
          Is called by ContentLocalizationMap to update the ContentLocalizationMap of the Content.
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamableEntity
setName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamedEntity
getName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, getFullQualifiedClassNameJAXB, getId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.torweg.pulse.util.INameable
setName
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 
Methods inherited from interface org.torweg.pulse.site.content.util.ILinkCorretable
getLinkCorrectables
 
Methods inherited from interface org.torweg.pulse.bundle.JDOMable
deserializeToJDOM
 

Constructor Detail

Content

public Content()
Method Detail

getCreator

public final User getCreator()
Returns the User which has created the Content.

Returns:
the creator

setCreator

public final void setCreator(User user)
Sets the User which has created the Content.

Does set the Date for created.

Parameters:
user - the creator to set

getCreated

public final java.util.Date getCreated()
Returns the Date of the creation of the content.

Returns:
the created

getCreatedMillis

public final java.lang.Long getCreatedMillis()
Returns the Date-millis of the creation of the content.

Usage: for JAXB

Returns:
the created-millis

getLastModifier

public final User getLastModifier()
Returns the User which has last modified the Content.

Returns:
the lastModifier

setLastModifier

public final void setLastModifier(User user)
Sets the User which has last modified the Content.

Does set the Date for lastModified.

Parameters:
user - the User to set

getLastModified

public final java.util.Date getLastModified()
Returns the Date of the last modification.

Returns:
the lastModified

getLocale

public final java.util.Locale getLocale()
Returns the Locale of the Content.

Returns:
the Locale of the Content.

setLocale

public final void setLocale(java.util.Locale pLocale)
Sets the Locale of the Content.

Parameters:
pLocale - the Locale to be set.

getBundle

public final Bundle getBundle()
Returns the Bundle of the Content.

Returns:
the Bundle of the Content.

setBundle

public final void setBundle(Bundle pBundle)
Sets the Bundle of the Content.

Parameters:
pBundle - the Bundle to be set.

getLocalizationMap

public final ContentLocalizationMap getLocalizationMap()
Returns the ContentLocalizationMap of the Content.

Returns:
the ContentLocalizationMap of the Content.

getLocalizationMapJAXB

@Deprecated
protected final ContentLocalizationMap getLocalizationMapJAXB()
Deprecated. 

for JAXB only.

Returns:
this.getLocalizationMap()

setLocalizationMap

public final void setLocalizationMap(ContentLocalizationMap pLocalizationMap)
Sets the ContentLocalizationMap of the Content.

Parameters:
pLocalizationMap - the ContentLocalizationMap to be set.

updateLocalizationMap

protected final void updateLocalizationMap(ContentLocalizationMap pLocalizationMap)
Is called by ContentLocalizationMap to update the ContentLocalizationMap of the Content.

Parameters:
pLocalizationMap - the ContentLocalizationMap to be set.

getAssociatedViews

public final java.util.Set<View> getAssociatedViews()
Returns the Views of the Content.

Returns:
the Views of the Content. (shallow copy)

setAssociatedVirtualFiles

public final void setAssociatedVirtualFiles(java.util.Set<VirtualFile> pVirtualFiles)
Sets the VirtualFiles of the Content.

Parameters:
pVirtualFiles - the VirtualFiles to be set. (overwrite matching)

getAssociatedVirtualFiles

public final java.util.Set<VirtualFile> getAssociatedVirtualFiles()
Returns the VirtualFiles of the Content.

Returns:
the VirtualFiles of the Content. (reference)

setAttachments

public final void setAttachments(java.util.Set<Attachment> pAttachments)
Sets the Attachments of the Content.

Parameters:
pAttachments - the Attachments to be set. (overwrite matching)

getAttachments

public final java.util.Set<Attachment> getAttachments()
Returns the Attachments of the Content.

Returns:
the Attachments of the Content. (reference)

hasReferenceDuration

public final boolean hasReferenceDuration()
returns whether the Content has a reference duration.

Returns:
true, if and only if a reference duration has been set. Otherwise false.

getReferenceDuration

public final Duration getReferenceDuration()
returns the reference duration of the Content or null, if no Duration has been set.

Returns:
the reference duration of the Content or null

setReferenceDuration

public final void setReferenceDuration(Duration rd)
sets the reference duration of the Content.

Parameters:
rd - the reference duration

removeReferenceDuration

public final Duration removeReferenceDuration()
removes the current reference Duration and returns the previous value.

Returns:
the previous reference duration

equals

public final boolean equals(java.lang.Object pObject)
Determines whether the given Object is equal to the Content.

Overrides:
equals in class AbstractBasicEntity
Parameters:
pObject - the Object to be checked for equality with the Content.
Returns:
true, if the given Object is equal to the Content. Returns false, otherwise.

hashCode

public final int hashCode()
Returns a hash code for the Content.

Overrides:
hashCode in class AbstractBasicEntity
Returns:
a hash code for the Content
See Also:
AbstractBasicEntity.hashCode()

toString

public java.lang.String toString()
returns the Content's name and id.

Overrides:
toString in class java.lang.Object
Returns:
getName() + " [" + getId() + "]"
See Also:
Object.toString()

compareTo

public final int compareTo(Content pContent)
Compares two Contents lexicographically. Note: See the details below for a full explanation.

First, the names are compared lexicographically, using the Content's Locale. If the Content's Locale is null, the Locale of the given Content is used. If both Contents' Locales are null, the result of getName().compareTo(pContent.getName()) is used instead.

If the Contents' names are lexicographically equal, their ids are compared afterwards. If any of the two ids is null, the comparison scheme of BasicObject is used.

Specified by:
compareTo in interface java.lang.Comparable<Content>
Parameters:
pContent - the Content used for the comparison.
Returns:
-1, 0, or 1 as the Content is less than, equal to, or greater than the given Content.

getViewTypes

@Deprecated
public final ViewTypes getViewTypes()
Deprecated. 

Returns a ViewTypes containing all Views that may be combined with the Content.

Returns:
a ViewTypes containing all Views that may be combined with the Content.

initLazyFields

public void initLazyFields()
initialises the content for display.


initLazyVariants

public static final void initLazyVariants(IHasVariants hasVariants)
initialises lazy variants for contents implementing IHasVariants.

Parameters:
hasVariants - the IHasVariants to be initialised

initLazyImageGroups

public static final void initLazyImageGroups(IHasMainImage hasMainImage)
initialises lazy image groups for contents implementing IHasMainImage and/or IHasAlternativeImages.

Parameters:
hasMainImage - the IHasMainImage to be initialised

isGroup

public abstract boolean isGroup()
Determines whether the Content is a group.

A group is a Content generating its contents from its children in the Sitemap.

Returns:
true, if the Content is a group. Return false, otherwise.

getFullTextValue

public abstract java.lang.StringBuilder getFullTextValue()
Returns the StringBuilder to be indexed for site full text searches.

Returns:
the StringBuilder to be indexed for site full text searches.

onVirtualFileSystemChange

public abstract void onVirtualFileSystemChange(VirtualFile file)
Is called by the VirtualFileSystem, if any associated VirtualFiles have been moved in the file system.

Parameters:
file - the file that has been moved.

updateAssociatedVirtualFiles

public abstract void updateAssociatedVirtualFiles()
is called by the editors upon save actions to update the list of associated VirtualFiles.


createCopy

public abstract Content createCopy(java.util.Locale l, User u)
                            throws java.lang.UnsupportedOperationException
creates and returns a non-persistent (therefore id = null) copy of the current Content with a given Locale.

Parameters:
l - the Locale to use for the the copy
u - the User to be used as the creator/last modifier of the copied Content
Returns:
a copy of this Content
Throws:
java.lang.UnsupportedOperationException - where method is not supported (FilterContent, InstructionsContent)

processHTML

protected static final void processHTML(org.jdom.Element html,
                                        java.util.Set<VirtualFile> files, VirtualFileSystem vfs)
Searches the given Element for VirtualFiles, adds them to the given Set of VirtualFiles and adds a vfs-id attribute to the corresponding Element.

Parameters:
html - the Element to be searched.
files - the Set of VirtualFiles.
vfs - an instance of the VirtualFileSystem.

updateHTML

protected static final org.jdom.Element updateHTML(org.jdom.Element html, VirtualFile file)
Updates the src and href attributes in the given Element, referencing VirtualFiles by a vfs-id attribute.

Parameters:
html - the Element to be updated.
file - the VirtualFiles that have been changed.
Returns:
the updated Element.