Record Class MetaIdentifier

java.lang.Object
java.lang.Record
is.galia.image.MetaIdentifier
Record Components:
identifier - Identifier component.
pageNumber - Page number component, which may be null.
scaleConstraint - Scale constraint component, which may be null.

public record MetaIdentifier(Identifier identifier, Integer pageNumber, ScaleConstraint scaleConstraint) extends Record

An Identifier is used to uniquely identify a source image file or object. But a client may require more specificity than this—for example, to be able to retrieve a particular page from within a multi-page image, and/or at a particular scale limit. Ideally these parameters would be supplied as arguments to the image request API service, but said service may not support them. (This is the case for the IIIF Image API, at least, through version 3.0.)

Thus this class, which joins meta-information about an identifier with the identifier itself, for utilization by an image-request API that doesn't natively support such information.

Input

When meta-identifiers are supplied to the application via URIs, they must go through some processing steps before they can be used (order is important):

  1. URI decoding
  2. slash decoding

(fromURI(String, Delegate) will handle all of this.)

Output

The input steps must be reversed for output. Note that requests can supply a AbstractResource.PUBLIC_IDENTIFIER_HEADER to suggest that the meta-identifier supplied in a URI is different from the one the user agent is seeing and supplying to a reverse proxy.

So, the steps for output are:

  1. Replace the URI meta-identifier with the one from AbstractResource.PUBLIC_IDENTIFIER_HEADER, if present
  2. Encode slashes
  3. URI encoding
  • Constructor Details

    • MetaIdentifier

      public MetaIdentifier(String identifier)
      Creates a minimal valid instance. For more options, use MetaIdentifier.Builder.
    • MetaIdentifier

      public MetaIdentifier(Identifier identifier)
      Creates a minimal valid instance. For more options, use MetaIdentifier.Builder.
    • MetaIdentifier

      public MetaIdentifier(Identifier identifier, Integer pageNumber, ScaleConstraint scaleConstraint)
      Creates an instance of a MetaIdentifier record class.
      Parameters:
      identifier - the value for the identifier record component
      pageNumber - the value for the pageNumber record component
      scaleConstraint - the value for the scaleConstraint record component
  • Method Details

    • builder

      public static MetaIdentifier.Builder builder()
    • fromString

      public static MetaIdentifier fromString(String string, Delegate delegate)

      Deserializes the given meta-identifier string using the MetaIdentifierTransformer specified in the application configuration.

      This is a shortcut to using MetaIdentifierTransformerFactory.

      Returns:
      New deserialized instance.
    • fromURI

      public static MetaIdentifier fromURI(String uriValue, Delegate delegate)
      Translates the string in a raw URI path component or query into a new instance using the MetaIdentifierTransformer specified in the application configuration.
      Parameters:
      uriValue - Raw URI value from the path or query.
      delegate - Delegate.
      See Also:
    • forURI

      public String forURI(Delegate delegate)
      Parameters:
      delegate - Delegate.
      Returns:
      Serialization suitable for insertion into a URI path or query and already encoded.
      See Also:
    • rebuilder

      public MetaIdentifier.Builder rebuilder()
      Returns:
      Reference.Builder of a new instance based on this one.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • identifier

      public Identifier identifier()
      Returns the value of the identifier record component.
      Returns:
      the value of the identifier record component
    • pageNumber

      public Integer pageNumber()
      Returns the value of the pageNumber record component.
      Returns:
      the value of the pageNumber record component
    • scaleConstraint

      public ScaleConstraint scaleConstraint()
      Returns the value of the scaleConstraint record component.
      Returns:
      the value of the scaleConstraint record component