Class LabelParser


  • public class LabelParser
    extends Object
    The Label parser understands the formatting of label strings.

    The following are considered valid label strings.

    • my:label
      : a user label owned by the currently logged in user. If no user is logged in, this defaults to the global label of the same name..
    • label
      : a global label.
    • ~username:label
      : a user label owned by the specified user.
    • Constructor Detail

      • LabelParser

        public LabelParser()
    • Method Detail

      • isValidLabelLength

        public static boolean isValidLabelLength​(ParsedLabelName labelName)
      • isValidNameLength

        public static boolean isValidNameLength​(ParsedLabelName labelName)
      • isValidPrefixLength

        public static boolean isValidPrefixLength​(ParsedLabelName labelName)
      • isPersonalLabel

        public static boolean isPersonalLabel​(String labelString)
        Returns true if the label is a personal label, false otherwise.
        Parameters:
        labelString - a string representation of exactly one label, optionally including a namespace. E.g. "my:favourite", "team:confluence" or "blah". Should not be null.
        Returns:
        true if the label is a personal label, false otherwise.
      • isLabelOwnedByUser

        public static boolean isLabelOwnedByUser​(String labelString,
                                                 com.atlassian.user.User user)
        Returns true if the label is a personal label and is owned by the specified user, false otherwise. Returns false, if the specified labelString is not a personal or user label (as no other label types have user ownership).
        Parameters:
        labelString - must be user label or personal label
        user - user to check against
        Returns:
        true if the label is a personal label and is owned by the specified user, false otherwise.
      • parse

        public static @Nullable ParsedLabelName parse​(@NonNull String labelString,
                                                      @Nullable com.atlassian.user.User user)
        Since:
        6.0
      • getInvalidCharactersAsString

        public static String getInvalidCharactersAsString()
      • render

        public static String render​(Label label)
      • render

        public static String render​(ParsedLabelName parsedLabelName,
                                    com.atlassian.user.User currentUser)
        The pure render function without side effects
        Since:
        7.7.0