001/* 002 * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Bogdan Stefanescu 011 * Florent Guillaume 012 */ 013package org.nuxeo.ecm.core.schema.types; 014 015/** 016 * A list of typed objects. 017 * <p> 018 * The List type can validate java <code>array</code> and/or java <code>Collection</code>. 019 */ 020public interface ListType extends Type { 021 022 /** 023 * Get the field describing the element type the list accept. 024 * 025 * @return the field describing the list element types 026 */ 027 Type getFieldType(); 028 029 /** 030 * The field name if any was specified. 031 * <p> 032 * This is used to more for outputting the list as XML and for compatibility with XSD. 033 * 034 * @return the field name 035 */ 036 String getFieldName(); 037 038 /** 039 * Get the field defining the elements stored by this list. 040 * 041 * @return the field 042 */ 043 Field getField(); 044 045 /** 046 * Gets the required minimum count of elements in this list. 047 * 048 * @return the minimum count of required elements 049 */ 050 int getMinCount(); 051 052 /** 053 * Gets the required maximum count of allowed elements in this list. 054 * 055 * @return the maximum count of allowed elements 056 */ 057 int getMaxCount(); 058 059 /** 060 * Gets the default value of the list elements, if any. 061 * 062 * @return the default value or null if none 063 */ 064 Object getDefaultValue(); 065 066 /** 067 * Sets the default value encoded as a string. 068 * 069 * @param value 070 */ 071 void setDefaultValue(String value); 072 073 /** 074 * Sets list limits. 075 * 076 * @param minOccurs 077 * @param maxOccurs 078 */ 079 void setLimits(int minOccurs, int maxOccurs); 080 081 /** 082 * Whether the instances of this list are arrays. 083 */ 084 boolean isArray(); 085 086 /** 087 * This method is provided for compatibility. Existing code is mapping scalar lists to arrays but this should be 088 * changed in order to map only explicit scalar list (those declared using xs:list) to arrays and not all list that 089 * have scalar items. 090 * 091 * @return true if the list items are of a scalar type TODO FIXME XXX remove the method and use instead isArray 092 */ 093 boolean isScalarList(); 094 095}