001 /*
002 GRANITE DATA SERVICES
003 Copyright (C) 2013 GRANITE DATA SERVICES S.A.S.
004
005 This file is part of Granite Data Services.
006
007 Granite Data Services is free software; you can redistribute it and/or modify
008 it under the terms of the GNU Library General Public License as published by
009 the Free Software Foundation; either version 2 of the License, or (at your
010 option) any later version.
011
012 Granite Data Services is distributed in the hope that it will be useful, but
013 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015 for more details.
016
017 You should have received a copy of the GNU Library General Public License
018 along with this library; if not, see <http://www.gnu.org/licenses/>.
019 */
020
021 package org.granite.messaging.jmf;
022
023 import java.io.IOException;
024 import java.lang.reflect.InvocationTargetException;
025
026 import org.granite.messaging.jmf.codec.ExtendedObjectCodec;
027 import org.granite.messaging.jmf.codec.StandardCodec;
028 import org.granite.messaging.jmf.codec.std.BooleanCodec;
029 import org.granite.messaging.jmf.codec.std.ByteCodec;
030 import org.granite.messaging.jmf.codec.std.CharacterCodec;
031 import org.granite.messaging.jmf.codec.std.DoubleCodec;
032 import org.granite.messaging.jmf.codec.std.FloatCodec;
033 import org.granite.messaging.jmf.codec.std.IntegerCodec;
034 import org.granite.messaging.jmf.codec.std.LongCodec;
035 import org.granite.messaging.jmf.codec.std.NullCodec;
036 import org.granite.messaging.jmf.codec.std.ShortCodec;
037 import org.granite.messaging.jmf.codec.std.StringCodec;
038 import org.granite.messaging.reflect.Property;
039
040 /**
041 * @author Franck WOLFF
042 */
043 public interface CodecRegistry extends JMFConstants {
044
045 NullCodec getNullCodec();
046
047 BooleanCodec getBooleanCodec();
048 CharacterCodec getCharacterCodec();
049 ByteCodec getByteCodec();
050 ShortCodec getShortCodec();
051 IntegerCodec getIntegerCodec();
052 LongCodec getLongCodec();
053 FloatCodec getFloatCodec();
054 DoubleCodec getDoubleCodec();
055 StringCodec getStringCodec();
056
057 <T> StandardCodec<T> getCodec(int jmfType);
058 <T> StandardCodec<T> getCodec(Object v);
059
060 ExtendedObjectCodec findExtendedEncoder(ExtendedObjectOutput out, Object v);
061 ExtendedObjectCodec findExtendedDecoder(ExtendedObjectInput in, String className);
062
063 static interface PrimitivePropertyCodec {
064 public void encodePrimitive(OutputContext ctx, Object holder, Property property)
065 throws IllegalAccessException, IOException, InvocationTargetException;
066 public void decodePrimitive(InputContext ctx, Object holder, Property property)
067 throws IllegalAccessException, IOException, InvocationTargetException;
068 }
069
070 PrimitivePropertyCodec getPrimitivePropertyCodec(Class<?> propertyCls);
071
072 int extractJmfType(int parameterizedJmfType);
073
074 int jmfTypeOfPrimitiveClass(Class<?> cls);
075 Class<?> primitiveClassOfJmfType(int jmfType);
076 }