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.PropertyType;
027    import javax.jcr.nodetype.PropertyDefinition;
028    import javax.jcr.version.OnParentVersionAction;
029    import net.jcip.annotations.NotThreadSafe;
030    
031    /**
032     * A template that can be used to create new property 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 PropertyDefinition}
034     * interface and adds setter methods for the various attributes.
035     * 
036     * @see NodeTypeTemplate#getDeclaredPropertyDefinitions()
037     */
038    @NotThreadSafe
039    public interface PropertyDefinitionTemplate extends PropertyDefinition {
040    
041        /**
042         * Set the name of the property definition
043         * 
044         * @param name the name
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 required property type for the values of the property, or {@link PropertyType#UNDEFINED} if there is no type
078         * requirement
079         * 
080         * @param requiredType the required type for the property values
081         */
082        public void setRequiredType( int requiredType );
083    
084        /**
085         * Set the constraint expressions for the values of the property. See {@link PropertyDefinition#getValueConstraints()} for
086         * more details about the formats of the constraints.
087         * 
088         * @param constraints the value constraints, or null or an empty array if there are no constraints.
089         */
090        public void setValueConstraints( String[] constraints );
091    
092        /**
093         * Set the default values for the property, using their string representation. See
094         * {@link PropertyDefinition#getDefaultValues()} for more details.
095         * 
096         * @param defaultValues the string representation of the default values, or null or an empty array if there are no default
097         *        values
098         */
099        public void setDefaultValues( String[] defaultValues );
100    
101        /**
102         * Set whether the properties described by this definition may have multiple values.
103         * 
104         * @param multiple true if the properties may have multiple values, or false if they are limited to one value each
105         */
106        public void setMultiple( boolean multiple );
107    }