1 /*
   2  * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.corba.se.impl.encoding;
  26 
  27 import java.io.IOException;
  28 import java.io.Serializable;
  29 import java.math.BigDecimal;
  30 import java.nio.ByteBuffer;
  31 
  32 import org.omg.CORBA.TypeCode;
  33 import org.omg.CORBA.Principal;
  34 import org.omg.CORBA.Any;
  35 
  36 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  37 import com.sun.corba.se.spi.orb.ORB;
  38 
  39 /**
  40  * Describes CDROutputStream delegates and provides some
  41  * implementation.  Non-default constructors are avoided in
  42  * the delegation to separate instantiation from initialization,
  43  * so we use init methods.
  44  */
  45 abstract class CDROutputStreamBase extends java.io.OutputStream
  46 {
  47     protected CDROutputStream parent;
  48 
  49     // Required by parent CDROutputStream
  50     public void setParent(CDROutputStream parent) {
  51         this.parent = parent;
  52     }
  53 
  54     public void init(org.omg.CORBA.ORB orb,
  55                      BufferManagerWrite bufferManager,
  56                      byte streamFormatVersion) {
  57         init(orb, false, bufferManager, streamFormatVersion, true);
  58     }
  59 
  60     // See EncapsOutputStream, the only one that uses the
  61     // non-pooled ByteBuffers, for additional info.
  62     protected abstract void init(org.omg.CORBA.ORB orb,
  63                                  boolean littleEndian,
  64                                  BufferManagerWrite bufferManager,
  65                                  byte streamFormatVersion,
  66                                  boolean usePooledByteBuffers);
  67 
  68     public abstract void write_boolean(boolean value);
  69     public abstract void write_char(char value);
  70     public abstract void write_wchar(char value);
  71     public abstract void write_octet(byte value);
  72     public abstract void write_short(short value);
  73     public abstract void write_ushort(short value);
  74     public abstract void write_long(int value);
  75     public abstract void write_ulong(int value);
  76     public abstract void write_longlong(long value);
  77     public abstract void write_ulonglong(long value);
  78     public abstract void write_float(float value);
  79     public abstract void write_double(double value);
  80     public abstract void write_string(String value);
  81     public abstract void write_wstring(String value);
  82     public abstract void write_boolean_array(boolean[] value, int offset, int length);
  83     public abstract void write_char_array(char[] value, int offset, int length);
  84     public abstract void write_wchar_array(char[] value, int offset, int length);
  85     public abstract void write_octet_array(byte[] value, int offset, int length);
  86     public abstract void write_short_array(short[] value, int offset, int length);
  87     public abstract void write_ushort_array(short[] value, int offset, int length);
  88     public abstract void write_long_array(int[] value, int offset, int length);
  89     public abstract void write_ulong_array(int[] value, int offset, int length);
  90     public abstract void write_longlong_array(long[] value, int offset, int length);
  91     public abstract void write_ulonglong_array(long[] value, int offset, int length);
  92     public abstract void write_float_array(float[] value, int offset, int length);
  93     public abstract void write_double_array(double[] value, int offset, int length);
  94     public abstract void write_Object(org.omg.CORBA.Object value);
  95     public abstract void write_TypeCode(TypeCode value);
  96     public abstract void write_any(Any value);
  97     public abstract void write_Principal(Principal value);
  98     public void write(int b) throws java.io.IOException {
  99         throw new org.omg.CORBA.NO_IMPLEMENT();
 100     }
 101     public abstract void write_fixed(java.math.BigDecimal value);
 102     public void write_Context(org.omg.CORBA.Context ctx,
 103                               org.omg.CORBA.ContextList contexts) {
 104         throw new org.omg.CORBA.NO_IMPLEMENT();
 105     }
 106 
 107     public abstract org.omg.CORBA.ORB orb();
 108 
 109     // org.omg.CORBA_2_3.portable.OutputStream
 110     public abstract void write_value(java.io.Serializable value);
 111     public abstract void write_value(java.io.Serializable value, java.lang.Class clz);
 112     public abstract void write_value(java.io.Serializable value, String repository_id);
 113     public abstract void write_value(java.io.Serializable value,
 114                                      org.omg.CORBA.portable.BoxedValueHelper factory);
 115     public abstract void write_abstract_interface(java.lang.Object obj);
 116 
 117     // java.io.OutputStream
 118 //     public abstract void write(byte b[]) throws IOException;
 119 //     public abstract void write(byte b[], int off, int len) throws IOException;
 120 //     public abstract void flush() throws IOException;
 121 //     public abstract void close() throws IOException;
 122 
 123     // com.sun.corba.se.impl.encoding.MarshalOutputStream
 124     public abstract void start_block();
 125     public abstract void end_block();
 126     public abstract void putEndian();
 127     public abstract void writeTo(java.io.OutputStream s)
 128         throws IOException;
 129     public abstract byte[] toByteArray();
 130 
 131     // org.omg.CORBA.DataOutputStream
 132     public abstract void write_Abstract (java.lang.Object value);
 133     public abstract void write_Value (java.io.Serializable value);
 134     public abstract void write_any_array(org.omg.CORBA.Any[] seq, int offset, int length);
 135 
 136     // org.omg.CORBA.portable.ValueBase
 137     public abstract String[] _truncatable_ids();
 138 
 139     // Needed by request and reply messages for GIOP versions >= 1.2 only.
 140     abstract void setHeaderPadding(boolean headerPadding);
 141 
 142     // Required by IIOPOutputStream and other subclasses
 143     public abstract int getSize();
 144 
 145     public abstract int getIndex();
 146     public abstract void setIndex(int value);
 147 
 148     public abstract ByteBuffer getByteBuffer();
 149     public abstract void setByteBuffer(ByteBuffer byteBuffer);
 150 
 151     public abstract boolean isLittleEndian();
 152 
 153     public abstract ByteBufferWithInfo getByteBufferWithInfo();
 154     public abstract void setByteBufferWithInfo(ByteBufferWithInfo bbwi);
 155 
 156     public abstract BufferManagerWrite getBufferManager();
 157 
 158     public abstract void write_fixed(java.math.BigDecimal bigDecimal, short digits, short scale);
 159     public abstract void writeOctetSequenceTo(org.omg.CORBA.portable.OutputStream s);
 160 
 161     public abstract GIOPVersion getGIOPVersion();
 162 
 163     public abstract void writeIndirection(int tag, int posIndirectedTo);
 164 
 165     abstract void freeInternalCaches();
 166 
 167     abstract void printBuffer();
 168 
 169     abstract void alignOnBoundary(int octetBoundary);
 170 
 171     // org.omg.CORBA.portable.ValueOutputStream
 172 
 173     public abstract void start_value(String rep_id);
 174 
 175     public abstract void end_value();
 176 }