Java Doc for PatternMatcherInput.java in  » Development » Jakarta-ORO » org » apache » oro » text » regex » 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 » Development » Jakarta ORO » org.apache.oro.text.regex 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.oro.text.regex.PatternMatcherInput

PatternMatcherInput
final public class PatternMatcherInput (Code)
The PatternMatcherInput class is used to preserve state across calls to the contains() methods of PatternMatcher instances. It is also used to specify that only a subregion of a string should be used as input when looking for a pattern match. All that is meant by preserving state is that the end offset of the last match is remembered, so that the next match is performed from that point where the last match left off. This offset can be accessed from the PatternMatcherInput.getCurrentOffset() method and can be set with the PatternMatcherInput.setCurrentOffset(int) method.

You would use a PatternMatcherInput object when you want to search for more than just the first occurrence of a pattern in a string, or when you only want to search a subregion of the string for a match. An example of its most common use is:

 PatternMatcher matcher;
 PatternCompiler compiler;
 Pattern pattern;
 PatternMatcherInput input;
 MatchResult result;
 compiler = new Perl5Compiler();
 matcher  = new Perl5Matcher();
 try {
 pattern = compiler.compile(somePatternString);
 } catch(MalformedPatternException e) {
 System.out.println("Bad pattern.");
 System.out.println(e.getMessage());
 return;
 }
 input   = new PatternMatcherInput(someStringInput);
 while(matcher.contains(input, pattern)) {
 result = matcher.getMatch();  
 // Perform whatever processing on the result you want.
 }
 // Suppose we want to start searching from the beginning again with
 // a different pattern.
 // Just set the current offset to the begin offset.
 input.setCurrentOffset(input.getBeginOffset());
 // Second search omitted
 // Suppose we're done with this input, but want to search another string.
 // There's no need to create another PatternMatcherInput instance.
 // We can just use the setInput() method.
 input.setInput(aNewInputString);
 

version:
   @version@
since:
   1.0
See Also:   PatternMatcher


Field Summary
 int_beginOffset_endOffset_currentOffset
    
 int_matchBeginOffset_matchEndOffset
    
 char[]_originalCharInput_originalBuffer_toLowerBuffer
    
 String_originalStringInput
    

Constructor Summary
public  PatternMatcherInput(String input, int begin, int length)
     Creates a PatternMatcherInput object, associating a region of a String as input to be used for pattern matching by PatternMatcher objects.
public  PatternMatcherInput(String input)
    
public  PatternMatcherInput(char[] input, int begin, int length)
     Creates a PatternMatcherInput object, associating a region of a string (represented as a char[]) as input to be used for pattern matching by PatternMatcher objects.
public  PatternMatcherInput(char[] input)
    

Method Summary
public  charcharAt(int offset)
     Returns the character at a particular offset relative to the begin offset of the input.


Parameters:
  offset - The offset at which to fetch a character (relative tothe beginning offset.

public  booleanendOfInput()
     Returns whether or not the end of the input has been reached.
public  intgetBeginOffset()
    
public  char[]getBuffer()
     Retrieves the char[] buffer to be used used as input by PatternMatcher implementations to look for matches.
public  intgetCurrentOffset()
    
public  intgetEndOffset()
     The offset of the input that should be considered the endof the region to be considered as input by PatternMatchermethods.
public  ObjectgetInput()
     Retrieves the original input used to initialize the PatternMatcherInput instance.
public  intgetMatchBeginOffset()
     Returns the offset marking the beginning of the match found by contains().
public  intgetMatchEndOffset()
     Returns the offset marking the end of the match found by contains().
public  intlength()
     The length of the region to be considered input for patternmatching purposes.
public  Stringmatch()
     A convenience method returning the part of the input corresponding to the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method.
public  StringpostMatch()
     A convenience method returning the part of the input occurring after the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method.
public  StringpreMatch()
     A convenience method returning the part of the input occurring before the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method.
public  voidsetBeginOffset(int offset)
     Sets the offset of the input that should be considered the start of the region to be considered as input by PatternMatcher methods.
public  voidsetCurrentOffset(int offset)
     Sets the offset of the input that should be considered the current offset where PatternMatcher methods should start looking for matches.
public  voidsetEndOffset(int offset)
     Sets the offset of the input that should be considered the end of the region to be considered as input by PatternMatcher methods.
public  voidsetInput(String input, int begin, int length)
     Associates a region of a String as input to be used for pattern matching by PatternMatcher objects.
public  voidsetInput(String input)
    
public  voidsetInput(char[] input, int begin, int length)
     Associates a region of a string (represented as a char[]) as input to be used for pattern matching by PatternMatcher objects.
public  voidsetInput(char[] input)
    
public  voidsetMatchOffsets(int matchBeginOffset, int matchEndOffset)
     This method is intended for use by PatternMatcher implementations. It is necessary to record the location of the previous match so that consecutive contains() matches involving null string matches are properly handled.
public  Stringsubstring(int beginOffset, int endOffset)
     Returns a new string that is a substring of the PatternMatcherInput instance.
public  Stringsubstring(int beginOffset)
     Returns a new string that is a substring of the PatternMatcherInput instance.
public  StringtoString()
     Returns the string representation of the input, where the input is considered to start from the begin offset and end at the end offset.

Field Detail
_beginOffset_endOffset_currentOffset
int _beginOffset_endOffset_currentOffset(Code)



_matchBeginOffset_matchEndOffset
int _matchBeginOffset_matchEndOffset(Code)



_originalCharInput_originalBuffer_toLowerBuffer
char[] _originalCharInput_originalBuffer_toLowerBuffer(Code)



_originalStringInput
String _originalStringInput(Code)




Constructor Detail
PatternMatcherInput
public PatternMatcherInput(String input, int begin, int length)(Code)
Creates a PatternMatcherInput object, associating a region of a String as input to be used for pattern matching by PatternMatcher objects. A copy of the string is not made, therefore you should not modify the string unless you know what you are doing. The current offset of the PatternMatcherInput is set to the begin offset of the region.


Parameters:
  input - The input to associate with the PatternMatcherInput.
Parameters:
  begin - The offset into the char[] to use as the beginning ofthe input.
Parameters:
  length - The length of the reegion starting from the begin offsetto use as the input for pattern matching purposes.




PatternMatcherInput
public PatternMatcherInput(String input)(Code)
Like calling
 PatternMatcherInput(input, 0, input.length());
 


Parameters:
  input - The input to associate with the PatternMatcherInput.




PatternMatcherInput
public PatternMatcherInput(char[] input, int begin, int length)(Code)
Creates a PatternMatcherInput object, associating a region of a string (represented as a char[]) as input to be used for pattern matching by PatternMatcher objects. A copy of the string is not made, therefore you should not modify the string unless you know what you are doing. The current offset of the PatternMatcherInput is set to the begin offset of the region.


Parameters:
  input - The input to associate with the PatternMatcherInput.
Parameters:
  begin - The offset into the char[] to use as the beginning ofthe input.
Parameters:
  length - The length of the reegion starting from the begin offsetto use as the input for pattern matching purposes.




PatternMatcherInput
public PatternMatcherInput(char[] input)(Code)
Like calling:
 PatternMatcherInput(input, 0, input.length);
 


Parameters:
  input - The input to associate with the PatternMatcherInput.





Method Detail
charAt
public char charAt(int offset)(Code)
Returns the character at a particular offset relative to the begin offset of the input.


Parameters:
  offset - The offset at which to fetch a character (relative tothe beginning offset. The character at a particular offset.
exception:
  ArrayIndexOutOfBoundsException - If the offset does not occurwithin the bounds of the input.




endOfInput
public boolean endOfInput()(Code)
Returns whether or not the end of the input has been reached.

True if the current offset is greater than or equal to theend offset.




getBeginOffset
public int getBeginOffset()(Code)
The offset of the input that should be considered the startof the region to be considered as input by PatternMatchermethods.



getBuffer
public char[] getBuffer()(Code)
Retrieves the char[] buffer to be used used as input by PatternMatcher implementations to look for matches. This array should be treated as read only by the programmer.

The char[] buffer to be used as input by PatternMatcherimplementations.




getCurrentOffset
public int getCurrentOffset()(Code)
The offset of the input that should be considered the currentoffset where PatternMatcher methods should start looking formatches.



getEndOffset
public int getEndOffset()(Code)
The offset of the input that should be considered the endof the region to be considered as input by PatternMatchermethods. This offset is actually 1 plus the last offsetthat is part of the input region.



getInput
public Object getInput()(Code)
Retrieves the original input used to initialize the PatternMatcherInput instance. If a String was used, the String instance will be returned. If a char[] was used, a char instance will be returned. This violates data encapsulation and hiding principles, but it is a great convenience for the programmer.

The String or char[] input used to initialize thePatternMatcherInput instance.




getMatchBeginOffset
public int getMatchBeginOffset()(Code)
Returns the offset marking the beginning of the match found by contains().

The begin offset of a contains() match.




getMatchEndOffset
public int getMatchEndOffset()(Code)
Returns the offset marking the end of the match found by contains().

The end offset of a contains() match.




length
public int length()(Code)
The length of the region to be considered input for patternmatching purposes. Essentially this is then end offset minusthe begin offset.



match
public String match()(Code)
A convenience method returning the part of the input corresponding to the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method. The method is not called getMatch() so as not to confuse it with Perl5Matcher's getMatch() which returns a MatchResult instance and also for consistency with preMatch() and postMatch().

The input consisting of the match found by contains().




postMatch
public String postMatch()(Code)
A convenience method returning the part of the input occurring after the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method.

The input succeeding a contains() match.




preMatch
public String preMatch()(Code)
A convenience method returning the part of the input occurring before the last match found by a call to a Perl5Matcher Perl5Matcher.contains contains method.

The input preceeding a match.




setBeginOffset
public void setBeginOffset(int offset)(Code)
Sets the offset of the input that should be considered the start of the region to be considered as input by PatternMatcher methods. In other words, everything before this offset is ignored by a PatternMatcher.


Parameters:
  offset - The offset to use as the beginning of the input.




setCurrentOffset
public void setCurrentOffset(int offset)(Code)
Sets the offset of the input that should be considered the current offset where PatternMatcher methods should start looking for matches. Also resets all match offset information to -1. By calling this method, you invalidate all previous match information. Therefore a PatternMatcher implementation must call this method before setting match offset information.


Parameters:
  offset - The offset to use as the current offset.




setEndOffset
public void setEndOffset(int offset)(Code)
Sets the offset of the input that should be considered the end of the region to be considered as input by PatternMatcher methods. This offset is actually 1 plus the last offset that is part of the input region.


Parameters:
  offset - The offset to use as the end of the input.




setInput
public void setInput(String input, int begin, int length)(Code)
Associates a region of a String as input to be used for pattern matching by PatternMatcher objects. The current offset of the PatternMatcherInput is set to the begin offset of the region.


Parameters:
  input - The input to associate with the PatternMatcherInput.
Parameters:
  begin - The offset into the String to use as the beginning ofthe input.
Parameters:
  length - The length of the reegion starting from the begin offsetto use as the input for pattern matching purposes.




setInput
public void setInput(String input)(Code)
This method is identical to calling:
 setInput(input, 0, input.length());
 


Parameters:
  input - The input to associate with the PatternMatcherInput.




setInput
public void setInput(char[] input, int begin, int length)(Code)
Associates a region of a string (represented as a char[]) as input to be used for pattern matching by PatternMatcher objects. A copy of the string is not made, therefore you should not modify the string unless you know what you are doing. The current offset of the PatternMatcherInput is set to the begin offset of the region.


Parameters:
  input - The input to associate with the PatternMatcherInput.
Parameters:
  begin - The offset into the char[] to use as the beginning ofthe input.
Parameters:
  length - The length of the reegion starting from the begin offsetto use as the input for pattern matching purposes.




setInput
public void setInput(char[] input)(Code)
This method is identical to calling:
 setInput(input, 0, input.length);
 


Parameters:
  input - The input to associate with the PatternMatcherInput.




setMatchOffsets
public void setMatchOffsets(int matchBeginOffset, int matchEndOffset)(Code)
This method is intended for use by PatternMatcher implementations. It is necessary to record the location of the previous match so that consecutive contains() matches involving null string matches are properly handled. If you are not implementing a PatternMatcher, forget this method exists. If you use it outside of its intended context, you will only disrupt the stored state.

As a note, the preMatch(), postMatch(), and match() methods are provided as conveniences because PatternMatcherInput must store match offset information to completely preserve state for consecutive PatternMatcher contains() matches.


Parameters:
  matchBeginOffset - The begin offset of a match found by contains().
Parameters:
  matchEndOffset - The end offset of a match found by contains().




substring
public String substring(int beginOffset, int endOffset)(Code)
Returns a new string that is a substring of the PatternMatcherInput instance. The substring begins at the specified beginOffset relative to the begin offset and extends to the specified endOffset - 1 relative to the begin offset of the PatternMatcherInput instance.


Parameters:
  beginOffset - The offset relative to the begin offset of thePatternMatcherInput at which to start the substring (inclusive).
Parameters:
  endOffset - The offset relative to the begin offset of thePatternMatcherInput at which to end the substring (exclusive). The specified substring.
exception:
  ArrayIndexOutOfBoundsException - If one of the offsets doesnot occur within the bounds of the input.




substring
public String substring(int beginOffset)(Code)
Returns a new string that is a substring of the PatternMatcherInput instance. The substring begins at the specified beginOffset relative to the begin offset and extends to the end offset of the PatternMatcherInput.


Parameters:
  beginOffset - The offset relative to the begin offset of thePatternMatcherInput at which to start the substring. The specified substring.
exception:
  ArrayIndexOutOfBoundsException - If the offset does not occurwithin the bounds of the input.




toString
public String toString()(Code)
Returns the string representation of the input, where the input is considered to start from the begin offset and end at the end offset.

The string representation of the input.




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.