001package com.hfg.xml.msoffice2003.spreadsheetml;
002
003import com.hfg.util.StringUtil;
004import com.hfg.xml.XMLTag;
005
006
007//------------------------------------------------------------------------------
008/**
009 Data tag for use with Microsoft's Office 2003 SpreadsheetML.
010
011 @author J. Alex Taylor, hairyfatguy.com
012 */
013//------------------------------------------------------------------------------
014// com.hfg Library
015//
016// This library is free software; you can redistribute it and/or
017// modify it under the terms of the GNU Lesser General Public
018// License as published by the Free Software Foundation; either
019// version 2.1 of the License, or (at your option) any later version.
020//
021// This library is distributed in the hope that it will be useful,
022// but WITHOUT ANY WARRANTY; without even the implied warranty of
023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
024// Lesser General Public License for more details.
025//
026// You should have received a copy of the GNU Lesser General Public
027// License along with this library; if not, write to the Free Software
028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
029//
030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
031// jataylor@hairyfatguy.com
032//------------------------------------------------------------------------------
033
034public class ExcelData extends XMLTag
035{
036
037   //---------------------------------------------------------------------------
038   public ExcelData(ExcelDataType inType, String inValue)
039   {
040      super(SpreadsheetML.DATA);
041      if (inType != null)
042      {
043         setAttribute(SpreadsheetML.TYPE_ATT, inType.name());
044      }
045      setContent(inValue);
046   }
047
048   //---------------------------------------------------------------------------
049   public ExcelData(String inValue)
050   {
051      super(SpreadsheetML.DATA);
052      setDataType(ExcelDataType.String);
053      setContent(inValue);
054   }
055
056   //---------------------------------------------------------------------------
057   public ExcelData(int inValue)
058   {
059      super(SpreadsheetML.DATA);
060      setDataType(ExcelDataType.Number);
061      setContent(inValue + "");
062   }
063
064   //---------------------------------------------------------------------------
065   public ExcelData(float inValue)
066   {
067      super(SpreadsheetML.DATA);
068      setDataType(ExcelDataType.Number);
069      setContent(inValue + "");
070   }
071
072   //---------------------------------------------------------------------------
073   public ExcelData(double inValue)
074   {
075      super(SpreadsheetML.DATA);
076      setDataType(ExcelDataType.Number);
077      setContent(inValue + "");
078   }
079
080
081
082   //---------------------------------------------------------------------------
083   /**
084    Specifies the data type attribute.
085    */
086   public ExcelData setDataType(ExcelDataType inValue)
087   {
088      setAttribute(SpreadsheetML.TYPE_ATT, inValue);
089      return this;
090   }
091
092   //---------------------------------------------------------------------------
093   /**
094    Specifies the data type attribute.
095    */
096   public ExcelDataType getDataType()
097   {
098      String attrValue = getAttributeValue(SpreadsheetML.TYPE_ATT);
099      return (StringUtil.isSet(attrValue) ? ExcelDataType.valueOf(attrValue) : null);
100   }
101
102}