Package org.teiid.internal.core.index
Class CharOperation
- java.lang.Object
-
- org.teiid.internal.core.index.CharOperation
-
public final class CharOperation extends Object
This class is a collection of helper methods to manipulate char arrays.- Since:
- 2.1
-
-
Constructor Summary
Constructors Constructor Description CharOperation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
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:
NullPointerException
- if the given name is null or if the given prefix is null
-
-