AttributeList.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:10k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  * 
  4.  * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  * 
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer. 
  13.  * 
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  * 
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:  
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  * 
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written 
  29.  *    permission, please contact apache@apache.org.
  30.  * 
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  * 
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  * 
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 1999, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Log: AttributeList.hpp,v $
  58.  * Revision 1.8  2000/03/02 19:54:34  roddey
  59.  * This checkin includes many changes done while waiting for the
  60.  * 1.1.0 code to be finished. I can't list them all here, but a list is
  61.  * available elsewhere.
  62.  *
  63.  * Revision 1.7  2000/02/24 20:12:54  abagchi
  64.  * Swat for removing Log from API docs
  65.  *
  66.  * Revision 1.6  2000/02/12 03:31:55  rahulj
  67.  * Removed duplicate CVS Log entries.
  68.  *
  69.  * Revision 1.5  2000/02/12 01:27:19  aruna1
  70.  * Documentation updated
  71.  *
  72.  * Revision 1.4  2000/02/09 02:12:21  abagchi
  73.  * Added getValue docs
  74.  *
  75.  * Revision 1.3  2000/02/06 07:47:57  rahulj
  76.  * Year 2K copyright swat.
  77.  *
  78.  * Revision 1.2  1999/12/15 19:58:31  roddey
  79.  * Added new convenience version of getValue() that takes a short character
  80.  * string for the attribute name.
  81.  *
  82.  * Revision 1.1.1.1  1999/11/09 01:07:43  twl
  83.  * Initial checkin
  84.  *
  85.  * Revision 1.2  1999/11/08 20:44:54  rahul
  86.  * Swat for adding in Product name and CVS comment log variable.
  87.  *
  88.  */
  89. #ifndef ATTRIBUTELIST_HPP
  90. #define ATTRIBUTELIST_HPP
  91. #include <util/XercesDefs.hpp>
  92. /**
  93.   * Interface for an element's attribute specifications.
  94.   *
  95.   * The SAX parser implements this interface and passes an instance
  96.   * to the SAX application as the second argument of each startElement
  97.   * event.
  98.   *
  99.   * The instance provided will return valid results only during the
  100.   * scope of the startElement invocation (to save it for future
  101.   * use, the application must make a copy: the AttributeListImpl
  102.   * helper class provides a convenient constructor for doing so).
  103.   *
  104.   * An AttributeList includes only attributes that have been
  105.   * specified or defaulted: #IMPLIED attributes will not be included.
  106.   *
  107.   * There are two ways for the SAX application to obtain information
  108.   * from the AttributeList.  First, it can iterate through the entire
  109.   * list:
  110.   *
  111.   * <pre>
  112.   * public void startElement (String name, AttributeList atts) {
  113.   *   for (int i = 0; i < atts.getLength(); i++) {
  114.   *     String name = atts.getName(i);
  115.   *     String type = atts.getType(i);
  116.   *     String value = atts.getValue(i);
  117.   *     [...]
  118.   *   }
  119.   * }
  120.   * </pre>
  121.   *
  122.   * (Note that the result of getLength() will be zero if there
  123.   * are no attributes.)
  124.   *
  125.   * As an alternative, the application can request the value or
  126.   * type of specific attributes:
  127.   *
  128.   * <pre>
  129.   * public void startElement (String name, AttributeList atts) {
  130.   *   String identifier = atts.getValue("id");
  131.   *   String label = atts.getValue("label");
  132.   *   [...]
  133.   * }
  134.   * </pre>
  135.   *
  136.   * The AttributeListImpl helper class provides a convenience 
  137.   * implementation for use by parser or application writers.
  138.   *
  139.   * @see DocumentHandler#startElement 
  140.   * @see AttributeListImpl#AttributeListImpl
  141.   */
  142. class SAX_EXPORT AttributeList
  143. {
  144. public:
  145.     // -----------------------------------------------------------------------
  146.     //  Constructors and Destructor
  147.     // -----------------------------------------------------------------------
  148.     /** @name Constructors and Destructor */
  149.     //@{
  150.     /** Default constructor */
  151.     AttributeList()
  152.     {
  153.     }
  154.     /** Destructor */
  155.     virtual ~AttributeList()
  156.     {
  157.     }
  158.     //@}
  159.     /** @name The virtual attribute list interface */
  160.     //@{
  161.   /**
  162.     * Return the number of attributes in this list.
  163.     *
  164.     * The SAX parser may provide attributes in any
  165.     * arbitrary order, regardless of the order in which they were
  166.     * declared or specified.  The number of attributes may be
  167.     * zero.
  168.     *
  169.     * @return The number of attributes in the list.  
  170.     */
  171.     virtual unsigned int getLength() const = 0;
  172.   /**
  173.     * Return the name of an attribute in this list (by position).
  174.     *
  175.     * The names must be unique: the SAX parser shall not include the
  176.     * same attribute twice.  Attributes without values (those declared
  177.     * #IMPLIED without a value specified in the start tag) will be
  178.     * omitted from the list.
  179.     *
  180.     * If the attribute name has a namespace prefix, the prefix
  181.     * will still be attached.
  182.     *
  183.     * @param index The index of the attribute in the list (starting at 0).
  184.     * @return The name of the indexed attribute, or null
  185.     *         if the index is out of range.
  186.     * @see #getLength 
  187.     */
  188.     virtual const XMLCh* getName(const unsigned int index) const = 0;
  189.   /**
  190.     * Return the type of an attribute in the list (by position).
  191.     *
  192.     * The attribute type is one of the strings "CDATA", "ID",
  193.     * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
  194.     * or "NOTATION" (always in upper case).
  195.     *
  196.     * If the parser has not read a declaration for the attribute,
  197.     * or if the parser does not report attribute types, then it must
  198.     * return the value "CDATA" as stated in the XML 1.0 Recommentation
  199.     * (clause 3.3.3, "Attribute-Value Normalization").
  200.     *
  201.     * For an enumerated attribute that is not a notation, the
  202.     * parser will report the type as "NMTOKEN".
  203.     *
  204.     * @param index The index of the attribute in the list (starting at 0).
  205.     * @return The attribute type as a string, or
  206.     *         null if the index is out of range.
  207.     * @see #getLength 
  208.     * @see #getType(String)
  209.     */
  210.     virtual const XMLCh* getType(const unsigned int index) const = 0;
  211.   /**
  212.     * Return the value of an attribute in the list (by position).
  213.     *
  214.     * If the attribute value is a list of tokens (IDREFS,
  215.     * ENTITIES, or NMTOKENS), the tokens will be concatenated
  216.     * into a single string separated by whitespace.
  217.     *
  218.     * @param index The index of the attribute in the list (starting at 0).
  219.     * @return The attribute value as a string, or
  220.     *         null if the index is out of range.
  221.     * @see #getLength
  222.     * @see #getValue(XMLCh*)
  223.     * @see #getValue(char *)
  224.     */
  225.     virtual const XMLCh* getValue(const unsigned int index) const = 0;
  226.   /**
  227.     * Return the type of an attribute in the list (by name).
  228.     *
  229.     * The return value is the same as the return value for
  230.     * getType(int).
  231.     *
  232.     * If the attribute name has a namespace prefix in the document,
  233.     * the application must include the prefix here.
  234.     *
  235.     * @param name The name of the attribute.
  236.     * @return The attribute type as a string, or null if no
  237.     *         such attribute exists.
  238.     * @see #getType(int)
  239.     */
  240.     virtual const XMLCh* getType(const XMLCh* const name) const = 0;
  241.   /**
  242.     * Return the value of an attribute in the list (by name).
  243.     *
  244.     * The return value is the same as the return value for
  245.     * getValue(int).
  246.     *
  247.     * If the attribute name has a namespace prefix in the document,
  248.     * the application must include the prefix here.
  249.     *
  250.     * @param name The name of the attribute in the list.
  251.     * @return The attribute value as a string, or null if
  252.     *         no such attribute exists.
  253.     * @see #getValue(int)
  254.     * @see #getValue(char *)
  255.     */
  256.     virtual const XMLCh* getValue(const XMLCh* const name) const = 0;
  257.   /**
  258.     * Return the value of an attribute in the list (by name).
  259.     *
  260.     * The return value is the same as the return value for
  261.     * getValue(int).
  262.     *
  263.     * If the attribute name has a namespace prefix in the document,
  264.     * the application must include the prefix here.
  265.     *
  266.     * @param name The name of the attribute in the list.
  267.     * @return The attribute value as a string, or null if
  268.     *         no such attribute exists.
  269.     * @see #getValue(int)
  270.     * @see #getValue(XMLCh*)
  271.     */
  272.     virtual const XMLCh* getValue(const char* const name) const = 0;
  273.     //@}
  274. private :
  275.     /* Constructors and operators */
  276.     /* Copy constructor */
  277.     AttributeList(const AttributeList&);
  278.     /* Assignment operator */
  279.     void operator=(const AttributeList&);
  280.     
  281. };
  282. #endif