src/share/classes/java/io/ObjectStreamField.java

Print this page


   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


 222      */
 223     // REMIND: deprecate?
 224     protected void setOffset(int offset) {
 225         this.offset = offset;
 226     }
 227 
 228     /**
 229      * Return true if this field has a primitive type.
 230      *
 231      * @return  true if and only if this field corresponds to a primitive type
 232      */
 233     // REMIND: deprecate?
 234     public boolean isPrimitive() {
 235         char tcode = signature.charAt(0);
 236         return ((tcode != 'L') && (tcode != '['));
 237     }
 238 
 239     /**
 240      * Returns boolean value indicating whether or not the serializable field
 241      * represented by this ObjectStreamField instance is unshared.


 242      *
 243      * @since 1.4
 244      */
 245     public boolean isUnshared() {
 246         return unshared;
 247     }
 248 
 249     /**
 250      * Compare this field with another <code>ObjectStreamField</code>.  Return
 251      * -1 if this is smaller, 0 if equal, 1 if greater.  Types that are
 252      * primitives are "smaller" than object types.  If equal, the field names
 253      * are compared.
 254      */
 255     // REMIND: deprecate?
 256     public int compareTo(Object obj) {
 257         ObjectStreamField other = (ObjectStreamField) obj;
 258         boolean isPrim = isPrimitive();
 259         if (isPrim != other.isPrimitive()) {
 260             return isPrim ? -1 : 1;
 261         }


   1 /*
   2  * Copyright (c) 1996, 2013, 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


 222      */
 223     // REMIND: deprecate?
 224     protected void setOffset(int offset) {
 225         this.offset = offset;
 226     }
 227 
 228     /**
 229      * Return true if this field has a primitive type.
 230      *
 231      * @return  true if and only if this field corresponds to a primitive type
 232      */
 233     // REMIND: deprecate?
 234     public boolean isPrimitive() {
 235         char tcode = signature.charAt(0);
 236         return ((tcode != 'L') && (tcode != '['));
 237     }
 238 
 239     /**
 240      * Returns boolean value indicating whether or not the serializable field
 241      * represented by this ObjectStreamField instance is unshared.
 242      *
 243      * @return true if this field is unshared
 244      *
 245      * @since 1.4
 246      */
 247     public boolean isUnshared() {
 248         return unshared;
 249     }
 250 
 251     /**
 252      * Compare this field with another <code>ObjectStreamField</code>.  Return
 253      * -1 if this is smaller, 0 if equal, 1 if greater.  Types that are
 254      * primitives are "smaller" than object types.  If equal, the field names
 255      * are compared.
 256      */
 257     // REMIND: deprecate?
 258     public int compareTo(Object obj) {
 259         ObjectStreamField other = (ObjectStreamField) obj;
 260         boolean isPrim = isPrimitive();
 261         if (isPrim != other.isPrimitive()) {
 262             return isPrim ? -1 : 1;
 263         }