KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > test > SimpleHtmlParserContext


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21
22 package org.lobobrowser.html.test;
23
24 import org.lobobrowser.html.*;
25
26 import java.util.logging.*;
27
28 /**
29  * The <code>SimpleHtmlParserContext</code> is a simple implementation
30  * of the {@link org.lobobrowser.html.HtmlParserContext} interface. Methods
31  * in this class should be overridden to provide functionality
32  * such as cookies.
33  * @author J. H. S.
34  */

35 public class SimpleHtmlParserContext implements HtmlParserContext {
36     private static final Logger logger = Logger.getLogger(SimpleHtmlParserContext.class.getName());
37     
38     public SimpleHtmlParserContext() {
39         super();
40     }
41
42     public String JavaDoc getCookie() {
43         return "";
44     }
45     
46     public void setCookie(String JavaDoc cookie) {
47         this.warn("setCookie(): Not overridden");
48     }
49     
50     public void warn(String JavaDoc message, Throwable JavaDoc throwable) {
51         if(logger.isLoggable(Level.WARNING)) {
52             logger.log(Level.WARNING, message, throwable);
53         }
54     }
55     
56     public void error(String JavaDoc message, Throwable JavaDoc throwable) {
57         if(logger.isLoggable(Level.SEVERE)) {
58             logger.log(Level.SEVERE, message, throwable);
59         }
60     }
61     
62     public void warn(String JavaDoc message) {
63         if(logger.isLoggable(Level.WARNING)) {
64             logger.log(Level.WARNING, message);
65         }
66     }
67     
68     public void error(String JavaDoc message) {
69         if(logger.isLoggable(Level.SEVERE)) {
70             logger.log(Level.SEVERE, message);
71         }
72     }
73     
74     private UserAgentContext bcontext = null;
75     
76     public UserAgentContext getUserAgentContext() {
77         this.warn("getUserAgentContext(): Not overridden; returning simple one.");
78         synchronized(this) {
79             if(this.bcontext == null) {
80                 this.bcontext = new SimpleUserAgentContext();
81             }
82             return this.bcontext;
83         }
84     }
85 }
86
87
Popular Tags