Class PlexusIoCompressedFileResourceCollection
- java.lang.Object
-
- org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection
-
- All Implemented Interfaces:
Iterable<PlexusIoResource>,PlexusIoArchivedResourceCollection,PlexusIoResourceCollection
public abstract class PlexusIoCompressedFileResourceCollection extends Object implements PlexusIoArchivedResourceCollection, Iterable<PlexusIoResource>
Abstract base class for compressed files, aka singleton resource collections.
-
-
Constructor Summary
Constructors Constructor Description PlexusIoCompressedFileResourceCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract PlexusIoResourceAttributesgetAttributes(File f)protected abstract StringgetDefaultExtension()FilegetFile()Returns the archive fileprotected abstract InputStreamgetInputStream(File file)InputStreamgetInputStream(PlexusIoResource resource)Returns an input stream for the provided resource, with stream transformers appliedlonggetLastModified()Returns the collections last modification time.protected StringgetName(File file)StringgetName(PlexusIoResource resource)Returns the resources suggested name.StringgetPath()Iterator<PlexusIoResource>getResources()Returns an iterator over the resources in the collection.booleanisConcurrentAccessSupported()Indicates if this collection supports concurrent access to its resources.Iterator<PlexusIoResource>iterator()PlexusIoResourceresolve(PlexusIoResource resource)Resolves the supplied resource into a "real" resource.voidsetFile(File file)Sets the archive filevoidsetPath(String path)voidsetStreamTransformer(InputStreamTransformer streamTransformers)Streamstream()Returns the resources as a stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getFile
public File getFile()
Description copied from interface:PlexusIoArchivedResourceCollectionReturns the archive file- Specified by:
getFilein interfacePlexusIoArchivedResourceCollection
-
setFile
public void setFile(File file)
Description copied from interface:PlexusIoArchivedResourceCollectionSets the archive file- Specified by:
setFilein interfacePlexusIoArchivedResourceCollection
-
getPath
public String getPath()
-
setPath
public void setPath(String path)
-
getAttributes
protected abstract PlexusIoResourceAttributes getAttributes(File f) throws IOException
- Throws:
IOException
-
setStreamTransformer
public void setStreamTransformer(InputStreamTransformer streamTransformers)
-
stream
public Stream stream()
Description copied from interface:PlexusIoResourceCollectionReturns the resources as a stream.- Specified by:
streamin interfacePlexusIoResourceCollection- Returns:
- A stream for functional iteration
-
getResources
public Iterator<PlexusIoResource> getResources() throws IOException
Description copied from interface:PlexusIoResourceCollectionReturns an iterator over the resources in the collection.- Specified by:
getResourcesin interfacePlexusIoResourceCollection- Returns:
- An iterator
- Throws:
IOException- .
-
getName
protected String getName(File file) throws IOException
- Throws:
IOException
-
getDefaultExtension
protected abstract String getDefaultExtension()
-
getInputStream
@Nonnull protected abstract InputStream getInputStream(File file) throws IOException
- Throws:
IOException
-
getInputStream
public InputStream getInputStream(PlexusIoResource resource) throws IOException
Description copied from interface:PlexusIoResourceCollectionReturns an input stream for the provided resource, with stream transformers applied- Specified by:
getInputStreamin interfacePlexusIoResourceCollection- Parameters:
resource- The resources- Returns:
- A possibly transformed resource
- Throws:
IOException- when something goes bad
-
resolve
public PlexusIoResource resolve(PlexusIoResource resource) throws IOException
Description copied from interface:PlexusIoResourceCollectionResolves the supplied resource into a "real" resource. Resolving means applying input transformations Returns an input stream for the provided resource, with stream transformers applied- Specified by:
resolvein interfacePlexusIoResourceCollection- Parameters:
resource- The resources- Returns:
- A possibly transformed resource
- Throws:
IOException- when something goes bad
-
iterator
public Iterator<PlexusIoResource> iterator()
- Specified by:
iteratorin interfaceIterable<PlexusIoResource>
-
getName
public String getName(PlexusIoResource resource)
Description copied from interface:PlexusIoResourceCollectionReturns the resources suggested name. This is used for integrating file mappers.- Specified by:
getNamein interfacePlexusIoResourceCollection- Parameters:
resource- A resource, which has been obtained by callingPlexusIoResourceCollection.getResources().- Returns:
- The resource name. If it is a file, it should be normalized to platform separators
-
getLastModified
public long getLastModified() throws IOExceptionDescription copied from interface:PlexusIoResourceCollectionReturns the collections last modification time. For a collection of files, this might be the last modification time of the file, which has been modified at last. For an archive file, this might be the modification time of the archive file.- Specified by:
getLastModifiedin interfacePlexusIoResourceCollection- Returns:
PlexusIoResource.UNKNOWN_MODIFICATION_DATE, if the collections last modification time is unknown, otherwise the last modification time in milliseconds.- Throws:
IOException- .
-
isConcurrentAccessSupported
public boolean isConcurrentAccessSupported()
Description copied from interface:PlexusIoResourceCollectionIndicates if this collection supports concurrent access to its resources.Some resource collections (like tar files) may not support efficient random access or seek operation so implementations that represent such collections may not be able to provide concurrent access to its resources. If implementation returns
false, then it is not safe to access its methods and resources in concurrent fashion. For example it is not safe to read from two resources in two concurrent threads, to read a resource and iterate over the iterator returned byPlexusIoResourceCollection.getResources()in two concurrent threads, etc.Please note that this method indicates concurrent support only for the collection, not for the individual resources. This means there is no guarantee that the resources returned by
PlexusIoResourceCollection.resolve(PlexusIoResource)or the input stream returned byPlexusIoResourceCollection.getInputStream(PlexusIoResource)are thread-safe, even iftrueis returned.- Specified by:
isConcurrentAccessSupportedin interfacePlexusIoResourceCollection- Returns:
trueif this collection supports concurrent access, otherwisefalse
-
-