// 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.base; import com.fasterxml.jackson.core.Base64Variant; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonStreamContext; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.PrettyPrinter; import com.fasterxml.jackson.core.SerializableString; import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.json.DupDetector; import com.fasterxml.jackson.core.json.JsonWriteContext; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.core.util.VersionUtil; import java.io.IOException; import java.io.InputStream; public abstract class GeneratorBase extends JsonGenerator { protected static final int DERIVED_FEATURES_MASK; public static final int SURR1_FIRST = 55296; public static final int SURR1_LAST = 56319; public static final int SURR2_FIRST = 56320; public static final int SURR2_LAST = 57343; protected final String WRITE_BINARY; protected final String WRITE_BOOLEAN; protected final String WRITE_NULL; protected final String WRITE_NUMBER; protected final String WRITE_RAW; protected final String WRITE_STRING; protected boolean _cfgNumbersAsStrings; protected boolean _closed; protected int _features; protected ObjectCodec _objectCodec; protected JsonWriteContext _writeContext; protected GeneratorBase(int i, ObjectCodec objectcodec) { WRITE_BINARY = "write a binary value"; WRITE_BOOLEAN = "write a boolean value"; WRITE_NULL = "write a null"; WRITE_NUMBER = "write a number"; WRITE_RAW = "write a raw (unencoded) value"; WRITE_STRING = "write a string"; _features = i; _objectCodec = objectcodec; if (com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(i)) { objectcodec = DupDetector.rootDetector(this); } else { objectcodec = null; } _writeContext = JsonWriteContext.createRootContext(objectcodec); _cfgNumbersAsStrings = com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(i); } protected GeneratorBase(int i, ObjectCodec objectcodec, JsonWriteContext jsonwritecontext) { WRITE_BINARY = "write a binary value"; WRITE_BOOLEAN = "write a boolean value"; WRITE_NULL = "write a null"; WRITE_NUMBER = "write a number"; WRITE_RAW = "write a raw (unencoded) value"; WRITE_STRING = "write a string"; _features = i; _objectCodec = objectcodec; _writeContext = jsonwritecontext; _cfgNumbersAsStrings = com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(i); } protected PrettyPrinter _constructDefaultPrettyPrinter() { return new DefaultPrettyPrinter(); } protected final int _decodeSurrogate(int i, int j) throws IOException { if (j < 56320 || j > 57343) { _reportError((new StringBuilder()).append("Incomplete surrogate pair: first char 0x").append(Integer.toHexString(i)).append(", second 0x").append(Integer.toHexString(j)).toString()); } return 0x10000 + (i - 55296 << 10) + (j - 56320); } protected abstract void _releaseBuffers(); protected abstract void _verifyValueWrite(String s) throws IOException; public void close() throws IOException { _closed = true; } public JsonGenerator disable(com.fasterxml.jackson.core.JsonGenerator.Feature feature) { int i = feature.getMask(); _features = _features & ~i; if ((DERIVED_FEATURES_MASK & i) != 0) { if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS) { _cfgNumbersAsStrings = false; } else { if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.ESCAPE_NON_ASCII) { setHighestNonEscapedChar(0); return this; } if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION) { _writeContext = _writeContext.withDupDetector(null); return this; } } } return this; } public JsonGenerator enable(com.fasterxml.jackson.core.JsonGenerator.Feature feature) { int i = feature.getMask(); _features = _features | i; if ((DERIVED_FEATURES_MASK & i) != 0) { if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS) { _cfgNumbersAsStrings = true; } else { if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.ESCAPE_NON_ASCII) { setHighestNonEscapedChar(127); return this; } if (feature == com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION && _writeContext.getDupDetector() == null) { _writeContext = _writeContext.withDupDetector(DupDetector.rootDetector(this)); return this; } } } return this; } public abstract void flush() throws IOException; public final ObjectCodec getCodec() { return _objectCodec; } public Object getCurrentValue() { return _writeContext.getCurrentValue(); } public int getFeatureMask() { return _features; } public volatile JsonStreamContext getOutputContext() { return getOutputContext(); } public final JsonWriteContext getOutputContext() { return _writeContext; } public boolean isClosed() { return _closed; } public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature feature) { return (_features & feature.getMask()) != 0; } public JsonGenerator setCodec(ObjectCodec objectcodec) { _objectCodec = objectcodec; return this; } public void setCurrentValue(Object obj) { _writeContext.setCurrentValue(obj); } public JsonGenerator setFeatureMask(int i) { label0: { int j = i ^ _features; _features = i; if ((DERIVED_FEATURES_MASK & j) != 0) { _cfgNumbersAsStrings = com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.enabledIn(i); if (com.fasterxml.jackson.core.JsonGenerator.Feature.ESCAPE_NON_ASCII.enabledIn(j)) { if (com.fasterxml.jackson.core.JsonGenerator.Feature.ESCAPE_NON_ASCII.enabledIn(i)) { setHighestNonEscapedChar(127); } else { setHighestNonEscapedChar(0); } } if (com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(j)) { if (!com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(i)) { break label0; } if (_writeContext.getDupDetector() == null) { _writeContext = _writeContext.withDupDetector(DupDetector.rootDetector(this)); } } } return this; } _writeContext = _writeContext.withDupDetector(null); return this; } public JsonGenerator useDefaultPrettyPrinter() { if (getPrettyPrinter() != null) { return this; } else { return setPrettyPrinter(_constructDefaultPrettyPrinter()); } } public Version version() { return VersionUtil.versionFor(getClass()); } public int writeBinary(Base64Variant base64variant, InputStream inputstream, int i) throws IOException { _reportUnsupportedOperation(); return 0; } public void writeFieldName(SerializableString serializablestring) throws IOException { writeFieldName(serializablestring.getValue()); } public void writeObject(Object obj) throws IOException { if (obj == null) { writeNull(); return; } if (_objectCodec != null) { _objectCodec.writeValue(this, obj); return; } else { _writeSimpleObject(obj); return; } } public void writeRawValue(SerializableString serializablestring) throws IOException { _verifyValueWrite("write raw value"); writeRaw(serializablestring); } public void writeRawValue(String s) throws IOException { _verifyValueWrite("write raw value"); writeRaw(s); } public void writeRawValue(String s, int i, int j) throws IOException { _verifyValueWrite("write raw value"); writeRaw(s, i, j); } public void writeRawValue(char ac[], int i, int j) throws IOException { _verifyValueWrite("write raw value"); writeRaw(ac, i, j); } public void writeString(SerializableString serializablestring) throws IOException { writeString(serializablestring.getValue()); } public void writeTree(TreeNode treenode) throws IOException { if (treenode == null) { writeNull(); return; } if (_objectCodec == null) { throw new IllegalStateException("No ObjectCodec defined"); } else { _objectCodec.writeValue(this, treenode); return; } } static { DERIVED_FEATURES_MASK = com.fasterxml.jackson.core.JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS.getMask() | com.fasterxml.jackson.core.JsonGenerator.Feature.ESCAPE_NON_ASCII.getMask() | com.fasterxml.jackson.core.JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION.getMask(); } }