5 private int cachedHashcode;
10 public String(char str[]) {
11 char charstr[]=new char[str.length];
12 for(int i=0;i<str.length;i++)
15 this.count=str.length;
19 public String(byte str[]) {
20 char charstr[]=new char[str.length];
21 for(int i=0;i<str.length;i++)
22 charstr[i]=(char)str[i];
24 this.count=str.length;
28 public String(String str) {
31 this.offset=str.offset;
34 public String(StringBuffer strbuf) {
35 value=new char[strbuf.length()];
36 count=strbuf.length();
38 for(int i=0;i<count;i++)
39 value[i]=strbuf.value[i];
42 public String subString(int beginIndex, int endIndex) {
43 String str=new String();
44 if (beginIndex>this.count||endIndex>this.count||beginIndex>endIndex) {
48 str.count=endIndex-beginIndex;
49 str.offset=this.offset+beginIndex;
53 public String subString(int beginIndex) {
54 return this.subString(beginIndex, this.count);
57 public int indexOf(int ch) {
58 return this.indexOf(ch, 0);
61 public int indexOf(int ch, int fromIndex) {
62 for(int i=fromIndex;i<count;i++)
63 if (this.charAt(i)==ch)
68 public int indexOf(String str) {
69 return this.indexOf(str, 0);
72 public int indexOf(String str, int fromIndex) {
75 for(int i=fromIndex;i<=(count-str.count);i++)
76 if (regionMatches(i, str, 0, str.count))
81 public boolean startsWith(String str) {
82 return regionMatches(0, str, 0, str.count);
85 public boolean regionMatches(int toffset, String other, int ooffset, int len) {
86 if (toffset<0 || ooffset <0 || (toffset+len)>count || (ooffset+len)>other.count)
88 for(int i=0;i<len;i++)
89 if (other.value[i+other.offset+ooffset]!=
90 this.value[i+this.offset+toffset])
95 public char[] toCharArray() {
96 char str[]=new char[count];
97 for(int i=0;i<count;i++)
98 str[i]=value[i+offset];
102 public byte[] getBytes() {
103 byte str[]=new byte[count];
104 for(int i=0;i<count;i++)
105 str[i]=(byte)value[i+offset];
109 public int length() {
113 public char charAt(int i) {
114 return value[i+offset];
117 public String toString() {
121 public static String valueOf(Object o) {
125 public static String valueOf(int x) {
139 chararray=new char[length+1];
141 chararray=new char[length];
151 chararray[--length+voffset]=(char)(x%10+'0');
154 return new String(chararray);
157 public int hashCode() {
158 if (cachedHashcode!=0)
159 return cachedHashcode;
161 for(int i=0;i<count;i++)
162 hashcode=hashcode*31+value[i+offset];
163 cachedHashcode=hashcode;
167 public boolean equals(Object o) {
168 if (o.getType()!=getType())
173 for(int i=0;i<count;i++) {
174 if (s.value[i+s.offset]!=value[i+offset])