langtools/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java
author ksrini
Fri, 01 Jul 2011 13:34:37 -0700
changeset 10190 11c701650189
parent 5520 86e4b9a9da40
child 14260 727a84636f12
permissions -rw-r--r--
6735320: StringIndexOutOfBoundsException for empty @serialField tag Reviewed-by: jjg, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
10190
11c701650189 6735320: StringIndexOutOfBoundsException for empty @serialField tag
ksrini
parents: 5520
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javadoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * Documents a Serializable field defined by an ObjectStreamField.
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * The class parses and stores the three serialField tag parameters:
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * - field name
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * - field type name
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *      (fully-qualified or visible from the current import context)
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * - description of the valid values for the field
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * This tag is only allowed in the javadoc for the special member
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * serialPersistentFields.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Joe Fialli
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Neal Gafter
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @see java.io.ObjectStreamField
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
class SerialFieldTagImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    extends TagImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    implements SerialFieldTag, Comparable<Object>
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    //### These could be final, except that the constructor
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    //### does not set them directly.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    private String fieldName;    // Required Argument 1 of serialField
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    private String fieldType;    // Required Argument 2 of serialField
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    private String description;  // Optional Remaining Arguments of serialField
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    private ClassDoc containingClass;   // Class containing serialPersistentField member
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    private ClassDoc fieldTypeDoc;      // ClassDocImpl of fieldType
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    private FieldDocImpl matchingField; // FieldDocImpl with same name as fieldName
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
   /* Constructor. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
   SerialFieldTagImpl(DocImpl holder, String name, String text) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        super(holder, name, text);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        parseSerialFieldString();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        if (holder instanceof MemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
            containingClass = ((MemberDocImpl)holder).containingClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /*
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * The serialField tag is composed of three entities.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     *   serialField  serializableFieldName serisliableFieldType
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *                 description of field.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * The fieldName and fieldType must be legal Java Identifiers.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    private void parseSerialFieldString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        int len = text.length();
10190
11c701650189 6735320: StringIndexOutOfBoundsException for empty @serialField tag
ksrini
parents: 5520
diff changeset
    83
        if (len == 0) {
11c701650189 6735320: StringIndexOutOfBoundsException for empty @serialField tag
ksrini
parents: 5520
diff changeset
    84
            return;
11c701650189 6735320: StringIndexOutOfBoundsException for empty @serialField tag
ksrini
parents: 5520
diff changeset
    85
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        // if no white space found
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        /* Skip white space. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        int inx = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        int cp;
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        for (; inx < len; inx += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
             cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
             if (!Character.isWhitespace(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                 break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
             }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        /* find first word. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        int first = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        int last = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        if (! Character.isJavaIdentifierStart(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
            docenv().warning(holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                             "tag.serialField.illegal_character",
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                             new String(Character.toChars(cp)), text);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        for (inx += Character.charCount(cp); inx < len; inx += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
             cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
             if (!Character.isJavaIdentifierPart(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                 break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
             }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        if (inx < len && ! Character.isWhitespace(cp = text.codePointAt(inx))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
            docenv().warning(holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                             "tag.serialField.illegal_character",
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                             new String(Character.toChars(cp)), text);
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        last = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        fieldName = text.substring(first, last);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        /* Skip white space. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        for (; inx < len; inx += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
             cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
             if (!Character.isWhitespace(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
                 break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
             }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        /* find second word. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        first = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        last = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        for (; inx < len; inx += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
             cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
             if (Character.isWhitespace(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                 break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
             }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        if (inx < len && ! Character.isWhitespace(cp = text.codePointAt(inx))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
            docenv().warning(holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                             "tag.serialField.illegal_character",
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                             new String(Character.toChars(cp)), text);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        last = inx;
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        fieldType = text.substring(first, last);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        /* Skip leading white space. Rest of string is description for serialField.*/
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        for (; inx < len; inx += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
             cp = text.codePointAt(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
             if (!Character.isWhitespace(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
                 break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
             }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        description = text.substring(inx);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * return a key for sorting.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    String key() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        return fieldName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    /*
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * Optional. Link this serialField tag to its corrsponding
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * field in the class. Note: there is no requirement that
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * there be a field in the class that matches serialField tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    void mapToFieldDocImpl(FieldDocImpl fd) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        matchingField = fd;
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     * Return the serialziable field name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    public String fieldName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        return fieldName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * Return the field type string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    public String fieldType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        return fieldType;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * Return the ClassDocImpl for field type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * @returns null if no ClassDocImpl for field type is visible from
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     *          containingClass context.
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    public ClassDoc fieldTypeDoc() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        if (fieldTypeDoc == null && containingClass != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            fieldTypeDoc = containingClass.findClass(fieldType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        return fieldTypeDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     * Return the corresponding FieldDocImpl for this SerialFieldTagImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * @returns null if no matching FieldDocImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    FieldDocImpl getMatchingField() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        return matchingField;
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * Return the field comment. If there is no serialField comment, return
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     * javadoc comment of corresponding FieldDocImpl.
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    public String description() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        if (description.length() == 0 && matchingField != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
            //check for javadoc comment of corresponding field.
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
            Comment comment = matchingField.comment();
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            if (comment != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                return comment.commentText();
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        return description;
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     * Return the kind of this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    public String kind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        return "@serialField";
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * Convert this object to a string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    public String toString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        return name + ":" + text;
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * Compares this Object with the specified Object for order.  Returns a
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * negative integer, zero, or a positive integer as this Object is less
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     * than, equal to, or greater than the given Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * Included to make SerialFieldTagImpl items java.lang.Comparable.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * @param   obj the <code>Object</code> to be compared.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @return  a negative integer, zero, or a positive integer as this Object
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     *          is less than, equal to, or greater than the given Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     * @exception ClassCastException the specified Object's type prevents it
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     *            from being compared to this Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    public int compareTo(Object obj) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        return key().compareTo(((SerialFieldTagImpl)obj).key());
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
}