001package com.hfg.xml.creativecommons;
002
003
004
005import com.hfg.util.collection.CollectionUtil;
006import com.hfg.xml.XMLAttribute;
007import com.hfg.xml.XMLTag;
008import com.hfg.xml.dublincore.DublinCore;
009
010import java.util.List;
011
012//------------------------------------------------------------------------------
013/**
014 Object representation of the Creative Commons 'Work' tag.
015 <p>
016 See <a href='http://creativecommons.org/ns'>http://creativecommons.org/ns</a>
017 </p>
018 @author J. Alex Taylor, hairyfatguy.com
019 */
020//------------------------------------------------------------------------------
021// com.hfg XML/HTML Coding Library
022//
023// This library is free software; you can redistribute it and/or
024// modify it under the terms of the GNU Lesser General Public
025// License as published by the Free Software Foundation; either
026// version 2.1 of the License, or (at your option) any later version.
027//
028// This library is distributed in the hope that it will be useful,
029// but WITHOUT ANY WARRANTY; without even the implied warranty of
030// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
031// Lesser General Public License for more details.
032//
033// You should have received a copy of the GNU Lesser General Public
034// License along with this library; if not, write to the Free Software
035// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
036//
037// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
038// jataylor@hairyfatguy.com
039//------------------------------------------------------------------------------
040
041public class CreativeCommons_Work extends XMLTag
042{
043   //##########################################################################
044   // CONSTRUCTORS
045   //##########################################################################
046
047   //---------------------------------------------------------------------------
048   public CreativeCommons_Work()
049   {
050      super(CreativeCommons.WORK);
051   }
052
053   //---------------------------------------------------------------------------
054   public CreativeCommons_Work(XMLTag inXMLTag)
055   {
056      this();
057
058      inXMLTag.verifyTagName(CreativeCommons.WORK);
059
060
061      if (CollectionUtil.hasValues(inXMLTag.getAttributes()))
062      {
063         for (XMLAttribute attr : inXMLTag.getAttributes())
064         {
065            setAttribute(attr.clone());
066         }
067      }
068
069      List subtagsAndContent = inXMLTag.getContentPlusSubtagList();
070      if (CollectionUtil.hasValues(subtagsAndContent))
071      {
072         for (Object object : subtagsAndContent)
073         {
074            if (object instanceof XMLTag)
075            {
076               XMLTag subtag = (XMLTag) object;
077               if (subtag.getNamespace().equals(DublinCore.DUBLIN_CORE_NAMESPACE))
078               {
079                  addSubtag(DublinCore.constructFromXMLTag(subtag));
080               }
081               else
082               {
083                  addSubtag(subtag);
084               }
085            }
086            else
087            {
088               addContent((String)object);
089            }
090         }
091      }
092
093   }
094
095   //##########################################################################
096   // PUBLIC METHODS
097   //##########################################################################
098
099
100}