/* RawReply.java --
   Copyright (C) 2005 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package gnu.CORBA;

import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.MessageHeader;

import org.omg.CORBA.ORB;

/**
 * The remote object reply in the binary form, holding
 * the message header and the following binary data.
 *
 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
 */
class RawReply
{
  /**
   * The message header.
   */
  final MessageHeader header;

  /**
   * The associated orb.
   */
  final ORB orb;

  /**
   * The message data.
   */
  final byte[] data;

  /**
   * Create the binary reply.
   *
   * @param an_header the message header
   * @param a_data the message data.
   */
  RawReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
  {
    orb = an_orb;
    header = an_header;
    data = a_data;
  }

  /**
   * Get the CDR input stream with the correctly set alignment.
   *
   * @return the CDR stream to read the message data.
   */
  BufferredCdrInput getStream()
  {
    BufferredCdrInput in = new BufferredCdrInput(data);
    in.setOffset(header.getHeaderSize());
    in.setVersion(header.version);
    in.setOrb(orb);
    in.setBigEndian(header.isBigEndian());
    return in;
  }
}
