/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.tomcat.util.buf;
/** * This class implements some basic ASCII character handling functions. * * @author dac@eng.sun.com * @author James Todd [gonzo@eng.sun.com]
*/ publicfinalclass Ascii { /* * Character translation tables.
*/ privatestaticfinalbyte[] toLower = newbyte[256];
/* * Character type tables.
*/ privatestaticfinalboolean[] isDigit = newboolean[256];
/* * Initialize character translation and type tables.
*/ static { for (int i = 0; i < 256; i++) {
toLower[i] = (byte) i;
}
for (int lc = 'a'; lc <= 'z'; lc++) { int uc = lc + 'A' - 'a';
toLower[uc] = (byte) lc;
}
for (int d = '0'; d <= '9'; d++) {
isDigit[d] = true;
}
}
/** * Returns the lower case equivalent of the specified ASCII character. * * @param c The char * * @return the lower case equivalent char
*/ publicstaticint toLower(int c) { return toLower[c & 0xff] & 0xff;
}
/** * @return <code>true</code> if the specified ASCII character is a digit. * * @param c The char
*/ privatestaticboolean isDigit(int c) { return isDigit[c & 0xff];
}
/** * Parses an unsigned long from the specified subarray of bytes. * * @param b the bytes to parse * @param off the start offset of the bytes * @param len the length of the bytes * * @return the long value * * @exception NumberFormatException if the long format was invalid
*/ publicstaticlong parseLong(byte[] b, int off, int len) throws NumberFormatException { int c;
if (b == null || len <= 0 || !isDigit(c = b[off++])) { thrownew NumberFormatException();
}
long n = c - '0'; while (--len > 0) { if (isDigit(c = b[off++]) && (n < OVERFLOW_LIMIT || (n == OVERFLOW_LIMIT && (c - '0') < 8))) {
n = n * 10 + c - '0';
} else { thrownew NumberFormatException();
}
}
return n;
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.