java.lang.Object
org.apache.tika.pipes.core.extractor.frictionless.DataPackage

public class DataPackage extends Object
Represents a Frictionless Data Package manifest (datapackage.json). See: https://specs.frictionlessdata.io/data-package/ The Data Package format is a simple standard for packaging data with metadata. This implementation includes: - name: identifier for the package (typically the container filename) - created: ISO 8601 timestamp of when the package was created - resources: list of data files with path, mediatype, bytes, and hash
  • Constructor Details

    • DataPackage

      public DataPackage(String name)
      Creates a new DataPackage with the given name and current timestamp.
      Parameters:
      name - the package name (typically container filename)
    • DataPackage

      public DataPackage()
      Creates an empty DataPackage for deserialization.
  • Method Details

    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getCreated

      public String getCreated()
    • setCreated

      public void setCreated(String created)
    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • getDescription

      public String getDescription()
    • setDescription

      public void setDescription(String description)
    • getResources

      public List<FrictionlessResource> getResources()
    • setResources

      public void setResources(List<FrictionlessResource> resources)
    • addResource

      public void addResource(FrictionlessResource resource)
      Adds a resource to this data package.
      Parameters:
      resource - the resource to add
    • addResource

      public void addResource(String path, String mediatype, long bytes, String hash, String name)
      Adds a resource to this data package with all parameters.
      Parameters:
      path - relative path within package
      mediatype - MIME type
      bytes - file size
      hash - SHA256 hash with "sha256:" prefix
      name - optional original filename
    • toJson

      public String toJson() throws IOException
      Serializes this DataPackage to JSON.
      Returns:
      JSON string representation
      Throws:
      IOException - if serialization fails
    • writeTo

      public void writeTo(OutputStream outputStream) throws IOException
      Writes this DataPackage as JSON to the given output stream. Does not close the output stream.
      Parameters:
      outputStream - the stream to write to
      Throws:
      IOException - if serialization fails
    • fromJson

      public static DataPackage fromJson(String json) throws IOException
      Parses a DataPackage from JSON string.
      Parameters:
      json - the JSON string
      Returns:
      parsed DataPackage
      Throws:
      IOException - if parsing fails
    • hasResources

      public boolean hasResources()
      Returns true if this package has any resources.
      Returns:
      true if resources list is not empty
    • resourceCount

      public int resourceCount()
      Returns the number of resources in this package.
      Returns:
      resource count
    • toString

      public String toString()
      Overrides:
      toString in class Object