001package com.hfg.html;
002
003
004import com.hfg.css.CSSRule;
005import com.hfg.util.mime.MimeType;
006import com.hfg.xml.XMLNode;
007
008//------------------------------------------------------------------------------
009/**
010 * Represents an HTML style (<style>) 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 StyleTag extends HTMLTag
036{
037
038   //##########################################################################
039   // PRIVATE FIELDS
040   //##########################################################################
041
042
043   //##########################################################################
044   // CONSTRUCTORS
045   //##########################################################################
046
047   //--------------------------------------------------------------------------
048   public StyleTag()
049   {
050      super(HTML.STYLE);
051      setTypeCSS();
052   }
053
054   //--------------------------------------------------------------------------
055   public StyleTag(String inContent)
056   {
057      this();
058      addContentWithoutEscaping(inContent);
059   }
060
061   //--------------------------------------------------------------------------
062   public StyleTag(XMLNode inXMLNode)
063   {
064      super(HTML.STYLE);
065      initFromXMLNode(inXMLNode);
066   }
067
068   //##########################################################################
069   // PUBLIC METHODS
070   //##########################################################################
071
072
073   //--------------------------------------------------------------------------
074   public StyleTag setTypeCSS()
075   {
076      return setType(MimeType.TEXT_CSS);
077   }
078
079
080   //--------------------------------------------------------------------------
081   public StyleTag setType(MimeType inValue)
082   {
083      setAttribute(HTML.TYPE, inValue);
084
085      return this;
086   }
087
088
089   //--------------------------------------------------------------------------
090   public StyleTag setScoped()
091   {
092      setAttribute(HTML.SCOPED, true);
093      return this;
094   }
095
096
097   //--------------------------------------------------------------------------
098   public StyleTag addRule(CSSRule inValue)
099   {
100      addContent(inValue.toString() + "\n");
101      return this;
102   }
103
104}