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 /** Display cost */ 048 COST, 049 /** Captcha */ 050 CAPTCHA 051 } 052 053 /** The field ID. */ 054 protected String _id; 055 056 /** The field type. */ 057 protected FieldType _type; 058 059 /** The field name. */ 060 protected String _name; 061 062 /** The field label. */ 063 protected String _label; 064 065 /** The field properties. */ 066 protected Map<String, String> _properties; 067 068 /** 069 * Default constructor. 070 * @param type the field type. 071 */ 072 public Field(FieldType type) 073 { 074 this("", type, "", "", new HashMap<String, String>()); 075 } 076 077 /** 078 * Constructor with parameters. 079 * @param id the field ID. 080 * @param type the field type. 081 * @param name the field name. 082 * @param label the field label. 083 * @param properties the field properties. 084 */ 085 public Field(String id, FieldType type, String name, String label, Map<String, String> properties) 086 { 087 this._id = id; 088 this._type = type; 089 this._name = name; 090 this._label = label; 091 this._properties = properties; 092 } 093 094 /** 095 * Get the id. 096 * @return the id 097 */ 098 public String getId() 099 { 100 return _id; 101 } 102 103 /** 104 * Set the id. 105 * @param id the id to set 106 */ 107 public void setId(String id) 108 { 109 this._id = id; 110 } 111 112 /** 113 * Get the type. 114 * @return the type 115 */ 116 public FieldType getType() 117 { 118 return _type; 119 } 120 121 /** 122 * Set the type. 123 * @param type the type to set 124 */ 125 public void setType(FieldType type) 126 { 127 this._type = type; 128 } 129 130 /** 131 * Get the name. 132 * @return the name 133 */ 134 public String getName() 135 { 136 return _name; 137 } 138 139 /** 140 * Set the name. 141 * @param name the name to set 142 */ 143 public void setName(String name) 144 { 145 this._name = name; 146 } 147 148 /** 149 * Get the label. 150 * @return the label 151 */ 152 public String getLabel() 153 { 154 return _label; 155 } 156 157 /** 158 * Set the label. 159 * @param label the label to set 160 */ 161 public void setLabel(String label) 162 { 163 this._label = label; 164 } 165 166 /** 167 * Get the properties. 168 * @return the properties 169 */ 170 public Map<String, String> getProperties() 171 { 172 return _properties; 173 } 174 175 /** 176 * Set the properties. 177 * @param properties the properties to set 178 */ 179 public void setProperties(Map<String, String> properties) 180 { 181 this._properties = properties; 182 } 183 184}