KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > RemarkNode


1 // $Header: /home/cvs/jakarta-jmeter/src/htmlparser/org/htmlparser/RemarkNode.java,v 1.2.2.1 2004/10/24 01:22:59 sebb Exp $
2
/*
3  * ====================================================================
4  * Copyright 2002-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */

19
20 // The developers of JMeter and Apache are greatful to the developers
21
// of HTMLParser for giving Apache Software Foundation a non-exclusive
22
// license. The performance benefits of HTMLParser are clear and the
23
// users of JMeter will benefit from the hard work the HTMLParser
24
// team. For detailed information about HTMLParser, the project is
25
// hosted on sourceforge at http://htmlparser.sourceforge.net/.
26
//
27
// HTMLParser was originally created by Somik Raha in 2000. Since then
28
// a healthy community of users has formed and helped refine the
29
// design so that it is able to tackle the difficult task of parsing
30
// dirty HTML. Derrick Oswald is the current lead developer and was kind
31
// enough to assist JMeter.
32

33
34 package org.htmlparser;
35
36 import org.htmlparser.util.NodeList;
37 import org.htmlparser.visitors.NodeVisitor;
38
39 /**
40  * The remark tag is identified and represented by this class.
41  */

42 public class RemarkNode extends Node
43 {
44     public final static String JavaDoc REMARK_NODE_FILTER = "-r";
45
46     /**
47      * Tag contents will have the contents of the comment tag.
48          */

49     String JavaDoc tagContents;
50     /**
51      * The HTMLRemarkTag is constructed by providing the beginning posn, ending posn
52      * and the tag contents.
53      * @param nodeBegin beginning position of the tag
54      * @param nodeEnd ending position of the tag
55      * @param tagContents contents of the remark tag
56      * @param tagLine The current line being parsed, where the tag was found
57      */

58     public RemarkNode(int tagBegin, int tagEnd, String JavaDoc tagContents)
59     {
60         super(tagBegin, tagEnd);
61         this.tagContents = tagContents;
62     }
63
64     /**
65      * Returns the text contents of the comment tag.
66      */

67     public String JavaDoc getText()
68     {
69         return tagContents;
70     }
71     public String JavaDoc toPlainTextString()
72     {
73         return tagContents;
74     }
75     public String JavaDoc toHtml()
76     {
77         return "<!--" + tagContents + "-->";
78     }
79     /**
80      * Print the contents of the remark tag.
81      */

82     public String JavaDoc toString()
83     {
84         return "Comment Tag : "
85             + tagContents
86             + "; begins at : "
87             + elementBegin()
88             + "; ends at : "
89             + elementEnd()
90             + "\n";
91     }
92
93     public void collectInto(NodeList collectionList, String JavaDoc filter)
94     {
95         if (filter.equals(REMARK_NODE_FILTER))
96             collectionList.add(this);
97     }
98
99     public void accept(NodeVisitor visitor)
100     {
101         visitor.visitRemarkNode(this);
102     }
103
104 }
105
Popular Tags