Scripting API

Home Scripting API Index Class Overview

nlvm.lang

Class String


public final class String
extends Object

Represents a character string. Instances of this class are immutable.

Constructor Summary

String()
    Constructs an empty string
String(String value)
    Constructs a copy of value
String(StringBuilder builder)
    Constructs a copy using the content of builder
String(char[] value)
    Constructs a copy of value
String(char[] value, int offset, int count)
    Constructs a copy of value, starting from offset, using count characters


Method Summary

char charAt(int index)
  Returns the character at index
String concat(String str)
  Returns a new string from concatening this and str
bool endsWith(String postfix)
  Returns true if the string ends with postfix
bool equals(Object obj)
  Returns true if obj is a string with the same content as this
int hashCode()
int indexOf(char ch, int fromIndex)
  Returns the index of the first occurance of a character starting from an index
int indexOf(String str, int fromIndex)
  Returns the index of the first occurance of a string starting from an index
int length()
  Returns the number of characters in this string
bool startsWith(String prefix)
  Returns true if the string starts with a prefix
bool startsWith(String prefix, int offset)
  Returns true if the string contains a prefix at the specified index
String substring(int beginIndex)
  Returns a sub string starting from at beginIndex
String substring(int beginIndex, int endIndex)
  Returns a sub string (beginIndex...endIndex-1)
char[] toCharArray()
  Returns a copy of this string as a char array
String toString()
  Trivial implementation of toString(), returns this
static String valueOf(char c)
  Returns a string representation of c
static String valueOf(double d)
  Returns a string representation of d (decimal)
static String valueOf(float f)
  Returns a string representation of f (decimal)
static String valueOf(int n)
  Returns a string representation of n (decimal)
static String valueOf(long l)
  Returns a string representation of l (decimal)
static String valueOf(bool b)
  Returns a string representation of b


Constructor Detail


String

public String()

Constructs an empty string


String

public String(String value)

Constructs a copy of value


String

public String(StringBuilder builder)

Constructs a copy using the content of builder


String

public String(char[] value)

Constructs a copy of value


String

public String(char[] value, int offset, int count)

Constructs a copy of value, starting from offset, using count characters


Method Detail


charAt

public char charAt(int index)

Returns the character at index

index: 0..length()-1


concat

public String concat(String str)

Returns a new string from concatening this and str


endsWith

public bool endsWith(String postfix)

Returns true if the string ends with postfix


equals

public bool equals(Object obj)

Returns true if obj is a string with the same content as this


hashCode

public int hashCode()


indexOf

public int indexOf(char ch, int fromIndex)

Returns the index of the first occurance of a character starting from an index

Parameters:

ch - the character to look for
fromIndex - the starting index

Returns:
    the index of the first occurrence, or -1 of not found

Since:
    2.6.5.6


indexOf

public int indexOf(String str, int fromIndex)

Returns the index of the first occurance of a string starting from an index

Parameters:

str - the string to look for
fromIndex - the starting index

Returns:
    the index of the first occurrence, or -1 of not found

Since:
    2.6.5.6


length

public int length()

Returns the number of characters in this string


startsWith

public bool startsWith(String prefix)

Returns true if the string starts with a prefix

Parameters:

prefix - the prefix

startsWith

public bool startsWith(String prefix, int offset)

Returns true if the string contains a prefix at the specified index

Parameters:

offset - the index in this string where to look for the prefix
prefix - the prefix

Since:
    2.6.5.6


substring

public String substring(int beginIndex)

Returns a sub string starting from at beginIndex


substring

public String substring(int beginIndex, int endIndex)

Returns a sub string (beginIndex...endIndex-1)


toCharArray

public char[] toCharArray()

Returns a copy of this string as a char array


toString

public String toString()

Trivial implementation of toString(), returns this


valueOf

public static String valueOf(char c)

Returns a string representation of c


valueOf

public static String valueOf(double d)

Returns a string representation of d (decimal)


valueOf

public static String valueOf(float f)

Returns a string representation of f (decimal)


valueOf

public static String valueOf(int n)

Returns a string representation of n (decimal)


valueOf

public static String valueOf(long l)

Returns a string representation of l (decimal)


valueOf

public static String valueOf(bool b)

Returns a string representation of b