Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Jackson Core Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson Core Source Code files are provided in the source packge (jackson-core-2.14.0-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Core Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/core/io/doubleparser/FastFloatParser.java
/**
* References:
* <dl>
* <dt>This class has been derived from "FastDoubleParser".</dt>
* <dd>Copyright (c) Werner Randelshofer. Apache 2.0 License.
* <a href="https://github.com/wrandelshofer/FastDoubleParser">github.com</a>.</dd>
* </dl>
*/
package com.fasterxml.jackson.core.io.doubleparser;
/**
* Provides static method for parsing a {@code float} from a
* {@link CharSequence}, {@code char} array or {@code byte} array.
*/
public class FastFloatParser {
/**
* Don't let anyone instantiate this class.
*/
private FastFloatParser() {
}
/**
* Convenience method for calling {@link #parseFloat(CharSequence, int, int)}.
*
* @param str the string to be parsed
* @return the parsed value
* @throws NumberFormatException if the string can not be parsed
*/
public static float parseFloat(CharSequence str) throws NumberFormatException {
return parseFloat(str, 0, str.length());
}
/**
* Parses a {@code FloatingPointLiteral} from a {@link CharSequence} and converts it
* into a {@code float} value.
* <p>
* See {@link com.fasterxml.jackson.core.io.doubleparser} for the syntax of {@code FloatingPointLiteral}.
*
* @param str the string to be parsed
* @param offset the start offset of the {@code FloatingPointLiteral} in {@code str}
* @param length the length of {@code FloatingPointLiteral} in {@code str}
* @return the parsed value
* @throws NumberFormatException if the string can not be parsed
*/
public static float parseFloat(CharSequence str, int offset, int length) throws NumberFormatException {
long bitPattern = new FloatBitsFromCharSequence().parseFloatingPointLiteral(str, offset, length);
if (bitPattern == AbstractFloatValueParser.PARSE_ERROR) {
throw new NumberFormatException("Illegal input");
}
return Float.intBitsToFloat((int) bitPattern);
}
/**
* Convenience method for calling {@link #parseFloat(char[], int, int)}.
*
* @param str the string to be parsed
* @return the parsed value
* @throws NumberFormatException if the string can not be parsed
*/
public static float parseFloat(char[] str) throws NumberFormatException {
return parseFloat(str, 0, str.length);
}
/**
* Parses a {@code FloatingPointLiteral} from a {@code byte}-Array and converts it
* into a {@code float} value.
* <p>
* See {@link com.fasterxml.jackson.core.io.doubleparser} for the syntax of {@code FloatingPointLiteral}.
*
* @param str the string to be parsed, a byte array with characters
* in ISO-8859-1, ASCII or UTF-8 encoding
* @param offset The index of the first character to parse
* @param length The number of characters to parse
* @return the parsed value
* @throws NumberFormatException if the string can not be parsed
*/
public static float parseFloat(char[] str, int offset, int length) throws NumberFormatException {
long bitPattern = new FloatBitsFromCharArray().parseFloatingPointLiteral(str, offset, length);
if (bitPattern == AbstractFloatValueParser.PARSE_ERROR) {
throw new NumberFormatException("Illegal input");
}
return Float.intBitsToFloat((int) bitPattern);
}
/**
* Parses a {@code FloatingPointLiteral} from a {@link CharSequence} and converts it
* into a bit pattern that encodes a {@code float} value.
* <p>
* See {@link com.fasterxml.jackson.core.io.doubleparser} for the syntax of {@code FloatingPointLiteral}.
* <p>
* Usage example:
* <pre>
* long bitPattern = parseFloatBits("3.14", 0, 4);
* if (bitPattern == -1L) {
* ...handle parse error...
* } else {
* double d = Double.longBitsToDouble(bitPattern);
* }
* </pre>
*
* @param str the string to be parsed
* @param offset the start offset of the {@code FloatingPointLiteral} in {@code str}
* @param length the length of {@code FloatingPointLiteral} in {@code str}
* @return the bit pattern of the parsed value, if the input is legal;
* otherwise, {@code -1L}.
*/
public static long parseFloatBits(CharSequence str, int offset, int length) {
return new FloatBitsFromCharSequence().parseFloatingPointLiteral(str, offset, length);
}
/**
* Parses a {@code FloatingPointLiteral} from a {@code byte}-Array and converts it
* into a bit pattern that encodes a {@code float} value.
* <p>
* See {@link com.fasterxml.jackson.core.io.doubleparser} for the syntax of {@code FloatingPointLiteral}.
* <p>
* See {@link #parseFloatBits(CharSequence, int, int)} for a usage example.
*
* @param str the string to be parsed, a byte array with characters
* in ISO-8859-1, ASCII or UTF-8 encoding
* @param offset The index of the first character to parse
* @param length The number of characters to parse
* @return the bit pattern of the parsed value, if the input is legal;
* otherwise, {@code -1L}.
*/
public static long parseFloatBits(char[] str, int offset, int length) {
return new FloatBitsFromCharArray().parseFloatingPointLiteral(str, offset, length);
}
}⏎ com/fasterxml/jackson/core/io/doubleparser/FastFloatParser.java
Or download all of them as a single archive file:
File name: jackson-core-2.14.0-sources.jar File size: 497693 bytes Release date: 2022-11-05 Download
⇒ Download and Install Jackson Binary Package
2016-02-03, ≈85🔥, 1💬
Popular Posts:
Jetty provides an HTTP server, HTTP client, and javax.servlet container. These components are open s...
How to read XML document from socket connections with the socket\DelayedInput.java provided in the A...
Where to get the Java source code for Connector/J 8.0 Core API module? Java source code files for Co...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
What Is jtds-1.2.2.jar? jtds-1.2.2.jar is the JAR files of jTDS Java library 1.2.2, which is a JDBC ...