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


001:        /* MatchesRegExpDecideRule
002:         *
003:         * $Id: MatchesRegExpDecideRule.java 4649 2006-09-25 17:16:55Z paul_jack $
004:         *
005:         * Created on Apr 4, 2005
006:         *
007:         * Copyright (C) 2005 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.deciderules;
026:
027:        import java.util.logging.Level;
028:        import java.util.logging.Logger;
029:
030:        import javax.management.AttributeNotFoundException;
031:
032:        import org.archive.crawler.settings.SimpleType;
033:        import org.archive.util.TextUtils;
034:
035:        /**
036:         * Rule applies configured decision to any CrawlURIs whose String URI
037:         * matches the supplied regexp.
038:         *
039:         * @author gojomo
040:         */
041:        public class MatchesRegExpDecideRule extends PredicatedDecideRule {
042:
043:            private static final long serialVersionUID = 6441410917074319295L;
044:
045:            private static final Logger logger = Logger
046:                    .getLogger(MatchesRegExpDecideRule.class.getName());
047:
048:            public static final String ATTR_REGEXP = "regexp";
049:
050:            /**
051:             * Usual constructor. 
052:             * @param name
053:             */
054:            public MatchesRegExpDecideRule(String name) {
055:                super (name);
056:                setDescription("MatchesRegExpDecideRule. Applies the configured "
057:                        + "decision to URIs matching the supplied regular expression.");
058:                addElementToDefinition(new SimpleType(ATTR_REGEXP,
059:                        "Java regular" + "expression to match.", ""));
060:            }
061:
062:            /**
063:             * Evaluate whether given object's string version
064:             * matches configured regexp
065:             * 
066:             * @param object
067:             * @return true if regexp is matched
068:             */
069:            protected boolean evaluate(Object object) {
070:                try {
071:                    String regexp = getRegexp(object);
072:                    String str = object.toString();
073:                    boolean result = (regexp == null) ? false : TextUtils
074:                            .matches(regexp, str);
075:                    if (logger.isLoggable(Level.FINE)) {
076:                        logger.fine("Tested '" + str + "' match with regex '"
077:                                + regexp + " and result was " + result);
078:                    }
079:                    return result;
080:                } catch (ClassCastException e) {
081:                    // if not CrawlURI, always disregard
082:                    return false;
083:                }
084:            }
085:
086:            /** 
087:             * Get the regular expression string to match the URI against.
088:             *
089:             * @param o the object for which the regular expression should be
090:             *          matched against.
091:             * @return the regular expression to match against.
092:             */
093:            protected String getRegexp(Object o) {
094:                try {
095:                    return (String) getAttribute(o, ATTR_REGEXP);
096:                } catch (AttributeNotFoundException e) {
097:                    logger.severe(e.getMessage());
098:                    return null; // Basically the filter is inactive if this occurs.
099:                }
100:            }
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.