public class AssetMerger
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected javax.xml.parsers.DocumentBuilderFactory |
mFactory |
| Constructor and Description |
|---|
AssetMerger() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataSet(S resourceSet)
Adds a new
DataSet and overlays it on top of the existing DataSet. |
boolean |
checkValidUpdate(java.util.List<S> dataSets)
Checks that a loaded merger can be updated with a given list of DataSet.
|
void |
cleanBlob(java.io.File blobRootFolder) |
protected void |
createDir(java.io.File folder) |
protected AssetSet |
createFromXml(org.w3c.dom.Node node) |
protected boolean |
filterAccept(I dataItem)
Method that implements data filters.
|
FileValidity<S> |
findDataSetContaining(java.io.File file)
Finds the
DataSet that contains the given file. |
FileValidity<S> |
findDataSetContaining(java.io.File file,
FileValidity<S> fileValidity)
Finds the
DataSet that contains the given file. |
protected java.lang.String |
getAdditionalDataTagName() |
com.google.common.collect.ListMultimap<java.lang.String,I> |
getDataMap()
Returns a map of the data items.
|
java.util.List<S> |
getDataSets()
Returns the list of ResourceSet objects.
|
protected void |
loadAdditionalData(org.w3c.dom.Node additionalDataNode,
boolean incrementalState) |
boolean |
loadFromBlob(java.io.File blobRootFolder,
boolean incrementalState)
Loads the merger state from a blob file.
|
void |
mergeData(MergeConsumer<I> consumer,
boolean doCleanUp)
Merges the data into a given consumer.
|
protected void |
mergeItems(java.lang.String dataItemKey,
java.util.List<com.android.ide.common.resources.AssetItem> items,
MergeConsumer<com.android.ide.common.resources.AssetItem> consumer)
Merge items together, and register the merged items with the given consumer.
|
protected boolean |
requiresMerge(java.lang.String dataItemKey) |
int |
size()
Returns the number of items.
|
java.lang.String |
toString() |
protected void |
writeAdditionalData(org.w3c.dom.Document document,
org.w3c.dom.Node rootNode) |
void |
writeBlobTo(java.io.File blobRootFolder,
MergeConsumer<I> consumer,
boolean includeTimestamps)
Writes a single blob file to store all that the DataMerger knows about.
|
void |
writeBlobToWithTimestamps(java.io.File blobRootFolder,
MergeConsumer<I> consumer)
Writes a single blob file to store all that the DataMerger knows about, and tag file entries
with lastModified timestamps.
|
protected AssetSet createFromXml(org.w3c.dom.Node node) throws MergingException
MergingExceptionprotected boolean requiresMerge(@NonNull
java.lang.String dataItemKey)
protected void mergeItems(@NonNull
java.lang.String dataItemKey,
@NonNull
java.util.List<com.android.ide.common.resources.AssetItem> items,
@NonNull
MergeConsumer<com.android.ide.common.resources.AssetItem> consumer)
dataItemKey - the key for the itemsitems - the items, from lower priority to higher priority.consumer - the consumer to receive the merged items.public void addDataSet(S resourceSet)
DataSet and overlays it on top of the existing DataSet.resourceSet - the ResourceSet to add.@NonNull public java.util.List<S> getDataSets()
public int size()
DataMap@NonNull public com.google.common.collect.ListMultimap<java.lang.String,I> getDataMap()
DataMappublic void mergeData(@NonNull
MergeConsumer<I> consumer,
boolean doCleanUp)
throws MergingException
consumer - the consumer of the merge.doCleanUp - clean up the state to be able to do further incremental merges. If this
is a one-shot merge, this can be false to improve performance.MergingException - such as a DuplicateDataException or a
MergeConsumer.ConsumerException if something goes wrongpublic void writeBlobTo(@NonNull
java.io.File blobRootFolder,
@NonNull
MergeConsumer<I> consumer,
boolean includeTimestamps)
throws MergingException
blobRootFolder - the root folder where blobs are store.consumer - the merge consumer that was used by the merge.includeTimestamps - true if the files should be tagged with lastModified timestampsMergingException - if something goes wrongloadFromBlob(File, boolean)public void writeBlobToWithTimestamps(@NonNull
java.io.File blobRootFolder,
@NonNull
MergeConsumer<I> consumer)
throws MergingException
blobRootFolder - the root folder where blobs are store.consumer - the merge consumer that was used by the merge.MergingException - if something goes wrongloadFromBlob(File, boolean)public boolean loadFromBlob(@NonNull
java.io.File blobRootFolder,
boolean incrementalState)
throws MergingException
This can be loaded into two different ways that differ only by the state on
the DataItem objects.
If incrementalState is true then the items that are on disk are
marked as written (DataItem.isWritten() returning true. This is to be
used by MergeWriter to update a merged res folder.
If false, the items are marked as touched, and this can be used to feed a new
AbstractResourceRepository object.
blobRootFolder - the folder containing the blob.incrementalState - whether to load into an incremental state or a new state.MergingException - if something goes wrongwriteBlobTo(File, MergeConsumer, boolean)@NonNull protected java.lang.String getAdditionalDataTagName()
protected void loadAdditionalData(@NonNull
org.w3c.dom.Node additionalDataNode,
boolean incrementalState)
throws MergingException
MergingExceptionprotected void writeAdditionalData(org.w3c.dom.Document document,
org.w3c.dom.Node rootNode)
throws MergingException
MergingExceptionpublic void cleanBlob(@NonNull
java.io.File blobRootFolder)
public boolean checkValidUpdate(java.util.List<S> dataSets)
dataSets - the resource sets.public FileValidity<S> findDataSetContaining(@NonNull java.io.File file)
DataSet that contains the given file.
This methods will also performs some checks to make sure the given file is a valid file
in the data set.
All the information is set in a FileValidity object that is returned.
FileValidity contains information about the changed file including:
- is it from an known set, is it an ignored file, or is it unknown?
- what data set does it belong to
- what source folder in the data set does it belong to.
"belong" means that the DataSet has a source file/folder that is the root folder
of this file. The folder and/or file doesn't have to exist.file - the file to checkpublic FileValidity<S> findDataSetContaining(@NonNull java.io.File file, @Nullable FileValidity<S> fileValidity)
DataSet that contains the given file.
This methods will also performs some checks to make sure the given file is a valid file
in the data set.
All the information is set in a FileValidity object that is returned. If an instance
is passed, then this object is filled instead, and returned.
FileValidity contains information about the changed file including:
- is it from an known set, is it an ignored file, or is it unknown?
- what data set does it belong to
- what source folder in the data set does it belong to.
"belong" means that the DataSet has a source file/folder that is the root folder
of this file. The folder and/or file doesn't have to exist.file - the file to checkfileValidity - an optional FileValidity to fill. If null a new one is returned.protected void createDir(java.io.File folder)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Objectprotected boolean filterAccept(@NonNull
I dataItem)
dataItem - the data item to filter