// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.fasterxml.jackson.core; import com.fasterxml.jackson.core.format.InputAccessor; import com.fasterxml.jackson.core.format.MatchStrength; import com.fasterxml.jackson.core.io.CharacterEscapes; import com.fasterxml.jackson.core.io.IOContext; import com.fasterxml.jackson.core.io.InputDecorator; import com.fasterxml.jackson.core.io.OutputDecorator; import com.fasterxml.jackson.core.io.SerializedString; import com.fasterxml.jackson.core.io.UTF8Writer; import com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper; import com.fasterxml.jackson.core.json.PackageVersion; import com.fasterxml.jackson.core.json.ReaderBasedJsonParser; import com.fasterxml.jackson.core.json.UTF8JsonGenerator; import com.fasterxml.jackson.core.json.WriterBasedJsonGenerator; import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer; import com.fasterxml.jackson.core.sym.BytesToNameCanonicalizer; import com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer; import com.fasterxml.jackson.core.util.BufferRecycler; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import java.io.CharArrayReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Serializable; import java.io.StringReader; import java.io.Writer; import java.lang.ref.SoftReference; import java.net.URL; // Referenced classes of package com.fasterxml.jackson.core: // Versioned, JsonEncoding, FormatSchema, JsonParseException, // SerializableString, ObjectCodec, JsonGenerator, JsonParser, // Version public class JsonFactory implements Versioned, Serializable { public static final class Feature extends Enum { private static final Feature $VALUES[]; public static final Feature CANONICALIZE_FIELD_NAMES; public static final Feature FAIL_ON_SYMBOL_HASH_OVERFLOW; public static final Feature INTERN_FIELD_NAMES; public static final Feature USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING; private final boolean _defaultState; public static int collectDefaults() { int j = 0; Feature afeature[] = values(); int l = afeature.length; for (int i = 0; i < l;) { Feature feature = afeature[i]; int k = j; if (feature.enabledByDefault()) { k = j | feature.getMask(); } i++; j = k; } return j; } public static Feature valueOf(String s) { return (Feature)Enum.valueOf(com/fasterxml/jackson/core/JsonFactory$Feature, s); } public static Feature[] values() { return (Feature[])$VALUES.clone(); } public boolean enabledByDefault() { return _defaultState; } public boolean enabledIn(int i) { return (getMask() & i) != 0; } public int getMask() { return 1 << ordinal(); } static { INTERN_FIELD_NAMES = new Feature("INTERN_FIELD_NAMES", 0, true); CANONICALIZE_FIELD_NAMES = new Feature("CANONICALIZE_FIELD_NAMES", 1, true); FAIL_ON_SYMBOL_HASH_OVERFLOW = new Feature("FAIL_ON_SYMBOL_HASH_OVERFLOW", 2, true); USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING = new Feature("USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING", 3, true); $VALUES = (new Feature[] { INTERN_FIELD_NAMES, CANONICALIZE_FIELD_NAMES, FAIL_ON_SYMBOL_HASH_OVERFLOW, USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING }); } private Feature(String s, int i, boolean flag) { super(s, i); _defaultState = flag; } } protected static final int DEFAULT_FACTORY_FEATURE_FLAGS = Feature.collectDefaults(); protected static final int DEFAULT_GENERATOR_FEATURE_FLAGS = JsonGenerator.Feature.collectDefaults(); protected static final int DEFAULT_PARSER_FEATURE_FLAGS = JsonParser.Feature.collectDefaults(); private static final SerializableString DEFAULT_ROOT_VALUE_SEPARATOR; public static final String FORMAT_NAME_JSON = "JSON"; protected static final ThreadLocal _recyclerRef = new ThreadLocal(); private static final long serialVersionUID = 1L; protected final transient ByteQuadsCanonicalizer _byteSymbolCanonicalizer; protected CharacterEscapes _characterEscapes; protected int _factoryFeatures; protected int _generatorFeatures; protected InputDecorator _inputDecorator; protected ObjectCodec _objectCodec; protected OutputDecorator _outputDecorator; protected int _parserFeatures; protected final transient BytesToNameCanonicalizer _rootByteSymbols; protected final transient CharsToNameCanonicalizer _rootCharSymbols; protected SerializableString _rootValueSeparator; public JsonFactory() { this(null); } protected JsonFactory(JsonFactory jsonfactory, ObjectCodec objectcodec) { _rootCharSymbols = CharsToNameCanonicalizer.createRoot(); _byteSymbolCanonicalizer = ByteQuadsCanonicalizer.createRoot(); _rootByteSymbols = BytesToNameCanonicalizer.createRoot(); _factoryFeatures = DEFAULT_FACTORY_FEATURE_FLAGS; _parserFeatures = DEFAULT_PARSER_FEATURE_FLAGS; _generatorFeatures = DEFAULT_GENERATOR_FEATURE_FLAGS; _rootValueSeparator = DEFAULT_ROOT_VALUE_SEPARATOR; _objectCodec = null; _factoryFeatures = jsonfactory._factoryFeatures; _parserFeatures = jsonfactory._parserFeatures; _generatorFeatures = jsonfactory._generatorFeatures; _characterEscapes = jsonfactory._characterEscapes; _inputDecorator = jsonfactory._inputDecorator; _outputDecorator = jsonfactory._outputDecorator; _rootValueSeparator = jsonfactory._rootValueSeparator; } public JsonFactory(ObjectCodec objectcodec) { _rootCharSymbols = CharsToNameCanonicalizer.createRoot(); _byteSymbolCanonicalizer = ByteQuadsCanonicalizer.createRoot(); _rootByteSymbols = BytesToNameCanonicalizer.createRoot(); _factoryFeatures = DEFAULT_FACTORY_FEATURE_FLAGS; _parserFeatures = DEFAULT_PARSER_FEATURE_FLAGS; _generatorFeatures = DEFAULT_GENERATOR_FEATURE_FLAGS; _rootValueSeparator = DEFAULT_ROOT_VALUE_SEPARATOR; _objectCodec = objectcodec; } protected void _checkInvalidCopy(Class class1) { if (getClass() != class1) { throw new IllegalStateException((new StringBuilder()).append("Failed copy(): ").append(getClass().getName()).append(" (version: ").append(version()).append(") does not override copy(); it has to").toString()); } else { return; } } protected IOContext _createContext(Object obj, boolean flag) { return new IOContext(_getBufferRecycler(), obj, flag); } protected JsonGenerator _createGenerator(Writer writer, IOContext iocontext) throws IOException { writer = new WriterBasedJsonGenerator(iocontext, _generatorFeatures, _objectCodec, writer); if (_characterEscapes != null) { writer.setCharacterEscapes(_characterEscapes); } iocontext = _rootValueSeparator; if (iocontext != DEFAULT_ROOT_VALUE_SEPARATOR) { writer.setRootValueSeparator(iocontext); } return writer; } protected JsonParser _createParser(InputStream inputstream, IOContext iocontext) throws IOException { return (new ByteSourceJsonBootstrapper(iocontext, inputstream)).constructParser(_parserFeatures, _objectCodec, _byteSymbolCanonicalizer, _rootCharSymbols, _factoryFeatures); } protected JsonParser _createParser(Reader reader, IOContext iocontext) throws IOException { return new ReaderBasedJsonParser(iocontext, _parserFeatures, reader, _objectCodec, _rootCharSymbols.makeChild(_factoryFeatures)); } protected JsonParser _createParser(byte abyte0[], int i, int j, IOContext iocontext) throws IOException { return (new ByteSourceJsonBootstrapper(iocontext, abyte0, i, j)).constructParser(_parserFeatures, _objectCodec, _byteSymbolCanonicalizer, _rootCharSymbols, _factoryFeatures); } protected JsonParser _createParser(char ac[], int i, int j, IOContext iocontext, boolean flag) throws IOException { return new ReaderBasedJsonParser(iocontext, _parserFeatures, null, _objectCodec, _rootCharSymbols.makeChild(_factoryFeatures), ac, i, i + j, flag); } protected JsonGenerator _createUTF8Generator(OutputStream outputstream, IOContext iocontext) throws IOException { outputstream = new UTF8JsonGenerator(iocontext, _generatorFeatures, _objectCodec, outputstream); if (_characterEscapes != null) { outputstream.setCharacterEscapes(_characterEscapes); } iocontext = _rootValueSeparator; if (iocontext != DEFAULT_ROOT_VALUE_SEPARATOR) { outputstream.setRootValueSeparator(iocontext); } return outputstream; } protected Writer _createWriter(OutputStream outputstream, JsonEncoding jsonencoding, IOContext iocontext) throws IOException { if (jsonencoding == JsonEncoding.UTF8) { return new UTF8Writer(iocontext, outputstream); } else { return new OutputStreamWriter(outputstream, jsonencoding.getJavaName()); } } protected final InputStream _decorate(InputStream inputstream, IOContext iocontext) throws IOException { if (_inputDecorator != null) { iocontext = _inputDecorator.decorate(iocontext, inputstream); if (iocontext != null) { return iocontext; } } return inputstream; } protected final OutputStream _decorate(OutputStream outputstream, IOContext iocontext) throws IOException { if (_outputDecorator != null) { iocontext = _outputDecorator.decorate(iocontext, outputstream); if (iocontext != null) { return iocontext; } } return outputstream; } protected final Reader _decorate(Reader reader, IOContext iocontext) throws IOException { if (_inputDecorator != null) { iocontext = _inputDecorator.decorate(iocontext, reader); if (iocontext != null) { return iocontext; } } return reader; } protected final Writer _decorate(Writer writer, IOContext iocontext) throws IOException { if (_outputDecorator != null) { iocontext = _outputDecorator.decorate(iocontext, writer); if (iocontext != null) { return iocontext; } } return writer; } public BufferRecycler _getBufferRecycler() { if (isEnabled(Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING)) { Object obj = (SoftReference)_recyclerRef.get(); Object obj1; if (obj == null) { obj = null; } else { obj = (BufferRecycler)((SoftReference) (obj)).get(); } obj1 = obj; if (obj == null) { obj1 = new BufferRecycler(); _recyclerRef.set(new SoftReference(obj1)); } return ((BufferRecycler) (obj1)); } else { return new BufferRecycler(); } } protected InputStream _optimizedStreamFromURL(URL url) throws IOException { if ("file".equals(url.getProtocol())) { String s = url.getHost(); if ((s == null || s.length() == 0) && url.getPath().indexOf('%') < 0) { return new FileInputStream(url.getPath()); } } return url.openStream(); } public boolean canHandleBinaryNatively() { return false; } public boolean canUseCharArrays() { return true; } public boolean canUseSchema(FormatSchema formatschema) { String s = getFormatName(); return s != null && s.equals(formatschema.getSchemaType()); } public final JsonFactory configure(Feature feature, boolean flag) { if (flag) { return enable(feature); } else { return disable(feature); } } public final JsonFactory configure(JsonGenerator.Feature feature, boolean flag) { if (flag) { return enable(feature); } else { return disable(feature); } } public final JsonFactory configure(JsonParser.Feature feature, boolean flag) { if (flag) { return enable(feature); } else { return disable(feature); } } public JsonFactory copy() { _checkInvalidCopy(com/fasterxml/jackson/core/JsonFactory); return new JsonFactory(this, null); } public JsonGenerator createGenerator(File file, JsonEncoding jsonencoding) throws IOException { file = new FileOutputStream(file); IOContext iocontext = _createContext(file, true); iocontext.setEncoding(jsonencoding); if (jsonencoding == JsonEncoding.UTF8) { return _createUTF8Generator(_decorate(file, iocontext), iocontext); } else { return _createGenerator(_decorate(_createWriter(file, jsonencoding, iocontext), iocontext), iocontext); } } public JsonGenerator createGenerator(OutputStream outputstream) throws IOException { return createGenerator(outputstream, JsonEncoding.UTF8); } public JsonGenerator createGenerator(OutputStream outputstream, JsonEncoding jsonencoding) throws IOException { IOContext iocontext = _createContext(outputstream, false); iocontext.setEncoding(jsonencoding); if (jsonencoding == JsonEncoding.UTF8) { return _createUTF8Generator(_decorate(outputstream, iocontext), iocontext); } else { return _createGenerator(_decorate(_createWriter(outputstream, jsonencoding, iocontext), iocontext), iocontext); } } public JsonGenerator createGenerator(Writer writer) throws IOException { IOContext iocontext = _createContext(writer, false); return _createGenerator(_decorate(writer, iocontext), iocontext); } public JsonGenerator createJsonGenerator(File file, JsonEncoding jsonencoding) throws IOException { return createGenerator(file, jsonencoding); } public JsonGenerator createJsonGenerator(OutputStream outputstream) throws IOException { return createGenerator(outputstream, JsonEncoding.UTF8); } public JsonGenerator createJsonGenerator(OutputStream outputstream, JsonEncoding jsonencoding) throws IOException { return createGenerator(outputstream, jsonencoding); } public JsonGenerator createJsonGenerator(Writer writer) throws IOException { return createGenerator(writer); } public JsonParser createJsonParser(File file) throws IOException, JsonParseException { return createParser(file); } public JsonParser createJsonParser(InputStream inputstream) throws IOException, JsonParseException { return createParser(inputstream); } public JsonParser createJsonParser(Reader reader) throws IOException, JsonParseException { return createParser(reader); } public JsonParser createJsonParser(String s) throws IOException, JsonParseException { return createParser(s); } public JsonParser createJsonParser(URL url) throws IOException, JsonParseException { return createParser(url); } public JsonParser createJsonParser(byte abyte0[]) throws IOException, JsonParseException { return createParser(abyte0); } public JsonParser createJsonParser(byte abyte0[], int i, int j) throws IOException, JsonParseException { return createParser(abyte0, i, j); } public JsonParser createParser(File file) throws IOException, JsonParseException { IOContext iocontext = _createContext(file, true); return _createParser(_decorate(new FileInputStream(file), iocontext), iocontext); } public JsonParser createParser(InputStream inputstream) throws IOException, JsonParseException { IOContext iocontext = _createContext(inputstream, false); return _createParser(_decorate(inputstream, iocontext), iocontext); } public JsonParser createParser(Reader reader) throws IOException, JsonParseException { IOContext iocontext = _createContext(reader, false); return _createParser(_decorate(reader, iocontext), iocontext); } public JsonParser createParser(String s) throws IOException, JsonParseException { int i = s.length(); if (_inputDecorator != null || i > 32768 || !canUseCharArrays()) { return createParser(((Reader) (new StringReader(s)))); } else { IOContext iocontext = _createContext(s, true); char ac[] = iocontext.allocTokenBuffer(i); s.getChars(0, i, ac, 0); return _createParser(ac, 0, i, iocontext, true); } } public JsonParser createParser(URL url) throws IOException, JsonParseException { IOContext iocontext = _createContext(url, true); return _createParser(_decorate(_optimizedStreamFromURL(url), iocontext), iocontext); } public JsonParser createParser(byte abyte0[]) throws IOException, JsonParseException { IOContext iocontext = _createContext(abyte0, true); if (_inputDecorator != null) { InputStream inputstream = _inputDecorator.decorate(iocontext, abyte0, 0, abyte0.length); if (inputstream != null) { return _createParser(inputstream, iocontext); } } return _createParser(abyte0, 0, abyte0.length, iocontext); } public JsonParser createParser(byte abyte0[], int i, int j) throws IOException, JsonParseException { IOContext iocontext = _createContext(abyte0, true); if (_inputDecorator != null) { InputStream inputstream = _inputDecorator.decorate(iocontext, abyte0, i, j); if (inputstream != null) { return _createParser(inputstream, iocontext); } } return _createParser(abyte0, i, j, iocontext); } public JsonParser createParser(char ac[]) throws IOException { return createParser(ac, 0, ac.length); } public JsonParser createParser(char ac[], int i, int j) throws IOException { if (_inputDecorator != null) { return createParser(((Reader) (new CharArrayReader(ac, i, j)))); } else { return _createParser(ac, i, j, _createContext(ac, true), false); } } public JsonFactory disable(Feature feature) { _factoryFeatures = _factoryFeatures & ~feature.getMask(); return this; } public JsonFactory disable(JsonGenerator.Feature feature) { _generatorFeatures = _generatorFeatures & ~feature.getMask(); return this; } public JsonFactory disable(JsonParser.Feature feature) { _parserFeatures = _parserFeatures & ~feature.getMask(); return this; } public JsonFactory enable(Feature feature) { _factoryFeatures = _factoryFeatures | feature.getMask(); return this; } public JsonFactory enable(JsonGenerator.Feature feature) { _generatorFeatures = _generatorFeatures | feature.getMask(); return this; } public JsonFactory enable(JsonParser.Feature feature) { _parserFeatures = _parserFeatures | feature.getMask(); return this; } public CharacterEscapes getCharacterEscapes() { return _characterEscapes; } public ObjectCodec getCodec() { return _objectCodec; } public String getFormatName() { if (getClass() == com/fasterxml/jackson/core/JsonFactory) { return "JSON"; } else { return null; } } public Class getFormatReadFeatureType() { return null; } public Class getFormatWriteFeatureType() { return null; } public InputDecorator getInputDecorator() { return _inputDecorator; } public OutputDecorator getOutputDecorator() { return _outputDecorator; } public String getRootValueSeparator() { if (_rootValueSeparator == null) { return null; } else { return _rootValueSeparator.getValue(); } } public MatchStrength hasFormat(InputAccessor inputaccessor) throws IOException { if (getClass() == com/fasterxml/jackson/core/JsonFactory) { return hasJSONFormat(inputaccessor); } else { return null; } } protected MatchStrength hasJSONFormat(InputAccessor inputaccessor) throws IOException { return ByteSourceJsonBootstrapper.hasJSONFormat(inputaccessor); } public final boolean isEnabled(Feature feature) { return (_factoryFeatures & feature.getMask()) != 0; } public final boolean isEnabled(JsonGenerator.Feature feature) { return (_generatorFeatures & feature.getMask()) != 0; } public final boolean isEnabled(JsonParser.Feature feature) { return (_parserFeatures & feature.getMask()) != 0; } protected Object readResolve() { return new JsonFactory(this, _objectCodec); } public boolean requiresCustomCodec() { return false; } public boolean requiresPropertyOrdering() { return false; } public JsonFactory setCharacterEscapes(CharacterEscapes characterescapes) { _characterEscapes = characterescapes; return this; } public JsonFactory setCodec(ObjectCodec objectcodec) { _objectCodec = objectcodec; return this; } public JsonFactory setInputDecorator(InputDecorator inputdecorator) { _inputDecorator = inputdecorator; return this; } public JsonFactory setOutputDecorator(OutputDecorator outputdecorator) { _outputDecorator = outputdecorator; return this; } public JsonFactory setRootValueSeparator(String s) { if (s == null) { s = null; } else { s = new SerializedString(s); } _rootValueSeparator = s; return this; } public Version version() { return PackageVersion.VERSION; } static { DEFAULT_ROOT_VALUE_SEPARATOR = DefaultPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR; } }