Home » openjdk-7 » java » io » [javadoc | source]

    1   /*
    2    * Copyright (c) 1996, 2006, 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   
   26   package java.io;
   27   
   28   /**
   29    * Constants written into the Object Serialization Stream.
   30    *
   31    * @author  unascribed
   32    * @since JDK 1.1
   33    */
   34   public interface ObjectStreamConstants {
   35   
   36       /**
   37        * Magic number that is written to the stream header.
   38        */
   39       final static short STREAM_MAGIC = (short)0xaced;
   40   
   41       /**
   42        * Version number that is written to the stream header.
   43        */
   44       final static short STREAM_VERSION = 5;
   45   
   46       /* Each item in the stream is preceded by a tag
   47        */
   48   
   49       /**
   50        * First tag value.
   51        */
   52       final static byte TC_BASE = 0x70;
   53   
   54       /**
   55        * Null object reference.
   56        */
   57       final static byte TC_NULL =         (byte)0x70;
   58   
   59       /**
   60        * Reference to an object already written into the stream.
   61        */
   62       final static byte TC_REFERENCE =    (byte)0x71;
   63   
   64       /**
   65        * new Class Descriptor.
   66        */
   67       final static byte TC_CLASSDESC =    (byte)0x72;
   68   
   69       /**
   70        * new Object.
   71        */
   72       final static byte TC_OBJECT =       (byte)0x73;
   73   
   74       /**
   75        * new String.
   76        */
   77       final static byte TC_STRING =       (byte)0x74;
   78   
   79       /**
   80        * new Array.
   81        */
   82       final static byte TC_ARRAY =        (byte)0x75;
   83   
   84       /**
   85        * Reference to Class.
   86        */
   87       final static byte TC_CLASS =        (byte)0x76;
   88   
   89       /**
   90        * Block of optional data. Byte following tag indicates number
   91        * of bytes in this block data.
   92        */
   93       final static byte TC_BLOCKDATA =    (byte)0x77;
   94   
   95       /**
   96        * End of optional block data blocks for an object.
   97        */
   98       final static byte TC_ENDBLOCKDATA = (byte)0x78;
   99   
  100       /**
  101        * Reset stream context. All handles written into stream are reset.
  102        */
  103       final static byte TC_RESET =        (byte)0x79;
  104   
  105       /**
  106        * long Block data. The long following the tag indicates the
  107        * number of bytes in this block data.
  108        */
  109       final static byte TC_BLOCKDATALONG= (byte)0x7A;
  110   
  111       /**
  112        * Exception during write.
  113        */
  114       final static byte TC_EXCEPTION =    (byte)0x7B;
  115   
  116       /**
  117        * Long string.
  118        */
  119       final static byte TC_LONGSTRING =   (byte)0x7C;
  120   
  121       /**
  122        * new Proxy Class Descriptor.
  123        */
  124       final static byte TC_PROXYCLASSDESC =       (byte)0x7D;
  125   
  126       /**
  127        * new Enum constant.
  128        * @since 1.5
  129        */
  130       final static byte TC_ENUM =         (byte)0x7E;
  131   
  132       /**
  133        * Last tag value.
  134        */
  135       final static byte TC_MAX =          (byte)0x7E;
  136   
  137       /**
  138        * First wire handle to be assigned.
  139        */
  140       final static int baseWireHandle = 0x7e0000;
  141   
  142   
  143       /******************************************************/
  144       /* Bit masks for ObjectStreamClass flag.*/
  145   
  146       /**
  147        * Bit mask for ObjectStreamClass flag. Indicates a Serializable class
  148        * defines its own writeObject method.
  149        */
  150       final static byte SC_WRITE_METHOD = 0x01;
  151   
  152       /**
  153        * Bit mask for ObjectStreamClass flag. Indicates Externalizable data
  154        * written in Block Data mode.
  155        * Added for PROTOCOL_VERSION_2.
  156        *
  157        * @see #PROTOCOL_VERSION_2
  158        * @since 1.2
  159        */
  160       final static byte SC_BLOCK_DATA = 0x08;
  161   
  162       /**
  163        * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
  164        */
  165       final static byte SC_SERIALIZABLE = 0x02;
  166   
  167       /**
  168        * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
  169        */
  170       final static byte SC_EXTERNALIZABLE = 0x04;
  171   
  172       /**
  173        * Bit mask for ObjectStreamClass flag. Indicates class is an enum type.
  174        * @since 1.5
  175        */
  176       final static byte SC_ENUM = 0x10;
  177   
  178   
  179       /* *******************************************************************/
  180       /* Security permissions */
  181   
  182       /**
  183        * Enable substitution of one object for another during
  184        * serialization/deserialization.
  185        *
  186        * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
  187        * @see java.io.ObjectInputStream#enableResolveObject(boolean)
  188        * @since 1.2
  189        */
  190       final static SerializablePermission SUBSTITUTION_PERMISSION =
  191                              new SerializablePermission("enableSubstitution");
  192   
  193       /**
  194        * Enable overriding of readObject and writeObject.
  195        *
  196        * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
  197        * @see java.io.ObjectInputStream#readObjectOverride()
  198        * @since 1.2
  199        */
  200       final static SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
  201                       new SerializablePermission("enableSubclassImplementation");
  202      /**
  203       * A Stream Protocol Version. <p>
  204       *
  205       * All externalizable data is written in JDK 1.1 external data
  206       * format after calling this method. This version is needed to write
  207       * streams containing Externalizable data that can be read by
  208       * pre-JDK 1.1.6 JVMs.
  209       *
  210       * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  211       * @since 1.2
  212       */
  213       public final static int PROTOCOL_VERSION_1 = 1;
  214   
  215   
  216      /**
  217       * A Stream Protocol Version. <p>
  218       *
  219       * This protocol is written by JVM 1.2.
  220       *
  221       * Externalizable data is written in block data mode and is
  222       * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
  223       * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can
  224       * read this format change.
  225       *
  226       * Enables writing a nonSerializable class descriptor into the
  227       * stream. The serialVersionUID of a nonSerializable class is
  228       * set to 0L.
  229       *
  230       * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  231       * @see #SC_BLOCK_DATA
  232       * @since 1.2
  233       */
  234       public final static int PROTOCOL_VERSION_2 = 2;
  235   }

Home » openjdk-7 » java » io » [javadoc | source]