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 Variant<T extends Variant<?>>

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.Variant<T>
Type Parameters:
T - the actual Variant-implementation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<T>, ExtendedJDOMable, JDOMable, IHasVariants, ILinkCorretable, INameable, INamed
Direct Known Subclasses:
AbstractBasicVariant

@Entity
public abstract class Variant<T extends Variant<?>>
extends AbstractNamableEntity
implements java.lang.Comparable<T>, ILinkCorretable, IHasVariants, ExtendedJDOMable

An abstract base class for Variants.

Version:
$Revision: 1501 $
Author:
Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Field Summary
protected static org.slf4j.Logger LOGGER
          The Logger of the Variant.
 
Constructor Summary
Variant()
           
 
Method Summary
 boolean addVariant(T variant)
          Adds a sub-Variant to the Variant.
 int compareTo(T pVariant)
          Compares two Variants lexicographically.
abstract  T createCopy(Content content)
          Creates a non-persistent (therefore id = null) copy of the current Variant.
 boolean equals(java.lang.Object pObject)
          Determines whether the given Object is equal to the Variant.
 java.util.Set<VirtualFile> getAssociatedVirtualFiles()
          Returns the VirtualFiles of the Variant.
 java.util.Set<Attachment> getAttachments()
          Returns the Attachments of the Variant.
abstract  Content getContent()
          Returns the Content the Variant belongs to.
abstract  java.lang.StringBuilder getFullTextValue()
          Returns the StringBuilder to be indexed for full text searches.
 T getParentVariant()
          Returns the parent-AbstractBasicVariant of the AbstractBasicVariant .
 java.util.Set<T> getVariants()
          Returns the sub-Variants of the Variant.
 int hashCode()
          Returns a hash code for the Variant.
abstract  void onVirtualFileSystemChange(VirtualFile file)
          Is called by the VirtualFileSystem, if any of the associated VirtualFiles has 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.
 boolean removeVariant(T variant)
          Removes the given Variant from the Variant.
 void setAssociatedVirtualFiles(java.util.Set<VirtualFile> pVirtualFiles)
          Sets the VirtualFiles of the Variant.
 void setAttachments(java.util.Set<Attachment> pAttachments)
          Sets the Attachments of the Variant.
protected abstract  void setContent(Content content)
          Sets the Content the Variant belongs to.
 void setVariants(java.util.Set<T> vars)
          Sets the Variants of the Variant.
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.
 
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, toString, wait, wait, wait
 
Methods inherited from interface org.torweg.pulse.site.content.util.ILinkCorretable
getLinkCorrectables
 
Methods inherited from interface org.torweg.pulse.bundle.ExtendedJDOMable
deserializeToJDOM
 
Methods inherited from interface org.torweg.pulse.bundle.JDOMable
deserializeToJDOM
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 

Field Detail

LOGGER

protected static final org.slf4j.Logger LOGGER
The Logger of the Variant.

Constructor Detail

Variant

public Variant()
Method Detail

getVariants

public final java.util.Set<T> getVariants()
Returns the sub-Variants of the Variant.

Specified by:
getVariants in interface IHasVariants
Returns:
the sub-Variants of the Variant

setVariants

public final void setVariants(java.util.Set<T> vars)
Sets the Variants of the Variant.

Parameters:
vars - the Variants to be set. (final)

addVariant

public final boolean addVariant(T variant)
Adds a sub-Variant to the Variant.

Parameters:
variant - the Content to be added
Returns:
true if and only if the given Variant has been added to the internal List&lt;Variant&gt;, false otherwise

removeVariant

public final boolean removeVariant(T variant)
Removes the given Variant from the Variant.

Parameters:
variant - the Variant to be removed
Returns:
true if and only if the given Variant has been removed from the internal List&lt;Variant&gt;, false otherwise

getParentVariant

public final T getParentVariant()
Returns the parent-AbstractBasicVariant of the AbstractBasicVariant .

Returns:
the parent-AbstractBasicVariant of the AbstractBasicVariant

getAssociatedVirtualFiles

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

Returns:
the VirtualFiles of the Variant. (reference)

setAssociatedVirtualFiles

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

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

getAttachments

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

Returns:
the Attachments of the Variant. (reference)

setAttachments

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

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

equals

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

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

hashCode

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

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

compareTo

public final int compareTo(T pVariant)
Compares two Variants lexicographically. Note: See the details below for a full explanation.

First, the names are compared lexicographically, using the result of getName().compareTo(pVariant.getName()). If the Variants' 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<T extends Variant<?>>
Parameters:
pVariant - the Variant used for the comparison.
Returns:
-1, 0, or 1 as the Variant is less than, equal to, or greater than the given Variant.

getFullTextValue

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

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

onVirtualFileSystemChange

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

Parameters:
file - the associated VirtualFile that has been moved in the file system.

createCopy

public abstract T createCopy(Content content)
                                         throws java.lang.UnsupportedOperationException
Creates a non-persistent (therefore id = null) copy of the current Variant.

Parameters:
content - the parent Content
Returns:
a copy of the Variant.
Throws:
java.lang.UnsupportedOperationException - if the method is not supported.

getContent

public abstract Content getContent()
Returns the Content the Variant belongs to.

Returns:
Content

setContent

protected abstract void setContent(Content content)
Sets the Content the Variant belongs to.

Parameters:
content - Content

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 VirtualFile that has been changed.
Returns:
the updated Element.