Class FileSystemResource
- java.lang.Object
-
- org.drools.core.io.impl.BaseResource
-
- org.drools.core.io.impl.FileSystemResource
-
- All Implemented Interfaces:
Externalizable
,Serializable
,InternalResource
,org.kie.api.io.Resource
public class FileSystemResource extends BaseResource implements InternalResource, Externalizable
Borrowed gratuitously from Spring under ASL2.0.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.drools.core.io.impl.BaseResource
bytes
-
-
Constructor Summary
Constructors Constructor Description FileSystemResource()
FileSystemResource(File file)
Create a new FileSystemResource from a File handle.FileSystemResource(File file, String encoding)
FileSystemResource(String path)
Create a new FileSystemResource from a file path.FileSystemResource(String path, String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
String
getEncoding()
File
getFile()
InputStream
getInputStream()
This implementation opens a FileInputStream for the underlying file.Reader
getReader()
URL
getURL()
This implementation returns a URL for the underlying file.int
hashCode()
boolean
hasURL()
boolean
isDirectory()
Collection<org.kie.api.io.Resource>
listResources()
void
readExternal(ObjectInput in)
String
toString()
void
writeExternal(ObjectOutput out)
-
Methods inherited from class org.drools.core.io.impl.BaseResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, getSourcePath, getTargetPath, setCategories, setConfiguration, setDescription, setResourceType, setSourcePath, setTargetPath
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.io.internal.InternalResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, setCategories, setConfiguration, setDescription, 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 theconstructor 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 interfaceExternalizable
- Overrides:
writeExternal
in classBaseResource
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classBaseResource
- Throws:
IOException
ClassNotFoundException
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceInternalResource
-
getInputStream
public InputStream getInputStream() throws IOException
This implementation opens a FileInputStream for the underlying file.- Specified by:
getInputStream
in interfaceorg.kie.api.io.Resource
- Throws:
IOException
- See Also:
FileInputStream
-
getReader
public Reader getReader() throws IOException
- Specified by:
getReader
in interfaceorg.kie.api.io.Resource
- Throws:
IOException
-
getFile
public File getFile()
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory
in interfaceInternalResource
-
listResources
public Collection<org.kie.api.io.Resource> listResources()
- Specified by:
listResources
in interfaceInternalResource
-
getURL
public URL getURL() throws IOException
This implementation returns a URL for the underlying file.- Specified by:
getURL
in interfaceInternalResource
- Throws:
IOException
- See Also:
File.toURI()
-
hasURL
public boolean hasURL()
- Specified by:
hasURL
in interfaceInternalResource
-
toString
public String toString()
- Overrides:
toString
in classBaseResource
-
equals
public boolean equals(Object object)
- Overrides:
equals
in classBaseResource
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseResource
-
-