public class

LabelParser

extends Object
java.lang.Object
   ↳ com.atlassian.confluence.labels.LabelParser

Class Overview

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.

Summary

Constants
int MAX_LABEL_NAME_LENGTH
int MAX_LABEL_PREFIX_LENGTH
String NAMESPACE_DELIMITER
String PERSONAL_LABEL_PREFIX
String TEAM_LABEL_PREFIX
String USER_LABEL_PREFIX
Fields
public static final char[] INVALID_CHARACTERS
Public Constructors
LabelParser()
Public Methods
static ParsedLabelName create(String labelName, String userName)
static ParsedLabelName create(Label label)
static String getInvalidCharactersAsString()
static boolean isLabelOwnedByUser(String labelString, User user)
Returns true if the label is a personal label and is owned by the specified user, false otherwise.
static boolean isPersonalLabel(String labelString)
Returns true if the label is a personal label, false otherwise.
static boolean isValidLabelLength(ParsedLabelName labelName)
static boolean isValidNameLength(ParsedLabelName labelName)
static boolean isValidPrefixLength(ParsedLabelName labelName)
static ParsedLabelName parse(String labelString)
static String render(ParsedLabelName parsedLabelName, boolean ignoreCurrentUser)
static String render(ParsedLabelName parsedLabelName)
static String render(Label label)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MAX_LABEL_NAME_LENGTH

Constant Value: 255 (0x000000ff)

public static final int MAX_LABEL_PREFIX_LENGTH

Constant Value: 255 (0x000000ff)

public static final String NAMESPACE_DELIMITER

Constant Value: ":"

public static final String PERSONAL_LABEL_PREFIX

Constant Value: "my:"

public static final String TEAM_LABEL_PREFIX

Constant Value: "team:"

public static final String USER_LABEL_PREFIX

Constant Value: "~"

Fields

public static final char[] INVALID_CHARACTERS

Public Constructors

public LabelParser ()

Public Methods

public static ParsedLabelName create (String labelName, String userName)

public static ParsedLabelName create (Label label)

public static String getInvalidCharactersAsString ()

public static boolean isLabelOwnedByUser (String labelString, 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.

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.

public static boolean isValidLabelLength (ParsedLabelName labelName)

public static boolean isValidNameLength (ParsedLabelName labelName)

public static boolean isValidPrefixLength (ParsedLabelName labelName)

public static ParsedLabelName parse (String labelString)

public static String render (ParsedLabelName parsedLabelName, boolean ignoreCurrentUser)

public static String render (ParsedLabelName parsedLabelName)

public static String render (Label label)