001    /*
002     * JBoss DNA (http://www.jboss.org/dna)
003     * See the COPYRIGHT.txt file distributed with this work for information
004     * regarding copyright ownership.  Some portions may be licensed
005     * to Red Hat, Inc. under one or more contributor license agreements.
006     * See the AUTHORS.txt file in the distribution for a full listing of 
007     * individual contributors.
008     *
009     * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
010     * is licensed to you under the terms of the GNU Lesser General Public License as
011     * published by the Free Software Foundation; either version 2.1 of
012     * the License, or (at your option) any later version.
013     * 
014     * JBoss DNA 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. See the GNU
017     * Lesser General Public License for more details.
018     *
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this software; if not, write to the Free
021     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023     */
024    package org.jboss.dna.jcr.nodetype;
025    
026    import javax.jcr.Node;
027    import javax.jcr.nodetype.NodeDefinition;
028    import javax.jcr.version.OnParentVersionAction;
029    import net.jcip.annotations.NotThreadSafe;
030    
031    /**
032     * A template that can be used to create new child node definitions, patterned after the approach in the proposed <a
033     * href="http://jcp.org/en/jsr/detail?id=283">JSR-283</a>. This interface extends the standard {@link NodeTypeDefinition}
034     * interface and adds setter methods for the various attributes.
035     * 
036     * @see NodeTypeTemplate#getDeclaredNodeDefinitions()
037     */
038    @NotThreadSafe
039    public interface NodeDefinitionTemplate extends NodeDefinition {
040    
041        /**
042         * Set the name of this child node definition.
043         * 
044         * @param name the name for this child node definition.
045         */
046        public void setName( String name );
047    
048        /**
049         * Set whether this definition describes a child node that is auto-created by the system.
050         * 
051         * @param autoCreated true if this child should be auto-created
052         */
053        public void setAutoCreated( boolean autoCreated );
054    
055        /**
056         * Set whether this definition describes a child that is required (mandatory).
057         * 
058         * @param mandatory true if the child is mandatory
059         */
060        public void setMandatory( boolean mandatory );
061    
062        /**
063         * Set the mode for the versioning of the child with respect to versioning of the parent.
064         * 
065         * @param opv the on-parent versioning mode; one of {@link OnParentVersionAction} values.
066         */
067        public void setOnParentVersion( int opv );
068    
069        /**
070         * Set whether the child node described by this definition is protected from changes through the JCR API.
071         * 
072         * @param isProtected true if the child node is protected, or false if it may be changed through the JCR API
073         */
074        public void setProtected( boolean isProtected );
075    
076        /**
077         * Set the names of the primary types that must appear on the child(ren) described by this definition
078         * 
079         * @param requiredPrimaryTypes the names of the required primary types, or null or empty if there are no requirements for the
080         *        primary types of the children described by this definition
081         */
082        public void setRequiredPrimaryTypes( String[] requiredPrimaryTypes );
083    
084        /**
085         * Set the name of the primary type that should be used by default when creating children using this node definition.
086         * 
087         * @param defaultPrimaryType the name of the primary type that should be used by default, or null if there is none
088         */
089        public void setDefaultPrimaryType( String defaultPrimaryType );
090    
091        /**
092         * Set whether the children described by this definition may have the same names (and therefore distinguished only by their
093         * {@link Node#getIndex() same-name-sibiling index}).
094         * 
095         * @param allowSameNameSiblings true if the children described by this definition may have the same names, or false otherwise
096         */
097        public void setSameNameSiblings( boolean allowSameNameSiblings );
098    
099    }