com.android.tools.lint.detector.api
Interface Detector.XmlScanner

All Known Implementing Classes:
LayoutDetector, ResourceXmlDetector
Enclosing class:
Detector

public static interface Detector.XmlScanner

Specialized interface for detectors that scan XML files


Field Summary
static java.util.List<java.lang.String> ALL
          Special marker collection returned by getApplicableElements() or getApplicableAttributes() to indicate that the check should be invoked on all elements or all attributes
 
Method Summary
 java.util.Collection<java.lang.String> getApplicableAttributes()
          Returns the list of attributes that this detector wants to analyze.
 java.util.Collection<java.lang.String> getApplicableElements()
          Returns the list of elements that this detector wants to analyze.
 void visitAttribute(XmlContext context, org.w3c.dom.Attr attribute)
          Visit the given attribute.
 void visitDocument(XmlContext context, org.w3c.dom.Document document)
          Visit the given document.
 void visitElement(XmlContext context, org.w3c.dom.Element element)
          Visit the given element.
 void visitElementAfter(XmlContext context, org.w3c.dom.Element element)
          Visit the given element after its children have been analyzed.
 

Field Detail

ALL

@NonNull
static final java.util.List<java.lang.String> ALL
Special marker collection returned by getApplicableElements() or getApplicableAttributes() to indicate that the check should be invoked on all elements or all attributes

Method Detail

visitDocument

void visitDocument(@NonNull
                   XmlContext context,
                   @NonNull
                   org.w3c.dom.Document document)
Visit the given document. The detector is responsible for its own iteration through the document.

Parameters:
context - information about the document being analyzed
document - the document to examine

visitElement

void visitElement(@NonNull
                  XmlContext context,
                  @NonNull
                  org.w3c.dom.Element element)
Visit the given element.

Parameters:
context - information about the document being analyzed
element - the element to examine

visitElementAfter

void visitElementAfter(@NonNull
                       XmlContext context,
                       @NonNull
                       org.w3c.dom.Element element)
Visit the given element after its children have been analyzed.

Parameters:
context - information about the document being analyzed
element - the element to examine

visitAttribute

void visitAttribute(@NonNull
                    XmlContext context,
                    @NonNull
                    org.w3c.dom.Attr attribute)
Visit the given attribute.

Parameters:
context - information about the document being analyzed
attribute - the attribute node to examine

getApplicableElements

@Nullable
java.util.Collection<java.lang.String> getApplicableElements()
Returns the list of elements that this detector wants to analyze. If non null, this detector will be called (specifically, the visitElement(com.android.tools.lint.detector.api.XmlContext, org.w3c.dom.Element) method) for each matching element in the document.

If this method returns null, and getApplicableAttributes() also returns null, then the visitDocument(com.android.tools.lint.detector.api.XmlContext, org.w3c.dom.Document) method will be called instead.

Returns:
a collection of elements, or null, or the special ALL marker to indicate that every single element should be analyzed.

getApplicableAttributes

@Nullable
java.util.Collection<java.lang.String> getApplicableAttributes()
Returns the list of attributes that this detector wants to analyze. If non null, this detector will be called (specifically, the visitAttribute(com.android.tools.lint.detector.api.XmlContext, org.w3c.dom.Attr) method) for each matching attribute in the document.

If this method returns null, and getApplicableElements() also returns null, then the visitDocument(com.android.tools.lint.detector.api.XmlContext, org.w3c.dom.Document) method will be called instead.

Returns:
a collection of attributes, or null, or the special ALL marker to indicate that every single attribute should be analyzed.