001: /*
002: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
003: */
004: package javax.jcr.nodetype;
005:
006: /**
007: * Superclass of {@link NodeDefinition} and {@link PropertyDefinition}.
008: *
009: */
010: public interface ItemDefinition {
011:
012: /**
013: * Gets the node type that contains the declaration of <i>this</i>
014: * <code>ItemDefinition</code>.
015: *
016: * In implementations that support node type registration an
017: * <code>ItemDefinition</code> object may be acquired (in the form of a
018: * <code>NodeDefinitionTemplate</code> or
019: * <code>PropertyDefinitionTemplate</code>) that is not attached to a live
020: * <code>NodeType</code>. In such cases this method returns <code>null</code>.
021: *
022: * @return a <code>NodeType</code> object.
023: */
024: public NodeType getDeclaringNodeType();
025:
026: /**
027: * Gets the name of the child item. If <code>"*"</code>, this
028: * <code>ItemDefinition</code> defines a residual set of child items. That is,
029: * it defines the characteristics of all those child items with names apart
030: * from the names explicitly used in other child item definitions.
031: * <p/>
032: * In implementations that support node type registration, if this
033: * <code>ItemDefinition</code> object is actually a newly-created empty
034: * <code>PropertyDefinitionTemplate</code> or
035: * <code>NodeDefinitionTemplate</code>, then this method will return
036: * <code>null</code>.
037: *
038: * @return a <code>String</code> denoting the name or <code>"*"</code>.
039: */
040: public String getName();
041:
042: /**
043: * Reports whether the item is to be automatically created when its parent node is created.
044: * If <code>true</code>, then this <code>ItemDefinition</code> will necessarily not be a residual
045: * set definition but will specify an actual item name (in other words getName() will not
046: * return "*").
047: * <p/>
048: * An autocreated item is created immediately when its parent node is created
049: * in the transient session space. Creation of autocreated items is never
050: * delayed until <code>save</code>.
051: * <p/>
052: * In implementations that support node type registration, if this
053: * <code>ItemDefinition</code> object is actually a newly-created empty
054: * <code>PropertyDefinitionTemplate</code> or
055: * <code>NodeDefinitionTemplate</code>, then this method will return
056: * <code>false</code>.
057: *
058: * @return a <code>boolean</code>.
059: */
060: public boolean isAutoCreated();
061:
062: /**
063: * Reports whether the item is mandatory. A mandatory item is one that,
064: * if its parent node exists, must also exist.
065: * <p/>
066: * This means that a mandatory single-value property
067: * must have a value (since there is no such thing a <code>null</code> value).
068: * In the case of multi-value properties this means that the property must exist,
069: * though it can have zero or more values.
070: * <p/>
071: * An attempt to save a node that has a mandatory child item without first
072: * creating that child item will throw a
073: * <code>ConstraintViolationException</code> on <code>save</code>.
074: * <p/>
075: * In implementations that support node type registration, if this
076: * <code>ItemDefinition</code> object is actually a newly-created empty
077: * <code>PropertyDefinitionTemplate</code> or
078: * <code>NodeDefinitionTemplate</code>, then this method will return
079: * <code>false</code>.
080: * <p/>
081: * An item definition cannot be both residual and mandatory.
082: *
083: * @return a <code>boolean</code>
084: */
085: public boolean isMandatory();
086:
087: /**
088: * Gets the <code>OnParentVersion </code> status of the child item. This
089: * governs what occurs (in implementations that support versioning) when the
090: * parent node of this item is checked-in. One of:
091: * <ul>
092: * <li><code>OnParentVersionAction.COPY</code></li>
093: * <li><code>OnParentVersionAction.VERSION</code></li>
094: * <li><code>OnParentVersionAction.IGNORE</code></li>
095: * <li><code>OnParentVersionAction.INITIALIZE</code></li>
096: * <li><code>OnParentVersionAction.COMPUTE</code></li>
097: * <li><code>OnParentVersionAction.ABORT</code></li>
098: * </ul>
099: * <p/>
100: * In implementations that support node type registration, if this
101: * <code>ItemDefinition</code> object is actually a newly-created empty
102: * <code>PropertyDefinitionTemplate</code> or
103: * <code>NodeDefinitionTemplate</code>, then this method will return
104: * <code>OnParentVersionAction.COPY</code>.
105: *
106: * @return a <code>int</code> constant meber of {@link javax.jcr.version.OnParentVersionAction}.
107: */
108: public int getOnParentVersion();
109:
110: /**
111: * Reports whether the child item is protected. In level 2 implementations, a protected item is one that cannot be removed
112: * (xcept by removing its parent) or modified through the the standard write methods of this API (that is, <code>Item.remove</code>,
113: * <code>Node.addNode</code>, <code>Node.setProperty</code> and <code>Property.setValue</code>).
114: * <p/>
115: * A protected node may be removed or modified (in a level 2 implementation), however, through some
116: * mechanism not defined by this specification or as a side-effect of operations other than
117: * the standard write methods of the API.
118: * <p/>
119: * In implementations that support node type registration, if this
120: * <code>ItemDefinition</code> object is actually a newly-created empty
121: * <code>PropertyDefinitionTemplate</code> or
122: * <code>NodeDefinitionTemplate</code>, then this method will return
123: * <code>false</code>.
124: *
125: * @return a <code>boolean</code>.
126: */
127: public boolean isProtected();
128: }
|