KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jcr > nodetype > NodeDef


1 /*
2  * $Id: NodeDef.java,v 1.3 2004/07/31 11:49:25 benjmestrallet Exp $
3  *
4  * Copyright 2002-2004 Day Management AG, Switzerland.
5  *
6  * Licensed under the Day RI License, Version 2.0 (the "License"),
7  * as a reference implementation of the following specification:
8  *
9  * Content Repository API for Java Technology, revision 0.12
10  * <http://www.jcp.org/en/jsr/detail?id=170>
11  *
12  * You may not use this file except in compliance with the License.
13  * You may obtain a copy of the License files at
14  *
15  * http://www.day.com/content/en/licenses/day-ri-license-2.0
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */

24 package javax.jcr.nodetype;
25
26 import javax.jcr.version.OnParentVersionAction;
27
28 /**
29  * A node definition. Used in node typed definition
30  *
31  * @author Peeter Piegaze
32  * @author Stefan Guggisberg
33  * @see NodeType#getChildNodeDefs
34  * @see javax.jcr.Node#getDefinition
35  */

36 public interface NodeDef {
37
38   /**
39    * Gets the node type that contains the declaration of <i>this</i>
40    * <code>NodeDef</code>.
41    *
42    * @return a <code>NodeType</code> object.
43    */

44   public NodeType getDeclaringNodeType();
45
46   /**
47    * Gets the name of the child node. If <code>null</code>, this
48    * <code>NodeDef</code> defines a residual set of child nodes. That is,
49    * it defines the characteristics of all those child nodes with names apart
50    * from the names explicitly used in other property or child node
51    * definitions.
52    *
53    * @return a <code>String</code> or <code>null</code>.
54    */

55   public String JavaDoc getName();
56
57   /**
58    * Gets the minimum set of primary node types that the child node must have.
59    * Returns an array to support those implementations with multiple
60    * inheritance. The simplest case would be to return <code>nt:base</code>,
61    * which is the base of all primary node types and therefore, in this
62    * context, represents the least restrictive requirement.
63    * <p/>
64    * A node must still have only one assigned primary node type, though
65    * this attribute can restrict that node type by taking advantage of any
66    * inheritance hierarchy that the implementation may support.
67    *
68    * @return an array of <code>NodeType</code> objects.
69    */

70   public NodeType[] getRequiredPrimaryTypes();
71
72   /**
73    * Gets the default primary node type that will be assigned to the child
74    * node if it is created without an explicitly specified primary node type.
75    * This node type must be a subtype of (or the same type as) the node types
76    * returned by <code>getRequiredPrimaryTypes</code>.
77    *
78    * @return a <code>NodeType</code>.
79    */

80   public NodeType getDefaultPrimaryType();
81
82   /**
83    * Gets the minimum set of mixin node types that the child node must have.
84    *
85    * @return an array of <code>NodeType</code> objects.
86    */

87   public NodeType[] getRequiredMixinTypes();
88
89   /**
90    * Gets the default set of mixin node types that will be assigned to the child
91    * node upon creation. This set of mixin node types must include <i>at least
92    * those</i>, or subtypes of those, returned by
93    * <code>getRequiredMixinTypes</code>.
94    *
95    * @return an array of <code>NodeType</code> objects.
96    */

97   public NodeType[] getDefaultMixinTypes();
98
99   /**
100    * Reports whether the child node is to be automatically created when its
101    * parent node is created. If set to <code>true</code> then this
102    * <code>NodeDef</code> must not be a residual set definition
103    * but must specify an actual child node name. This child node
104    * may be of a node type that specifies further auto-created child nodes.
105    * In such a case a chain of nodes will be created.
106    *
107    * @return a <code>boolean</code>.
108    */

109   public boolean isAutoCreate();
110
111   /**
112    * Reports whether the child node is mandatory. A mandatory property is one
113    * that, if its parent node exists, must also exist. It cannot be removed
114    * through this API except by removing its parent. An attempt to save a
115    * node that has a mandatory child node without first creating that child node,
116    * will throw a <code>ConstraintViolationException</code> on <code>save</code>.
117    * <p/>
118    * If a child node is mandatory then the following restrictions must be
119    * enforced:
120    * <ul>
121    * <li>
122    * If <code>autoCreate</code> is <code>false</code> then the client must
123    * ensure that the child node is created before the parent node is saved, otherwise
124    * a <code>ConstraintViolationException</code> will be thrown on <code>save</code>.
125    * </li>
126    * <li>
127    * Once created, the child node cannot be removed without removing its parent node,
128    * otherwise a <code>ConstraintViolationException</code> is thrown on <code>save</code>.
129    * </li>
130    * </ul>
131    *
132    * @return a <code>boolean</code>
133    */

134   public boolean isMandatory();
135
136   /**
137    * Gets the on-parent-version status of the child node. This governs what to do if
138    * the parent node of this child node is versioned; an
139    * {@link OnParentVersionAction}.
140    *
141    * @return an <code>int</code>.
142    */

143   public int getOnParentVersion();
144
145   /**
146    * Reports whether the child node is read-only.A read-only node is one that
147    * cannot be changed (i.e., have child nodes or properties added or removed)
148    * through this API. However, it may be altered by the implementation itself
149    * through some mechanism not defined by this specification.
150    *
151    * @return a <code>boolean</code>.
152    */

153   public boolean isReadOnly();
154
155   /**
156    * Reports whether this node is the primary child item of its parent
157    * node. Since any given node may have either zero or one primary child
158    * items, this means that a maximum of one <code>PropertyDefNT</code> or
159    * <code>NodeDef</code> within a particular <code>NodeType</code> may
160    * return <code>true</code> on this call. The primary child item flag
161    * is used by the method <code>{@link javax.jcr.Node#getPrimaryItem()
162    * Node.getPrimaryItem()}</code>.
163    *
164    * @return a <code>boolean</code>.
165    */

166   public boolean isPrimaryItem();
167
168   /**
169    * Reports whether this child node can have same-name siblings. In other
170    * words, whether the parent node can have more than one child node of this
171    * name.
172    *
173    * @return a boolean.
174    */

175   public boolean allowSameNameSibs();
176 }
Popular Tags