Source Code Cross Referenced for WriterLogger.java in  » HTML-Parser » jericho-html » au » id » jericho » lib » html » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » HTML Parser » jericho html » au.id.jericho.lib.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Jericho HTML Parser - Java based library for analysing and manipulating HTML
002:        // Version 2.5
003:        // Copyright (C) 2007 Martin Jericho
004:        // http://jerichohtml.sourceforge.net/
005:        //
006:        // This library is free software; you can redistribute it and/or
007:        // modify it under the terms of either one of the following licences:
008:        //
009:        // 1. The Eclipse Public License (EPL) version 1.0,
010:        // included in this distribution in the file licence-epl-1.0.html
011:        // or available at http://www.eclipse.org/legal/epl-v10.html
012:        //
013:        // 2. The GNU Lesser General Public License (LGPL) version 2.1 or later,
014:        // included in this distribution in the file licence-lgpl-2.1.txt
015:        // or available at http://www.gnu.org/licenses/lgpl.txt
016:        //
017:        // This library is distributed on an "AS IS" basis,
018:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
019:        // See the individual licence texts for more details.
020:
021:        package au.id.jericho.lib.html;
022:
023:        import java.io.*;
024:
025:        /**
026:         * Provides an implementation of the {@link Logger} interface that sends output to the specified <code>java.io.Writer</code>.
027:         * <p>
028:         * Each log entry is formatted using the {@link BasicLogFormatter#format(String level, String message, String loggerName)} method.
029:         * <p>
030:         * Note that each <a href="Logger.html#LoggingLevel">logging level</a> can be enabled independently in this implementation.
031:         */
032:        public class WriterLogger implements  Logger {
033:            private final Writer writer;
034:            private final String name;
035:
036:            private boolean errorEnabled = true;
037:            private boolean warnEnabled = true;
038:            private boolean infoEnabled = true;
039:            private boolean debugEnabled = true;
040:
041:            /**
042:             * Constructs a new <code>WriterLogger</code> with the specified <code>Writer</code> and the default name.
043:             * <p>
044:             * The default logger name is "<code>net.htmlparser.jericho</code>".
045:             *
046:             * @param writer  the <code>Writer</code> to which all output is sent.
047:             */
048:            public WriterLogger(final Writer writer) {
049:                this (writer, Source.PACKAGE_NAME);
050:            }
051:
052:            /**
053:             * Constructs a new <code>WriterLogger</code> with the specified <code>Writer</code> and name.
054:             * <p>
055:             * The value of the <code>name</code> argument is only relevant if the {@link BasicLogFormatter#OutputName} static property is set to <code>true</code>,
056:             * otherwise the name is not included in the output at all.
057:             *
058:             * @param writer  the <code>Writer</code> to which all output is sent.
059:             * @param name  the logger name, may be <code>null</code>.
060:             */
061:            public WriterLogger(final Writer writer, final String name) {
062:                this .writer = writer;
063:                this .name = name;
064:            }
065:
066:            /**
067:             * Returns the <code>Writer</code> to which all output is sent.
068:             * @return the <code>Writer</code> to which all output is sent.
069:             */
070:            public Writer getWriter() {
071:                return writer;
072:            }
073:
074:            /**
075:             * Returns the name of this logger.
076:             * @return the name of this logger, may be <code>null</code>.
077:             */
078:            public String getName() {
079:                return name;
080:            }
081:
082:            // Documentation inherited from Logger
083:            public void error(final String message) {
084:                if (isErrorEnabled())
085:                    log("ERROR", message);
086:            }
087:
088:            // Documentation inherited from Logger
089:            public void warn(final String message) {
090:                if (isWarnEnabled())
091:                    log("WARN", message);
092:            }
093:
094:            // Documentation inherited from Logger
095:            public void info(final String message) {
096:                if (isInfoEnabled())
097:                    log("INFO", message);
098:            }
099:
100:            // Documentation inherited from Logger
101:            public void debug(final String message) {
102:                if (isDebugEnabled())
103:                    log("DEBUG", message);
104:            }
105:
106:            // Documentation inherited from Logger
107:            public boolean isErrorEnabled() {
108:                return errorEnabled;
109:            }
110:
111:            /**
112:             * Sets whether logging is enabled at the ERROR level.
113:             * @param errorEnabled  determines whether logging is enabled at the ERROR level.
114:             */
115:            public void setErrorEnabled(final boolean errorEnabled) {
116:                this .errorEnabled = errorEnabled;
117:            }
118:
119:            // Documentation inherited from Logger
120:            public boolean isWarnEnabled() {
121:                return warnEnabled;
122:            }
123:
124:            /**
125:             * Sets whether logging is enabled at the WARN level.
126:             * @param warnEnabled  determines whether logging is enabled at the WARN level.
127:             */
128:            public void setWarnEnabled(final boolean warnEnabled) {
129:                this .warnEnabled = warnEnabled;
130:            }
131:
132:            // Documentation inherited from Logger
133:            public boolean isInfoEnabled() {
134:                return infoEnabled;
135:            }
136:
137:            /**
138:             * Sets whether logging is enabled at the INFO level.
139:             * @param infoEnabled  determines whether logging is enabled at the INFO level.
140:             */
141:            public void setInfoEnabled(final boolean infoEnabled) {
142:                this .infoEnabled = infoEnabled;
143:            }
144:
145:            // Documentation inherited from Logger
146:            public boolean isDebugEnabled() {
147:                return debugEnabled;
148:            }
149:
150:            /**
151:             * Sets whether logging is enabled at the DEBUG level.
152:             * @param debugEnabled  determines whether logging is enabled at the DEBUG level.
153:             */
154:            public void setDebugEnabled(final boolean debugEnabled) {
155:                this .debugEnabled = debugEnabled;
156:            }
157:
158:            private void log(final String level, final String message) {
159:                try {
160:                    writer
161:                            .write(BasicLogFormatter.format(level, message,
162:                                    name));
163:                    writer.flush();
164:                } catch (IOException ex) {
165:                    throw new RuntimeException(ex);
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.