Class PlexusIoCompressedFileResourceCollection
- java.lang.Object
-
- org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection
-
- All Implemented Interfaces:
java.lang.Iterable<PlexusIoResource>
,PlexusIoArchivedResourceCollection
,PlexusIoResourceCollection
public abstract class PlexusIoCompressedFileResourceCollection extends java.lang.Object implements PlexusIoArchivedResourceCollection, java.lang.Iterable<PlexusIoResource>
Abstract base class for compressed files, aka singleton resource collections.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
file
private java.lang.String
path
private InputStreamTransformer
streamTransformers
-
Fields inherited from interface org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection
DEFAULT_ROLE_HINT, ROLE
-
-
Constructor Summary
Constructors Constructor Description PlexusIoCompressedFileResourceCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract PlexusIoResourceAttributes
getAttributes(java.io.File f)
protected abstract java.lang.String
getDefaultExtension()
java.io.File
getFile()
Returns the archive fileprotected abstract java.io.InputStream
getInputStream(java.io.File file)
java.io.InputStream
getInputStream(PlexusIoResource resource)
Returns an input stream for the provided resource, with stream transformers appliedlong
getLastModified()
Returns the collections last modification time.protected java.lang.String
getName(java.io.File file)
java.lang.String
getName(PlexusIoResource resource)
Returns the resources suggested name.java.lang.String
getPath()
java.util.Iterator<PlexusIoResource>
getResources()
Returns an iterator over the resources in the collection.boolean
isConcurrentAccessSupported()
Indicates if this collection supports concurrent access to its resources.java.util.Iterator<PlexusIoResource>
iterator()
PlexusIoResource
resolve(PlexusIoResource resource)
Resolves the supplied resource into a "real" resource.void
setFile(java.io.File file)
Sets the archive filevoid
setPath(java.lang.String path)
void
setStreamTransformer(InputStreamTransformer streamTransformers)
Stream
stream()
Returns the resources as a stream.
-
-
-
Field Detail
-
file
private java.io.File file
-
path
private java.lang.String path
-
streamTransformers
private InputStreamTransformer streamTransformers
-
-
Method Detail
-
getFile
public java.io.File getFile()
Description copied from interface:PlexusIoArchivedResourceCollection
Returns the archive file- Specified by:
getFile
in interfacePlexusIoArchivedResourceCollection
-
setFile
public void setFile(java.io.File file)
Description copied from interface:PlexusIoArchivedResourceCollection
Sets the archive file- Specified by:
setFile
in interfacePlexusIoArchivedResourceCollection
-
getPath
public java.lang.String getPath()
-
setPath
public void setPath(java.lang.String path)
-
getAttributes
protected abstract PlexusIoResourceAttributes getAttributes(java.io.File f) throws java.io.IOException
- Throws:
java.io.IOException
-
setStreamTransformer
public void setStreamTransformer(InputStreamTransformer streamTransformers)
-
stream
public Stream stream()
Description copied from interface:PlexusIoResourceCollection
Returns the resources as a stream.- Specified by:
stream
in interfacePlexusIoResourceCollection
- Returns:
- A stream for functional iteration
-
getResources
public java.util.Iterator<PlexusIoResource> getResources() throws java.io.IOException
Description copied from interface:PlexusIoResourceCollection
Returns an iterator over the resources in the collection.- Specified by:
getResources
in interfacePlexusIoResourceCollection
- Returns:
- An iterator
- Throws:
java.io.IOException
- .
-
getName
protected java.lang.String getName(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
getDefaultExtension
protected abstract java.lang.String getDefaultExtension()
-
getInputStream
@Nonnull protected abstract java.io.InputStream getInputStream(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream(PlexusIoResource resource) throws java.io.IOException
Description copied from interface:PlexusIoResourceCollection
Returns an input stream for the provided resource, with stream transformers applied- Specified by:
getInputStream
in interfacePlexusIoResourceCollection
- Parameters:
resource
- The resources- Returns:
- A possibly transformed resource
- Throws:
java.io.IOException
- when something goes bad
-
resolve
public PlexusIoResource resolve(PlexusIoResource resource) throws java.io.IOException
Description copied from interface:PlexusIoResourceCollection
Resolves 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:
resolve
in interfacePlexusIoResourceCollection
- Parameters:
resource
- The resources- Returns:
- A possibly transformed resource
- Throws:
java.io.IOException
- when something goes bad
-
iterator
public java.util.Iterator<PlexusIoResource> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<PlexusIoResource>
-
getName
public java.lang.String getName(PlexusIoResource resource)
Description copied from interface:PlexusIoResourceCollection
Returns the resources suggested name. This is used for integrating file mappers.- Specified by:
getName
in 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 java.io.IOException
Description copied from interface:PlexusIoResourceCollection
Returns 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:
getLastModified
in interfacePlexusIoResourceCollection
- Returns:
PlexusIoResource.UNKNOWN_MODIFICATION_DATE
, if the collections last modification time is unknown, otherwise the last modification time in milliseconds.- Throws:
java.io.IOException
- .
-
isConcurrentAccessSupported
public boolean isConcurrentAccessSupported()
Description copied from interface:PlexusIoResourceCollection
Indicates 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 iftrue
is returned.- Specified by:
isConcurrentAccessSupported
in interfacePlexusIoResourceCollection
- Returns:
true
if this collection supports concurrent access, otherwisefalse
-
-