Java Doc for SearchPattern.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » core » search » 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 » IDE Eclipse » jdt » org.eclipse.jdt.core.search 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.eclipse.jdt.internal.core.search.matching.InternalSearchPattern
      org.eclipse.jdt.core.search.SearchPattern

All known Subclasses:   org.eclipse.jdt.internal.core.search.matching.JavaSearchPattern,  org.eclipse.jdt.internal.core.search.matching.OrPattern,
SearchPattern
abstract public class SearchPattern extends InternalSearchPattern (Code)
A search pattern defines how search results are found. Use SearchPattern.createPattern to create a search pattern.

Search patterns are used during the search phase to decode index entries that were added during the indexing phase (see SearchDocument.addIndexEntry(char[]char[]) ). When an index is queried, the index categories and keys to consider are retrieved from the search pattern using SearchPattern.getIndexCategories() and SearchPattern.getIndexKey() , as well as the match rule (see SearchPattern.getMatchRule() ). A blank pattern is then created (see SearchPattern.getBlankPattern() ). This blank pattern is used as a record as follows. For each index entry in the given index categories and that starts with the given key, the blank pattern is fed using SearchPattern.decodeIndexKey(char[]) . The original pattern is then asked if it matches the decoded key using SearchPattern.matchesDecodedKey(SearchPattern) . If it matches, a search document is created for this index entry using SearchParticipant.getDocument(String) .

This class is intended to be sub-classed by clients. A default behavior is provided for each of the methods above, that clients can override if they wish.


See Also:   SearchPattern.createPattern(org.eclipse.jdt.core.IJavaElement,int)
See Also:   SearchPattern.createPattern(String,int,int,int)
since:
   3.0


Field Summary
final public static  intR_CAMELCASE_MATCH
     Match rule: The search pattern contains a Camel Case expression.

Examples:

  • 'NPE' type string pattern will match 'NullPointerException' and 'NoPermissionException' types,
  • 'NuPoEx' type string pattern will only match 'NullPointerException' type.
Can be combined to SearchPattern.R_PREFIX_MATCH match rule.
final public static  intR_CAMEL_CASE_MATCH
     Match rule: The search pattern contains a Camel Case expression with a strict number of parts and preventing automatic prefix matching for the last part (if it consists of multiple letters).
Examples:
  • 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
  • 'HMap' type string pattern will match 'HashMap' type but not 'HtmlMapper'.
This Camel Case match rule does not allow prefix match but accept insensitive case.
final public static  intR_CASE_SENSITIVE
     Match rule: The search pattern matches the search result only if cases are the same. Can be combined to previous rules, e.g.
final public static  intR_EQUIVALENT_MATCH
     Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters. This mode has no effect on other java elements search.
Type search example:
  • pattern: List<Exception>
  • match:
    • List<? extends Throwable>
    • List<? super RuntimeException>
    • List<?>
Method search example:
  • declaration: <T>foo(T t)
  • pattern: <Exception>foo(new Exception())
  • match:
    • <? extends Throwable>foo(new Exception())
    • <? super RuntimeException>foo(new Exception())
    • foo(new Exception())
Can be combined to all other match rules, e.g.
final public static  intR_ERASURE_MATCH
     Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure. This mode has no effect on other java elements search.
Type search example:
  • pattern: List<Exception>
  • match: List<Object>
Method search example:
  • declaration: <T>foo(T t)
  • pattern: <Exception>foo(new Exception())
  • match: <Object>foo(new Object())
Can be combined to all other match rules, e.g.
final public static  intR_EXACT_MATCH
     Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.
final public static  intR_FULL_MATCH
     Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.
final public static  intR_PATTERN_MATCH
     Match rule: The search pattern contains one or more wild cards ('*' or '?').
final public static  intR_PREFIX_MATCH
     Match rule: The search pattern is a prefix of the search result.
final public static  intR_REGEXP_MATCH
     Match rule: The search pattern contains a regular expression.

Constructor Summary
public  SearchPattern(int matchRule)
     Creates a search pattern with the rule to apply for matching index keys.

Method Summary
final public static  booleancamelCaseMatch(String pattern, String name)
     Answers true if the pattern matches the given name using CamelCase rules, or false otherwise.
final public static  booleancamelCaseMatch(String pattern, String name, boolean prefixMatch)
     Answers true if the pattern matches the given name using CamelCase rules, or false otherwise.
final public static  booleancamelCaseMatch(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd)
     Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise.
final public static  booleancamelCaseMatch(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd, boolean prefixMatch)
     Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise.
public static  SearchPatterncreateAndPattern(SearchPattern leftPattern, SearchPattern rightPattern)
     Returns a search pattern that combines the given two patterns into an "and" pattern.
public static  SearchPatterncreateOrPattern(SearchPattern leftPattern, SearchPattern rightPattern)
     Returns a search pattern that combines the given two patterns into an "or" pattern.
public static  SearchPatterncreatePattern(String stringPattern, int searchFor, int limitTo, int matchRule)
     Returns a search pattern based on a given string pattern.
public static  SearchPatterncreatePattern(IJavaElement element, int limitTo)
     Returns a search pattern based on a given Java element.
public static  SearchPatterncreatePattern(IJavaElement element, int limitTo, int matchRule)
     Returns a search pattern based on a given Java element.
public  voiddecodeIndexKey(char[] key)
     Decode the given index key in this pattern.
abstract public  SearchPatterngetBlankPattern()
     Returns a blank pattern that can be used as a record to decode an index key.
public  char[][]getIndexCategories()
     Returns an array of index categories to consider for this index query.
public  char[]getIndexKey()
     Returns a key to find in relevant index categories, if null then all index entries are matched. The key will be matched according to some match rule.
final public  intgetMatchRule()
     Returns the rule to apply for matching index keys.
public  booleanmatchesDecodedKey(SearchPattern decodedPattern)
     Returns whether this pattern matches the given pattern (representing a decoded index key).
public  booleanmatchesName(char[] pattern, char[] name)
     Returns whether the given name matches the given pattern.
public  StringtoString()
    
static  intupdateMatchRule(int matchRule)
     Update deprecated flags if necessary in the given match rule.
public static  intvalidateMatchRule(String stringPattern, int matchRule)
     Validate compatibility between given string pattern and match rule.
Returned match rule is modified, when following combinations are observed in the given parameters:
Rejected (i.e.

Field Detail
R_CAMELCASE_MATCH
final public static int R_CAMELCASE_MATCH(Code)
Match rule: The search pattern contains a Camel Case expression.

Examples:

  • 'NPE' type string pattern will match 'NullPointerException' and 'NoPermissionException' types,
  • 'NuPoEx' type string pattern will only match 'NullPointerException' type.
Can be combined to SearchPattern.R_PREFIX_MATCH match rule. For example, when prefix match rule is combined with Camel Case match rule, 'nPE' pattern will match 'nPException'.

Match rule SearchPattern.R_PATTERN_MATCH may also be combined but both rules will not be used simultaneously as they are mutually exclusive. Used match rule depends on whether string pattern contains specific pattern characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule will be used, otherwise only Camel Case match will be used. For example, with 'NPE' string pattern, search will only use Camel Case match rule, but with 'N*P*E*' string pattern, it will use only Pattern match rule.


See Also:   SearchPattern.camelCaseMatch(String,String)
See Also:    for a detailed explanation of Camel
See Also:   Case matching.
since:
   3.2SearchPattern.R_CAMEL_CASE_MATCHSearchPattern.R_PREFIX_MATCH




R_CAMEL_CASE_MATCH
final public static int R_CAMEL_CASE_MATCH(Code)
Match rule: The search pattern contains a Camel Case expression with a strict number of parts and preventing automatic prefix matching for the last part (if it consists of multiple letters).
Examples:
  • 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
  • 'HMap' type string pattern will match 'HashMap' type but not 'HtmlMapper'.
This Camel Case match rule does not allow prefix match but accept insensitive case. For instance, 'HashMap' or 'HASHMAP' patterns using this Camel Case rule will match both 'HashMap' but not 'HashMapEntry'.

This rule still can be combined to prefix match to accept prefix matches ('HashMap' pattern matching 'HashMapEntry' name). It can also be combined to case sensitive match to reject case insensitive matches ('HAMA' pattern will not match 'HashMap' name).

If SearchPattern.R_PATTERN_MATCH rule is also combined, then the real used match rule will depend on whether string pattern contains specific pattern characters (e.g. '*' or '?') or not. If it does, then only Pattern match rule will be used, otherwise only Camel Case match will be used.
For example, with 'NPE' string pattern, search will only use Camel Case match rule, but with 'N*P*E*' string pattern, it will use only Pattern match rule.


See Also:   CharOperation.camelCaseMatch(char[]char[]boolean)
See Also:    for a detailed
See Also:   explanation of Camel Case matching.
See Also:   


since:
   3.4




R_CASE_SENSITIVE
final public static int R_CASE_SENSITIVE(Code)
Match rule: The search pattern matches the search result only if cases are the same. Can be combined to previous rules, e.g. SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE



R_EQUIVALENT_MATCH
final public static int R_EQUIVALENT_MATCH(Code)
Match rule: The search pattern matches search results as raw/parameterized types/methods with equivalent type parameters. This mode has no effect on other java elements search.
Type search example:
  • pattern: List<Exception>
  • match:
    • List<? extends Throwable>
    • List<? super RuntimeException>
    • List<?>
Method search example:
  • declaration: <T>foo(T t)
  • pattern: <Exception>foo(new Exception())
  • match:
    • <? extends Throwable>foo(new Exception())
    • <? super RuntimeException>foo(new Exception())
    • foo(new Exception())
Can be combined to all other match rules, e.g. SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_EQUIVALENT_MATCH This rule is not activated by default, so raw types or equivalent parameterized types will not be found for pattern List<String>, This mode is overridden by SearchPattern.R_ERASURE_MATCH as erasure matches obviously include equivalent ones. That means that pattern with rule set to SearchPattern.R_EQUIVALENT_MATCH | SearchPattern.R_ERASURE_MATCH will return same results than rule only set with SearchPattern.R_ERASURE_MATCH .
since:
   3.1



R_ERASURE_MATCH
final public static int R_ERASURE_MATCH(Code)
Match rule: The search pattern matches search results as raw/parameterized types/methods with same erasure. This mode has no effect on other java elements search.
Type search example:
  • pattern: List<Exception>
  • match: List<Object>
Method search example:
  • declaration: <T>foo(T t)
  • pattern: <Exception>foo(new Exception())
  • match: <Object>foo(new Object())
Can be combined to all other match rules, e.g. SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH This rule is not activated by default, so raw types or parameterized types with same erasure will not be found for pattern List<String>, Note that with this pattern, the match selection will be only on the erasure even for parameterized types.
since:
   3.1



R_EXACT_MATCH
final public static int R_EXACT_MATCH(Code)
Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.



R_FULL_MATCH
final public static int R_FULL_MATCH(Code)
Match rule: The search pattern matches exactly the search result, that is, the source of the search result equals the search pattern.
since:
   3.1



R_PATTERN_MATCH
final public static int R_PATTERN_MATCH(Code)
Match rule: The search pattern contains one or more wild cards ('*' or '?'). A '*' wild-card can replace 0 or more characters in the search result. A '?' wild-card replaces exactly 1 character in the search result.



R_PREFIX_MATCH
final public static int R_PREFIX_MATCH(Code)
Match rule: The search pattern is a prefix of the search result.



R_REGEXP_MATCH
final public static int R_REGEXP_MATCH(Code)
Match rule: The search pattern contains a regular expression.




Constructor Detail
SearchPattern
public SearchPattern(int matchRule)(Code)
Creates a search pattern with the rule to apply for matching index keys. It can be exact match, prefix match, pattern match or regexp match. Rule can also be combined with a case sensitivity flag.
Parameters:
  matchRule - one of SearchPattern.R_EXACT_MATCH, SearchPattern.R_PREFIX_MATCH,SearchPattern.R_PATTERN_MATCH, SearchPattern.R_REGEXP_MATCH combined withone of following values: SearchPattern.R_CASE_SENSITIVE, SearchPattern.R_ERASURE_MATCH,SearchPattern.R_EQUIVALENT_MATCH or SearchPattern.R_CAMEL_CASE_MATCH.e.g. SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE if an exactand case sensitive match is requested, SearchPattern.R_PREFIX_MATCH if a prefixnon case sensitive match is requested or SearchPattern.R_EXACT_MATCH | SearchPattern.R_ERASURE_MATCHif a non case sensitive and erasure match is requested.
Note that SearchPattern.R_ERASURE_MATCH or SearchPattern.R_EQUIVALENT_MATCH have no effecton non-generic types/methods search.
Note also that default behavior for generic types/methods search is to find exact matches.




Method Detail
camelCaseMatch
final public static boolean camelCaseMatch(String pattern, String name)(Code)
Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

This method allows prefix match in Camel Case (see SearchPattern.camelCaseMatch(String,String,boolean) ).

 Examples:
 
  1. pattern = "NPE" name = NullPointerException / NoPermissionException result => true
  2. pattern = "NuPoEx" name = NullPointerException result => true
  3. pattern = "npe" name = NullPointerException result => false
  4. pattern = "IPL3" name = "IPerspectiveListener3" result => true
  5. pattern = "HM" name = "HashMapEntry" result => true
  6. pattern = "HMap" name = "HatMapper" result => true

See Also:   SearchPattern.camelCaseMatch(String,int,int,String,int,int,boolean)
See Also:    for algorithm
See Also:   implementation
Parameters:
  pattern - the given pattern
Parameters:
  name - the given name true if the pattern matches the given name, false otherwise
since:
   3.2



camelCaseMatch
final public static boolean camelCaseMatch(String pattern, String name, boolean prefixMatch)(Code)
Answers true if the pattern matches the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

CamelCase may or may not match prefixes depending on the given parameter. When the prefix match parameter is true, the given pattern can match only a prefix of the given name. For instance, 'HM' , 'HaMa' and 'HMap' patterns will all match 'HashMap', 'HatMapper' and 'HashMapEntry'.
Reversely, if the prefix match parameter is false, then pattern and name must have exactly the same number of parts, and their last parts must be identical if they contain lowercase characters. For instance, 'HMap' and 'HaMap' patterns will match 'HashMap' but neither 'HashMapEntry' nor 'HatMapper'. Note that when the last part does not contain lowercase characters, then the name may end with lowercase characters. So, 'HM' pattern will match both 'HashMap' and 'HatMapper' but will not match 'HashMapEntry'.

 Examples:
 
  1. pattern = "NPE" name = NullPointerException / NoPermissionException result => true
  2. pattern = "NuPoEx" name = NullPointerException result => true
  3. pattern = "npe" name = NullPointerException result => false
  4. pattern = "IPL3" name = "IPerspectiveListener3" result => true
  5. pattern = "HM" name = "HashMapEntry" result => (prefixMatch == true)
  6. pattern = "HMap" name = "HatMapper" result => (prefixMatch == true)

See Also:   SearchPattern.camelCaseMatch(String,int,int,String,int,int,boolean)
See Also:    for algorithm
See Also:   implementation
Parameters:
  pattern - the given pattern
Parameters:
  name - the given name
Parameters:
  prefixMatch - flag telling whether the pattern can match name prefix or not.
  • For example, when it's true:
    - HM type string pattern will matchHashMap and HtmlMapper types,but not HashMapEntry
    - HMap type string pattern will matchHashMap type but not HtmlMapper.
  • and, when it's false:
    - HM type string pattern will match both HashMap and HtmlMapperand HashMapEntry
    - HMap type string pattern will match bothHashMap and HtmlMapper types.
true if the pattern matches the given name, false otherwise
since:
   3.4



camelCaseMatch
final public static boolean camelCaseMatch(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd)(Code)
Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. Can match only subset of name/pattern, considering end positions as non-inclusive. The sub-pattern is defined by the patternStart and patternEnd positions.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

This method allows prefix match in Camel Case (see SearchPattern.camelCaseMatch(String,int,int,String,int,int,boolean) ).

Examples:
  1. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
  2. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NoPermissionException nameStart = 0 nameEnd = 21 result => true
  3. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
  4. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NoPermissionException nameStart = 0 nameEnd = 21 result => false
  5. pattern = "npe" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => false
  6. pattern = "IPL3" patternStart = 0 patternEnd = 3 name = "IPerspectiveListener3" nameStart = 0 nameEnd = 21 result => true
  7. pattern = "HM" patternStart = 0 patternEnd = 2 name = "HashMapEntry" nameStart = 0 nameEnd = 12 result => true
  8. pattern = "HMap" patternStart = 0 patternEnd = 4 name = "HatMapper" nameStart = 0 nameEnd = 9 result => true

Parameters:
  pattern - the given pattern
Parameters:
  patternStart - the start index of the pattern, inclusive
Parameters:
  patternEnd - the end index of the pattern, exclusive
Parameters:
  name - the given name
Parameters:
  nameStart - the start index of the name, inclusive
Parameters:
  nameEnd - the end index of the name, exclusive true if a sub-pattern matches the sub-part of the given name, false otherwise
since:
   3.2



camelCaseMatch
final public static boolean camelCaseMatch(String pattern, int patternStart, int patternEnd, String name, int nameStart, int nameEnd, boolean prefixMatch)(Code)
Answers true if a sub-pattern matches the sub-part of the given name using CamelCase rules, or false otherwise. char[] CamelCase matching does NOT accept explicit wild-cards '*' and '?' and is inherently case sensitive. Can match only subset of name/pattern, considering end positions as non-inclusive. The sub-pattern is defined by the patternStart and patternEnd positions.

CamelCase denotes the convention of writing compound names without spaces, and capitalizing every term. This function recognizes both upper and lower CamelCase, depending whether the leading character is capitalized or not. The leading part of an upper CamelCase pattern is assumed to contain a sequence of capitals which are appearing in the matching name; e.g. 'NPE' will match 'NullPointerException', but not 'NewPerfData'. A lower CamelCase pattern uses a lowercase first character. In Java, type names follow the upper CamelCase convention, whereas method or field names follow the lower CamelCase convention.

The pattern may contain lowercase characters, which will be matched in a case sensitive way. These characters must appear in sequence in the name. For instance, 'NPExcep' will match 'NullPointerException', but not 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but not 'NoPointerException'.

Digit characters are treated in a special way. They can be used in the pattern but are not always considered as leading character. For instance, both 'UTF16DSS' and 'UTFDSS' patterns will match 'UTF16DocumentScannerSupport'.

CamelCase may or may not match prefixes depending on the given parameter. When the prefix match parameter is true, the given pattern can match only a prefix of the given name. For instance, 'HM' , 'HaMa' and 'HMap' patterns will all match 'HashMap', 'HatMapper' and 'HashMapEntry'.
Reversely, if the prefix match parameter is false, then pattern and name must have exactly the same number of parts, and their last parts must be identical if they contain lowercase characters. For instance, 'HMap' and 'HaMap' patterns will match 'HashMap' but neither 'HashMapEntry' nor 'HatMapper'. Note that when the last part does not contain lowercase characters, then the name may end with lowercase characters. So, 'HM' pattern will match both 'HashMap' and 'HatMapper' but will not match 'HashMapEntry'.

Examples:
  1. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
  2. pattern = "NPE" patternStart = 0 patternEnd = 3 name = NoPermissionException nameStart = 0 nameEnd = 21 result => true
  3. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NullPointerException nameStart = 0 nameEnd = 20 result => true
  4. pattern = "NuPoEx" patternStart = 0 patternEnd = 6 name = NoPermissionException nameStart = 0 nameEnd = 21 result => false
  5. pattern = "npe" patternStart = 0 patternEnd = 3 name = NullPointerException nameStart = 0 nameEnd = 20 result => false
  6. pattern = "IPL3" patternStart = 0 patternEnd = 3 name = "IPerspectiveListener3" nameStart = 0 nameEnd = 21 result => true
  7. pattern = "HM" patternStart = 0 patternEnd = 2 name = "HashMapEntry" nameStart = 0 nameEnd = 12 result => (prefixMatch == true)
  8. pattern = "HMap" patternStart = 0 patternEnd = 4 name = "HatMapper" nameStart = 0 nameEnd = 9 result => (prefixMatch == true)

See Also:   CharOperation.camelCaseMatch(char[]intintchar[]intintboolean)
See Also:   from which algorithm implementation has been entirely copied.
Parameters:
  pattern - the given pattern
Parameters:
  patternStart - the start index of the pattern, inclusive
Parameters:
  patternEnd - the end index of the pattern, exclusive
Parameters:
  name - the given name
Parameters:
  nameStart - the start index of the name, inclusive
Parameters:
  nameEnd - the end index of the name, exclusive
Parameters:
  prefixMatch - flag telling whether the pattern can match name prefix or not.
  • For example, when it's true:
    - HM type string pattern will matchHashMap and HtmlMapper types,but not HashMapEntry
    - HMap type string pattern will matchHashMap type but not HtmlMapper.
  • and, when it's false:
    - HM type string pattern will match both HashMap and HtmlMapperand HashMapEntry
    - HMap type string pattern will match bothHashMap and HtmlMapper types.
true if a sub-pattern matches the sub-part of the given name, false otherwise
since:
   3.4



createAndPattern
public static SearchPattern createAndPattern(SearchPattern leftPattern, SearchPattern rightPattern)(Code)
Returns a search pattern that combines the given two patterns into an "and" pattern. The search result will match both the left pattern and the right pattern.
Parameters:
  leftPattern - the left pattern
Parameters:
  rightPattern - the right pattern an "and" pattern



createOrPattern
public static SearchPattern createOrPattern(SearchPattern leftPattern, SearchPattern rightPattern)(Code)
Returns a search pattern that combines the given two patterns into an "or" pattern. The search result will match either the left pattern or the right pattern.
Parameters:
  leftPattern - the left pattern
Parameters:
  rightPattern - the right pattern an "or" pattern



createPattern
public static SearchPattern createPattern(String stringPattern, int searchFor, int limitTo, int matchRule)(Code)
Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards. The remaining parameters are used to narrow down the type of expected results.
Examples:
  • search for case insensitive references to Object: createSearchPattern("Object", TYPE, REFERENCES, false);
  • search for case sensitive references to exact Object() constructor: createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);
  • search for implementers of java.lang.Runnable: createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);

Parameters:
  stringPattern - the given pattern
Parameters:
  searchFor - determines the nature of the searched elements
Parameters:
  limitTo - determines the nature of the expected matches
Parameters:
  matchRule - one of SearchPattern.R_EXACT_MATCH, SearchPattern.R_PREFIX_MATCH,SearchPattern.R_PATTERN_MATCH, SearchPattern.R_REGEXP_MATCH combined withone of following values: SearchPattern.R_CASE_SENSITIVE, SearchPattern.R_ERASURE_MATCH,SearchPattern.R_EQUIVALENT_MATCH or SearchPattern.R_CAMEL_CASE_MATCH.e.g. SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE if an exactand case sensitive match is requested, SearchPattern.R_PREFIX_MATCH if a prefixnon case sensitive match is requested or SearchPattern.R_EXACT_MATCH | SearchPattern.R_ERASURE_MATCHif a non case sensitive and erasure match is requested.
Note that SearchPattern.R_ERASURE_MATCH or SearchPattern.R_EQUIVALENT_MATCH have no effecton non-generic types/methods search.
Note also that default behavior for generic types/methods search is to find exact matches. a search pattern on the given string pattern, or null if the string pattern is ill-formed



createPattern
public static SearchPattern createPattern(IJavaElement element, int limitTo)(Code)
Returns a search pattern based on a given Java element. The pattern is used to trigger the appropriate search.
Note that for generic searches, the returned pattern consider SearchPattern.R_ERASURE_MATCH matches. If other kind of generic matches (i.e. SearchPattern.R_EXACT_MATCH or SearchPattern.R_EQUIVALENT_MATCH ) are expected, SearchPattern.createPattern(IJavaElement,int,int) method need to be used instead with the explicit match rule specified.
The pattern can be parameterized as follows:
Parameters:
  element - the Java element the search pattern is based on
Parameters:
  limitTo - determines the nature of the expected matches
  • IJavaSearchConstants.DECLARATIONS: will search declarations matchingwith the corresponding element. In case the element is a method, declarations of matchingmethods in sub-types will also be found, allowing to find declarations of abstract methods, etc.Some additional flags may be specified while searching declaration:
    • IJavaSearchConstants.IGNORE_DECLARING_TYPE: declaring type will be ignoredduring the search.
      For example using following test case:
      class A { A method() { return null; } }class B extends A { B method() { return null; } }class C { A method() { return null; } }
      search for method declaration with this flagwill return 2 matches: in A and in C
    • IJavaSearchConstants.IGNORE_RETURN_TYPE: return type will be ignoredduring the search.
      Using same example, search for method declaration with this flagwill return 2 matches: in A and in B.
    Note that these two flags may be combined and both declaring and return types can be ignoredduring the search. Then, using same example, search for method declarationwith these 2 flags will return 3 matches: in A, in B and in C
  • IJavaSearchConstants.REFERENCES: will search references to the given element.
  • IJavaSearchConstants.ALL_OCCURRENCES: will search for either declarations orreferences as specified above.
  • IJavaSearchConstants.IMPLEMENTORS: for types, will find all typeswhich directly implement/extend a given interface.
a search pattern for a Java element or null if the given element is ill-formed



createPattern
public static SearchPattern createPattern(IJavaElement element, int limitTo, int matchRule)(Code)
Returns a search pattern based on a given Java element. The pattern is used to trigger the appropriate search, and can be parameterized as follows:
Parameters:
  element - the Java element the search pattern is based on
Parameters:
  limitTo - determines the nature of the expected matches
  • IJavaSearchConstants.DECLARATIONS: will search declarations matchingwith the corresponding element. In case the element is a method, declarations of matchingmethods in sub-types will also be found, allowing to find declarations of abstract methods, etc.Some additional flags may be specified while searching declaration:
    • IJavaSearchConstants.IGNORE_DECLARING_TYPE: declaring type will be ignoredduring the search.
      For example using following test case:
      class A { A method() { return null; } }class B extends A { B method() { return null; } }class C { A method() { return null; } }
      search for method declaration with this flagwill return 2 matches: in A and in C
    • IJavaSearchConstants.IGNORE_RETURN_TYPE: return type will be ignoredduring the search.
      Using same example, search for method declaration with this flagwill return 2 matches: in A and in B.
    Note that these two flags may be combined and both declaring and return types can be ignoredduring the search. Then, using same example, search for method declarationwith these 2 flags will return 3 matches: in A, in B and in C
  • IJavaSearchConstants.REFERENCES: will search references to the given element.
  • IJavaSearchConstants.ALL_OCCURRENCES: will search for either declarations orreferences as specified above.
  • IJavaSearchConstants.IMPLEMENTORS: for types, will find all typeswhich directly implement/extend a given interface.

Parameters:
  matchRule - one of SearchPattern.R_EXACT_MATCH, SearchPattern.R_PREFIX_MATCH,SearchPattern.R_PATTERN_MATCH, SearchPattern.R_REGEXP_MATCH combined withone of following values: SearchPattern.R_CASE_SENSITIVE, SearchPattern.R_ERASURE_MATCH,SearchPattern.R_EQUIVALENT_MATCH or SearchPattern.R_CAMEL_CASE_MATCH.e.g. SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE if an exactand case sensitive match is requested, SearchPattern.R_PREFIX_MATCH if a prefixnon case sensitive match is requested or SearchPattern.R_EXACT_MATCH | SearchPattern.R_ERASURE_MATCHif a non case sensitive and erasure match is requested.
Note that SearchPattern.R_ERASURE_MATCH or SearchPattern.R_EQUIVALENT_MATCH have no effecton non-generic types/methods search.
Note also that default behavior for generic types/methods search is to find exact matches. a search pattern for a Java element or null if the given element is ill-formed
since:
   3.1



decodeIndexKey
public void decodeIndexKey(char[] key)(Code)
Decode the given index key in this pattern. The decoded index key is used by SearchPattern.matchesDecodedKey(SearchPattern) to find out if the corresponding index entry should be considered.

This method should be re-implemented in subclasses that need to decode an index key.


Parameters:
  key - the given index key



getBlankPattern
abstract public SearchPattern getBlankPattern()(Code)
Returns a blank pattern that can be used as a record to decode an index key.

Implementors of this method should return a new search pattern that is going to be used to decode index keys.

a new blank pattern
See Also:   SearchPattern.decodeIndexKey(char[])



getIndexCategories
public char[][] getIndexCategories()(Code)
Returns an array of index categories to consider for this index query. These potential matches will be further narrowed by the match locator, but precise match locating can be expensive, and index query should be as accurate as possible so as to eliminate obvious false hits.

This method should be re-implemented in subclasses that need to narrow down the index query.

an array of index categories



getIndexKey
public char[] getIndexKey()(Code)
Returns a key to find in relevant index categories, if null then all index entries are matched. The key will be matched according to some match rule. These potential matches will be further narrowed by the match locator, but precise match locating can be expensive, and index query should be as accurate as possible so as to eliminate obvious false hits.

This method should be re-implemented in subclasses that need to narrow down the index query.

an index key from this pattern, or null if all index entries are matched.



getMatchRule
final public int getMatchRule()(Code)
Returns the rule to apply for matching index keys. Can be exact match, prefix match, pattern match or regexp match. Rule can also be combined with a case sensitivity flag. one of R_EXACT_MATCH, R_PREFIX_MATCH, R_PATTERN_MATCH, R_REGEXP_MATCH combined with R_CASE_SENSITIVE,e.g. R_EXACT_MATCH | R_CASE_SENSITIVE if an exact and case sensitive match is requested, or R_PREFIX_MATCH if a prefix non case sensitive match is requested.[TODO (frederic) I hope R_ERASURE_MATCH doesn't need to be on this list. Because it would be a breaking API change.]



matchesDecodedKey
public boolean matchesDecodedKey(SearchPattern decodedPattern)(Code)
Returns whether this pattern matches the given pattern (representing a decoded index key).

This method should be re-implemented in subclasses that need to narrow down the index query.


Parameters:
  decodedPattern - a pattern representing a decoded index key whether this pattern matches the given pattern



matchesName
public boolean matchesName(char[] pattern, char[] name)(Code)
Returns whether the given name matches the given pattern.

This method should be re-implemented in subclasses that need to define how a name matches a pattern.


Parameters:
  pattern - the given pattern, or null to represent "*"
Parameters:
  name - the given name whether the given name matches the given pattern



toString
public String toString()(Code)

See Also:   java.lang.Object.toString



updateMatchRule
static int updateMatchRule(int matchRule)(Code)
Update deprecated flags if necessary in the given match rule.
Parameters:
  matchRule - The match rule to update The updated match rule with the updated flags



validateMatchRule
public static int validateMatchRule(String stringPattern, int matchRule)(Code)
Validate compatibility between given string pattern and match rule.
Returned match rule is modified, when following combinations are observed in the given parameters:
Rejected (i.e. returned match rule -1) combinations are:
Parameters:
  stringPattern - The string pattern
Parameters:
  matchRule - The match rule Optimized valid match rule or -1 if an incompatibility was detected.
since:
   3.2




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.