FileDocCategorySizeDatePackage
CodecFactoryImpl.javaAPI DocJava SE 5 API3098Fri Aug 26 14:54:22 BST 2005com.sun.corba.se.impl.interceptors

CodecFactoryImpl

public final class CodecFactoryImpl extends org.omg.CORBA.LocalObject implements org.omg.IOP.CodecFactory
CodecFactoryImpl is the implementation of the Codec Factory, as described in orbos/99-12-02.

Fields Summary
private org.omg.CORBA.ORB
orb
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
private static final int
MAX_MINOR_VERSION_SUPPORTED
private org.omg.IOP.Codec[]
codecs
Constructors Summary
public CodecFactoryImpl(org.omg.CORBA.ORB orb)
Creates a new CodecFactory implementation. Stores the ORB that created this factory, for later use by the Codec.


                            
         
        this.orb = orb;
	wrapper = ORBUtilSystemException.get( 
	    (com.sun.corba.se.spi.orb.ORB)orb, 
	    CORBALogDomains.RPC_PROTOCOL ) ;

	// Precreate a codec for version 1.0 through 
	// 1.(MAX_MINOR_VERSION_SUPPORTED).  This can be
	// done since Codecs are immutable in their current implementation.
	// This is an optimization that eliminates the overhead of creating
	// a new Codec each time create_codec is called.
	for( int minor = 0; minor <= MAX_MINOR_VERSION_SUPPORTED; minor++ ) {
	    codecs[minor] = new CDREncapsCodec( orb, 1, minor );
        }
    
Methods Summary
public org.omg.IOP.Codeccreate_codec(org.omg.IOP.Encoding enc)
Creates a codec of the given encoding. The only format recognized by this factory is ENCODING_CDR_ENCAPS, versions 1.0 through 1.(MAX_MINOR_VERSION_SUPPORTED).

exception
UnknownEncoding Thrown if this factory cannot create a Codec of the given encoding.

        if( enc == null ) nullParam();

	Codec result = null;

	// This is the only format we can currently create codecs for:
	if( (enc.format == ENCODING_CDR_ENCAPS.value) &&
            (enc.major_version == 1) ) 
        {
	    if( (enc.minor_version >= 0) && 
		(enc.minor_version <= MAX_MINOR_VERSION_SUPPORTED) ) 
            {
		result = codecs[enc.minor_version];
	    }
	}

	if( result == null ) {
	    throw new UnknownEncoding();
	}

	return result;
    
private voidnullParam()
Called when an invalid null parameter was passed. Throws a BAD_PARAM with a minor code of 1

	throw wrapper.nullParam() ;