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

public abstract class LocalFile extends Bean
Base class for the FileSource and FileSink implementations backed by a file on the local file system.
See Also:
  • Constructor Details

    • LocalFile

      public LocalFile()
  • Method Details

    • getName

      public String getName()
    • setName

      public LocalFile setName(String name)
    • getPath

      public String getPath()
      Returns the path of the local file; a relative path is resolved against the current working directory.
    • setPath

      public LocalFile setPath(String path)
      Sets the path of the local file, clearing the cached file and detected file type.
    • getFile

      public File getFile()
      Returns the absolute file for the path; throws an exception if the path is empty.
    • setNameFromPath

      public LocalFile setNameFromPath()
      Sets the name to the file name at the end of the path.
    • getFileType

      public FileType getFileType()
      Returns the file type, detecting it from the file's extension or content if it was not set.
    • setFileType

      public LocalFile setFileType(FileType fileType)
      Sets the file type, which is otherwise detected from the file's extension or content.
    • detectFileType

      public LocalFile detectFileType()
      Detects the file type from the file's extension or content, replacing any type already set.
    • getUrlPath

      public String getUrlPath()
      Returns the path as a file:// 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

      public String getContentType()
      Returns null since no content type is tracked for local files.
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public LocalFile fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
    • fromXmlElement

      public LocalFile fromXmlElement(Element element)