All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.velocypack.internal.VPackDeserializers Maven / Gradle / Ivy

There is a newer version: 7.15.0
Show newest version
/*
 * DISCLAIMER
 *
 * Copyright 2016 ArangoDB GmbH, Cologne, Germany
 *
 * 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.
 *
 * Copyright holder is ArangoDB GmbH, Cologne, Germany
 */

package com.arangodb.velocypack.internal;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;

import com.arangodb.velocypack.VPackDeserializationContext;
import com.arangodb.velocypack.VPackDeserializer;
import com.arangodb.velocypack.VPackSlice;
import com.arangodb.velocypack.exception.VPackException;

/**
 * @author Mark - mark at arangodb.com
 *
 */
public class VPackDeserializers {

	private VPackDeserializers() {
		super();
	}

	public static final VPackDeserializer STRING = new VPackDeserializer() {
		@Override
		public String deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsString();
		}
	};
	public static final VPackDeserializer BOOLEAN = new VPackDeserializer() {
		@Override
		public Boolean deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsBoolean();
		}
	};
	public static final VPackDeserializer INTEGER = new VPackDeserializer() {
		@Override
		public Integer deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsInt();
		}
	};
	public static final VPackDeserializer LONG = new VPackDeserializer() {
		@Override
		public Long deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsLong();
		}
	};
	public static final VPackDeserializer SHORT = new VPackDeserializer() {
		@Override
		public Short deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsShort();
		}
	};
	public static final VPackDeserializer DOUBLE = new VPackDeserializer() {
		@Override
		public Double deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsDouble();
		}
	};
	public static final VPackDeserializer FLOAT = new VPackDeserializer() {
		@Override
		public Float deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsFloat();
		}
	};
	public static final VPackDeserializer BIG_INTEGER = new VPackDeserializer() {
		@Override
		public BigInteger deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsBigInteger();
		}
	};
	public static final VPackDeserializer BIG_DECIMAL = new VPackDeserializer() {
		@Override
		public BigDecimal deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsBigDecimal();
		}
	};
	public static final VPackDeserializer NUMBER = new VPackDeserializer() {
		@Override
		public Number deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsNumber();
		}
	};
	public static final VPackDeserializer CHARACTER = new VPackDeserializer() {
		@Override
		public Character deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsChar();
		}
	};
	public static final VPackDeserializer DATE = new VPackDeserializer() {
		@Override
		public Date deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsDate();
		}
	};
	public static final VPackDeserializer SQL_DATE = new VPackDeserializer() {
		@Override
		public java.sql.Date deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsSQLDate();
		}
	};
	public static final VPackDeserializer SQL_TIMESTAMP = new VPackDeserializer() {
		@Override
		public Timestamp deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack.getAsSQLTimestamp();
		}
	};
	public static final VPackDeserializer VPACK = new VPackDeserializer() {
		@Override
		public VPackSlice deserialize(
			final VPackSlice parent,
			final VPackSlice vpack,
			final VPackDeserializationContext context) throws VPackException {
			return vpack;
		}
	};

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy