org.hippoecm.hst.mock.content.beans.standard
Class MockHippoBean

java.lang.Object
  extended by org.hippoecm.hst.mock.content.beans.standard.MockHippoBean
All Implemented Interfaces:
Comparable<HippoBean>, ObjectConverterAware, NodeAware, HippoBean
Direct Known Subclasses:
MockHippoResourceBean

public class MockHippoBean
extends Object
implements HippoBean


Constructor Summary
MockHippoBean()
           
 
Method Summary
 int compareTo(HippoBean o)
           
 boolean equalCompare(Object compare)
          A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node.
<T extends HippoBean>
HippoAvailableTranslationsBean<T>
getAvailableTranslationsBean()
          In general, only a HippoDocumentBean and HippoFolderBean can have a HippoAvailableTranslationsBean.
<T> T
getBean(String relPath)
          This methods fetches a child HippoBean with the relative path relPath.
<T extends HippoBean>
T
getBean(String relPath, Class<T> beanMappingClass)
           
 String getCanonicalPath()
          Returns the jcr path of the backing canonical (physical) jcr node or null when
 String getCanonicalUUID()
          Returns the jcr uuid of the backing canonical (physical) jcr node or null when
<T extends HippoBean>
List<T>
getChildBeans(Class<T> beanMappingClass)
           Returns all the child beans as a List with elements of type T.
<T> List<T>
getChildBeans(String jcrPrimaryNodeType)
          Returns all the child beans of this bean, where the backing jcr node primary node type equals jcrPrimaryNodeType.
<T> List<T>
getChildBeansByName(String childNodeName)
          Returns all the child beans of name childNodeName as a List with elements of type T.
<T extends HippoBean>
List<T>
getChildBeansByName(String childNodeName, Class<T> beanMappingClass)
           Returns all the child beans of name childNodeName as a List with elements of type T.
 HippoBean getContextualBean()
          Expert: Returns the 'real' contextual (preview / live context) bean version of this bean.
 HippoBean getContextualParentBean()
          Expert: Returns the parent bean in the context of live/preview.
 Map<Object,Object> getEqualComparator()
          A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node.
<T extends HippoBean>
T
getLinkedBean(String relPath, Class<T> beanMappingClass)
          This method returns the HippoBean linked by relPath of type beanMappingClass, or null if no bean found or not of (sub)type beanMappingClass.
<T extends HippoBean>
List<T>
getLinkedBeans(String relPath, Class<T> beanMappingClass)
          This method returns all the HippoBean's linked by relPath of type beanMappingClass as a List, or an Empty list if no bean found or not of (sub)type beanMappingClass.
 String getLocalizedName()
          This returns the localized node name of the backing jcr node for this bean.
 String getName()
          This returns the node name of the backing jcr node for this bean
 javax.jcr.Node getNode()
          This returns the backing jcr node for this bean.
 ObjectConverter getObjectConverter()
           
 HippoBean getParentBean()
          Returns the parent bean wrt this bean.
 String getPath()
          This returns the absolute path of the backing jcr node for this bean, for example /documents/content/myprojec/news/article When the jcr node is virtual, it returns the virtual path.
 Map<String,Object> getProperties()
          Same as HippoBean.getProperty(String), where getProperty is only there for having a nice .getProperty['propname'] in jsp expression language
 Map<String,Object> getProperty()
           
<T> T
getProperty(String name)
          Return types can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]
<T> T
getProperty(String name, T defaultValue)
          If the property does not exist, return the defaultValue.
 JCRValueProvider getValueProvider()
           
 boolean isAncestor(HippoBean compare)
          Returns true when this HippoBean is an ancestor of the compare HippoBean.
 boolean isDescendant(HippoBean compare)
          Returns true when this HippoBean is an descendant of the compare HippoBean.
 boolean isHippoDocumentBean()
           
 boolean isHippoFolderBean()
           
 boolean isLeaf()
           
 boolean isSelf(HippoBean compare)
          Returns true when this HippoBean has a underlying jcr node with the same jcr path as the compare HippoBean.
 void setNode(javax.jcr.Node node)
          Callback that supplies the originating JCR node.
 void setObjectConverter(ObjectConverter objectConverter)
          Callback that supplies the object converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockHippoBean

public MockHippoBean()
Method Detail

equalCompare

public boolean equalCompare(Object compare)
Description copied from interface: HippoBean
A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node. When the nodes being compared have the same canonical node (physical equivalence) this method returns true. If there is no canonical node the virtual jcr path is used to compare the items: if these paths are the same, true is returned Note: this method compares the jcr path of the backing canonical jcr nodes. The #equals(Object) tests the jcr node path, which might be a virtual path. So this method can return true while #equals(Object) returns false

Specified by:
equalCompare in interface HippoBean
Parameters:
compare - the object to compare to
Returns:
true if the object compared has the same canonical node or the same virtual path when they don't have a canonical

getAvailableTranslationsBean

public <T extends HippoBean> HippoAvailableTranslationsBean<T> getAvailableTranslationsBean()
Description copied from interface: HippoBean
In general, only a HippoDocumentBean and HippoFolderBean can have a HippoAvailableTranslationsBean. However, to make sure that on any HippoBean you can call HippoBean.getAvailableTranslationsBean(), we add it to the base HippoBean as well. If the bean is not a document or folder, this method will return a no-operation HippoAvailableTranslationsBean instance.

Specified by:
getAvailableTranslationsBean in interface HippoBean
Returns:
A HippoAvailableTranslationsBean. If there are no translations for this HippoBean, a no-operation HippoAvailableTranslationsBean will be returned

getBean

public <T> T getBean(String relPath)
Description copied from interface: HippoBean
This methods fetches a child HippoBean with the relative path relPath. A relPath is not allowed to start with a "/", as this is considered to be an absolute path. For example getBean("x/y") is a valid relative path. "../x" is also supported, but dis-encouraged as the "../" works directly on jcr level, which does not take the hippo:handle intermediate node into account in case of a HippoDocument bean. Always preferred to use is HippoBean.getParentBean() instead of using "../". In case of a HippoDocument kind of bean, the HippoBean.getParentBean() jumps to the parent of the handle, while ../ jumps to the handle, resulting in the exact same bean in case of a HippoDocument

Specified by:
getBean in interface HippoBean
Parameters:
relPath - a path that does not start with a "/"
Returns:
returns the HippoBean with relative path relPath to this bean, or null when it does not exist, or when the relPath is not a valid relative path

getBean

public <T extends HippoBean> T getBean(String relPath,
                                       Class<T> beanMappingClass)
Specified by:
getBean in interface HippoBean
Parameters:
relPath - a path that does not start with a "/"
beanMappingClass - the class T that the child bean must be off
Returns:
returns the HippoBean of (sub)type beanMappingClass with relative path relPath to this bean, or null when it does not exist, is not of (sub)type beanMappingClass, or when the relPath is not a valid relative path

getCanonicalUUID

public String getCanonicalUUID()
Description copied from interface: HippoBean
Returns the jcr uuid of the backing canonical (physical) jcr node or null when

For HippoDocumentBean's, the uuid of the handle might be more valuable, which you can get with HippoDocumentBean.getCanonicalHandleUUID().

Specified by:
getCanonicalUUID in interface HippoBean
Returns:
the jcr uuid of the backing canonical (physical) jcr node or null
See Also:
HippoDocumentBean.getCanonicalHandleUUID()

getChildBeans

public <T extends HippoBean> List<T> getChildBeans(Class<T> beanMappingClass)
Description copied from interface: HippoBean

Returns all the child beans as a List with elements of type T. When a child bean is found that is not of type beanMappingClass, it is skipped

If you want all child beans that can be mapped to a HippoBean, just call List beans = getBeans(HippoBean.class);

Specified by:
getChildBeans in interface HippoBean
Type Parameters:
T - the return type of the child bean
Parameters:
beanMappingClass - the class T that the child beans must be off
Returns:
List where the backing jcr nodes have the name childNodeName

getChildBeans

public <T> List<T> getChildBeans(String jcrPrimaryNodeType)
Description copied from interface: HippoBean
Returns all the child beans of this bean, where the backing jcr node primary node type equals jcrPrimaryNodeType. If a jcr child node is of primary nodetype 'hippo:handle', we look whether the underlying 'Document' has the corresponding jcrPrimaryNodeType. If so, we return the bean for this 'Document'.

Specified by:
getChildBeans in interface HippoBean
Type Parameters:
T - the return type of the List elements
Parameters:
jcrPrimaryNodeType - the primary type the child beans should be off
Returns:
List where the backing jcr nodes are of type jcrPrimaryNodeType

getChildBeansByName

public <T> List<T> getChildBeansByName(String childNodeName)
                            throws ClassCastException
Description copied from interface: HippoBean
Returns all the child beans of name childNodeName as a List with elements of type T. When a found bean is not of type T a ClassCastException is thrown.

Specified by:
getChildBeansByName in interface HippoBean
Type Parameters:
T - the return type of the child bean
Returns:
List where the backing jcr nodes have the name childNodeName
Throws:
ClassCastException

getChildBeansByName

public <T extends HippoBean> List<T> getChildBeansByName(String childNodeName,
                                                         Class<T> beanMappingClass)
Description copied from interface: HippoBean

Returns all the child beans of name childNodeName as a List with elements of type T. When a child bean is found that is not of type beanMappingClass, it is skipped

If the beanMappingClass is null, it is ignored. Then, this method returns the same a HippoBean.getChildBeansByName(String) and can throw a ClassCastException

Specified by:
getChildBeansByName in interface HippoBean
Type Parameters:
T - the return type of the child bean
beanMappingClass - the class T that the child beans must be off.
Returns:
List where the backing jcr nodes have the name childNodeName

getContextualBean

public HippoBean getContextualBean()
Description copied from interface: HippoBean
Expert: Returns the 'real' contextual (preview / live context) bean version of this bean. Most of the time, this is just the current bean. However, when the current bean is below some parent bean because it was mirrored by this parent, then, this method returns the 'real' contextual version, where the HippoBean.getParentBean() also returns the contextualized version of the physical parent note: this is quite an expensive check

Specified by:
getContextualBean in interface HippoBean
Returns:
the contextual bean for this bean, or null if it fails to contextualize this bean

getContextualParentBean

public HippoBean getContextualParentBean()
Description copied from interface: HippoBean
Expert: Returns the parent bean in the context of live/preview.

Specified by:
getContextualParentBean in interface HippoBean
Returns:
the 'unmirrored' parent bean in wrt this bean, but still in context, or if this bean backing jcr node is null or if the object converter cannot create a bean for the parent, return null
See Also:
#getParentBean()}, only this method returns the 'real' contextual parent bean. Suppose I have some HippoBean (= myBean), that I got through a mirror, in other, words, the HippoBean is below the document (=docA) that had the mirror (link). {@link #getParentBean()} will return docA, but this is not the 'real' contextual parent bean of myBean. The 'real' contextual parent can be fetched through this method. Note, that when myBean was not the result of a mirror, that {@link #getParentBean()} will then return the same bean note: this is quite an expensive check

getEqualComparator

public Map<Object,Object> getEqualComparator()
Description copied from interface: HippoBean
A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node. When the nodes being compared have the same canonical node (physical equivalence) the get(Object o) returns true. In expression language, for example jsp, you can use to compare as follows: ${mydocument.equalComparator[otherdocument]} returns true when mydocument and otherdocument have the same canonical node If there is no canonical node the virtual jcr path is used to compare the items: if these paths are the same, true is returned Note: this method compares the jcr path of the backing canonical jcr nodes. The #equals(Object) tests the jcr node path, which might be a virtual path. So this method can return true while #equals(Object) returns false

Specified by:
getEqualComparator in interface HippoBean
Returns:
a ComparatorMap in which you can compare HippoBean's via the get(Object o)

getLinkedBean

public <T extends HippoBean> T getLinkedBean(String relPath,
                                             Class<T> beanMappingClass)
Description copied from interface: HippoBean
This method returns the HippoBean linked by relPath of type beanMappingClass, or null if no bean found or not of (sub)type beanMappingClass. Only a bean can be returned if, and only if, the bean at relPath is a bean of type HippoMirrorBean (thus either a hippo:mirror or hippo:facetselect). If a mirror bean is found, and the mirror points to a bean of (sub)type beanMappingClass, then, this bean is returned. In all other cases, null is returned

Specified by:
getLinkedBean in interface HippoBean
Parameters:
relPath - (path not starting with a "/")
Returns:
The linked HippoBean of (sub)type beanMappingClass where the link has relative path relPath to this bean, or null when it does not exist, is not of (sub)type beanMappingClass, or when the relPath is not a valid relative path

getLinkedBeans

public <T extends HippoBean> List<T> getLinkedBeans(String relPath,
                                                    Class<T> beanMappingClass)
Description copied from interface: HippoBean
This method returns all the HippoBean's linked by relPath of type beanMappingClass as a List, or an Empty list if no bean found or not of (sub)type beanMappingClass. if the relPath is something like: foo/bar/my:links, then, all first the node foo/bar is fetched, and then all beans are returned that have name 'my:links'

Specified by:
getLinkedBeans in interface HippoBean
Parameters:
relPath - (path not starting with a "/")
Returns:
See Also:
#getBean(String, Class)}

getLocalizedName

public String getLocalizedName()
Description copied from interface: HippoBean
This returns the localized node name of the backing jcr node for this bean. If it is a HippoNode is returns HippoNode.getLocalizedName(), otherwise Item.getName()

Specified by:
getLocalizedName in interface HippoBean
Returns:
the localized node name of the backing jcr node and null when some RepositoryException happens

getName

public String getName()
Description copied from interface: HippoBean
This returns the node name of the backing jcr node for this bean

Specified by:
getName in interface HippoBean
Returns:
the node name of the backing jcr node. This method never returns null

getNode

public javax.jcr.Node getNode()
Description copied from interface: HippoBean
This returns the backing jcr node for this bean.

Specified by:
getNode in interface HippoBean
Returns:
the backing jcr node for this bean. null if the bean is detached

getParentBean

public HippoBean getParentBean()
Description copied from interface: HippoBean
Returns the parent bean wrt this bean. Note that this does not automatically imply a bean with the parent jcr node of this bean. When the parent node is of type "hippo:handle", the parent of the handle must be taken

Specified by:
getParentBean in interface HippoBean
Returns:
the parent bean wrt this bean, or if this bean backing jcr node is null or object converter cannot create a bean for the parent, return null

getPath

public String getPath()
Description copied from interface: HippoBean
This returns the absolute path of the backing jcr node for this bean, for example /documents/content/myprojec/news/article When the jcr node is virtual, it returns the virtual path.

Specified by:
getPath in interface HippoBean
Returns:
the absolute jcr path of the backing jcr node.

getProperties

public Map<String,Object> getProperties()
Description copied from interface: HippoBean
Same as HippoBean.getProperty(String), where getProperty is only there for having a nice .getProperty['propname'] in jsp expression language

Specified by:
getProperties in interface HippoBean

getProperty

public <T> T getProperty(String name)
Description copied from interface: HippoBean
Return types can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]

Specified by:
getProperty in interface HippoBean
Parameters:
name - the name of the property
Returns:
The value of the property and null if it does not exist. The return type is either String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]

getProperty

public <T> T getProperty(String name,
                         T defaultValue)
Description copied from interface: HippoBean
If the property does not exist, return the defaultValue. If the property does exist, the same value as HippoBean.getProperty(String) will be returned Return types can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]

Specified by:
getProperty in interface HippoBean
Parameters:
name - the name of the property
Returns:
The value of the property and defaultValue if it does not exist. The return type is either String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]

getProperty

public Map<String,Object> getProperty()
Specified by:
getProperty in interface HippoBean
Returns:
Map of all properties, where the values can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]

getValueProvider

public JCRValueProvider getValueProvider()
Specified by:
getValueProvider in interface HippoBean

isAncestor

public boolean isAncestor(HippoBean compare)
Description copied from interface: HippoBean
Returns true when this HippoBean is an ancestor of the compare HippoBean. Note that this is done by the jcr path of the backing jcr node. In case of a virtual node, the virtual path is taken.

Specified by:
isAncestor in interface HippoBean
Returns:
true when this HippoBean is an ancestor of the compare HippoBean.

isDescendant

public boolean isDescendant(HippoBean compare)
Description copied from interface: HippoBean
Returns true when this HippoBean is an descendant of the compare HippoBean. Note that this is done by the jcr path of the backing jcr node. In case of a virtual node, the virtual path is taken. This means, that although the canonical nodes of the backing jcr nodes might return true for this method, this does not automatically holds for the beans of the virtual nodes.

Specified by:
isDescendant in interface HippoBean
Returns:
true when this HippoBean is an descendant of the compare HippoBean.

isHippoDocumentBean

public boolean isHippoDocumentBean()
Specified by:
isHippoDocumentBean in interface HippoBean
Returns:
true is this HippoBean is an instanceof HippoDocumentBean

isHippoFolderBean

public boolean isHippoFolderBean()
Specified by:
isHippoFolderBean in interface HippoBean
Returns:
true is this HippoBean is an instanceof HippoFolderBean

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface HippoBean
Returns:
true when the backing jcr Node has no child nodes

isSelf

public boolean isSelf(HippoBean compare)
Description copied from interface: HippoBean
Returns true when this HippoBean has a underlying jcr node with the same jcr path as the compare HippoBean. This means, that two HippoBeans might have the same canonical underlying jcr node, but do not return true because their virtual node might have different jcr paths.

Specified by:
isSelf in interface HippoBean
Returns:
Returns true when this HippoBean has the same underlying jcr node path as the compare HippoBean.

setNode

public void setNode(javax.jcr.Node node)
Description copied from interface: NodeAware
Callback that supplies the originating JCR node.

Specified by:
setNode in interface NodeAware

getObjectConverter

public ObjectConverter getObjectConverter()
Specified by:
getObjectConverter in interface ObjectConverterAware
Returns:
the ObjectConverter

setObjectConverter

public void setObjectConverter(ObjectConverter objectConverter)
Description copied from interface: ObjectConverterAware
Callback that supplies the object converter.

Specified by:
setObjectConverter in interface ObjectConverterAware

compareTo

public int compareTo(HippoBean o)
Specified by:
compareTo in interface Comparable<HippoBean>

getCanonicalPath

public String getCanonicalPath()
Description copied from interface: HippoBean
Returns the jcr path of the backing canonical (physical) jcr node or null when

For HippoDocumentBean's, the uuid of the handle might be more valuable, which you can get with HippoDocumentBean.getCanonicalHandleUUID().

Specified by:
getCanonicalPath in interface HippoBean
Returns:
the jcr path of the backing canonical (physical) jcr node or null
See Also:
HippoDocumentBean.getCanonicalHandlePath()


Copyright © 2008-2012 Hippo. All Rights Reserved.