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 021package org.granite.messaging.jmf; 022 023import java.io.IOException; 024import java.lang.reflect.Field; 025 026import org.granite.messaging.jmf.codec.ExtendedObjectCodec; 027import org.granite.messaging.jmf.codec.StandardCodec; 028import org.granite.messaging.jmf.codec.std.BooleanCodec; 029import org.granite.messaging.jmf.codec.std.ByteCodec; 030import org.granite.messaging.jmf.codec.std.CharacterCodec; 031import org.granite.messaging.jmf.codec.std.DoubleCodec; 032import org.granite.messaging.jmf.codec.std.FloatCodec; 033import org.granite.messaging.jmf.codec.std.IntegerCodec; 034import org.granite.messaging.jmf.codec.std.LongCodec; 035import org.granite.messaging.jmf.codec.std.NullCodec; 036import org.granite.messaging.jmf.codec.std.ShortCodec; 037import org.granite.messaging.jmf.codec.std.StringCodec; 038 039/** 040 * @author Franck WOLFF 041 */ 042public interface CodecRegistry extends JMFConstants { 043 044 NullCodec getNullCodec(); 045 046 BooleanCodec getBooleanCodec(); 047 CharacterCodec getCharacterCodec(); 048 ByteCodec getByteCodec(); 049 ShortCodec getShortCodec(); 050 IntegerCodec getIntegerCodec(); 051 LongCodec getLongCodec(); 052 FloatCodec getFloatCodec(); 053 DoubleCodec getDoubleCodec(); 054 StringCodec getStringCodec(); 055 056 <T> StandardCodec<T> getCodec(int jmfType); 057 <T> StandardCodec<T> getCodec(Object v); 058 059 ExtendedObjectCodec findExtendedEncoder(ExtendedObjectOutput out, Object v); 060 ExtendedObjectCodec findExtendedDecoder(ExtendedObjectInput in, String className) 061 throws ClassNotFoundException; 062 063 static interface PrimitiveFieldCodec { 064 public void encodePrimitive(OutputContext ctx, Object v, Field field) 065 throws IllegalAccessException, IOException; 066 public void decodePrimitive(InputContext ctx, Object v, Field field) 067 throws IllegalAccessException, IOException; 068 } 069 070 PrimitiveFieldCodec getPrimitiveFieldCodec(Class<?> fieldCls); 071 072 int extractJmfType(int parameterizedJmfType); 073 074 int jmfTypeOfPrimitiveClass(Class<?> cls); 075 Class<?> primitiveClassOfJmfType(int jmfType); 076}