/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** Utility class for static conversion methods between numbers
* and strings in various formats.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class Convert {
/** Convert string to integer.
*/
throws NumberFormatException {
if (radix == 10) {
} else {
char[] cs = s.toCharArray();
int n = 0;
if (n < 0 ||
n > limit ||
throw new NumberFormatException();
n = n * radix + d;
}
return n;
}
}
/** Convert string to long integer.
*/
throws NumberFormatException {
if (radix == 10) {
} else {
char[] cs = s.toCharArray();
long n = 0;
if (n < 0 ||
n > limit ||
throw new NumberFormatException();
n = n * radix + d;
}
return n;
}
}
/* Conversion routines between names, strings, and byte arrays in Utf8 format
*/
/** Convert `len' bytes from utf8 to characters.
* Parameters are as in System.arraycopy
* Return first index in `dst' past the last copied char.
* @param src The array holding the bytes to convert.
* @param sindex The start index from which bytes are converted.
* @param dst The array holding the converted characters..
* @param dindex The start index from which converted characters
* are written.
* @param len The maximum number of bytes to convert.
*/
int len) {
int i = sindex;
int j = dindex;
while (i < limit) {
int b = src[i++] & 0xFF;
if (b >= 0xE0) {
b = (b & 0x0F) << 12;
b = b | (src[i++] & 0x3F);
} else if (b >= 0xC0) {
b = (b & 0x1F) << 6;
b = b | (src[i++] & 0x3F);
}
dst[j++] = (char)b;
}
return j;
}
/** Return bytes in Utf8 representation as an array of characters.
* @param src The array holding the bytes.
* @param sindex The start index from which bytes are converted.
* @param len The maximum number of bytes to convert.
*/
return result;
}
/** Return all bytes of a given array in Utf8 representation
* as an array of characters.
* @param src The array holding the bytes.
*/
}
/** Return bytes in Utf8 representation as a string.
* @param src The array holding the bytes.
* @param sindex The start index from which bytes are converted.
* @param len The maximum number of bytes to convert.
*/
}
/** Return all bytes of a given array in Utf8 representation
* as a string.
* @param src The array holding the bytes.
*/
}
/** Copy characters in source array to bytes in target array,
* converting them to Utf8 representation.
* The target array must be large enough to hold the result.
* returns first index in `dst' past the last copied byte.
* @param src The array holding the characters to convert.
* @param sindex The start index from which characters are converted.
* @param dst The array holding the converted characters..
* @param dindex The start index from which converted bytes
* are written.
* @param len The maximum number of characters to convert.
*/
int len) {
int j = dindex;
} else if (ch <= 0x7FF) {
} else {
}
}
return j;
}
/** Return characters as an array of bytes in Utf8 representation.
* @param src The array holding the characters.
* @param sindex The start index from which characters are converted.
* @param len The maximum number of characters to convert.
*/
return result;
}
/** Return all characters in given array as an array of bytes
* in Utf8 representation.
* @param src The array holding the characters.
*/
}
/** Return string as an array of bytes in in Utf8 representation.
*/
return chars2utf(s.toCharArray());
}
/**
* Escapes each character in a string that has an escape sequence or
* is non-printable ASCII. Leaves non-ASCII characters alone.
*/
for (int i = 0; i < s.length(); i++) {
}
}
/**
* Escapes a character if it has an escape sequence or is
* non-printable ASCII. Leaves non-ASCII characters alone.
*/
switch (ch) {
case '\b': return "\\b";
case '\f': return "\\f";
case '\n': return "\\n";
case '\r': return "\\r";
case '\t': return "\\t";
case '\'': return "\\'";
case '\"': return "\\\"";
case '\\': return "\\\\";
default:
return (isPrintableAscii(ch))
}
}
/**
* Is a character printable ASCII?
*/
}
/** Escape all unicode characters in string.
*/
int i = 0;
while (i < len) {
if (ch > 255) {
while (i < len) {
if (ch > 255) {
} else {
}
i++;
}
} else {
i++;
}
}
return s;
}
/* Conversion routines for qualified name splitting
*/
/** Return the last part of a class name.
*/
}
}
/** Return the package name of a class name, excluding the trailing '.',
* "" if not existent.
*/
}
}
int index;
}
return names;
}
}