Class FileResourceReference

java.lang.Object
org.apache.nifi.components.resource.FileResourceReference
All Implemented Interfaces:
ResourceReference

public class FileResourceReference extends Object implements ResourceReference
  • Field Details

    • file

      private final File file
    • resourceType

      private final ResourceType resourceType
  • Constructor Details

    • FileResourceReference

      public FileResourceReference(File file)
  • Method Details

    • asFile

      public File asFile()
      Specified by:
      asFile in interface ResourceReference
      Returns:
      a file representation of the resource, or null if the Resource cannot be represented as a File
    • asURL

      public URL asURL()
      Specified by:
      asURL in interface ResourceReference
      Returns:
      a URL representation of the resource, or null if the Resource cannot be represented as a URL
    • read

      public InputStream read() throws IOException
      Specified by:
      read in interface ResourceReference
      Returns:
      an InputStream to read the contents of the resource
      Throws:
      IOException - if unable to obtain an InputStream from the resource
    • isAccessible

      public boolean isAccessible()
      Description copied from interface: ResourceReference
      Indicates whether or not the resource is accessible. What it means for the resource to be accessible depends on the type of resource. A File resource, for example, might be accessible only if the file exists and is readable, while a URL resource might always be considered accessible, or might be accesssible only if the existence of the resource can be confirmed.
      Specified by:
      isAccessible in interface ResourceReference
      Returns:
      true if the file can be accessed, false otherwise
    • getLocation

      public String getLocation()
      Specified by:
      getLocation in interface ResourceReference
      Returns:
      a String representation of the location, or null for a Resource that does not have an external location. For a File or a Directory, this will be the full path name; for a URL it will be the String form of the URL
    • getResourceType

      public ResourceType getResourceType()
      Specified by:
      getResourceType in interface ResourceReference
      Returns:
      the type of resource that is being referenced
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object