Class AbstractNode

    • Constructor Detail

      • AbstractNode

        public AbstractNode()
    • Method Detail

      • getPath

        public java.lang.String getPath()
                                 throws RepositoryException
        Returns the path of this node.

        The default implementation recursively calls this method on the parent node and appends the name and optionally the index of this node to construct the full path. Returns "/" if the parent node is not available (i.e. this is the root node).

        Specified by:
        getPath in interface Item
        Returns:
        node path
        Throws:
        RepositoryException - if an error occurs
      • isNode

        public boolean isNode()
        Returns true.
        Specified by:
        isNode in interface Item
        Returns:
        true
      • getMixinNodeTypes

        public NodeType[] getMixinNodeTypes()
                                     throws RepositoryException
        Returns the declared mixin node types of this node.

        The default implementation uses the values of the jcr:mixinTypes property to look up the mixin node types from the NodeTypeManager of the current workspace.

        Specified by:
        getMixinNodeTypes in interface Node
        Returns:
        mixin node types
        Throws:
        RepositoryException - if an error occurs
      • getPrimaryNodeType

        public NodeType getPrimaryNodeType()
                                    throws RepositoryException
        Returns the primary node type of this node.

        The default implementation uses the value of the jcr:primaryType property to look up the primary node type from the NodeTypeManager of the current workspace.

        Specified by:
        getPrimaryNodeType in interface Node
        Returns:
        primary node type
        Throws:
        RepositoryException - if an error occurs
      • getProperty

        public Property getProperty​(java.lang.String relPath)
                             throws PathNotFoundException,
                                    RepositoryException
        Returns the property at the given relative path from this node.

        The default implementation looks up the parent node of the given relative path and iterates through the properties of that node to find and return the identified property.

        Specified by:
        getProperty in interface Node
        Parameters:
        relPath - relative path of the property
        Returns:
        property
        Throws:
        PathNotFoundException - if the property is not found
        RepositoryException - if an error occurs
      • hasNode

        public boolean hasNode​(java.lang.String relPath)
                        throws RepositoryException
        Checks whether a node at the given relative path exists.

        The default implementation looks up the node using Node.getNode(String) and returns true if a PathNotFoundException is not thrown.

        Specified by:
        hasNode in interface Node
        Parameters:
        relPath - relative path
        Returns:
        true if a node exists at the given path, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • hasNodes

        public boolean hasNodes()
                         throws RepositoryException
        Checks if this node has one or more properties.

        The default implementation calls Node.getNodes() and returns true iff returned iterator has at least one element.

        Specified by:
        hasNodes in interface Node
        Returns:
        true if this node has child nodes, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • hasProperties

        public boolean hasProperties()
                              throws RepositoryException
        Checks if this node has one or more properties.

        The default implementation calls Node.getProperties() and returns true iff returned iterator has at least one element.

        Note that in normal circumstances (i.e. no weird access controls) this method will always return true since all nodes always have at least the jcr:primaryType property.

        Specified by:
        hasProperties in interface Node
        Returns:
        true if this node has properties, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • hasProperty

        public boolean hasProperty​(java.lang.String relPath)
                            throws RepositoryException
        Checks whether a property at the given relative path exists.

        The default implementation looks up the property using Node.getProperty(String) and returns true if a PathNotFoundException is not thrown.

        Specified by:
        hasProperty in interface Node
        Parameters:
        relPath - relative path
        Returns:
        true if a property exists at the given path, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • holdsLock

        public boolean holdsLock()
                          throws RepositoryException
        Checks if this node holds a lock.

        The default implementation calls Node.getLock() and returns true iff the holding node of the lock is the same as this node.

        Specified by:
        holdsLock in interface Node
        Returns:
        true if this node holds a lock, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • isCheckedOut

        public boolean isCheckedOut()
                             throws RepositoryException
        Checks whether this node is checked out.

        The default implementation checks the jcr:isCheckedOut property if this node is versionable, and recursively calls this method on the parent node if this node is not versionable. A non-versionable root node always returns true from this method.

        Specified by:
        isCheckedOut in interface Node
        Returns:
        true if this node is checked out, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • isNodeType

        public boolean isNodeType​(java.lang.String name)
                           throws RepositoryException
        Checks whether this node is of the given type.

        The default implementation iterates through the primary and mixin types and all the supertypes of this node, returning true if a type with the given name is encountered. Returns false if none of the types matches.

        Specified by:
        isNodeType in interface Node
        Parameters:
        name - type name
        Returns:
        true if this node is of the given type, false otherwise
        Throws:
        RepositoryException - if an error occurs
      • setProperty

        public Property setProperty​(java.lang.String name,
                                    java.lang.String[] strings,
                                    int type)
                             throws RepositoryException
        Sets the value of the named property.

        The default implementation uses the ValueFactory of the current Session to create Value instances of the given type from the given string values and forwards the call to the Node.setProperty(String, Value[]) method.

        Specified by:
        setProperty in interface Node
        Parameters:
        name - property name
        strings - string values
        type - property type
        Returns:
        modified property
        Throws:
        RepositoryException - if an error occurs
      • setProperty

        public Property setProperty​(java.lang.String name,
                                    java.lang.String value,
                                    int type)
                             throws RepositoryException
        Sets the value of the named property.

        The default implementation uses the ValueFactory of the current Session to create a Value instance of the given type from the given string value and forwards the call to the Node.setProperty(String, Value) method.

        Specified by:
        setProperty in interface Node
        Parameters:
        name - property name
        value - string value
        type - property type
        Returns:
        modified property
        Throws:
        RepositoryException - if an error occurs