Class AbstractCommentManager<C,U extends IInteractiveUnit>

java.lang.Object
com.pnfsoftware.jeb.core.units.impl.AbstractCommentManager<C,U>
Type Parameters:
C - coordinate type
U - managed unit type
Direct Known Subclasses:
CodeCommentManager, CommentManager

@Ser public abstract class AbstractCommentManager<C,U extends IInteractiveUnit> extends Object
A comment manager to be used by IInteractiveUnit. It supports dual-addressing: regular string address (per the interactive unit specifications), and custom address (methods for custom addressing are suffixed by 2). The conversion methods are to be provided by the subclass.

Specialized subclasses exist.

  • Field Details

    • INLINE

      public static final int INLINE
      Constant used to identify an item's primary comment inlined with the item (for rendering purposes).
      See Also:
    • PRE

      public static final int PRE
      Constant used to identify an item's primary comment located above/before the item (for rendering purposes).
      See Also:
    • COMMENT_FLAG_FAVORITE

      public static final int COMMENT_FLAG_FAVORITE
      Flag indicating that a comment should be treated as a favorite marker.
      See Also:
  • Constructor Details

    • AbstractCommentManager

      protected AbstractCommentManager(U unit)
      Create a comment manager.
      Parameters:
      unit - managed unit
  • Method Details

    • getUnit

      public U getUnit()
      Retrieve the managed unit.
      Returns:
      the managed unit
    • getComments

      public Map<String,Comment> getComments()
      Retrieve comments keyed by string address.
      Returns:
      a map of addresses to comments
    • getComments2

      public Map<C,Comment> getComments2()
      Retrieve comments keyed by custom coordinate.
      Returns:
      a map of coordinates to comments
    • getComment

      public Comment getComment(String address)
      Retrieve the comment at the provided address.
      Parameters:
      address - address
      Returns:
      the comment, or null if none
    • getComment2

      public Comment getComment2(C coord)
      Retrieve the comment at the provided coordinate.
      Parameters:
      coord - coordinate
      Returns:
      the comment, or null if none
    • setComment

      public boolean setComment(String address, Comment comment, boolean notify)
      Set or delete the comment at the provided address.
      Parameters:
      address - address
      comment - new comment; null to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • setComment2

      public boolean setComment2(C coord, Comment comment, boolean notify)
      Set or delete the comment at the provided coordinate.
      Parameters:
      coord - coordinate
      comment - new comment; null to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • getInlineComment

      public String getInlineComment(String address)
      Retrieve the inline comment at the provided address.
      Parameters:
      address - address
      Returns:
      the inline comment, or null if none
    • setInlineComment

      public boolean setInlineComment(String address, String value)
      Set or delete the inline comment at the provided address and notify listeners.
      Parameters:
      address - address
      value - new comment; null or empty to delete
      Returns:
      success indicator
    • setInlineComment

      public boolean setInlineComment(String address, String value, boolean notify)
      Set or delete the inline comment at the provided address.
      Parameters:
      address - address
      value - new comment; null or empty to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • getInlineComment2

      public String getInlineComment2(C coord)
      Retrieve the inline comment at the provided coordinate.
      Parameters:
      coord - coordinate
      Returns:
      the inline comment, or null if none
    • setInlineComment2

      public boolean setInlineComment2(C coord, String value)
      Set or delete the inline comment at the provided coordinate and notify listeners.
      Parameters:
      coord - coordinate
      value - new comment; null or empty to delete
      Returns:
      success indicator
    • setInlineComment2

      public boolean setInlineComment2(C coord, String value, boolean notify)
      Set or delete the inline comment at the provided coordinate.
      Parameters:
      coord - coordinate
      value - new comment; null or empty to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • getPreComment

      public String getPreComment(String address)
      Retrieve the pre-comment at the provided address.
      Parameters:
      address - address
      Returns:
      the pre-comment, or null if none
    • setPreComment

      public boolean setPreComment(String address, String value)
      Set or delete the pre-comment at the provided address and notify listeners.
      Parameters:
      address - address
      value - new comment; null or empty to delete
      Returns:
      success indicator
    • setPreComment

      public boolean setPreComment(String address, String value, boolean notify)
      Set or delete the pre-comment at the provided address.
      Parameters:
      address - address
      value - new comment; null or empty to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • getPreComment2

      public String getPreComment2(C coord)
      Retrieve the pre-comment at the provided coordinate.
      Parameters:
      coord - coordinate
      Returns:
      the pre-comment, or null if none
    • setPreComment2

      public boolean setPreComment2(C coord, String value)
      Set or delete the pre-comment at the provided coordinate and notify listeners.
      Parameters:
      coord - coordinate
      value - new comment; null or empty to delete
      Returns:
      success indicator
    • setPreComment2

      public boolean setPreComment2(C coord, String value, boolean notify)
      Set or delete the pre-comment at the provided coordinate.
      Parameters:
      coord - coordinate
      value - new comment; null or empty to delete
      notify - true to notify listeners
      Returns:
      success indicator
    • getPrimary

      public String getPrimary(String address, int position)
      Retrieve a primary comment at the provided address.
      Parameters:
      address - address
      position - one of INLINE or PRE
      Returns:
      the primary comment, or null if none
    • getPrimary2

      public String getPrimary2(C coord, int position)
      Retrieve a primary comment at the provided coordinate.
      Parameters:
      coord - coordinate
      position - one of INLINE or PRE
      Returns:
      the primary comment, or null if none
    • setPrimary

      public boolean setPrimary(String address, String value, int position, boolean notify)
      Set or delete a primary comment at the provided address.
      Parameters:
      address - address
      value - new comment; null or empty to delete
      position - one of INLINE or PRE
      notify - true to notify listeners
      Returns:
      success indicator
    • setPrimary2

      public boolean setPrimary2(C coord, String value, int position, boolean notify)
      Set or delete a primary comment at the provided coordinate.
      Parameters:
      coord - coordinate
      value - new comment; null or empty to delete
      position - one of INLINE or PRE
      notify - true to notify listeners
      Returns:
      success indicator
    • getPrimaryMap

      public Map<String,String> getPrimaryMap(int position)
      Retrieve primary comments keyed by string address.
      Parameters:
      position - one of INLINE or PRE
      Returns:
      a map of addresses to primary comments
    • getPrimaryMap2

      public Map<C,String> getPrimaryMap2(int position)
      Retrieve primary comments keyed by custom coordinate.
      Parameters:
      position - one of INLINE or PRE
      Returns:
      a map of coordinates to primary comments
    • getMetaComments

      public Collection<MetaComment> getMetaComments(String address)
      Retrieve meta-comments at the provided address.
      Parameters:
      address - address
      Returns:
      meta-comments, possibly empty
    • getMetaComments2

      public Collection<MetaComment> getMetaComments2(C coord)
      Retrieve meta-comments at the provided coordinate.
      Parameters:
      coord - coordinate
      Returns:
      meta-comments, possibly empty
    • getMetaComments

      public Collection<MetaComment> getMetaComments(String address, int flagsMustHave, int flagsCantHave)
      Retrieve meta-comments at the provided address filtered by flags.
      Parameters:
      address - address
      flagsMustHave - mask of flags that must be present
      flagsCantHave - mask of flags that must be absent
      Returns:
      filtered meta-comments, possibly empty
    • getMetaComments2

      public Collection<MetaComment> getMetaComments2(C coord, int flagsMustHave, int flagsCantHave)
      Retrieve meta-comments at the provided coordinate filtered by flags.
      Parameters:
      coord - coordinate
      flagsMustHave - mask of flags that must be present
      flagsCantHave - mask of flags that must be absent
      Returns:
      filtered meta-comments, possibly empty
    • addMetaComment

      public boolean addMetaComment(String address, String str, boolean notify)
      Add a meta-comment at the provided address.
      Parameters:
      address - address
      str - comment text
      notify - true to notify listeners
      Returns:
      success indicator
    • addMetaComment

      public boolean addMetaComment(String address, MetaComment c, boolean notify)
      Add a meta-comment at the provided address.
      Parameters:
      address - address
      c - meta-comment
      notify - true to notify listeners
      Returns:
      success indicator
    • addMetaComment2

      public boolean addMetaComment2(C coord, String str, boolean notify)
      Add a meta-comment at the provided coordinate.
      Parameters:
      coord - coordinate
      str - comment text
      notify - true to notify listeners
      Returns:
      success indicator
    • addMetaComment2

      public boolean addMetaComment2(C coord, MetaComment c, boolean notify)
      Add a meta-comment at the provided coordinate.
      Parameters:
      coord - coordinate
      c - meta-comment
      notify - true to notify listeners
      Returns:
      success indicator
    • removeMetaComment

      public boolean removeMetaComment(String address, MetaComment c, boolean notify)
      Remove a meta-comment at the provided address.
      Parameters:
      address - address
      c - meta-comment to remove
      notify - true to notify listeners
      Returns:
      success indicator
    • removeMetaComment2

      public boolean removeMetaComment2(C coord, MetaComment c, boolean notify)
      Remove a meta-comment at the provided coordinate.
      Parameters:
      coord - coordinate
      c - meta-comment to remove
      notify - true to notify listeners
      Returns:
      success indicator
    • getMetaCommentObjects

      public Collection<String> getMetaCommentObjects(String address, int flagsMustHave, int flagsCantHave)
      Retrieve meta-comment text values at the provided address filtered by flags.
      Parameters:
      address - address
      flagsMustHave - mask of flags that must be present
      flagsCantHave - mask of flags that must be absent
      Returns:
      filtered meta-comment text values
    • getMetaCommentObjects2

      public Collection<String> getMetaCommentObjects2(C coord, int flagsMustHave, int flagsCantHave)
      Retrieve meta-comment text values at the provided coordinate filtered by flags.
      Parameters:
      coord - coordinate
      flagsMustHave - mask of flags that must be present
      flagsCantHave - mask of flags that must be absent
      Returns:
      filtered meta-comment text values
    • formatComments

      public String formatComments(String address, boolean includePre, int flagsMustHave, int flagsCantHave)
      Format comments at the provided address.
      Parameters:
      address - address
      includePre - true to include the pre-comment
      flagsMustHave - mask of meta-comment flags that must be present
      flagsCantHave - mask of meta-comment flags that must be absent
      Returns:
      formatted comments, or an empty string if none
    • formatComments2

      public String formatComments2(C coord, boolean includePre, int flagsMustHave, int flagsCantHave)
      Format comments at the provided coordinate.
      Parameters:
      coord - coordinate
      includePre - true to include the pre-comment
      flagsMustHave - mask of meta-comment flags that must be present
      flagsCantHave - mask of meta-comment flags that must be absent
      Returns:
      formatted comments, or an empty string if none
    • formatMetaComment

      public String formatMetaComment(MetaComment c)
      Format a meta-comment for display.
      Parameters:
      c - meta-comment
      Returns:
      formatted meta-comment
    • formatMetaFlags

      public String formatMetaFlags(int flags)
      Format meta-comment flags for display.
      Parameters:
      flags - flags
      Returns:
      formatted flags
    • addressToCoord

      public abstract C addressToCoord(String address)
      Convert a string address to a custom coordinate.
      Parameters:
      address - address
      Returns:
      coordinate, or null if the address cannot be converted
    • coordToAddress

      public abstract String coordToAddress(C coord)
      Convert a custom coordinate to a string address.
      Parameters:
      coord - coordinate
      Returns:
      address, or null if the coordinate cannot be converted
    • putAll

      public void putAll(Map<C,Comment> map)
      Add all provided comments to this manager.
      Parameters:
      map - comments keyed by coordinate