tests/libjava-mauve/src/gnu/testlet/org/omg/CORBA/portable/OutputStream/mirror.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: not-a-test
       
     2 // Copyright (C) 2005 Audrius Meskauskas (AudriusA@Bioinformatics.org)
       
     3 
       
     4 // Mauve is free software; you can redistribute it and/or modify
       
     5 // it under the terms of the GNU General Public License as published by
       
     6 // the Free Software Foundation; either version 2, or (at your option)
       
     7 // any later version.
       
     8 
       
     9 // Mauve is distributed in the hope that it will be useful,
       
    10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 // GNU General Public License for more details.
       
    13 
       
    14 // You should have received a copy of the GNU General Public License
       
    15 // along with Mauve; see the file COPYING.  If not, write to
       
    16 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    17 // Boston, MA 02111-1307, USA.  */
       
    18 
       
    19 package gnu.testlet.org.omg.CORBA.portable.OutputStream;
       
    20 
       
    21 import org.omg.CORBA.OctetSeqHelper;
       
    22 import org.omg.CORBA.portable.InputStream;
       
    23 import org.omg.CORBA.portable.InvokeHandler;
       
    24 import org.omg.CORBA.portable.ObjectImpl;
       
    25 import org.omg.CORBA.portable.OutputStream;
       
    26 import org.omg.CORBA.portable.ResponseHandler;
       
    27 
       
    28 import java.io.ByteArrayOutputStream;
       
    29 
       
    30 /**
       
    31  * A reflector is a non standard CORBA object that accepts the
       
    32  * passed parameter and then returns all passed data as a
       
    33  * plain byte array, exactly how they were sent. Not a test,
       
    34  * needed by BinaryAlignment.
       
    35  *
       
    36  * @author Audrius Meskauskas (AudriusA@bluewin.ch)
       
    37  */
       
    38 class mirror
       
    39   extends ObjectImpl
       
    40   implements InvokeHandler
       
    41 {
       
    42   /**
       
    43    *  Return the passed parameters as the plain binary array.
       
    44    */
       
    45   public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
       
    46   {
       
    47     ByteArrayOutputStream data = new ByteArrayOutputStream();
       
    48 
       
    49     byte b;
       
    50     do
       
    51       {
       
    52         b = in.read_octet();
       
    53         data.write(b);
       
    54       }
       
    55     while ((b & 0xFF) != 0xFF);
       
    56 
       
    57     OutputStream out = rh.createReply();
       
    58     OctetSeqHelper.write(out, data.toByteArray());
       
    59 
       
    60     return out;
       
    61   }
       
    62 
       
    63   public String[] _ids()
       
    64   {
       
    65     return new String[] { getClass().getName() };
       
    66   }
       
    67 }