KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > dictionary > NodeDefinitionImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.jcr.dictionary;
18
19
20 import javax.jcr.nodetype.NodeDefinition;
21 import javax.jcr.nodetype.NodeType;
22 import javax.jcr.version.OnParentVersionAction;
23
24 import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
25 import org.alfresco.service.cmr.dictionary.ClassDefinition;
26
27
28 /**
29  * Alfresco implementation of a JCR Node Definition
30  *
31  * @author David Caruana
32  *
33  */

34 public class NodeDefinitionImpl implements NodeDefinition
35 {
36     private NodeTypeManagerImpl typeManager;
37     private ChildAssociationDefinition assocDef;
38     
39     /**
40      * Construct
41      *
42      * @param typeManager
43      * @param assocDef
44      */

45     public NodeDefinitionImpl(NodeTypeManagerImpl typeManager, ChildAssociationDefinition assocDef)
46     {
47         this.typeManager = typeManager;
48         this.assocDef = assocDef;
49     }
50     
51     /* (non-Javadoc)
52      * @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
53      */

54     public NodeType[] getRequiredPrimaryTypes()
55     {
56         // Note: target class is mandatory in Alfresco
57
ClassDefinition target = assocDef.getTargetClass();
58         return new NodeType[] { typeManager.getNodeTypeImpl(target.getName()) };
59     }
60
61     /* (non-Javadoc)
62      * @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
63      */

64     public NodeType getDefaultPrimaryType()
65     {
66         return null;
67     }
68
69     /* (non-Javadoc)
70      * @see javax.jcr.nodetype.NodeDefinition#allowsSameNameSiblings()
71      */

72     public boolean allowsSameNameSiblings()
73     {
74         return assocDef.getDuplicateChildNamesAllowed();
75     }
76
77     /* (non-Javadoc)
78      * @see javax.jcr.nodetype.ItemDefinition#getDeclaringNodeType()
79      */

80     public NodeType getDeclaringNodeType()
81     {
82         return typeManager.getNodeTypeImpl(assocDef.getSourceClass().getName());
83     }
84
85     /* (non-Javadoc)
86      * @see javax.jcr.nodetype.ItemDefinition#getName()
87      */

88     public String JavaDoc getName()
89     {
90         return assocDef.getName().toPrefixString(typeManager.getNamespaceService());
91     }
92
93     /* (non-Javadoc)
94      * @see javax.jcr.nodetype.ItemDefinition#isAutoCreated()
95      */

96     public boolean isAutoCreated()
97     {
98         return isMandatory();
99     }
100
101     /* (non-Javadoc)
102      * @see javax.jcr.nodetype.ItemDefinition#isMandatory()
103      */

104     public boolean isMandatory()
105     {
106         return assocDef.isTargetMandatory();
107     }
108
109     /* (non-Javadoc)
110      * @see javax.jcr.nodetype.ItemDefinition#getOnParentVersion()
111      */

112     public int getOnParentVersion()
113     {
114         // TODO: Check this correct
115
return OnParentVersionAction.INITIALIZE;
116     }
117
118     /* (non-Javadoc)
119      * @see javax.jcr.nodetype.ItemDefinition#isProtected()
120      */

121     public boolean isProtected()
122     {
123         return assocDef.isProtected();
124     }
125
126 }
127
Popular Tags