001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jcr.base;
031:
032: import javax.jcr.nodetype.ItemDefinition;
033: import javax.jcr.nodetype.NodeType;
034: import javax.jcr.version.OnParentVersionAction;
035:
036: /**
037: * Definition for types of items.
038: */
039: public class BaseItemDefinition implements ItemDefinition {
040: private final NodeType _nodeType;
041: private final String _name;
042:
043: private boolean _isAutoCreated;
044: private boolean _isMandatory;
045: private int _onParentVersion = OnParentVersionAction.COPY;
046: private boolean _isProtected;
047:
048: public BaseItemDefinition(String name, NodeType nodeType) {
049: _name = name;
050: _nodeType = nodeType;
051: }
052:
053: /**
054: * Returns the declaring node type.
055: */
056: public NodeType getDeclaringNodeType() {
057: return _nodeType;
058: }
059:
060: /**
061: * Returns the item definition name.
062: */
063: public String getName() {
064: return _name;
065: }
066:
067: /**
068: * Returns true if this item is automatically created by the
069: * repository.
070: */
071: public boolean isAutoCreated() {
072: return _isAutoCreated;
073: }
074:
075: /**
076: * Set if the item is auto-created.
077: */
078: public void setAutoCreated(boolean isAutoCreated) {
079: _isAutoCreated = isAutoCreated;
080: }
081:
082: /**
083: * Returns true if this item always exists.
084: */
085: public boolean isMandatory() {
086: return _isMandatory;
087: }
088:
089: /**
090: * Set if the item is mandatory
091: */
092: public void setMandatory(boolean isMandatory) {
093: _isMandatory = isMandatory;
094: }
095:
096: /**
097: * Returns the action when the parent is versioned.
098: */
099: public int getOnParentVersion() {
100: return _onParentVersion;
101: }
102:
103: /**
104: * Set the action for the parent versioning.
105: */
106: public void setOnParentVersion(int onParentVersion) {
107: _onParentVersion = onParentVersion;
108: }
109:
110: /**
111: * Returns true for a read-only item.
112: */
113: public boolean isProtected() {
114: return _isProtected;
115: }
116:
117: /**
118: * Set true for a read-only item.
119: */
120: public void setProtected(boolean isProtected) {
121: _isProtected = isProtected;
122: }
123: }
|