TinyLine
v2.0

com.tinyline.tiny2d
Class TinyString

java.lang.Object
  extended bycom.tinyline.tiny2d.TinyString

public final class TinyString
extends java.lang.Object

The TinyString class represents character strings.

Version:
2.0

Author:
Andrew Girow

Field Summary
 int count
          The number of chars in this TinyString object.
 char[] data
          The buffer where the chars of the TinyString are stored.
 
Constructor Summary
TinyString(char[] ac)
          Allocates a new TinyString, so that it has the sequence of characters from the character array argument.
TinyString(char[] ac, int off, int len)
          Allocates a new TinyString, so that it has the sequence of characters from the character subarray argument.
 
Method Summary
static int compareTo(char[] v1, int offset1, int len1, char[] v2, int offset2, int len2)
          Compares two char arrays lexicographically.
 boolean equals(java.lang.Object obj)
          Compares this string to the specified object.
 int hashCode()
          Returns a hashcode for this string.
 int indexOf(int ch, int i)
          Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
 int lastIndexOf(int ch, int i)
          Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

public char[] data
The buffer where the chars of the TinyString are stored.


count

public int count
The number of chars in this TinyString object. The chars are from data[0] through data[count-1].

Constructor Detail

TinyString

public TinyString(char[] ac)
Allocates a new TinyString, so that it has the sequence of characters from the character array argument. The content of the character array 'ac' is copied.

Parameters:
ac - the initial value of the string.

TinyString

public TinyString(char[] ac,
                  int off,
                  int len)
Allocates a new TinyString, so that it has the sequence of characters from the character subarray argument. The content of the character subarray 'ac' is copied.

Parameters:
ac - array that is the source of characters.
off - the initial offset.
len - the length.
Method Detail

indexOf

public int indexOf(int ch,
                   int i)
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

Parameters:
ch - a character.
i - the index to start the search from.
Returns:
the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur.

lastIndexOf

public int lastIndexOf(int ch,
                       int i)
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.

Parameters:
ch - a character.
i - the index to start the search from.
Returns:
the index of the last occurrence of the character in the character sequence represented by this object that is less than or equal to fromIndex, or -1 if the character does not occur before that point.

equals

public boolean equals(java.lang.Object obj)
Compares this string to the specified object. The result is true if and only if the argument is not null and is a TinyString object that represents the same sequence of characters as this object.

Parameters:
obj - the object to compare this String against.
Returns:
true if the TinyString are equal; false otherwise.

hashCode

public int hashCode()
Returns a hashcode for this string.

Returns:
a hash code value for this object.

compareTo

public static int compareTo(char[] v1,
                            int offset1,
                            int len1,
                            char[] v2,
                            int offset2,
                            int len2)
Compares two char arrays lexicographically. The comparison is based on the Unicode value of each character in the arrays.

Returns:
the value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this string is lexicographically greater than the string argument.

TinyLine
v2.0

Provided under the terms of the TinyLine License Agreement that has been included with this distribution