KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > impl > core > nodetype > PropertyDefImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5
6 package org.exoplatform.services.jcr.impl.core.nodetype;
7
8 import javax.jcr.nodetype.PropertyDef;
9 import javax.jcr.nodetype.NodeType;
10 import javax.jcr.Value;
11 import javax.jcr.nodetype.NoSuchNodeTypeException;
12 import javax.jcr.PropertyType;
13 import javax.jcr.version.OnParentVersionAction;
14
15 /**
16  * Created by The eXo Platform SARL .
17  *
18  * @author <a HREF="mailto:geaz@users.sourceforge.net">Gennady Azarenkov</a>
19  * @version $Id: PropertyDefImpl.java,v 1.3 2004/07/31 11:49:26 benjmestrallet Exp $
20  */

21
22 public class PropertyDefImpl implements PropertyDef {
23
24   private String JavaDoc name;
25   private String JavaDoc declaringNodeType;
26   private int requiredType;
27   private String JavaDoc valueConstraint;
28   private Value defaultValue;
29   private boolean autoCreate;
30   private boolean mandatory;
31   private int onVersion;
32   private boolean readOnly;
33   private boolean primaryItem;
34   private boolean multiple;
35
36   public PropertyDefImpl(String JavaDoc name, String JavaDoc declaringNodeType, int requiredType,
37                          String JavaDoc valueConstraint, Value defaultValue, boolean autoCreate, boolean mandatory,
38                          int onVersion, boolean readOnly, boolean primaryItem, boolean multiple) {
39
40     this.name = name;
41     this.declaringNodeType = declaringNodeType;
42     this.requiredType = requiredType;
43     this.valueConstraint = valueConstraint;
44     this.defaultValue = defaultValue;
45     this.autoCreate = autoCreate;
46     this.mandatory = mandatory;
47     this.onVersion = onVersion;
48     this.readOnly = readOnly;
49     this.primaryItem = primaryItem;
50     this.multiple = multiple;
51   }
52
53   // Residual definition
54
public PropertyDefImpl(String JavaDoc declaringNodeType) {
55
56     this.name = null;
57     this.declaringNodeType = declaringNodeType;
58     this.requiredType = PropertyType.UNDEFINED;
59     this.valueConstraint = null;
60     this.defaultValue = null;
61     this.autoCreate = false;
62     this.mandatory = false;
63     this.onVersion = OnParentVersionAction.IGNORE;
64     this.readOnly = false;
65     this.primaryItem = false;
66     this.multiple = true;
67   }
68
69   /**
70    * 6.10.6
71    * Gets the name of the property to which this definition
72    * applies. If null, then this PropertyDefNT defines a residual
73    * set of properties. That is, it defines the characteristics of
74    * all those properties with names apart from the names
75    * explicitly used in other property or child node definitions.
76    */

77   public String JavaDoc getName() {
78     return name;
79   }
80
81   /**
82    * 6.10.6
83    * Gets the node type that contains the declaration of this PropertyDefNT.
84    */

85   public NodeType getDeclaringNodeType() /*throws NoSuchNodeTypeException*/ {
86     try {
87       return NodeTypeManagerImpl.getInstance().getNodeType(declaringNodeType);
88     } catch (NoSuchNodeTypeException e) {
89       throw new RuntimeException JavaDoc(e.getMessage());
90     }
91   }
92
93
94   /**
95    * 6.10.6
96    * Gets the required type of the property. One of STRING,
97    * BINARY, DATE, LONG, DOUBLE, SOFTLINK or BOOLEAN. See
98    * Property Types, above. If null, then this property may
99    * be of any type.
100    */

101   public int getRequiredType() {
102     return requiredType;
103   }
104
105   /**
106    * 6.10.6
107    * Gets the constraint string. This string describes the
108    * constraints that exist on future values of the property.
109    * Reporting of value constraints is optional. An
110    * implementation is free to return null to this call,
111    * indicating that value constraint information is unavailable
112    * (though a constraint may still exist). If a string is
113    * returned then it is interpreted in different ways depending
114    * on the type specified for this property.
115    */

116   public String JavaDoc getValueConstraint() {
117     return valueConstraint;
118   }
119
120   /**
121    * 6.10.6
122    */

123   public Value getDefaultValue() {
124     return defaultValue;
125   }
126
127   /**
128    * 6.10.6
129    */

130   public boolean isAutoCreate() {
131     return autoCreate;
132   }
133
134   /**
135    * 6.10.6
136    */

137   public boolean isMandatory() {
138     return mandatory;
139   }
140
141   /**
142    * 6.10.6
143    */

144   public int getOnParentVersion() {
145     return onVersion;
146   }
147
148   /**
149    * 6.10.6
150    */

151   public boolean isReadOnly() {
152     return readOnly;
153   }
154
155   /**
156    * 6.10.6
157    */

158   public boolean isPrimaryItem() {
159     return primaryItem;
160   }
161
162   /**
163    * 6.10.6
164    */

165   public boolean isMultiple() {
166     return multiple;
167   }
168
169   public String JavaDoc toString() {
170     return "PropertyDefImpl: " + name;
171   }
172
173   public boolean equals(Object JavaDoc obj) {
174     if (obj == null)
175       return false;
176     if (!(obj instanceof PropertyDefImpl))
177       return false;
178     if (this.getName() == null)
179       return ((PropertyDefImpl) obj).getName() == null;
180     return this.getName().equals(((PropertyDefImpl) obj).getName());
181   }
182
183 }
184
Popular Tags