public class FileObject
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
asBytes
If true the contents can only be stored as a list of bytes.
|
protected java.lang.String |
classType
This defines the class type
|
protected java.lang.Object |
fileContents
The file contents
|
protected java.lang.String |
filePath
This define the file path
|
protected java.lang.String |
password
Password of either type to protect processing on a remote service, for example.
|
Constructor and Description |
---|
FileObject()
Creates a new instance of FileObject
|
Modifier and Type | Method and Description |
---|---|
boolean |
addFileContents(java.lang.Object theFileContents)
Add the object passed in to the end of the file contents.
|
static java.io.File |
checkFileType(java.io.File theFile,
java.lang.String type)
Check the file type to make sure it is in the file name.
|
static java.lang.String |
contentTypeFromCode(java.lang.String bodyStr)
Get the html content file type description from the content itself.
|
static java.lang.String |
contentTypeFromFile(java.lang.String fileName)
Get the html content file type description from the file path.
|
static void |
copyStream(java.io.File sourceFile,
java.io.File destFile)
Copy the source input stream contents to the destination file.
|
static ByteArray |
fileToByteArray(java.lang.String filePath)
Copy the source input stream contents to a list of Byte objects.
|
static java.util.ArrayList<java.lang.String> |
getAllJarFilePaths(java.lang.String jarFile,
java.lang.String serverIp)
Get the list of all required jar files for a particular jar class.
|
boolean |
getAsBytes()
Get a value indicating that the file contents can only be stored as a byte list.
|
java.lang.String |
getClassType()
Get the class type this file relates to.
|
static java.lang.String |
getCurrentDirectory()
Get the current directory the program is running in.
|
static java.util.ArrayList<java.lang.String> |
getDirectoryList(java.lang.String dirPath)
Get the list of directories stored in the specified directory.
|
java.lang.Object |
getFileContents()
Get the contents of the file.
|
static java.util.ArrayList<java.lang.String> |
getFileList(java.lang.String dirPath)
Get the list of files stored in the specified directory.
|
java.lang.String |
getFilePath()
Get the file path.
|
static java.lang.String |
getFileType(java.lang.String fileName)
Get the file type.
|
static java.util.ArrayList<java.lang.String> |
getFullFileListPaths(java.lang.String dirPath)
Get the list of files stored in the specified directory.
|
static java.util.ArrayList<java.lang.String> |
getFullFileListPaths(java.lang.String dirPath,
boolean subFolders)
Get the list of files stored in the specified directory.
|
java.lang.String |
getPassword()
Get the security password.
|
static boolean |
isBinaryFile(java.lang.String fileName)
Return true if the file is binary, requiring a byte list.
|
static boolean |
isHtmlFile(java.lang.String fileName)
Return true if the file path ends with a known internet file type.
|
static boolean |
isImageFile(java.lang.String fileName)
Return true if the file path ends with a known image file type.
|
static boolean |
isKnownApplicationType(java.lang.String dataType)
Return true if the data type is a known application type, for example 'Application/pdf', etc..
|
static boolean |
isKnownBinaryType(java.lang.String dataType)
Return true if the data type is a known binary type, for example 'image,png',
or 'Application/pdf', etc.
|
static boolean |
isKnownDataType(java.lang.String dataType)
Return true if the data type is known, for example 'text/html', or 'image,png', etc.
|
static boolean |
isKnownFile(java.lang.String fileName)
Return true if the file path end with a known file type.
|
static boolean |
isKnownHtmlType(java.lang.String dataType)
Return true if the data type is a known html type, for example 'text/xhtml', etc.
|
static boolean |
isKnownImageType(java.lang.String dataType)
Return true if the data type is a known image type, for example 'image,png', etc..
|
static boolean |
isKnownTextType(java.lang.String dataType)
Return true if the data type is a known text type, for example 'text/html', etc.
|
static boolean |
isKnownXmlType(java.lang.String dataType)
Return true if the data type is a known xml type, for example 'text/xml', etc.
|
static boolean |
isTextFile(java.lang.String fileName)
Return true if the file path ends with a known text file type.
|
static boolean |
isXmlFile(java.lang.String fileName)
Return true if the file path ends with a known xml file type.
|
void |
loadFile(java.lang.String theFilePath)
Load the contents of the file specified by the path into an appropriate data structure.
|
static java.lang.String |
removeFileType(java.lang.String fileName)
Remove the file type from the file name.
|
void |
setAsBytes(boolean thisAsBytes)
Set a value indicating that the file contents can only be stored as a byte
list and not in any other form.
|
void |
setClassType(java.lang.String theClassType)
Set the class type this file relates to.
|
void |
setFileContents(java.lang.Object theFileContents)
Set the contents of this file to the value passed in.
|
void |
setFilePath(java.lang.String theFilePath)
Set the file path to the value passed in.
|
void |
setPassword(java.lang.String thePassword)
Set the security password.
|
java.lang.String |
toString()
Return a String description of this object.
|
protected boolean |
useAsXmlFile(java.lang.String fileName)
Return true if an xml file representation should be used.
|
protected java.lang.String filePath
protected java.lang.String classType
protected java.lang.Object fileContents
protected boolean asBytes
protected java.lang.String password
public void setAsBytes(boolean thisAsBytes)
thisAsBytes
- true if the file contents can only be stored as a byte list.public boolean getAsBytes()
public void setFilePath(java.lang.String theFilePath)
theFilePath
- the file path.public java.lang.String getFilePath()
public void setClassType(java.lang.String theClassType)
theClassType
- the class type.public java.lang.String getClassType()
public void setPassword(java.lang.String thePassword)
thePassword
- the security password.public java.lang.String getPassword()
public void setFileContents(java.lang.Object theFileContents)
theFileContents
- the file contents.public boolean addFileContents(java.lang.Object theFileContents)
theFileContents
- can be either a String or a ArrayList of Bytes.public java.lang.Object getFileContents()
public static boolean isKnownDataType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownTextType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownHtmlType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownXmlType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownBinaryType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownImageType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownApplicationType(java.lang.String dataType)
dataType
- the data type, usually for a browser realisation.public static boolean isKnownFile(java.lang.String fileName)
fileName
- the file name or full file path.public static boolean isTextFile(java.lang.String fileName)
fileName
- the file name or full file path.public static boolean isBinaryFile(java.lang.String fileName)
fileName
- the file path or name.public static boolean isXmlFile(java.lang.String fileName)
fileName
- the file name or full file path.public static boolean isImageFile(java.lang.String fileName)
fileName
- the file name or full file path.public static boolean isHtmlFile(java.lang.String fileName)
fileName
- the file name or full file path.protected boolean useAsXmlFile(java.lang.String fileName)
fileName
- the file path or name.public static java.lang.String getFileType(java.lang.String fileName)
fileName
- the file name or full file path.public static java.lang.String removeFileType(java.lang.String fileName)
fileName
- the file name or full file path.public static java.lang.String contentTypeFromFile(java.lang.String fileName)
fileName
- the file name or full file path.public static java.lang.String contentTypeFromCode(java.lang.String bodyStr)
bodyStr
- the file content as a string.public void loadFile(java.lang.String theFilePath) throws java.lang.Exception
theFilePath
- the local path of the file to load.java.lang.Exception
- any error.public static ByteArray fileToByteArray(java.lang.String filePath)
filePath
- the file path in string format.public static void copyStream(java.io.File sourceFile, java.io.File destFile) throws java.lang.Exception
sourceFile
- the file to copy.destFile
- the file path to copy tojava.lang.Exception
- any error.public static java.lang.String getCurrentDirectory() throws java.lang.Exception
java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getDirectoryList(java.lang.String dirPath)
dirPath
- the directory path.public static java.util.ArrayList<java.lang.String> getFileList(java.lang.String dirPath) throws java.lang.Exception
dirPath
- the directory path.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getFullFileListPaths(java.lang.String dirPath) throws java.lang.Exception
dirPath
- the directory path.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getFullFileListPaths(java.lang.String dirPath, boolean subFolders) throws java.lang.Exception
dirPath
- the directory path.subFolders
- if true include all files in all sub-folders, if false include
files in the current folder only.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getAllJarFilePaths(java.lang.String jarFile, java.lang.String serverIp) throws java.lang.Exception
jarFile
- the path for the base jar file.serverIp
- the server ip address.java.lang.Exception
- any error.public static java.io.File checkFileType(java.io.File theFile, java.lang.String type)
theFile
- the file object with the full file path.type
- the file type that should be indicated.public java.lang.String toString()
toString
in class java.lang.Object