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.
//========================================================================
//Copyright 2007-2009 David Yu [email protected]
//------------------------------------------------------------------------
//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 com.dyuproject.protostuff.runtime;
import static com.dyuproject.protostuff.runtime.RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS;
import static com.dyuproject.protostuff.runtime.RuntimeEnv.MORPH_NON_FINAL_POJOS;
import static com.dyuproject.protostuff.runtime.RuntimeEnv.USE_SUN_MISC_UNSAFE;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.dyuproject.protostuff.ByteString;
import com.dyuproject.protostuff.Input;
import com.dyuproject.protostuff.Message;
import com.dyuproject.protostuff.Output;
import com.dyuproject.protostuff.Pipe;
import com.dyuproject.protostuff.WireFormat.FieldType;
import com.dyuproject.protostuff.runtime.MappedSchema.Field;
/**
* A factory to create runtime {@link MappedSchema.Field fields} based on reflection.
*
* @author David Yu
* @created Nov 10, 2009
*/
public abstract class RuntimeFieldFactory
{
static final int ID_BOOL = 1, ID_BYTE = 2, ID_CHAR = 3, ID_SHORT = 4,
ID_INT32 = 5, ID_INT64 = 6, ID_FLOAT = 7, ID_DOUBLE = 8,
ID_STRING = 9, ID_BYTES = 10, ID_BYTE_ARRAY = 11,
ID_BIGDECIMAL = 12, ID_BIGINTEGER = 13, ID_DATE = 14,
ID_ARRAY = 15, // 1-15 is encoded as 1 byte on protobuf and protostuff format
ID_OBJECT = 16,
// room for more scalar types (17-23)
ID_ENUM = 24,
ID_COLLECTION = 25,
ID_MAP = 26,
// pojo fields limited to 126
ID_POJO = 127;
static final String STR_BOOL = "a", STR_BYTE = "b", STR_CHAR = "c", STR_SHORT = "d",
STR_INT32 = "e", STR_INT64 = "f", STR_FLOAT = "g", STR_DOUBLE = "h",
STR_STRING = "i", STR_BYTES = "j", STR_BYTE_ARRAY = "k",
STR_BIGDECIMAL = "l", STR_BIGINTEGER = "m", STR_DATE = "n",
STR_ARRAY = "o",
STR_OBJECT = "p",
// room for more scalar types (17-23)
STR_ENUM = "x",
STR_COLLECTION = "y",
STR_MAP = "z",
// pojo fields limited to 126
STR_POJO = "_";
private static final HashMap> __inlineValues =
new HashMap>();
static final RuntimeFieldFactory BIGDECIMAL;
static final RuntimeFieldFactory BIGINTEGER;
static final RuntimeFieldFactory BOOL;
static final RuntimeFieldFactory BYTE;
static final RuntimeFieldFactory BYTES;
static final RuntimeFieldFactory BYTE_ARRAY;
static final RuntimeFieldFactory CHAR;
static final RuntimeFieldFactory DATE;
static final RuntimeFieldFactory DOUBLE;
static final RuntimeFieldFactory FLOAT;
static final RuntimeFieldFactory INT32;
static final RuntimeFieldFactory INT64;
static final RuntimeFieldFactory SHORT;
static final RuntimeFieldFactory STRING;
static final RuntimeFieldFactory ENUM;
static final RuntimeFieldFactory