001/*
002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Bogdan Stefanescu
018 *     Florent Guillaume
019 */
020package org.nuxeo.ecm.core.schema.types;
021
022/**
023 * A list of typed objects.
024 * <p>
025 * The List type can validate java <code>array</code> and/or java <code>Collection</code>.
026 */
027public interface ListType extends Type {
028
029    /**
030     * Get the field describing the element type the list accept.
031     *
032     * @return the field describing the list element types
033     */
034    Type getFieldType();
035
036    /**
037     * The field name if any was specified.
038     * <p>
039     * This is used to more for outputting the list as XML and for compatibility with XSD.
040     *
041     * @return the field name
042     */
043    String getFieldName();
044
045    /**
046     * Get the field defining the elements stored by this list.
047     *
048     * @return the field
049     */
050    Field getField();
051
052    /**
053     * Gets the required minimum count of elements in this list.
054     *
055     * @return the minimum count of required elements
056     */
057    int getMinCount();
058
059    /**
060     * Gets the required maximum count of allowed elements in this list.
061     *
062     * @return the maximum count of allowed elements
063     */
064    int getMaxCount();
065
066    /**
067     * Gets the default value of the list elements, if any.
068     *
069     * @return the default value or null if none
070     */
071    Object getDefaultValue();
072
073    /**
074     * Sets the default value encoded as a string.
075     *
076     * @param value
077     */
078    void setDefaultValue(String value);
079
080    /**
081     * Sets list limits.
082     *
083     * @param minOccurs
084     * @param maxOccurs
085     */
086    void setLimits(int minOccurs, int maxOccurs);
087
088    /**
089     * Whether the instances of this list are arrays.
090     */
091    boolean isArray();
092
093    /**
094     * This method is provided for compatibility. Existing code is mapping scalar lists to arrays but this should be
095     * changed in order to map only explicit scalar list (those declared using xs:list) to arrays and not all list that
096     * have scalar items.
097     *
098     * @return true if the list items are of a scalar type TODO FIXME XXX remove the method and use instead isArray
099     */
100    boolean isScalarList();
101
102}