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


java.lang.Object
   org.apache.oro.text.GlobCompiler

GlobCompiler
final public class GlobCompiler implements PatternCompiler(Code)
The GlobCompiler class will compile a glob expression into a Perl5Pattern that may be used to match patterns in conjunction with Perl5Matcher. Rather than create extra GlobMatcher and GlobPattern classes tailored to the task of matching glob expressions, we have simply reused the Perl5 regular expression classes from org.apache.oro.text.regex by making GlobCompiler translate a glob expression into a Perl5 expression that is compiled by a Perl5Compiler instance internal to the GlobCompiler.

Because there are various similar glob expression syntaxes, GlobCompiler tries to provide a small amount of customization by providing the GlobCompiler.STAR_CANNOT_MATCH_NULL_MASK and GlobCompiler.QUESTION_MATCHES_ZERO_OR_ONE_MASK compilation options.

The GlobCompiler expression syntax is based on Unix shell glob expressions but should be usable to simulate Win32 wildcards. The following syntax is supported:

  • * - Matches zero or more instances of any character. If the STAR_CANNOT_MATCH_NULL_MASK option is used, * matches one or more instances of any character.
  • ? - Matches one instance of any character. If the QUESTION_MATCHES_ZERO_OR_ONE_MASK option is used, ? matches zero or one instances of any character.
  • [...] - Matches any of characters enclosed by the brackets. * and ? lose their special meanings within a character class. Additionaly if the first character following the opening bracket is a ! or a ^, then any character not in the character class is matched. A - between two characters can be used to denote a range. A - at the beginning or end of the character class matches itself rather than referring to a range. A ] immediately following the opening [ matches itself rather than indicating the end of the character class, otherwise it must be escaped with a backslash to refer to itself.
  • \ - A backslash matches itself in most situations. But when a special character such as a * follows it, a backslash escapes the character, indicating that the special chracter should be interpreted as a normal character instead of its special meaning.
  • All other characters match themselves.

Please remember that the when you construct a Java string in Java code, the backslash character is itself a special Java character, and it must be double backslashed to represent single backslash in a regular expression.
version:
   @version@
since:
   1.0
See Also:   org.apache.oro.text.regex.PatternCompiler
See Also:   org.apache.oro.text.regex.Perl5Matcher



Field Summary
final public static  intCASE_INSENSITIVE_MASK
     A mask passed as an option to the GlobCompiler.compile compile methods to indicate a compiled glob expression should be case insensitive.
final public static  intDEFAULT_MASK
     The default mask for the GlobCompiler.compile compile methods. It is equal to 0.
final public static  intQUESTION_MATCHES_ZERO_OR_ONE_MASK
     A mask passed as an option to the GlobCompiler.compile compile methods to indicate that a ? should not be allowed to match the null string. The normal behavior of the ? metacharacter is that it may match any 1 character.
final public static  intREAD_ONLY_MASK
     A mask passed as an option to the GlobCompiler.compile compile methods to indicate that the resulting Perl5Pattern should be treated as a read only data structure by Perl5Matcher, making it safe to share a single Perl5Pattern instance among multiple threads without needing synchronization.
final public static  intSTAR_CANNOT_MATCH_NULL_MASK
     A mask passed as an option to the GlobCompiler.compile compile methods to indicate that a * should not be allowed to match the null string. The normal behavior of the * metacharacter is that it may match any 0 or more characters.

Constructor Summary
public  GlobCompiler()
     The default GlobCompiler constructor.

Method Summary
public  Patterncompile(char[] pattern, int options)
     Compiles a Glob expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.


Parameters:
  pattern - A Glob expression to compile.
Parameters:
  options - A set of flags giving the compiler instructions onhow to treat the glob expression.

public  Patterncompile(char[] pattern)
     Same as calling compile(pattern, GlobCompiler.DEFAULT_MASK);


Parameters:
  pattern - A regular expression to compile.

public  Patterncompile(String pattern)
     Same as calling compile(pattern, GlobCompiler.DEFAULT_MASK);


Parameters:
  pattern - A regular expression to compile.

public  Patterncompile(String pattern, int options)
     Compiles a Glob expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.


Parameters:
  pattern - A Glob expression to compile.
Parameters:
  options - A set of flags giving the compiler instructions onhow to treat the glob expression.

public static  StringglobToPerl5(char[] pattern, int options)
     This static method is the basic engine of the Glob PatternCompiler implementation.

Field Detail
CASE_INSENSITIVE_MASK
final public static int CASE_INSENSITIVE_MASK(Code)
A mask passed as an option to the GlobCompiler.compile compile methods to indicate a compiled glob expression should be case insensitive.



DEFAULT_MASK
final public static int DEFAULT_MASK(Code)
The default mask for the GlobCompiler.compile compile methods. It is equal to 0. The default behavior is for a glob expression to be case sensitive unless it is compiled with the CASE_INSENSITIVE_MASK option.



QUESTION_MATCHES_ZERO_OR_ONE_MASK
final public static int QUESTION_MATCHES_ZERO_OR_ONE_MASK(Code)
A mask passed as an option to the GlobCompiler.compile compile methods to indicate that a ? should not be allowed to match the null string. The normal behavior of the ? metacharacter is that it may match any 1 character. This mask causes it to match 0 or 1 characters.



READ_ONLY_MASK
final public static int READ_ONLY_MASK(Code)
A mask passed as an option to the GlobCompiler.compile compile methods to indicate that the resulting Perl5Pattern should be treated as a read only data structure by Perl5Matcher, making it safe to share a single Perl5Pattern instance among multiple threads without needing synchronization. Without this option, Perl5Matcher reserves the right to store heuristic or other information in Perl5Pattern that might accelerate future matches. When you use this option, Perl5Matcher will not store or modify any information in a Perl5Pattern. Use this option when you want to share a Perl5Pattern instance among multiple threads using different Perl5Matcher instances.



STAR_CANNOT_MATCH_NULL_MASK
final public static int STAR_CANNOT_MATCH_NULL_MASK(Code)
A mask passed as an option to the GlobCompiler.compile compile methods to indicate that a * should not be allowed to match the null string. The normal behavior of the * metacharacter is that it may match any 0 or more characters. This mask causes it to match 1 or more characters of anything.




Constructor Detail
GlobCompiler
public GlobCompiler()(Code)
The default GlobCompiler constructor. It initializes an internal Perl5Compiler instance to compile translated glob expressions.




Method Detail
compile
public Pattern compile(char[] pattern, int options) throws MalformedPatternException(Code)
Compiles a Glob expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.


Parameters:
  pattern - A Glob expression to compile.
Parameters:
  options - A set of flags giving the compiler instructions onhow to treat the glob expression. The flagsare a logical OR of any number of the 3 MASKconstants. For example:

regex =compiler.compile(pattern, GlobCompiler.CASE_INSENSITIVE_MASK |GlobCompiler.STAR_CANNOT_MATCH_NULL_MASK);
This says to compile the pattern so that *cannot match the null string and to performmatches in a case insensitive manner. A Pattern instance constituting the compiled expression.This instance will always be a Perl5Pattern and can be reliablycasted to a Perl5Pattern.
exception:
  MalformedPatternException - If the compiled expressionis not a valid Glob expression.



compile
public Pattern compile(char[] pattern) throws MalformedPatternException(Code)
Same as calling compile(pattern, GlobCompiler.DEFAULT_MASK);


Parameters:
  pattern - A regular expression to compile. A Pattern instance constituting the compiled regular expression.This instance will always be a Perl5Pattern and can be reliablycasted to a Perl5Pattern.
exception:
  MalformedPatternException - If the compiled expressionis not a valid Glob expression.




compile
public Pattern compile(String pattern) throws MalformedPatternException(Code)
Same as calling compile(pattern, GlobCompiler.DEFAULT_MASK);


Parameters:
  pattern - A regular expression to compile. A Pattern instance constituting the compiled regular expression.This instance will always be a Perl5Pattern and can be reliablycasted to a Perl5Pattern.
exception:
  MalformedPatternException - If the compiled expressionis not a valid Glob expression.




compile
public Pattern compile(String pattern, int options) throws MalformedPatternException(Code)
Compiles a Glob expression into a Perl5Pattern instance that can be used by a Perl5Matcher object to perform pattern matching.


Parameters:
  pattern - A Glob expression to compile.
Parameters:
  options - A set of flags giving the compiler instructions onhow to treat the glob expression. The flagsare a logical OR of any number of the 3 MASKconstants. For example:

regex =compiler.compile("*.*", GlobCompiler.CASE_INSENSITIVE_MASK |GlobCompiler.STAR_CANNOT_MATCH_NULL_MASK);
This says to compile the pattern so that *cannot match the null string and to performmatches in a case insensitive manner. A Pattern instance constituting the compiled expression.This instance will always be a Perl5Pattern and can be reliablycasted to a Perl5Pattern.
exception:
  MalformedPatternException - If the compiled expressionis not a valid Glob expression.



globToPerl5
public static String globToPerl5(char[] pattern, int options)(Code)
This static method is the basic engine of the Glob PatternCompiler implementation. It takes a glob expression in the form of a character array and converts it into a String representation of a Perl5 pattern. The method is made public so that programmers may use it for their own purposes. However, the GlobCompiler compile methods work by converting the glob pattern to a Perl5 pattern using this method, and then invoking the compile() method of an internally stored Perl5Compiler instance.


Parameters:
  pattern - A character array representation of a Glob pattern. A String representation of a Perl5 pattern equivalent to theGlob pattern.




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.