[Taka-cvs] Taka Editor/src/org/takadb/maximilian/marshallers JavassistMarshaller.java,NONE,1.1 Refle
Status: Beta
Brought to you by:
asbel
From: Matthew J. F. <as...@us...> - 2005-05-08 11:33:57
|
Update of /cvsroot/taka/Taka Editor/src/org/takadb/maximilian/marshallers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19503/src/org/takadb/maximilian/marshallers Modified Files: ReflectionMarshaller.java Added Files: JavassistMarshaller.java ReflectionMarshallerMap.java Log Message: - Move default unserialiser to XmlPullParser/reflection based model - Miscellaneous internal refactoring - Documentation updates --- NEW FILE: JavassistMarshaller.java --- package org.takadb.maximilian.marshallers; /** * Interface implemented by reflection-based type Marshallers */ public interface JavassistMarshaller { /** * Generate Javassist code marshalling an field * @param sourceIndentDepth Cosmetic indent depth to give the code * @param fieldName Name of the field * @return Generated code */ public String marshal (int sourceIndentDepth, String fieldName); /** * Generate Javassist code unmarshalling an field * @param sourceIndentDepth Cosmetic indent depth to give the code * @param fieldName Name of the field * @return Generated code */ public String unmarshal (int sourceIndentDepth, String fieldName); } --- NEW FILE: ReflectionMarshallerMap.java --- package org.takadb.maximilian.marshallers; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.takadb.maximilian.annotations.Persistable; import org.takadb.maximilian.marshallers.reflection.*; /** * Contains a map of type specific Marshallers for use in Reflection-based serialisation/unserialisation */ public class ReflectionMarshallerMap { /** * Map of type specific Marshallers for use in Reflection-based serialisation/unserialisation */ public static final Map<Class<?>,ReflectionMarshaller> marshallers; static { Map<Class<?>,ReflectionMarshaller> modifiableMarshallers = new HashMap<Class<?>,ReflectionMarshaller>(); modifiableMarshallers.put (boolean.class, new PrimitiveBooleanMarshaller()); modifiableMarshallers.put (byte.class, new PrimitiveByteMarshaller()); modifiableMarshallers.put (short.class, new PrimitiveShortMarshaller()); modifiableMarshallers.put (int.class, new PrimitiveIntMarshaller()); modifiableMarshallers.put (long.class, new PrimitiveLongMarshaller()); modifiableMarshallers.put (float.class, new PrimitiveFloatMarshaller()); modifiableMarshallers.put (double.class, new PrimitiveDoubleMarshaller()); modifiableMarshallers.put (char.class, new PrimitiveCharMarshaller()); modifiableMarshallers.put (Boolean.class, new BooleanMarshaller()); modifiableMarshallers.put (Byte.class, new ByteMarshaller()); modifiableMarshallers.put (Short.class, new ShortMarshaller()); modifiableMarshallers.put (Integer.class, new IntegerMarshaller()); modifiableMarshallers.put (Long.class, new LongMarshaller()); modifiableMarshallers.put (Float.class, new FloatMarshaller()); modifiableMarshallers.put (Double.class, new DoubleMarshaller()); modifiableMarshallers.put (Character.class, new CharacterMarshaller()); modifiableMarshallers.put (String.class, new StringMarshaller()); modifiableMarshallers.put (byte[].class, new PrimitiveByteArrayMarshaller()); modifiableMarshallers.put (Enum.class, new EnumMarshaller()); modifiableMarshallers.put (Persistable.class, new PersistableMarshaller()); marshallers = Collections.unmodifiableMap (modifiableMarshallers); } } Index: ReflectionMarshaller.java =================================================================== RCS file: /cvsroot/taka/Taka Editor/src/org/takadb/maximilian/marshallers/ReflectionMarshaller.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReflectionMarshaller.java 28 Apr 2005 22:49:45 -0000 1.1 --- ReflectionMarshaller.java 8 May 2005 11:33:49 -0000 1.2 *************** *** 2,12 **** ! ! public interface ReflectionMarshaller { public String marshal (Object value); public Object unmarshal (Class<?> objectClass, String value); --- 2,24 ---- ! /** ! * Interface implemented by reflection-based type Marshallers ! */ public interface ReflectionMarshaller { + /** + * Marshal an object into a string + * @param value Object to marshal + * @return Marshalled string + */ public String marshal (Object value); + /** + * Unmarshal a string back into an object + * @param objectClass Concrete class to unmarshal + * @param value String to unmarshal + * @return Unmarshalled object + */ public Object unmarshal (Class<?> objectClass, String value); |