Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
//
// MessagePack for Java
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.msgpack.jackson.dataformat;
import com.fasterxml.jackson.core.Base64Variant;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonStreamContext;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.base.ParserMinimalBase;
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.core.io.JsonEOFException;
import com.fasterxml.jackson.core.json.DupDetector;
import org.msgpack.core.ExtensionTypeHeader;
import org.msgpack.core.MessageFormat;
import org.msgpack.core.MessagePack;
import org.msgpack.core.MessageUnpacker;
import org.msgpack.core.buffer.ArrayBufferInput;
import org.msgpack.core.buffer.InputStreamBufferInput;
import org.msgpack.core.buffer.MessageBufferInput;
import org.msgpack.value.ValueType;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import static org.msgpack.jackson.dataformat.JavaInfo.STRING_VALUE_FIELD_IS_CHARS;
public class MessagePackParser
extends ParserMinimalBase
{
private static final ThreadLocal> messageUnpackerHolder = new ThreadLocal<>();
private final MessageUnpacker messageUnpacker;
private static final BigInteger LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE);
private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
private ObjectCodec codec;
private MessagePackReadContext streamReadContext;
private boolean isClosed;
private long tokenPosition;
private long currentPosition;
private final IOContext ioContext;
private ExtensionTypeCustomDeserializers extTypeCustomDesers;
private final byte[] tempBytes = new byte[64];
private final char[] tempChars = new char[64];
private enum Type
{
INT, LONG, DOUBLE, STRING, BYTES, BIG_INT, EXT
}
private Type type;
private int intValue;
private long longValue;
private double doubleValue;
private byte[] bytesValue;
private String stringValue;
private BigInteger biValue;
private MessagePackExtensionType extensionTypeValue;
public MessagePackParser(
IOContext ctxt,
int features,
ObjectCodec objectCodec,
InputStream in,
boolean reuseResourceInParser)
throws IOException
{
this(ctxt, features, new InputStreamBufferInput(in), objectCodec, in, reuseResourceInParser);
}
public MessagePackParser(
IOContext ctxt,
int features,
ObjectCodec objectCodec,
byte[] bytes,
boolean reuseResourceInParser)
throws IOException
{
this(ctxt, features, new ArrayBufferInput(bytes), objectCodec, bytes, reuseResourceInParser);
}
private MessagePackParser(IOContext ctxt,
int features,
MessageBufferInput input,
ObjectCodec objectCodec,
Object src,
boolean reuseResourceInParser)
throws IOException
{
super(features);
this.codec = objectCodec;
ioContext = ctxt;
DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
? DupDetector.rootDetector(this) : null;
streamReadContext = MessagePackReadContext.createRootContext(dups);
if (!reuseResourceInParser) {
messageUnpacker = MessagePack.newDefaultUnpacker(input);
return;
}
Tuple