public class HippoItem extends Object implements HippoBean
Modifier and Type | Class and Description |
---|---|
class |
HippoItem.ComparatorMap |
Modifier and Type | Field and Description |
---|---|
protected String |
comparePath |
protected boolean |
detached |
protected String |
displayName |
protected String |
localizedName |
protected String |
name |
protected javax.jcr.Node |
node |
protected ObjectConverter |
objectConverter |
protected String |
path |
protected JCRValueProvider |
valueProvider |
Constructor and Description |
---|
HippoItem() |
Modifier and Type | Method and Description |
---|---|
void |
attach(javax.jcr.Session session)
Try to attach the jcr Node again with this session.
|
int |
compareTo(HippoBean hippoBean)
The standard HippoItem has a natural ordering based on node name.
|
void |
detach()
Detach the jcr Node.
|
boolean |
equalCompare(Object compare)
A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node.
|
boolean |
equals(Object obj)
equality is based on the absolute path of the backing jcr node.
|
<T extends HippoBean> |
getAvailableTranslations()
|
<T> T |
getBean(String relPath)
This methods fetches a child
HippoBean with the relative path relPath. |
<T extends HippoBean> |
getBean(String relPath,
Class<T> beanMappingClass)
Only if a bean found of type
beanMappingClass , it is returned, and otherwise null is returned. |
<T extends HippoBean> |
getBeanByUUID(String uuid,
Class<T> beanMappingClass) |
<T extends HippoBean> |
getCanonicalBean()
Returns the canonical version of the current
HippoBean or null in case that the backing Node 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 or
null when |
String |
getCanonicalUUID()
Returns the jcr uuid of the backing canonical (physical) jcr node or
null when |
<T extends HippoBean> |
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)
|
<T extends HippoBean> |
getChildBeansByName(String childNodeName,
Class<T> beanMappingClass)
|
String |
getComparePath() |
String |
getDisplayName()
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 property exists |
Map<Object,Object> |
getEqualComparator()
A convenience method capable of comparing two HippoBean instances for you for the underlying jcr node.
|
String |
getIdentifier()
This returns the identifier of the backing provider for this bean, for example some UUID or
/documents/content/myprojec/news/article or http://www.example.com/foo/bar, or a RDBMS id, etc
It is not allowed for any implementation to return
null |
<T extends HippoBean> |
getLinkedBean(String relPath,
Class<T> beanMappingClass)
This method returns the
HippoBean linked by relPath of type beanMappingClass. |
<T extends HippoBean> |
getLinkedBeans(String relPath,
Class<T> beanMappingClass)
Same as
HippoBean.getLinkedBean(String, Class) only now all linked beans found at relPath are returned. |
String |
getLocalizedName()
Deprecated.
use
getDisplayName() instead. Deprecated since 4.0.0 |
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()
values in the map can be of type String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or
Calendar, Calendar[]
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() |
int |
hashCode()
hashcode is based on the absolute path of the backing jcr node.
|
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 |
setComparePath(String comparePath) |
void |
setDisplayName(String displayName) |
void |
setIdentifier(String identifier) |
void |
setLocalizedName(String localizedName)
Deprecated.
use
setDisplayName(String) instead. Deprecated since 4.0.0 |
void |
setName(String name) |
void |
setNode(javax.jcr.Node node)
Callback that supplies the originating JCR node.
|
void |
setObjectConverter(ObjectConverter objectConverter)
Callback that supplies the object converter.
|
void |
setPath(String path) |
protected transient javax.jcr.Node node
protected String comparePath
protected String path
protected String name
protected String localizedName
protected String displayName
protected JCRValueProvider valueProvider
protected transient ObjectConverter objectConverter
protected boolean detached
public void setObjectConverter(ObjectConverter objectConverter)
ObjectConverterAware
setObjectConverter
in interface ObjectConverterAware
public ObjectConverter getObjectConverter()
getObjectConverter
in interface ObjectConverterAware
public void setNode(javax.jcr.Node node)
NodeAware
public javax.jcr.Node getNode()
HippoBean
public JCRValueProvider getValueProvider()
getValueProvider
in interface HippoBean
public String getIdentifier()
IdentifiableContentBean
This returns the identifier of the backing provider for this bean, for example some UUID or
/documents/content/myprojec/news/article or http://www.example.com/foo/bar, or a RDBMS id, etc
It is not allowed for any implementation to return null
Since the return value for this method is used as the index document identifier, it must be unique for every bean that must be indexed
getIdentifier
in interface IdentifiableContentBean
IdentifiableContentBean
public void setIdentifier(String identifier)
setIdentifier
in interface IdentifiableContentBean
identifier
- sets the identifier for this IdentifiableContentBean
IdentifiableContentBean.getIdentifier()
@IndexField(ignoreInCompound=true) public String getName()
HippoBean
public void setName(String name)
@IndexField(ignoreInCompound=true) public String getDisplayName()
HippoBean
hippo:name
property
or the node name of the backing jcr node if no such property existsgetDisplayName
in interface HippoBean
hippo:name
property
or the node name of the backing jcr node if no such proeprty existspublic void setDisplayName(String displayName)
@Deprecated @IndexField(ignoreInCompound=true) public String getLocalizedName()
getDisplayName()
instead. Deprecated since 4.0.0HippoBean
HippoNode
is returns HippoNode.getDisplayName()
()},
otherwise Item.getName()
getLocalizedName
in interface HippoBean
null
when some RepositoryException
happens@Deprecated public void setLocalizedName(String localizedName)
setDisplayName(String)
instead. Deprecated since 4.0.0public String getPath()
HippoBean
public void setPath(String path)
@IndexField(ignoreInCompound=true) public String getComparePath()
public void setComparePath(String comparePath)
public String getCanonicalUUID()
HippoBean
null
when
For HippoDocumentBean
's, the uuid of the handle might be more valuable, which you can get with HippoDocumentBean.getCanonicalHandleUUID()
.
getCanonicalUUID
in interface HippoBean
null
HippoDocumentBean.getCanonicalHandleUUID()
public String getCanonicalPath()
HippoBean
null
when
For HippoDocumentBean
's, the uuid of the handle might be more valuable, which you can get with HippoDocumentBean.getCanonicalHandleUUID()
.
getCanonicalPath
in interface HippoBean
null
HippoDocumentBean.getCanonicalHandlePath()
public Map<String,Object> getProperties()
HippoBean.getProperty(String)
, where getProperty is only there for having a nice .getProperty['propname'] in jsp expression languagegetProperties
in interface HippoBean
public <T> T getProperty(String name)
HippoBean
getProperty
in interface HippoBean
name
- the name of the propertynull
if it does not exist. The return type is either String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]public <T> T getProperty(String name, T defaultValue)
HippoBean
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[]getProperty
in interface HippoBean
name
- the name of the propertydefaultValue
if it does not exist. The return type is either String, String[], Boolean, Boolean[], Long, Long[], Double, Double[] or Calendar, Calendar[]public Map<String,Object> getProperty()
getProperty
in interface HippoBean
#getProperties()}
,
HippoBean.getProperty()
public <T> T getBean(String relPath)
HippoBean
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 HippoDocumentpublic <T extends HippoBean> T getBean(String relPath, Class<T> beanMappingClass)
HippoBean
beanMappingClass
, it is returned, and otherwise null
is returned.getBean
in interface HippoBean
relPath
- a path that does not start with a "/"beanMappingClass
- the class T
that the child bean must inherit fromHippoBean
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 pathHippoBean.getBean(String)
public <T extends HippoBean> List<T> getChildBeans(Class<T> beanMappingClass)
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
getChildBeans
in interface HippoBean
T
- the return type of the child beanbeanMappingClass
- the class T
that the child beans must inherit frompublic <T> List<T> getChildBeansByName(String childNodeName)
HippoBean
childNodeName
as a List
with elements of type
T
. When a found bean is not of type T
a ClassCastException
is thrown.getChildBeansByName
in interface HippoBean
T
- the return type of the child beanpublic <T extends HippoBean> List<T> getChildBeansByName(String childNodeName, Class<T> beanMappingClass)
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
getChildBeansByName
in interface HippoBean
T
- the return type of the child beanbeanMappingClass
- the class T
that the child beans must inherit frompublic <T> List<T> getChildBeans(String jcrPrimaryNodeType)
HippoBean
getChildBeans
in interface HippoBean
T
- the return type of the List
elementsjcrPrimaryNodeType
- the primary type the child beans should inherit frompublic <T extends HippoBean> T getLinkedBean(String relPath, Class<T> beanMappingClass)
HippoBean
This method returns the HippoBean
linked by relPath
of type beanMappingClass. It returns
a HippoBean
if and only if
relPath
points to a node of (sub)type hippo:mirror
or
of (sub)type hippo:facetselect
hippo:docbase
of the mirror points to an existing node that results in a HippoBean
of type beanMappingClass
null
is returned.getLinkedBean
in interface HippoBean
T
- the expected type of the linked beanrelPath
- (path not starting with a "/")beanMappingClass
- the expected class of the linked beanHippoBean
or null
public <T extends HippoBean> List<T> getLinkedBeans(String relPath, Class<T> beanMappingClass)
HippoBean
HippoBean.getLinkedBean(String, Class)
only now all linked beans found at relPath
are returned.
When no linked beans found, an empty list is returned.getLinkedBeans
in interface HippoBean
HippoBean.getLinkedBean(String, Class)
public <T extends HippoBean> T getBeanByUUID(String uuid, Class<T> beanMappingClass)
getBeanByUUID
in interface HippoBean
T
- the type of the returned beanuuid
- the uuid of the node for which to get the HippoBean
beanMappingClass
- the expected class of the linked beanHippoBean
of type T
for uuid
or null
if no node for
uuid
found or not of correct typepublic HippoBean getParentBean()
HippoBean
getParentBean
in interface HippoBean
null
public <T extends HippoBean> T getCanonicalBean()
HippoBean
HippoBean
or null
in case that the backing Node
is pure virtual, which
is the case for example for some faceted navigation nodes. When an exception happens null
can be returnedgetCanonicalBean
in interface HippoBean
HippoBean
or null
in case that the backing Node
is pure virtual or when
some exception happenedpublic boolean isAncestor(HippoBean compare)
HippoBean
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.isAncestor
in interface HippoBean
true
when this HippoBean
is an ancestor of the compare
HippoBean.public boolean isLeaf()
public boolean isDescendant(HippoBean compare)
HippoBean
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.isDescendant
in interface HippoBean
true
when this HippoBean
is an descendant of the compare
HippoBean.public boolean isSelf(HippoBean compare)
HippoBean
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.public boolean isHippoDocumentBean()
isHippoDocumentBean
in interface HippoBean
true
is this HippoBean is an instanceof HippoDocumentBean
public boolean isHippoFolderBean()
isHippoFolderBean
in interface HippoBean
true
is this HippoBean is an instanceof HippoFolderBean
public <T extends HippoBean> HippoAvailableTranslationsBean<T> getAvailableTranslations()
HippoBean
HippoDocumentBean
and HippoFolderBean
can have a HippoAvailableTranslationsBean
. However, to make sure that on
any HippoBean
you can call HippoBean.getAvailableTranslations()
, we add it to the base HippoBean
as well.getAvailableTranslations
in interface HippoBean
HippoAvailableTranslationsBean
.public boolean equalCompare(Object compare)
HippoBean
Object.equals(Object)
to compare the jcr node path, which might be a virtual path. So this method can
return true while Object.equals(Object)
returns falseequalCompare
in interface HippoBean
compare
- the object to compare totrue
if the object compared has the same canonical node or the same virtual path when they don't have a canonicalpublic Map<Object,Object> getEqualComparator()
HippoBean
${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 override
Object.equals(Object)
to compare the jcr node path, which might be a virtual path. So this method can
return true while Object.equals(Object)
returns falsegetEqualComparator
in interface HippoBean
public int compareTo(HippoBean hippoBean)
compareTo
in interface Comparable<HippoBean>
public boolean equals(Object obj)
public void detach()
public void attach(javax.jcr.Session session)
session
- Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.