001package com.hfg.xml;
002
003import java.util.Collection;
004import java.util.HashSet;
005
006//------------------------------------------------------------------------------
007/**
008 Container for a set of XML namespaces which also track what the current default
009 namespace is.
010
011 @author J. Alex Taylor
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 class XMLNamespaceSet extends HashSet<XMLNamespace>
035{
036   XMLNamespace mDefaultNamespace;
037
038   //###########################################################################
039   // CONSTRUCTORS
040   //###########################################################################
041
042   //---------------------------------------------------------------------------
043   public XMLNamespaceSet()
044   {
045      super();
046   }
047
048   //---------------------------------------------------------------------------
049   public XMLNamespaceSet(int inInitialSize)
050   {
051      super(inInitialSize);
052   }
053
054   //---------------------------------------------------------------------------
055   public XMLNamespaceSet(Collection<XMLNamespace> inInitialValues)
056   {
057      super(inInitialValues);
058   }
059
060
061   //###########################################################################
062   // PUBLIC METHODS
063   //###########################################################################
064
065   //---------------------------------------------------------------------------
066   public XMLNamespaceSet setDefault(XMLNamespace inValue)
067   {
068      if (inValue != null
069          && ! contains(inValue))
070      {
071         add(inValue);
072      }
073/*
074      for (XMLNamespace namespace : this)
075      {
076         namespace.setIsDefault(namespace.equals(inValue));
077      }
078*/
079      mDefaultNamespace = inValue;
080
081      return this;
082   }
083
084   //---------------------------------------------------------------------------
085   public XMLNamespace getDefault()
086   {
087      return mDefaultNamespace;
088   }
089}