001package com.hfg.xml.msofficexml.docx.wordprocessingml;
002
003import com.hfg.util.StringUtil;
004import com.hfg.xml.XMLTag;
005import com.hfg.xml.msofficexml.docx.Docx;
006
007
008//------------------------------------------------------------------------------
009/**
010 Represents an Office Open XML numbering properties (<w:numPr>) tag.
011
012 @author J. Alex Taylor, hairyfatguy.com
013 */
014//------------------------------------------------------------------------------
015// com.hfg XML/HTML Coding Library
016//
017// This library is free software; you can redistribute it and/or
018// modify it under the terms of the GNU Lesser General Public
019// License as published by the Free Software Foundation; either
020// version 2.1 of the License, or (at your option) any later version.
021//
022// This library is distributed in the hope that it will be useful,
023// but WITHOUT ANY WARRANTY; without even the implied warranty of
024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
025// Lesser General Public License for more details.
026//
027// You should have received a copy of the GNU Lesser General Public
028// License along with this library; if not, write to the Free Software
029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030//
031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
032// jataylor@hairyfatguy.com
033//------------------------------------------------------------------------------
034
035public class WmlNumberingProperties extends WmlXMLTag
036{
037   XMLTag mLevelTag;
038   XMLTag mNumberingIdTag;
039
040   //---------------------------------------------------------------------------
041   public WmlNumberingProperties(Docx inDocx)
042   {
043      super(WmlXML.NUMBERING_PROPERTIES, inDocx);
044   }
045
046   //---------------------------------------------------------------------------
047   public WmlNumberingProperties setLevel(int inValue)
048   {
049      if (null == mLevelTag)
050      {
051         // Check it it has been added via addSubtag()...
052         mLevelTag = getOptionalSubtagByName(WmlXML.ITEM_LEVEL);
053         if (null == mLevelTag)
054         {
055            mLevelTag = new XMLTag(WmlXML.ITEM_LEVEL);
056            addSubtag(mLevelTag);
057         }
058      }
059
060      mLevelTag.setAttribute(WmlXML.VALUE_ATT, inValue);
061
062      return this;
063   }
064
065   //---------------------------------------------------------------------------
066   public Integer getLevel()
067   {
068      Integer level = null;
069
070      mLevelTag = getOptionalSubtagByName(WmlXML.ITEM_LEVEL);
071      if (mLevelTag != null)
072      {
073         String stringValue = mLevelTag.getAttributeValue(WmlXML.VALUE_ATT);
074         if (StringUtil.isNumber(stringValue))
075         {
076            level = Integer.parseInt(stringValue);
077         }
078      }
079
080      return level;
081   }
082
083   //---------------------------------------------------------------------------
084   public WmlNumberingProperties setNumberingId(int inValue)
085   {
086      if (null == mNumberingIdTag)
087      {
088         // Check it it has been added via addSubtag()...
089         mNumberingIdTag = getOptionalSubtagByName(WmlXML.NUMBERING_ID);
090         if (null == mNumberingIdTag)
091         {
092            mNumberingIdTag = new XMLTag(WmlXML.NUMBERING_ID);
093            addSubtag(mNumberingIdTag);
094         }
095      }
096
097      mNumberingIdTag.setAttribute(WmlXML.VALUE_ATT, inValue);
098
099      return this;
100   }
101}