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 of
PlexusIoResource
for files.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PlexusIoResourceAttributes
private final ContentSupplier
private final org.apache.commons.io.output.DeferredFileOutputStream
private final File
private final FileAttributes
private static final InputStreamTransformer
Fields inherited from interface org.codehaus.plexus.components.io.resources.PlexusIoResource
UNKNOWN_MODIFICATION_DATE, UNKNOWN_RESOURCE_SIZE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PlexusIoFileResource
(File file, String name, PlexusIoResourceAttributes attrs) (package private)
PlexusIoFileResource
(File file, String name, PlexusIoResourceAttributes attrs, FileAttributes fileAttributes, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) (package private)
PlexusIoFileResource
(File file, String name, PlexusIoResourceAttributes attrs, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.apache.commons.io.output.DeferredFileOutputStream
asDeferredStream
(ContentSupplier supplier, InputStreamTransformer transToUse, PlexusIoResource resource) Creates anInputStream
, which may be used to read the files contents.protected org.apache.commons.io.output.DeferredFileOutputStream
getDfos()
getFile()
Returns the resource file.long
Returns the date, when the resource was last modified, if known.static String
private static ContentSupplier
getRootContentSupplier
(File file) long
getSize()
Returns the resources size, if known.getURL()
Returns anURL
, which may be used to reference the resource, if possible.boolean
Returns, whether theFileInfo
refers to a directory.boolean
Returns, whether the resource exists.boolean
isFile()
Returns, whether theFileInfo
refers to a file.boolean
Returns, whether theFileInfo
refers to a symlink.Methods inherited from class org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource
getName
-
Field Details
-
file
-
attributes
-
fileAttributes
-
contentSupplier
-
dfos
private final org.apache.commons.io.output.DeferredFileOutputStream dfos -
identityTransformer
-
-
Constructor Details
-
PlexusIoFileResource
protected PlexusIoFileResource(@Nonnull File file, @Nonnull String name, @Nonnull PlexusIoResourceAttributes attrs) throws IOException - Throws:
IOException
-
PlexusIoFileResource
PlexusIoFileResource(@Nonnull File file, @Nonnull String name, @Nonnull PlexusIoResourceAttributes attrs, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) throws IOException - Throws:
IOException
-
PlexusIoFileResource
PlexusIoFileResource(@Nonnull File file, @Nonnull String name, @Nonnull PlexusIoResourceAttributes attrs, @Nonnull FileAttributes fileAttributes, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) throws IOException - Throws:
IOException
-
-
Method Details
-
asDeferredStream
private static org.apache.commons.io.output.DeferredFileOutputStream asDeferredStream(@Nonnull ContentSupplier supplier, @Nonnull InputStreamTransformer transToUse, PlexusIoResource resource) throws IOException - Throws:
IOException
-
getRootContentSupplier
-
getName
-
getFile
Returns the resource file.- Specified by:
getFile
in interfaceFileSupplier
- Returns:
- The file
-
getContents
Description copied from interface:PlexusIoResource
Creates 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:
getContents
in interfaceContentSupplier
- Specified by:
getContents
in interfaceFileInfo
- Specified by:
getContents
in interfacePlexusIoResource
- Throws:
IOException
-
getURL
Description copied from interface:PlexusIoResource
Returns anURL
, which may be used to reference the resource, if possible.- Specified by:
getURL
in interfacePlexusIoResource
- Returns:
- An URL referencing the resource, if possible, or null.
In the latter case, you are forced to use
PlexusIoResource.getContents()
. - Throws:
IOException
-
getSize
public long getSize()Description copied from interface:PlexusIoResource
Returns the resources size, if known. Otherwise returnsPlexusIoResource.UNKNOWN_RESOURCE_SIZE
.- Specified by:
getSize
in interfacePlexusIoResource
- Specified by:
getSize
in interfaceSizeSupplier
- Overrides:
getSize
in classAbstractPlexusIoResource
-
isDirectory
public boolean isDirectory()Description copied from interface:PlexusIoResource
Returns, whether theFileInfo
refers to a directory.- Specified by:
isDirectory
in interfaceFileInfo
- Specified by:
isDirectory
in interfacePlexusIoResource
- Overrides:
isDirectory
in classAbstractPlexusIoResource
-
isExisting
public boolean isExisting()Description copied from interface:PlexusIoResource
Returns, whether the resource exists.- Specified by:
isExisting
in interfacePlexusIoResource
- Overrides:
isExisting
in classAbstractPlexusIoResource
-
isFile
public boolean isFile()Description copied from interface:PlexusIoResource
Returns, whether theFileInfo
refers to a file.- Specified by:
isFile
in interfaceFileInfo
- Specified by:
isFile
in interfacePlexusIoResource
- Overrides:
isFile
in classAbstractPlexusIoResource
-
getAttributes
- Specified by:
getAttributes
in interfaceResourceAttributeSupplier
-
getFileAttributes
-
getLastModified
public long getLastModified()Description copied from interface:PlexusIoResource
Returns the date, when the resource was last modified, if known. Otherwise, returnsPlexusIoResource.UNKNOWN_MODIFICATION_DATE
.- Specified by:
getLastModified
in interfacePlexusIoResource
- Overrides:
getLastModified
in classAbstractPlexusIoResource
- See Also:
-
isSymbolicLink
public boolean isSymbolicLink()Description copied from interface:FileInfo
Returns, whether theFileInfo
refers 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:
isSymbolicLink
in interfaceFileInfo
- Overrides:
isSymbolicLink
in classAbstractPlexusIoResource
-
getDfos
protected org.apache.commons.io.output.DeferredFileOutputStream getDfos()
-