jdk/src/share/classes/sun/security/x509/DistributionPointName.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.x509;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.security.util.BitArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.security.util.DerOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.util.DerValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Represents the DistributionPointName ASN.1 type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * It is used in the CRL Distribution Points Extension (OID = 2.5.29.31)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * and the Issuing Distribution Point Extension (OID = 2.5.29.28).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Its ASN.1 definition is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *     DistributionPointName ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *         fullName                  [0] GeneralNames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *         nameRelativeToCRLIssuer   [1] RelativeDistinguishedName }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *     GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *     GeneralName ::= CHOICE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *         otherName                 [0] INSTANCE OF OTHER-NAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *         rfc822Name                [1] IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *         dNSName                   [2] IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *         x400Address               [3] ORAddress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *         directoryName             [4] Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *         ediPartyName              [5] EDIPartyName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *         uniformResourceIdentifier [6] IA5String,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *         iPAddress                 [7] OCTET STRING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *         registeredID              [8] OBJECT IDENTIFIER }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *     RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *     AttributeTypeAndValue ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *         type    AttributeType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *         value   AttributeValue }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *     AttributeType ::= OBJECT IDENTIFIER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *     AttributeValue ::= ANY DEFINED BY AttributeType
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * Instances of this class are designed to be immutable. However, since this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * is an internal API we do not use defensive cloning for values for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * performance reasons. It is the responsibility of the consumer to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * that no mutable elements are modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @see CRLDistributionPointsExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @see IssuingDistributionPointExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
public class DistributionPointName {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    // ASN.1 context specific tag values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private static final byte TAG_FULL_NAME = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private static final byte TAG_RELATIVE_NAME = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    // Only one of fullName and relativeName can be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private GeneralNames fullName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private RDN relativeName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    // Cached hashCode value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private volatile int hashCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Creates a distribution point name using a full name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param fullName the name for the distribution point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @exception IllegalArgumentException if <code>fullName</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public DistributionPointName(GeneralNames fullName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (fullName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            throw new IllegalArgumentException("fullName must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        this.fullName = fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Creates a distribution point name using a relative name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param relativeName the name of the distribution point relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *        the name of the issuer of the CRL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @exception IllegalArgumentException if <code>relativeName</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public DistributionPointName(RDN relativeName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (relativeName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            throw new IllegalArgumentException("relativeName must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        this.relativeName = relativeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Creates a distribution point name from its DER-encoded form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param encoding the DER-encoded value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @throws IOException on decoding error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public DistributionPointName(DerValue encoding) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (encoding.isContextSpecific(TAG_FULL_NAME) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            encoding.isConstructed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            encoding.resetTag(DerValue.tag_Sequence);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            fullName = new GeneralNames(encoding);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        } else if (encoding.isContextSpecific(TAG_RELATIVE_NAME) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            encoding.isConstructed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            encoding.resetTag(DerValue.tag_Set);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            relativeName = new RDN(encoding);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            throw new IOException("Invalid encoding for DistributionPointName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Returns the full name for the distribution point or null if not set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public GeneralNames getFullName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        return fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Returns the relative name for the distribution point or null if not set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public RDN getRelativeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return relativeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Encodes the distribution point name and writes it to the DerOutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param out the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @exception IOException on encoding error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public void encode(DerOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        DerOutputStream theChoice = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (fullName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            fullName.encode(theChoice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            out.writeImplicit(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                DerValue.createTag(DerValue.TAG_CONTEXT, true, TAG_FULL_NAME),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                theChoice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            relativeName.encode(theChoice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            out.writeImplicit(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                DerValue.createTag(DerValue.TAG_CONTEXT, true,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    TAG_RELATIVE_NAME),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                theChoice);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Compare an object to this distribution point name for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param obj Object to be compared to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @return true if objects match; false otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (this == obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if (obj instanceof DistributionPointName == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        DistributionPointName other = (DistributionPointName)obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return equals(this.fullName, other.fullName) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
               equals(this.relativeName, other.relativeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Returns the hash code for this distribution point name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @return the hash code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        int hash = hashCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (hash == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            hash = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            if (fullName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                hash += fullName.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                hash += relativeName.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            hashCode = hash;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return hash;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Returns a printable string of the distribution point name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        if (fullName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            sb.append("DistributionPointName:\n     " + fullName + "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            sb.append("DistributionPointName:\n     " + relativeName + "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Utility function for a.equals(b) where both a and b may be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    private static boolean equals(Object a, Object b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return (a == null) ? (b == null) : a.equals(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}