< prev index next >

src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java

Print this page




  48 import java.lang.reflect.Proxy;
  49 import java.lang.reflect.InvocationTargetException;
  50 
  51 import java.io.IOException;
  52 import java.io.DataOutputStream;
  53 import java.io.ByteArrayOutputStream;
  54 import java.io.InvalidClassException;
  55 import java.io.Externalizable;
  56 import java.io.Serializable;
  57 
  58 import java.util.Arrays;
  59 import java.util.Comparator;
  60 
  61 import com.sun.corba.se.impl.util.RepositoryId;
  62 
  63 import org.omg.CORBA.ValueMember;
  64 
  65 import sun.corba.Bridge;
  66 
  67 /**
  68  * A ObjectStreamClass describes a class that can be serialized to a stream
  69  * or a class that was serialized to a stream.  It contains the name
  70  * and the serialVersionUID of the class.
  71  * <br>
  72  * The ObjectStreamClass for a specific class loaded in this Java VM can
  73  * be found using the lookup method.
  74  *
  75  * @author  Roger Riggs
  76  * @since   JDK1.1
  77  */
  78 public class ObjectStreamClass implements java.io.Serializable {
  79     private static final boolean DEBUG_SVUID = false ;
  80 
  81     public static final long kDefaultUID = -1;
  82 
  83     private static Object noArgsList[] = {};
  84     private static Class<?> noTypesList[] = {};
  85 
  86     /** true if represents enum type */
  87     private boolean isEnum;
  88 


 771                 }
 772             }
 773         }
 774 
 775         /* Set up field data for use while reading from the input stream. */
 776         computeFieldInfo();
 777 
 778         /* Remember the class this represents */
 779         ofClass = cl;
 780 
 781         /* get the cache of these methods from the local class
 782          * implementation.
 783          */
 784         readObjectMethod = localClassDesc.readObjectMethod;
 785         readResolveObjectMethod = localClassDesc.readResolveObjectMethod;
 786     }
 787 
 788     /* Compare the base class names of streamName and localName.
 789      *
 790      * @return  Return true iff the base class name compare.
 791      * @parameter streamName    Fully qualified class name.
 792      * @parameter localName     Fully qualified class name.
 793      * @parameter pkgSeparator  class names use either '.' or '/'.
 794      *
 795      * Only compare base class name to allow package renaming.
 796      */
 797     static boolean compareClassNames(String streamName,
 798                                      String localName,
 799                                      char pkgSeparator) {
 800         /* compare the class names, stripping off package names. */
 801         int streamNameIndex = streamName.lastIndexOf(pkgSeparator);
 802         if (streamNameIndex < 0)
 803             streamNameIndex = 0;
 804 
 805         int localNameIndex = localName.lastIndexOf(pkgSeparator);
 806         if (localNameIndex < 0)
 807             localNameIndex = 0;
 808 
 809         return streamName.regionMatches(false, streamNameIndex,
 810                                         localName, localNameIndex,
 811                                         streamName.length() - streamNameIndex);
 812     }
 813 




  48 import java.lang.reflect.Proxy;
  49 import java.lang.reflect.InvocationTargetException;
  50 
  51 import java.io.IOException;
  52 import java.io.DataOutputStream;
  53 import java.io.ByteArrayOutputStream;
  54 import java.io.InvalidClassException;
  55 import java.io.Externalizable;
  56 import java.io.Serializable;
  57 
  58 import java.util.Arrays;
  59 import java.util.Comparator;
  60 
  61 import com.sun.corba.se.impl.util.RepositoryId;
  62 
  63 import org.omg.CORBA.ValueMember;
  64 
  65 import sun.corba.Bridge;
  66 
  67 /**
  68  * An ObjectStreamClass describes a class that can be serialized to a stream
  69  * or a class that was serialized to a stream.  It contains the name
  70  * and the serialVersionUID of the class.
  71  * <br>
  72  * The ObjectStreamClass for a specific class loaded in this Java VM can
  73  * be found using the lookup method.
  74  *
  75  * @author  Roger Riggs
  76  * @since   JDK1.1
  77  */
  78 public class ObjectStreamClass implements java.io.Serializable {
  79     private static final boolean DEBUG_SVUID = false ;
  80 
  81     public static final long kDefaultUID = -1;
  82 
  83     private static Object noArgsList[] = {};
  84     private static Class<?> noTypesList[] = {};
  85 
  86     /** true if represents enum type */
  87     private boolean isEnum;
  88 


 771                 }
 772             }
 773         }
 774 
 775         /* Set up field data for use while reading from the input stream. */
 776         computeFieldInfo();
 777 
 778         /* Remember the class this represents */
 779         ofClass = cl;
 780 
 781         /* get the cache of these methods from the local class
 782          * implementation.
 783          */
 784         readObjectMethod = localClassDesc.readObjectMethod;
 785         readResolveObjectMethod = localClassDesc.readResolveObjectMethod;
 786     }
 787 
 788     /* Compare the base class names of streamName and localName.
 789      *
 790      * @return  Return true iff the base class name compare.
 791      * @param streamName    Fully qualified class name.
 792      * @param localName     Fully qualified class name.
 793      * @param pkgSeparator  class names use either '.' or '/'.
 794      *
 795      * Only compare base class name to allow package renaming.
 796      */
 797     static boolean compareClassNames(String streamName,
 798                                      String localName,
 799                                      char pkgSeparator) {
 800         /* compare the class names, stripping off package names. */
 801         int streamNameIndex = streamName.lastIndexOf(pkgSeparator);
 802         if (streamNameIndex < 0)
 803             streamNameIndex = 0;
 804 
 805         int localNameIndex = localName.lastIndexOf(pkgSeparator);
 806         if (localNameIndex < 0)
 807             localNameIndex = 0;
 808 
 809         return streamName.regionMatches(false, streamNameIndex,
 810                                         localName, localNameIndex,
 811                                         streamName.length() - streamNameIndex);
 812     }
 813 


< prev index next >