|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.magnolia.jcr.wrapper.DelegateNodeWrapper info.magnolia.module.groovy.support.nodes.MgnlGroovyJCRNode
public class MgnlGroovyJCRNode
Implementation of wrapped Node object used in Groovy console context.
This makes it possible, for example, navigating the nodes in a Magnolia repository
with a . (dot)
notation and access their properties with .
or .@
notation much like it happens when using the result of parsing an xml with groovy's groovy.util.XmlSlurper.XmlSlurper
.
For example, here is how, in a groovy script, one could navigate to and print the node data named abstract:
session = ctx.getJCRSession('website') node = session.getNode('/demo-project') println node.about.history.abstractThe above example can also be made more groovy-like by using the
@
notation to access the property
node.about.history.@abstractAs
node
is also a Node
, you can call any of its
methods. E.g.
println node.metaData.template println node.about.title println node.about.parent (this can return null)
node.about.properties.each {println it.name}It is also possible to assign values to properties or create new ones. E.g.
node.foo = 3.14d node.bar = true node.baz = 'some text' node.qux = 100will assign the values on the right hand side to the node data on left hand side. Should those not exist, they will be automatically created. Furthermore, the correct type will be detected based on the value assigned (i.e. Boolean, String, Calendar, Long or Double).
save()
on a parent node.
Nested Class Summary | |
---|---|
protected class |
MgnlGroovyJCRNode.MgnlGroovyWrappingNodeIterator
MgnlGroovyWrappingNodeIterator. |
Field Summary | |
---|---|
protected static org.slf4j.Logger |
log
|
Fields inherited from class info.magnolia.jcr.wrapper.DelegateNodeWrapper |
---|
wrapped |
Fields inherited from interface javax.jcr.Node |
---|
JCR_CHILD_NODE_DEFINITION, JCR_CONTENT, JCR_FROZEN_NODE, JCR_PROPERTY_DEFINITION, JCR_ROOT_VERSION, JCR_VERSION_LABELS |
Constructor Summary | |
---|---|
MgnlGroovyJCRNode(javax.jcr.Node node)
|
Method Summary | |
---|---|
boolean |
equals(Object obj)
|
Object |
get(String key)
Provides lookup of elements by non-namespaced name. |
protected Object |
getPropertyValue(javax.jcr.Property property)
Returns the value for the given property. |
int |
hashCode()
|
String |
name()
|
String |
print()
|
protected static void |
setMetaClass(groovy.lang.MetaClass metaClass,
Class nodeClass)
|
protected boolean |
showNode(javax.jcr.Node node)
|
protected boolean |
showProperty(javax.jcr.Property property)
|
Methods inherited from class info.magnolia.jcr.wrapper.DelegateNodeWrapper |
---|
accept, addMixin, addNode, addNode, canAddMixin, cancelMerge, checkin, checkout, clone, deepUnwrap, doneMerge, followLifecycleTransition, getAllowedLifecycleTransistions, getAncestor, getBaseVersion, getCorrespondingNodePath, getDefinition, getDepth, getIdentifier, getIndex, getLock, getMixinNodeTypes, getName, getNode, getNodes, getNodes, getNodes, getParent, getPath, getPrimaryItem, getPrimaryNodeType, getProperties, getProperties, getProperties, getProperty, getReferences, getReferences, getSession, getSharedSet, getUUID, getVersionHistory, getWeakReferences, getWeakReferences, getWrappedNode, hasNode, hasNodes, hasProperties, hasProperty, holdsLock, initClone, isCheckedOut, isLocked, isModified, isNew, isNode, isNodeType, isSame, lock, merge, orderBefore, refresh, remove, removeMixin, removeShare, removeSharedSet, restore, restore, restore, restoreByLabel, save, setPrimaryType, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setWrappedNode, toString, unlock, update |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final org.slf4j.Logger log
Constructor Detail |
---|
public MgnlGroovyJCRNode(javax.jcr.Node node)
Method Detail |
---|
protected static void setMetaClass(groovy.lang.MetaClass metaClass, Class nodeClass)
public String name()
public Object get(String key) throws javax.jcr.ValueFormatException, javax.jcr.RepositoryException
key
- the name (or shortcut key) of the node(s) of interest
javax.jcr.RepositoryException
javax.jcr.ValueFormatException
protected Object getPropertyValue(javax.jcr.Property property) throws javax.jcr.RepositoryException, javax.jcr.ValueFormatException
PropertyType
.
PropertyType.STRING
returns a String
PropertyType.DATE
returns a Calendar
PropertyType.DOUBLE
returns a BigDecimal
PropertyType.LONG
returns a BigDecimal
PropertyType.BINARY
returns the InputStream
value.
String
(s)
javax.jcr.RepositoryException
javax.jcr.ValueFormatException
public String print()
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
protected boolean showNode(javax.jcr.Node node)
protected boolean showProperty(javax.jcr.Property property)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |