1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 package org.modeshape.graph; 25 26 import java.util.Collection; 27 import java.util.List; 28 import java.util.Map; 29 import net.jcip.annotations.Immutable; 30 import org.modeshape.graph.property.DateTime; 31 import org.modeshape.graph.property.Name; 32 import org.modeshape.graph.property.Path; 33 import org.modeshape.graph.property.Property; 34 35 /** 36 * A node in a {@link Graph graph}, with methods to access the properties and children. 37 */ 38 @Immutable 39 public interface Node extends Iterable<Location> { 40 41 /** 42 * Get the graph containing the node. 43 * 44 * @return the graph 45 */ 46 Graph getGraph(); 47 48 /** 49 * Get the time at which this node representation should no longer be used. 50 * 51 * @return the expiration time, or null if there is none 52 */ 53 DateTime getExpirationTime(); 54 55 /** 56 * Get the location of the node. 57 * 58 * @return the node's location 59 */ 60 Location getLocation(); 61 62 /** 63 * Get the properties on the node. 64 * 65 * @return the properties 66 */ 67 Collection<Property> getProperties(); 68 69 /** 70 * Get the property with the supplied name. 71 * 72 * @param name the property name 73 * @return the property, or null if there is no property by that name 74 */ 75 Property getProperty( String name ); 76 77 /** 78 * Get the property with the supplied name. 79 * 80 * @param name the property name 81 * @return the property, or null if there is no property by that name 82 */ 83 Property getProperty( Name name ); 84 85 /** 86 * Get the map of properties keyed by the property names. 87 * 88 * @return the map of properties keyed by property name 89 */ 90 Map<Name, Property> getPropertiesByName(); 91 92 /** 93 * Get the children of the node. 94 * 95 * @return the list of locations for each child 96 */ 97 List<Location> getChildren(); 98 99 /** 100 * Get the list of child {@link Path.Segment segments}. 101 * 102 * @return the list containing a segment for each child 103 */ 104 List<Path.Segment> getChildrenSegments(); 105 106 /** 107 * Return whether this node has children. 108 * 109 * @return true if the node has children, or false otherwise 110 */ 111 boolean hasChildren(); 112 113 }