info.bioinfweb.jphyloio.utils

## Class LabelEditingReporter

- java.lang.Object
- - info.bioinfweb.jphyloio.utils.LabelEditingReporter

-     public class LabelEditingReporter
      extends java.lang.Object

  Data storage class that allows instances of `JPhyloIOEventWriter` to give feedback to the application on how labels of different elements (e.g. OTUs, sequences, nodes) were changed in order to fulfill the requirements of the target format. In some cases it may also happen that the specific element was not at all written to the target format, because it is not supported there.
  Since:
    0.0.0
  Author:
    Ben Stöver

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LabelEditingReporter.LabelStatus` Enumerates the possible cases of how the label associated with a data element was treated by an instance of `JPhyloIOEventWriter`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LabelEditingReporter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEdit(EventContentType contentType, java.lang.String id, java.lang.String label, boolean edited)` Adds a new mapping from an element ID to the label used for it in the target document to this instance.
    `void` | `addEdit(LabeledIDEvent event, java.lang.String label)` Adds a new mapping from an element ID to the label used for it in the target document to this instance.
    `boolean` | `anyLabelEdited(EventContentType contentType)` Determines whether any label of data elements of the specified content type was edited.
    `void` | `clear()` Removes all mappings from this instance.
    `java.lang.String` | `getEditedLabel(EventContentType contentType, java.lang.String id)` Returns the (edited) label associated with the specified data element.
    `java.lang.String` | `getEditedLabel(LabeledIDEvent event)` Returns the (edited) label associated with the specified data element.
    `LabelEditingReporter.LabelStatus` | `getLabelStatus(EventContentType contentType, java.lang.String id)` Returns the status of the specified data element and its label.
    `LabelEditingReporter.LabelStatus` | `getLabelStatus(LabeledIDEvent event)` Returns the status of the specified data element and its label.
    `boolean` | `isLabelUsed(EventContentType contentType, java.lang.String label)` Checks whether the specified label was already used for the specified content type.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LabelEditingReporter

          public LabelEditingReporter()

  - ### Method Detail

    - #### addEdit

          public void addEdit(EventContentType contentType,
                              java.lang.String id,
                              java.lang.String label,
                              boolean edited)

      Adds a new mapping from an element ID to the label used for it in the target document to this instance.
      Parameters:
        `contentType` - the content type of the element to be mapped
        `id` - the ID of the element to be mapped
        `label` - the label that was used in the target document for the specified element
        `edited` - Specify `true` here, if the specified label is not the label originally associated with the specified element (denoted `id`).
      Throws:
        `java.lang.NullPointerException` - if `contentType` or `id` are `null`

    - #### addEdit

          public void addEdit(LabeledIDEvent event,
                              java.lang.String label)

      Adds a new mapping from an element ID to the label used for it in the target document to this instance.
      Parameters:
        `event` - the event object describing the element associated with the edited label
        `label` - the label that was used in the target document for the specified element
      Throws:
        `java.lang.NullPointerException` - if `event` is `null`

    - #### clear

          public void clear()

      Removes all mappings from this instance.

    - #### getEditedLabel

          public java.lang.String getEditedLabel(EventContentType contentType,
                                                 java.lang.String id)

      Returns the (edited) label associated with the specified data element.
      Parameters:
        `contentType` - the content type of the labeled data element
        `id` - the ID of the labeled data element
      Returns:
        the label used in the document or `null` if the specified data element was either not written to the target document or no according mapping could not be found in this instance

    - #### getEditedLabel

          public java.lang.String getEditedLabel(LabeledIDEvent event)

      Returns the (edited) label associated with the specified data element.
      Parameters:
        `event` - the event representing the labeled data element
      Returns:
        the label used in the document or `null` if the specified data element was either not written to the target document or no according mapping could not be found in this instance

    - #### getLabelStatus

          public LabelEditingReporter.LabelStatus getLabelStatus(EventContentType contentType,
                                                                 java.lang.String id)

      Returns the status of the specified data element and its label.
      Parameters:
        `contentType` - the content type of the labeled data element
        `id` - the ID of the labeled data element
      Returns:
        the label status associated with the specified data element

    - #### getLabelStatus

          public LabelEditingReporter.LabelStatus getLabelStatus(LabeledIDEvent event)

      Returns the status of the specified data element and its label.
      Parameters:
        `event` - the event representing the labeled data element
      Returns:
        the label status associated with the specified data element

    - #### isLabelUsed

          public boolean isLabelUsed(EventContentType contentType,
                                     java.lang.String label)

      Checks whether the specified label was already used for the specified content type. This method is intended for internal use by implementations of `JPhyloIOEventWriter` and will usually not be of much use for application developers.
      Parameters:
        `contentType` - the content type for which the label could have been used
        `label` - the label to search for
      Returns:
        `true` if the specified label was already used until now or `false` otherwise

    - #### anyLabelEdited

          public boolean anyLabelEdited(EventContentType contentType)

      Determines whether any label of data elements of the specified content type was edited. This method is useful, e.g. if applications want to check whether they shall inform the user about label editing after an instance of `JPhyloIOEventWriter` has been used to write a document.
      Parameters:
        `contentType` - the content type of the labeled data element
      Returns:
        `true`