Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
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/json/JsonGeneratorImpl.java
package com.fasterxml.jackson.core.json; import java.io.IOException; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.base.GeneratorBase; import com.fasterxml.jackson.core.io.CharTypes; import com.fasterxml.jackson.core.io.CharacterEscapes; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.core.util.JacksonFeatureSet; import com.fasterxml.jackson.core.util.VersionUtil; /** * Intermediate base class shared by JSON-backed generators * like {@link UTF8JsonGenerator} and {@link WriterBasedJsonGenerator}. * * @since 2.1 */ public abstract class JsonGeneratorImpl extends GeneratorBase { /* /********************************************************** /* Constants /********************************************************** */ /** * This is the default set of escape codes, over 7-bit ASCII range * (first 128 character codes), used for single-byte UTF-8 characters. */ protected final static int[] sOutputEscapes = CharTypes.get7BitOutputEscapes(); /** * Default capabilities for JSON generator implementations which do not * different from "general textual" defaults * * @since 2.12 */ protected final static JacksonFeatureSet<StreamWriteCapability> JSON_WRITE_CAPABILITIES = DEFAULT_TEXTUAL_WRITE_CAPABILITIES; /* /********************************************************** /* Configuration, basic I/O /********************************************************** */ protected final IOContext _ioContext; /* /********************************************************** /* Configuration, output escaping /********************************************************** */ /** * Currently active set of output escape code definitions (whether * and how to escape or not) for 7-bit ASCII range (first 128 * character codes). Defined separately to make potentially * customizable */ protected int[] _outputEscapes = sOutputEscapes; /** * Value between 128 (0x80) and 65535 (0xFFFF) that indicates highest * Unicode code point that will not need escaping; or 0 to indicate * that all characters can be represented without escaping. * Typically used to force escaping of some portion of character set; * for example to always escape non-ASCII characters (if value was 127). *<p> * NOTE: not all sub-classes make use of this setting. */ protected int _maximumNonEscapedChar; /** * Definition of custom character escapes to use for generators created * by this factory, if any. If null, standard data format specific * escapes are used. */ protected CharacterEscapes _characterEscapes; /* /********************************************************** /* Configuration, other /********************************************************** */ /** * Separator to use, if any, between root-level values. * * @since 2.1 */ protected SerializableString _rootValueSeparator = DefaultPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR; /** * Flag that is set if quoting is not to be added around * JSON Object property names. * * @since 2.7 */ protected boolean _cfgUnqNames; /** * Write Hex values with uppercase letters * * @since 2.14 */ protected boolean _cfgWriteHexUppercase; /* /********************************************************** /* Life-cycle /********************************************************** */ @SuppressWarnings("deprecation") public JsonGeneratorImpl(IOContext ctxt, int features, ObjectCodec codec) { super(features, codec); _ioContext = ctxt; if (Feature.ESCAPE_NON_ASCII.enabledIn(features)) { // inlined `setHighestNonEscapedChar()` _maximumNonEscapedChar = 127; } _cfgWriteHexUppercase = Feature.WRITE_HEX_UPPER_CASE.enabledIn(features); _cfgUnqNames = !Feature.QUOTE_FIELD_NAMES.enabledIn(features); } /* /********************************************************** /* Versioned /********************************************************** */ @Override public Version version() { return VersionUtil.versionFor(getClass()); } /* /********************************************************** /* Overridden configuration methods /********************************************************** */ @SuppressWarnings("deprecation") @Override public JsonGenerator enable(Feature f) { super.enable(f); if (f == Feature.QUOTE_FIELD_NAMES) { _cfgUnqNames = false; } else if ( f == Feature.WRITE_HEX_UPPER_CASE) { _cfgWriteHexUppercase = true; } return this; } @SuppressWarnings("deprecation") @Override public JsonGenerator disable(Feature f) { super.disable(f); if (f == Feature.QUOTE_FIELD_NAMES) { _cfgUnqNames = true; } else if ( f == Feature.WRITE_HEX_UPPER_CASE) { _cfgWriteHexUppercase = false; } return this; } @SuppressWarnings("deprecation") @Override protected void _checkStdFeatureChanges(int newFeatureFlags, int changedFeatures) { super._checkStdFeatureChanges(newFeatureFlags, changedFeatures); _cfgUnqNames = !Feature.QUOTE_FIELD_NAMES.enabledIn(newFeatureFlags); _cfgWriteHexUppercase = Feature.WRITE_HEX_UPPER_CASE.enabledIn(newFeatureFlags); } @Override public JsonGenerator setHighestNonEscapedChar(int charCode) { _maximumNonEscapedChar = (charCode < 0) ? 0 : charCode; return this; } @Override public int getHighestEscapedChar() { return _maximumNonEscapedChar; } @Override public JsonGenerator setCharacterEscapes(CharacterEscapes esc) { _characterEscapes = esc; if (esc == null) { // revert to standard escapes _outputEscapes = sOutputEscapes; } else { _outputEscapes = esc.getEscapeCodesForAscii(); } return this; } /** * Method for accessing custom escapes factory uses for {@link JsonGenerator}s * it creates. */ @Override public CharacterEscapes getCharacterEscapes() { return _characterEscapes; } @Override public JsonGenerator setRootValueSeparator(SerializableString sep) { _rootValueSeparator = sep; return this; } @Override public JacksonFeatureSet<StreamWriteCapability> getWriteCapabilities() { return JSON_WRITE_CAPABILITIES; } /* /********************************************************** /* Shared helper methods /********************************************************** */ protected void _verifyPrettyValueWrite(String typeMsg, int status) throws IOException { // If we have a pretty printer, it knows what to do: switch (status) { case JsonWriteContext.STATUS_OK_AFTER_COMMA: // array _cfgPrettyPrinter.writeArrayValueSeparator(this); break; case JsonWriteContext.STATUS_OK_AFTER_COLON: _cfgPrettyPrinter.writeObjectFieldValueSeparator(this); break; case JsonWriteContext.STATUS_OK_AFTER_SPACE: _cfgPrettyPrinter.writeRootValueSeparator(this); break; case JsonWriteContext.STATUS_OK_AS_IS: // First entry, but of which context? if (_writeContext.inArray()) { _cfgPrettyPrinter.beforeArrayValues(this); } else if (_writeContext.inObject()) { _cfgPrettyPrinter.beforeObjectEntries(this); } break; case JsonWriteContext.STATUS_EXPECT_NAME: _reportCantWriteValueExpectName(typeMsg); break; default: _throwInternal(); break; } } protected void _reportCantWriteValueExpectName(String typeMsg) throws IOException { _reportError(String.format("Can not %s, expecting field name (context: %s)", typeMsg, _writeContext.typeDesc())); } }
⏎ com/fasterxml/jackson/core/json/JsonGeneratorImpl.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, 57204👍, 1💬
Popular Posts:
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
Where Can I see Java Source Code files for Xerces Java 2.11.2? Here are Java Source Code files for X...
How to read XML document with DTD validation from socket connections with the socket\DelayedInput.ja.. .
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify ex...
How to display XML element type information with the jaxp\TypeInfoWriter.java provided in the Apache...