|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.ide.common.res2.ResourceMerger
public class ResourceMerger
Implementation of DataMerger
for ResourceSet
, ResourceItem
, and
ResourceFile
.
Field Summary | |
---|---|
protected javax.xml.parsers.DocumentBuilderFactory |
mFactory
|
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,ResourceItem>> |
mMergedItems
Map of items that are purely results of merges (ie item that made up of several original items). |
Constructor Summary | |
---|---|
ResourceMerger()
|
Method Summary | |
---|---|
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 ResourceSet |
createFromXml(org.w3c.dom.Node node)
|
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. |
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. |
boolean |
loadFromBlob(java.io.File blobRootFolder,
boolean incrementalState)
Loads the merger state from a blob file. |
protected void |
loadMergedItems(org.w3c.dom.Node mergedItemsNode)
|
void |
mergeData(MergeConsumer<I> consumer,
boolean doCleanUp)
Merges the data into a given consumer. |
protected void |
mergeItems(java.lang.String dataItemKey,
java.util.List<ResourceItem> items,
MergeConsumer<ResourceItem> 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()
|
void |
writeBlobTo(java.io.File blobRootFolder,
MergeConsumer<I> consumer)
Writes a single blob file to store all that the DataMerger knows about. |
protected void |
writeMergedItems(org.w3c.dom.Document document,
org.w3c.dom.Node rootNode)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.util.Map<java.lang.String,java.util.Map<java.lang.String,ResourceItem>> mMergedItems
@NonNull protected final javax.xml.parsers.DocumentBuilderFactory mFactory
Constructor Detail |
---|
public ResourceMerger()
Method Detail |
---|
protected ResourceSet createFromXml(org.w3c.dom.Node node)
protected boolean requiresMerge(@NonNull java.lang.String dataItemKey)
protected void mergeItems(@NonNull java.lang.String dataItemKey, @NonNull java.util.List<ResourceItem> items, @NonNull MergeConsumer<ResourceItem> consumer) throws MergingException
dataItemKey
- the key for the itemsitems
- the items, from lower priority to higher priority.consumer
- the consumer to receive the merged items.
MergingException
protected void loadMergedItems(@NonNull org.w3c.dom.Node mergedItemsNode)
protected void writeMergedItems(org.w3c.dom.Document document, org.w3c.dom.Node rootNode)
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()
DataMap
public 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) 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
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
ResourceRepository
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)
public 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 check
public 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.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |