KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > tags > StyleTag


1 // HTMLParser Library $Name: v1_5_20050313 $ - A java-based parser for HTML
2
// http://sourceforge.org/projects/htmlparser
3
// Copyright (C) 2004 Somik Raha
4
//
5
// Revision Control Information
6
//
7
// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/StyleTag.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/02/29 14:16:27 $
10
// $Revision: 1.35 $
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
//
26

27 package org.htmlparser.tags;
28
29 import org.htmlparser.scanners.StyleScanner;
30
31 /**
32  * A StyleTag represents a <style> tag.
33  */

34 public class StyleTag extends CompositeTag
35 {
36     /**
37      * The set of names handled by this tag.
38      */

39     private static final String JavaDoc[] mIds = new String JavaDoc[] {"STYLE"};
40
41     /**
42      * The set of end tag names that indicate the end of this tag.
43      */

44     private static final String JavaDoc[] mEndTagEnders = new String JavaDoc[] {"BODY", "HTML"};
45
46     /**
47      * Create a new style tag.
48      */

49     public StyleTag ()
50     {
51         setThisScanner (new StyleScanner ());
52     }
53
54     /**
55      * Return the set of names handled by this tag.
56      * @return The names to be matched that create tags of this type.
57      */

58     public String JavaDoc[] getIds ()
59     {
60         return (mIds);
61     }
62
63     /**
64      * Return the set of end tag names that cause this tag to finish.
65      * @return The names of following end tags that stop further scanning.
66      */

67     public String JavaDoc[] getEndTagEnders ()
68     {
69         return (mEndTagEnders);
70     }
71
72     /**
73      * Get the style data in this tag.
74      * @return The HTML of the children of this tag.
75      */

76     public String JavaDoc getStyleCode ()
77     {
78         return (getChildrenHTML ());
79     }
80
81     /**
82      * Print the contents of the style node.
83      * @return A string suitable for debugging or a printout.
84      */

85     public String JavaDoc toString()
86     {
87         String JavaDoc guts;
88         StringBuffer JavaDoc ret;
89         
90         ret = new StringBuffer JavaDoc ();
91
92         guts = toHtml ();
93         guts = guts.substring (1, guts.length () - 1);
94         ret.append ("Style node :\n");
95         ret.append (guts);
96         ret.append ("\n");
97
98         return (ret.toString ());
99     }
100 }
101
Popular Tags