Class PlexusIoFileResource
- java.lang.Object
-
- org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource
-
- org.codehaus.plexus.components.io.resources.PlexusIoFileResource
-
- All Implemented Interfaces:
FileInfo,ContentSupplier,FileSupplier,NameSupplier,ResourceAttributeSupplier,SizeSupplier,PlexusIoResource
- Direct Known Subclasses:
PlexusIoSymlinkResource
public class PlexusIoFileResource extends AbstractPlexusIoResource implements ResourceAttributeSupplier, FileSupplier
Implementation ofPlexusIoResourcefor files.
-
-
Field Summary
Fields Modifier and Type Field Description private PlexusIoResourceAttributesattributesprivate ContentSuppliercontentSupplierprivate org.apache.commons.io.output.DeferredFileOutputStreamdfosprivate java.io.Filefileprivate static InputStreamTransformeridentityTransformer-
Fields inherited from interface org.codehaus.plexus.components.io.resources.PlexusIoResource
UNKNOWN_MODIFICATION_DATE, UNKNOWN_RESOURCE_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPlexusIoFileResource(java.io.File file, java.lang.String name, PlexusIoResourceAttributes attrs)(package private)PlexusIoFileResource(java.io.File file, java.lang.String name, PlexusIoResourceAttributes attrs, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static org.apache.commons.io.output.DeferredFileOutputStreamasDeferredStream(ContentSupplier supplier, InputStreamTransformer transToUse, PlexusIoResource resource)PlexusIoResourceAttributesgetAttributes()java.io.InputStreamgetContents()Creates anInputStream, which may be used to read the files contents.java.io.FilegetFile()Returns the resource file.longgetLastModified()Returns the date, when the resource was last modified, if known.static java.lang.StringgetName(java.io.File file)private static ContentSuppliergetRootContentSupplier(java.io.File file)longgetSize()Returns the resources size, if known.java.net.URLgetURL()Returns anURL, which may be used to reference the resource, if possible.booleanisDirectory()Returns, whether theFileInforefers to a directory.booleanisExisting()Returns, whether the resource exists.booleanisFile()Returns, whether theFileInforefers to a file.booleanisSymbolicLink()Returns, whether theFileInforefers to a symlink.-
Methods inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource
getName
-
-
-
-
Field Detail
-
file
@Nonnull private final java.io.File file
-
attributes
@Nonnull private final PlexusIoResourceAttributes attributes
-
contentSupplier
private final ContentSupplier contentSupplier
-
dfos
private final org.apache.commons.io.output.DeferredFileOutputStream dfos
-
identityTransformer
private static final InputStreamTransformer identityTransformer
-
-
Constructor Detail
-
PlexusIoFileResource
protected PlexusIoFileResource(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull PlexusIoResourceAttributes attrs) throws java.io.IOException- Throws:
java.io.IOException
-
PlexusIoFileResource
PlexusIoFileResource(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull PlexusIoResourceAttributes attrs, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
asDeferredStream
private static org.apache.commons.io.output.DeferredFileOutputStream asDeferredStream(@Nonnull ContentSupplier supplier, @Nonnull InputStreamTransformer transToUse, PlexusIoResource resource) throws java.io.IOException- Throws:
java.io.IOException
-
getRootContentSupplier
private static ContentSupplier getRootContentSupplier(java.io.File file)
-
getName
public static java.lang.String getName(java.io.File file)
-
getFile
@Nonnull public java.io.File getFile()
Returns the resource file.- Specified by:
getFilein interfaceFileSupplier- Returns:
- The file
-
getContents
@Nonnull public java.io.InputStream getContents() throws java.io.IOExceptionDescription copied from interface:PlexusIoResourceCreates anInputStream, which may be used to read the files contents. This is useful, if the file selector comes to a decision based on the files contents. Please note that this InputStream is unbuffered. Clients should wrap this in a BufferedInputStream or attempt reading reasonably large chunks (8K+).- Specified by:
getContentsin interfaceContentSupplier- Specified by:
getContentsin interfaceFileInfo- Specified by:
getContentsin interfacePlexusIoResource- Throws:
java.io.IOException
-
getURL
@Nonnull public java.net.URL getURL() throws java.io.IOExceptionDescription copied from interface:PlexusIoResourceReturns anURL, which may be used to reference the resource, if possible.- Specified by:
getURLin interfacePlexusIoResource- Returns:
- An URL referencing the resource, if possible, or null.
In the latter case, you are forced to use
PlexusIoResource.getContents(). - Throws:
java.io.IOException
-
getSize
public long getSize()
Description copied from interface:PlexusIoResourceReturns the resources size, if known. Otherwise returnsPlexusIoResource.UNKNOWN_RESOURCE_SIZE.- Specified by:
getSizein interfacePlexusIoResource- Specified by:
getSizein interfaceSizeSupplier- Overrides:
getSizein classAbstractPlexusIoResource
-
isDirectory
public boolean isDirectory()
Description copied from interface:PlexusIoResourceReturns, whether theFileInforefers to a directory.- Specified by:
isDirectoryin interfaceFileInfo- Specified by:
isDirectoryin interfacePlexusIoResource- Overrides:
isDirectoryin classAbstractPlexusIoResource
-
isExisting
public boolean isExisting()
Description copied from interface:PlexusIoResourceReturns, whether the resource exists.- Specified by:
isExistingin interfacePlexusIoResource- Overrides:
isExistingin classAbstractPlexusIoResource
-
isFile
public boolean isFile()
Description copied from interface:PlexusIoResourceReturns, whether theFileInforefers to a file.- Specified by:
isFilein interfaceFileInfo- Specified by:
isFilein interfacePlexusIoResource- Overrides:
isFilein classAbstractPlexusIoResource
-
getAttributes
@Nonnull public PlexusIoResourceAttributes getAttributes()
- Specified by:
getAttributesin interfaceResourceAttributeSupplier
-
getLastModified
public long getLastModified()
Description copied from interface:PlexusIoResourceReturns the date, when the resource was last modified, if known. Otherwise, returnsPlexusIoResource.UNKNOWN_MODIFICATION_DATE.- Specified by:
getLastModifiedin interfacePlexusIoResource- Overrides:
getLastModifiedin classAbstractPlexusIoResource- See Also:
File.lastModified()
-
isSymbolicLink
public boolean isSymbolicLink()
Description copied from interface:FileInfoReturns, whether theFileInforefers to a symlink. This does not necessarily mean that the underlying representation *is* a symlink on disk, but that this resource represents a symlink. This method will return "false" for java versions prior to java7.- Specified by:
isSymbolicLinkin interfaceFileInfo- Overrides:
isSymbolicLinkin classAbstractPlexusIoResource
-
-