Java Doc for AwkMatcher.java in  » Library » jakarta-oro-2.0.8 » org » apache » oro » text » awk » 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 » Library » jakarta oro 2.0.8 » org.apache.oro.text.awk 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.oro.text.awk.AwkMatcher

AwkMatcher
final public class AwkMatcher implements PatternMatcher(Code)
The AwkMatcher class is used to match regular expressions (conforming to the Awk regular expression syntax) generated by AwkCompiler. AwkMatcher only supports 8-bit ASCII. Any attempt to match Unicode values greater than 255 will result in undefined behavior. AwkMatcher finds true leftmost-longest matches, so you must take care with how you formulate your regular expression to avoid matching more than you really want.

It is important for you to remember that AwkMatcher does not save parenthesized sub-group information. Therefore the number of groups saved in a MatchResult produced by AwkMatcher will always be 1.
version:
   @version@
since:
   1.0
See Also:   org.apache.oro.text.regex.PatternMatcher
See Also:   AwkCompiler




Constructor Summary
public  AwkMatcher()
    

Method Summary
 void_search()
    
public  booleancontains(char[] input, Pattern pattern)
     Determines if a string (represented as a char[]) contains a pattern. If the pattern is matched by some substring of the input, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() .
public  booleancontains(String input, Pattern pattern)
     Determines if a string contains a pattern.
public  booleancontains(PatternMatcherInput input, Pattern pattern)
     Determines if the contents of a PatternMatcherInput, starting from the current offset of the input contains a pattern. If a pattern match is found, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() .
public  booleancontains(AwkStreamInput input, Pattern pattern)
     Determines if the contents of an AwkStreamInput, starting from the current offset of the input contains a pattern. If a pattern match is found, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() .
public  MatchResultgetMatch()
     Fetches the last match found by a call to a matches() or contains() method.

A MatchResult instance containing the pattern match foundby the last call to any one of the matches() or contains()methods.

public  booleanmatches(char[] input, Pattern pattern)
     Determines if a string (represented as a char[]) exactly matches a given pattern.
public  booleanmatches(String input, Pattern pattern)
     Determines if a string exactly matches a given pattern.
public  booleanmatches(PatternMatcherInput input, Pattern pattern)
     Determines if the contents of a PatternMatcherInput instance exactly matches a given pattern.
public  booleanmatchesPrefix(char[] input, Pattern pattern, int offset)
     Determines if a prefix of a string (represented as a char[]) matches a given pattern, starting from a given offset into the string. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The char[] to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched.
Parameters:
  offset - The offset at which to start searching for the prefix.

public  booleanmatchesPrefix(char[] input, Pattern pattern)
     Determines if a prefix of a string (represented as a char[]) matches a given pattern. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The char[] to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched.

public  booleanmatchesPrefix(String input, Pattern pattern)
     Determines if a prefix of a string matches a given pattern. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The String to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched.

public  booleanmatchesPrefix(PatternMatcherInput input, Pattern pattern)
     Determines if a prefix of a PatternMatcherInput instance matches a given pattern.


Constructor Detail
AwkMatcher
public AwkMatcher()(Code)




Method Detail
_search
void _search() throws IOException(Code)



contains
public boolean contains(char[] input, Pattern pattern)(Code)
Determines if a string (represented as a char[]) contains a pattern. If the pattern is matched by some substring of the input, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() . If you want to access subsequent matches you should either use a PatternMatcherInput object or use the offset information in the MatchResult to create a substring representing the remaining input. Using the MatchResult offset information is the recommended method of obtaining the parts of the string preceeding the match and following the match.

The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.


Parameters:
  input - The char[] to test for a match.
Parameters:
  pattern - The AwkPattern to be matched. True if the input contains a pattern match, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




contains
public boolean contains(String input, Pattern pattern)(Code)
Determines if a string contains a pattern. If the pattern is matched by some substring of the input, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() . If you want to access subsequent matches you should either use a PatternMatcherInput object or use the offset information in the MatchResult to create a substring representing the remaining input. Using the MatchResult offset information is the recommended method of obtaining the parts of the string preceeding the match and following the match.

The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.


Parameters:
  input - The String to test for a match.
Parameters:
  pattern - The AwkPattern to be matched. True if the input contains a pattern match, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




contains
public boolean contains(PatternMatcherInput input, Pattern pattern)(Code)
Determines if the contents of a PatternMatcherInput, starting from the current offset of the input contains a pattern. If a pattern match is found, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() . The current offset of the PatternMatcherInput is set to the offset corresponding to the end of the match, so that a subsequent call to this method will continue searching where the last call left off. You should remember that the region between the begin and end offsets of the PatternMatcherInput are considered the input to be searched, and that the current offset of the PatternMatcherInput reflects where a search will start from. Matches extending beyond the end offset of the PatternMatcherInput will not be matched. In other words, a match must occur entirely between the begin and end offsets of the input. See org.apache.oro.text.regex.PatternMatcherInput PatternMatcherInput for more details.

As a side effect, if a match is found, the PatternMatcherInput match offset information is updated. See the PatternMatcherInput org.apache.oro.text.regex.PatternMatcherInput.setMatchOffsetssetMatchOffsets(int, int) method for more details.

The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.

This method is usually used in a loop as follows:

 PatternMatcher matcher;
 PatternCompiler compiler;
 Pattern pattern;
 PatternMatcherInput input;
 MatchResult result;
 compiler = new AwkCompiler();
 matcher  = new AwkMatcher();
 try {
 pattern = compiler.compile(somePatternString);
 } catch(MalformedPatternException e) {
 System.err.println("Bad pattern.");
 System.err.println(e.getMessage());
 return;
 }
 input   = new PatternMatcherInput(someStringInput);
 while(matcher.contains(input, pattern)) {
 result = matcher.getMatch();  
 // Perform whatever processing on the result you want.
 }
 


Parameters:
  input - The PatternMatcherInput to test for a match.
Parameters:
  pattern - The Pattern to be matched. True if the input contains a pattern match, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




contains
public boolean contains(AwkStreamInput input, Pattern pattern) throws IOException(Code)
Determines if the contents of an AwkStreamInput, starting from the current offset of the input contains a pattern. If a pattern match is found, a MatchResult instance representing the first such match is made acessible via AwkMatcher.getMatch() . The current offset of the input stream is advanced to the end offset corresponding to the end of the match. Consequently a subsequent call to this method will continue searching where the last call left off. See AwkStreamInput for more details.

Note, patterns matching the null string do NOT match at end of input stream. This is different from the behavior you get from the other contains() methods.

The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.

This method is usually used in a loop as follows:

 PatternMatcher matcher;
 PatternCompiler compiler;
 Pattern pattern;
 AwkStreamInput input;
 MatchResult result;
 compiler = new AwkCompiler();
 matcher  = new AwkMatcher();
 try {
 pattern = compiler.compile(somePatternString);
 } catch(MalformedPatternException e) {
 System.err.println("Bad pattern.");
 System.err.println(e.getMessage());
 return;
 }
 input   = new AwkStreamInput(
 new BufferedInputStream(new FileInputStream(someFileName)));
 while(matcher.contains(input, pattern)) {
 result = matcher.getMatch();  
 // Perform whatever processing on the result you want.
 }
 


Parameters:
  input - The PatternStreamInput to test for a match.
Parameters:
  pattern - The Pattern to be matched. True if the input contains a pattern match, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




getMatch
public MatchResult getMatch()(Code)
Fetches the last match found by a call to a matches() or contains() method.

A MatchResult instance containing the pattern match foundby the last call to any one of the matches() or contains()methods. If no match was found by the last call, returnsnull.




matches
public boolean matches(char[] input, Pattern pattern)(Code)
Determines if a string (represented as a char[]) exactly matches a given pattern. If there is an exact match, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() . The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.


Parameters:
  input - The char[] to test for an exact match.
Parameters:
  pattern - The AwkPattern to be matched. True if input matches pattern, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




matches
public boolean matches(String input, Pattern pattern)(Code)
Determines if a string exactly matches a given pattern. If there is an exact match, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() . The pattern must be a AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.


Parameters:
  input - The String to test for an exact match.
Parameters:
  pattern - The AwkPattern to be matched. True if input matches pattern, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




matches
public boolean matches(PatternMatcherInput input, Pattern pattern)(Code)
Determines if the contents of a PatternMatcherInput instance exactly matches a given pattern. If there is an exact match, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() . Unlike the AwkMatcher.contains(PatternMatcherInput,Pattern) method, the current offset of the PatternMatcherInput argument is not updated. You should remember that the region between the begin and end offsets of the PatternMatcherInput will be tested for an exact match.

The pattern must be an AwkPattern instance, otherwise a ClassCastException will be thrown. You are not required to, and indeed should NOT try to (for performance reasons), catch a ClassCastException because it will never be thrown as long as you use an AwkPattern as the pattern parameter.


Parameters:
  input - The PatternMatcherInput to test for a match.
Parameters:
  pattern - The AwkPattern to be matched. True if input matches pattern, false otherwise.
exception:
  ClassCastException - If a Pattern instance other than anAwkPattern is passed as the pattern parameter.




matchesPrefix
public boolean matchesPrefix(char[] input, Pattern pattern, int offset)(Code)
Determines if a prefix of a string (represented as a char[]) matches a given pattern, starting from a given offset into the string. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The char[] to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched.
Parameters:
  offset - The offset at which to start searching for the prefix. True if input matches pattern, false otherwise.




matchesPrefix
public boolean matchesPrefix(char[] input, Pattern pattern)(Code)
Determines if a prefix of a string (represented as a char[]) matches a given pattern. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The char[] to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched. True if input matches pattern, false otherwise.




matchesPrefix
public boolean matchesPrefix(String input, Pattern pattern)(Code)
Determines if a prefix of a string matches a given pattern. If a prefix of the string matches the pattern, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() .

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The String to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched. True if input matches pattern, false otherwise.




matchesPrefix
public boolean matchesPrefix(PatternMatcherInput input, Pattern pattern)(Code)
Determines if a prefix of a PatternMatcherInput instance matches a given pattern. If there is a match, a MatchResult instance representing the match is made accesible via AwkMatcher.getMatch() . Unlike the AwkMatcher.contains(PatternMatcherInput,Pattern) method, the current offset of the PatternMatcherInput argument is not updated. You should remember that the region starting from the begin offset of the PatternMatcherInput will be tested for a prefix match.

This method is useful for certain common token identification tasks that are made more difficult without this functionality.


Parameters:
  input - The PatternMatcherInput to test for a prefix match.
Parameters:
  pattern - The Pattern to be matched. True if input matches pattern, false otherwise.




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.