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.data;
017
018import java.sql.Types;
019
020import org.ametys.plugins.forms.Field;
021
022/**
023 * Class representing a field value.
024 */
025public class FieldValue
026{
027    
028    /** The database column name. */
029    protected String _columnName;
030    
031    /** The database column type (from {@link java.sql.Types}). */
032    protected int _type;
033    
034    /** The value. */
035    protected Object _value;
036    
037    /** The corresponding field. */
038    protected Field _field;
039    
040    /**
041     * Default constructor.
042     */
043    public FieldValue()
044    {
045        this("", Types.OTHER, null, null);
046    }
047    
048    /**
049     * Constructor with parameters.
050     * @param columnName the column name.
051     * @param type the column type.
052     * @param value the entry value.
053     * @param field the corresponding field.
054     */
055    public FieldValue(String columnName, int type, Object value, Field field)
056    {
057        this._columnName = columnName;
058        this._type = type;
059        this._value = value;
060        this._field = field;
061    }
062    
063    /**
064     * Copy constructor.
065     * @param value the value.
066     */
067    public FieldValue(FieldValue value)
068    {
069        this(value.getColumnName(), value.getType(), value.getValue(), value.getField());
070    }
071    
072    /**
073     * Get the columnName.
074     * @return the columnName
075     */
076    public String getColumnName()
077    {
078        return _columnName;
079    }
080    
081    /**
082     * Set the columnName.
083     * @param columnName the columnName to set
084     */
085    public void setColumnName(String columnName)
086    {
087        this._columnName = columnName;
088    }
089    
090    /**
091     * Get the type.
092     * @return the type
093     */
094    public int getType()
095    {
096        return _type;
097    }
098    
099    /**
100     * Set the type.
101     * @param type the type to set
102     */
103    public void setType(int type)
104    {
105        this._type = type;
106    }
107    
108    /**
109     * Get the value.
110     * @return the value
111     */
112    public Object getValue()
113    {
114        return _value;
115    }
116    
117    /**
118     * Set the value.
119     * @param value the value to set
120     */
121    public void setValue(Object value)
122    {
123        this._value = value;
124    }
125    
126    /**
127     * Get the corresponding field.
128     * @return the corresponding field.
129     */
130    public Field getField()
131    {
132        return _field;
133    }
134    
135    /**
136     * Set the corresponding field.
137     * @param field the corresponding field to set.
138     */
139    public void setField(Field field)
140    {
141        this._field = field;
142    }
143    
144}