Class ContentReference

java.lang.Object
org.deltafi.common.content.ContentReference

public class ContentReference extends Object
  • Constructor Details

    • ContentReference

      public ContentReference(String mediaType, Segment... segments)
    • ContentReference

      public ContentReference(String mediaType, List<Segment> segments, long ignored)
      Provide an all-args constructor including size, which is a field in graphql but not on the object
      Parameters:
      mediaType - mediaType
      segments - segments
      ignored - placeholder for size
  • Method Details

    • setSize

      public void setSize(long ignored)
      Empty method in place for object mappers trying to set the size from JSON
      Parameters:
      ignored - ignored field
    • getSize

      public long getSize()
      Calculate size of all the segments
      Returns:
      total size
    • subreference

      public ContentReference subreference(long offset, long size)
      Returns a new ContentReference that is a copy of a portion of this ContentReference, at the given offset and size Handles piecing together the underlying segments properly
      Parameters:
      offset - Number of bytes at which to offset the new ContentReference
      size - Size in bytes of the new ContentReference
      Returns:
      A trimmed down ContentReference
    • subreferenceSegments

      public List<Segment> subreferenceSegments(long offset, long size)
      Returns a list of Segments that copy portions of this ContentReference, at the given offset and size Handles piecing together the underlying segments properly
      Parameters:
      offset - Number of bytes at which to offset the new segments
      size - Size in bytes of the new segments
      Returns:
      A subset of segments in the ContentReference
    • sumSegmentSizes

      public static long sumSegmentSizes(List<Segment> segments)
    • minOffset

      public static long minOffset(List<Segment> segments)