Class PlexusIoFileResourceCollection
- java.lang.Object
-
- org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection
-
- org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollectionWithAttributes
-
- org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection
-
- All Implemented Interfaces:
java.lang.Iterable<PlexusIoResource>,PlexusIoResourceCollection
public class PlexusIoFileResourceCollection extends AbstractPlexusIoResourceCollectionWithAttributes
Implementation ofPlexusIoResourceCollectionfor the set of files in a common directory.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection
AbstractPlexusIoResourceCollection.IdentityTransformer
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilebaseDirprivate java.util.Comparator<java.lang.String>filenameComparatorprivate booleanisFollowingSymLinksstatic java.lang.StringROLE_HINTRole hint of this component-
Fields inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection
identityTransformer
-
Fields inherited from interface org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection
DEFAULT_ROLE_HINT, ROLE
-
-
Constructor Summary
Constructors Constructor Description PlexusIoFileResourceCollection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddResources(java.util.List<PlexusIoResource> result, java.lang.String[] resources)private static PlexusIoResourceAttributescreateDefaults(int uid, java.lang.String userName, int gid, java.lang.String groupName, int mode)java.io.FilegetBaseDir()java.io.InputStreamgetInputStream(PlexusIoResource resource)Returns an input stream for the provided resource, with stream transformers appliedjava.lang.StringgetName(PlexusIoResource resource)Returns the resources suggested name.java.util.Iterator<PlexusIoResource>getResources()Returns an iterator over the resources in the collection.booleanisConcurrentAccessSupported()Indicates if this collection supports concurrent access to its resources.booleanisFollowingSymLinks()PlexusIoResourceresolve(PlexusIoResource resource)Resolves the supplied resource into a "real" resource.voidsetBaseDir(java.io.File baseDir)voidsetDefaultAttributes(int uid, java.lang.String userName, int gid, java.lang.String groupName, int fileMode, int dirMode)voidsetFilenameComparator(java.util.Comparator<java.lang.String> filenameComparator)voidsetFollowingSymLinks(boolean pIsFollowingSymLinks)voidsetOverrideAttributes(int uid, java.lang.String userName, int gid, java.lang.String groupName, int fileMode, int dirMode)voidsetPrefix(java.lang.String prefix)Sets the prefix, which the file sets contents shall have.Streamstream()Returns the resources as a stream.-
Methods inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollectionWithAttributes
getDefaultDirAttributes, getDefaultFileAttributes, getOverrideDirAttributes, getOverrideFileAttributes, mergeAttributes, setDefaultDirAttributes, setDefaultFileAttributes, setOverrideDirAttributes, setOverrideFileAttributes
-
Methods inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection
getExcludes, getFileMappers, getFileSelectors, getIncludes, getLastModified, getName, getPrefix, getStreamTransformer, isCaseSensitive, isIncludingEmptyDirectories, isSelected, isUsingDefaultExcludes, iterator, setCaseSensitive, setExcludes, setFileMappers, setFileSelectors, setIncludes, setIncludingEmptyDirectories, setStreamTransformer, setUsingDefaultExcludes
-
-
-
-
Field Detail
-
ROLE_HINT
public static final java.lang.String ROLE_HINT
Role hint of this component- See Also:
- Constant Field Values
-
baseDir
private java.io.File baseDir
-
isFollowingSymLinks
private boolean isFollowingSymLinks
-
filenameComparator
private java.util.Comparator<java.lang.String> filenameComparator
- Since:
- 3.2.0
-
-
Method Detail
-
resolve
public PlexusIoResource resolve(PlexusIoResource resource) throws java.io.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- Overrides:
resolvein classAbstractPlexusIoResourceCollection- Parameters:
resource- The resources- Returns:
- A possibly transformed resource
- Throws:
java.io.IOException- when something goes bad
-
getInputStream
public java.io.InputStream getInputStream(PlexusIoResource resource) throws java.io.IOException
Description copied from interface:PlexusIoResourceCollectionReturns an input stream for the provided resource, with stream transformers applied- Specified by:
getInputStreamin interfacePlexusIoResourceCollection- Overrides:
getInputStreamin classAbstractPlexusIoResourceCollection- Parameters:
resource- The resources- Returns:
- A possibly transformed resource
- Throws:
java.io.IOException- when something goes bad
-
getName
public java.lang.String getName(PlexusIoResource resource)
Description copied from interface:PlexusIoResourceCollectionReturns the resources suggested name. This is used for integrating file mappers.- Specified by:
getNamein interfacePlexusIoResourceCollection- Overrides:
getNamein classAbstractPlexusIoResourceCollection- 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
-
setBaseDir
public void setBaseDir(java.io.File baseDir)
- Parameters:
baseDir- The base directory of the file collection
-
getBaseDir
public java.io.File getBaseDir()
- Returns:
- Returns the file collections base directory.
-
isFollowingSymLinks
public boolean isFollowingSymLinks()
- Returns:
- Returns, whether symbolic links should be followed. Defaults to true.
-
setFollowingSymLinks
public void setFollowingSymLinks(boolean pIsFollowingSymLinks)
- Parameters:
pIsFollowingSymLinks- whether symbolic links should be followed
-
setDefaultAttributes
public void setDefaultAttributes(int uid, java.lang.String userName, int gid, java.lang.String groupName, int fileMode, int dirMode)
-
setOverrideAttributes
public void setOverrideAttributes(int uid, java.lang.String userName, int gid, java.lang.String groupName, int fileMode, int dirMode)
-
createDefaults
private static PlexusIoResourceAttributes createDefaults(int uid, java.lang.String userName, int gid, java.lang.String groupName, int mode)
-
setPrefix
public void setPrefix(java.lang.String prefix)
Description copied from class:AbstractPlexusIoResourceCollectionSets the prefix, which the file sets contents shall have.- Overrides:
setPrefixin classAbstractPlexusIoResourceCollection
-
addResources
private void addResources(java.util.List<PlexusIoResource> result, java.lang.String[] resources) throws java.io.IOException
- Throws:
java.io.IOException
-
stream
public Stream stream()
Description copied from interface:PlexusIoResourceCollectionReturns the resources as a stream.- Returns:
- A stream for functional iteration
-
getResources
public java.util.Iterator<PlexusIoResource> getResources() throws java.io.IOException
Description copied from interface:PlexusIoResourceCollectionReturns an iterator over the resources in the collection.- Returns:
- An iterator
- Throws:
java.io.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.- Returns:
trueif this collection supports concurrent access, otherwisefalse
-
setFilenameComparator
public void setFilenameComparator(java.util.Comparator<java.lang.String> filenameComparator)
- Since:
- 3.2.0
-
-