Record Class Hyperlink

java.lang.Object
java.lang.Record
io.keikai.axyra.sheets.content.Hyperlink

public record Hyperlink(String address, String display, String tooltip) extends Record
A cell hyperlink. display and tooltip may be null (the address is shown when there is no display text).

The address string decides the link kind: a #-prefixed address is an internal (in-workbook) reference, a mailto: address is an email link, anything else is an external URL / file target.

  • Constructor Details

    • Hyperlink

      public Hyperlink(String address, String display, String tooltip)
      Creates an instance of a Hyperlink record class.
      Parameters:
      address - the value for the address record component
      display - the value for the display record component
      tooltip - the value for the tooltip record component
  • Method Details

    • url

      public static Hyperlink url(String address)
      A URL hyperlink with no display text or tooltip.
    • url

      public static Hyperlink url(String address, String display)
      A URL hyperlink with display text.
    • internal

      public static Hyperlink internal(String cellRef, String display)
      An internal (in-workbook) hyperlink to cellRef, e.g. "Sheet2!B5" or a defined name. The stored address gains the # prefix Excel uses for location links if not already present.
      Throws:
      NullPointerException - if cellRef is null
    • email

      public static Hyperlink email(String address, String subject, String display)
      An email hyperlink (mailto:). subject may be null; when present it is carried as the ?subject= query, matching Excel's email links. subject is appended as given and not percent-encoded; encode spaces as %20 yourself. A mailto: prefix on address is not doubled.
      Throws:
      NullPointerException - if address is null
    • isInternal

      public boolean isInternal()
      Whether this is an internal (in-workbook) reference.
    • isEmail

      public boolean isEmail()
      Whether this is an email (mailto:) link.
    • toString

      public final 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.
    • address

      public String address()
      Returns the value of the address record component.
      Returns:
      the value of the address record component
    • display

      public String display()
      Returns the value of the display record component.
      Returns:
      the value of the display record component
    • tooltip

      public String tooltip()
      Returns the value of the tooltip record component.
      Returns:
      the value of the tooltip record component