001package com.hfg.xml.xsd;
002
003import com.hfg.util.StringUtil;
004import com.hfg.xml.XMLNode;
005
006//------------------------------------------------------------------------------
007/**
008 Base class for representation of elements in an XML Schema Definition (XSD) specification.
009 <div>
010  @author J. Alex Taylor, hairyfatguy.com
011 </div>
012 */
013//------------------------------------------------------------------------------
014// com.hfg XML/HTML Coding 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 abstract class XsdContent
035{
036   private int              mMinOccurs;
037   private int              mMaxOccurs;
038
039   //---------------------------------------------------------------------------
040   public XsdContent()
041   {
042
043   }
044
045   //---------------------------------------------------------------------------
046   public XsdContent(XMLNode inTag)
047   {
048      String maxOccursString = inTag.getAttributeValue(XsdXML.MAX_OCCURS_ATT.getLocalName());
049      if (StringUtil.isSet(maxOccursString)
050            && ! maxOccursString.equalsIgnoreCase("unbounded"))
051      {
052         setMaxOccurs(Integer.parseInt(maxOccursString));
053      }
054
055      String minOccursString = inTag.getAttributeValue(XsdXML.MIN_OCCURS_ATT.getLocalName());
056      if (StringUtil.isSet(minOccursString))
057      {
058         setMinOccurs(Integer.parseInt(minOccursString));
059      }
060   }
061
062   //---------------------------------------------------------------------------
063   public XsdContent setMaxOccurs(int inValue)
064   {
065      mMaxOccurs = inValue;
066      return this;
067   }
068
069   //---------------------------------------------------------------------------
070   public int getMaxOccurs()
071   {
072      return mMaxOccurs;
073   }
074
075   //---------------------------------------------------------------------------
076   public XsdContent setMinOccurs(int inValue)
077   {
078      mMinOccurs = inValue;
079      return this;
080   }
081
082   //---------------------------------------------------------------------------
083   public int getMinOccurs()
084   {
085      return mMinOccurs;
086   }
087
088}