Java Code Examples for gnu.CORBA.CDR.BufferedCdrOutput

The following are top voted examples for showing how to use gnu.CORBA.CDR.BufferedCdrOutput. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: javify   File: gnuPOA.java   Source Code and License 6 votes vote down vote up
/**
 * Get the unique Id of the POA in the process in which it is created.
 * This Id is needed by portable interceptors. The id is unique
 * for the life span of the POA in the process. For persistent
 * POAs, if a POA is created in the same path with the same name as
 * another POA, these POAs are identical have the same id. All transient
 * POAs are assumed unique.
 */
public byte[] id()
{
  if (m_poa_id != null)
    return m_poa_id;
  else
    {
      BufferedCdrOutput buffer = new BufferedCdrOutput();
      POA p = this;
      while (p != null)
        {
          buffer.write_string(p.the_name());
          p = p.the_parent();
        }
      m_poa_id = buffer.buffer.toByteArray();
      return m_poa_id;
    }
}
 
Example 2
Project: javify   File: IOR.java   Source Code and License 6 votes vote down vote up
/**
 * Returs a stringified reference.
 *
 * @return a newly constructed stringified reference.
 */
public String toStringifiedReference()
{
  BufferedCdrOutput out = new BufferedCdrOutput();

  _write(out);

  CPStringBuilder b = new CPStringBuilder("IOR:");

  byte[] binary = out.buffer.toByteArray();
  String s;

  for (int i = 0; i < binary.length; i++)
    {
      s = Integer.toHexString(binary[i] & 0xFF);
      if (s.length() == 1)
        b.append('0');
      b.append(s);
    }

  return b.toString();
}
 
Example 3
Project: javify   File: GeneralTypeCode.java   Source Code and License 6 votes vote down vote up
/**
 * Returns true if both typecodes, if written into CDR
 * stream, would result the same stream content.
 */
public boolean equal(TypeCode other)
{
  if (this == other)
    return true;
  if (kind() != other.kind())
    return false;

  BufferedCdrOutput a = new BufferedCdrOutput(16);
  BufferedCdrOutput b = new BufferedCdrOutput(16);

  a.write_TypeCode(this);
  b.write_TypeCode(other);

  return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
}
 
Example 4
Project: javify   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Create the buffered CDR input stream, containing the
 * value, stored inside of this {@link Any}.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
  if (has instanceof GeneralHolder)
    {
      GeneralHolder u = (GeneralHolder) has;
      return u.getInputStream();
    }
  else
    {
      BufferedCdrOutput out = new BufferedCdrOutput();
      out.setOrb(orb);
      write_value(out);

      BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
      in.setOrb(orb);
      return in;
    }
}
 
Example 5
Project: javify   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Compare two Any's for equality.
 * @param other the other Any to compare.
 */
public boolean equal(Any other)
{
  if (other == this)
    return true;
  if (type().kind() != other.type().kind())
    return false;

  if (has != null && other instanceof gnuAny)
    if (has.equals(((gnuAny) other).has))
      return true;

  BufferedCdrOutput a = new BufferedCdrOutput();
  a.setOrb(orb);
  write_value(a);

  BufferedCdrOutput b = new BufferedCdrOutput();
  b.setOrb(orb);
  other.write_value(b);

  byte[] ba = a.buffer.toByteArray();
  byte[] bb = b.buffer.toByteArray();

  return Arrays.equals(ba, bb);
}
 
Example 6
Project: javify   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);

      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());

      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
Example 7
Project: javify   File: CdrEncapsCodecImpl.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
public byte[] encode_value(Any that)
                    throws InvalidTypeForEncoding
{
  checkTypePossibility("", that.type());

  BufferedCdrOutput output = createOutput(that);

  AbstractCdrOutput encapsulation = output.createEncapsulation();

  try
    {
      that.write_value(encapsulation);

      encapsulation.close();
      output.close();
    }
  catch (Exception ex)
    {
      MARSHAL m = new MARSHAL();
      m.minor = Minor.Encapsulation;
      m.initCause(ex);
      throw m;
    }
  return output.buffer.toByteArray();
}
 
Example 8
Project: javify   File: ResponseHandlerImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Compute the header offset, set the correct version number and codeset.
 */
private void prepareStream()
{
  buffer = new BufferedCdrOutput();
  buffer.setOrb(orb);
  buffer.setVersion(message_header.version);
  buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));

  // Since 1.2, the data section is always aligned on the 8 byte boundary.
  // In older versions, it is necessary to set the offset correctly.
  if (message_header.version.until_inclusive(1, 1))
    {
      buffer.setOffset(message_header.getHeaderSize());

      // Get the position after the reply header would be written.
      reply_header.write(buffer);

      int new_offset = message_header.getHeaderSize() + buffer.buffer.size();

      buffer.buffer.reset();
      buffer.setOffset(new_offset);
    }
}
 
Example 9
Project: javify   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Get the parameter stream, where the invocation arguments should be written
 * if they are written into the stream directly.
 */
public StreamBasedRequest getParameterStream()
{
  m_parameter_buffer = new StreamBasedRequest();
  m_parameter_buffer.request = this;
  m_parameter_buffer.setVersion(ior.Internet.version);
  m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
  m_parameter_buffer.setOrb(orb);
  m_parameter_buffer.setBigEndian(Big_endian);

  // For the old iiop versions, it is important to set the size
  // correctly.
  if (ior.Internet.version.until_inclusive(1, 1))
    {
      BufferedCdrOutput measure = new BufferedCdrOutput();
      measure.setOffset(12);
      if (m_rqh == null)
        m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
      m_rqh.operation = m_operation;
      m_rqh.object_key = ior.key;
      m_rqh.write(measure);
      m_parameter_buffer.setOffset(12 + measure.buffer.size());
    }

  return m_parameter_buffer;
}
 
Example 10
Project: javify   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Write the operation parameters.
 *
 * @param header the message header
 * @param request_part the stream to write parameters into
 *
 * @throws MARSHAL if the attempt to write the parameters has failde.
 */
protected void write_parameter_buffer(MessageHeader header,
  BufferedCdrOutput request_part
) throws MARSHAL
{
  try
    {
      if (header.version.since_inclusive(1, 2))
        {
          request_part.align(8);
        }
      m_parameter_buffer.buffer.writeTo(request_part);
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
      m.minor = Minor.CDR;
      throw m;
    }
}
 
Example 11
Project: jvm-stm   File: gnuPOA.java   Source Code and License 6 votes vote down vote up
/**
 * Get the unique Id of the POA in the process in which it is created.
 * This Id is needed by portable interceptors. The id is unique
 * for the life span of the POA in the process. For persistent
 * POAs, if a POA is created in the same path with the same name as
 * another POA, these POAs are identical have the same id. All transient
 * POAs are assumed unique.
 */
public byte[] id()
{
  if (m_poa_id != null)
    return m_poa_id;
  else
    {
      BufferedCdrOutput buffer = new BufferedCdrOutput();
      POA p = this;
      while (p != null)
        {
          buffer.write_string(p.the_name());
          p = p.the_parent();
        }
      m_poa_id = buffer.buffer.toByteArray();
      return m_poa_id;
    }
}
 
Example 12
Project: jvm-stm   File: IOR.java   Source Code and License 6 votes vote down vote up
/**
 * Returs a stringified reference.
 *
 * @return a newly constructed stringified reference.
 */
public String toStringifiedReference()
{
  BufferedCdrOutput out = new BufferedCdrOutput();

  _write(out);

  CPStringBuilder b = new CPStringBuilder("IOR:");

  byte[] binary = out.buffer.toByteArray();
  String s;

  for (int i = 0; i < binary.length; i++)
    {
      s = Integer.toHexString(binary[i] & 0xFF);
      if (s.length() == 1)
        b.append('0');
      b.append(s);
    }

  return b.toString();
}
 
Example 13
Project: jvm-stm   File: GeneralTypeCode.java   Source Code and License 6 votes vote down vote up
/**
 * Returns true if both typecodes, if written into CDR
 * stream, would result the same stream content.
 */
public boolean equal(TypeCode other)
{
  if (this == other)
    return true;
  if (kind() != other.kind())
    return false;

  BufferedCdrOutput a = new BufferedCdrOutput(16);
  BufferedCdrOutput b = new BufferedCdrOutput(16);

  a.write_TypeCode(this);
  b.write_TypeCode(other);

  return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
}
 
Example 14
Project: jvm-stm   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Create the buffered CDR input stream, containing the
 * value, stored inside of this {@link Any}.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
  if (has instanceof GeneralHolder)
    {
      GeneralHolder u = (GeneralHolder) has;
      return u.getInputStream();
    }
  else
    {
      BufferedCdrOutput out = new BufferedCdrOutput();
      out.setOrb(orb);
      write_value(out);

      BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
      in.setOrb(orb);
      return in;
    }
}
 
Example 15
Project: jvm-stm   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Compare two Any's for equality.
 * @param other the other Any to compare.
 */
public boolean equal(Any other)
{
  if (other == this)
    return true;
  if (type().kind() != other.type().kind())
    return false;

  if (has != null && other instanceof gnuAny)
    if (has.equals(((gnuAny) other).has))
      return true;

  BufferedCdrOutput a = new BufferedCdrOutput();
  a.setOrb(orb);
  write_value(a);

  BufferedCdrOutput b = new BufferedCdrOutput();
  b.setOrb(orb);
  other.write_value(b);

  byte[] ba = a.buffer.toByteArray();
  byte[] bb = b.buffer.toByteArray();

  return Arrays.equals(ba, bb);
}
 
Example 16
Project: jvm-stm   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);
      
      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());
      
      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
Example 17
Project: jvm-stm   File: CdrEncapsCodecImpl.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
public byte[] encode_value(Any that)
                    throws InvalidTypeForEncoding
{
  checkTypePossibility("", that.type());

  BufferedCdrOutput output = createOutput(that);

  AbstractCdrOutput encapsulation = output.createEncapsulation();

  try
    {
      that.write_value(encapsulation);

      encapsulation.close();
      output.close();
    }
  catch (Exception ex)
    {
      MARSHAL m = new MARSHAL();
      m.minor = Minor.Encapsulation;
      m.initCause(ex);
      throw m;
    }
  return output.buffer.toByteArray();
}
 
Example 18
Project: jvm-stm   File: ResponseHandlerImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Compute the header offset, set the correct version number and codeset.
 */
private void prepareStream()
{
  buffer = new BufferedCdrOutput();
  buffer.setOrb(orb);
  buffer.setVersion(message_header.version);
  buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));

  // Since 1.2, the data section is always aligned on the 8 byte boundary.
  // In older versions, it is necessary to set the offset correctly.
  if (message_header.version.until_inclusive(1, 1))
    {
      buffer.setOffset(message_header.getHeaderSize());

      // Get the position after the reply header would be written.
      reply_header.write(buffer);

      int new_offset = message_header.getHeaderSize() + buffer.buffer.size();

      buffer.buffer.reset();
      buffer.setOffset(new_offset);
    }
}
 
Example 19
Project: jvm-stm   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Get the parameter stream, where the invocation arguments should be written
 * if they are written into the stream directly.
 */
public StreamBasedRequest getParameterStream()
{
  m_parameter_buffer = new StreamBasedRequest();
  m_parameter_buffer.request = this;
  m_parameter_buffer.setVersion(ior.Internet.version);
  m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
  m_parameter_buffer.setOrb(orb);
  m_parameter_buffer.setBigEndian(Big_endian);

  // For the old iiop versions, it is important to set the size
  // correctly.
  if (ior.Internet.version.until_inclusive(1, 1))
    {
      BufferedCdrOutput measure = new BufferedCdrOutput();
      measure.setOffset(12);
      if (m_rqh == null)
        m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
      m_rqh.operation = m_operation;
      m_rqh.object_key = ior.key;
      m_rqh.write(measure);
      m_parameter_buffer.setOffset(12 + measure.buffer.size());
    }

  return m_parameter_buffer;
}
 
Example 20
Project: jvm-stm   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Write the operation parameters.
 *
 * @param header the message header
 * @param request_part the stream to write parameters into
 *
 * @throws MARSHAL if the attempt to write the parameters has failde.
 */
protected void write_parameter_buffer(MessageHeader header,
  BufferedCdrOutput request_part
) throws MARSHAL
{
  try
    {
      if (header.version.since_inclusive(1, 2))
        {
          request_part.align(8);
        }
      m_parameter_buffer.buffer.writeTo(request_part);
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
      m.minor = Minor.CDR;
      throw m;
    }
}
 
Example 21
Project: JamVM-PH   File: gnuPOA.java   Source Code and License 6 votes vote down vote up
/**
 * Get the unique Id of the POA in the process in which it is created.
 * This Id is needed by portable interceptors. The id is unique
 * for the life span of the POA in the process. For persistent
 * POAs, if a POA is created in the same path with the same name as
 * another POA, these POAs are identical have the same id. All transient
 * POAs are assumed unique.
 */
public byte[] id()
{
  if (m_poa_id != null)
    return m_poa_id;
  else
    {
      BufferedCdrOutput buffer = new BufferedCdrOutput();
      POA p = this;
      while (p != null)
        {
          buffer.write_string(p.the_name());
          p = p.the_parent();
        }
      m_poa_id = buffer.buffer.toByteArray();
      return m_poa_id;
    }
}
 
Example 22
Project: JamVM-PH   File: IOR.java   Source Code and License 6 votes vote down vote up
/**
 * Returs a stringified reference.
 *
 * @return a newly constructed stringified reference.
 */
public String toStringifiedReference()
{
  BufferedCdrOutput out = new BufferedCdrOutput();

  _write(out);

  CPStringBuilder b = new CPStringBuilder("IOR:");

  byte[] binary = out.buffer.toByteArray();
  String s;

  for (int i = 0; i < binary.length; i++)
    {
      s = Integer.toHexString(binary[i] & 0xFF);
      if (s.length() == 1)
        b.append('0');
      b.append(s);
    }

  return b.toString();
}
 
Example 23
Project: JamVM-PH   File: GeneralTypeCode.java   Source Code and License 6 votes vote down vote up
/**
 * Returns true if both typecodes, if written into CDR
 * stream, would result the same stream content.
 */
public boolean equal(TypeCode other)
{
  if (this == other)
    return true;
  if (kind() != other.kind())
    return false;

  BufferedCdrOutput a = new BufferedCdrOutput(16);
  BufferedCdrOutput b = new BufferedCdrOutput(16);

  a.write_TypeCode(this);
  b.write_TypeCode(other);

  return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
}
 
Example 24
Project: JamVM-PH   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Create the buffered CDR input stream, containing the
 * value, stored inside of this {@link Any}.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
  if (has instanceof GeneralHolder)
    {
      GeneralHolder u = (GeneralHolder) has;
      return u.getInputStream();
    }
  else
    {
      BufferedCdrOutput out = new BufferedCdrOutput();
      out.setOrb(orb);
      write_value(out);

      BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
      in.setOrb(orb);
      return in;
    }
}
 
Example 25
Project: JamVM-PH   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Compare two Any's for equality.
 * @param other the other Any to compare.
 */
public boolean equal(Any other)
{
  if (other == this)
    return true;
  if (type().kind() != other.type().kind())
    return false;

  if (has != null && other instanceof gnuAny)
    if (has.equals(((gnuAny) other).has))
      return true;

  BufferedCdrOutput a = new BufferedCdrOutput();
  a.setOrb(orb);
  write_value(a);

  BufferedCdrOutput b = new BufferedCdrOutput();
  b.setOrb(orb);
  other.write_value(b);

  byte[] ba = a.buffer.toByteArray();
  byte[] bb = b.buffer.toByteArray();

  return Arrays.equals(ba, bb);
}
 
Example 26
Project: JamVM-PH   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);
      
      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());
      
      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
Example 27
Project: JamVM-PH   File: CdrEncapsCodecImpl.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
public byte[] encode_value(Any that)
                    throws InvalidTypeForEncoding
{
  checkTypePossibility("", that.type());

  BufferedCdrOutput output = createOutput(that);

  AbstractCdrOutput encapsulation = output.createEncapsulation();

  try
    {
      that.write_value(encapsulation);

      encapsulation.close();
      output.close();
    }
  catch (Exception ex)
    {
      MARSHAL m = new MARSHAL();
      m.minor = Minor.Encapsulation;
      m.initCause(ex);
      throw m;
    }
  return output.buffer.toByteArray();
}
 
Example 28
Project: JamVM-PH   File: ResponseHandlerImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Compute the header offset, set the correct version number and codeset.
 */
private void prepareStream()
{
  buffer = new BufferedCdrOutput();
  buffer.setOrb(orb);
  buffer.setVersion(message_header.version);
  buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));

  // Since 1.2, the data section is always aligned on the 8 byte boundary.
  // In older versions, it is necessary to set the offset correctly.
  if (message_header.version.until_inclusive(1, 1))
    {
      buffer.setOffset(message_header.getHeaderSize());

      // Get the position after the reply header would be written.
      reply_header.write(buffer);

      int new_offset = message_header.getHeaderSize() + buffer.buffer.size();

      buffer.buffer.reset();
      buffer.setOffset(new_offset);
    }
}
 
Example 29
Project: JamVM-PH   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Get the parameter stream, where the invocation arguments should be written
 * if they are written into the stream directly.
 */
public StreamBasedRequest getParameterStream()
{
  m_parameter_buffer = new StreamBasedRequest();
  m_parameter_buffer.request = this;
  m_parameter_buffer.setVersion(ior.Internet.version);
  m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
  m_parameter_buffer.setOrb(orb);
  m_parameter_buffer.setBigEndian(Big_endian);

  // For the old iiop versions, it is important to set the size
  // correctly.
  if (ior.Internet.version.until_inclusive(1, 1))
    {
      BufferedCdrOutput measure = new BufferedCdrOutput();
      measure.setOffset(12);
      if (m_rqh == null)
        m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
      m_rqh.operation = m_operation;
      m_rqh.object_key = ior.key;
      m_rqh.write(measure);
      m_parameter_buffer.setOffset(12 + measure.buffer.size());
    }

  return m_parameter_buffer;
}
 
Example 30
Project: JamVM-PH   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Write the operation parameters.
 *
 * @param header the message header
 * @param request_part the stream to write parameters into
 *
 * @throws MARSHAL if the attempt to write the parameters has failde.
 */
protected void write_parameter_buffer(MessageHeader header,
  BufferedCdrOutput request_part
) throws MARSHAL
{
  try
    {
      if (header.version.since_inclusive(1, 2))
        {
          request_part.align(8);
        }
      m_parameter_buffer.buffer.writeTo(request_part);
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
      m.minor = Minor.CDR;
      throw m;
    }
}
 
Example 31
Project: classpath   File: gnuPOA.java   Source Code and License 6 votes vote down vote up
/**
 * Get the unique Id of the POA in the process in which it is created.
 * This Id is needed by portable interceptors. The id is unique
 * for the life span of the POA in the process. For persistent
 * POAs, if a POA is created in the same path with the same name as
 * another POA, these POAs are identical have the same id. All transient
 * POAs are assumed unique.
 */
public byte[] id()
{
  if (m_poa_id != null)
    return m_poa_id;
  else
    {
      BufferedCdrOutput buffer = new BufferedCdrOutput();
      POA p = this;
      while (p != null)
        {
          buffer.write_string(p.the_name());
          p = p.the_parent();
        }
      m_poa_id = buffer.buffer.toByteArray();
      return m_poa_id;
    }
}
 
Example 32
Project: classpath   File: IOR.java   Source Code and License 6 votes vote down vote up
/**
 * Returs a stringified reference.
 *
 * @return a newly constructed stringified reference.
 */
public String toStringifiedReference()
{
  BufferedCdrOutput out = new BufferedCdrOutput();

  _write(out);

  CPStringBuilder b = new CPStringBuilder("IOR:");

  byte[] binary = out.buffer.toByteArray();
  String s;

  for (int i = 0; i < binary.length; i++)
    {
      s = Integer.toHexString(binary[i] & 0xFF);
      if (s.length() == 1)
        b.append('0');
      b.append(s);
    }

  return b.toString();
}
 
Example 33
Project: classpath   File: GeneralTypeCode.java   Source Code and License 6 votes vote down vote up
/**
 * Returns true if both typecodes, if written into CDR
 * stream, would result the same stream content.
 */
public boolean equal(TypeCode other)
{
  if (this == other)
    return true;
  if (kind() != other.kind())
    return false;

  BufferedCdrOutput a = new BufferedCdrOutput(16);
  BufferedCdrOutput b = new BufferedCdrOutput(16);

  a.write_TypeCode(this);
  b.write_TypeCode(other);

  return Arrays.equals(a.buffer.toByteArray(), b.buffer.toByteArray());
}
 
Example 34
Project: classpath   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Create the buffered CDR input stream, containing the
 * value, stored inside of this {@link Any}.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
  if (has instanceof GeneralHolder)
    {
      GeneralHolder u = (GeneralHolder) has;
      return u.getInputStream();
    }
  else
    {
      BufferedCdrOutput out = new BufferedCdrOutput();
      out.setOrb(orb);
      write_value(out);

      BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
      in.setOrb(orb);
      return in;
    }
}
 
Example 35
Project: classpath   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Compare two Any's for equality.
 * @param other the other Any to compare.
 */
public boolean equal(Any other)
{
  if (other == this)
    return true;
  if (type().kind() != other.type().kind())
    return false;

  if (has != null && other instanceof gnuAny)
    if (has.equals(((gnuAny) other).has))
      return true;

  BufferedCdrOutput a = new BufferedCdrOutput();
  a.setOrb(orb);
  write_value(a);

  BufferedCdrOutput b = new BufferedCdrOutput();
  b.setOrb(orb);
  other.write_value(b);

  byte[] ba = a.buffer.toByteArray();
  byte[] bb = b.buffer.toByteArray();

  return Arrays.equals(ba, bb);
}
 
Example 36
Project: classpath   File: gnuAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get the content - dependent hashcode.
 */
public int hashCode()
{
  if (has == null)
    return type().kind().value();
  else
    {
      Adler32 adler = new Adler32();

      BufferedCdrOutput a = new BufferedCdrOutput();
      a.setOrb(orb);
      write_value(a);

      adler.update(a.buffer.toByteArray());
      adler.update(type().kind().value());

      return (int) adler.getValue() & Integer.MAX_VALUE;
    }
}
 
Example 37
Project: classpath   File: CdrEncapsCodecImpl.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
public byte[] encode_value(Any that)
                    throws InvalidTypeForEncoding
{
  checkTypePossibility("", that.type());

  BufferedCdrOutput output = createOutput(that);

  AbstractCdrOutput encapsulation = output.createEncapsulation();

  try
    {
      that.write_value(encapsulation);

      encapsulation.close();
      output.close();
    }
  catch (Exception ex)
    {
      MARSHAL m = new MARSHAL();
      m.minor = Minor.Encapsulation;
      m.initCause(ex);
      throw m;
    }
  return output.buffer.toByteArray();
}
 
Example 38
Project: classpath   File: ResponseHandlerImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Compute the header offset, set the correct version number and codeset.
 */
private void prepareStream()
{
  buffer = new BufferedCdrOutput();
  buffer.setOrb(orb);
  buffer.setVersion(message_header.version);
  buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));

  // Since 1.2, the data section is always aligned on the 8 byte boundary.
  // In older versions, it is necessary to set the offset correctly.
  if (message_header.version.until_inclusive(1, 1))
    {
      buffer.setOffset(message_header.getHeaderSize());

      // Get the position after the reply header would be written.
      reply_header.write(buffer);

      int new_offset = message_header.getHeaderSize() + buffer.buffer.size();

      buffer.buffer.reset();
      buffer.setOffset(new_offset);
    }
}
 
Example 39
Project: classpath   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Get the parameter stream, where the invocation arguments should be written
 * if they are written into the stream directly.
 */
public StreamBasedRequest getParameterStream()
{
  m_parameter_buffer = new StreamBasedRequest();
  m_parameter_buffer.request = this;
  m_parameter_buffer.setVersion(ior.Internet.version);
  m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
  m_parameter_buffer.setOrb(orb);
  m_parameter_buffer.setBigEndian(Big_endian);

  // For the old iiop versions, it is important to set the size
  // correctly.
  if (ior.Internet.version.until_inclusive(1, 1))
    {
      BufferedCdrOutput measure = new BufferedCdrOutput();
      measure.setOffset(12);
      if (m_rqh == null)
        m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
      m_rqh.operation = m_operation;
      m_rqh.object_key = ior.key;
      m_rqh.write(measure);
      m_parameter_buffer.setOffset(12 + measure.buffer.size());
    }

  return m_parameter_buffer;
}
 
Example 40
Project: classpath   File: gnuRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Write the operation parameters.
 *
 * @param header the message header
 * @param request_part the stream to write parameters into
 *
 * @throws MARSHAL if the attempt to write the parameters has failde.
 */
protected void write_parameter_buffer(MessageHeader header,
  BufferedCdrOutput request_part
) throws MARSHAL
{
  try
    {
      if (header.version.since_inclusive(1, 2))
        {
          request_part.align(8);
        }
      m_parameter_buffer.buffer.writeTo(request_part);
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
      m.minor = Minor.CDR;
      throw m;
    }
}