jaxp/src/org/xml/sax/ext/Attributes2Impl.java
author henryjen
Thu, 19 Jun 2014 15:35:10 -0700
changeset 25262 1fe892ba017a
parent 12457 c348e06f0e82
permissions -rw-r--r--
8047723: @since tag cleanup in jaxp Reviewed-by: joehw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     2
 * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    10
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * accompanied this code).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
 * questions.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    24
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    26
// Attributes2Impl.java - extended AttributesImpl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    27
// http://www.saxproject.org
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    28
// Public Domain: no warranty.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    29
// $Id: Attributes2Impl.java,v 1.3 2005/02/24 11:20:18 gg156739 Exp $
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    30
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    31
package org.xml.sax.ext;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    32
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    33
import org.xml.sax.Attributes;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    34
import org.xml.sax.helpers.AttributesImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    35
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    36
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    37
/**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
 * SAX2 extension helper for additional Attributes information,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
 * implementing the {@link Attributes2} interface.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    40
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
 * <blockquote>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
 * <em>This module, both source code and documentation, is in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
 * </blockquote>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
 * <p>This is not part of core-only SAX2 distributions.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
 * <p>The <em>specified</em> flag for each attribute will always
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
 * be true, unless it has been set to false in the copy constructor
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
 * or using {@link #setSpecified}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
 * Similarly, the <em>declared</em> flag for each attribute will
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
 * always be false, except for defaulted attributes (<em>specified</em>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
 * is false), non-CDATA attributes, or when it is set to true using
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    54
 * {@link #setDeclared}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    55
 * If you change an attribute's type by hand, you may need to modify
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
 * its <em>declared</em> flag to match.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
 * </p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    58
 *
25262
1fe892ba017a 8047723: @since tag cleanup in jaxp
henryjen
parents: 12457
diff changeset
    59
 * @since 1.5, SAX 2.0 (extensions 1.1 alpha)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    60
 * @author David Brownell
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
public class Attributes2Impl extends AttributesImpl implements Attributes2
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    63
{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
    private boolean     declared [];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    65
    private boolean     specified [];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    66
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
     * Construct a new, empty Attributes2Impl object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
    public Attributes2Impl () {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
        specified = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
        declared = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    75
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
     * Copy an existing Attributes or Attributes2 object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
     * If the object implements Attributes2, values of the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
     * <em>specified</em> and <em>declared</em> flags for each
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
     * attribute are copied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
     * Otherwise the flag values are defaulted to assume no DTD was used,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
     * unless there is evidence to the contrary (such as attributes with
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
     * type other than CDATA, which must have been <em>declared</em>).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    86
     * <p>This constructor is especially useful inside a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
     * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    89
     * @param atts The existing Attributes object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    91
    public Attributes2Impl (Attributes atts)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    92
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    93
        super (atts);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    94
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    95
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    96
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    97
    ////////////////////////////////////////////////////////////////////
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
    // Implementation of Attributes2
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    ////////////////////////////////////////////////////////////////////
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
     * Returns the current value of the attribute's "declared" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
    // javadoc mostly from interface
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
    public boolean isDeclared (int index)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   108
        if (index < 0 || index >= getLength ())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   109
            throw new ArrayIndexOutOfBoundsException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   110
                "No attribute at index: " + index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
        return declared [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
     * Returns the current value of the attribute's "declared" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
    // javadoc mostly from interface
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
    public boolean isDeclared (String uri, String localName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
        int index = getIndex (uri, localName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
        if (index < 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
            throw new IllegalArgumentException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
                "No such attribute: local=" + localName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
                + ", namespace=" + uri);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
        return declared [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   132
     * Returns the current value of the attribute's "declared" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   134
    // javadoc mostly from interface
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   135
    public boolean isDeclared (String qName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   136
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
        int index = getIndex (qName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   139
        if (index < 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
            throw new IllegalArgumentException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
                "No such attribute: " + qName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
        return declared [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   143
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   146
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
     * Returns the current value of an attribute's "specified" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
     * @param index The attribute index (zero-based).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
     * @return current flag value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
     * @exception java.lang.ArrayIndexOutOfBoundsException When the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
     *            supplied index does not identify an attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
    public boolean isSpecified (int index)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
        if (index < 0 || index >= getLength ())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
            throw new ArrayIndexOutOfBoundsException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
                "No attribute at index: " + index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
        return specified [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   164
     * Returns the current value of an attribute's "specified" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
     * @param uri The Namespace URI, or the empty string if
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
     *        the name has no Namespace URI.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
     * @param localName The attribute's local name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
     * @return current flag value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
     * @exception java.lang.IllegalArgumentException When the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
     *            supplied names do not identify an attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
    public boolean isSpecified (String uri, String localName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
        int index = getIndex (uri, localName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
        if (index < 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
            throw new IllegalArgumentException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
                "No such attribute: local=" + localName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
                + ", namespace=" + uri);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
        return specified [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
     * Returns the current value of an attribute's "specified" flag.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
     * @param qName The XML qualified (prefixed) name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
     * @return current flag value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
     * @exception java.lang.IllegalArgumentException When the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
     *            supplied name does not identify an attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
    public boolean isSpecified (String qName)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
        int index = getIndex (qName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
        if (index < 0)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
            throw new IllegalArgumentException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
                "No such attribute: " + qName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
        return specified [index];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   201
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   203
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
    ////////////////////////////////////////////////////////////////////
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
    // Manipulators
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
    ////////////////////////////////////////////////////////////////////
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   210
     * Copy an entire Attributes object.  The "specified" flags are
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
     * assigned as true, and "declared" flags as false (except when
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
     * an attribute's type is not CDATA),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
     * unless the object is an Attributes2 object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
     * In that case those flag values are all copied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
     * @see AttributesImpl#setAttributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   217
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
    public void setAttributes (Attributes atts)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   219
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   220
        int length = atts.getLength ();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   221
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
        super.setAttributes (atts);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
        declared = new boolean [length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
        specified = new boolean [length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   225
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   226
        if (atts instanceof Attributes2) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   227
            Attributes2 a2 = (Attributes2) atts;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   228
            for (int i = 0; i < length; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   229
                declared [i] = a2.isDeclared (i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
                specified [i] = a2.isSpecified (i);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
        } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   233
            for (int i = 0; i < length; i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   234
                declared [i] = !"CDATA".equals (atts.getType (i));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   235
                specified [i] = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   236
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   237
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   238
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   239
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   240
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   241
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   242
     * Add an attribute to the end of the list, setting its
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   243
     * "specified" flag to true.  To set that flag's value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   244
     * to false, use {@link #setSpecified}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   245
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   246
     * <p>Unless the attribute <em>type</em> is CDATA, this attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   247
     * is marked as being declared in the DTD.  To set that flag's value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   248
     * to true for CDATA attributes, use {@link #setDeclared}.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   249
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   250
     * @see AttributesImpl#addAttribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   251
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   252
    public void addAttribute (String uri, String localName, String qName,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   253
                              String type, String value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   254
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   255
        super.addAttribute (uri, localName, qName, type, value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   256
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   257
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   258
        int length = getLength ();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   259
        if(specified==null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   260
        {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   261
            specified = new boolean[length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   262
            declared = new boolean[length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   263
        } else if (length > specified.length) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   264
            boolean     newFlags [];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   265
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   266
            newFlags = new boolean [length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   267
            System.arraycopy (declared, 0, newFlags, 0, declared.length);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   268
            declared = newFlags;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   269
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   270
            newFlags = new boolean [length];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   271
            System.arraycopy (specified, 0, newFlags, 0, specified.length);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   272
            specified = newFlags;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   273
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   274
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   275
        specified [length - 1] = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   276
        declared [length - 1] = !"CDATA".equals (type);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   277
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   278
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   279
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   280
    // javadoc entirely from superclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   281
    public void removeAttribute (int index)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   282
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   283
        int origMax = getLength () - 1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   284
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   285
        super.removeAttribute (index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   286
        if (index != origMax) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   287
            System.arraycopy (declared, index + 1, declared, index,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   288
                    origMax - index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   289
            System.arraycopy (specified, index + 1, specified, index,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   290
                    origMax - index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   291
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
     * Assign a value to the "declared" flag of a specific attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
     * This is normally needed only for attributes of type CDATA,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   298
     * including attributes whose type is changed to or from CDATA.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   300
     * @param index The index of the attribute (zero-based).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   301
     * @param value The desired flag value.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
     * @exception java.lang.ArrayIndexOutOfBoundsException When the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
     *            supplied index does not identify an attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
     * @see #setType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
    public void setDeclared (int index, boolean value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   307
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
        if (index < 0 || index >= getLength ())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   309
            throw new ArrayIndexOutOfBoundsException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
                "No attribute at index: " + index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   311
        declared [index] = value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   312
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   313
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   314
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   316
     * Assign a value to the "specified" flag of a specific attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
     * This is the only way this flag can be cleared, except clearing
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
     * by initialization with the copy constructor.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
     * @param index The index of the attribute (zero-based).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
     * @param value The desired flag value.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
     * @exception java.lang.ArrayIndexOutOfBoundsException When the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   323
     *            supplied index does not identify an attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   325
    public void setSpecified (int index, boolean value)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   326
    {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   327
        if (index < 0 || index >= getLength ())
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   328
            throw new ArrayIndexOutOfBoundsException (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   329
                "No attribute at index: " + index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   330
        specified [index] = value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   331
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
}