Home / Function/ readLiteral() — spring-boot Function Reference

readLiteral() — spring-boot Function Reference

Architecture documentation for the readLiteral() function in JSONTokener.java from the spring-boot codebase.

Function java GradlePlugin AotProcessing calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  8089b70b_21e3_f7e1_7641_cc4fd9b7bd5a["readLiteral()"]
  9d280377_39f9_945d_4b0c_8be3562c4bd5["nextValue()"]
  9d280377_39f9_945d_4b0c_8be3562c4bd5 -->|calls| 8089b70b_21e3_f7e1_7641_cc4fd9b7bd5a
  9cbd13f0_7e91_22bb_092a_99b7c304c684["nextToInternal()"]
  8089b70b_21e3_f7e1_7641_cc4fd9b7bd5a -->|calls| 9cbd13f0_7e91_22bb_092a_99b7c304c684
  5d37c1ba_6649_7ef7_7cb2_9bcac45ebb3e["syntaxError()"]
  8089b70b_21e3_f7e1_7641_cc4fd9b7bd5a -->|calls| 5d37c1ba_6649_7ef7_7cb2_9bcac45ebb3e
  style 8089b70b_21e3_f7e1_7641_cc4fd9b7bd5a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

cli/spring-boot-cli/src/json-shade/java/org/springframework/boot/cli/json/JSONTokener.java lines 273–329

	private Object readLiteral() throws JSONException {
		String literal = nextToInternal("{}[]/\\:,=;# \t\f");

		if (literal.isEmpty()) {
			throw syntaxError("Expected literal value");
		}
		else if ("null".equalsIgnoreCase(literal)) {
			return JSONObject.NULL;
		}
		else if ("true".equalsIgnoreCase(literal)) {
			return Boolean.TRUE;
		}
		else if ("false".equalsIgnoreCase(literal)) {
			return Boolean.FALSE;
		}

		/* try to parse as an integral type... */
		if (literal.indexOf('.') == -1) {
			int base = 10;
			String number = literal;
			if (number.startsWith("0x") || number.startsWith("0X")) {
				number = number.substring(2);
				base = 16;
			}
			else if (number.startsWith("0") && number.length() > 1) {
				number = number.substring(1);
				base = 8;
			}
			try {
				long longValue = Long.parseLong(number, base);
				if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
					return (int) longValue;
				}
				else {
					return longValue;
				}
			}
			catch (NumberFormatException e) {
				/*
				 * This only happens for integral numbers greater than Long.MAX_VALUE,
				 * numbers in exponential form (5e-10) and unquoted strings. Fall through
				 * to try floating point.
				 */
			}
		}

		/* ...next try to parse as a floating point... */
		try {
			return Double.valueOf(literal);
		}
		catch (NumberFormatException ex) {
			// Ignore
		}

		/* ... finally give up. We have an unquoted string */
		return new String(literal); // a new string avoids leaking memory
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does readLiteral() do?
readLiteral() is a function in the spring-boot codebase.
What does readLiteral() call?
readLiteral() calls 2 function(s): nextToInternal, syntaxError.
What calls readLiteral()?
readLiteral() is called by 1 function(s): nextValue.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free