KickJava   Java API By Example, From Geeks To Geeks.

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


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/FrameSetTag.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/01/25 21:33:12 $
10
// $Revision: 1.36 $
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 java.util.Locale JavaDoc;
30
31 import org.htmlparser.Node;
32 import org.htmlparser.util.NodeList;
33 import org.htmlparser.util.SimpleNodeIterator;
34
35 /**
36  * Identifies an frame set tag.
37  */

38 public class FrameSetTag extends CompositeTag
39 {
40     /**
41      * The set of names handled by this tag.
42      */

43     private static final String JavaDoc[] mIds = new String JavaDoc[] {"FRAMESET"};
44
45     /**
46      * The set of end tag names that indicate the end of this tag.
47      */

48     private static final String JavaDoc[] mEndTagEnders = new String JavaDoc[] {"HTML"};
49
50     /**
51      * Create a new frame set tag.
52      */

53     public FrameSetTag ()
54     {
55     }
56
57     /**
58      * Return the set of names handled by this tag.
59      * @return The names to be matched that create tags of this type.
60      */

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

70     public String JavaDoc[] getEndTagEnders ()
71     {
72         return (mEndTagEnders);
73     }
74
75     /**
76      * Print the contents of the FrameSetTag
77      */

78     public String JavaDoc toString()
79     {
80         return "FRAMESET TAG : begins at : "+getStartPosition ()+"; ends at : "+getEndPosition ();
81     }
82
83     /**
84      * Returns the frames.
85      * @return The children of this tag.
86      */

87     public NodeList getFrames()
88     {
89         return (getChildren());
90     }
91
92     /**
93      * Gets a frame by name.
94      * Names are checked without case sensitivity and conversion to uppercase
95      * is performed with an English locale.
96      * @param name The name of the frame to retrieve.
97      * @return The specified frame or <code>null</code> if it wasn't found.
98      */

99     public FrameTag getFrame (String JavaDoc name)
100     {
101         return (getFrame (name, Locale.ENGLISH));
102     }
103
104     /**
105      * Gets a frame by name.
106      * Names are checked without case sensitivity and conversion to uppercase
107      * is performed with the locale provided.
108      * @param name The name of the frame to retrieve.
109      * @param locale The locale to use when converting to uppercase.
110      * @return The specified frame or <code>null</code> if it wasn't found.
111      */

112     public FrameTag getFrame (String JavaDoc name, Locale JavaDoc locale)
113     {
114         Node node;
115         FrameTag ret;
116
117         ret = null;
118         
119         name = name.toUpperCase (locale);
120         for (SimpleNodeIterator e = getFrames ().elements (); e.hasMoreNodes () && (null == ret); )
121         {
122             node = e.nextNode();
123             if (node instanceof FrameTag)
124             {
125                 ret = (FrameTag)node;
126                 if (!ret.getFrameName ().toUpperCase (locale).equals (name))
127                     ret = null;
128             }
129         }
130
131         return (ret);
132     }
133
134     /**
135      * Sets the frames (children of this tag).
136      * @param frames The frames to set
137      */

138     public void setFrames(NodeList frames)
139     {
140         setChildren (frames);
141     }
142 }
143
Popular Tags