167
168 int byte_at(int index) const {
169 assert(index >=0 && index < _length, "symbol index overflow");
170 return base()[index];
171 }
172
173 const jbyte* bytes() const { return base(); }
174
175 int utf8_length() const { return _length; }
176
177 // Compares the symbol with a string.
178 bool equals(const char* str, int len) const;
179 bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
180
181 // Tests if the symbol starts with the given prefix.
182 bool starts_with(const char* prefix, int len) const;
183 bool starts_with(const char* prefix) const {
184 return starts_with(prefix, (int) strlen(prefix));
185 }
186
187 // Tests if the symbol starts with the given prefix.
188 int index_of_at(int i, const char* str, int len) const;
189 int index_of_at(int i, const char* str) const {
190 return index_of_at(i, str, (int) strlen(str));
191 }
192
193 // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
194 // note that the ordering is not alfabetical
195 inline int fast_compare(const Symbol* other) const;
196
197 // Returns receiver converted to null-terminated UTF-8 string; string is
198 // allocated in resource area, or in the char buffer provided by caller.
199 char* as_C_string() const;
200 char* as_C_string(char* buf, int size) const;
201 // Use buf if needed buffer length is <= size.
202 char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const;
203
204 // Returns an escaped form of a Java string.
205 char* as_quoted_ascii() const;
206
207 // Returns a null terminated utf8 string in a resource array
|
167
168 int byte_at(int index) const {
169 assert(index >=0 && index < _length, "symbol index overflow");
170 return base()[index];
171 }
172
173 const jbyte* bytes() const { return base(); }
174
175 int utf8_length() const { return _length; }
176
177 // Compares the symbol with a string.
178 bool equals(const char* str, int len) const;
179 bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
180
181 // Tests if the symbol starts with the given prefix.
182 bool starts_with(const char* prefix, int len) const;
183 bool starts_with(const char* prefix) const {
184 return starts_with(prefix, (int) strlen(prefix));
185 }
186
187 // Tests if the symbol ends with the given suffix.
188 bool ends_with(const char* suffix, int len) const;
189 bool ends_with(const char* suffix) const {
190 return ends_with(suffix, (int) strlen(suffix));
191 }
192
193 // Returns index of the given substring in the symbol, starting
194 // at index 'i'.
195 // If the symbol doesn't contain the given substring, return -1.
196 int index_of_at(int i, const char* str, int len) const;
197 int index_of_at(int i, const char* str) const {
198 return index_of_at(i, str, (int) strlen(str));
199 }
200
201 // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
202 // note that the ordering is not alfabetical
203 inline int fast_compare(const Symbol* other) const;
204
205 // Returns receiver converted to null-terminated UTF-8 string; string is
206 // allocated in resource area, or in the char buffer provided by caller.
207 char* as_C_string() const;
208 char* as_C_string(char* buf, int size) const;
209 // Use buf if needed buffer length is <= size.
210 char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const;
211
212 // Returns an escaped form of a Java string.
213 char* as_quoted_ascii() const;
214
215 // Returns a null terminated utf8 string in a resource array
|