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 java.util.Collection;
027 import java.util.List;
028 import java.util.Map;
029 import net.jcip.annotations.Immutable;
030 import org.jboss.dna.graph.property.Name;
031 import org.jboss.dna.graph.property.Path;
032 import org.jboss.dna.graph.property.Property;
033
034 /**
035 * A node in a {@link Graph graph}, with methods to access the properties and children.
036 *
037 * @author Randall Hauch
038 */
039 @Immutable
040 public interface Node extends Iterable<Location> {
041
042 /**
043 * Get the graph containing the node.
044 *
045 * @return the graph
046 */
047 Graph getGraph();
048
049 /**
050 * Get the location of the node.
051 *
052 * @return the node's location
053 */
054 Location getLocation();
055
056 /**
057 * Get the properties on the node.
058 *
059 * @return the properties
060 */
061 Collection<Property> getProperties();
062
063 /**
064 * Get the property with the supplied name.
065 *
066 * @param name the property name
067 * @return the property, or null if there is no property by that name
068 */
069 Property getProperty( String name );
070
071 /**
072 * Get the property with the supplied name.
073 *
074 * @param name the property name
075 * @return the property, or null if there is no property by that name
076 */
077 Property getProperty( Name name );
078
079 /**
080 * Get the map of properties keyed by the property names.
081 *
082 * @return the map of properties keyed by property name
083 */
084 Map<Name, Property> getPropertiesByName();
085
086 /**
087 * Get the children of the node.
088 *
089 * @return the list of locations for each child
090 */
091 List<Location> getChildren();
092
093 /**
094 * Get the list of child {@link Path.Segment segments}.
095 *
096 * @return the list containing a segment for each child
097 */
098 List<Path.Segment> getChildrenSegments();
099
100 /**
101 * Return whether this node has children.
102 *
103 * @return true if the node has children, or false otherwise
104 */
105 boolean hasChildren();
106
107 }