001/*
002 *  Copyright 2010 Anyware Services
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 */
016package org.ametys.plugins.forms;
017
018import java.util.HashMap;
019import java.util.Map;
020
021/**
022 * Class representing a form field.
023 */
024public class Field
025{
026    /**
027     * Field type.
028     */
029    public static enum FieldType
030    {
031        /** Text input */
032        TEXT,
033        /** Textarea */
034        TEXTAREA,
035        /** Select list */
036        SELECT,
037        /** Checkbox */
038        CHECKBOX,
039        /** Radio button */
040        RADIO,
041        /** Password */
042        PASSWORD,
043        /** File upload control */
044        FILE,
045        /** Hidden value */
046        HIDDEN,
047        /** Captcha */
048        CAPTCHA
049    }
050    
051    /** The field ID. */
052    protected String _id;
053    
054    /** The field type. */
055    protected FieldType _type;
056    
057    /** The field name. */
058    protected String _name;
059    
060    /** The field label. */
061    protected String _label;
062    
063    /** The field properties. */
064    protected Map<String, String> _properties;
065    
066    /**
067     * Default constructor.
068     * @param type the field type.
069     */
070    public Field(FieldType type)
071    {
072        this("", type, "", "", new HashMap<String, String>());
073    }
074    
075    /**
076     * Constructor with parameters.
077     * @param id the field ID.
078     * @param type the field type.
079     * @param name the field name.
080     * @param label the field label.
081     * @param properties the field properties.
082     */
083    public Field(String id, FieldType type, String name, String label, Map<String, String> properties)
084    {
085        this._id = id;
086        this._type = type;
087        this._name = name;
088        this._label = label;
089        this._properties = properties;
090    }
091
092    /**
093     * Get the id.
094     * @return the id
095     */
096    public String getId()
097    {
098        return _id;
099    }
100
101    /**
102     * Set the id.
103     * @param id the id to set
104     */
105    public void setId(String id)
106    {
107        this._id = id;
108    }
109    
110    /**
111     * Get the type.
112     * @return the type
113     */
114    public FieldType getType()
115    {
116        return _type;
117    }
118    
119    /**
120     * Set the type.
121     * @param type the type to set
122     */
123    public void setType(FieldType type)
124    {
125        this._type = type;
126    }
127    
128    /**
129     * Get the name.
130     * @return the name
131     */
132    public String getName()
133    {
134        return _name;
135    }
136
137    /**
138     * Set the name.
139     * @param name the name to set
140     */
141    public void setName(String name)
142    {
143        this._name = name;
144    }
145
146    /**
147     * Get the label.
148     * @return the label
149     */
150    public String getLabel()
151    {
152        return _label;
153    }
154
155    /**
156     * Set the label.
157     * @param label the label to set
158     */
159    public void setLabel(String label)
160    {
161        this._label = label;
162    }
163
164    /**
165     * Get the properties.
166     * @return the properties
167     */
168    public Map<String, String> getProperties()
169    {
170        return _properties;
171    }
172
173    /**
174     * Set the properties.
175     * @param properties the properties to set
176     */
177    public void setProperties(Map<String, String> properties)
178    {
179        this._properties = properties;
180    }
181    
182}