模块  java.xml
软件包  org.xml.sax.helpers

Class AttributeListImpl

  • 实现的所有接口
    AttributeList

    @Deprecated(since="1.5")
    public class AttributeListImpl
    extends Object
    implements AttributeList
    Deprecated.
    This class implements a deprecated interface, AttributeList; that interface has been replaced by Attributes, which is implemented in the AttributesImpl helper class.
    AttributeList的默认实现。
    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.

    AttributeList实现了不推荐使用的SAX1 AttributeList接口,并已被新的SAX2 AttributesImpl接口取代。

    该类提供了SAX AttributeList接口的便捷实现。 此实现对于SAX解析器编写者(可以使用它为应用程序提供属性)以及SAX应用程序编写者都很有用,SAX应用程序编写者可以使用它来创建元素属性规范的持久副本:

      private AttributeList myatts;
    
     public void startElement (String name, AttributeList atts)
     {
                  // create a persistent copy of the attribute list
                  // for use outside this method
       myatts = new AttributeListImpl(atts);
       [...]
     } 

    请注意,SAX解析器不需要使用此类来提供AttributeList的实现; 它仅作为可选的便利提供。 特别是,鼓励解析器编写者发明更有效的实现。

    从以下版本开始:
    1.4,SAX 1.0
    另请参见:
    AttributeListDocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)
    • 方法详细信息

      • setAttributeList

        public void setAttributeList​(AttributeList atts)
        Deprecated.
        设置属性列表,丢弃以前的内容。

        此方法允许应用程序编写者轻松地重用属性列表。

        参数
        atts - 要复制的属性列表。
      • removeAttribute

        public void removeAttribute​(String name)
        Deprecated.
        从列表中删除属性。

        SAX应用程序编写者可以使用此方法从AttributeList中过滤属性。 请注意,调用此方法将更改属性列表的长度和某些属性的索引。

        如果请求的属性不在列表中,则这是无操作。

        参数
        name - 属性名称。
        另请参见:
        addAttribute(java.lang.String, java.lang.String, java.lang.String)
      • clear

        public void clear()
        Deprecated.
        清除属性列表。

        SAX解析器编写器可以使用此方法重置DocumentHandler.startElement事件之间的属性列表。 通常,重用相同的AttributeListImpl对象而不是每次都分配一个新对象是有意义的。

        另请参见:
        DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)
      • getName

        public String getName​(int i)
        Deprecated.
        获取属性的名称(按位置)。
        Specified by:
        getName接口 AttributeList
        参数
        i - 列表中属性的位置。
        结果
        属性名称为字符串,如果该位置没有属性,则为null。
        另请参见:
        AttributeList.getName(int)
      • getType

        public String getType​(int i)
        Deprecated.
        获取属性的类型(按位置)。
        Specified by:
        getType接口 AttributeList
        参数
        i - 列表中属性的位置。
        结果
        属性类型为字符串(枚举为“NMTOKEN”,如果未读取任何声明,则为“CDATA”),如果该位置没有属性,则为null。
        另请参见:
        AttributeList.getType(int)
      • getValue

        public String getValue​(int i)
        Deprecated.
        获取属性的值(按位置)。
        Specified by:
        getValue接口 AttributeList
        参数
        i - 列表中属性的位置。
        结果
        属性值为字符串,如果该位置没有属性,则为null。
        另请参见:
        AttributeList.getValue(int)