KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jcr > base > BaseItemDefinition


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source 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, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.jcr.base;
31
32 import javax.jcr.nodetype.ItemDefinition;
33 import javax.jcr.nodetype.NodeType;
34 import javax.jcr.version.OnParentVersionAction;
35
36 /**
37  * Definition for types of items.
38  */

39 public class BaseItemDefinition implements ItemDefinition {
40   private final NodeType _nodeType;
41   private final String JavaDoc _name;
42
43   private boolean _isAutoCreated;
44   private boolean _isMandatory;
45   private int _onParentVersion = OnParentVersionAction.COPY;
46   private boolean _isProtected;
47
48   public BaseItemDefinition(String JavaDoc name, NodeType nodeType)
49   {
50     _name = name;
51     _nodeType = nodeType;
52   }
53   
54   /**
55    * Returns the declaring node type.
56    */

57   public NodeType getDeclaringNodeType()
58   {
59     return _nodeType;
60   }
61
62   /**
63    * Returns the item definition name.
64    */

65   public String JavaDoc getName()
66   {
67     return _name;
68   }
69
70   /**
71    * Returns true if this item is automatically created by the
72    * repository.
73    */

74   public boolean isAutoCreated()
75   {
76     return _isAutoCreated;
77   }
78
79   /**
80    * Set if the item is auto-created.
81    */

82   public void setAutoCreated(boolean isAutoCreated)
83   {
84     _isAutoCreated = isAutoCreated;
85   }
86
87   /**
88    * Returns true if this item always exists.
89    */

90   public boolean isMandatory()
91   {
92     return _isMandatory;
93   }
94
95   /**
96    * Set if the item is mandatory
97    */

98   public void setMandatory(boolean isMandatory)
99   {
100     _isMandatory = isMandatory;
101   }
102
103   /**
104    * Returns the action when the parent is versioned.
105    */

106   public int getOnParentVersion()
107   {
108     return _onParentVersion;
109   }
110
111   /**
112    * Set the action for the parent versioning.
113    */

114   public void setOnParentVersion(int onParentVersion)
115   {
116     _onParentVersion = onParentVersion;
117   }
118
119   /**
120    * Returns true for a read-only item.
121    */

122   public boolean isProtected()
123   {
124     return _isProtected;
125   }
126
127   /**
128    * Set true for a read-only item.
129    */

130   public void setProtected(boolean isProtected)
131   {
132     _isProtected = isProtected;
133   }
134 }
135
Popular Tags