|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.util.AbstractIteratorUtil
org.entityfs.util.IteratorCopier
public class IteratorCopier
The IteratorCopier
takes a tree of entities returned from an iterator
and copies them to another entity tree, possibly in another file system. It
automatically creates necessary directories at the target.
The copier's source directory is used to create the target location of the copied entities. A copied entity will be put with the same location relative to the target directory as it had relative to the source directory.
The client can only use an IteratorCopier
instance once.
The copier locks entities and parent entities as needed, but it never holds
any locks between two copy operations. (In other words: when it calls next
on the iterator, it does not hold any locks.)
An optional ErrorHandlingStrategy
can be used to deal with errors.
The default strategy when an exception is caught is to abort the copy
operation and rethrow the exception.
The copier uses a DirectoryView
as a source directory rather than an
EntityListable
since every copied entity's location relative to the
source directory is significant for finding its destination location.
EntityFS iterators are not thread safe. Don't use them concurrently from several threads without synchronizing access to them.
Constructor Summary | |
---|---|
IteratorCopier(DirectoryView sourceDir,
DirectoryView target)
Create an IteratorCopier with one target directory and the
default error strategy (see above). |
|
IteratorCopier(DirectoryView sourceDir,
Iterator<? extends EntityView> itr,
Collection<? extends DirectoryView> targets)
Create an IteratorCopier with a collection of target directories
and the default error strategy (see above). |
|
IteratorCopier(DirectoryView sourceDir,
Iterator<? extends EntityView> itr,
Collection<? extends DirectoryView> targets,
ErrorHandlingStrategy errorStrategy)
Create an IteratorCopier with a collection of target directories
and the supplied error strategy. |
|
IteratorCopier(DirectoryView sourceDir,
Iterator<? extends EntityView> itr,
DirectoryView target)
Create an IteratorCopier with one target directory and the
default error strategy (see above). |
|
IteratorCopier(DirectoryView sourceDir,
Iterator<? extends EntityView> itr,
DirectoryView target,
ErrorHandlingStrategy errorStrategy)
Create an IteratorCopier with one target directory and the
supplied error strategy. |
Method Summary | |
---|---|
void |
copy()
Copy all entities returned from the iterator. |
void |
copy(boolean overwrite,
boolean preserveAttr)
Copy all entities returned from the iterator. |
void |
copy(OverwriteStrategy overwriteStrategy,
boolean preserveAttr)
Copy all entities returned from the iterator. |
Methods inherited from class org.entityfs.util.AbstractIteratorUtil |
---|
letErrorStrategyHandle, letErrorStrategyHandle, letErrorStrategyHandle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IteratorCopier(DirectoryView sourceDir, DirectoryView target)
IteratorCopier
with one target directory and the
default error strategy (see above). A depth-last iterator created on the
source directory is used for copying the files.
sourceDir
- The source directorytarget
- The target directory.public IteratorCopier(DirectoryView sourceDir, Iterator<? extends EntityView> itr, DirectoryView target)
IteratorCopier
with one target directory and the
default error strategy (see above).
sourceDir
- The source directory. This is used to create target
locations for copied entities.itr
- The Iterator
the copier will read entities to copy
from. It's a little more efficient to use a DepthLastIterator
than a DepthFirstIterator
when copying hierarchies.target
- The target directory. Entities will be copied to the same
location relative to the target directory that they have relative to the
source directory.public IteratorCopier(DirectoryView sourceDir, Iterator<? extends EntityView> itr, DirectoryView target, ErrorHandlingStrategy errorStrategy)
IteratorCopier
with one target directory and the
supplied error strategy.
sourceDir
- The source directory. This is used to create target
locations for copied entities.itr
- The Iterator
the copier will read entities to copy
from. It's a little more efficient to use a DepthLastIterator
than a DepthFirstIterator
when copying hierarchies.target
- The target directory. Entities will be copied to the same
location relative to the target directory that they have relative to the
source directory.errorStrategy
- The error strategy.public IteratorCopier(DirectoryView sourceDir, Iterator<? extends EntityView> itr, Collection<? extends DirectoryView> targets)
IteratorCopier
with a collection of target directories
and the default error strategy (see above).
sourceDir
- The source directory. This is used to create target
locations for copied entities.itr
- The Iterator
the copier will read entities to copy
from. It's a little more efficient to use a DepthLastIterator
than a DepthFirstIterator
when copying hierarchies.targets
- The collection of target directories. Entities will be
copied to the same location relative to a target directory that they have
relative to the source directory.public IteratorCopier(DirectoryView sourceDir, Iterator<? extends EntityView> itr, Collection<? extends DirectoryView> targets, ErrorHandlingStrategy errorStrategy)
IteratorCopier
with a collection of target directories
and the supplied error strategy.
sourceDir
- The source directory. This is used to create target
locations for copied entities.itr
- The Iterator
the copier will read entities to copy
from. It's a little more efficient to use a DepthLastIterator
than a DepthFirstIterator
when copying hierarchies.targets
- The target directories. Entities will be copied to the
same location relative to a target directory that they have relative to
the source directory.errorStrategy
- The error strategy.Method Detail |
---|
public void copy(OverwriteStrategy overwriteStrategy, boolean preserveAttr)
overwriteStrategy
- The strategy to use for overwriting existing
entities.preserveAttr
- Should entity attributes such as the last
modification times of entities be copied to the target entities?
UncheckedInterruptedException
- If the copy operation is
interrupted.copy()
,
copy(boolean, boolean)
public void copy(boolean overwrite, boolean preserveAttr) throws UncheckedInterruptedException
overwrite
- If true
, this means that the overwrite strategy
DontOverwriteAndLogWarning
is used. If false
, this means
that the strategy DontOverwriteAndLogWarning
is used.preserveAttr
- Should entity attributes such as the last
modification times of entities be copied to the target entities?
UncheckedInterruptedException
- If the copy operation is
interrupted.copy()
,
copy(OverwriteStrategy, boolean)
public void copy() throws UncheckedInterruptedException
Entity attributes such as their last modification times are not copied.
UncheckedInterruptedException
- If the copy operation is
interrupted.copy(boolean,boolean)
,
copy(OverwriteStrategy, boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |