jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java
changeset 27111 7a491d709b83
parent 25868 686eef1e7a79
child 33349 975138b77cff
equal deleted inserted replaced
26996:a137992d750c 27111:7a491d709b83
     1 /*
     1 /*
     2  * reserved comment block
     2  * reserved comment block
     3  * DO NOT REMOVE OR ALTER!
     3  * DO NOT REMOVE OR ALTER!
     4  */
     4  */
     5 /*
     5 /*
     6  * The Apache Software License, Version 1.1
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
       
     7  * contributor license agreements.  See the NOTICE file distributed with
       
     8  * this work for additional information regarding copyright ownership.
       
     9  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    10  * (the "License"); you may not use this file except in compliance with
       
    11  * the License.  You may obtain a copy of the License at
     7  *
    12  *
       
    13  *      http://www.apache.org/licenses/LICENSE-2.0
     8  *
    14  *
     9  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
    15  * Unless required by applicable law or agreed to in writing, software
    10  * reserved.
    16  * distributed under the License is distributed on an "AS IS" BASIS,
    11  *
    17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  * Redistribution and use in source and binary forms, with or without
    18  * See the License for the specific language governing permissions and
    13  * modification, are permitted provided that the following conditions
    19  * limitations under the License.
    14  * are met:
       
    15  *
       
    16  * 1. Redistributions of source code must retain the above copyright
       
    17  *    notice, this list of conditions and the following disclaimer.
       
    18  *
       
    19  * 2. Redistributions in binary form must reproduce the above copyright
       
    20  *    notice, this list of conditions and the following disclaimer in
       
    21  *    the documentation and/or other materials provided with the
       
    22  *    distribution.
       
    23  *
       
    24  * 3. The end-user documentation included with the redistribution,
       
    25  *    if any, must include the following acknowledgment:
       
    26  *       "This product includes software developed by the
       
    27  *        Apache Software Foundation (http://www.apache.org/)."
       
    28  *    Alternately, this acknowledgment may appear in the software itself,
       
    29  *    if and wherever such third-party acknowledgments normally appear.
       
    30  *
       
    31  * 4. The names "Xerces" and "Apache Software Foundation" must
       
    32  *    not be used to endorse or promote products derived from this
       
    33  *    software without prior written permission. For written
       
    34  *    permission, please contact apache@apache.org.
       
    35  *
       
    36  * 5. Products derived from this software may not be called "Apache",
       
    37  *    nor may "Apache" appear in their name, without prior written
       
    38  *    permission of the Apache Software Foundation.
       
    39  *
       
    40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
       
    41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
       
    42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    43  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
       
    44  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    45  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
       
    46  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
       
    47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
       
    49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
       
    50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    51  * SUCH DAMAGE.
       
    52  * ====================================================================
       
    53  *
       
    54  * This software consists of voluntary contributions made by many
       
    55  * individuals on behalf of the Apache Software Foundation and was
       
    56  * originally based on software copyright (c) 1999, International
       
    57  * Business Machines, Inc., http://www.apache.org.  For more
       
    58  * information on the Apache Software Foundation, please see
       
    59  * <http://www.apache.org/>.
       
    60  */
    20  */
    61 
    21 
    62 package com.sun.org.apache.xerces.internal.util;
    22 package com.sun.org.apache.xerces.internal.util;
    63 
    23 
    64 import com.sun.xml.internal.stream.XMLBufferListener;
    24 import com.sun.xml.internal.stream.XMLBufferListener;
   220     }
   180     }
   221     public int addAttribute(QName name, String type, String value,XMLString valueCache) {
   181     public int addAttribute(QName name, String type, String value,XMLString valueCache) {
   222 
   182 
   223         int index;
   183         int index;
   224         if (fLength < SIZE_LIMIT) {
   184         if (fLength < SIZE_LIMIT) {
   225             index = name.uri != null && !name.uri.equals("")
   185             index = name.uri != null && name.uri.length() != 0
   226                 ? getIndexFast(name.uri, name.localpart)
   186                 ? getIndexFast(name.uri, name.localpart)
   227                 : getIndexFast(name.rawname);
   187                 : getIndexFast(name.rawname);
   228 
   188 
   229             if (index == -1) {
   189             if (index == -1) {
   230                 index = fLength;
   190                 index = fLength;
  1095     public void setURI(int attrIndex, String uri) {
  1055     public void setURI(int attrIndex, String uri) {
  1096         fAttributes[attrIndex].name.uri = uri;
  1056         fAttributes[attrIndex].name.uri = uri;
  1097     } // getURI(int,QName)
  1057     } // getURI(int,QName)
  1098 
  1058 
  1099     // Implementation methods
  1059     // Implementation methods
  1100     public void setSchemaId(int attrIndex, boolean schemaId) {
       
  1101         fAttributes[attrIndex].schemaId = schemaId;
       
  1102     }
       
  1103 
       
  1104     public boolean getSchemaId(int index) {
       
  1105         if (index < 0 || index >= fLength) {
       
  1106             return false;
       
  1107         }
       
  1108         return fAttributes[index].schemaId;
       
  1109     }
       
  1110 
       
  1111     public boolean getSchemaId(String qname) {
       
  1112         int index = getIndex(qname);
       
  1113         return index != -1 ? fAttributes[index].schemaId : false;
       
  1114     } // getType(String):String
       
  1115 
       
  1116     public boolean getSchemaId(String uri, String localName) {
       
  1117         if (!fNamespaces) {
       
  1118             return false;
       
  1119         }
       
  1120         int index = getIndex(uri, localName);
       
  1121         return index != -1 ? fAttributes[index].schemaId : false;
       
  1122     } // getType(String,String):String
       
  1123 
  1060 
  1124     //XMLBufferListener methods
  1061     //XMLBufferListener methods
  1125     /**
  1062     /**
  1126      * This method will be invoked by XMLEntityReader before ScannedEntities buffer
  1063      * This method will be invoked by XMLEntityReader before ScannedEntities buffer
  1127      * is reloaded.
  1064      * is reloaded.
  1152         //
  1089         //
  1153 
  1090 
  1154         // basic info
  1091         // basic info
  1155 
  1092 
  1156         /** Name. */
  1093         /** Name. */
  1157         public QName name = new QName();
  1094         public final QName name = new QName();
  1158 
  1095 
  1159         /** Type. */
  1096         /** Type. */
  1160         public String type;
  1097         public String type;
  1161 
  1098 
  1162         /** Value. */
  1099         /** Value. */
  1169         public String nonNormalizedValue;
  1106         public String nonNormalizedValue;
  1170 
  1107 
  1171         /** Specified. */
  1108         /** Specified. */
  1172         public boolean specified;
  1109         public boolean specified;
  1173 
  1110 
  1174         /** Schema ID type. */
       
  1175         public boolean schemaId;
       
  1176 
  1111 
  1177         /**
  1112         /**
  1178          * Augmentations information for this attribute.
  1113          * Augmentations information for this attribute.
  1179          * XMLAttributes has no knowledge if any augmentations
  1114          * XMLAttributes has no knowledge if any augmentations
  1180          * were attached to Augmentations.
  1115          * were attached to Augmentations.