KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: PropertyDef.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.Value;
27 import javax.jcr.version.OnParentVersionAction;
28
29 /**
30  * A property definition. Used in node type definitions.
31  *
32  * @author Peeter Piegaze
33  * @author Stefan Guggisberg
34  */

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

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

54   public String JavaDoc getName();
55
56   /**
57    * Gets the required type of the property. One of:
58    * <ul>
59    * <li><code>PropertyType.STRING</code></li>
60    * <li><code>PropertyType.DATE</code></li>
61    * <li><code>PropertyType.BINARY</code></li>
62    * <li><code>PropertyType.DOUBLE</code></li>
63    * <li><code>PropertyType.LONG</code></li>
64    * <li><code>PropertyType.BOOLEAN</code></li>
65    * <li><code>PropertyType.SOFTLINK</code></li>
66    * <li><code>PropertyType.REFERENCE</code></li>
67    * <li><code>PropertyType.UNDEFINED</code></li>
68    * </ul>
69    * <code>PropertyType.UNDEFINED</code> is returned if this property may be
70    * of any type.
71    *
72    * @return an int
73    */

74   public int getRequiredType();
75
76   /**
77    * Gets the constraint string. This string describes the constraints
78    * that exist on future values of the property.
79    * <p/>
80    * Reporting of value constraints is <i>optional</i>. An implementation
81    * is free to return <code>null</code> to this call, indicating that value
82    * constraint information is unavailable (though a constraint may still
83    * exist).
84    * <p/>
85    * If a string is returned then it is interpreted in different ways
86    * depending on the type specified for this property. The following
87    * describes the value constraint syntax for each property type:
88    * <p/>
89    * <ul>
90    * <p/>
91    * <li><code>STRING</code>: The constraint string is a regular expression
92    * pattern. For example the regular expression <b><code>".*"</code></b> means
93    * "any string"</li>
94    * <p/>
95    * <li><code>REFERENCE</code>: The constraint string is a comma separated list
96    * of node type names. For example <code>"nt:authored, mynt:newsArticle"</code>.
97    * </li>
98    * <p/>
99    * <li><code>BOOLEAN</code>: Either <code>"true"</code> or
100    * <code>"false"</code>.</li>
101    * <p/>
102    * </ul>
103    * <p/>
104    * The remaining types all have value constraints in the form of inclusive
105    * or exclusive ranges: i.e., <code>"[<i>min</i>, <i>max</i>]"</code>,
106    * <code>"(<i>min</i>, <i>max</i>)"</code>, <code>"(<i>min</i>, <i>max</i>]"</code> or
107    * <code>"[<i>min</i>, <i>max</i>)"</code>. Where <code>"["</code> and <code>"]"</code>
108    * indicate "inclusive", while <code>"("</code> and <code>")"</code>
109    * indicate "exclusive". A missing <code><i>min</i></code> or <code><i>max</i></code> value
110    * indicates no bound in that direction. For example <code>[,5]</code>
111    * means no minimum but a maximum of 5 (inclusive).
112    * The syntax and meaning of the <code><i>min</i></code> and <code><i>max</i></code> values
113    * themselves differs between types as follows:
114    * <p/>
115    * <ul>
116    * <p/>
117    * <li><code>BINARY</code>: <code><i>min</i></code> and <code><i>max</i></code>
118    * specify the allowed size range of the binary value in bytes.</li>
119    * <p/>
120    * <li><code>DATE</code>: <code><i>min</i></code> and <code><i>max</i></code>
121    * are dates specifiying the allowed date range. The date strings must be
122    * in the ISO8601-compliant format:
123    * <code><i>YYYY-MM-DD</i>T<i>hh:mm:ss.sssTZD</i></code>.</li>
124    * <p/>
125    * <li><code>LONG</code>, <code>DOUBLE</code>: <code><i>min</i></code> and
126    * <code><i>max</i></code> are numbers.</li>
127    * <p/>
128    * </ul>
129    *
130    * @return a <code>String</code> or <code>null</code>
131    */

132   public String JavaDoc getValueConstraint();
133
134   /**
135    * Gets the default value of the property. This is the value that the
136    * property will be assigned if it is either automatically created, or
137    * created without a specified initial value. If <code>null</code>,
138    * then the property has no fixed default value. Note that this does not
139    * exclude the possibility that the property still assumes some value
140    * automatically, but that value may be variable (for example, "the current
141    * date") and hence cannot be expressed as a single fixed value.
142    *
143    * @return a <code>Value</code> or <code>null</code>
144    */

145   public Value getDefaultValue();
146
147   /**
148    * Reports whether the property is to be automatically created when its
149    * parent node is created. If <code>true</code> then this
150    * <code>PropertyDefNT</code> will necessarily not be a residual set
151    * definition but will specify an actual property name (in other words
152    * <code>getName()</code> will return a non-null value).
153    *
154    * @return a <code>boolean</code>
155    */

156   public boolean isAutoCreate();
157
158   /**
159    * Reports whether the property is mandatory. A mandatory property is one
160    * that, if its parent node exists, must also exist. It cannot be removed
161    * through this API except by removing its parent. An attempt to save a
162    * node that has a mandatory property without first creating that property,
163    * will throw a <code>ConstraintViolationException</code> on <code>save</code>.
164    * <p/>
165    * If a property is mandatory then the following restrictions must be
166    * enforced:
167    * <ul>
168    * <li>
169    * If <code>autoCreate</code> is <code>false</code> then the client must
170    * ensure that the property is created (and if no default value is
171    * indicated, given a value) before the parent node is saved, otherwise
172    * a <code>ConstraintViolationException</code> will be thrown on <code>save</code>.
173    * </li>
174    * <li>
175    * Once created, the property cannot be removed without removing its parent node,
176    * otherwise a <code>ConstraintViolationException</code> is thrown on <code>save</code>.
177    * </li>
178    * </ul>
179    *
180    * @return a <code>boolean</code>
181    */

182   public boolean isMandatory();
183
184   /**
185    * Gets the on-parent-version status of the property. This governs what to do if
186    * the parent node of this property is versioned; an
187    * {@link OnParentVersionAction}.
188    *
189    * @return an <code>int</code>
190    */

191   public int getOnParentVersion();
192
193   /**
194    * Reports whether the property is read-only. A read-only
195    * property cannot be written-to via this API. It may be written to,
196    * however, by the implementation itself via some mechanism not
197    * specified by this specification.
198    *
199    * @return a <code>boolean</code>
200    */

201   public boolean isReadOnly();
202
203   /**
204    * Reports whether this property is the primary child item of its parent
205    * node. Since any given node may have either zero or one primary child
206    * items, this means that a maximum of one <code>PropertyDefNT</code> or
207    * <code>NodeDef</code> within a particular <code>NodeType</code> may
208    * return <code>true</code> on this call. The primary child item flag
209    * is used by the method <code>{@link javax.jcr.Node#getPrimaryItem()}</code>.
210    *
211    * @return a <code>boolean</code>
212    */

213   public boolean isPrimaryItem();
214
215   /**
216    * Reports whether this property can have multiple values.
217    *
218    * @return a <code>boolean</code>
219    */

220   public boolean isMultiple();
221 }
222
Popular Tags