├── .gitignore ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── jd │ └── dd │ └── glowworm │ ├── PB.java │ ├── PBException.java │ ├── asm │ ├── ASMException.java │ ├── ByteVector.java │ ├── ClassWriter.java │ ├── FieldVisitor.java │ ├── FieldWriter.java │ ├── Item.java │ ├── Label.java │ ├── MethodVisitor.java │ ├── MethodWriter.java │ ├── Opcodes.java │ └── Type.java │ ├── deserializer │ ├── ObjectDeserializer.java │ ├── PBDeserializer.java │ ├── asm │ │ ├── ASMDeserializerFactory.java │ │ └── ASMJavaBeanDeserializer.java │ ├── multi │ │ ├── ArrayDeserializer.java │ │ ├── ListDeserializer.java │ │ ├── MapDeserializer.java │ │ ├── MultiDeserialier.java │ │ └── SetDeserializer.java │ ├── normal │ │ ├── AtomicBooleanDeserializer.java │ │ ├── AtomicIntegerDeserializer.java │ │ ├── AtomicLongDeserializer.java │ │ ├── BigDecimalDeserializer.java │ │ ├── BigIntegerDeserializer.java │ │ ├── ClassDeserializer.java │ │ ├── DateDeserializer.java │ │ ├── EnumDeserializer.java │ │ ├── ExceptionDeserializer.java │ │ ├── InetAddressDeserializer.java │ │ ├── JavaObjectDeserializer.java │ │ ├── StackTraceElementDeserializer.java │ │ ├── StringDeserializer.java │ │ ├── TimeDeserializer.java │ │ └── TimestampDeserializer.java │ ├── primary │ │ ├── BooleanArrayDeserializer.java │ │ ├── BooleanDeserializer.java │ │ ├── ByteArrayDeserializer.java │ │ ├── ByteDeserializer.java │ │ ├── CharArrayDeserializer.java │ │ ├── CharacterDeserializer.java │ │ ├── DoubleArrayDeserializer.java │ │ ├── DoubleDeserializer.java │ │ ├── FloatArrayDeserializer.java │ │ ├── FloatDeserializer.java │ │ ├── IntArrayDeserializer.java │ │ ├── IntegerDeserializer.java │ │ ├── LongArrayDeserializer.java │ │ ├── LongDeserializer.java │ │ ├── ShortArrayDeserializer.java │ │ └── ShortDeserializer.java │ └── reflect │ │ ├── DefaultFieldDeserializer.java │ │ ├── FieldDeserializer.java │ │ └── JavaBeanDeserializer.java │ ├── serializer │ ├── ObjectSerializer.java │ ├── PBSerializer.java │ ├── asm │ │ └── ASMSerializerFactory.java │ ├── multi │ │ ├── ArraySerializer.java │ │ ├── ListSerializer.java │ │ ├── MapSerializer.java │ │ ├── MultiSerializer.java │ │ └── SetSerializer.java │ ├── normal │ │ ├── AtomicBooleanSerializer.java │ │ ├── AtomicIntegerSerializer.java │ │ ├── AtomicLongSerializer.java │ │ ├── BigDecimalSerializer.java │ │ ├── BigIntegerSerializer.java │ │ ├── ClassSerializer.java │ │ ├── DateSerializer.java │ │ ├── EnumSerializer.java │ │ ├── ExceptionSerializer.java │ │ ├── InetAddressSerializer.java │ │ ├── StringSerializer.java │ │ ├── TimeSerializer.java │ │ └── TimestampSerializer.java │ ├── primary │ │ ├── BooleanArraySerializer.java │ │ ├── BooleanSerializer.java │ │ ├── ByteArraySerializer.java │ │ ├── ByteSerializer.java │ │ ├── CharArraySerializer.java │ │ ├── CharacterSerializer.java │ │ ├── DoubleArraySerializer.java │ │ ├── DoubleSerializer.java │ │ ├── FloatArraySerializer.java │ │ ├── FloatSerializer.java │ │ ├── IntArraySerializer.java │ │ ├── IntegerSerializer.java │ │ ├── LongArraySerializer.java │ │ ├── LongSerializer.java │ │ ├── ShortArraySerializer.java │ │ └── ShortSerializer.java │ └── reflect │ │ ├── FieldSerializer.java │ │ ├── JavaBeanSerializer.java │ │ └── ObjectFieldSerializer.java │ └── util │ ├── ASMClassLoader.java │ ├── ASMUtils.java │ ├── AntiCollisionHashMap.java │ ├── Base64.java │ ├── Buffer.java │ ├── BufferInputStream.java │ ├── BufferOutputStream.java │ ├── CodedInputStream.java │ ├── CodedOutputStream.java │ ├── CustByteBuffer.java │ ├── DeserializeBeanInfo.java │ ├── ExistInputStream.java │ ├── ExistOutputStream.java │ ├── FieldInfo.java │ ├── IdentityHashMap.java │ ├── InputStreamBuffer.java │ ├── InvalidProtocolBufferException.java │ ├── OutputStreamBuffer.java │ ├── Parameters.java │ ├── SerializeContext.java │ ├── Transient.java │ ├── TypeInputStream.java │ ├── TypeOutputStream.java │ ├── TypeUtils.java │ └── WireFormat.java └── test └── java ├── com └── jd │ └── bdp │ └── seomonitor │ └── model │ └── page │ └── SeoWord.java ├── testcase ├── TestBase.java ├── function │ ├── AsmTest.java │ ├── MultiTest.java │ ├── NormalTest.java │ └── ReflectTest.java └── rule │ ├── AsmTest.java │ ├── BitTest.java │ ├── MultiTest.java │ ├── NormalTest.java │ └── ReflectTest.java └── userJavabean ├── AtomicPerson1.java ├── Broker.java ├── CommonResponse.java ├── Course.java ├── Difficulty.java ├── Food.java ├── Glowworm_Serializer_1.java ├── Group.java ├── InnerBean.java ├── InnerBean3.java ├── LoopPerson1.java ├── LoopPerson10.java ├── LoopPerson11.java ├── LoopPerson2.java ├── LoopPerson3.java ├── LoopPerson4.java ├── LoopPerson5.java ├── LoopPerson6.java ├── LoopPerson7.java ├── LoopPerson8.java ├── LoopPerson9.java ├── MapBean.java ├── MemoryRecord.java ├── NoDefaultConstructorBean.java ├── Person1.java ├── Person10.java ├── Person11.java ├── Person2.java ├── Person4.java ├── Person5.java ├── Person6.java ├── Person7.java ├── Person8.java ├── PersonCollection3.java ├── PersonCollection4.java ├── PersonForDate.java ├── Rule.java ├── RuleItem.java ├── School.java ├── Student.java ├── Student1.java ├── Student2.java ├── Supply1.java ├── Supply2.java ├── Supply3.java ├── TpMagic.java ├── TpMagic2.java ├── TransientBean1.java ├── TransientBean2.java ├── TransientBean3.java ├── TransientBean4.java ├── TransientBean5.java ├── User.java ├── User1.java ├── User10.java ├── User11.java ├── User12.java ├── User13.java ├── User14.java ├── User15.java ├── User16.java ├── User17.java ├── User18.java ├── User2.java ├── User3.java ├── User4.java ├── User5.java ├── User7.java ├── User8.java ├── User9.java └── UserGeneric.java /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .idea 3 | *.iml 4 | .svn -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | glowworm高性能轻便的序列化组件 2 | ======== 3 | http://bigbully.github.com/glowworm/ 4 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/PBException.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jd.dd.glowworm; 3 | 4 | 5 | public class PBException extends RuntimeException { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | public PBException() { 10 | super(); 11 | } 12 | 13 | public PBException(String message) { 14 | super(message); 15 | } 16 | 17 | public PBException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/asm/ASMException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.asm; 17 | 18 | 19 | public class ASMException extends RuntimeException { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public ASMException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/asm/FieldVisitor.java: -------------------------------------------------------------------------------- 1 | /*** 2 | * ASM: a very small and fast Java bytecode manipulation framework 3 | * Copyright (c) 2000-2007 INRIA, France Telecom 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the copyright holders nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 | * THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | package com.jd.dd.glowworm.asm; 31 | 32 | /** 33 | * A visitor to visit a Java field. The methods of this interface must be called in the following order: ( 34 | * visitAnnotation | visitAttribute )* visitEnd. 35 | * 36 | * @author Eric Bruneton 37 | */ 38 | public interface FieldVisitor { 39 | 40 | /** 41 | * Visits the end of the field. This method, which is the last one to be called, is used to inform the visitor that 42 | * all the annotations and attributes of the field have been visited. 43 | */ 44 | void visitEnd(); 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/ObjectDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer; 17 | 18 | import java.lang.reflect.Type; 19 | 20 | public interface ObjectDeserializer { 21 | 22 | T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/asm/ASMJavaBeanDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.asm; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | import com.jd.dd.glowworm.deserializer.reflect.FieldDeserializer; 21 | import com.jd.dd.glowworm.deserializer.reflect.JavaBeanDeserializer; 22 | import com.jd.dd.glowworm.util.FieldInfo; 23 | 24 | import java.lang.reflect.Type; 25 | import java.util.Map; 26 | 27 | public abstract class ASMJavaBeanDeserializer implements ObjectDeserializer { 28 | 29 | protected InnerJavaBeanDeserializer serializer; 30 | 31 | public ASMJavaBeanDeserializer(PBDeserializer mapping, Class clazz) { 32 | serializer = new InnerJavaBeanDeserializer(mapping, clazz); 33 | 34 | serializer.getFieldDeserializerMap(); 35 | } 36 | 37 | public abstract Object createInstance(PBDeserializer parser, Type type); 38 | 39 | public InnerJavaBeanDeserializer getInnterSerializer() { 40 | return serializer; 41 | } 42 | 43 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 44 | return (T) serializer.deserialize(deserializer, type, false); 45 | } 46 | 47 | public Object createInstance(PBDeserializer parser) { 48 | return serializer.createInstance(parser, serializer.getClazz()); 49 | } 50 | 51 | public FieldDeserializer createFieldDeserializer(PBDeserializer mapping, Class clazz, FieldInfo fieldInfo) { 52 | return mapping.createFieldDeserializer(mapping, clazz, fieldInfo); 53 | } 54 | 55 | public FieldDeserializer getFieldDeserializer(String name) { 56 | return serializer.getFieldDeserializerMap().get(name); 57 | } 58 | 59 | public Type getFieldType(String name) { 60 | return serializer.getFieldDeserializerMap().get(name).getFieldType(); 61 | } 62 | 63 | public boolean parseField(PBDeserializer parser, String key, Object object, Type objectType, Map fieldValues) { 64 | Map feildDeserializerMap = serializer.getFieldDeserializerMap(); 65 | FieldDeserializer fieldDeserializer = feildDeserializerMap.get(key); 66 | 67 | if (fieldDeserializer == null) { 68 | for (Map.Entry entry : feildDeserializerMap.entrySet()) { 69 | if (entry.getKey().equalsIgnoreCase(key)) { 70 | fieldDeserializer = entry.getValue(); 71 | break; 72 | } 73 | } 74 | } 75 | 76 | fieldDeserializer.parseField(parser, object, objectType, fieldValues); 77 | return true; 78 | } 79 | 80 | public final class InnerJavaBeanDeserializer extends JavaBeanDeserializer { 81 | 82 | private InnerJavaBeanDeserializer(PBDeserializer mapping, Class clazz) { 83 | super(mapping, clazz); 84 | } 85 | 86 | public boolean parseField(PBDeserializer parser, String key, Object object, Type objectType, Map fieldValues) { 87 | return ASMJavaBeanDeserializer.this.parseField(parser, key, object, objectType, fieldValues); 88 | } 89 | 90 | public FieldDeserializer createFieldDeserializer(PBDeserializer mapping, Class clazz, FieldInfo fieldInfo) { 91 | return ASMJavaBeanDeserializer.this.createFieldDeserializer(mapping, clazz, fieldInfo); 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/multi/ArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.multi; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Array; 22 | import java.lang.reflect.Type; 23 | 24 | public class ArrayDeserializer extends MultiDeserialier implements ObjectDeserializer { 25 | 26 | public final static ArrayDeserializer instance = new ArrayDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | if (needConfirmExist) { 31 | try { 32 | if (deserializer.isObjectExist()) { 33 | Class componentType; 34 | if (!needConfirmExist) { 35 | componentType = (Class) extraParams[0]; 36 | } else { 37 | componentType = ((Class) type).getComponentType(); 38 | } 39 | return (T) getArray(deserializer, componentType); 40 | } else { 41 | return (T) deserializer.getReference(); 42 | } 43 | } catch (Exception ex) { 44 | ex.printStackTrace(); 45 | } 46 | } else { 47 | Class componentType; 48 | if (needConfirmExist) { 49 | componentType = (Class) extraParams[0]; 50 | } else { 51 | componentType = ((Class) type).getComponentType(); 52 | } 53 | return (T) getArray(deserializer, componentType); 54 | } 55 | return null; 56 | } 57 | 58 | 59 | private Object getArray(PBDeserializer parser, Class componentType) { 60 | int size = 0; 61 | try { 62 | size = parser.scanNaturalInt(); 63 | } catch (Exception e) { 64 | e.printStackTrace(); 65 | } 66 | Object array = Array.newInstance(componentType, size); 67 | parser.addToObjectIndexMap(array, this); 68 | 69 | if (componentType == Object.class) { 70 | getObjectElement(parser, array, size); 71 | } else { 72 | getElementWithGerenic(parser, array, componentType, size); 73 | } 74 | return array; 75 | } 76 | 77 | @Override 78 | public void setEachElement(Object multi, int i, Object item) { 79 | ((Object[]) multi)[i] = item; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/AtomicBooleanDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.util.concurrent.atomic.AtomicBoolean; 23 | 24 | public class AtomicBooleanDeserializer implements ObjectDeserializer { 25 | 26 | public final static AtomicBooleanDeserializer instance = new AtomicBooleanDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | AtomicBoolean value = null; 31 | try { 32 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 33 | value = deserializer.scanAtomicBool(); 34 | } 35 | } catch (Exception ex) { 36 | ex.printStackTrace(); 37 | } 38 | return (T) value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/AtomicIntegerDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.util.concurrent.atomic.AtomicInteger; 23 | 24 | public class AtomicIntegerDeserializer implements ObjectDeserializer { 25 | 26 | public final static AtomicIntegerDeserializer instance = new AtomicIntegerDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | AtomicInteger value = null; 31 | try { 32 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 33 | value = deserializer.scanAtomicInt(); 34 | } 35 | } catch (Exception ex) { 36 | ex.printStackTrace(); 37 | } 38 | return (T) value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/AtomicLongDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.util.concurrent.atomic.AtomicLong; 23 | 24 | public class AtomicLongDeserializer implements ObjectDeserializer { 25 | 26 | public final static AtomicLongDeserializer instance = new AtomicLongDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | AtomicLong value = null; 31 | try { 32 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 33 | value = deserializer.scanAtomicLong(); 34 | } 35 | } catch (Exception ex) { 36 | ex.printStackTrace(); 37 | } 38 | return (T) value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/BigDecimalDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class BigDecimalDeserializer implements ObjectDeserializer { 24 | 25 | public final static BigDecimalDeserializer instance = new BigDecimalDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Object value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanBigDecimal(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/BigIntegerDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class BigIntegerDeserializer implements ObjectDeserializer { 24 | 25 | public final static BigIntegerDeserializer instance = new BigIntegerDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Object value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanBigInteger(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/ClassDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class ClassDeserializer implements ObjectDeserializer { 24 | 25 | public static final ClassDeserializer instance = new ClassDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Class value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | String className = deserializer.scanString(); 33 | value = Class.forName(className); 34 | } 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | } 38 | return (T) value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/DateDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.util.Date; 23 | 24 | public class DateDeserializer implements ObjectDeserializer { 25 | public final static DateDeserializer instance = new DateDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Date value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanDate(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/EnumDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class EnumDeserializer implements ObjectDeserializer { 24 | 25 | private final Class enumClass; 26 | 27 | public EnumDeserializer(Class enumClass) { 28 | this.enumClass = enumClass; 29 | } 30 | 31 | @Override 32 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 33 | Enum value = null; 34 | try { 35 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 36 | value = deserializer.scanEnum(enumClass); 37 | } 38 | } catch (Exception ex) { 39 | ex.printStackTrace(); 40 | } 41 | return (T) value; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/InetAddressDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.net.InetAddress; 23 | 24 | public class InetAddressDeserializer implements ObjectDeserializer { 25 | 26 | public final static InetAddressDeserializer instance = new InetAddressDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | InetAddress value = null; 31 | try { 32 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 33 | value = deserializer.scanInetAddress(); 34 | } 35 | } catch (Exception ex) { 36 | ex.printStackTrace(); 37 | } 38 | return (T) value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/JavaObjectDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | 24 | public class JavaObjectDeserializer implements ObjectDeserializer { 25 | 26 | public static final JavaObjectDeserializer instance = new JavaObjectDeserializer(); 27 | 28 | //这个反序列化器进行所有用Object声明的属性的反序列化 29 | @Override 30 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 31 | int typeCode = deserializer.scanType(); 32 | return (T) deserializer.parsePureObject(typeCode); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/StackTraceElementDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | import com.jd.dd.glowworm.deserializer.primary.IntegerDeserializer; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | public class StackTraceElementDeserializer implements ObjectDeserializer { 25 | 26 | public static final StackTraceElementDeserializer instance = new StackTraceElementDeserializer(); 27 | 28 | @Override 29 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 30 | Object obj; 31 | if (needConfirmExist) {//作为对象的属性 32 | if (deserializer.isObjectExist()) { 33 | obj = getStackTraceElement(deserializer); 34 | } else { 35 | obj = deserializer.getReference(); 36 | } 37 | } else { 38 | obj = getStackTraceElement(deserializer); 39 | } 40 | return (T) obj; 41 | } 42 | 43 | private Object getStackTraceElement(PBDeserializer deserializer) { 44 | String className = StringDeserializer.instance.deserialize(deserializer, null, true); 45 | if (className != null && !className.equals("")) { 46 | String fileName = StringDeserializer.instance.deserialize(deserializer, String.class, true); 47 | Integer lineNumber = IntegerDeserializer.instance.deserialize(deserializer, Integer.class, true); 48 | String methodName = StringDeserializer.instance.deserialize(deserializer, String.class, true); 49 | return new StackTraceElement(className, methodName, fileName, lineNumber); 50 | } else { 51 | return null; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/StringDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class StringDeserializer implements ObjectDeserializer { 24 | 25 | public final static StringDeserializer instance = new StringDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | String value = null; 30 | try { 31 | value = deserializer.scanStringWithCharset(); 32 | } catch (Exception ex) { 33 | ex.printStackTrace(); 34 | } 35 | return (T) value; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/TimeDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.sql.Time; 23 | 24 | public class TimeDeserializer implements ObjectDeserializer { 25 | public final static TimeDeserializer instance = new TimeDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Time value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanTime(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/normal/TimestampDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.normal; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | import java.sql.Timestamp; 23 | 24 | public class TimestampDeserializer implements ObjectDeserializer { 25 | public final static TimestampDeserializer instance = new TimestampDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Timestamp value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanTimeStamp(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/BooleanArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class BooleanArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static BooleanArrayDeserializer instance = new BooleanArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | boolean[] booleans = null; 30 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 31 | try { 32 | booleans = deserializer.scanBooleanArray(); 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | return (T) booleans; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/BooleanDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class BooleanDeserializer implements ObjectDeserializer { 24 | public final static BooleanDeserializer instance = new BooleanDeserializer(); 25 | 26 | @Override 27 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 28 | Boolean value = null; 29 | try { 30 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 31 | value = deserializer.scanBool(); 32 | } 33 | } catch (Exception ex) { 34 | ex.printStackTrace(); 35 | } 36 | return (T) value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/ByteArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class ByteArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static ByteArrayDeserializer instance = new ByteArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | byte[] ret = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | ret = deserializer.scanByteArray(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) ret; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/ByteDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class ByteDeserializer implements ObjectDeserializer { 24 | public final static ByteDeserializer instance = new ByteDeserializer(); 25 | 26 | @Override 27 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 28 | Byte value = null; 29 | try { 30 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 31 | value = deserializer.scanByte(); 32 | } 33 | } catch (Exception ex) { 34 | ex.printStackTrace(); 35 | } 36 | return (T) value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/CharArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class CharArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static CharArrayDeserializer instance = new CharArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | String value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanStringWithCharset(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) value.toCharArray(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/CharacterDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | import com.jd.dd.glowworm.util.TypeUtils; 21 | 22 | import java.lang.reflect.Type; 23 | 24 | public class CharacterDeserializer implements ObjectDeserializer { 25 | public final static CharacterDeserializer instance = new CharacterDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Object value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanStringWithCharset(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) TypeUtils.castToChar(value); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/DoubleArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class DoubleArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static DoubleArrayDeserializer instance = new DoubleArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | double[] doubles = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | doubles = deserializer.scanDoubleArray(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) doubles; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/DoubleDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class DoubleDeserializer implements ObjectDeserializer { 24 | 25 | public final static DoubleDeserializer instance = new DoubleDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Double value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanDouble(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/FloatArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class FloatArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static FloatArrayDeserializer instance = new FloatArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | float[] floats = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | floats = deserializer.scanFloatArray(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) floats; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/FloatDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class FloatDeserializer implements ObjectDeserializer { 24 | 25 | public final static FloatDeserializer instance = new FloatDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Float value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanFloat(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/IntArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class IntArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static IntArrayDeserializer instance = new IntArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | int[] ints = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | ints = deserializer.scanIntArray(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) ints; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/IntegerDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class IntegerDeserializer implements ObjectDeserializer { 24 | public final static IntegerDeserializer instance = new IntegerDeserializer(); 25 | 26 | @Override 27 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 28 | Integer value = null; 29 | try { 30 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 31 | value = deserializer.scanInt(); 32 | } 33 | } catch (Exception ex) { 34 | ex.printStackTrace(); 35 | } 36 | return (T) value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/LongArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class LongArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static LongArrayDeserializer instance = new LongArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | long[] longs = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | longs = deserializer.scanLongArray(); 33 | } 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return (T) longs; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/LongDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class LongDeserializer implements ObjectDeserializer { 24 | 25 | public final static LongDeserializer instance = new LongDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | Long value = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | value = deserializer.scanLong(); 33 | } 34 | } catch (Exception ex) { 35 | ex.printStackTrace(); 36 | } 37 | return (T) value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/ShortArrayDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class ShortArrayDeserializer implements ObjectDeserializer { 24 | 25 | public final static ShortArrayDeserializer instance = new ShortArrayDeserializer(); 26 | 27 | @Override 28 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 29 | short[] shorts = null; 30 | try { 31 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 32 | int size = deserializer.scanNaturalInt(); 33 | shorts = new short[size]; 34 | for (int i = 0; i < size; i++) { 35 | shorts[i] = deserializer.scanShort(); 36 | } 37 | } 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | return (T) shorts; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/primary/ShortDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.primary; 17 | 18 | import com.jd.dd.glowworm.deserializer.ObjectDeserializer; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | public class ShortDeserializer implements ObjectDeserializer { 24 | public final static ShortDeserializer instance = new ShortDeserializer(); 25 | 26 | @Override 27 | public T deserialize(PBDeserializer deserializer, Type type, boolean needConfirmExist, Object... extraParams) { 28 | Short value = null; 29 | try { 30 | if (needConfirmExist && deserializer.isObjectExist() || !needConfirmExist) { 31 | value = deserializer.scanShort(); 32 | } 33 | } catch (Exception ex) { 34 | ex.printStackTrace(); 35 | } 36 | return (T) value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/deserializer/reflect/FieldDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.deserializer.reflect; 17 | 18 | import com.jd.dd.glowworm.PBException; 19 | import com.jd.dd.glowworm.deserializer.PBDeserializer; 20 | import com.jd.dd.glowworm.util.FieldInfo; 21 | 22 | import java.lang.reflect.Method; 23 | import java.lang.reflect.Type; 24 | import java.util.Collection; 25 | import java.util.Map; 26 | 27 | public abstract class FieldDeserializer implements Comparable { 28 | 29 | protected final FieldInfo fieldInfo; 30 | 31 | protected final Class clazz; 32 | 33 | public FieldDeserializer(Class clazz, FieldInfo fieldInfo) { 34 | this.clazz = clazz; 35 | this.fieldInfo = fieldInfo; 36 | } 37 | 38 | public Method getMethod() { 39 | return fieldInfo.getMethod(); 40 | } 41 | 42 | public Class getFieldClass() { 43 | return fieldInfo.getFieldClass(); 44 | } 45 | 46 | public Type getFieldType() { 47 | return fieldInfo.getFieldType(); 48 | } 49 | 50 | public abstract void parseField(PBDeserializer parser, Object object, Type objectType, 51 | Map fieldValues); 52 | 53 | public void setValue(Object object, boolean value) { 54 | setValue(object, Boolean.valueOf(value)); 55 | } 56 | 57 | public void setValue(Object object, int value) { 58 | setValue(object, Integer.valueOf(value)); 59 | } 60 | 61 | public void setValue(Object object, long value) { 62 | setValue(object, Long.valueOf(value)); 63 | } 64 | 65 | public void setValue(Object object, String value) { 66 | setValue(object, (Object) value); 67 | } 68 | 69 | @SuppressWarnings({"rawtypes", "unchecked"}) 70 | public void setValue(Object object, Object value) { 71 | Method method = fieldInfo.getMethod(); 72 | if (method != null) { 73 | try { 74 | if (fieldInfo.isGetOnly()) { 75 | Collection collection = (Collection) method.invoke(object); 76 | collection.addAll((Collection) value); 77 | } else { 78 | method.invoke(object, value); 79 | } 80 | } catch (Exception e) { 81 | throw new PBException("set property error, " + fieldInfo.getName(), e); 82 | } 83 | } else if (fieldInfo.getField() != null) { 84 | try { 85 | fieldInfo.getField().set(object, value); 86 | } catch (Exception e) { 87 | throw new PBException("set property error, " + fieldInfo.getName(), e); 88 | } 89 | } 90 | } 91 | 92 | public int compareTo(Object o) { 93 | return this.getFieldInfo().compareTo(((FieldDeserializer) o).getFieldInfo()); 94 | } 95 | 96 | public FieldInfo getFieldInfo() { 97 | return fieldInfo; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/ObjectSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer; 17 | 18 | import java.io.IOException; 19 | 20 | public interface ObjectSerializer { 21 | 22 | void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/multi/ArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.multi; 17 | 18 | import com.jd.dd.glowworm.asm.Type; 19 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 20 | import com.jd.dd.glowworm.serializer.PBSerializer; 21 | 22 | import java.io.IOException; 23 | 24 | public class ArraySerializer extends MultiSerializer implements ObjectSerializer { 25 | 26 | public final static ArraySerializer instance = new ArraySerializer(); 27 | 28 | @Override 29 | public Object getEachElement(Object array, int i) { 30 | return ((Object[]) array)[i]; 31 | } 32 | 33 | @Override 34 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 35 | if (needWriteType) { 36 | serializer.writeType(Type.ARRAY); 37 | } 38 | Class elementClazz; 39 | if (!needWriteType) {//如果是在写javabean的属性,则会传extraParams 40 | elementClazz = (Class) extraParams[0]; 41 | } else {//如果在序列化集合,则不传extraParams 42 | elementClazz = object.getClass().getComponentType(); 43 | } 44 | Object[] array = (Object[]) object; 45 | int size = array.length; 46 | serializer.writeNaturalInt(size); 47 | if (elementClazz == Object.class) {//如果是Object[] 48 | writeObjectElement(serializer, array, size); 49 | } else {//如果是特定类型的数组 50 | writeElementWithGerenic(serializer, array, elementClazz, size); 51 | } 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/multi/ListSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.multi; 17 | 18 | 19 | import com.jd.dd.glowworm.asm.Type; 20 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 21 | import com.jd.dd.glowworm.serializer.PBSerializer; 22 | 23 | import java.io.IOException; 24 | import java.util.ArrayList; 25 | import java.util.LinkedList; 26 | import java.util.List; 27 | 28 | public class ListSerializer extends MultiSerializer implements ObjectSerializer { 29 | 30 | public final static ListSerializer instance = new ListSerializer(); 31 | 32 | @Override 33 | public Object getEachElement(Object multi, int i) { 34 | return ((List) multi).get(i); 35 | } 36 | 37 | @Override 38 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 39 | int size = ((List) object).size(); 40 | serializer.writeNaturalInt(size); 41 | if (!needWriteType) { 42 | if (isInterface(extraParams)) { 43 | writeActualType(serializer, object); 44 | } 45 | Class componentClazz = (Class) extraParams[0]; 46 | if (componentClazz == Object.class) {//选择性写入类名(Object) 47 | writeObjectElement(serializer, object, size); 48 | } else {//都不写(Generic) 49 | writeElementWithGerenic(serializer, object, componentClazz, size); 50 | } 51 | } else { 52 | writeActualType(serializer, object); 53 | writeObjectElement(serializer, object, size); 54 | } 55 | } 56 | 57 | private void writeActualType(PBSerializer serializer, Object object) { 58 | Class clazz = object.getClass(); 59 | if (ArrayList.class.isAssignableFrom(clazz)) { 60 | serializer.writeType(Type.LIST_ARRAYLIST); 61 | } else if (LinkedList.class.isAssignableFrom(clazz)) { 62 | serializer.writeType(Type.LIST_LINKEDLIST); 63 | } else if (clazz.getName().equals("java.util.Arrays$ArrayList")) { 64 | serializer.writeType(Type.LIST_ARRAYS_ARRAYLIST); 65 | } else { 66 | serializer.writeType(Type.Unknown); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/AtomicBooleanSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.util.concurrent.atomic.AtomicBoolean; 23 | 24 | public class AtomicBooleanSerializer implements ObjectSerializer { 25 | 26 | public final static AtomicBooleanSerializer instance = new AtomicBooleanSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | AtomicBoolean value = (AtomicBoolean) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ATOMIC_BOOL); 33 | } 34 | serializer.writeBool(value.get()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/AtomicIntegerSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.util.concurrent.atomic.AtomicInteger; 23 | 24 | public class AtomicIntegerSerializer implements ObjectSerializer { 25 | 26 | public final static AtomicIntegerSerializer instance = new AtomicIntegerSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | AtomicInteger value = (AtomicInteger) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ATOMIC_INT); 33 | } 34 | serializer.writeInt(value.get()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/AtomicLongSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.util.concurrent.atomic.AtomicLong; 23 | 24 | public class AtomicLongSerializer implements ObjectSerializer { 25 | 26 | public final static AtomicLongSerializer instance = new AtomicLongSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | AtomicLong value = (AtomicLong) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ATOMIC_LONG); 33 | } 34 | serializer.writeLong(value.get()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/BigDecimalSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.math.BigDecimal; 23 | 24 | public class BigDecimalSerializer implements ObjectSerializer { 25 | 26 | public final static BigDecimalSerializer instance = new BigDecimalSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | BigDecimal val = (BigDecimal) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.BIGDECIMAL); 33 | } 34 | serializer.writeString(val.toString()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/BigIntegerSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.math.BigInteger; 23 | 24 | public class BigIntegerSerializer implements ObjectSerializer { 25 | 26 | public final static BigIntegerSerializer instance = new BigIntegerSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | BigInteger val = (BigInteger) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.BIGINTEGER); 33 | } 34 | serializer.writeString(val.toString()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/ClassSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class ClassSerializer implements ObjectSerializer { 24 | 25 | public final static ClassSerializer instance = new ClassSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | if (needWriteType) { 30 | serializer.writeType(com.jd.dd.glowworm.asm.Type.CLASS); 31 | } 32 | Class clazz = (Class) object; 33 | serializer.writeString(clazz.getName()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/DateSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.util.Date; 23 | 24 | public class DateSerializer implements ObjectSerializer { 25 | 26 | public final static DateSerializer instance = new DateSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | Date value = (Date) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.DATE); 33 | } 34 | serializer.writeLong(value.getTime()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/EnumSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | 24 | public class EnumSerializer implements ObjectSerializer { 25 | 26 | public final static EnumSerializer instance = new EnumSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | Enum e = (Enum) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ENUM); 33 | serializer.writeString(object.getClass().getName()); 34 | } 35 | serializer.writeString(e.name()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/ExceptionSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.asm.Type; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | import com.jd.dd.glowworm.serializer.reflect.JavaBeanSerializer; 21 | 22 | import java.io.IOException; 23 | 24 | public class ExceptionSerializer extends JavaBeanSerializer { 25 | 26 | public ExceptionSerializer(Class clazz) { 27 | super(clazz); 28 | } 29 | 30 | @Override 31 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 32 | if (needWriteType) { 33 | serializer.writeType(Type.EXCEPTION); 34 | } 35 | super.write(serializer, object, false, extraParams); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/InetAddressSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.net.InetAddress; 23 | 24 | public class InetAddressSerializer implements ObjectSerializer { 25 | 26 | public static InetAddressSerializer instance = new InetAddressSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.INETADDRESS); 32 | } 33 | serializer.writeString(((InetAddress) object).getHostAddress()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/StringSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class StringSerializer implements ObjectSerializer { 24 | 25 | public static StringSerializer instance = new StringSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | if (needWriteType) { 30 | serializer.writeType(com.jd.dd.glowworm.asm.Type.STRING); 31 | } 32 | serializer.writeStringWithCharset(object.toString()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/TimeSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.sql.Time; 23 | 24 | public class TimeSerializer implements ObjectSerializer { 25 | 26 | public final static TimeSerializer instance = new TimeSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | Time value = (Time) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.TIME); 33 | } 34 | serializer.writeLong(value.getTime()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/normal/TimestampSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.normal; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | import java.sql.Timestamp; 23 | 24 | public class TimestampSerializer implements ObjectSerializer { 25 | 26 | public final static TimestampSerializer instance = new TimestampSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | Timestamp value = (Timestamp) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.TIMESTAMP); 33 | } 34 | serializer.writeLong(value.getTime()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/BooleanArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class BooleanArraySerializer implements ObjectSerializer { 24 | 25 | public static BooleanArraySerializer instance = new BooleanArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_BOOLEAN); 30 | } 31 | boolean[] array = (boolean[]) object; 32 | serializer.writeBooleanArray(array); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/BooleanSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class BooleanSerializer implements ObjectSerializer { 24 | 25 | public final static BooleanSerializer instance = new BooleanSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | Boolean value = (Boolean) object; 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.BOOLEAN); 32 | } 33 | serializer.writeBool(value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/ByteArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class ByteArraySerializer implements ObjectSerializer { 24 | 25 | public static ByteArraySerializer instance = new ByteArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_BYTE); 30 | } 31 | byte[] array = (byte[]) object; 32 | serializer.writeByteArray(array); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/ByteSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | 24 | public class ByteSerializer implements ObjectSerializer { 25 | 26 | public static ByteSerializer instance = new ByteSerializer(); 27 | 28 | @Override 29 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 30 | Byte value = (Byte) object; 31 | if (needWriteType) { 32 | serializer.writeType(com.jd.dd.glowworm.asm.Type.BYTE); 33 | } 34 | serializer.writeByte(value); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/CharArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | 24 | public class CharArraySerializer implements ObjectSerializer { 25 | 26 | public static CharArraySerializer instance = new CharArraySerializer(); 27 | 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | if (needWriteType) { 30 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_CHAR); 31 | } 32 | char[] chars = (char[]) object; 33 | serializer.writeStringWithCharset(new String(chars)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/CharacterSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class CharacterSerializer implements ObjectSerializer { 24 | 25 | public final static CharacterSerializer instance = new CharacterSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | Character value = (Character) object; 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.CHAR); 32 | } 33 | serializer.writeStringWithCharset(value.toString()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/DoubleArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class DoubleArraySerializer implements ObjectSerializer { 24 | 25 | public static final DoubleArraySerializer instance = new DoubleArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_DOUBLE); 30 | } 31 | double[] array = (double[]) object; 32 | serializer.writeDoubleArray(array); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/DoubleSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class DoubleSerializer implements ObjectSerializer { 24 | 25 | public final static DoubleSerializer instance = new DoubleSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | double doubleValue = ((Double) object).doubleValue(); 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.DOUBLE); 32 | } 33 | serializer.writeDouble(doubleValue); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/FloatArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class FloatArraySerializer implements ObjectSerializer { 24 | 25 | public static final FloatArraySerializer instance = new FloatArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_FLOAT); 30 | } 31 | float[] array = (float[]) object; 32 | 33 | serializer.writeFloatArray(array); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/FloatSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class FloatSerializer implements ObjectSerializer { 24 | 25 | public static FloatSerializer instance = new FloatSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | float floatValue = ((Float) object).floatValue(); 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.FLOAT); 32 | } 33 | serializer.writeFloat(floatValue); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/IntArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class IntArraySerializer implements ObjectSerializer { 24 | 25 | public static IntArraySerializer instance = new IntArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_INT); 30 | } 31 | int[] array = (int[]) object; 32 | 33 | serializer.writeIntArray(array); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/IntegerSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class IntegerSerializer implements ObjectSerializer { 24 | 25 | public static IntegerSerializer instance = new IntegerSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | Number value = (Number) object; 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.INT); 32 | } 33 | serializer.writeInt(value.intValue()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/LongArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class LongArraySerializer implements ObjectSerializer { 24 | 25 | public static LongArraySerializer instance = new LongArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_LONG); 30 | } 31 | long[] array = (long[]) object; 32 | 33 | serializer.writeLongArray(array); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/LongSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class LongSerializer implements ObjectSerializer { 24 | 25 | public final static LongSerializer instance = new LongSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | long longValue = ((Long) object).longValue(); 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.LONG); 32 | } 33 | serializer.writeLong(longValue); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/ShortArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class ShortArraySerializer implements ObjectSerializer { 24 | 25 | public static ShortArraySerializer instance = new ShortArraySerializer(); 26 | 27 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 28 | if (needWriteType) { 29 | serializer.writeType(com.jd.dd.glowworm.asm.Type.ARRAY_SHORT); 30 | } 31 | short[] array = (short[]) object; 32 | serializer.writeShortArray(array); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/primary/ShortSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.primary; 17 | 18 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 19 | import com.jd.dd.glowworm.serializer.PBSerializer; 20 | 21 | import java.io.IOException; 22 | 23 | public class ShortSerializer implements ObjectSerializer { 24 | 25 | public static ShortSerializer instance = new ShortSerializer(); 26 | 27 | @Override 28 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 29 | Number value = (Number) object; 30 | if (needWriteType) { 31 | serializer.writeType(com.jd.dd.glowworm.asm.Type.SHORT); 32 | } 33 | serializer.writeShort(value.shortValue()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/reflect/FieldSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.reflect; 17 | 18 | import com.jd.dd.glowworm.serializer.PBSerializer; 19 | import com.jd.dd.glowworm.util.FieldInfo; 20 | 21 | import java.lang.reflect.Field; 22 | import java.lang.reflect.Method; 23 | 24 | public abstract class FieldSerializer implements Comparable { 25 | 26 | protected final FieldInfo fieldInfo; 27 | private boolean writeNull = false; 28 | 29 | public FieldSerializer(FieldInfo fieldInfo) { 30 | super(); 31 | this.fieldInfo = fieldInfo; 32 | fieldInfo.setAccessible(true); 33 | } 34 | 35 | public boolean isWriteNull() { 36 | return writeNull; 37 | } 38 | 39 | public Field getField() { 40 | return fieldInfo.getField(); 41 | } 42 | 43 | public String getName() { 44 | return fieldInfo.getName(); 45 | } 46 | 47 | public Method getMethod() { 48 | return fieldInfo.getMethod(); 49 | } 50 | 51 | public int compareTo(FieldSerializer o) { 52 | return this.getName().compareTo(o.getName()); 53 | } 54 | 55 | public Object getPropertyValue(Object object) throws Exception { 56 | return fieldInfo.get(object); 57 | } 58 | 59 | public abstract void writeProperty(PBSerializer serializer, Object propertyValue, int fieldInfoIndexParm) throws Exception; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/serializer/reflect/JavaBeanSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.serializer.reflect; 17 | 18 | import com.jd.dd.glowworm.PBException; 19 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 20 | import com.jd.dd.glowworm.serializer.PBSerializer; 21 | import com.jd.dd.glowworm.util.FieldInfo; 22 | import com.jd.dd.glowworm.util.TypeUtils; 23 | 24 | import java.io.IOException; 25 | import java.lang.reflect.Field; 26 | import java.lang.reflect.Modifier; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | import java.util.Map; 30 | 31 | public class JavaBeanSerializer implements ObjectSerializer { 32 | 33 | private final FieldSerializer[] sortedGetters; 34 | 35 | public JavaBeanSerializer(Class clazz) { 36 | this(clazz, (Map) null); 37 | } 38 | 39 | @Override 40 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 41 | final FieldSerializer[] getters = this.sortedGetters; 42 | 43 | try { 44 | if (needWriteType) { 45 | serializer.writeType(com.jd.dd.glowworm.asm.Type.OBJECT); 46 | serializer.writeString(object.getClass().getName()); 47 | } 48 | 49 | for (int i = 0; i < getters.length; ++i) { 50 | FieldSerializer fieldSerializer = getters[i]; 51 | Field field = fieldSerializer.getField(); 52 | if (field != null) { 53 | if (Modifier.isTransient(field.getModifiers())) { 54 | continue; 55 | } 56 | } 57 | 58 | Object propertyValue = fieldSerializer.getPropertyValue(object); 59 | fieldSerializer.writeProperty(serializer, propertyValue, i); 60 | } 61 | } catch (Exception e) { 62 | throw new PBException("write javaBean error", e); 63 | } 64 | } 65 | 66 | public JavaBeanSerializer(Class clazz, Map aliasMap) { 67 | { 68 | List getterList = new ArrayList(); 69 | List fieldInfoList = TypeUtils.computeGetters(clazz, aliasMap, true); 70 | 71 | for (FieldInfo fieldInfo : fieldInfoList) { 72 | getterList.add(createFieldSerializer(fieldInfo)); 73 | } 74 | 75 | sortedGetters = getterList.toArray(new FieldSerializer[getterList.size()]); 76 | } 77 | } 78 | 79 | public FieldSerializer createFieldSerializer(FieldInfo fieldInfo) { 80 | return new ObjectFieldSerializer(fieldInfo); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/ASMClassLoader.java: -------------------------------------------------------------------------------- 1 | package com.jd.dd.glowworm.util; 2 | 3 | import com.jd.dd.glowworm.PBException; 4 | 5 | import java.security.PrivilegedAction; 6 | 7 | 8 | public class ASMClassLoader extends ClassLoader { 9 | 10 | private static java.security.ProtectionDomain DOMAIN; 11 | 12 | static { 13 | DOMAIN = (java.security.ProtectionDomain) java.security.AccessController.doPrivileged(new PrivilegedAction() { 14 | 15 | public Object run() { 16 | return ASMClassLoader.class.getProtectionDomain(); 17 | } 18 | }); 19 | } 20 | 21 | public ASMClassLoader() { 22 | super(Thread.currentThread().getContextClassLoader()); 23 | } 24 | 25 | public Class defineClassPublic(String name, byte[] b, int off, int len) throws ClassFormatError { 26 | Class clazz = defineClass(name, b, off, len, DOMAIN); 27 | 28 | return clazz; 29 | } 30 | 31 | public static Class forName(String className) { 32 | try { 33 | ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 34 | return classLoader.loadClass(className); 35 | } catch (ClassNotFoundException e) { 36 | throw new PBException("class nout found : " + className); 37 | } 38 | } 39 | 40 | public static boolean isExternalClass(Class clazz) { 41 | ClassLoader classLoader = clazz.getClassLoader(); 42 | 43 | if (classLoader == null) { 44 | return false; 45 | } 46 | 47 | ClassLoader current = Thread.currentThread().getContextClassLoader(); 48 | while (current != null) { 49 | if (current == classLoader) { 50 | return false; 51 | } 52 | 53 | current = current.getParent(); 54 | } 55 | 56 | return true; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/BufferInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | 19 | import java.io.IOException; 20 | 21 | public final class BufferInputStream { 22 | byte[] buffer; 23 | int limit; 24 | int pos; 25 | int mark; 26 | 27 | public BufferInputStream(byte[] data) { 28 | this(data, 0, data.length); 29 | } 30 | 31 | public BufferInputStream(Buffer sequence) { 32 | this(sequence.getData(), sequence.getOffset(), sequence.getLength()); 33 | } 34 | 35 | public BufferInputStream(byte[] data, int offset, int size) { 36 | this.buffer = data; 37 | this.mark = offset; 38 | this.pos = offset; 39 | this.limit = (offset + size); 40 | } 41 | 42 | public BufferInputStream(byte[] data, int offset) { 43 | this.buffer = data; 44 | this.mark = offset; 45 | this.pos = offset; 46 | this.limit = (offset + data.length); 47 | } 48 | 49 | public int read() throws IOException { 50 | if (this.pos < this.limit) 51 | return (this.buffer[(this.pos++)] & 0xFF); 52 | 53 | return -1; 54 | } 55 | 56 | public int read(byte[] b) throws IOException { 57 | return read(b, 0, b.length); 58 | } 59 | 60 | public int read(byte[] b, int off, int len) { 61 | if (this.pos < this.limit) { 62 | len = Math.min(len, this.limit - this.pos); 63 | System.arraycopy(this.buffer, this.pos, b, off, len); 64 | this.pos += len; 65 | return len; 66 | } 67 | return -1; 68 | } 69 | 70 | public Buffer readBuffer(int len) { 71 | Buffer rc = null; 72 | if (this.pos < this.limit) { 73 | len = Math.min(len, this.limit - this.pos); 74 | rc = new Buffer(this.buffer, this.pos, len); 75 | this.pos += len; 76 | } 77 | return rc; 78 | } 79 | 80 | public long skip(long len) throws IOException { 81 | if (this.pos < this.limit) { 82 | len = Math.min(len, this.limit - this.pos); 83 | if (len > 0L) { 84 | BufferInputStream tmp33_32 = this; 85 | tmp33_32.pos = (int) (tmp33_32.pos + len); 86 | } 87 | return len; 88 | } 89 | return -1L; 90 | } 91 | 92 | public int available() { 93 | return (this.limit - this.pos); 94 | } 95 | 96 | public boolean markSupported() { 97 | return true; 98 | } 99 | 100 | public void mark(int markpos) { 101 | this.mark = this.pos; 102 | } 103 | 104 | public void reset() { 105 | this.pos = this.mark; 106 | } 107 | 108 | public void setNewData(byte[] data) { 109 | this.buffer = data; 110 | this.mark = 0; 111 | this.pos = 0; 112 | this.limit = (0 + data.length); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/BufferOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | 19 | import java.io.IOException; 20 | 21 | public final class BufferOutputStream { 22 | byte[] buffer; 23 | int offset; 24 | int limit; 25 | int pos; 26 | 27 | public BufferOutputStream(int size) { 28 | this(new byte[size]); 29 | } 30 | 31 | public BufferOutputStream(byte[] buffer) { 32 | this.buffer = buffer; 33 | this.limit = buffer.length; 34 | } 35 | 36 | public BufferOutputStream(Buffer data) { 37 | this.buffer = data.data; 38 | this.pos = (this.offset = data.offset); 39 | this.limit = (data.offset + data.length); 40 | } 41 | 42 | public void write(int b) { 43 | int newPos = this.pos + 1; 44 | checkCapacity(newPos); 45 | this.buffer[this.pos] = (byte) b; 46 | this.pos = newPos; 47 | } 48 | 49 | public void write(byte[] b, int off, int len) { 50 | int newPos = this.pos + len; 51 | checkCapacity(newPos); 52 | System.arraycopy(b, off, this.buffer, this.pos, len); 53 | this.pos = newPos; 54 | } 55 | 56 | public Buffer getNextBuffer(int len) throws IOException { 57 | int newPos = this.pos + len; 58 | checkCapacity(newPos); 59 | return new Buffer(this.buffer, this.pos, len); 60 | } 61 | 62 | private void checkCapacity(int minimumCapacity) { 63 | if (minimumCapacity > this.limit) { 64 | byte[] tmpNewBytes = new byte[minimumCapacity + 1024]; 65 | System.arraycopy(this.buffer, 0, tmpNewBytes, 0, this.limit); 66 | this.buffer = tmpNewBytes; 67 | this.limit = tmpNewBytes.length; 68 | } 69 | } 70 | 71 | public void reset() { 72 | this.pos = this.offset; 73 | } 74 | 75 | public Buffer toBuffer() { 76 | return new Buffer(this.buffer, this.offset, this.pos); 77 | } 78 | 79 | public byte[] toByteArray() { 80 | return toBuffer().toByteArray(); 81 | } 82 | 83 | 84 | public byte[] getBytes() { 85 | if (this.pos == 0) { 86 | return null; 87 | } else { 88 | byte[] retBytes = new byte[this.pos]; 89 | System.arraycopy(this.buffer, 0, retBytes, 0, this.pos); 90 | return retBytes; 91 | } 92 | } 93 | 94 | public int size() { 95 | return (this.offset - this.pos); 96 | } 97 | 98 | public byte[] getBuffer() { 99 | return buffer; 100 | } 101 | 102 | public void setBuffer(byte[] buffer) { 103 | this.buffer = buffer; 104 | } 105 | 106 | public int getPos() { 107 | return pos; 108 | } 109 | 110 | public void setPos(int pos) { 111 | this.pos = pos; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/ExistInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | import com.jd.dd.glowworm.PBException; 19 | 20 | public class ExistInputStream { 21 | 22 | private byte[] buffer; 23 | private int pos; 24 | private int limit; 25 | private int bitPos; 26 | private int offset; 27 | 28 | public ExistInputStream(byte[] bytes, int pos, int length) { 29 | this.buffer = bytes; 30 | this.pos = pos; 31 | this.limit = pos + length; 32 | } 33 | 34 | public void reset(byte[] bytes, int pos, int length) { 35 | this.buffer = bytes; 36 | this.pos = pos; 37 | this.limit = pos + length; 38 | } 39 | 40 | public int readRawByte() { 41 | if (this.pos < this.limit) { 42 | if (bitPos % 8 == 0 && bitPos != 0) { 43 | pos++; 44 | } 45 | return ((byte) (buffer[pos] >> (7 - (bitPos++ % 8))) & 1); 46 | } else { 47 | throw new PBException("out of index"); 48 | } 49 | } 50 | 51 | public void reset() { 52 | pos = offset; 53 | limit = offset; 54 | bitPos = offset; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/ExistOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | public class ExistOutputStream { 19 | 20 | byte[] buffer; 21 | int offset; 22 | int limit; 23 | int pos; 24 | int bitPos; 25 | 26 | public ExistOutputStream(int size) { 27 | this(new byte[size]); 28 | } 29 | 30 | public ExistOutputStream(byte[] buffer) { 31 | this.buffer = buffer; 32 | this.limit = buffer.length; 33 | } 34 | 35 | public void write(boolean bool) { 36 | if (bitPos != 0 && bitPos % 8 == 0) { 37 | pos++; 38 | checkCapacity(pos); 39 | } 40 | byte b1 = bitPos % 8 == 0 ? 0 : buffer[pos]; 41 | if (bool) { 42 | bitPos++; 43 | } else { 44 | b1 = (byte) (b1 | (1 << (7 - (bitPos++ % 8)))); 45 | } 46 | buffer[pos] = b1; 47 | } 48 | 49 | private void checkCapacity(int minimumCapacity) { 50 | if (minimumCapacity + 1 >= this.limit) { 51 | byte[] tmpNewBytes = new byte[minimumCapacity + 100]; 52 | System.arraycopy(this.buffer, 0, tmpNewBytes, 0, this.limit); 53 | this.buffer = tmpNewBytes; 54 | this.limit = tmpNewBytes.length; 55 | } 56 | } 57 | 58 | public void reset() { 59 | this.pos = this.offset; 60 | this.bitPos = this.offset; 61 | } 62 | 63 | public byte[] getBytes() { 64 | if (this.bitPos == 0) { 65 | return null; 66 | } else { 67 | byte[] retBytes = new byte[pos + 1]; 68 | System.arraycopy(buffer, 0, retBytes, 0, pos + 1); 69 | return retBytes; 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/IdentityHashMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | /** 19 | * for concurrent IdentityHashMap 20 | * 21 | * @author wenshao 22 | */ 23 | @SuppressWarnings("unchecked") 24 | public class IdentityHashMap { 25 | 26 | public static final int DEFAULT_TABLE_SIZE = 1024; 27 | 28 | private final Entry[] buckets; 29 | private final int indexMask; 30 | 31 | public IdentityHashMap() { 32 | this(DEFAULT_TABLE_SIZE); 33 | } 34 | 35 | public IdentityHashMap(int tableSize) { 36 | this.indexMask = tableSize - 1; 37 | this.buckets = new Entry[tableSize]; 38 | } 39 | 40 | public final V get(K key) { 41 | final int hash = System.identityHashCode(key); 42 | final int bucket = hash & indexMask; 43 | 44 | for (Entry entry = buckets[bucket]; entry != null; entry = entry.next) { 45 | if (key == entry.key) { 46 | return (V) entry.value; 47 | } 48 | } 49 | 50 | return null; 51 | } 52 | 53 | public boolean put(K key, V value) { 54 | final int hash = System.identityHashCode(key); 55 | final int bucket = hash & indexMask; 56 | 57 | for (Entry entry = buckets[bucket]; entry != null; entry = entry.next) { 58 | if (key == entry.key) { 59 | entry.value = value; 60 | return true; 61 | } 62 | } 63 | 64 | Entry entry = new Entry(key, value, hash, buckets[bucket]); 65 | buckets[bucket] = entry; // 并发是处理时会可能导致缓存丢失,但不影响正确�? 66 | 67 | return false; 68 | } 69 | 70 | public int size() { 71 | int size = 0; 72 | for (int i = 0; i < buckets.length; ++i) { 73 | for (Entry entry = buckets[i]; entry != null; entry = entry.next) { 74 | size++; 75 | } 76 | } 77 | return size; 78 | } 79 | 80 | protected static final class Entry { 81 | 82 | public final int hashCode; 83 | public final K key; 84 | public V value; 85 | 86 | public final Entry next; 87 | 88 | public Entry(K key, V value, int hash, Entry next) { 89 | this.key = key; 90 | this.value = value; 91 | this.next = next; 92 | this.hashCode = hash; 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/InputStreamBuffer.java: -------------------------------------------------------------------------------- 1 | package com.jd.dd.glowworm.util; 2 | 3 | public class InputStreamBuffer { 4 | 5 | private CodedInputStream theCodedInputStream; 6 | private ExistInputStream existStream; 7 | private TypeInputStream typeStream; 8 | 9 | public InputStreamBuffer(CodedInputStream theCodedInputStream, ExistInputStream existStream, TypeInputStream typeStream) { 10 | this.theCodedInputStream = theCodedInputStream; 11 | this.existStream = existStream; 12 | this.typeStream = typeStream; 13 | } 14 | 15 | public CodedInputStream getTheCodedInputStream() { 16 | return theCodedInputStream; 17 | } 18 | 19 | public ExistInputStream getExistStream() { 20 | return existStream; 21 | } 22 | 23 | public TypeInputStream getTypeStream() { 24 | return typeStream; 25 | } 26 | 27 | public void setAll(CodedInputStream theCodedInputStream, ExistInputStream existStream, TypeInputStream typeStream) { 28 | this.theCodedInputStream = theCodedInputStream; 29 | this.existStream = existStream; 30 | this.typeStream = typeStream; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/InvalidProtocolBufferException.java: -------------------------------------------------------------------------------- 1 | package com.jd.dd.glowworm.util; 2 | 3 | 4 | import java.io.IOException; 5 | 6 | public class InvalidProtocolBufferException extends IOException { 7 | private static final long serialVersionUID = -951609456L; 8 | 9 | public InvalidProtocolBufferException(String description) { 10 | super(description); 11 | } 12 | 13 | static InvalidProtocolBufferException truncatedMessage() { 14 | return new InvalidProtocolBufferException("While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either than the input has been truncated or that an embedded message misreported its own length."); 15 | } 16 | 17 | static InvalidProtocolBufferException negativeSize() { 18 | return new InvalidProtocolBufferException("CodedInputStream encountered an embedded string or message which claimed to have negative size."); 19 | } 20 | 21 | static InvalidProtocolBufferException malformedVarint() { 22 | return new InvalidProtocolBufferException("CodedInputStream encountered a malformed varint."); 23 | } 24 | 25 | static InvalidProtocolBufferException invalidTag() { 26 | return new InvalidProtocolBufferException("Protocol message contained an invalid tag (zero)."); 27 | } 28 | 29 | static InvalidProtocolBufferException invalidEndTag() { 30 | return new InvalidProtocolBufferException("Protocol message end-group tag did not match expected tag."); 31 | } 32 | 33 | static InvalidProtocolBufferException invalidWireType() { 34 | return new InvalidProtocolBufferException("Protocol message tag had invalid wire type."); 35 | } 36 | 37 | static InvalidProtocolBufferException recursionLimitExceeded() { 38 | return new InvalidProtocolBufferException("Protocol message had too many levels of nesting. May be malicious. Use CodedInputStream.setRecursionLimit() to increase the depth limit."); 39 | } 40 | 41 | static InvalidProtocolBufferException sizeLimitExceeded() { 42 | return new InvalidProtocolBufferException("Protocol message was too large. May be malicious. Use CodedInputStream.setSizeLimit() to increase the size limit."); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/OutputStreamBuffer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | public class OutputStreamBuffer { 19 | 20 | private CodedOutputStream theCodedOutputStream; 21 | private CodedOutputStream refStream; 22 | private ExistOutputStream existStream; 23 | private TypeOutputStream typeStream; 24 | private CodedOutputStream headStream; 25 | 26 | 27 | public OutputStreamBuffer(CodedOutputStream theCodedOutputStream, CodedOutputStream refStream, ExistOutputStream existStream, TypeOutputStream typeStream, CodedOutputStream headStream) { 28 | this.theCodedOutputStream = theCodedOutputStream; 29 | this.refStream = refStream; 30 | this.existStream = existStream; 31 | this.typeStream = typeStream; 32 | this.headStream = headStream; 33 | } 34 | 35 | public CodedOutputStream getTheCodedOutputStream() { 36 | return theCodedOutputStream; 37 | } 38 | 39 | public CodedOutputStream getRefStream() { 40 | return refStream; 41 | } 42 | 43 | public ExistOutputStream getExistStream() { 44 | return existStream; 45 | } 46 | 47 | public TypeOutputStream getTypeStream() { 48 | return typeStream; 49 | } 50 | 51 | public CodedOutputStream getHeadStream() { 52 | return headStream; 53 | } 54 | 55 | public void setAll(CodedOutputStream theCodedOutputStream, CodedOutputStream refStream, ExistOutputStream existStream, TypeOutputStream typeStream, CodedOutputStream headStream) { 56 | this.theCodedOutputStream = theCodedOutputStream; 57 | this.refStream = refStream; 58 | this.existStream = existStream; 59 | this.typeStream = typeStream; 60 | this.headStream = headStream; 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/Parameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | public class Parameters { 19 | 20 | private String charset = "UTF-8"; 21 | private Boolean needWriteClassName = false; 22 | 23 | public String getCharset() { 24 | return charset; 25 | } 26 | 27 | public void setCharset(String charset) { 28 | this.charset = charset; 29 | } 30 | 31 | public Boolean getNeedWriteClassName() { 32 | return needWriteClassName; 33 | } 34 | 35 | public void setNeedWriteClassName(Boolean needWriteClassName) { 36 | this.needWriteClassName = needWriteClassName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/SerializeContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | public class SerializeContext { 19 | 20 | private Object obj; 21 | private Integer index; 22 | 23 | public SerializeContext() { 24 | } 25 | 26 | public SerializeContext(Object obj, Integer index) { 27 | this.obj = obj; 28 | this.index = index; 29 | } 30 | 31 | public Object getObj() { 32 | return obj; 33 | } 34 | 35 | public void setObj(Object obj) { 36 | this.obj = obj; 37 | } 38 | 39 | public Integer getIndex() { 40 | return index; 41 | } 42 | 43 | public void setIndex(Integer index) { 44 | this.index = index; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/Transient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jd.dd.glowworm.util; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Target({ElementType.METHOD, ElementType.FIELD}) 25 | public @interface Transient { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/jd/dd/glowworm/util/WireFormat.java: -------------------------------------------------------------------------------- 1 | package com.jd.dd.glowworm.util; 2 | 3 | 4 | public final class WireFormat { 5 | public static final int WIRETYPE_VARINT = 0; 6 | public static final int WIRETYPE_FIXED64 = 1; 7 | public static final int WIRETYPE_LENGTH_DELIMITED = 2; 8 | public static final int WIRETYPE_START_GROUP = 3; 9 | public static final int WIRETYPE_END_GROUP = 4; 10 | public static final int WIRETYPE_FIXED32 = 5; 11 | public static final int TAG_TYPE_BITS = 3; 12 | public static final int TAG_TYPE_MASK = 7; 13 | public static final int MESSAGE_SET_ITEM = 1; 14 | public static final int MESSAGE_SET_TYPE_ID = 2; 15 | public static final int MESSAGE_SET_MESSAGE = 3; 16 | public static final int MESSAGE_SET_ITEM_TAG = makeTag(1, 3); 17 | public static final int MESSAGE_SET_ITEM_END_TAG = makeTag(1, 4); 18 | public static final int MESSAGE_SET_TYPE_ID_TAG = makeTag(2, 0); 19 | public static final int MESSAGE_SET_MESSAGE_TAG = makeTag(3, 2); 20 | 21 | public static int getTagWireType(int tag) { 22 | return (tag & 0x7); 23 | } 24 | 25 | public static int getTagFieldNumber(int tag) { 26 | return (tag >>> 3); 27 | } 28 | 29 | public static int makeTag(int fieldNumber, int wireType) { 30 | return (fieldNumber << 3 | wireType); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/com/jd/bdp/seomonitor/model/page/SeoWord.java: -------------------------------------------------------------------------------- 1 | package com.jd.bdp.seomonitor.model.page; 2 | 3 | import java.util.Date; 4 | 5 | 6 | public class SeoWord{ 7 | 8 | private Long id; 9 | 10 | 11 | private Date grabDate; 12 | 13 | private String ranking; 14 | 15 | private Long searchNumber; 16 | 17 | private String url; 18 | 19 | private Integer isChange; 20 | private String changeDesc; 21 | 22 | private Long wordConfigId; 23 | private String wordName; 24 | private String person; 25 | 26 | private Date operateTime; 27 | private String searchTime; 28 | private Integer start; 29 | private Integer limit; 30 | 31 | public String getPerson() { 32 | return person; 33 | } 34 | 35 | public void setPerson(String person) { 36 | this.person = person; 37 | } 38 | 39 | 40 | // ==================================================================== 41 | 42 | 43 | public String getRanking() { 44 | return ranking; 45 | } 46 | 47 | public void setRanking() { 48 | this.ranking = ranking; 49 | } 50 | 51 | public Integer getStart() { 52 | return start; 53 | } 54 | 55 | public void setStart(Integer start) { 56 | this.start = start; 57 | } 58 | 59 | public Integer getLimit() { 60 | return limit; 61 | } 62 | 63 | public void setLimit(Integer limit) { 64 | this.limit = limit; 65 | } 66 | 67 | 68 | public String getChangeDesc() { 69 | // if(isChange != null) { 70 | // changeDesc = ChangeEnum.enumValueOf(isChange).toName(); 71 | // } 72 | return changeDesc; 73 | } 74 | 75 | public void setChangeDesc(String changeDesc) { 76 | this.changeDesc = changeDesc; 77 | } 78 | 79 | public String getSearchTime() { 80 | return searchTime; 81 | } 82 | 83 | public void setSearchTime(String searchTime) { 84 | this.searchTime = searchTime; 85 | } 86 | 87 | public String getWordName() { 88 | return wordName; 89 | } 90 | 91 | public void setWordName(String wordName) { 92 | this.wordName = wordName; 93 | } 94 | 95 | public Integer getChange() { 96 | return isChange; 97 | } 98 | 99 | public void setChange(Integer change) { 100 | isChange = change; 101 | } 102 | 103 | public Date getOperateTime() { 104 | return operateTime; 105 | } 106 | 107 | public void setOperateTime(Date operateTime) { 108 | this.operateTime = operateTime; 109 | } 110 | 111 | public Long getId() { 112 | return id; 113 | } 114 | 115 | public void setId(Long id) { 116 | this.id = id; 117 | } 118 | 119 | public Date getGrabDate() { 120 | return grabDate; 121 | } 122 | 123 | public void setGrabDate(Date grabDate) { 124 | this.grabDate = grabDate; 125 | } 126 | 127 | public Long getSearchNumber() { 128 | return searchNumber; 129 | } 130 | 131 | public void setSearchNumber(Long searchNumber) { 132 | this.searchNumber = searchNumber; 133 | } 134 | 135 | public String getUrl() { 136 | return url; 137 | } 138 | 139 | public void setUrl(String url) { 140 | this.url = url; 141 | } 142 | 143 | 144 | 145 | public Long getWordConfigId() { 146 | return wordConfigId; 147 | } 148 | 149 | public void setWordConfigId(Long wordConfigId) { 150 | this.wordConfigId = wordConfigId; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /src/test/java/testcase/rule/NormalTest.java: -------------------------------------------------------------------------------- 1 | package testcase.rule; 2 | 3 | import org.junit.Test; 4 | import testcase.TestBase; 5 | 6 | import java.util.List; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | public class NormalTest extends TestBase { 11 | 12 | //所有基础类型无论是否是包装类都会走同一个序列化器 13 | //测试Boolean类型 TURE 14 | @Test 15 | public void testBoolean1() throws Exception { 16 | Boolean flag = true; 17 | byte[] result = executeSerialization(flag); 18 | 19 | List list = getHeadBytesArray(result); 20 | byte[] refArray = list.get(0); 21 | byte[] existArray = list.get(1); 22 | byte[] typeHeadArray = list.get(2); 23 | byte[] typeArray = list.get(3); 24 | result = list.get(4); 25 | 26 | assertEquals(0, refArray.length); 27 | assertEquals(0, existArray.length); 28 | 29 | assertEquals(1, typeHeadArray.length); 30 | assertEquals(0, typeHeadArray[0]); 31 | assertEquals(1, typeArray.length); 32 | assertEquals(32, typeArray[0]); 33 | 34 | //检查Boolean中的值 35 | int index = 0; 36 | assertEquals(1, result[index++]);//默认写类名 37 | byte[] bytesString = (Boolean.class.getName().getBytes("UTF-8")); 38 | Byte[] bytesStringLength = writeRawVarint32(bytesString.length); 39 | for (int i = 0; i < bytesStringLength.length; i++) { 40 | assertEquals(bytesStringLength[i].toString(), String.valueOf(result[index++])); 41 | } 42 | //循环判断str内容转化成的byte[] 43 | for (int i = 0; i < bytesString.length; i++) { 44 | assertEquals(bytesString[i], result[index++]); 45 | } 46 | assertEquals(flag ? 1 : 0, result[index++]); 47 | } 48 | 49 | //测试Boolean类型 FALSE 50 | @Test 51 | public void testBoolean() throws Exception { 52 | boolean flag = false; 53 | byte[] result = executeSerialization(flag); 54 | 55 | List list = getHeadBytesArray(result); 56 | byte[] refArray = list.get(0); 57 | byte[] existArray = list.get(1); 58 | byte[] typeHeadArray = list.get(2); 59 | byte[] typeArray = list.get(3); 60 | result = list.get(4); 61 | 62 | assertEquals(0, refArray.length); 63 | assertEquals(0, existArray.length); 64 | 65 | assertEquals(1, typeHeadArray.length); 66 | assertEquals(0, typeHeadArray[0]); 67 | assertEquals(1, typeArray.length); 68 | assertEquals(32, typeArray[0]); 69 | 70 | int index = 0; 71 | assertEquals(1, result[index++]);//默认写类名 72 | byte[] bytesString = (Boolean.class.getName().getBytes("UTF-8")); 73 | Byte[] bytesStringLength = writeRawVarint32(bytesString.length); 74 | for (int i = 0; i < bytesStringLength.length; i++) { 75 | assertEquals(bytesStringLength[i].toString(), String.valueOf(result[index++])); 76 | } 77 | //循环判断str内容转化成的byte[] 78 | for (int i = 0; i < bytesString.length; i++) { 79 | assertEquals(bytesString[i], result[index++]); 80 | } 81 | //检查Boolean中的值 82 | assertEquals(flag ? 1 : 0, result[index++]); 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/AtomicPerson1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | import java.util.concurrent.atomic.AtomicLong; 6 | 7 | public class AtomicPerson1 { 8 | 9 | private AtomicInteger ai; 10 | private AtomicBoolean ab; 11 | private AtomicLong al; 12 | 13 | public AtomicInteger getAi() { 14 | return ai; 15 | } 16 | 17 | public void setAi(AtomicInteger ai) { 18 | this.ai = ai; 19 | } 20 | 21 | public AtomicBoolean getAb() { 22 | return ab; 23 | } 24 | 25 | public void setAb(AtomicBoolean ab) { 26 | this.ab = ab; 27 | } 28 | 29 | public AtomicLong getAl() { 30 | return al; 31 | } 32 | 33 | public void setAl(AtomicLong al) { 34 | this.al = al; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Broker.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | /** 4 | * User: biandi 5 | * Date: 13-7-10 6 | * Time: 下午3:26 7 | */ 8 | public class Broker { 9 | private Integer id; 10 | private String ip; 11 | private Integer port; 12 | private Boolean master; 13 | 14 | // private int load;//负载,用来表示当前broker的繁忙程度 15 | 16 | // 17 | // public int compareTo(Broker o) { 18 | // return this.getId() - o.getId(); 19 | // } 20 | // 21 | // 22 | // public boolean equals(Object obj) { 23 | // return this.id == ((Broker) obj).getId(); 24 | // } 25 | 26 | public Broker() { 27 | } 28 | 29 | public Broker(Integer id, String ip, Integer port, Boolean master) { 30 | this.id = id; 31 | this.ip = ip; 32 | this.port = port; 33 | this.master = master; 34 | } 35 | 36 | public String gnnetIp() { 37 | return ip; 38 | } 39 | 40 | public void setIp(String ip) { 41 | this.ip = ip; 42 | } 43 | 44 | // public int getLoad() { 45 | // return load; 46 | // } 47 | // 48 | // public void setLoad(int load) { 49 | // this.load = load; 50 | // } 51 | 52 | public Integer getPort() { 53 | return port; 54 | } 55 | 56 | public void setPort(Integer port) { 57 | this.port = port; 58 | } 59 | 60 | public Integer getId() { 61 | return id; 62 | } 63 | 64 | public void setId(Integer id) { 65 | this.id = id; 66 | } 67 | 68 | 69 | public Boolean getMaster() { 70 | return master; 71 | } 72 | 73 | public void setMaster(Boolean master) { 74 | this.master = master; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/CommonResponse.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | /** 4 | * User: biandi 5 | * Date: 13-7-10 6 | * Time: 下午3:22 7 | */ 8 | public class CommonResponse { 9 | 10 | public static int SUCCESS_TYPE = 0; 11 | public static int EXCEPTION_TYPE = 1; 12 | 13 | 14 | public static CommonResponse successResponse(){ 15 | return new CommonResponse(SUCCESS_TYPE); 16 | } 17 | 18 | public static CommonResponse successResponse(Object content){ 19 | return new CommonResponse(SUCCESS_TYPE, content); 20 | } 21 | 22 | public static CommonResponse exceptionResponse(String exception){ 23 | return new CommonResponse(EXCEPTION_TYPE, exception); 24 | } 25 | 26 | private int type; 27 | private Object content; 28 | 29 | public CommonResponse(){} 30 | 31 | private CommonResponse(int type) { 32 | this.type = type; 33 | } 34 | 35 | private CommonResponse(int type, String exception){ 36 | this.type = type; 37 | this.content = exception; 38 | } 39 | 40 | private CommonResponse(int type, Object content){ 41 | this.type = type; 42 | this.content = content; 43 | } 44 | 45 | public int getType() { 46 | return type; 47 | } 48 | 49 | public void setType(int type) { 50 | this.type = type; 51 | } 52 | 53 | public Object getContent() { 54 | return content; 55 | } 56 | 57 | public void setContent(Object content) { 58 | this.content = content; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Course.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public enum Course { 4 | English, Chinese 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Difficulty.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public enum Difficulty { 4 | NORMAL, MEDIUM, HARD //注意:枚举成员命名,请使用英文大写形式 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Food.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public enum Food { 4 | BEEF, PORK 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Glowworm_Serializer_1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import com.jd.dd.glowworm.serializer.ObjectSerializer; 4 | import com.jd.dd.glowworm.serializer.PBSerializer; 5 | import com.jd.dd.glowworm.serializer.normal.StringSerializer; 6 | 7 | import java.io.IOException; 8 | import java.util.Map; 9 | 10 | public class Glowworm_Serializer_1 implements ObjectSerializer { 11 | 12 | public ObjectSerializer abcSerializer; 13 | 14 | @Override 15 | public void write(PBSerializer serializer, Object object, boolean needWriteType, Object... extraParams) throws IOException { 16 | // StringSerializer.instance.write(serializer, object, needWriteType, Map); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Group.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Group { 7 | private String name; 8 | private List members = new ArrayList(); 9 | 10 | public Group() { 11 | } 12 | 13 | public Group(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public void setName(String name) { 22 | this.name = name; 23 | } 24 | 25 | public List getMembers() { 26 | return members; 27 | } 28 | 29 | public void setMembers(List members) { 30 | this.members = members; 31 | } 32 | 33 | public String toString() { 34 | return this.name; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/InnerBean.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class InnerBean { 4 | 5 | private int i; 6 | private InnerBean ib; 7 | private Inner inner; 8 | 9 | public InnerBean() { 10 | this.inner = new Inner(); 11 | } 12 | 13 | public int getI() { 14 | return i; 15 | } 16 | 17 | public void setI(int i) { 18 | this.i = i; 19 | } 20 | 21 | public InnerBean getIb() { 22 | return ib; 23 | } 24 | 25 | public void setIb(InnerBean ib) { 26 | this.ib = ib; 27 | } 28 | 29 | public Inner getInner() { 30 | return inner; 31 | } 32 | 33 | public void setInner(Inner inner) { 34 | this.inner = inner; 35 | } 36 | 37 | private class Inner { 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/InnerBean3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class InnerBean3 { 4 | 5 | private Inner inner; 6 | 7 | public InnerBean3() { 8 | } 9 | 10 | public InnerBean3(String name) { 11 | this.inner = new Inner(); 12 | this.inner.setName(name); 13 | } 14 | 15 | public Inner getInner() { 16 | return inner; 17 | } 18 | 19 | public void setInner(Inner inner) { 20 | this.inner = inner; 21 | } 22 | 23 | public String findName() { 24 | return this.inner.getName(); 25 | } 26 | 27 | private class Inner { 28 | 29 | private String name; 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class LoopPerson1 { 4 | 5 | private byte b; 6 | private LoopPerson1 brother; 7 | 8 | public LoopPerson1 getBrother() { 9 | return brother; 10 | } 11 | 12 | public void setBrother(LoopPerson1 brother) { 13 | this.brother = brother; 14 | } 15 | 16 | public byte getB() { 17 | return b; 18 | } 19 | 20 | public void setB(byte b) { 21 | this.b = b; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson10.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.Map; 4 | 5 | public class LoopPerson10 { 6 | 7 | private Integer integer; 8 | private LoopPerson10 lp; 9 | private Map map1; 10 | private Map map2; 11 | 12 | public LoopPerson10 getLp() { 13 | return lp; 14 | } 15 | 16 | public void setLp(LoopPerson10 lp) { 17 | this.lp = lp; 18 | } 19 | 20 | public Map getMap1() { 21 | return map1; 22 | } 23 | 24 | public void setMap1(Map map1) { 25 | this.map1 = map1; 26 | } 27 | 28 | public Map getMap2() { 29 | return map2; 30 | } 31 | 32 | public void setMap2(Map map2) { 33 | this.map2 = map2; 34 | } 35 | 36 | public Integer getInteger() { 37 | return integer; 38 | } 39 | 40 | public void setInteger(Integer integer) { 41 | this.integer = integer; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson11.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.*; 4 | 5 | public class LoopPerson11 { 6 | 7 | private Integer integer; 8 | private LoopInner loopInner; 9 | 10 | public LoopPerson11() { 11 | this.integer = 1; 12 | this.loopInner = new LoopInner(); 13 | this.loopInner.setInteger(2); 14 | List list = new ArrayList(); 15 | list.add(this); 16 | Set set = new HashSet(); 17 | set.add(this); 18 | Map map = new HashMap(); 19 | map.put("1", this); 20 | this.loopInner.setList(list); 21 | this.loopInner.setSet(set); 22 | this.loopInner.setMap(map); 23 | } 24 | 25 | public List findInnerList() { 26 | return this.loopInner.getList(); 27 | } 28 | 29 | public Set findInnerSet() { 30 | return this.loopInner.getSet(); 31 | } 32 | 33 | public Map findInnerMap() { 34 | return this.getLoopInner().getMap(); 35 | } 36 | 37 | public Integer getInteger() { 38 | return integer; 39 | } 40 | 41 | public void setInteger(Integer integer) { 42 | this.integer = integer; 43 | } 44 | 45 | public LoopInner getLoopInner() { 46 | return loopInner; 47 | } 48 | 49 | public void setLoopInner(LoopInner loopInner) { 50 | this.loopInner = loopInner; 51 | } 52 | 53 | private class LoopInner { 54 | 55 | private Integer integer; 56 | private List list; 57 | private Set set; 58 | private Map map; 59 | 60 | private LoopInner() { 61 | 62 | } 63 | 64 | public Integer getInteger() { 65 | return integer; 66 | } 67 | 68 | public void setInteger(Integer integer) { 69 | this.integer = integer; 70 | } 71 | 72 | public List getList() { 73 | return list; 74 | } 75 | 76 | public void setList(List list) { 77 | this.list = list; 78 | } 79 | 80 | public Set getSet() { 81 | return set; 82 | } 83 | 84 | public void setSet(Set set) { 85 | this.set = set; 86 | } 87 | 88 | public Map getMap() { 89 | return map; 90 | } 91 | 92 | public void setMap(Map map) { 93 | this.map = map; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class LoopPerson2 { 4 | 5 | private byte b; 6 | private LoopPerson2[] loopPerson2s; 7 | private LoopPerson2 brother; 8 | 9 | public LoopPerson2[] getLoopPerson2s() { 10 | return loopPerson2s; 11 | } 12 | 13 | public void setLoopPerson2s(LoopPerson2[] loopPerson2s) { 14 | this.loopPerson2s = loopPerson2s; 15 | } 16 | 17 | public byte getB() { 18 | return b; 19 | } 20 | 21 | public void setB(byte b) { 22 | this.b = b; 23 | } 24 | 25 | public LoopPerson2 getBrother() { 26 | return brother; 27 | } 28 | 29 | public void setBrother(LoopPerson2 brother) { 30 | this.brother = brother; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class LoopPerson3 { 6 | 7 | private byte b; 8 | private List list; 9 | private LoopPerson3 brother; 10 | 11 | 12 | public byte getB() { 13 | return b; 14 | } 15 | 16 | public void setB(byte b) { 17 | this.b = b; 18 | } 19 | 20 | public List getList() { 21 | return list; 22 | } 23 | 24 | public void setList(List list) { 25 | this.list = list; 26 | } 27 | 28 | public LoopPerson3 getBrother() { 29 | return brother; 30 | } 31 | 32 | public void setBrother(LoopPerson3 brother) { 33 | this.brother = brother; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson4.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.Set; 4 | 5 | public class LoopPerson4 { 6 | 7 | private byte b; 8 | private Set set; 9 | // private HashMap map1; 10 | // private Map map2; 11 | private LoopPerson4 brother; 12 | 13 | public byte getB() { 14 | return b; 15 | } 16 | 17 | public void setB(byte b) { 18 | this.b = b; 19 | } 20 | 21 | public Set getSet() { 22 | return set; 23 | } 24 | 25 | public void setSet(Set set) { 26 | this.set = set; 27 | } 28 | 29 | // public HashMap getMap1() { 30 | // return map1; 31 | // } 32 | // 33 | // public void setMap1(HashMap map1) { 34 | // this.map1 = map1; 35 | // } 36 | 37 | // public Map getMap2() { 38 | // return map2; 39 | // } 40 | // 41 | // public void setMap2(Map map2) { 42 | // this.map2 = map2; 43 | // } 44 | 45 | public LoopPerson4 getBrother() { 46 | return brother; 47 | } 48 | 49 | public void setBrother(LoopPerson4 brother) { 50 | this.brother = brother; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson5.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | 5 | public class LoopPerson5 { 6 | 7 | private Integer integer; 8 | private HashMap map; 9 | 10 | public HashMap getMap() { 11 | return map; 12 | } 13 | 14 | public void setMap(HashMap map) { 15 | this.map = map; 16 | } 17 | 18 | public Integer getInteger() { 19 | return integer; 20 | } 21 | 22 | public void setInteger(Integer integer) { 23 | this.integer = integer; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson6.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | 5 | public class LoopPerson6 { 6 | 7 | private Integer integer; 8 | private HashMap map; 9 | 10 | public HashMap getMap() { 11 | return map; 12 | } 13 | 14 | public void setMap(HashMap map) { 15 | this.map = map; 16 | } 17 | 18 | public Integer getInteger() { 19 | return integer; 20 | } 21 | 22 | public void setInteger(Integer integer) { 23 | this.integer = integer; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson7.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | 5 | public class LoopPerson7 { 6 | 7 | private LoopPerson7 bro; 8 | private HashMap map; 9 | 10 | public LoopPerson7 getBro() { 11 | return bro; 12 | } 13 | 14 | public void setBro(LoopPerson7 bro) { 15 | this.bro = bro; 16 | } 17 | 18 | public HashMap getMap() { 19 | return map; 20 | } 21 | 22 | public void setMap(HashMap map) { 23 | this.map = map; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson8.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class LoopPerson8 { 6 | 7 | private Integer integer; 8 | private LoopPerson8 lp; 9 | private List list; 10 | 11 | public Integer getInteger() { 12 | return integer; 13 | } 14 | 15 | public void setInteger(Integer integer) { 16 | this.integer = integer; 17 | } 18 | 19 | public List getList() { 20 | return list; 21 | } 22 | 23 | public void setList(List list) { 24 | this.list = list; 25 | } 26 | 27 | public LoopPerson8 getLp() { 28 | return lp; 29 | } 30 | 31 | public void setLp(LoopPerson8 lp) { 32 | this.lp = lp; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/LoopPerson9.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.Set; 4 | 5 | public class LoopPerson9 { 6 | 7 | private Integer integer; 8 | private LoopPerson9 lp; 9 | private Set set; 10 | 11 | public Integer getInteger() { 12 | return integer; 13 | } 14 | 15 | public void setInteger(Integer integer) { 16 | this.integer = integer; 17 | } 18 | 19 | public LoopPerson9 getLp() { 20 | return lp; 21 | } 22 | 23 | public void setLp(LoopPerson9 lp) { 24 | this.lp = lp; 25 | } 26 | 27 | public Set getSet() { 28 | return set; 29 | } 30 | 31 | public void setSet(Set set) { 32 | this.set = set; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/MapBean.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | 5 | public class MapBean { 6 | 7 | private int i; 8 | private HashMap map; 9 | 10 | public int getI() { 11 | return i; 12 | } 13 | 14 | public void setI(int i) { 15 | this.i = i; 16 | } 17 | 18 | public HashMap getMap() { 19 | return map; 20 | } 21 | 22 | public void setMap(HashMap map) { 23 | this.map = map; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/NoDefaultConstructorBean.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | /** 4 | * User: bigbully 5 | * Date: 13-7-20 6 | * Time: 下午10:21 7 | */ 8 | public class NoDefaultConstructorBean { 9 | 10 | private String id; 11 | 12 | public NoDefaultConstructorBean(String id){ 13 | this.id = id; 14 | } 15 | 16 | public String getId() { 17 | return id; 18 | } 19 | 20 | public void setId(String id) { 21 | this.id = id; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person1 { 4 | 5 | private Long id; 6 | 7 | public Long getId() { 8 | return id; 9 | } 10 | 11 | public void setId(Long id) { 12 | this.id = id; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person11.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.Map; 4 | 5 | public class Person11 { 6 | 7 | private Integer integer; 8 | private Person11 p; 9 | private Map map1; 10 | private Map map2; 11 | 12 | public Person11 getP() { 13 | return p; 14 | } 15 | 16 | public void setP(Person11 p) { 17 | this.p = p; 18 | } 19 | 20 | public Map getMap1() { 21 | return map1; 22 | } 23 | 24 | public void setMap1(Map map1) { 25 | this.map1 = map1; 26 | } 27 | 28 | public Map getMap2() { 29 | return map2; 30 | } 31 | 32 | public void setMap2(Map map2) { 33 | this.map2 = map2; 34 | } 35 | 36 | public Integer getInteger() { 37 | return integer; 38 | } 39 | 40 | public void setInteger(Integer integer) { 41 | this.integer = integer; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person2 { 4 | 5 | private Long id; 6 | private String name; 7 | 8 | public Long getId() { 9 | return id; 10 | } 11 | 12 | public void setId(Long id) { 13 | this.id = id; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person4.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person4 { 4 | 5 | private char c; 6 | private int i; 7 | private byte b; 8 | private short s; 9 | private float f; 10 | private double d; 11 | private long l; 12 | private boolean bool; 13 | 14 | 15 | public char getC() { 16 | return c; 17 | } 18 | 19 | public void setC(char c) { 20 | this.c = c; 21 | } 22 | 23 | public int getI() { 24 | return i; 25 | } 26 | 27 | public void setI(int i) { 28 | this.i = i; 29 | } 30 | 31 | public byte getB() { 32 | return b; 33 | } 34 | 35 | public void setB(byte b) { 36 | this.b = b; 37 | } 38 | 39 | public short getS() { 40 | return s; 41 | } 42 | 43 | public void setS(short s) { 44 | this.s = s; 45 | } 46 | 47 | public float getF() { 48 | return f; 49 | } 50 | 51 | public void setF(float f) { 52 | this.f = f; 53 | } 54 | 55 | public double getD() { 56 | return d; 57 | } 58 | 59 | public void setD(double d) { 60 | this.d = d; 61 | } 62 | 63 | public long getL() { 64 | return l; 65 | } 66 | 67 | public void setL(long l) { 68 | this.l = l; 69 | } 70 | 71 | public boolean isBool() { 72 | return bool; 73 | } 74 | 75 | public void setBool(boolean bool) { 76 | this.bool = bool; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person5.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person5 { 4 | 5 | private Object[] person6s; 6 | 7 | public Object[] getPerson6s() { 8 | return person6s; 9 | } 10 | 11 | public void setPerson6s(Object[] person6s) { 12 | this.person6s = person6s; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person6.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person6 { 4 | 5 | private String name; 6 | 7 | public String getName() { 8 | return name; 9 | } 10 | 11 | public void setName(String name) { 12 | this.name = name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person7.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class Person7 { 4 | 5 | private Long id; 6 | private String yName; 7 | private Person9 person9; 8 | 9 | public Person7() { 10 | this.id = 1L; 11 | this.yName = "123232"; 12 | this.person9 = new Person9(); 13 | this.person9.setId(1); 14 | this.person9.setName("123"); 15 | } 16 | 17 | public Long getId() { 18 | return id; 19 | } 20 | 21 | public void setId(Long id) { 22 | this.id = id; 23 | } 24 | 25 | public String getYName() { 26 | return yName; 27 | } 28 | 29 | public void setYName(String yName) { 30 | this.yName = yName; 31 | } 32 | 33 | public Person9 getPerson9() { 34 | return person9; 35 | } 36 | 37 | public void setPerson9(Person9 person9) { 38 | this.person9 = person9; 39 | } 40 | 41 | public int findPerson9Id() { 42 | return this.person9.getId(); 43 | } 44 | 45 | public String findPerson9Name() { 46 | return this.person9.getName(); 47 | } 48 | 49 | private class Person9 { 50 | private int id; 51 | private String name; 52 | 53 | private Person9() { 54 | } 55 | 56 | public int getId() { 57 | return id; 58 | } 59 | 60 | public void setId(int id) { 61 | this.id = id; 62 | } 63 | 64 | public String getName() { 65 | return name; 66 | } 67 | 68 | public void setName(String name) { 69 | this.name = name; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Person8.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class Person8 { 6 | 7 | private List courses; 8 | 9 | public List getCourses() { 10 | return courses; 11 | } 12 | 13 | public void setCourses(List courses) { 14 | this.courses = courses; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/PersonCollection3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class PersonCollection3 { 6 | 7 | private ArrayList list; 8 | 9 | public ArrayList getList() { 10 | return list; 11 | } 12 | 13 | public void setList(ArrayList list) { 14 | this.list = list; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/PersonCollection4.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class PersonCollection4 { 6 | 7 | private ArrayList list; 8 | 9 | public ArrayList getList() { 10 | return list; 11 | } 12 | 13 | public void setList(ArrayList list) { 14 | this.list = list; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/PersonForDate.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.BigInteger; 5 | import java.net.Inet4Address; 6 | import java.sql.Time; 7 | import java.sql.Timestamp; 8 | import java.util.Date; 9 | 10 | public class PersonForDate { 11 | 12 | private Date date; 13 | private Timestamp timestamp; 14 | private Time time; 15 | private Inet4Address inet4Address; 16 | private BigDecimal bd; 17 | private BigInteger bi; 18 | 19 | 20 | public Date getDate() { 21 | return date; 22 | } 23 | 24 | public void setDate(Date date) { 25 | this.date = date; 26 | } 27 | 28 | public Timestamp getTimestamp() { 29 | return timestamp; 30 | } 31 | 32 | public void setTimestamp(Timestamp timestamp) { 33 | this.timestamp = timestamp; 34 | } 35 | 36 | public Inet4Address getInet4Address() { 37 | return inet4Address; 38 | } 39 | 40 | public void setInet4Address(Inet4Address inet4Address) { 41 | this.inet4Address = inet4Address; 42 | } 43 | 44 | public BigDecimal getBd() { 45 | return bd; 46 | } 47 | 48 | public void setBd(BigDecimal bd) { 49 | this.bd = bd; 50 | } 51 | 52 | public BigInteger getBi() { 53 | return bi; 54 | } 55 | 56 | public void setBi(BigInteger bi) { 57 | this.bi = bi; 58 | } 59 | 60 | public Time getTime() { 61 | return time; 62 | } 63 | 64 | public void setTime(Time time) { 65 | this.time = time; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Rule.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * User: yfliuyu 8 | * Date: 12-8-27 9 | * Time: 上午10:28 10 | */ 11 | public class Rule implements Serializable { 12 | private String code; 13 | 14 | private String name; 15 | 16 | private String description; 17 | 18 | private String status; 19 | 20 | public boolean isEnable() { 21 | return status.equalsIgnoreCase("0"); 22 | } 23 | 24 | private List items; 25 | 26 | public List getItems() { 27 | return items; 28 | } 29 | 30 | public void setItems(List items) { 31 | this.items = items; 32 | } 33 | 34 | public String getCode() { 35 | return code; 36 | } 37 | 38 | public void setCode(String code) { 39 | this.code = code; 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | 50 | public String getDescription() { 51 | return description; 52 | } 53 | 54 | public void setDescription(String description) { 55 | this.description = description; 56 | } 57 | 58 | public String getStatus() { 59 | return status; 60 | } 61 | 62 | public void setStatus(String status) { 63 | this.status = status; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "Rule{" + 69 | "code='" + code + '\'' + 70 | ", name='" + name + '\'' + 71 | ", status='" + status + '\'' + 72 | ", items=" + items + 73 | '}'; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/RuleItem.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * User: yfliuyu 7 | * Date: 12-8-15 8 | * Time: 下午3:18 9 | */ 10 | public class RuleItem implements Serializable { 11 | private String rule_id; 12 | private String item_id; 13 | private String warning_value; 14 | 15 | public String getRule_id() { 16 | return rule_id; 17 | } 18 | 19 | public void setRule_id(String rule_id) { 20 | this.rule_id = rule_id; 21 | } 22 | 23 | public String getItem_id() { 24 | return item_id; 25 | } 26 | 27 | public void setItem_id(String item_id) { 28 | this.item_id = item_id; 29 | } 30 | 31 | public String getWarning_value() { 32 | return warning_value; 33 | } 34 | 35 | public void setWarning_value(String warning_value) { 36 | this.warning_value = warning_value; 37 | } 38 | 39 | 40 | public String getDescription() { 41 | return description; 42 | } 43 | 44 | public void setDescription(String description) { 45 | this.description = description; 46 | } 47 | 48 | private String description; 49 | 50 | @Override 51 | public String toString() { 52 | return "RuleItem{" + 53 | "rule_id='" + rule_id + '\'' + 54 | ", item_id='" + item_id + '\'' + 55 | ", warning_value='" + warning_value + '\'' + 56 | ", description='" + description + '\'' + 57 | '}'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/School.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class School { 6 | 7 | private Long id; 8 | private String name; 9 | private List students; 10 | 11 | public Long getId() { 12 | return id; 13 | } 14 | 15 | public void setId(Long id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public List getStudents() { 28 | return students; 29 | } 30 | 31 | public void setStudents(List students) { 32 | this.students = students; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Student.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.Set; 4 | 5 | public class Student { 6 | 7 | private Long id; 8 | private String name; 9 | private Double salary; 10 | private Boolean sex; 11 | private School school; 12 | private Student[] classmates; 13 | private Set courses; 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(Long id) { 20 | this.id = id; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public Double getSalary() { 32 | return salary; 33 | } 34 | 35 | public void setSalary(Double salary) { 36 | this.salary = salary; 37 | } 38 | 39 | public Boolean getSex() { 40 | return sex; 41 | } 42 | 43 | public void setSex(Boolean sex) { 44 | this.sex = sex; 45 | } 46 | 47 | public School getSchool() { 48 | return school; 49 | } 50 | 51 | public void setSchool(School school) { 52 | this.school = school; 53 | } 54 | 55 | public Student[] getClassmates() { 56 | return classmates; 57 | } 58 | 59 | public void setClassmates(Student[] classmates) { 60 | this.classmates = classmates; 61 | } 62 | 63 | public Set getCourses() { 64 | return courses; 65 | } 66 | 67 | public void setCourses(Set courses) { 68 | this.courses = courses; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Student1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | /** 4 | * User: bigbully 5 | * Date: 13-7-20 6 | * Time: 下午5:43 7 | */ 8 | public class Student1 extends Person1{ 9 | 10 | private String name; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Student2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | /** 4 | * User: bigbully 5 | * Date: 13-7-20 6 | * Time: 下午10:02 7 | */ 8 | public class Student2 extends TransientBean1 { 9 | 10 | private String name; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Supply1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | public class Supply1 { 6 | 7 | private ConcurrentHashMap theConHMap; 8 | 9 | public ConcurrentHashMap getTheConHMap() { 10 | return theConHMap; 11 | } 12 | 13 | public void setTheConHMap(ConcurrentHashMap theConHMap) { 14 | this.theConHMap = theConHMap; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Supply2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | public class Supply2 { 6 | 7 | private ConcurrentHashMap theConHMap; 8 | private Inner inner; 9 | 10 | public ConcurrentHashMap getTheConHMap() { 11 | return theConHMap; 12 | } 13 | 14 | public void setTheConHMap(ConcurrentHashMap theConHMap) { 15 | this.theConHMap = theConHMap; 16 | } 17 | 18 | public Inner getInner() { 19 | return inner; 20 | } 21 | 22 | public void setInner(Inner inner) { 23 | this.inner = inner; 24 | } 25 | 26 | private class Inner { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/Supply3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class Supply3 { 6 | 7 | private List list; 8 | 9 | public List getList() { 10 | return list; 11 | } 12 | 13 | public void setList(List list) { 14 | this.list = list; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/TransientBean1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import com.jd.dd.glowworm.util.Transient; 4 | 5 | public class TransientBean1 { 6 | 7 | @Transient 8 | private Integer index; 9 | 10 | public Integer getIndex() { 11 | return index; 12 | } 13 | 14 | public void setIndex(Integer index) { 15 | this.index = index; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/TransientBean2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import com.jd.dd.glowworm.util.Transient; 4 | 5 | public class TransientBean2 { 6 | 7 | private Integer index; 8 | 9 | @Transient 10 | public Integer getIndex() { 11 | return index; 12 | } 13 | 14 | public void setIndex(Integer index) { 15 | this.index = index; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/TransientBean3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import com.jd.dd.glowworm.util.Transient; 4 | 5 | public class TransientBean3 { 6 | 7 | private Integer index; 8 | 9 | public Integer getIndex() { 10 | return index; 11 | } 12 | 13 | @Transient 14 | public void setIndex(Integer index) { 15 | this.index = index; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/TransientBean4.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class TransientBean4 { 4 | 5 | public void setIndex(Integer index) { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/TransientBean5.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class TransientBean5 { 4 | 5 | public Integer getIndex() { 6 | return 1; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class User { 7 | private String name; 8 | private List groups = new ArrayList(); 9 | private User reportTo; 10 | 11 | public User() { 12 | } 13 | 14 | public User getReportTo() { 15 | return reportTo; 16 | } 17 | 18 | public void setReportTo(User reportTo) { 19 | this.reportTo = reportTo; 20 | } 21 | 22 | public User(String name) { 23 | this.name = name; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public List getGroups() { 35 | return groups; 36 | } 37 | 38 | public void setGroups(List groups) { 39 | this.groups = groups; 40 | } 41 | 42 | public String toString() { 43 | return this.name; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User1.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User1 { 4 | 5 | private boolean b; 6 | 7 | public boolean getB() { 8 | return b; 9 | } 10 | 11 | public void setB(boolean b) { 12 | this.b = b; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User10.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User10 { 4 | 5 | public User10() { 6 | this.innerUser = new InnerUser(); 7 | } 8 | 9 | private InnerUser innerUser; 10 | 11 | public void putInnerArray(User1[] user1s) { 12 | innerUser.setUser1s(user1s); 13 | } 14 | 15 | public User1[] findInnerArray() { 16 | return innerUser.getUser1s(); 17 | } 18 | 19 | public InnerUser getInnerUser() { 20 | return innerUser; 21 | } 22 | 23 | public void setInnerUser(InnerUser innerUser) { 24 | this.innerUser = innerUser; 25 | } 26 | 27 | private class InnerUser { 28 | private User1[] user1s; 29 | 30 | public User1[] getUser1s() { 31 | return user1s; 32 | } 33 | 34 | public void setUser1s(User1[] user1s) { 35 | this.user1s = user1s; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User11.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User11 { 4 | 5 | public User11() { 6 | this.innerUser = new InnerUser(); 7 | } 8 | 9 | private InnerUser innerUser; 10 | 11 | public void putInnerArray(Object[] user1s) { 12 | innerUser.setUser1s(user1s); 13 | } 14 | 15 | public Object[] findInnerArray() { 16 | return innerUser.getUser1s(); 17 | } 18 | 19 | public InnerUser getInnerUser() { 20 | return innerUser; 21 | } 22 | 23 | public void setInnerUser(InnerUser innerUser) { 24 | this.innerUser = innerUser; 25 | } 26 | 27 | private class InnerUser { 28 | private Object[] user1s; 29 | 30 | public Object[] getUser1s() { 31 | return user1s; 32 | } 33 | 34 | public void setUser1s(Object[] user1s) { 35 | this.user1s = user1s; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User12.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class User12 { 7 | 8 | public User12() { 9 | innerUser = new InnerUser(); 10 | } 11 | 12 | public void putMap(Map map) { 13 | innerUser.setMap(map); 14 | } 15 | 16 | public Map findMap() { 17 | return innerUser.getMap(); 18 | } 19 | 20 | public void putHashMap(HashMap hashMap) { 21 | innerUser.setHashMap(hashMap); 22 | } 23 | 24 | public HashMap findHashMap() { 25 | return innerUser.getHashMap(); 26 | } 27 | 28 | public void putGenericMap(Map genericMap) { 29 | innerUser.setGenericMap(genericMap); 30 | } 31 | 32 | public Map findGenericMap() { 33 | return innerUser.getGenericMap(); 34 | } 35 | 36 | private InnerUser innerUser; 37 | 38 | public InnerUser getInnerUser() { 39 | return innerUser; 40 | } 41 | 42 | public void setInnerUser(InnerUser innerUser) { 43 | this.innerUser = innerUser; 44 | } 45 | 46 | private class InnerUser { 47 | private Map map; 48 | private HashMap hashMap; 49 | private Map genericMap; 50 | 51 | public Map getMap() { 52 | return map; 53 | } 54 | 55 | public void setMap(Map map) { 56 | this.map = map; 57 | } 58 | 59 | public HashMap getHashMap() { 60 | return hashMap; 61 | } 62 | 63 | public void setHashMap(HashMap hashMap) { 64 | this.hashMap = hashMap; 65 | } 66 | 67 | public Map getGenericMap() { 68 | return genericMap; 69 | } 70 | 71 | public void setGenericMap(Map genericMap) { 72 | this.genericMap = genericMap; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User13.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class User13 { 7 | 8 | private Map map; 9 | private HashMap hashMap; 10 | private Map genericMap; 11 | 12 | public Map getMap() { 13 | return map; 14 | } 15 | 16 | public void setMap(Map map) { 17 | this.map = map; 18 | } 19 | 20 | public HashMap getHashMap() { 21 | return hashMap; 22 | } 23 | 24 | public void setHashMap(HashMap hashMap) { 25 | this.hashMap = hashMap; 26 | } 27 | 28 | public Map getGenericMap() { 29 | return genericMap; 30 | } 31 | 32 | public void setGenericMap(Map genericMap) { 33 | this.genericMap = genericMap; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User14.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.LinkedList; 4 | import java.util.List; 5 | 6 | public class User14 { 7 | 8 | public User14() { 9 | innerUser = new InnerUser(); 10 | } 11 | 12 | private InnerUser innerUser; 13 | 14 | public void putList(List list) { 15 | innerUser.setList(list); 16 | } 17 | 18 | public List findList() { 19 | return innerUser.getList(); 20 | } 21 | 22 | public void putLinkedList(LinkedList linkedList) { 23 | innerUser.setLinkedList(linkedList); 24 | } 25 | 26 | public LinkedList findLinkedList() { 27 | return innerUser.getLinkedList(); 28 | } 29 | 30 | public InnerUser getInnerUser() { 31 | return innerUser; 32 | } 33 | 34 | public void setInnerUser(InnerUser innerUser) { 35 | this.innerUser = innerUser; 36 | } 37 | 38 | public void putList2(List list) { 39 | this.innerUser.setList2(list); 40 | } 41 | 42 | public List findList2() { 43 | return this.innerUser.getList2(); 44 | } 45 | 46 | public void putList3(List list) { 47 | this.innerUser.setList3(list); 48 | } 49 | 50 | public List findList3() { 51 | return innerUser.getList3(); 52 | } 53 | 54 | private class InnerUser { 55 | private List list; 56 | private LinkedList linkedList; 57 | private List list2; 58 | private List list3; 59 | 60 | public List getList() { 61 | return list; 62 | } 63 | 64 | public void setList(List list) { 65 | this.list = list; 66 | } 67 | 68 | public LinkedList getLinkedList() { 69 | return linkedList; 70 | } 71 | 72 | public void setLinkedList(LinkedList linkedList) { 73 | this.linkedList = linkedList; 74 | } 75 | 76 | public List getList2() { 77 | return list2; 78 | } 79 | 80 | public void setList2(List list2) { 81 | this.list2 = list2; 82 | } 83 | 84 | public List getList3() { 85 | return list3; 86 | } 87 | 88 | public void setList3(List list3) { 89 | this.list3 = list3; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User15.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.List; 4 | 5 | public class User15 { 6 | 7 | private List list; 8 | private List list1; 9 | 10 | public List getList() { 11 | return list; 12 | } 13 | 14 | public void setList(List list) { 15 | this.list = list; 16 | } 17 | 18 | public List getList1() { 19 | return list1; 20 | } 21 | 22 | public void setList1(List list1) { 23 | this.list1 = list1; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User16.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User16 { 4 | 5 | private Exception exception; 6 | 7 | public Exception getException() { 8 | return exception; 9 | } 10 | 11 | public void setException(Exception exception) { 12 | this.exception = exception; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User17.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User17 { 4 | 5 | public User17() { 6 | this.inner = new Inner(); 7 | } 8 | 9 | private Inner inner; 10 | 11 | public Inner getInner() { 12 | return inner; 13 | } 14 | 15 | public void setInner(Inner inner) { 16 | this.inner = inner; 17 | } 18 | 19 | public void putException(Exception e) { 20 | this.inner.setException(e); 21 | } 22 | 23 | public Exception findException() { 24 | return this.inner.getException(); 25 | } 26 | 27 | 28 | private class Inner { 29 | 30 | private Exception exception; 31 | 32 | public Exception getException() { 33 | return exception; 34 | } 35 | 36 | public void setException(Exception exception) { 37 | this.exception = exception; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User18.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 360buy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package userJavabean; 18 | 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | import java.util.Set; 23 | 24 | public class User18 { 25 | 26 | private List> list; 27 | private Set> set; 28 | private Map> map; 29 | 30 | public List> getList() { 31 | return list; 32 | } 33 | 34 | public void setList(List> list) { 35 | this.list = list; 36 | } 37 | 38 | public Set> getSet() { 39 | return set; 40 | } 41 | 42 | public void setSet(Set> set) { 43 | this.set = set; 44 | } 45 | 46 | public Map> getMap() { 47 | return map; 48 | } 49 | 50 | public void setMap(Map> map) { 51 | this.map = map; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User2.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User2 { 4 | 5 | private Boolean b; 6 | 7 | public Boolean getB() { 8 | return b; 9 | } 10 | 11 | public void setB(Boolean b) { 12 | this.b = b; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User3.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User3 { 4 | 5 | private User1 user1; 6 | 7 | public User1 getUser1() { 8 | return user1; 9 | } 10 | 11 | public void setUser1(User1 user1) { 12 | this.user1 = user1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User4.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User4 { 4 | 5 | private User1[] user1s; 6 | 7 | public User1[] getUser1s() { 8 | return user1s; 9 | } 10 | 11 | public void setUser1s(User1[] user1s) { 12 | this.user1s = user1s; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User5.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User5 { 4 | 5 | private Object[] objects; 6 | 7 | public Object[] getObjects() { 8 | return objects; 9 | } 10 | 11 | public void setObjects(Object[] objects) { 12 | this.objects = objects; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User7.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User7 { 4 | 5 | public User7() { 6 | this.innerUser = new InnerUser(); 7 | } 8 | 9 | private InnerUser innerUser; 10 | 11 | public void putInnerBoolean(Boolean b) { 12 | innerUser.setB(b); 13 | } 14 | 15 | public InnerUser getInnerUser() { 16 | return innerUser; 17 | } 18 | 19 | public void setInnerUser(InnerUser innerUser) { 20 | this.innerUser = innerUser; 21 | } 22 | 23 | public boolean findInnerBoolean() { 24 | return innerUser.getB(); 25 | } 26 | 27 | private class InnerUser { 28 | private Boolean b; 29 | 30 | public Boolean getB() { 31 | return b; 32 | } 33 | 34 | public void setB(Boolean b) { 35 | this.b = b; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User8.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User8 { 4 | 5 | public User8() { 6 | this.innerUser = new InnerUser(); 7 | } 8 | 9 | private InnerUser innerUser; 10 | 11 | public void putInnerBoolean(Boolean b) { 12 | innerUser.setB(b); 13 | } 14 | 15 | public InnerUser getInnerUser() { 16 | return innerUser; 17 | } 18 | 19 | public void setInnerUser(InnerUser innerUser) { 20 | this.innerUser = innerUser; 21 | } 22 | 23 | public boolean findInnerBoolean() { 24 | return innerUser.getB(); 25 | } 26 | 27 | private class InnerUser { 28 | private boolean b; 29 | 30 | public boolean getB() { 31 | return b; 32 | } 33 | 34 | public void setB(boolean b) { 35 | this.b = b; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/User9.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | public class User9 { 4 | 5 | public User9() { 6 | this.innerUser = new InnerUser(); 7 | } 8 | 9 | private InnerUser innerUser; 10 | 11 | public void putInnerBean(User1 user1) { 12 | innerUser.setUser1(user1); 13 | } 14 | 15 | public InnerUser getInnerUser() { 16 | return innerUser; 17 | } 18 | 19 | public void setInnerUser(InnerUser innerUser) { 20 | this.innerUser = innerUser; 21 | } 22 | 23 | public User1 findInnerUser1() { 24 | return innerUser.getUser1(); 25 | } 26 | 27 | private class InnerUser { 28 | private User1 user1; 29 | 30 | public User1 getUser1() { 31 | return user1; 32 | } 33 | 34 | public void setUser1(User1 user1) { 35 | this.user1 = user1; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/userJavabean/UserGeneric.java: -------------------------------------------------------------------------------- 1 | package userJavabean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | public class UserGeneric { 8 | 9 | private ArrayList list; 10 | private HashSet set; 11 | private Set set1; 12 | 13 | public ArrayList getList() { 14 | return list; 15 | } 16 | 17 | public void setList(ArrayList list) { 18 | this.list = list; 19 | } 20 | 21 | public HashSet getSet() { 22 | return set; 23 | } 24 | 25 | public void setSet(HashSet set) { 26 | this.set = set; 27 | } 28 | 29 | public Set getSet1() { 30 | return set1; 31 | } 32 | 33 | public void setSet1(Set set1) { 34 | this.set1 = set1; 35 | } 36 | } 37 | --------------------------------------------------------------------------------