java.lang
Class String

java.lang.Object
  extended byjava.lang.String

public final class String
extends Object

String is an array of characters.

As with all classes in the ewe.lang package, you can't reference the String class using the full specifier of ewe.lang.String. The ewe.lang package is implicitly imported. Instead, you should simply access the String class like this:

 String s = new String("Hello");
 


Constructor Summary
String()
          Creates an empty string.
String(byte[] utf8Bytes)
           
String(byte[] utf8Bytes, int start, int length)
           
String(char[] c)
          Creates a string from the given character array.
String(char[] c, int offset, int count)
          Creates a string from a portion of the given character array.
String(String s)
          Creates a copy of the given string.
String(StringBuffer buffer)
           
 
Method Summary
 char charAt(int i)
          Returns the character at the given position.
 int compareTo(String other)
           
 String concat(String s)
          Concatenates the given string to this string and returns the result.
static String copyValueOf(char[] data)
           
static String copyValueOf(char[] data, int start, int length)
           
 boolean endsWith(String other)
           
 boolean equals(Object obj)
          Returns if this object is considered equal to the other object.
 boolean equalsIgnoreCase(String other)
           
 byte[] getBytes()
          Convert the characters into bytes according to the default enocoding format.
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
           
 int hashCode()
          Returns a hashCode for the object.
 int indexOf(int ch)
           
 int indexOf(int ch, int start)
           
 int indexOf(String other)
           
 int indexOf(String other, int start)
           
 int lastIndexOf(int ch)
           
 int lastIndexOf(int ch, int start)
           
 int lastIndexOf(String other)
           
 int lastIndexOf(String other, int start)
           
 int length()
          Returns the length of the string in characters.
 boolean regionMatches(boolean ignoreCase, int toffset, String other, int oofset, int len)
           
 boolean regionMatches(int toffset, String other, int oofset, int len)
           
 String replace(char oldChar, char newChar)
           
 boolean startsWith(String prefix)
          Returns true if the given string is equal to this string and false otherwise.
 boolean startsWith(String prefix, int offset)
           
 String substring(int start)
          Get a substring from the specified index to the end of the string.
 String substring(int start, int end)
          Returns a substring of the string.
 char[] toCharArray()
          Returns this string as a character array.
 String toLowerCase()
           
 String toString()
          Returns this string.
 String toUpperCase()
           
 String trim()
           
static String valueOf(boolean b)
          Converts the given boolean to a String.
static String valueOf(char c)
          Converts the given char to a String.
static String valueOf(char[] data)
           
static String valueOf(char[] data, int start, int length)
           
static String valueOf(double d)
           
static String valueOf(float f)
          Converts the given float to a String.
static String valueOf(int i)
          Converts the given int to a String.
static String valueOf(long l)
           
static String valueOf(Object obj)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass
 

Constructor Detail

String

public String()
Creates an empty string.


String

public String(String s)
Creates a copy of the given string.


String

public String(char[] c)
Creates a string from the given character array.


String

public String(char[] c,
              int offset,
              int count)
Creates a string from a portion of the given character array.

Parameters:
c - the character array
offset - the position of the first character in the array
count - the number of characters

String

public String(byte[] utf8Bytes)

String

public String(byte[] utf8Bytes,
              int start,
              int length)

String

public String(StringBuffer buffer)
Method Detail

length

public int length()
Returns the length of the string in characters.


charAt

public char charAt(int i)
Returns the character at the given position.


concat

public String concat(String s)
Concatenates the given string to this string and returns the result.


toCharArray

public char[] toCharArray()
Returns this string as a character array. The array returned is allocated by this method and is a copy of the string's internal character array.


getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)

copyValueOf

public static String copyValueOf(char[] data,
                                 int start,
                                 int length)

copyValueOf

public static String copyValueOf(char[] data)

valueOf

public static String valueOf(char[] data)

valueOf

public static String valueOf(char[] data,
                             int start,
                             int length)

valueOf

public static String valueOf(boolean b)
Converts the given boolean to a String.


valueOf

public static String valueOf(char c)
Converts the given char to a String.


valueOf

public static String valueOf(int i)
Converts the given int to a String.


valueOf

public static String valueOf(float f)
Converts the given float to a String.


valueOf

public static String valueOf(double d)

valueOf

public static String valueOf(long l)

valueOf

public static String valueOf(Object obj)

toString

public String toString()
Returns this string.

Overrides:
toString in class Object
Returns:
a String representing this object.

substring

public String substring(int start,
                        int end)
Returns a substring of the string. The start value is included but the end value is not. That is, if you call:
 string.substring(4, 6);
 
a string created from characters 4 and 5 will be returned.

Parameters:
start - the first character of the substring
end - the character after the last character of the substring

substring

public String substring(int start)
Get a substring from the specified index to the end of the string.


startsWith

public boolean startsWith(String prefix)
Returns true if the given string is equal to this string and false otherwise. If the object passed is not a string, false is returned.


startsWith

public boolean startsWith(String prefix,
                          int offset)

replace

public String replace(char oldChar,
                      char newChar)

equals

public boolean equals(Object obj)
Description copied from class: Object
Returns if this object is considered equal to the other object.

Overrides:
equals in class Object
Parameters:
obj - Another object to compare to.
Returns:
true if this object is considered equal to the other object.

equalsIgnoreCase

public boolean equalsIgnoreCase(String other)

endsWith

public boolean endsWith(String other)

indexOf

public int indexOf(String other)

indexOf

public int indexOf(String other,
                   int start)

lastIndexOf

public int lastIndexOf(String other)

lastIndexOf

public int lastIndexOf(String other,
                       int start)

indexOf

public int indexOf(int ch)

indexOf

public int indexOf(int ch,
                   int start)

lastIndexOf

public int lastIndexOf(int ch)

lastIndexOf

public int lastIndexOf(int ch,
                       int start)

compareTo

public int compareTo(String other)

trim

public String trim()

toUpperCase

public String toUpperCase()

toLowerCase

public String toLowerCase()

hashCode

public int hashCode()
Description copied from class: Object
Returns a hashCode for the object. The general contract of hashCode is:
  • An object must return the same hash code for its entire existence.
  • If two objects are considered equal by the equals() method, they should return the same hash code. Not all Objects will do this and you should only use hashCode() from Objects which declare an overrided version of hashCode(). The only Objects which provide consistent and correct hash codes under Ewe are Object, String and Class.

    Overrides:
    hashCode in class Object

  • regionMatches

    public boolean regionMatches(boolean ignoreCase,
                                 int toffset,
                                 String other,
                                 int oofset,
                                 int len)

    regionMatches

    public boolean regionMatches(int toffset,
                                 String other,
                                 int oofset,
                                 int len)

    getBytes

    public byte[] getBytes()
    Convert the characters into bytes according to the default enocoding format. Under a native Ewe VM this will be UTF8 encoding.

    Returns:
    an array of bytes representing the String.