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;
31 public GString(StringBuffer gsb) {
32 value = global new char[gsb.length()];
35 for (int i = 0; i < count; i++)
36 value[i] = gsb.value[i];
40 public GString(char str[]) {
41 char charstr[]=new char[str.length];
42 for(int i=0; i<str.length; i++)
45 this.count=str.length;
49 public static char[] toLocalCharArray(GString str) {
53 length = str.length();
57 for (int i = 0; i < length; i++) {
58 c[i] = str.value[i+str.offset];
63 public String toLocalString() {
64 return new String(toLocalCharArray(this));
71 public int indexOf(int ch, int fromIndex) {
72 for (int i = fromIndex; i < count; i++)
73 if (this.charAt(i) == ch)
78 public int lastindexOf(int ch) {
79 return this.lastindexOf(ch, count - 1);
82 public int lastindexOf(int ch, int fromIndex) {
83 for (int i = fromIndex; i > 0; i--)
84 if (this.charAt(i) == ch)
89 public char charAt(int i) {
90 return value[i+offset];
93 public int indexOf(String str) {
94 return this.indexOf(str, 0);
97 public int indexOf(String str, int fromIndex) {
100 for (int i = fromIndex; i <= (count-str.count); i++)
101 if (regionMatches(i, str, 0, str.count))
106 public boolean regionMatches(int toffset, String other, int ooffset, int len) {
107 if (toffset < 0 || ooffset < 0 || (toffset+len) > count || (ooffset+len) > other.count)
110 for (int i = 0; i < len; i++) {
111 if (other.value[i+other.offset+ooffset] != this.value[i+this.offset+toffset])
117 public String subString(int beginIndex, int endIndex) {
118 return substring(beginIndex, endIndex);
121 public String substring(int beginIndex, int endIndex) {
123 str = global new String();
124 str.value = this.value;
125 str.count = endIndex-beginIndex;
126 str.offset = this.offset + beginIndex;
130 public static String valueOf(Object o) {
137 public String toLocalString() {
138 return new String(toLocalCharArray(this));
141 public static char[] toLocalCharArray(GString str) {
144 length = str.length();
145 c = new char[length];
146 for (int i = 0; i < length; i++) {
147 c[i] = str.value[i+str.offset];
152 public int hashCode() {
153 String s = this.toLocalString();
157 public boolean equals(Object o) {
160 if(!(o instanceof GString))
162 GString gs = (GString)o;
163 String s1 = gs.toLocalString();
164 String s2 = this.toLocalString();