Class CDREncapsCodec

java.lang.Object
org.omg.CORBA.LocalObject
com.sun.corba.ee.impl.interceptors.CDREncapsCodec
All Implemented Interfaces:
Serializable, Object, IDLEntity, Codec, CodecOperations

public final class CDREncapsCodec extends LocalObject implements Codec
CDREncapsCodec is an implementation of Codec, as described in orbos/99-12-02, that supports CDR encapsulation version 1.0, 1.1, and 1.2.
See Also:
  • Field Details

  • Constructor Details

    • CDREncapsCodec

      public CDREncapsCodec(ORB orb, int major, int minor)
      Creates a new codec implementation. Uses the given ORB to create CDRInputStreams when necessary.
      Parameters:
      orb - The ORB to use to create a CDRInputStream or CDROutputStream
      major - The major version of GIOP we are encoding for
      minor - The minor version of GIOP we are encoding for
  • Method Details

    • encode

      public byte[] encode(Any data) throws InvalidTypeForEncoding
      Convert the given any into a CDR encapsulated octet sequence
      Specified by:
      encode in interface CodecOperations
      Parameters:
      data - The data, in the form of an any, to be encoded into a byte array.
      Returns:
      A byte array containing the encoded Any. This byte array contains both the TypeCode and the data of the type.
      Throws:
      InvalidTypeForEncoding - thrown if the type is not valid for the encoding format effective for this Codec.
    • decode

      public Any decode(byte[] data) throws FormatMismatch
      Decode the given octet sequence into an any based on a CDR encapsulated octet sequence.
      Specified by:
      decode in interface CodecOperations
      Parameters:
      data - The data, in the form of a byte array, to be decoded into an Any.
      Returns:
      An Any containing the data from the decoded byte array.
      Throws:
      FormatMismatch - is thrown if the byte array cannot be decoded into an Any.
    • encode_value

      public byte[] encode_value(Any data) throws InvalidTypeForEncoding
      Convert the given any into a CDR encapsulated octet sequence. Only the data is stored. The type code is not.
      Specified by:
      encode_value in interface CodecOperations
      Parameters:
      data - The data, in the form of an Any, to be encoded into a byte array.
      Returns:
      A byte array containing the data from the encoded any.
      Throws:
      InvalidTypeForEncoding - thrown if the type is not valid for the encoding format effective for this Codec.
    • decode_value

      public Any decode_value(byte[] data, TypeCode tc) throws FormatMismatch, TypeMismatch
      Decode the given octet sequence into an any based on a CDR encapsulated octet sequence. The type code is expected not to appear in the octet sequence, and the given type code is used instead.
      Specified by:
      decode_value in interface CodecOperations
      Parameters:
      data - The data, in the form of a byte array, to be decoded into an Any.
      tc - The TypeCode to be used to decode the data.
      Returns:
      An Any containing the data from the decoded byte array.
      Throws:
      FormatMismatch - thrown if the byte array cannot be decoded into an Any.
      TypeMismatch - thrown
    • encodeImpl

      private byte[] encodeImpl(Any data, boolean sendTypeCode) throws InvalidTypeForEncoding
      Convert the given any into a CDR encapsulated octet sequence. If sendTypeCode is true, the type code is sent with the message, as in a standard encapsulation. If it is false, only the data is sent. Either way, the endian type is sent as the first part of the message.
      Throws:
      InvalidTypeForEncoding
    • decodeImpl

      private Any decodeImpl(byte[] data, TypeCode tc) throws FormatMismatch
      Decode the given octet sequence into an any based on a CDR encapsulated octet sequence. If the type code is null, it is expected to appear in the octet sequence. Otherwise, the given type code is used.
      Throws:
      FormatMismatch