public class PlexusIoFileResource extends AbstractPlexusIoResource implements ResourceAttributeSupplier, FileSupplier
PlexusIoResource
for files.Modifier and Type | Field and Description |
---|---|
private PlexusIoResourceAttributes |
attributes |
private ContentSupplier |
contentSupplier |
private org.apache.commons.io.output.DeferredFileOutputStream |
dfos |
private java.io.File |
file |
private static InputStreamTransformer |
identityTransformer |
UNKNOWN_MODIFICATION_DATE, UNKNOWN_RESOURCE_SIZE
Modifier | Constructor and Description |
---|---|
protected |
PlexusIoFileResource(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) |
Modifier and Type | Method and Description |
---|---|
private static org.apache.commons.io.output.DeferredFileOutputStream |
asDeferredStream(ContentSupplier supplier,
InputStreamTransformer transToUse,
PlexusIoResource resource) |
PlexusIoResourceAttributes |
getAttributes() |
java.io.InputStream |
getContents()
Creates an
InputStream , which may be used to read
the files contents. |
java.io.File |
getFile()
Returns the resource file.
|
long |
getLastModified()
Returns the date, when the resource was last modified, if known.
|
static java.lang.String |
getName(java.io.File file) |
private static ContentSupplier |
getRootContentSupplier(java.io.File file) |
long |
getSize()
Returns the resources size, if known.
|
java.net.URL |
getURL()
Returns an
URL , which may be used to reference the
resource, if possible. |
boolean |
isDirectory()
Returns, whether the
FileInfo refers to a directory. |
boolean |
isExisting()
Returns, whether the resource exists.
|
boolean |
isFile()
Returns, whether the
FileInfo refers to a file. |
boolean |
isSymbolicLink()
Returns, whether the
FileInfo refers to a symlink. |
getName
@Nonnull private final java.io.File file
@Nonnull private final PlexusIoResourceAttributes attributes
private final ContentSupplier contentSupplier
private final org.apache.commons.io.output.DeferredFileOutputStream dfos
private static final InputStreamTransformer identityTransformer
protected PlexusIoFileResource(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull PlexusIoResourceAttributes attrs) throws java.io.IOException
java.io.IOException
PlexusIoFileResource(@Nonnull java.io.File file, @Nonnull java.lang.String name, @Nonnull PlexusIoResourceAttributes attrs, ContentSupplier contentSupplier, InputStreamTransformer streamTransformer) throws java.io.IOException
java.io.IOException
private static org.apache.commons.io.output.DeferredFileOutputStream asDeferredStream(@Nonnull ContentSupplier supplier, @Nonnull InputStreamTransformer transToUse, PlexusIoResource resource) throws java.io.IOException
java.io.IOException
private static ContentSupplier getRootContentSupplier(java.io.File file)
public static java.lang.String getName(java.io.File file)
@Nonnull public java.io.File getFile()
getFile
in interface FileSupplier
@Nonnull public java.io.InputStream getContents() throws java.io.IOException
PlexusIoResource
InputStream
, 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+).getContents
in interface FileInfo
getContents
in interface ContentSupplier
getContents
in interface PlexusIoResource
java.io.IOException
@Nonnull public java.net.URL getURL() throws java.io.IOException
PlexusIoResource
URL
, which may be used to reference the
resource, if possible.getURL
in interface PlexusIoResource
PlexusIoResource.getContents()
.java.io.IOException
public long getSize()
PlexusIoResource
PlexusIoResource.UNKNOWN_RESOURCE_SIZE
.getSize
in interface SizeSupplier
getSize
in interface PlexusIoResource
getSize
in class AbstractPlexusIoResource
public boolean isDirectory()
PlexusIoResource
FileInfo
refers to a directory.isDirectory
in interface FileInfo
isDirectory
in interface PlexusIoResource
isDirectory
in class AbstractPlexusIoResource
public boolean isExisting()
PlexusIoResource
isExisting
in interface PlexusIoResource
isExisting
in class AbstractPlexusIoResource
public boolean isFile()
PlexusIoResource
FileInfo
refers to a file.isFile
in interface FileInfo
isFile
in interface PlexusIoResource
isFile
in class AbstractPlexusIoResource
@Nonnull public PlexusIoResourceAttributes getAttributes()
getAttributes
in interface ResourceAttributeSupplier
public long getLastModified()
PlexusIoResource
PlexusIoResource.UNKNOWN_MODIFICATION_DATE
.getLastModified
in interface PlexusIoResource
getLastModified
in class AbstractPlexusIoResource
File.lastModified()
public boolean isSymbolicLink()
FileInfo
FileInfo
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.isSymbolicLink
in interface FileInfo
isSymbolicLink
in class AbstractPlexusIoResource