com.android.manifmerger
Class XmlDocument

java.lang.Object
  extended by com.android.manifmerger.XmlDocument

public class XmlDocument
extends java.lang.Object

Represents a loaded xml document. Has pointers to the root XmlElement element and provides services to persist the document to an external format. Also provides abilities to be merged with other XmlDocument as well as access to the line numbers for all document's xml elements and attributes.


Constructor Summary
XmlDocument(com.android.utils.PositionXmlParser positionXmlParser, XmlLoader.SourceLocation sourceLocation, KeyResolver<java.lang.String> selectors, PlaceholderHandler.KeyBasedValueResolver<ManifestMerger2.SystemProperty> systemPropertyResolver, org.w3c.dom.Element element, com.android.manifmerger.XmlDocument.Type type, com.google.common.base.Optional<java.lang.String> mainManifestPackageName)
           
 
Method Summary
 com.google.common.base.Optional<java.lang.String> compareTo(XmlDocument other)
          Compares this document to another XmlDocument ignoring all attributes belonging to the SdkConstants.TOOLS_URI namespace.
 com.google.common.base.Optional<XmlElement> getByTypeAndKey(com.android.manifmerger.ManifestModel.NodeTypes type, java.lang.String keyValue)
           
 com.android.manifmerger.XmlDocument.Type getFileType()
           
 com.google.common.base.Optional<XmlAttribute> getPackage()
           
 java.lang.String getPackageName()
          Package name for this android manifest which will be used to resolve partial path.
 XmlElement getRootNode()
           
 KeyResolver<java.lang.String> getSelectors()
          Returns a KeyResolver capable of resolving all selectors types
 XmlLoader.SourceLocation getSourceLocation()
           
 PlaceholderHandler.KeyBasedValueResolver<ManifestMerger2.SystemProperty> getSystemPropertyResolver()
          Returns the PlaceholderHandler.KeyBasedValueResolver capable of resolving all injected ManifestMerger2.SystemProperty
 org.w3c.dom.Document getXml()
           
 com.google.common.base.Optional<XmlDocument> merge(XmlDocument lowerPriorityDocument, com.android.manifmerger.MergingReport.Builder mergingReportBuilder)
          merge this higher priority document with a higher priority document.
 java.lang.String prettyPrint()
          Returns a pretty string representation of this document.
 XmlDocument reparse()
          Forces a re-parsing of the document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDocument

public XmlDocument(@NonNull
                   com.android.utils.PositionXmlParser positionXmlParser,
                   @NonNull
                   XmlLoader.SourceLocation sourceLocation,
                   @NonNull
                   KeyResolver<java.lang.String> selectors,
                   @NonNull
                   PlaceholderHandler.KeyBasedValueResolver<ManifestMerger2.SystemProperty> systemPropertyResolver,
                   @NonNull
                   org.w3c.dom.Element element,
                   @NonNull
                   com.android.manifmerger.XmlDocument.Type type,
                   @NonNull
                   com.google.common.base.Optional<java.lang.String> mainManifestPackageName)
Method Detail

getFileType

public com.android.manifmerger.XmlDocument.Type getFileType()

prettyPrint

public java.lang.String prettyPrint()
Returns a pretty string representation of this document.


merge

public com.google.common.base.Optional<XmlDocument> merge(XmlDocument lowerPriorityDocument,
                                                          com.android.manifmerger.MergingReport.Builder mergingReportBuilder)
merge this higher priority document with a higher priority document.

Parameters:
lowerPriorityDocument - the lower priority document to merge in.
mergingReportBuilder - the merging report to record errors and actions.
Returns:
a new merged XmlDocument or Optional.absent() if there were errors during the merging activities.

reparse

public XmlDocument reparse()
Forces a re-parsing of the document

Returns:
a new XmlDocument with up to date information.

getSelectors

public KeyResolver<java.lang.String> getSelectors()
Returns a KeyResolver capable of resolving all selectors types


getSystemPropertyResolver

public PlaceholderHandler.KeyBasedValueResolver<ManifestMerger2.SystemProperty> getSystemPropertyResolver()
Returns the PlaceholderHandler.KeyBasedValueResolver capable of resolving all injected ManifestMerger2.SystemProperty


compareTo

public com.google.common.base.Optional<java.lang.String> compareTo(XmlDocument other)
Compares this document to another XmlDocument ignoring all attributes belonging to the SdkConstants.TOOLS_URI namespace.

Parameters:
other - the other document to compare against.
Returns:
a String describing the differences between the two XML elements or Optional.absent() if they are equals.

getSourceLocation

public XmlLoader.SourceLocation getSourceLocation()

getRootNode

public XmlElement getRootNode()

getByTypeAndKey

public com.google.common.base.Optional<XmlElement> getByTypeAndKey(com.android.manifmerger.ManifestModel.NodeTypes type,
                                                                   @Nullable
                                                                   java.lang.String keyValue)

getPackageName

public java.lang.String getPackageName()
Package name for this android manifest which will be used to resolve partial path. In the case of Overlays, this is absent and the main manifest packageName must be used.

Returns:
the package name to do partial class names resolution.

getPackage

public com.google.common.base.Optional<XmlAttribute> getPackage()

getXml

public org.w3c.dom.Document getXml()