org.codehaus.plexus.components.io.resources
Class PlexusIoFileResource

java.lang.Object
  extended byorg.codehaus.plexus.components.io.resources.PlexusIoFileResource
All Implemented Interfaces:
FileInfo, PlexusIoResource, PlexusIoResourceWithAttributes

public class PlexusIoFileResource
extends java.lang.Object
implements PlexusIoResourceWithAttributes

Implementation of PlexusIoResource for files.


Field Summary
 
Fields inherited from interface org.codehaus.plexus.components.io.resources.PlexusIoResource
UNKNOWN_MODIFICATION_DATE, UNKNOWN_RESOURCE_SIZE
 
Constructor Summary
PlexusIoFileResource()
          Creates a new instance.
PlexusIoFileResource(java.io.File file)
          Creates a new instance.
PlexusIoFileResource(java.io.File file, PlexusIoResourceAttributes attrs)
          Creates a new instance.
PlexusIoFileResource(java.io.File file, java.lang.String name)
          Creates a new instance.
PlexusIoFileResource(java.io.File file, java.lang.String name, PlexusIoResourceAttributes attrs)
           
 
Method Summary
 PlexusIoResourceAttributes getAttributes()
           
 java.io.InputStream getContents()
          Creates an InputStream, which may be used to read the files contents.
 java.io.File getFile()
          Returns the resources file.
 long getLastModified()
          Returns the date, when the resource was last modified, if known.
 java.lang.String getName()
          Returns the resources name, which may include path components, like directory names, or something like that.
 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.
 void setAttributes(PlexusIoResourceAttributes attributes)
           
 void setFile(java.io.File file)
          Sets the resources file.
 void setName(java.lang.String name)
          Sets the resources name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlexusIoFileResource

public PlexusIoFileResource()
Creates a new instance.


PlexusIoFileResource

public PlexusIoFileResource(java.io.File file)
Creates a new instance.


PlexusIoFileResource

public PlexusIoFileResource(java.io.File file,
                            PlexusIoResourceAttributes attrs)
Creates a new instance.


PlexusIoFileResource

public PlexusIoFileResource(java.io.File file,
                            java.lang.String name)
Creates a new instance.


PlexusIoFileResource

public PlexusIoFileResource(java.io.File file,
                            java.lang.String name,
                            PlexusIoResourceAttributes attrs)
Method Detail

setFile

public void setFile(java.io.File file)
Sets the resources file.


getFile

public java.io.File getFile()
Returns the resources file.


setName

public void setName(java.lang.String name)
Sets the resources name.


getName

public java.lang.String getName()
Description copied from interface: FileInfo
Returns the resources name, which may include path components, like directory names, or something like that. The resources name is expected to be a relative name and the path components must be separated by File.pathSeparator

Specified by:
getName in interface FileInfo

getLastModified

public long getLastModified()
Description copied from interface: PlexusIoResource
Returns the date, when the resource was last modified, if known. Otherwise, returns PlexusIoResource.UNKNOWN_MODIFICATION_DATE.

Specified by:
getLastModified in interface PlexusIoResource
See Also:
File.lastModified()

isFile

public boolean isFile()
Description copied from interface: FileInfo
Returns, whether the FileInfo refers to a file.

Specified by:
isFile in interface FileInfo

isDirectory

public boolean isDirectory()
Description copied from interface: FileInfo
Returns, whether the FileInfo refers to a directory.

Specified by:
isDirectory in interface FileInfo

isExisting

public boolean isExisting()
Description copied from interface: PlexusIoResource
Returns, whether the resource exists.

Specified by:
isExisting in interface PlexusIoResource

getSize

public long getSize()
Description copied from interface: PlexusIoResource
Returns the resources size, if known. Otherwise returns PlexusIoResource.UNKNOWN_RESOURCE_SIZE.

Specified by:
getSize in interface PlexusIoResource

getContents

public java.io.InputStream getContents()
                                throws java.io.IOException
Description copied from interface: FileInfo
Creates an 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.

Specified by:
getContents in interface FileInfo
Throws:
java.io.IOException

getURL

public java.net.URL getURL()
                    throws java.io.IOException
Description copied from interface: PlexusIoResource
Returns an URL, which may be used to reference the resource, if possible.

Specified by:
getURL in interface PlexusIoResource
Returns:
An URL referencing the resource, if possible, or null. In the latter case, you are forced to use #getInputStream().
Throws:
java.io.IOException

getAttributes

public PlexusIoResourceAttributes getAttributes()
Specified by:
getAttributes in interface PlexusIoResourceWithAttributes

setAttributes

public void setAttributes(PlexusIoResourceAttributes attributes)
Specified by:
setAttributes in interface PlexusIoResourceWithAttributes


Copyright © 2001-2008 Codehaus. All Rights Reserved.