Source Code Cross Referenced for CrawlJobErrorHandler.java in  » Web-Crawler » heritrix » org » archive » crawler » admin » 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 » Web Crawler » heritrix » org.archive.crawler.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* CrawlJobErrorHandler
002:         *
003:         * $Id: CrawlJobErrorHandler.java 4666 2006-09-26 17:53:28Z paul_jack $
004:         *
005:         * Created on Apr 2, 2004
006:         *
007:         * Copyright (C) 2004 Internet Archive.
008:         *
009:         * This file is part of the Heritrix web crawler (crawler.archive.org).
010:         *
011:         * Heritrix is free software; you can redistribute it and/or modify
012:         * it under the terms of the GNU Lesser Public License as published by
013:         * the Free Software Foundation; either version 2.1 of the License, or
014:         * any later version.
015:         *
016:         * Heritrix is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
019:         * GNU Lesser Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser Public License
022:         * along with Heritrix; if not, write to the Free Software
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:         */
025:        package org.archive.crawler.admin;
026:
027:        import java.util.ArrayList;
028:        import java.util.HashMap;
029:        import java.util.List;
030:        import java.util.logging.Level;
031:
032:        import org.archive.crawler.settings.ValueErrorHandler;
033:        import org.archive.crawler.settings.Constraint.FailedCheck;
034:
035:        /**
036:         * An implementation of the ValueErrorHandler for the UI.
037:         *
038:         * <p>The UI uses this class to trap errors in the settings of it's jobs and
039:         * profiles and manage their presentation to the user.
040:         *
041:         * @author Kristinn Sigurdsson
042:         *
043:         * @see org.archive.crawler.settings.ValueErrorHandler
044:         */
045:        public class CrawlJobErrorHandler implements  ValueErrorHandler {
046:            /** All encountered errors */
047:            HashMap<String, FailedCheck> errors = null;
048:            Level level = Level.INFO;
049:            Level highestEncounteredLevel = Level.OFF;
050:
051:            public CrawlJobErrorHandler() {
052:                errors = new HashMap<String, FailedCheck>();
053:            }
054:
055:            public CrawlJobErrorHandler(Level level) {
056:                this ();
057:                this .level = level;
058:            }
059:
060:            public void handleValueError(FailedCheck error) {
061:                String key = error.getOwner().getAbsoluteName() + "/"
062:                        + error.getDefinition().getName();
063:                errors.put(key, error);
064:                if (error.getLevel().intValue() > highestEncounteredLevel
065:                        .intValue()) {
066:                    highestEncounteredLevel = error.getLevel();
067:                }
068:            }
069:
070:            /**
071:             * Get error for a specific attribute.
072:             *
073:             * <p>Uses currently set error level
074:             *
075:             * @param absoluteName The absolute name of the attribute
076:             * @return error for a specific attribute at or above current error
077:             *           level. null if no matching error is found.
078:             */
079:            public FailedCheck getError(String absoluteName) {
080:                return getError(absoluteName, level);
081:            }
082:
083:            /**
084:             * Get error for a specific attribute
085:             * 
086:             * @param absoluteName
087:             *            The absolute name of the attribute.
088:             * @param level
089:             *            Limit errors to those at this or higher level.
090:             * @return error for a specific attribute at or above specified error level.
091:             *         null if no matching error is found.
092:             */
093:            public FailedCheck getError(String absoluteName, Level level) {
094:                FailedCheck fc = (FailedCheck) errors.get(absoluteName);
095:                if (fc != null && fc.getLevel().intValue() >= level.intValue()) {
096:                    return fc;
097:                }
098:                return null;
099:            }
100:
101:            /**
102:             * Has there been an error with severity (level) equal to or higher then
103:             * this handlers set level.
104:             * @return has there ben an error.
105:             */
106:            public boolean hasError() {
107:                return hasError(level);
108:            }
109:
110:            /**
111:             * Has there been an error with severity (level) equal to or higher then
112:             * specified.
113:             * @param level The severity.
114:             * @return has there ben an error.
115:             */
116:            public boolean hasError(Level level) {
117:                return highestEncounteredLevel.intValue() >= level.intValue();
118:            }
119:
120:            /**
121:             * @return Returns the level.
122:             */
123:            public Level getLevel() {
124:                return level;
125:            }
126:
127:            /**
128:             * @param level The level to set.
129:             */
130:            public void setLevel(Level level) {
131:                this .level = level;
132:            }
133:
134:            /**
135:             * Reset handler.
136:             *
137:             * <p>Delets all encountered errors of any level.
138:             */
139:            public void clearErrors() {
140:                errors = new HashMap<String, FailedCheck>();
141:            }
142:
143:            /**
144:             * Get an List of all the encountered errors.
145:             *
146:             * <p>The List contains a set of
147:             * {@link org.archive.crawler.settings.Constraint.FailedCheck
148:             * FailedCheck} objects.
149:             *
150:             * @return an list of all encountered errors (with level equal to
151:             *         or higher then current level).
152:             *
153:             * @see org.archive.crawler.settings.Constraint.FailedCheck
154:             */
155:            public List getErrors() {
156:                return getErrors(level);
157:            }
158:
159:            /**
160:             * Get an List of all the encountered errors.
161:             *
162:             * <p>The List contains a set of
163:             * {@link org.archive.crawler.settings.Constraint.FailedCheck
164:             * FailedCheck} objects.
165:             *
166:             * @param level Get all errors of this level or higher
167:             *
168:             * @return an list of all encountered errors (with level equal to
169:             *         or higher then specified level).
170:             *
171:             * @see org.archive.crawler.settings.Constraint.FailedCheck
172:             */
173:            public List getErrors(Level level) {
174:                ArrayList<FailedCheck> list = new ArrayList<FailedCheck>(errors
175:                        .size());
176:                for (FailedCheck fc : errors.values()) {
177:                    if (fc.getLevel().intValue() >= level.intValue()) {
178:                        list.add(fc);
179:                    }
180:                }
181:                return list;
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.