View Javadoc

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.connector.map;
25  
26  import java.util.List;
27  import java.util.Map;
28  import java.util.Set;
29  import java.util.UUID;
30  import org.modeshape.graph.ExecutionContext;
31  import org.modeshape.graph.property.Name;
32  import org.modeshape.graph.property.NameFactory;
33  import org.modeshape.graph.property.Path;
34  import org.modeshape.graph.property.Property;
35  import org.modeshape.graph.property.PropertyFactory;
36  
37  public interface MapNode {
38  
39      /**
40       * Returns the UUID for this node
41       * 
42       * @return the UUID for this node
43       */
44      public UUID getUuid();
45  
46      /**
47       * Returns the name of this node along with its SNS index within its parent's children
48       * 
49       * @return the name of this node along with its SNS index within its parent's children
50       */
51      public Path.Segment getName();
52  
53      /**
54       * @param name Sets name to the specified value.
55       */
56      public void setName( Path.Segment name );
57  
58      /**
59       * Returns the set of child names for this node
60       * 
61       * @return the set of child names for this node
62       */
63      public Set<Name> getUniqueChildNames();
64  
65      /**
66       * Returns the parent of this node or null if the node is the root node for its workspace.
67       * 
68       * @return the parent of this node; may be null if the node is the root node for its workspace
69       */
70      public MapNode getParent();
71  
72      /**
73       * @param parent Sets parent to the specified value.
74       */
75      public void setParent( MapNode parent );
76  
77      /**
78       * @return children
79       */
80      public List<MapNode> getChildren();
81  
82      /**
83       * Removes all of the children for this node in a single operation.
84       */
85      public void clearChildren();
86  
87      /**
88       * Adds the given child to the end of the list of children for this node
89       * 
90       * @param child the child to add to this node
91       */
92      public void addChild( MapNode child );
93  
94      /**
95       * Inserts the specified child at the specified position in the list of children. Shifts the child currently at that position
96       * (if any) and any subsequent children to the right (adds one to their indices).
97       * 
98       * @param index index at which the specified child is to be inserted
99       * @param child the child to be inserted
100      */
101     public void addChild( int index,
102                           MapNode child );
103 
104     /**
105      * Removes the given child from the list of children
106      * 
107      * @param child the child to be removed
108      * @return true if the child was one of this node's children (and was removed); false otherwise
109      */
110     public boolean removeChild( MapNode child );
111 
112     /**
113      * Returns a map of property names to the property for the given name
114      * 
115      * @return a map of property names to the property for the given name
116      */
117     public Map<Name, Property> getProperties();
118 
119     /**
120      * Sets the given properties in a single operation, overwriting any previous properties for the same name This bulk mutator
121      * should be used when multiple properties are being set in order to allow underlying implementations to optimize their access
122      * to their respective persistent storage mechanism.
123      * 
124      * @param properties the properties to set
125      * @return this map node
126      */
127     public MapNode setProperties( Iterable<Property> properties );
128 
129     /**
130      * Sets the property with the given name, overwriting any previous property for the given name
131      * 
132      * @param property the property to set
133      * @return this map node
134      */
135     public MapNode setProperty( Property property );
136 
137     /**
138      * Sets the property with the given name, overwriting any previous property for the given name
139      * 
140      * @param context the current execution context, used to get a {@link NameFactory name factory} and {@link PropertyFactory
141      *        property factory}.
142      * @param name the name of the property
143      * @param values the values for the property
144      * @return this map node
145      */
146     public MapNode setProperty( ExecutionContext context,
147                                 String name,
148                                 Object... values );
149 
150     /**
151      * Removes the property with the given name
152      * 
153      * @param propertyName the name of the property to remove
154      * @return this map node
155      */
156     public MapNode removeProperty( Name propertyName );
157 
158     /**
159      * Returns the named property
160      * 
161      * @param context the current execution context, used to get a {@link NameFactory name factory}
162      * @param name the name of the property to return
163      * @return the property for the given name
164      */
165     public Property getProperty( ExecutionContext context,
166                                  String name );
167 
168     /**
169      * Returns the named property
170      * 
171      * @param name the name of the property to return
172      * @return the property for the given name
173      */
174     public Property getProperty( Name name );
175 
176 }