org.drools.io.impl
Class FileSystemResource

java.lang.Object
  extended by org.drools.io.impl.BaseResource
      extended by org.drools.io.impl.FileSystemResource
All Implemented Interfaces:
Externalizable, Serializable, InternalResource, org.drools.io.Resource

public class FileSystemResource
extends BaseResource
implements InternalResource, Externalizable

Borrowed gratuitously from Spring under ASL2.0.

See Also:
Serialized Form

Constructor Summary
FileSystemResource()
           
FileSystemResource(File file)
          Create a new FileSystemResource from a File handle.
FileSystemResource(String path)
          Create a new FileSystemResource from a file path.
 
Method Summary
 boolean equals(Object object)
           
 File getFile()
           
 InputStream getInputStream()
          This implementation opens a FileInputStream for the underlying file.
 long getLastModified()
           
 long getLastRead()
           
 Reader getReader()
           
 URL getURL()
          This implementation returns a URL for the underlying file.
 int hashCode()
           
 boolean hasURL()
           
 boolean isDirectory()
           
 Collection<org.drools.io.Resource> listResources()
           
 void readExternal(ObjectInput in)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.io.impl.BaseResource
getConfiguration, getResourceType, setConfiguration, setResourceType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.io.internal.InternalResource
getConfiguration, getResourceType, setConfiguration, setResourceType
 

Constructor Detail

FileSystemResource

public FileSystemResource()

FileSystemResource

public FileSystemResource(File file)
Create a new FileSystemResource from a File handle.

Note: When building relative resources via #createRelative, the relative path will apply at the same directory level: e.g. new File("C:/dir1"), relative path "dir2" -> "C:/dir2"! If you prefer to have relative paths built underneath the given root directory, use the constructor with a file path to append a trailing slash to the root path: "C:/dir1/", which indicates this directory as root for all relative paths.

Parameters:
file - a File handle

FileSystemResource

public FileSystemResource(String path)
Create a new FileSystemResource from a file path.

Note: When building relative resources via #createRelative, it makes a difference whether the specified resource base path here ends with a slash or not. In the case of "C:/dir1/", relative paths will be built underneath that root: e.g. relative path "dir2" -> "C:/dir1/dir2". In the case of "C:/dir1", relative paths will apply at the same directory level: relative path "dir2" -> "C:/dir2".

Parameters:
path - a file path
Method Detail

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

getInputStream

public InputStream getInputStream()
                           throws IOException
This implementation opens a FileInputStream for the underlying file.

Specified by:
getInputStream in interface org.drools.io.Resource
Throws:
IOException
See Also:
FileInputStream

getReader

public Reader getReader()
                 throws IOException
Specified by:
getReader in interface org.drools.io.Resource
Throws:
IOException

getFile

public File getFile()

isDirectory

public boolean isDirectory()
Specified by:
isDirectory in interface InternalResource

listResources

public Collection<org.drools.io.Resource> listResources()
Specified by:
listResources in interface InternalResource

getURL

public URL getURL()
           throws IOException
This implementation returns a URL for the underlying file.

Specified by:
getURL in interface InternalResource
Throws:
IOException
See Also:
File.toURI()

hasURL

public boolean hasURL()
Specified by:
hasURL in interface InternalResource

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface InternalResource

getLastRead

public long getLastRead()
Specified by:
getLastRead in interface InternalResource

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.