public final class LabelUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
LABEL_DELIM
The canonical delimiter in output
|
static String |
LABEL_DELIM_CHARS
The characters accepted as label delimiters
|
static int |
MAX_ALLOWED_LABELS
The maximum number of labels allowed on a page or space.
|
static int |
MAX_ALLOWED_LABELS_PER_INPUT
The maximum number of labels we allow to be entered via a single sumbission from the user interface.
|
Constructor and Description |
---|
LabelUtil() |
Modifier and Type | Method and Description |
---|---|
static Label |
addLabel(String labelReference,
LabelManager labelManager,
Labelable object)
Adds the label to the specified object.
|
static String |
convertToDelimitedString(Labelable obj,
com.atlassian.user.User user)
Helper method converting list of labels associated with the labelable object into a space separated string
of the label names.
|
static String |
convertToDelimitedString(List names) |
static int |
countLabels(String input)
Counts the labels present in an input string.
|
static List<Label> |
extractLabelsFromLabellings(List<Labelling> labellings)
Simple utility method to extract the label instances from the given list of labelling instances.
|
static void |
fixLabels(List suggestedLabels) |
static com.atlassian.core.util.filter.ListFilter |
getLabelFilters(com.atlassian.user.User user,
boolean hideSpecialLabels)
returns only labels the user can see and also strips out special labels if 'hideSpecialLabels' flag is set
|
static com.google.common.base.Predicate<Label> |
getLabelPredicate(com.atlassian.user.User user,
boolean hideSpecialLabels) |
static List<Label> |
getLabelsFor(String labels,
LabelManager labelManager) |
static List |
getRecentAndPopularLabels(String spaceKey,
LabelManager labelManager,
int maxResults,
String user) |
static List |
getRecentAndPopularLabelsForEntity(ContentEntityObject entity,
LabelManager labelManager,
int maxResults,
String user) |
static List |
getVisibleLabelNames(List labels,
String username)
Get a list of the visible label names for this content.
|
static boolean |
isValidLabelLength(String input) |
static boolean |
isValidLabelLengths(Collection labelNames) |
static boolean |
isValidLabelLengths(String concatenatedLabelNames) |
static boolean |
isValidLabelName(String labelName) |
static boolean |
isValidLabelNames(Collection names) |
static boolean |
isValidLabelNames(String delimitedLabelNames) |
static String |
joinIds(List labels,
String separator) |
static List |
rankResults(List results) |
static void |
recordLabelInteractionInHistory(Label label) |
static List<String> |
split(String input)
Split the input string according to the label delimitation rules.
|
static boolean |
syncState(String source,
LabelManager labelManager,
com.atlassian.user.User user,
Labelable dest)
Neat method that will synchronize a space separated list of label names with the labels contained within the
labelable object.
|
static boolean |
syncState(String source,
LabelManager labelManager,
com.atlassian.user.User user,
Labelable dest,
boolean ignored)
Deprecated.
since 5.1. Use
syncState(String, LabelManager, User, Labelable) |
public static final String LABEL_DELIM_CHARS
public static final String LABEL_DELIM
public static final int MAX_ALLOWED_LABELS_PER_INPUT
public static final int MAX_ALLOWED_LABELS
public static String convertToDelimitedString(Labelable obj, com.atlassian.user.User user)
public static boolean isValidLabelNames(String delimitedLabelNames)
delimitedLabelNames
- contains a list of label names delimited by LABEL_DELIM_CHARS
public static boolean isValidLabelNames(Collection names)
names
- a collection of label names as String
s.public static boolean isValidLabelName(String labelName)
public static boolean isValidLabelLengths(String concatenatedLabelNames)
public static boolean isValidLabelLengths(Collection labelNames)
public static boolean isValidLabelLength(String input)
public static List getVisibleLabelNames(List labels, String username)
public static List<String> split(String input)
input
- space separated string of labelspublic static int countLabels(String input)
input
- a string of labels delimited by the characters in LABEL_DELIM_CHARS
. May be null or empty.@Deprecated public static boolean syncState(String source, LabelManager labelManager, com.atlassian.user.User user, Labelable dest, boolean ignored)
syncState(String, LabelManager, User, Labelable)
source
- is a space separated list of label names, eg: the following list "LabelA LabelB LabelC" will
be converted into label instances with the names 'LabelA', 'LabelB' and 'LabelC'ignored
- is ignoredpublic static boolean syncState(String source, LabelManager labelManager, com.atlassian.user.User user, Labelable dest)
source
- is a space separated list of label names, eg: the following list "LabelA LabelB LabelC" will
be converted into label instances with the names 'LabelA', 'LabelB' and 'LabelC'public static Label addLabel(String labelReference, LabelManager labelManager, Labelable object)
isValidLabelName(String)
and isValidLabelLength(String)
.
If the label can't be added, already exists, or is invalid, this method returns null.public static void recordLabelInteractionInHistory(Label label)
public static List getRecentAndPopularLabelsForEntity(ContentEntityObject entity, LabelManager labelManager, int maxResults, String user)
public static List getRecentAndPopularLabels(String spaceKey, LabelManager labelManager, int maxResults, String user)
public static void fixLabels(List suggestedLabels)
public static List<Label> extractLabelsFromLabellings(List<Labelling> labellings)
Label
instances.public static com.google.common.base.Predicate<Label> getLabelPredicate(com.atlassian.user.User user, boolean hideSpecialLabels)
public static com.atlassian.core.util.filter.ListFilter getLabelFilters(com.atlassian.user.User user, boolean hideSpecialLabels)
public static List<Label> getLabelsFor(String labels, LabelManager labelManager)
Copyright © 2003–2015 Atlassian. All rights reserved.