Source Code Cross Referenced for PatternHandler.java in  » Parser » JTopas » de » susebox » jtopas » spi » 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 » Parser » JTopas » de.susebox.jtopas.spi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * PatternHandler.java: Interface for pattern-aware tokenizers.
003:         *
004:         * Copyright (C) 2002 Heiko Blau
005:         *
006:         * This file belongs to the JTopas Library.
007:         * JTopas is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU Lesser General Public License as published by the 
009:         * Free Software Foundation; either version 2.1 of the License, or (at your 
010:         * option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful, but WITHOUT
013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
014:         * FITNESS FOR A PARTICULAR PURPOSE. 
015:         * See the GNU Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public License along
018:         * with JTopas. If not, write to the
019:         *
020:         *   Free Software Foundation, Inc.
021:         *   59 Temple Place, Suite 330, 
022:         *   Boston, MA 02111-1307 
023:         *   USA
024:         *
025:         * or check the Internet: http://www.fsf.org
026:         *
027:         * Contact:
028:         *   email: heiko@susebox.de 
029:         */
030:
031:        package de.susebox.jtopas.spi;
032:
033:        //-----------------------------------------------------------------------------
034:        // Imports
035:        //
036:        import de.susebox.jtopas.TokenizerProperty;
037:        import de.susebox.jtopas.TokenizerException;
038:
039:        //-----------------------------------------------------------------------------
040:        // Interface PatternHandler
041:        //
042:
043:        /**<p>
044:         * This interface must be implemented by classes that should be used as a 
045:         * pattern handler for a {@link de.susebox.jtopas.Tokenizer}. Pattern are usually
046:         * regular expressions that are applied on token images to check if that image 
047:         * matches the pattern.
048:         *</p>
049:         *
050:         * @see     de.susebox.jtopas.Tokenizer
051:         * @see     de.susebox.jtopas.TokenizerProperties
052:         * @see     de.susebox.jtopas.spi.DataMapper
053:         * @author  Heiko Blau
054:         */
055:        public interface PatternHandler {
056:
057:            /**
058:             * This method can be used by a {@link de.susebox.jtopas.Tokenizer} implementation 
059:             * for a fast detection if pattern matching must be performed at all. If the method
060:             * returns <code>false</code> time-consuming preparations can be skipped.
061:             *
062:             * @return  <code>true</code> if there actually are pattern that can be tested
063:             *          for a match, <code>false</code> otherwise.
064:             */
065:            public boolean hasPattern();
066:
067:            /**
068:             * This method checks if the start of a character range given through the 
069:             * {@link DataProvider} matches a pattern. An implementation should use
070:             * a {@link de.susebox.jtopas.TokenizerException} to report problems.
071:             *<br>
072:             * The method returns <code>null</code> if the beginning of the character range
073:             * doesn't match a pattern known to the <code>PatternHandler</code>. Otherwise
074:             * it returns an object with the implemented interface {@link PatternHandler.Result}.
075:             *<br>
076:             * The pattern check is repeated if the method returns a match that is exactly
077:             * as long as the given data range and more data is available. Since it is 
078:             * probably a rare case, that where are not enough data to find a complete or 
079:             * no match, the overhead of a repeated check on part of the data is neglected.
080:             *<br>
081:             * If a pattern handler has more than one pattern that could be applied to the
082:             * given data, it should return the longest possible match.
083:             *
084:             * @param   dataProvider    the source to get the data from
085:             * @param   lengthOfMatch   if a match is found, the method places the length of
086:             *                          it into the first element of this array
087:             * @return  a {@link PatternHandler.Result} object or <code>null</code> if no
088:             *          match was found
089:             * @throws  TokenizerException    generic exception
090:             * @throws  NullPointerException  if no {@link DataProvider} is given
091:             */
092:            public PatternHandler.Result matches(DataProvider dataProvider)
093:                    throws TokenizerException, NullPointerException;
094:
095:            //---------------------------------------------------------------------------
096:            // Inner Interfaces
097:            //
098:
099:            /**
100:             * An inner interface for the pattern match result.
101:             */
102:            public static interface Result {
103:
104:                /**
105:                 * Returns the {@link TokenizerProperty} that describes the pattern that 
106:                 * matches data passed to {@link PatternHandler#matches}. The returned value
107:                 * is <strong>not</strong> <code>null</code>.
108:                 *
109:                 * @return the pattern property of a successful match
110:                 */
111:                public TokenizerProperty getProperty();
112:
113:                /**
114:                 * Returns the number of characters that are part of a match.
115:                 *
116:                 * @return length of match
117:                 */
118:                public int getLengthOfMatch();
119:
120:                /**
121:                 * Returns the capturing groups of a match. It is used if the calling tokenizer 
122:                 * needs these groups (e. g. if the flag {@link de.susebox.jtopas.TokenizerProperties#F_RETURN_IMAGE_PARTS}   
123:                 * is set).
124:                 *<br>
125:                 * The return value must not be null or empty. The first element (array index 0) 
126:                 * must contain the whole pattern match (as described in the Java 1.4
127:                 * documentation for {@link java.util.regex.Matcher} or the newer Java 1.5 
128:                 * {@link java.util.regex.MatchResult}).
129:                 *
130:                 * @return  the capturing groups of the last pattern match in {@link #matches}.
131:                 */
132:                public String[] getGroups() throws TokenizerException;
133:            }
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.