org.teiid.metadata.index
Class CharOperation
java.lang.Object
org.teiid.metadata.index.CharOperation
public final class CharOperation
- extends java.lang.Object
This class is a collection of helper methods to manipulate char arrays.
- Since:
- 2.1
Method Summary |
static boolean |
match(char[] pattern,
char[] name,
boolean isCaseSensitive)
Answers true if the pattern matches the given name, false otherwise. |
static boolean |
prefixEquals(char[] prefix,
char[] name,
boolean isCaseSensitive)
Answers true if the given name starts with the given prefix, false otherwise. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CharOperation
public CharOperation()
match
public static final boolean match(char[] pattern,
char[] name,
boolean isCaseSensitive)
- Answers true if the pattern matches the given name, false otherwise. This
char[] pattern matching accepts wild-cards '*' and '?'.
When not case sensitive, the pattern is assumed to already be lowercased,
the name will be lowercased character per character as comparing. If name
is null, the answer is false. If pattern is null, the answer is true if
name is not null.
For example:
-
pattern = { '?', 'b', '*' }
name = { 'a', 'b', 'c' , 'd' }
isCaseSensitive = true
result => true
-
pattern = { '?', 'b', '?' }
name = { 'a', 'b', 'c' , 'd' }
isCaseSensitive = true
result => false
-
pattern = { 'b', '*' }
name = { 'a', 'b', 'c' , 'd' }
isCaseSensitive = true
result => false
- Parameters:
pattern
- the given patternname
- the given nameisCaseSensitive
- flag to know whether or not the matching should be case
sensitive
- Returns:
- true if the pattern matches the given name, false otherwise
TODO: this code was derived from eclipse CharOperation.
It also lacks the ability to specify an escape character.
prefixEquals
public static final boolean prefixEquals(char[] prefix,
char[] name,
boolean isCaseSensitive)
- Answers true if the given name starts with the given prefix, false otherwise.
isCaseSensitive is used to find out whether or not the comparison should be case sensitive.
For example:
prefix = { 'a' , 'B' }
name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
isCaseSensitive = false
result => true
prefix = { 'a' , 'B' }
name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
isCaseSensitive = true
result => false
- Parameters:
prefix
- the given prefixname
- the given nameisCaseSensitive
- to find out whether or not the comparison should be case sensitive
- Returns:
- true if the given name starts with the given prefix, false otherwise
- Throws:
java.lang.NullPointerException
- if the given name is null or if the given prefix is null
Copyright © 2009. All Rights Reserved.