Class LocalFile
java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.file.LocalFile
- All Implemented Interfaces:
DataExceptionContributor,JsonSerializable,RecordSerializable,XmlSerializable,Serializable
- Direct Known Subclasses:
LocalFileSink,LocalFileSource
Base class for the
FileSource and FileSink implementations backed by a file on the local file system.- See Also:
-
Field Summary
Fields inherited from interface com.northconcepts.datapipeline.core.RecordSerializable
SERIALIZED_CLASS_NAME, TYPEFields inherited from interface com.northconcepts.datapipeline.core.XmlSerializable
XML_SERIALIZED_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDetects the file type from the file's extension or content, replacing any type already set.fromRecord(Record source) Loads this instance's state from a record and returnsthis(for fluid API call chaining).fromXmlElement(Element element) Returns null since no content type is tracked for local files.getFile()Returns the absolute file for the path; throws an exception if the path is empty.longReturns the length of the file in bytes, or 0 if it does not exist.Returns the file type, detecting it from the file's extension or content if it was not set.getName()getPath()Returns the path of the local file; a relative path is resolved against the current working directory.Returns the path as afile://URL, with forward slashes and a leading slash added.booleanisLocal()setFileType(FileType fileType) Sets the file type, which is otherwise detected from the file's extension or content.Sets the name to the file name at the end of the path.Sets the path of the local file, clearing the cached file and detected file type.toRecord()Converts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.toXmlElement(Document document) Returns an element, created withdocument, describing this object; the default implementation throws aDataException.Methods inherited from class com.northconcepts.datapipeline.foundations.core.Bean
addExceptionProperties, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.northconcepts.datapipeline.core.DataExceptionContributor
addExceptionProperties, exception, exception, exception
-
Constructor Details
-
LocalFile
public LocalFile()
-
-
Method Details
-
getName
-
setName
-
getPath
Returns the path of the local file; a relative path is resolved against the current working directory. -
setPath
Sets the path of the local file, clearing the cached file and detected file type. -
getFile
Returns the absolute file for the path; throws an exception if the path is empty. -
setNameFromPath
Sets the name to the file name at the end of the path. -
getFileType
Returns the file type, detecting it from the file's extension or content if it was not set. -
setFileType
Sets the file type, which is otherwise detected from the file's extension or content. -
detectFileType
Detects the file type from the file's extension or content, replacing any type already set. -
getUrlPath
Returns the path as afile://URL, with forward slashes and a leading slash added. -
isLocal
public boolean isLocal() -
getFileSize
public long getFileSize()Returns the length of the file in bytes, or 0 if it does not exist. -
getContentType
Returns null since no content type is tracked for local files. -
toRecord
Description copied from interface:RecordSerializableConverts this object's state to a record thatRecordSerializable.fromRecord(Record)can load.- Specified by:
toRecordin interfaceRecordSerializable- Overrides:
toRecordin classBean
-
fromRecord
Description copied from interface:RecordSerializableLoads this instance's state from a record and returnsthis(for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.- Specified by:
fromRecordin interfaceRecordSerializable- Overrides:
fromRecordin classBean- Parameters:
source-- Returns:
- this instance.
-
toXmlElement
Description copied from interface:XmlSerializableReturns an element, created withdocument, describing this object; the default implementation throws aDataException. -
fromXmlElement
-