Class Transcript

All Implemented Interfaces:
IExtendable, Visitable<Transcript.Element>, Iterable<Transcript.Element>

public final class Transcript extends ExtendableObject implements Iterable<Transcript.Element>, Visitable<Transcript.Element>
A collection of interleaved Comments, Gems and Records
  • Method Details

    • getNumberOfElements

      public int getNumberOfElements()
      Get number of transcript elements
      Returns:
      number of comments and records
    • getElementAt

      public Transcript.Element getElementAt(int idx)
      Get element at specified index
      Parameters:
      idx -
      Returns:
      element at given index
      Throws:
      ArrayIndexOutOfBoundsException
    • addElement

      public void addElement(Transcript.Element element)
      Add element to end of list
      Parameters:
      element -
    • addElement

      public void addElement(int idx, Transcript.Element element)
      Add element and insert at specified location.
      Parameters:
      idx -
      element -
      Throws:
      ArrayIndexOutOfBoundsException
    • removeElement

      public void removeElement(Transcript.Element element)
      Remove specified element from transcript
      Parameters:
      element -
    • removeElement

      public Transcript.Element removeElement(int idx)
      Remove element at specified index
      Parameters:
      idx -
      Returns:
      session element that was removed
      Throws:
      ArrayIndexOutOfBoundsException
    • getElementIndex

      public int getElementIndex(Transcript.Element ele)
      Return the element index
      Parameters:
      ele -
      Returns:
      element index in transcript or -1 if not found
    • getElementIndex

      public int getElementIndex(Record r)
      Return the element index
      Parameters:
      r -
      Returns:
      element index in transcript or -1 if not found
    • getElementIndex

      public int getElementIndex(Comment comment)
      Return the element index
      Parameters:
      comment -
      Returns:
      element index in transcript or -1 if not found
    • getElementIndex

      public int getElementIndex(Gem gem)
      Return the element index
      Parameters:
      gem -
      Returns:
      element index in transcript or -1 if not found
    • addComment

      public void addComment(Comment comment)
      Add a new comment to end of the transcript
      Parameters:
      comment -
    • addComment

      public void addComment(int elementIndex, Comment comment)
      Add new comment at the given element index. Note this is different from asRecord(int recordIndex, Record record) which is a helper function to insert a record at the correct location between comments and records.
      Parameters:
      elementIndex -
      comment -
    • removeComment

      public Comment removeComment(Comment comment)
      Remove given comment
      Parameters:
      comment -
    • addGem

      public void addGem(Gem gem)
      Add a new gem to the end of the transcript
      Parameters:
      gem -
    • addGem

      public void addGem(int elementIndex, Gem gem)
      Add gem at given position in transcript
      Parameters:
      elementIndex -
      gem -
    • removeGem

      public Gem removeGem(Gem gem)
    • findBeginGem

      public int findBeginGem(String label)
      Return element index for start of given gem label
      Parameters:
      label -
      Returns:
      element index of BeginGem (@Bg) or -1 if not found
    • findEndGem

      public int findEndGem(String label)
      Return element index for end of given gem label
      Parameters:
      label -
      Returns:
      element index of EndGem (@Eg) or -1 if not found
    • findLazyGem

      public int findLazyGem(String label)
      Return element index for lazy gem with given label
      Parameters:
      label -
      Returns:
      element index of EndGem (@Eg) or -1 if not found
    • addRecord

      public void addRecord(Record record)
      Add a new record to the session
      Parameters:
      record -
    • getRecordElementIndex

      public int getRecordElementIndex(int recordIndex)
      Get index of record
      Parameters:
      recordIndex -
      Returns:
      element index of record, or -1 if not found
    • getRecordIndex

      public int getRecordIndex(int elementIndex)
      Get the record index of the given element index or the highest record index
      Parameters:
      elementIndex -
    • addRecord

      public void addRecord(int recordIndex, Record record)
      Add a new record to the list in the given position.
      Parameters:
      recordIndex -
      record -
      Throws:
      ArrayIndexOutOfBoundsException
    • removeRecord

      public void removeRecord(Record record)
      Remove a record from the session.
      Parameters:
      record -
    • removeRecord

      public Record removeRecord(int recordIndex)
      Remove a record from the session
      Parameters:
      recordIndex -
      Throws:
      ArrayIndexOutOfBoundsException
    • getRecord

      public Record getRecord(int recordIndex)
      Return the record at the given index.
      Parameters:
      recordIndex -
      Returns:
      the specified record
      Throws:
      ArrayIndexOutOfBoundsException
    • getRecordCount

      public int getRecordCount()
      Return the number of records.
      Returns:
      the number of records
    • getRecordIndex

      public int getRecordIndex(Record record)
      Get the record index of the given record.
      Parameters:
      record -
      Returns:
      record index or -1 if not found
    • setRecordIndex

      public void setRecordIndex(Record record, int recordIndex)
      Set the position of the given record. This will remove the record from the element list and then re-add it at the requested record index
      Parameters:
      record -
      recordIndex -
      Throws:
      ArrayIndexOutOfBoundsException
    • accept

      public void accept(Visitor<Transcript.Element> visitor)
      Description copied from interface: Visitable
      Accept the given visitor.
      Specified by:
      accept in interface Visitable<Transcript.Element>
    • iterator

      public Iterator<Transcript.Element> iterator()
      Specified by:
      iterator in interface Iterable<Transcript.Element>
    • stream

      public Stream<Transcript.Element> stream()
    • stream

      public Stream<Transcript.Element> stream(boolean parallel)