Interface HippoBean
-
- All Superinterfaces:
Comparable<HippoBean>
,ContentBean
,IdentifiableContentBean
,NodeAware
,ObjectConverterAware
- All Known Subinterfaces:
HippoAssetBean
,HippoCompoundBean
,HippoDocumentBean
,HippoFacetChildNavigationBean
,HippoFacetNavigationBean
,HippoFolderBean
,HippoGalleryImageBean
,HippoGalleryImageSetBean
,HippoHtmlBean
,HippoMirrorBean
,HippoRequestBean
,HippoResourceBean
,HippoResultSetBean
,HippoVirtualOnlyBean
public interface HippoBean extends IdentifiableContentBean, NodeAware, ObjectConverterAware, Comparable<HippoBean>
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Logger
log
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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>getAvailableTranslations()
<T> T
getBean(String relPath)
This methods fetches a childHippoBean
with the relative path relPath.<T extends HippoBean>
TgetBean(String relPath, Class<T> beanMappingClass)
Only if a bean found of typebeanMappingClass
, it is returned, and otherwisenull
is returned.<T extends HippoBean>
TgetBeanByUUID(String uuid, Class<T> beanMappingClass)
<T extends HippoBean>
TgetCanonicalBean()
Returns the canonical version of the currentHippoBean
ornull
in case that the backingNode
is pure virtual, which is the case for example for some faceted navigation nodes.String
getCanonicalPath()
Returns the jcr path of the backing canonical (physical) jcr node ornull
whenString
getCanonicalUUID()
Returns the jcr uuid of the backing canonical (physical) jcr node ornull
when<T extends HippoBean>
List<T>getChildBeans(Class<T> beanMappingClass)
Returns all the child beans as aList
with elements of typeT
.<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)
<T extends HippoBean>
List<T>getChildBeansByName(String childNodeName, Class<T> beanMappingClass)
default String
getComparePath()
Returns the canonical pathdefault String
getContentType()
String
getDisplayName()
Returns the display name of the backing jcr node for this bean as determined by itshippo:name
property or the node name of the backing jcr node if no such property existsMap<Object,Object>
getEqualComparator()
A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node.<T extends HippoBean>
TgetLinkedBean(String relPath, Class<T> beanMappingClass)
This method returns theHippoBean
linked byrelPath
of type beanMappingClass.<T extends HippoBean>
List<T>getLinkedBeans(String relPath, Class<T> beanMappingClass)
Same asgetLinkedBean(String, Class)
only now all linked beans found atrelPath
are returned.<T> T[]
getMultipleProperty(String name)
Returns the value of a document field which is marked asmultiple
.<T> T[]
getMultipleProperty(String name, T[] defaultValue)
Returns the value of a document field which is marked asmultiple
.String
getName()
This returns the node name of the backing jcr node for this beanjavax.jcr.Node
getNode()
This returns the backing jcr node for this bean.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 asgetSingleProperty(String)
, where getProperty is only there for having a nice .getProperty['propname'] in jsp expression languageMap<String,Object>
getProperty()
<T> T
getSingleProperty(String name)
Returns the value of a document field which is marked assingle
.<T> T
getSingleProperty(String name, T defaultValue)
Returns the value of a document field which is marked assingle
.JCRValueProvider
getValueProvider()
boolean
isAncestor(HippoBean compare)
Returnstrue
when thisHippoBean
is an ancestor of thecompare
HippoBean.boolean
isDescendant(HippoBean compare)
Returnstrue
when thisHippoBean
is an descendant of thecompare
HippoBean.boolean
isHippoDocumentBean()
boolean
isHippoFolderBean()
boolean
isLeaf()
boolean
isSelf(HippoBean compare)
Returnstrue
when thisHippoBean
has a underlying jcr node with the same jcr path as thecompare
HippoBean.boolean
isVersionedNode()
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.hippoecm.hst.content.beans.standard.IdentifiableContentBean
getIdentifier, getRepresentationId, setIdentifier
-
Methods inherited from interface org.hippoecm.hst.content.beans.manager.ObjectConverterAware
getObjectConverter, setObjectConverter
-
-
-
-
Method Detail
-
getNode
javax.jcr.Node getNode()
This returns the backing jcr node for this bean.- Returns:
- the backing jcr node for this bean.
null
if the bean is detached
-
getValueProvider
JCRValueProvider getValueProvider()
-
getName
String getName()
This returns the node name of the backing jcr node for this bean- Returns:
- the node name of the backing jcr node. This method never returns
null
-
getDisplayName
String getDisplayName()
Returns the display name of the backing jcr node for this bean as determined by itshippo:name
property or the node name of the backing jcr node if no such property exists- Returns:
- the display name of the backing jcr node for this bean as determined by its
hippo:name
property or the node name of the backing jcr node if no such proeprty exists
-
getContentType
default String getContentType()
- Returns:
- the primary nodetype name of the backing JCR Node and
null
if no backing jcr node is found
-
getPath
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.- Returns:
- the absolute jcr path of the backing jcr node.
-
getComparePath
default String getComparePath()
Returns the canonical path- Returns:
-
getCanonicalUUID
String getCanonicalUUID()
Returns the jcr uuid of the backing canonical (physical) jcr node ornull
when- there is no canonical node (for example this might be the case for faceted navigation folders)
- the jcr node is detached
- a repository exception happened
For
HippoDocumentBean
's, the uuid of the handle might be more valuable, which you can get withHippoDocumentBean.getCanonicalHandleUUID()
.- Returns:
- the jcr uuid of the backing canonical (physical) jcr node or
null
- See Also:
HippoDocumentBean.getCanonicalHandleUUID()
-
getCanonicalPath
String getCanonicalPath()
Returns the jcr path of the backing canonical (physical) jcr node ornull
when- there is no canonical node (for example this might be the case for faceted navigation folders)
- the jcr node is detached
- a repository exception happened
For
HippoDocumentBean
's, the uuid of the handle might be more valuable, which you can get withHippoDocumentBean.getCanonicalHandleUUID()
.- Returns:
- the jcr path of the backing canonical (physical) jcr node or
null
- See Also:
HippoDocumentBean.getCanonicalHandlePath()
-
getProperties
Map<String,Object> getProperties()
Same asgetSingleProperty(String)
, where getProperty is only there for having a nice .getProperty['propname'] in jsp expression language
-
getSingleProperty
<T> T getSingleProperty(String name)
Returns the value of a document field which is marked assingle
. If the value is an array, then returns the first element.- Type Parameters:
T
-- Parameters:
name
- the name of the property- Returns:
- The value of the property or
null
if it doesn't exist. Return types are String, Boolean, Long, Double or Calendar
-
getSingleProperty
<T> T getSingleProperty(String name, T defaultValue)
Returns the value of a document field which is marked assingle
. If the value is an array, then returns the first element.- Type Parameters:
T
-- Parameters:
name
- the name of the property- Returns:
- The value of the property and
defaultValue
if it doesn't exist. Allowed return types are String, Boolean, Long, Double or Calendar
-
getMultipleProperty
<T> T[] getMultipleProperty(String name)
Returns the value of a document field which is marked asmultiple
. If the value is not an array, then returns the value by creating an array.- Type Parameters:
T
-- Parameters:
name
- the name of the property- Returns:
- The value of the property and
null
if it doesn't exist. Allowed return types are String[], Boolean[], Long[], Double[] or Calendar[]
-
getMultipleProperty
<T> T[] getMultipleProperty(String name, T[] defaultValue)
Returns the value of a document field which is marked asmultiple
. If the value is not an array, then returns the value by creating an array.- Type Parameters:
T
-- Parameters:
name
- the name of the property- Returns:
- The value of the property and
defaultValue
if it doesn't exist. Allowed return types are String[], Boolean[], Long[], Double[] or Calendar[]
-
getProperty
Map<String,Object> getProperty()
- Returns:
- Map of all properties, where the values can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]
-
getBean
<T> T getBean(String relPath)
This methods fetches a childHippoBean
with the relative path relPath. A relPath is not allowed to start with a "/", as this is considered to be an absolute path. For examplegetBean("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 thehippo:handle
intermediate node into account in case of a HippoDocument bean. Always preferred to use isgetParentBean()
instead of using"../"
. In case of a HippoDocument kind of bean, thegetParentBean()
jumps to the parent of the handle, while../
jumps to the handle, resulting in the exact same bean in case of a HippoDocument- Parameters:
relPath
- a path that does not start with a "/"- Returns:
- returns the
HippoBean
with relative pathrelPath
to this bean, ornull
when it does not exist, or when the relPath is not a valid relative path
-
getBean
<T extends HippoBean> T getBean(String relPath, Class<T> beanMappingClass)
Only if a bean found of typebeanMappingClass
, it is returned, and otherwisenull
is returned.- Type Parameters:
T
-- Parameters:
relPath
- a path that does not start with a "/"beanMappingClass
- the classT
that the child bean must inherit from- Returns:
- returns the
HippoBean
of (sub)type beanMappingClass with relative pathrelPath
to this bean, ornull
when it does not exist, is not of (sub)type beanMappingClass, or when the relPath is not a valid relative path - See Also:
getBean(String)
-
getChildBeans
<T extends HippoBean> List<T> getChildBeans(Class<T> beanMappingClass)
Returns all the child beans as a
List
with elements of typeT
. When a child bean is found that is not of typebeanMappingClass
, it is skippedIf you want all child beans that can be mapped to a
HippoBean
, just callList
beans = getBeans(HippoBean.class); - Type Parameters:
T
- the return type of the child bean- Parameters:
beanMappingClass
- the classT
that the child beans must inherit from- Returns:
- List
where the backing jcr nodes have the name childNodeName
-
getChildBeansByName
<T> List<T> getChildBeansByName(String childNodeName) throws ClassCastException
Returns all the child beans of namechildNodeName
as aList
with elements of typeT
. When a found bean is not of typeT
aClassCastException
is thrown.- Type Parameters:
T
- the return type of the child bean- Parameters:
childNodeName
-- Returns:
- List
where the backing jcr nodes have the name childNodeName - Throws:
ClassCastException
-
getChildBeansByName
<T extends HippoBean> List<T> getChildBeansByName(String childNodeName, Class<T> beanMappingClass)
Returns all the child beans of name
childNodeName
as aList
with elements of typeT
. When a child bean is found that is not of typebeanMappingClass
, it is skippedIf the
beanMappingClass
isnull
, it is ignored. Then, this method returns the same agetChildBeansByName(String)
and can throw aClassCastException
- Type Parameters:
T
- the return type of the child bean- Parameters:
childNodeName
-beanMappingClass
- the classT
that the child beans must inherit from- Returns:
- List
where the backing jcr nodes have the name childNodeName
-
getChildBeans
<T> List<T> getChildBeans(String jcrPrimaryNodeType)
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'.- Type Parameters:
T
- the return type of theList
elements- Parameters:
jcrPrimaryNodeType
- the primary type the child beans should inherit from- Returns:
- List
where the backing jcr nodes are of type jcrPrimaryNodeType
-
getLinkedBean
<T extends HippoBean> T getLinkedBean(String relPath, Class<T> beanMappingClass)
This method returns the
HippoBean
linked byrelPath
of type beanMappingClass. It returns aHippoBean
if and only if-
relPath
points to a node of (sub)typehippo:mirror
or of (sub)typehippo:facetselect
-
the
hippo:docbase
of the mirror points to an existing node that results in aHippoBean
of typebeanMappingClass
null
is returned.- Type Parameters:
T
- the expected type of the linked bean- Parameters:
relPath
- (path not starting with a "/")beanMappingClass
- the expected class of the linked bean- Returns:
- The linked
HippoBean
ornull
-
-
getLinkedBeans
<T extends HippoBean> List<T> getLinkedBeans(String relPath, Class<T> beanMappingClass)
Same asgetLinkedBean(String, Class)
only now all linked beans found atrelPath
are returned. When no linked beans found, an empty list is returned.- See Also:
getLinkedBean(String, Class)
-
getParentBean
HippoBean getParentBean()
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- 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
-
getCanonicalBean
<T extends HippoBean> T getCanonicalBean()
Returns the canonical version of the currentHippoBean
ornull
in case that the backingNode
is pure virtual, which is the case for example for some faceted navigation nodes. When an exception happensnull
can be returned- Type Parameters:
T
-- Returns:
- the canonical version of the current
HippoBean
ornull
in case that the backingNode
is pure virtual or when some exception happened
-
isHippoDocumentBean
boolean isHippoDocumentBean()
- Returns:
true
is this HippoBean is an instanceofHippoDocumentBean
-
isHippoFolderBean
boolean isHippoFolderBean()
- Returns:
true
is this HippoBean is an instanceofHippoFolderBean
-
isLeaf
boolean isLeaf()
- Returns:
true
when the backing jcr Node has no child nodes
-
isAncestor
boolean isAncestor(HippoBean compare)
Returnstrue
when thisHippoBean
is an ancestor of thecompare
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.- Parameters:
compare
-- Returns:
true
when thisHippoBean
is an ancestor of thecompare
HippoBean.
-
isDescendant
boolean isDescendant(HippoBean compare)
Returnstrue
when thisHippoBean
is an descendant of thecompare
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.- Parameters:
compare
-- Returns:
true
when thisHippoBean
is an descendant of thecompare
HippoBean.
-
isSelf
boolean isSelf(HippoBean compare)
Returnstrue
when thisHippoBean
has a underlying jcr node with the same jcr path as thecompare
HippoBean. This means, that two HippoBeans might have the same canonical underlying jcr node, but do not returntrue
because their virtual node might have different jcr paths.- Parameters:
compare
-- Returns:
- Returns
true
when thisHippoBean
has the same underlying jcr node path as thecompare
HippoBean.
-
getAvailableTranslations
<T extends HippoBean> HippoAvailableTranslationsBean<T> getAvailableTranslations()
In general, only aHippoDocumentBean
andHippoFolderBean
can have aHippoAvailableTranslationsBean
. However, to make sure that on anyHippoBean
you can callgetAvailableTranslations()
, we add it to the baseHippoBean
as well.- Returns:
- A
HippoAvailableTranslationsBean
.
-
equalCompare
boolean equalCompare(Object compare)
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. All implementing classes overrideObject.equals(Object)
to compare the jcr node path, which might be a virtual path. So this method can return true whileObject.equals(Object)
returns false- 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
-
getEqualComparator
Map<Object,Object> getEqualComparator()
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. All implementing classes overrideObject.equals(Object)
to compare the jcr node path, which might be a virtual path. So this method can return true whileObject.equals(Object)
returns false- Returns:
- a ComparatorMap in which you can compare HippoBeans via the get(Object o)
-
isVersionedNode
boolean isVersionedNode()
- Returns:
true
if the backing node fromgetNode()
is a versioned node
-
-