Class TranscriptSpeakers

java.lang.Object
org.exoplatform.documents.model.TranscriptSpeakers

public final class TranscriptSpeakers extends Object
Reads who the speakers of a transcript are and writes its lines, with no service behind it, for any module that sees the documents API only (EXO-92123). A speaker is stored as <speaker>=<identityId> for a person with an account, or <speaker>=name:<text> for a guest named by a plain name. What is written is meant for an assistant, so it is never localised.
  • Field Details

    • GUEST_PREFIX

      public static final String GUEST_PREFIX
      The prefix of a stored guest name, matched case-sensitively.
      See Also:
    • SPEAKER_LABEL

      public static final String SPEAKER_LABEL
      The label of a speaker nobody named, followed by its number.
      See Also:
  • Method Details

    • isGuest

      public static boolean isGuest(String value)
      Tells whether a stored speaker value is a guest's plain name.
      Parameters:
      value - the stored value
      Returns:
      true when the value starts with GUEST_PREFIX
    • guestName

      public static String guestName(String value)
      Reads the guest name a stored speaker value holds.
      Parameters:
      value - the stored value
      Returns:
      the text after GUEST_PREFIX, or null when the value is no guest name
    • speakerName

      public static String speakerName(String speaker, Map<String,String> speakers, Function<String,String> fullNameOfIdentity)
      Names a speaker of a transcript: the full name of the person named for it, the guest's name, or Speaker N when nobody is named, when the person is gone, or when the lookup finds no name.
      Parameters:
      speaker - the speaker's number in the transcript, or null for a sentence the transcript gives no speaker
      speakers - the stored value of each named speaker, by speaker number
      fullNameOfIdentity - gives the full name of a person from their identity id, or null when there is none
      Returns:
      the speaker's name; null when the sentence has no speaker, which formatLine(double, String, String) and formatTurn(String, String) then write without a name
    • formatMoment

      public static String formatMoment(double seconds)
      Writes a moment of a media.
      Parameters:
      seconds - the moment, in seconds from the beginning of the media; its fraction is dropped, and a negative or undefined moment is 0
      Returns:
      mm:ss, or h:mm:ss past an hour
    • formatMarker

      public static String formatMarker(double seconds)
      Writes a moment of a media as the documents tools mark it for an assistant, with the whole seconds an assistant can jump to.
      Parameters:
      seconds - the moment, in seconds from the beginning of the media; its fraction is dropped, and a negative or undefined moment is 0
      Returns:
      [mm:ss · Ns], or [h:mm:ss · Ns] past an hour, N being the moment in whole seconds
    • formatLine

      public static String formatLine(double start, String name, String text)
      Writes one line of a timed transcript: the moment it was said, as formatMarker(double) marks it, then who said it.
      Parameters:
      start - the moment the line was said, in seconds
      name - who said it, or null when the transcript does not tell
      text - what was said
      Returns:
      [mm:ss · Ns] Name: text, or [mm:ss · Ns] text when the name is null
    • formatTurn

      public static String formatTurn(String name, String text)
      Writes one turn of a transcript with no moment.
      Parameters:
      name - who said it, or null when the transcript does not tell
      text - what was said
      Returns:
      Name: text, or the text alone when the name is null