001package com.hfg.setting; 002 003 004import com.hfg.xml.XMLTag; 005 006//------------------------------------------------------------------------------ 007/** 008 * An XML-serializable float setting. 009 * 010 * @author J. Alex Taylor, hairyfatguy.com 011 */ 012//------------------------------------------------------------------------------ 013// com.hfg XML/HTML Coding Library 014// 015// This library is free software; you can redistribute it and/or 016// modify it under the terms of the GNU Lesser General Public 017// License as published by the Free Software Foundation; either 018// version 2.1 of the License, or (at your option) any later version. 019// 020// This library is distributed in the hope that it will be useful, 021// but WITHOUT ANY WARRANTY; without even the implied warranty of 022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 023// Lesser General Public License for more details. 024// 025// You should have received a copy of the GNU Lesser General Public 026// License along with this library; if not, write to the Free Software 027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 028// 029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 030// jataylor@hairyfatguy.com 031//------------------------------------------------------------------------------ 032 033public class FloatSetting extends SettingImpl implements Setting<Float> 034{ 035 //########################################################################### 036 // CONSTRUCTORS 037 //########################################################################### 038 039 //--------------------------------------------------------------------------- 040 public FloatSetting(String inName) 041 { 042 super(inName); 043 } 044 045 //--------------------------------------------------------------------------- 046 public FloatSetting(String inName, Float inValue) 047 { 048 super(inName, inValue); 049 } 050 051 //--------------------------------------------------------------------------- 052 /** 053 * Copy constructor. 054 * @param inObj2 the FloatSetting to clone 055 */ 056 public FloatSetting(FloatSetting inObj2) 057 { 058 this(inObj2.name(), inObj2.getValue()); 059 } 060 061 //--------------------------------------------------------------------------- 062 public FloatSetting(XMLTag inXMLTag) 063 { 064 super(inXMLTag); 065 } 066 067 //########################################################################### 068 // PUBLIC METHODS 069 //########################################################################### 070 071 //--------------------------------------------------------------------------- 072 public FloatSetting setValue(Float inValue) 073 { 074 super.setObjectValue(inValue); 075 return this; 076 } 077 078 //--------------------------------------------------------------------------- 079 @Override 080 public Float getValue() 081 { 082 return (Float) super.getObjectValue(); 083 } 084 085 //--------------------------------------------------------------------------- 086 @Override 087 public FloatSetting clone() 088 { 089 return new FloatSetting(this); 090 } 091 092 //########################################################################### 093 // PROTECTED METHODS 094 //########################################################################### 095 096 //--------------------------------------------------------------------------- 097 protected void setValueFromString(String inValue) 098 { 099 setObjectValue(inValue != null ? Float.parseFloat(inValue) : null); 100 } 101 102}