Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12ff3716 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add AttributeSet.getAttributeNamespace().

Why not.

Bug: 73101753
Test: Build and booted
Change-Id: I8f712ce9d7ed06eceef04d50a733a9471429b94c
parent 4945e8e3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44903,6 +44903,7 @@ package android.util {
    method public abstract int getAttributeListValue(int, java.lang.String[], int);
    method public abstract java.lang.String getAttributeName(int);
    method public abstract int getAttributeNameResource(int);
    method public default java.lang.String getAttributeNamespace(int);
    method public abstract int getAttributeResourceValue(java.lang.String, java.lang.String, int);
    method public abstract int getAttributeResourceValue(int, int);
    method public abstract int getAttributeUnsignedIntValue(java.lang.String, java.lang.String, int);
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import org.xmlpull.v1.XmlPullParser;
 * it is done reading the resource.
 */
public interface XmlResourceParser extends XmlPullParser, AttributeSet, AutoCloseable {
    String getAttributeNamespace (int index);

    /**
     * Close this parser. Calls on the interface are no longer valid after this call.
     */
+28 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.util;


import org.xmlpull.v1.XmlPullParser;

/**
 * A collection of attributes, as found associated with a tag in an XML
 * document.  Often you will not want to use this interface directly, instead
@@ -54,18 +56,42 @@ package android.util;
 * compiled XML resource that is not available in a normal XML file, such
 * as {@link #getAttributeNameResource(int)} which returns the resource
 * identifier associated with a particular XML attribute name.
 *
 * @see XmlPullParser
 */
public interface AttributeSet {
    /**
     * Returns the number of attributes available in the set.
     *
     * <p>See also {@link XmlPullParser#getAttributeCount XmlPullParser.getAttributeCount()},
     * which this method corresponds to when parsing a compiled XML file.</p>
     *
     * @return A positive integer, or 0 if the set is empty.
     */
    public int getAttributeCount();

    /**
     * Returns the namespace of the specified attribute.
     *
     * <p>See also {@link XmlPullParser#getAttributeNamespace XmlPullParser.getAttributeNamespace()},
     * which this method corresponds to when parsing a compiled XML file.</p>
     *
     * @param index Index of the desired attribute, 0...count-1.
     *
     * @return A String containing the namespace of the attribute, or null if th
     *         attribute cannot be found.
     */
    default String getAttributeNamespace (int index) {
        // This is a new method since the first interface definition, so add stub impl.
        return null;
    }

    /**
     * Returns the name of the specified attribute.
     *
     * <p>See also {@link XmlPullParser#getAttributeName XmlPullParser.getAttributeName()},
     * which this method corresponds to when parsing a compiled XML file.</p>
     *
     * @param index Index of the desired attribute, 0...count-1.
     * 
     * @return A String containing the name of the attribute, or null if the
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ class XmlPullAttributes implements AttributeSet {
        return mParser.getAttributeCount();
    }

    public String getAttributeNamespace (int index) {
        return mParser.getAttributeNamespace(index);
    }

    public String getAttributeName(int index) {
        return mParser.getAttributeName(index);
    }