001 /*
002 * JBoss DNA (http://www.jboss.org/dna)
003 * See the COPYRIGHT.txt file distributed with this work for information
004 * regarding copyright ownership. Some portions may be licensed
005 * to Red Hat, Inc. under one or more contributor license agreements.
006 * See the AUTHORS.txt file in the distribution for a full listing of
007 * individual contributors.
008 *
009 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
010 * is licensed to you under the terms of the GNU Lesser General Public License as
011 * published by the Free Software Foundation; either version 2.1 of
012 * the License, or (at your option) any later version.
013 *
014 * JBoss DNA is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017 * Lesser General Public License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this software; if not, write to the Free
021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023 */
024 package org.jboss.dna.graph;
025
026 import net.jcip.annotations.Immutable;
027 import org.jboss.dna.graph.property.Name;
028 import org.jboss.dna.graph.property.Path;
029
030 /**
031 * A subgraph returned by the {@link Graph}, containing the nodes in the subgraph as well as the properties and children for each
032 * of those nodes. The {@link #iterator()} method may be used to walk the nodes in the subgraph in a pre-order traversal.
033 * <p>
034 * Since this subgraph has a single {@link #getLocation() node that is the top of the subgraph}, the methods that take a String
035 * path or {@link Path path object} will accept absolute or relative paths.
036 * </p>
037 * <p>
038 * This subgraph will not contain any {@link #iterator() nodes} that exist below the {@link #getMaximumDepth() maximum depth}.
039 * Also, all nodes included in the subgraph have all their properties and children. However, nodes that are at the maximum depth
040 * of the subgraph will contain the locations for child nodes that are below the maximum depth and therefore not included in this
041 * subgraph.
042 * </p>
043 *
044 * @author Randall Hauch
045 */
046 @Immutable
047 public interface Subgraph extends Graph.BaseResults<SubgraphNode> {
048
049 /**
050 * Get the location of the subgraph, which is the location of the node at the top of the subgraph.
051 *
052 * @return the location of the top node in the subgraph; never null
053 */
054 Location getLocation();
055
056 /**
057 * Get the maximum depth requested for this subgraph. The actual subgraph may not be as deep, but will never be deeper than
058 * this value.
059 *
060 * @return the maximum depth requested; always positive
061 */
062 int getMaximumDepth();
063
064 /**
065 * Get the node at the supplied location.
066 *
067 * @param relativePath the name that makes up a relative path to the node that is an immediate child of the {@link #getRoot()
068 * root}
069 * @return the node, or null if the node is not {@link #includes(Path) included} in these results
070 */
071 SubgraphNode getNode( Name relativePath );
072
073 /**
074 * Get the node that is at the {@link #getLocation() root} of the subgraph.
075 *
076 * @return the root node in the subgraph
077 */
078 SubgraphNode getRoot();
079
080 }