org.apache.jackrabbit.commons.flat.TreeManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.sling.feature.analyser Show documentation
Show all versions of org.apache.sling.feature.analyser Show documentation
A feature describes an OSGi system
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.apache.jackrabbit.commons.flat;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import java.util.Comparator;
import java.util.Set;
/**
* TreeManager instances are responsible for the mapping between sequence views
* of {@link Node}s and {@link Property}s and an hierarchical JCR
* representation. They are passed to the various factory methods in
* {@link ItemSequence} to parameterize the behavior of {@link NodeSequence}s
* and {@link PropertySequence}s.
*
* @see NodeSequence
* @see PropertySequence
*/
public interface TreeManager {
/**
* @return the root node of the JCR sub-tree where the items of the sequence
* are be mapped to.
*/
Node getRoot();
/**
* Determined whether the given node
is the root node of the
* JCR sub-tree.
*
* @param node Node to test for root
* @return getRoot().isSame(node)
.
* @throws RepositoryException
*/
boolean isRoot(Node node) throws RepositoryException;
/**
* Determines whether the given node
is a leaf. Leaf nodes are
* the nodes which are actually part of a {@link NodeSequence} or the
* parents of the properties of a {@link PropertySequence}.
*
* @param node Node to test for leaf
* @return true
if node
is a leaf node,
* false
otherwise.
* @throws RepositoryException
*/
boolean isLeaf(Node node) throws RepositoryException;
/**
* Properties to ignore.
* @return
*/
public Set getIgnoredProperties();
/**
* {@link Comparator} used for establishing the order of the keys in the
* sequence.
*
* @return a Comparator<String>
instance
*/
Comparator getOrder();
/**
* After the node cause
has been inserted into the sequence
* itemSequence
, the implementation of this method may decide
* to split the parent node
of cause
into two or
* more new nodes. Splitting must be done such that the overall order of the
* keys in this sequence obeys the order given by {@link #getOrder()} as
* much as possible.
*
* @param itemSequence the {@link ItemSequence} where the new node
* cause
has been inserted.
* @param node the parent node of the newly inserted node
* @param cause the newly inserted node or null
if not known.
* @throws RepositoryException
*/
void split(ItemSequence itemSequence, Node node, Node cause) throws RepositoryException;
/**
* After the property cause
has been inserted into the sequence
* itemSequence
, the implementation of this method may decide
* to split the parent node
of cause
into two or
* more new nodes. Splitting must be done such that the overall order of the
* keys in this sequence obeys the order given by {@link #getOrder()} as
* much as possible.
*
* @param itemSequence the {@link ItemSequence} where the new property
* cause
has been inserted.
* @param node the parent node of the newly inserted property
* @param cause the newly inserted property or null
if not
* known.
* @throws RepositoryException
*/
void split(ItemSequence itemSequence, Node node, Property cause) throws RepositoryException;
/**
* After the node cause
has been deleted from the sequence
* itemSequence
, the implementation of this method may decide
* to join the parent node
of cause
with some
* other nodes. Joining must be done such that the overall order of the keys
* in this sequence obeys the order given by {@link #getOrder()} as much as
* possible.
*
* @param itemSequence the {@link ItemSequence} where the node
* cause
has been deleted from.
* @param node the parent node from which cause
has been
* deleted.
* @param cause the deleted node or null
if not known.
* Note: cause
might be stale.
* @throws RepositoryException
*/
void join(ItemSequence itemSequence, Node node, Node cause) throws RepositoryException;
/**
* After the property cause
has been deleted from the sequence
* itemSequence
, the implementation of this method may decide
* to join the parent node
of cause
with some
* other nodes. Joining must be done such that the overall order of the keys
* in this sequence obeys the order given by {@link #getOrder()} as much as
* possible.
*
* @param itemSequence the {@link ItemSequence} where the property
* cause
has been deleted from.
* @param node the parent node from which cause
has been
* deleted.
* @param cause the deleted property or null
if not known.
* Note: cause
might be stale.
* @throws RepositoryException
*/
void join(ItemSequence itemSequence, Node node, Property cause) throws RepositoryException;
/**
* Whether to automatically save changes of the current session occurring
* from adding/removing nodes and properties.
*
* @return true
if changes should be automatically saved,
* false
otherwiese.
*/
boolean getAutoSave();
}