org.aspectj.org.eclipse.jdt.internal.core.search
Class StringOperation

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.search.StringOperation

public final class StringOperation
extends java.lang.Object

This class is a collection of helper methods to manipulate strings during search.


Constructor Summary
StringOperation()
           
 
Method Summary
static int[] getCamelCaseMatchingRegions(java.lang.String pattern, int patternStart, int patternEnd, java.lang.String name, int nameStart, int nameEnd, boolean samePartCount)
          Answers all the regions in a given name matching a given camel case pattern.
static int[] getPatternMatchingRegions(java.lang.String pattern, int patternStart, int patternEnd, java.lang.String name, int nameStart, int nameEnd, boolean isCaseSensitive)
          Answers all the regions in a given name matching a given pattern pattern (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringOperation

public StringOperation()
Method Detail

getCamelCaseMatchingRegions

public static final int[] getCamelCaseMatchingRegions(java.lang.String pattern,
                                                      int patternStart,
                                                      int patternEnd,
                                                      java.lang.String name,
                                                      int nameStart,
                                                      int nameEnd,
                                                      boolean samePartCount)
Answers all the regions in a given name matching a given camel case pattern.

Each of these regions is made of its starting index and its length in the given name. They are all concatenated in a single array of int which therefore always has an even length.

Note that each region is disjointed from the following one.
E.g. if the regions are { start1, length1, start2, length2 }, then start1+length1 will always be smaller than start2.

 Examples:
 
  1. pattern = "NPE" name = NullPointerException / NoPermissionException result: { 0, 1, 4, 1, 11, 1 } / { 0, 1, 2, 1, 12, 1 }
  2. pattern = "NuPoEx" name = NullPointerException result: { 0, 2, 4, 2, 11, 2 }
  3. pattern = "IPL3" name = "IPerspectiveListener3" result: { 0, 2, 12, 1, 20, 1 }
  4. pattern = "HashME" name = "HashMapEntry" result: { 0, 5, 7, 1 }

Parameters:
pattern - the given pattern
patternStart - the start index of the pattern, inclusive
patternEnd - the end index of the pattern, exclusive
name - the given name
nameStart - the start index of the name, inclusive
nameEnd - the end index of the name, exclusive
samePartCount - flag telling whether the pattern and the name should have the same count of parts or not.
  For example:
  • 'HM' type string pattern will match 'HashMap' and 'HtmlMapper' types, but not 'HashMapEntry'
  • 'HMap' type string pattern will still match previous 'HashMap' and 'HtmlMapper' types, but not 'HighMagnitude'
Returns:
an array of int having two slots per returned regions (first one is the starting index of the region and the second one the length of the region).
Note that it may be null if the given name does not match the pattern
Since:
3.5
See Also:
for more details on the camel case behavior, for more details on the pattern match behavior

getPatternMatchingRegions

public static final int[] getPatternMatchingRegions(java.lang.String pattern,
                                                    int patternStart,
                                                    int patternEnd,
                                                    java.lang.String name,
                                                    int nameStart,
                                                    int nameEnd,
                                                    boolean isCaseSensitive)
Answers all the regions in a given name matching a given pattern pattern (e.g. "H*M??").

Each of these regions is made of its starting index and its length in the given name. They are all concatenated in a single array of int which therefore always has an even length.

Note that each region is disjointed from the following one.
E.g. if the regions are { start1, length1, start2, length2 }, then start1+length1 will always be smaller than start2.

 Examples:
 
  1. pattern = "N???Po*Ex?eption" name = NullPointerException result: { 0, 1, 4, 2, 11, 2, 14, 6 }
  2. pattern = "Ha*M*ent*" name = "HashMapEntry" result: { 0, 2, 4, 1, 7, 3 }

Parameters:
pattern - the given pattern
patternStart - the given pattern start
patternEnd - the given pattern end
name - the given name
nameStart - the given name start
nameEnd - the given name end
isCaseSensitive - flag to know if the matching should be case sensitive
Returns:
an array of int having two slots per returned regions (first one is the starting index of the region and the second one the length of the region).
Note that it may be null if the given name does not match the pattern
Since:
3.5
See Also:
for more details on the pattern match behavior