jaxp/src/share/classes/org/xml/sax/ext/Attributes2.java
changeset 6 7f561c08de6b
equal deleted inserted replaced
0:fd16c54261b3 6:7f561c08de6b
       
     1 /*
       
     2  * Copyright 2004-2005 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 // Attributes2.java - extended Attributes
       
    27 // http://www.saxproject.org
       
    28 // Public Domain: no warranty.
       
    29 // $Id: Attributes2.java,v 1.2 2004/11/03 22:49:07 jsuttor Exp $
       
    30 
       
    31 package org.xml.sax.ext;
       
    32 
       
    33 import org.xml.sax.Attributes;
       
    34 
       
    35 
       
    36 /**
       
    37  * SAX2 extension to augment the per-attribute information
       
    38  * provided though {@link Attributes}.
       
    39  * If an implementation supports this extension, the attributes
       
    40  * provided in {@link org.xml.sax.ContentHandler#startElement
       
    41  * ContentHandler.startElement() } will implement this interface,
       
    42  * and the <em>http://xml.org/sax/features/use-attributes2</em>
       
    43  * feature flag will have the value <em>true</em>.
       
    44  *
       
    45  * <blockquote>
       
    46  * <em>This module, both source code and documentation, is in the
       
    47  * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
       
    48  * </blockquote>
       
    49  *
       
    50  * <p> XMLReader implementations are not required to support this
       
    51  * information, and it is not part of core-only SAX2 distributions.</p>
       
    52  *
       
    53  * <p>Note that if an attribute was defaulted (<em>!isSpecified()</em>)
       
    54  * it will of necessity also have been declared (<em>isDeclared()</em>)
       
    55  * in the DTD.
       
    56  * Similarly if an attribute's type is anything except CDATA, then it
       
    57  * must have been declared.
       
    58  * </p>
       
    59  *
       
    60  * @since SAX 2.0 (extensions 1.1 alpha)
       
    61  * @author David Brownell
       
    62  */
       
    63 public interface Attributes2 extends Attributes
       
    64 {
       
    65     /**
       
    66      * Returns false unless the attribute was declared in the DTD.
       
    67      * This helps distinguish two kinds of attributes that SAX reports
       
    68      * as CDATA:  ones that were declared (and hence are usually valid),
       
    69      * and those that were not (and which are never valid).
       
    70      *
       
    71      * @param index The attribute index (zero-based).
       
    72      * @return true if the attribute was declared in the DTD,
       
    73      *          false otherwise.
       
    74      * @exception java.lang.ArrayIndexOutOfBoundsException When the
       
    75      *            supplied index does not identify an attribute.
       
    76      */
       
    77     public boolean isDeclared (int index);
       
    78 
       
    79     /**
       
    80      * Returns false unless the attribute was declared in the DTD.
       
    81      * This helps distinguish two kinds of attributes that SAX reports
       
    82      * as CDATA:  ones that were declared (and hence are usually valid),
       
    83      * and those that were not (and which are never valid).
       
    84      *
       
    85      * @param qName The XML qualified (prefixed) name.
       
    86      * @return true if the attribute was declared in the DTD,
       
    87      *          false otherwise.
       
    88      * @exception java.lang.IllegalArgumentException When the
       
    89      *            supplied name does not identify an attribute.
       
    90      */
       
    91     public boolean isDeclared (String qName);
       
    92 
       
    93     /**
       
    94      * Returns false unless the attribute was declared in the DTD.
       
    95      * This helps distinguish two kinds of attributes that SAX reports
       
    96      * as CDATA:  ones that were declared (and hence are usually valid),
       
    97      * and those that were not (and which are never valid).
       
    98      *
       
    99      * <p>Remember that since DTDs do not "understand" namespaces, the
       
   100      * namespace URI associated with an attribute may not have come from
       
   101      * the DTD.  The declaration will have applied to the attribute's
       
   102      * <em>qName</em>.
       
   103      *
       
   104      * @param uri The Namespace URI, or the empty string if
       
   105      *        the name has no Namespace URI.
       
   106      * @param localName The attribute's local name.
       
   107      * @return true if the attribute was declared in the DTD,
       
   108      *          false otherwise.
       
   109      * @exception java.lang.IllegalArgumentException When the
       
   110      *            supplied names do not identify an attribute.
       
   111      */
       
   112     public boolean isDeclared (String uri, String localName);
       
   113 
       
   114     /**
       
   115      * Returns true unless the attribute value was provided
       
   116      * by DTD defaulting.
       
   117      *
       
   118      * @param index The attribute index (zero-based).
       
   119      * @return true if the value was found in the XML text,
       
   120      *          false if the value was provided by DTD defaulting.
       
   121      * @exception java.lang.ArrayIndexOutOfBoundsException When the
       
   122      *            supplied index does not identify an attribute.
       
   123      */
       
   124     public boolean isSpecified (int index);
       
   125 
       
   126     /**
       
   127      * Returns true unless the attribute value was provided
       
   128      * by DTD defaulting.
       
   129      *
       
   130      * <p>Remember that since DTDs do not "understand" namespaces, the
       
   131      * namespace URI associated with an attribute may not have come from
       
   132      * the DTD.  The declaration will have applied to the attribute's
       
   133      * <em>qName</em>.
       
   134      *
       
   135      * @param uri The Namespace URI, or the empty string if
       
   136      *        the name has no Namespace URI.
       
   137      * @param localName The attribute's local name.
       
   138      * @return true if the value was found in the XML text,
       
   139      *          false if the value was provided by DTD defaulting.
       
   140      * @exception java.lang.IllegalArgumentException When the
       
   141      *            supplied names do not identify an attribute.
       
   142      */
       
   143     public boolean isSpecified (String uri, String localName);
       
   144 
       
   145     /**
       
   146      * Returns true unless the attribute value was provided
       
   147      * by DTD defaulting.
       
   148      *
       
   149      * @param qName The XML qualified (prefixed) name.
       
   150      * @return true if the value was found in the XML text,
       
   151      *          false if the value was provided by DTD defaulting.
       
   152      * @exception java.lang.IllegalArgumentException When the
       
   153      *            supplied name does not identify an attribute.
       
   154      */
       
   155     public boolean isSpecified (String qName);
       
   156 }