1 package org.djutils.serialization; 2 3 /** 4 * Basics of the serializer 5 * <p> 6 * Copyright (c) 2019-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 7 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>. 8 * <p> 9 * @version $Revision$, $LastChangedDate$, by $Author$, <br> 10 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 11 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 12 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a> 13 * @param <T> class 14 */ 15 public abstract class BasicSerializer<T extends Object> implements Serializer<T> 16 { 17 /** The field type that usually prefixes the serialized data. */ 18 private final byte type; 19 20 /** String returned by the dataClassName method. */ 21 private final String dataClassName; 22 23 /** 24 * Construct the BasicSerializer. 25 * @param type byte; the field type (returned by the <code>fieldType</code> method) 26 * @param dataClassName String; returned by the dataClassName method 27 */ 28 public BasicSerializer(final byte type, final String dataClassName) 29 { 30 this.type = type; 31 this.dataClassName = dataClassName; 32 } 33 34 /** {@inheritDoc} */ 35 @Override 36 public final byte fieldType() 37 { 38 return this.type; 39 } 40 41 /** {@inheritDoc} */ 42 @Override 43 public final String dataClassName() 44 { 45 return this.dataClassName; 46 } 47 48 /** {@inheritDoc} */ 49 @Override 50 public String toString() 51 { 52 return "BasicSerializer [type=" + this.type + ", dataClassName=" + this.dataClassName + "]"; 53 } 54 55 }