001: /*
002: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
003: */
004: package javax.jcr.nodetype;
005:
006: /**
007: * A node definition. Used in node type definitions.
008: *
009: * @see NodeType#getChildNodeDefinitions
010: * @see javax.jcr.Node#getDefinition
011: *
012: */
013: public interface NodeDefinition extends ItemDefinition {
014:
015: /**
016: * Gets the minimum set of primary node types that the child node must have.
017: * Returns an array to support those implementations with multiple
018: * inheritance. This method never returns an empty array. If this node
019: * definition places no requirements on the primary node type, then this
020: * method will return an array containing only the <code>NodeType</code>
021: * object representing <code>nt:base</code>, which is the base of all
022: * primary node types and therefore constitutes the least restrictive node
023: * type requirement. Note that any particular node instance still has only
024: * one assigned primary node type, but in multiple-inheritance-supporting
025: * implementations the <code>RequiredPrimaryTypes</code> attribute can be
026: * used to restrict that assigned node type to be a subtype of <i>all<i> of
027: * a specified set of node types.
028: * <p/>
029: * In implementations that support node type registration an
030: * <code>NodeDefinition</code> object may be acquired (in the form of a
031: * <code>NodeDefinitionTemplate</code>) that is not attached to a live
032: * <code>NodeType</code>. In such cases this method returns an array
033: * containing only the <code>NodeType</code>
034: * object representing <code>nt:base</code>.
035: *
036: * @return an array of <code>NodeType</code> objects.
037: */
038: public NodeType[] getRequiredPrimaryTypes();
039:
040: /**
041: * Returns the names of the required primary node types.
042: * <p/>
043: * If this <code>NodeDefinition</code> is acquired from a live
044: * <code>NodeType</code> this list will reflect the node types returned by
045: * <code>getRequiredPrimaryTypes</code>, above.
046: * <p/>
047: * If this <code>NodeDefinition</code> is actually a
048: * <code>NodeDefinitionTemplate</code> that is not part of a registered node
049: * type, then this method will return the required primary types as set in
050: * that template. If that template is a newly-created empty one, then this
051: * method will return an array containing a single string indicating the
052: * node type <code>nt:base</code>.
053: *
054: * @return a String array
055: * @since JCR 2.0
056: */
057: public String[] getRequiredPrimaryTypeNames();
058:
059: /**
060: * Gets the default primary node type that will be assigned to the child
061: * node if it is created without an explicitly specified primary node type.
062: * This node type must be a subtype of (or the same type as) the node types
063: * returned by <code>getRequiredPrimaryTypes</code>.
064: * <p/>
065: * If <code>null</code> is returned this indicates that no default primary
066: * type is specified and that therefore an attempt to create this node without
067: * specifying a node type will throw a <code>ConstraintViolationException</code>.
068: *
069: * In implementations that support node type registration an
070: * <code>NodeDefinition</code> object may be acquired (in the form of a
071: * <code>NodeDefinitionTemplate</code>) that is not attached to a live
072: * <code>NodeType</code>. In such cases this method returns <code>null</code>.
073: *
074: * @return a <code>NodeType</code>.
075: */
076: public NodeType getDefaultPrimaryType();
077:
078: /**
079: * Returns the name of the default primary node type.
080: * <p/>
081: * If this <code>NodeDefinition</code> is acquired from a live
082: * <code>NodeType</code> this list will reflect the NodeType returned by
083: * getDefaultPrimaryType, above.
084: * <p/>
085: * If this <code>NodeDefinition</code> is actually a
086: * <code>NodeDefinitionTemplate</code> that is not part of a registered node
087: * type, then this method will return the required primary types as set in
088: * that template. If that template is a newly-created empty one, then this
089: * method will return <code>null</code>.
090: *
091: * @return a String
092: * @since JCR 2.0
093: */
094: public String getDefaultPrimaryTypeName();
095:
096: /**
097: * Reports whether this child node can have same-name siblings. In other
098: * words, whether the parent node can have more than one child node of this
099: * name.
100: *
101: * If this <code>NodeDefinition</code> is actually a <code>NodeDefinitionTemplate</code> that is not
102: * part of a registered node type, then this method will return the same
103: * name siblings status as set in that template. If that template is a
104: * newly-created empty one, then this method will return <code>false</code>.
105: *
106: * @return a boolean.
107: */
108: public boolean allowsSameNameSiblings();
109: }
|