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