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 RunTasks calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  2111ccdc_7354_2dd2_52b2_b19e29e21757["readLiteral()"]
  e00d01c8_1ae8_f530_0266_0863c164a433["nextValue()"]
  e00d01c8_1ae8_f530_0266_0863c164a433 -->|calls| 2111ccdc_7354_2dd2_52b2_b19e29e21757
  ed41e77b_e98c_09b8_6212_c2782cdb2cf6["nextToInternal()"]
  2111ccdc_7354_2dd2_52b2_b19e29e21757 -->|calls| ed41e77b_e98c_09b8_6212_c2782cdb2cf6
  424682c6_51c3_cdab_a5b5_25e0f9a6d8eb["syntaxError()"]
  2111ccdc_7354_2dd2_52b2_b19e29e21757 -->|calls| 424682c6_51c3_cdab_a5b5_25e0f9a6d8eb
  style 2111ccdc_7354_2dd2_52b2_b19e29e21757 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

configuration-metadata/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/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