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


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

Util
final public class Util (Code)
The Util class is a holder for useful static utility methods that can be generically applied to Pattern and PatternMatcher instances. This class cannot and is not meant to be instantiated. The Util class currently contains versions of the split() and substitute() methods inspired by Perl's split function and s operation respectively, although they are implemented in such a way as not to rely on the Perl5 implementations of the OROMatcher packages regular expression interfaces. They may operate on any interface implementations conforming to the OROMatcher API specification for the PatternMatcher, Pattern, and MatchResult interfaces. Future versions of the class may include additional utility methods.

A grep method is not included for two reasons:

  1. The details of reading a line at a time from an input stream differ in JDK 1.0.2 and JDK 1.1, making it difficult to retain compatibility across both Java releases.
  2. Grep style processing is trivial for the programmer to implement in a while loop. Rarely does anyone want to retrieve all occurences of a pattern and then process them. More often a programmer will retrieve pattern matches and process them as they are retrieved, which is more efficient than storing them all in a Vector and then accessing them.

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


Field Summary
final public static  intSPLIT_ALL
     A constant passed to the Util.split split() methods indicating that all occurrences of a pattern should be used to split a string.
final public static  intSUBSTITUTE_ALL
     A constant passed to the Util.substitute substitute() methods indicating that all occurrences of a pattern should be substituted.


Method Summary
public static  voidsplit(Collection results, PatternMatcher matcher, Pattern pattern, String input, int limit)
     Splits up a String instance and stores results as a List of substrings numbering no more than a specified limit.
public static  voidsplit(Collection results, PatternMatcher matcher, Pattern pattern, String input)
     Splits up a String instance and stores results as a Collection of all its substrings using a regular expression as the delimiter. This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern.
public static  Vectorsplit(PatternMatcher matcher, Pattern pattern, String input, int limit)
     Splits up a String instance into strings contained in a Vector of size not greater than a specified limit.
public static  Vectorsplit(PatternMatcher matcher, Pattern pattern, String input)
     Splits up a String instance into a Vector of all its substrings using a regular expression as the delimiter. This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern.
public static  Stringsubstitute(PatternMatcher matcher, Pattern pattern, Substitution sub, String input, int numSubs)
     Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter.
public static  Stringsubstitute(PatternMatcher matcher, Pattern pattern, Substitution sub, String input)
     Searches a string for a pattern and substitutes only the first occurence of the pattern.

This method is identical to calling:

 substitute(matcher, pattern, sub, input, 1);
 


Parameters:
  matcher - The regular expression matcher to execute the patternsearch.
Parameters:
  pattern - The regular expression to search for and substituteoccurrences of.
Parameters:
  sub - The Substitution used to substitute pattern occurences.
Parameters:
  input - The String on which to perform substitutions.

public static  intsubstitute(StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, String input, int numSubs)
     Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter.
public static  intsubstitute(StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, PatternMatcherInput input, int numSubs)
     Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter.

Field Detail
SPLIT_ALL
final public static int SPLIT_ALL(Code)
A constant passed to the Util.split split() methods indicating that all occurrences of a pattern should be used to split a string.



SUBSTITUTE_ALL
final public static int SUBSTITUTE_ALL(Code)
A constant passed to the Util.substitute substitute() methods indicating that all occurrences of a pattern should be substituted.





Method Detail
split
public static void split(Collection results, PatternMatcher matcher, Pattern pattern, String input, int limit)(Code)
Splits up a String instance and stores results as a List of substrings numbering no more than a specified limit. The string is split with a regular expression as the delimiter. The limit parameter essentially says to split the string only on at most the first limit - 1 number of pattern occurences.

This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:

      split(list, "/([,-])/", "8-12,15,18", Util.SPLIT_ALL)

    produces the list containing:

      { "8", "-", "12", ",", "15", ",", "18" }

    The OROMatcher split method does not follow this behavior. The following list would be produced by OROMatcher:

      { "8", "12", "15", "18" }

    To obtain the Perl behavior, use org.apache.oro.text.perl.Perl5Util.split .


Parameters:
  results - A Collection to which the split results are appended.After the method returns, it contains the substrings of the inputthat occur between the regular expression delimiter occurences.The input will not be split into any more substrings than thespecified limit. A way of thinking of this is thatonly the first limit - 1 matches of the delimitingregular expression will be used to split the input.
Parameters:
  matcher - The regular expression matcher to execute the split.
Parameters:
  pattern - The regular expression to use as a split delimiter.
Parameters:
  input - The String to split.
Parameters:
  limit - The limit on the number of resulting split elements.Values <= 0 produce the same behavior as using theSPLIT_ALL constant which causes the limit to be ignored and splits to be performed on all occurrences ofthe pattern. You should use the SPLIT_ALL constantto achieve this behavior instead of relying on the defaultbehavior associated with non-positive limit values.
since:
   2.0




split
public static void split(Collection results, PatternMatcher matcher, Pattern pattern, String input)(Code)
Splits up a String instance and stores results as a Collection of all its substrings using a regular expression as the delimiter. This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:

      split(list, "/([,-])/", "8-12,15,18")

    produces the list containing:

      { "8", "-", "12", ",", "15", ",", "18" }

    The OROMatcher split method does not follow this behavior. The following list would be produced by OROMatcher:

      { "8", "12", "15", "18" }

    To obtain the Perl behavior, use org.apache.oro.text.perl.Perl5Util.split .

This method is identical to calling:

 split(matcher, pattern, input, Util.SPLIT_ALL);
 


Parameters:
  results - A Collection to which all the substrings ofthe input that occur between the regular expression delimiteroccurences are appended.
Parameters:
  matcher - The regular expression matcher to execute the split.
Parameters:
  pattern - The regular expression to use as a split delimiter.
Parameters:
  input - The String to split.
since:
   2.0




split
public static Vector split(PatternMatcher matcher, Pattern pattern, String input, int limit)(Code)
Splits up a String instance into strings contained in a Vector of size not greater than a specified limit. The string is split with a regular expression as the delimiter. The limit parameter essentially says to split the string only on at most the first limit - 1 number of pattern occurences.

This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:

      split("/([,-])/", "8-12,15,18")

    produces the Vector containing:

      { "8", "-", "12", ",", "15", ",", "18" }

    The OROMatcher split method does not follow this behavior. The following Vector would be produced by OROMatcher:

      { "8", "12", "15", "18" }

    To obtain the Perl behavior, use org.apache.oro.text.perl.Perl5Util.split .

Util.split(Collection,PatternMatcher,Pattern,String,int)
Parameters:
  matcher - The regular expression matcher to execute the split.
Parameters:
  pattern - The regular expression to use as a split delimiter.
Parameters:
  input - The String to split.
Parameters:
  limit - The limit on the size of the returned Vector.Values <= 0 produce the same behavior as using theSPLIT_ALL constant which causes the limit to be ignored and splits to be performed on all occurrences ofthe pattern. You should use the SPLIT_ALL constantto achieve this behavior instead of relying on the defaultbehavior associated with non-positive limit values. A Vector containing the substrings of the inputthat occur between the regular expression delimiter occurences.The input will not be split into any more substrings than thespecified limit. A way of thinking of this is thatonly the first limit - 1 matches of the delimitingregular expression will be used to split the input.
since:
   1.0




split
public static Vector split(PatternMatcher matcher, Pattern pattern, String input)(Code)
Splits up a String instance into a Vector of all its substrings using a regular expression as the delimiter. This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:

    In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:

      split("/([,-])/", "8-12,15,18")

    produces the Vector containing:

      { "8", "-", "12", ",", "15", ",", "18" }

    The OROMatcher split method does not follow this behavior. The following Vector would be produced by OROMatcher:

      { "8", "12", "15", "18" }

    To obtain the Perl behavior, use org.apache.oro.text.perl.Perl5Util.split .

This method is identical to calling:

 split(matcher, pattern, input, Util.SPLIT_ALL);
 

Util.split(Collection,PatternMatcher,Pattern,String)
Parameters:
  matcher - The regular expression matcher to execute the split.
Parameters:
  pattern - The regular expression to use as a split delimiter.
Parameters:
  input - The String to split. A Vector containing all the substrings of the inputthat occur between the regular expression delimiter occurences.
since:
   1.0




substitute
public static String substitute(PatternMatcher matcher, Pattern pattern, Substitution sub, String input, int numSubs)(Code)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. A numSubs value of SUBSTITUTE_ALL will cause all occurrences of the pattern to be replaced.


Parameters:
  matcher - The regular expression matcher to execute the patternsearch.
Parameters:
  pattern - The regular expression to search for and substituteoccurrences of.
Parameters:
  sub - The Substitution used to substitute pattern occurences.
Parameters:
  input - The String on which to perform substitutions.
Parameters:
  numSubs - The number of substitutions to perform. Only thefirst numSubs patterns encountered aresubstituted. If you want to substitute all occurencesset this parameter to SUBSTITUTE_ALL . A String comprising the input string with the substitutions,if any, made. If no substitutions are made, the returned Stringis the original input String.
since:
   1.0




substitute
public static String substitute(PatternMatcher matcher, Pattern pattern, Substitution sub, String input)(Code)
Searches a string for a pattern and substitutes only the first occurence of the pattern.

This method is identical to calling:

 substitute(matcher, pattern, sub, input, 1);
 


Parameters:
  matcher - The regular expression matcher to execute the patternsearch.
Parameters:
  pattern - The regular expression to search for and substituteoccurrences of.
Parameters:
  sub - The Substitution used to substitute pattern occurences.
Parameters:
  input - The String on which to perform substitutions. A String comprising the input string with the substitutions,if any, made. If no substitutions are made, the returned Stringis the original input String.
since:
   1.0




substitute
public static int substitute(StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, String input, int numSubs)(Code)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. A numSubs value of SUBSTITUTE_ALL will cause all occurrences of the pattern to be replaced. The number of substitutions made is returned.


Parameters:
  result - The StringBuffer in which to store the result of thesubstitutions. The buffer is only appended to.
Parameters:
  matcher - The regular expression matcher to execute the patternsearch.
Parameters:
  pattern - The regular expression to search for and substituteoccurrences of.
Parameters:
  sub - The Substitution used to substitute pattern occurences.
Parameters:
  input - The input on which to perform substitutions.
Parameters:
  numSubs - The number of substitutions to perform. Only thefirst numSubs patterns encountered aresubstituted. If you want to substitute all occurencesset this parameter to SUBSTITUTE_ALL . The number of substitutions made.
since:
   2.0.6




substitute
public static int substitute(StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, PatternMatcherInput input, int numSubs)(Code)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. A numSubs value of SUBSTITUTE_ALL will cause all occurrences of the pattern to be replaced. The number of substitutions made is returned.


Parameters:
  result - The StringBuffer in which to store the result of thesubstitutions. The buffer is only appended to.
Parameters:
  matcher - The regular expression matcher to execute the patternsearch.
Parameters:
  pattern - The regular expression to search for and substituteoccurrences of.
Parameters:
  sub - The Substitution used to substitute pattern occurences.
Parameters:
  input - The input on which to perform substitutions.
Parameters:
  numSubs - The number of substitutions to perform. Only thefirst numSubs patterns encountered aresubstituted. If you want to substitute all occurencesset this parameter to SUBSTITUTE_ALL . The number of substitutions made.
since:
   2.0.3




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.