org.foray.common.util
Class CharSequenceUtils

java.lang.Object
  extended by org.foray.common.util.CharSequenceUtils

public final class CharSequenceUtils
extends Object

Utilities related to CharSequence.


Method Summary
static int compareNullTerminated(CharSequence sequence1, int sequence1Start, CharSequence sequence2)
          Compares a null-terminated string in one CharSequence with another one.
static int compareNullTerminated(CharSequence sequence1, int sequence1Start, CharSequence sequence2, int sequence2Start)
          Compares a null-terminated string in one CharSequence with another one.
static int compareNullTerminated(CharSequence sequence1, int sequence1Start, CharSequence sequence2, int sequence2Start, int sequence2End)
          Compares a null-terminated string in one CharSequence with that in another.
static boolean equals(CharSequence sequence1, CharSequence sequence2)
          Compares the content of two character sequences for equality.
static boolean equalToCapitalized(CharSequence normalizedSequence, CharSequence comparisonSequence)
          Compares the content of two character sequences for equivalence, based on the comparison sequence being equal to the title case version of the normalized sequence.
static boolean equalToUppercase(CharSequence normalizedSequence, CharSequence comparisonSequence)
          Compares the content of two character sequences for equivalence based on the comparison sequence being equal to the uppercase version of the normalized sequence.
static int getNullTerminatedLength(CharSequence sequence, int start)
          Returns the size of the null-terminated String starting at a specific location.
static IntArrayBuilder toCodepoints(CharSequence chars, int offset, int length)
          Converts a CharSequence to a sequence of Unicode codepoints.
static IntArrayBuilder toCodepoints(CharSequence chars, int offset, int length, int extraCapacity)
          Converts a CharSequence to a sequence of Unicode codepoints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNullTerminatedLength

public static int getNullTerminatedLength(CharSequence sequence,
                                          int start)
Returns the size of the null-terminated String starting at a specific location.

Parameters:
sequence - The CharSequence being searched.
start - The index to the first character of the String.
Returns:
The number of elements in the array starting with (and including) start through (but not including) the first null terminator found.

compareNullTerminated

public static int compareNullTerminated(CharSequence sequence1,
                                        int sequence1Start,
                                        CharSequence sequence2)
Compares a null-terminated string in one CharSequence with another one.

Parameters:
sequence1 - The first CharSequence being tested.
sequence1Start - The index into sequence1 indicating the first char in it to be tested.
sequence2 - The second CharSequence being tested.
Returns:
Zero if the content of the two arrays (from their start values to the null-termination) are equal. A positive value indicates that the string in this vector has a greater numeric value. A negative value indicates that the string in the comparison array has a greater numeric value.

compareNullTerminated

public static int compareNullTerminated(CharSequence sequence1,
                                        int sequence1Start,
                                        CharSequence sequence2,
                                        int sequence2Start)
Compares a null-terminated string in one CharSequence with another one.

Parameters:
sequence1 - The first CharSequence being tested.
sequence1Start - The index into sequence1 indicating the first char in it to be tested.
sequence2 - The second CharSequence being tested.
sequence2Start - The index into sequence2 indicating the first char in it to be tested.
Returns:
Zero if the content of the two arrays (from their start values to the null-termination) are equal. A positive value indicates that the string in this vector has a greater numeric value. A negative value indicates that the string in the comparison array has a greater numeric value.

compareNullTerminated

public static int compareNullTerminated(CharSequence sequence1,
                                        int sequence1Start,
                                        CharSequence sequence2,
                                        int sequence2Start,
                                        int sequence2End)
Compares a null-terminated string in one CharSequence with that in another.

Parameters:
sequence1 - The first CharSequence being tested.
sequence1Start - The index into sequence1 indicating the first char in it to be tested.
sequence2 - The second CharSequence being tested.
sequence2Start - The index into sequence2 indicating the first char in it to be tested.
sequence2End - The index into sequence2 indicating the first char in it, after sequence2Start, that should NOT be tested.
Returns:
Zero if the content of the two arrays (from their start values to the null-termination) are equal. A positive value indicates that the string in this vector has a greater numeric value. A negative value indicates that the string in the comparison array has a greater numeric value.

equals

public static boolean equals(CharSequence sequence1,
                             CharSequence sequence2)
Compares the content of two character sequences for equality.

Parameters:
sequence1 - The first sequence to be compared.
sequence2 - The second sequence to be compared.
Returns:
True if and only if the two sequences have identical content.

equalToUppercase

public static boolean equalToUppercase(CharSequence normalizedSequence,
                                       CharSequence comparisonSequence)
Compares the content of two character sequences for equivalence based on the comparison sequence being equal to the uppercase version of the normalized sequence.

Parameters:
normalizedSequence - The normalized or base sequence, usually all lowercase.
comparisonSequence - The second sequence to be compared. The test is whether the characters in this sequence are all the capitalized versions of the matching character in normalizedSequence.
Returns:
True if and only if the two sequences are equivalent.

equalToCapitalized

public static boolean equalToCapitalized(CharSequence normalizedSequence,
                                         CharSequence comparisonSequence)
Compares the content of two character sequences for equivalence, based on the comparison sequence being equal to the title case version of the normalized sequence.

Parameters:
normalizedSequence - The normalized or base sequence, usually all lowercase.
comparisonSequence - The second sequence to be compared. The test is whether the characters in this sequence are the title case versions of the matching character in normalizedSequence.
Returns:
True if and only if the two sequences are equivalent.

toCodepoints

public static IntArrayBuilder toCodepoints(CharSequence chars,
                                           int offset,
                                           int length,
                                           int extraCapacity)
Converts a CharSequence to a sequence of Unicode codepoints.

Parameters:
chars - The chars to be converted.
offset - The offset to the first char to be converted.
length - The number of chars to be converted, starting at offset.
extraCapacity - The number of extra bytes of capacity that should be added to the integer array builder when it is created. This is useful in cases where the array may grow after this method completes, and we wish to reduce the number of array copies.
Returns:
The Unicode codepoints.

toCodepoints

public static IntArrayBuilder toCodepoints(CharSequence chars,
                                           int offset,
                                           int length)
Converts a CharSequence to a sequence of Unicode codepoints.

Parameters:
chars - The chars to be converted.
offset - The offset to the first char to be converted.
length - The number of chars to be converted, starting at offset.
Returns:
The Unicode codepoints.


Copyright © 2017. All rights reserved.