001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     bstefanescu
016 */
017package org.nuxeo.ecm.webengine.forms.validation;
018
019import java.util.Collection;
020import java.util.Map;
021
022import org.nuxeo.ecm.webengine.forms.FormDataProvider;
023
024/**
025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
026 */
027public interface Form {
028    // TODO remove it?
029    Collection<String> unknownKeys();
030
031    /**
032     * Before using the form, implementors must ensure this method is called to initialize form data, otherwise NPE will
033     * be thrown. This method must never be called by clients. It is internal to validation implementation and should be
034     * called only by implementors when creating a form.
035     *
036     * @param data the form data source
037     * @param proxy the proxy to the user form
038     * @throws ValidationException
039     */
040    void load(FormDataProvider data, Form proxy) throws ValidationException;
041
042    /**
043     * Get the form fields as submitted by the client. The fields are present even if the form is not valid
044     *
045     * @return the form fields or an empty map if none
046     */
047    Map<String, String[]> fields();
048
049}