Package org.pentaho.di.core.vfs
Class KettleVFS
- java.lang.Object
-
- org.pentaho.di.core.vfs.KettleVFS
-
public class KettleVFS extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKettleVFS.Suffix
-
Field Summary
Fields Modifier and Type Field Description static StringCONNECTIONstatic StringTEMP_DIR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringcleanseFilename(String vfsFilename)Private method for stripping password from filename when a FileObject can not be obtained.static voidcloseEmbeddedFileSystem(String embeddedMetastoreKey)static org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, String suffix, String directory)static org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, String suffix, String directory, VariableSpace space)static org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, KettleVFS.Suffix suffix)Creates a file using "java.io.tmpdir" directorystatic org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, KettleVFS.Suffix suffix, String directory)static org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, KettleVFS.Suffix suffix, String directory, VariableSpace space)static org.apache.commons.vfs2.FileObjectcreateTempFile(String prefix, KettleVFS.Suffix suffix, VariableSpace variableSpace)Creates a file using "java.io.tmpdir" directorystatic booleanfileExists(String vfsFilename)static booleanfileExists(String vfsFilename, VariableSpace space)static voidfreeUnusedResources()static Comparator<org.apache.commons.vfs2.FileObject>getComparator()static FileInputStreamgetFileInputStream(org.apache.commons.vfs2.FileObject fileObject)Deprecated.because of API change in Apache VFS.static StringgetFilename(org.apache.commons.vfs2.FileObject fileObject)static org.apache.commons.vfs2.FileObjectgetFileObject(String vfsFilename)static org.apache.commons.vfs2.FileObjectgetFileObject(String vfsFilename, org.apache.commons.vfs2.FileSystemOptions fsOptions)static org.apache.commons.vfs2.FileObjectgetFileObject(String vfsFilename, VariableSpace space)static org.apache.commons.vfs2.FileObjectgetFileObject(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions)org.apache.commons.vfs2.FileSystemManagergetFileSystemManager()static StringgetFriendlyURI(String filename)static StringgetFriendlyURI(org.apache.commons.vfs2.FileObject fileObject)static InputStreamgetInputStream(String vfsFilename)static InputStreamgetInputStream(String vfsFilename, VariableSpace space)static InputStreamgetInputStream(org.apache.commons.vfs2.FileObject fileObject)static KettleVFSgetInstance()static OutputStreamgetOutputStream(String vfsFilename, boolean append)static OutputStreamgetOutputStream(String vfsFilename, VariableSpace space, boolean append)static OutputStreamgetOutputStream(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions, boolean append)static OutputStreamgetOutputStream(org.apache.commons.vfs2.FileObject fileObject, boolean append)static StringgetTextFileContent(String vfsFilename, String charSetName)Read a text file (like an XML document).static StringgetTextFileContent(String vfsFilename, VariableSpace space, String charSetName)protected static booleanhasSchemePattern(String path, String patternString)protected static StringnormalizePath(String path, String scheme)voidreset()static booleanstartsWithScheme(String vfsFileName)Check if filename starts with one of the known protocols like file: zip: ram: smb: jar: etc.
-
-
-
Field Detail
-
TEMP_DIR
public static final String TEMP_DIR
-
CONNECTION
public static final String CONNECTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getFileSystemManager
public org.apache.commons.vfs2.FileSystemManager getFileSystemManager()
-
getInstance
public static KettleVFS getInstance()
-
getFileObject
public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename) throws KettleFileException
- Throws:
KettleFileException
-
getFileObject
public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, VariableSpace space) throws KettleFileException
- Throws:
KettleFileException
-
getFileObject
public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, org.apache.commons.vfs2.FileSystemOptions fsOptions) throws KettleFileException
- Throws:
KettleFileException
-
getFileObject
public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions) throws KettleFileException
- Throws:
KettleFileException
-
cleanseFilename
public static String cleanseFilename(String vfsFilename)
Private method for stripping password from filename when a FileObject can not be obtained. getFriendlyURI(FileObject) or getFriendlyURI(String) are the public methods.
-
getTextFileContent
public static String getTextFileContent(String vfsFilename, String charSetName) throws KettleFileException
Read a text file (like an XML document). WARNING DO NOT USE FOR DATA FILES.- Parameters:
vfsFilename- the filename or URL to read fromcharSetName- the character set of the string (UTF-8, ISO8859-1, etc)- Returns:
- The content of the file as a String
- Throws:
IOExceptionKettleFileException
-
getTextFileContent
public static String getTextFileContent(String vfsFilename, VariableSpace space, String charSetName) throws KettleFileException
- Throws:
KettleFileException
-
fileExists
public static boolean fileExists(String vfsFilename) throws KettleFileException
- Throws:
KettleFileException
-
fileExists
public static boolean fileExists(String vfsFilename, VariableSpace space) throws KettleFileException
- Throws:
KettleFileException
-
getInputStream
public static InputStream getInputStream(org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
- Throws:
org.apache.commons.vfs2.FileSystemException
-
getInputStream
public static InputStream getInputStream(String vfsFilename) throws KettleFileException
- Throws:
KettleFileException
-
getInputStream
public static InputStream getInputStream(String vfsFilename, VariableSpace space) throws KettleFileException
- Throws:
KettleFileException
-
getOutputStream
public static OutputStream getOutputStream(org.apache.commons.vfs2.FileObject fileObject, boolean append) throws IOException
- Throws:
IOException
-
getOutputStream
public static OutputStream getOutputStream(String vfsFilename, boolean append) throws KettleFileException
- Throws:
KettleFileException
-
getOutputStream
public static OutputStream getOutputStream(String vfsFilename, VariableSpace space, boolean append) throws KettleFileException
- Throws:
KettleFileException
-
getOutputStream
public static OutputStream getOutputStream(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions, boolean append) throws KettleFileException
- Throws:
KettleFileException
-
getFilename
public static String getFilename(org.apache.commons.vfs2.FileObject fileObject)
-
getFriendlyURI
public static String getFriendlyURI(org.apache.commons.vfs2.FileObject fileObject)
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix) throws KettleFileException
Creates a file using "java.io.tmpdir" directory- Parameters:
prefix- - file nameprefix- - file extension- Returns:
- FileObject
- Throws:
KettleFileException
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, VariableSpace variableSpace) throws KettleFileException
Creates a file using "java.io.tmpdir" directory- Parameters:
prefix- - file namesuffix- - file extensionvariableSpace- is used to get system variables- Returns:
- FileObject
- Throws:
KettleFileException
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, String directory) throws KettleFileException
- Parameters:
prefix- - file namesuffix- - file extensiondirectory- - directory where file will be created- Returns:
- FileObject
- Throws:
KettleFileException
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, String suffix, String directory) throws KettleFileException
- Throws:
KettleFileException
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, String directory, VariableSpace space) throws KettleFileException
- Parameters:
prefix- - file namedirectory- path to directory where file will be createdspace- is used to get system variables- Returns:
- FileObject
- Throws:
KettleFileException
-
createTempFile
public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, String suffix, String directory, VariableSpace space) throws KettleFileException
- Throws:
KettleFileException
-
getComparator
public static Comparator<org.apache.commons.vfs2.FileObject> getComparator()
-
getFileInputStream
@Deprecated public static FileInputStream getFileInputStream(org.apache.commons.vfs2.FileObject fileObject) throws IOException
Deprecated.because of API change in Apache VFS. As a workaround use FileObject.getName().getPathDecoded(); Then use a regular File() object to create a File Input stream.Get a FileInputStream for a local file. Local files can be read with NIO.- Parameters:
fileObject-- Returns:
- a FileInputStream
- Throws:
IOException
-
startsWithScheme
public static boolean startsWithScheme(String vfsFileName)
Check if filename starts with one of the known protocols like file: zip: ram: smb: jar: etc. If yes, return true otherwise return false- Parameters:
vfsFileName-- Returns:
- boolean
-
closeEmbeddedFileSystem
public static void closeEmbeddedFileSystem(String embeddedMetastoreKey)
-
reset
public void reset()
-
freeUnusedResources
public static void freeUnusedResources()
- See Also:
DefaultFileSystemManager.freeUnusedResources()
-
-