9 public GString(char c) {
10 char[] str = global new char[1];
15 public GString(String str) {
16 value = global new char[str.count];
17 for(int i =0; i< str.count;i++) {
18 value[i] = str.value[i+str.offset];
24 public GString(GString gstr) {
25 this.value = gstr.value;
26 this.count = gstr.count;
27 this.offset = gstr.offset;
30 public GString(StringBuffer gsb) {
31 value = global new char[gsb.length()];
34 for (int i = 0; i < count; i++)
35 value[i] = gsb.value[i];
38 public GString(char str[]) {
39 char charstr[]=new char[str.length];
40 for(int i=0; i<str.length; i++)
43 this.count=str.length;
47 public static char[] toLocalCharArray(GString str) {
51 length = str.length();
55 for (int i = 0; i < length; i++) {
56 c[i] = str.value[i+str.offset];
61 public String toLocalString() {
62 return new String(toLocalCharArray(this));
69 public int indexOf(int ch, int fromIndex) {
70 for (int i = fromIndex; i < count; i++)
71 if (this.charAt(i) == ch)
76 public int lastindexOf(int ch) {
77 return this.lastindexOf(ch, count - 1);
80 public int lastindexOf(int ch, int fromIndex) {
81 for (int i = fromIndex; i > 0; i--)
82 if (this.charAt(i) == ch)
87 public char charAt(int i) {
88 return value[i+offset];
91 public int indexOf(String str) {
92 return this.indexOf(str, 0);
95 public int indexOf(String str, int fromIndex) {
98 for (int i = fromIndex; i <= (count-str.count); i++)
99 if (regionMatches(i, str, 0, str.count))
104 public boolean regionMatches(int toffset, String other, int ooffset, int len) {
105 if (toffset < 0 || ooffset < 0 || (toffset+len) > count || (ooffset+len) > other.count)
108 for (int i = 0; i < len; i++) {
109 if (other.value[i+other.offset+ooffset] != this.value[i+this.offset+toffset])
115 public String subString(int beginIndex, int endIndex) {
116 return substring(beginIndex, endIndex);
119 public String substring(int beginIndex, int endIndex) {
121 str = global new String();
122 str.value = this.value;
123 str.count = endIndex-beginIndex;
124 str.offset = this.offset + beginIndex;
128 public static String valueOf(Object o) {