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 String |
LABELS_STRING
The name of the form field containing the space separated labels
|
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 Label |
addLabel(String labelReference,
LabelManager labelManager,
Labelable object,
ConfluenceUser user)
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 |
countLabelNamesWithoutFavourites(Collection<String> labelNames)
Deprecated.
since 6.0 , use {
countParsedLabelNamesWithoutFavourites(Collection) } |
static int |
countLabels(String input)
Counts the labels present in an input string.
|
static int |
countLabelsWithoutFavourites(Collection<Label> labels)
Counts the labels present in an input collection.
|
static int |
countLabelsWithoutFavourites(String labelsString)
Counts the labels present in an input string.
|
static int |
countParsedLabelNamesWithoutFavourites(Collection<ParsedLabelName> labels)
Counts the labels present in an input collection.
|
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 String |
getLabelsHash(List<Label> labels) |
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 |
isFavouriteLabel(Label label)
Checks if the given label is of "Favourite" type
(
LabelManager.FAVOURITE_LABEL or
LabelManager.FAVOURITE_LABEL_YANKEE ). |
static boolean |
isFavouriteLabel(ParsedLabelName label)
Checks if the given label is of "Favourite" type
(
LabelManager.FAVOURITE_LABEL or
LabelManager.FAVOURITE_LABEL_YANKEE ). |
static boolean |
isFavouriteLabel(String labelName)
Deprecated.
since 6.0, use
isFavouriteLabel(ParsedLabelName) |
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(Collection<String> labelNames,
LabelManager labelManager,
com.atlassian.user.User user,
Labelable dest) |
static boolean |
syncState(List<Label> source,
LabelManager labelManager,
com.atlassian.user.User user,
Labelable dest) |
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 final String LABELS_STRING
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 isFavouriteLabel(String labelName)
isFavouriteLabel(ParsedLabelName)
LabelManager.FAVOURITE_LABEL
or
LabelManager.FAVOURITE_LABEL_YANKEE
).labelName
- labelNametrue
if the argument name represents "favourite" labelpublic static boolean isFavouriteLabel(@Nullable ParsedLabelName label)
LabelManager.FAVOURITE_LABEL
or
LabelManager.FAVOURITE_LABEL_YANKEE
).label
- parsed labeltrue
if the argument name represents "favourite" labelpublic static boolean isFavouriteLabel(Label label)
LabelManager.FAVOURITE_LABEL
or
LabelManager.FAVOURITE_LABEL_YANKEE
).label
- labeltrue
if the argument name represents "favourite" labelpublic static int countLabelsWithoutFavourites(String labelsString)
LabelManager.FAVOURITE_LABEL
and
LabelManager.FAVOURITE_LABEL_YANKEE
) are ignored.labelsString
- a string of labels delimited by the characters in LABEL_DELIM_CHARS
. May be null or empty.@Deprecated public static int countLabelNamesWithoutFavourites(Collection<String> labelNames)
countParsedLabelNamesWithoutFavourites(Collection)
}LabelManager.FAVOURITE_LABEL
and
LabelManager.FAVOURITE_LABEL_YANKEE
) are ignored.labelNames
- a collection of labels namespublic static int countParsedLabelNamesWithoutFavourites(Collection<ParsedLabelName> labels)
LabelManager.FAVOURITE_LABEL
and
LabelManager.FAVOURITE_LABEL_YANKEE
) are ignored.labels
- a collection of parsed labelspublic static int countLabelsWithoutFavourites(Collection<Label> labels)
LabelManager.FAVOURITE_LABEL
and
LabelManager.FAVOURITE_LABEL_YANKEE
) are ignored.labels
- a collection of labels@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 boolean syncState(List<Label> source, LabelManager labelManager, com.atlassian.user.User user, Labelable dest)
public static boolean syncState(Collection<String> labelNames, LabelManager labelManager, com.atlassian.user.User user, Labelable dest)
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 Label addLabel(String labelReference, LabelManager labelManager, Labelable object, ConfluenceUser user)
isValidLabelName(String)
and isValidLabelLength(String)
.
If the label can't be added, already exists, or is invalid, this method returns null.
user
- The user to associate with the label, regardless of the label reference.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–2017 Atlassian. All rights reserved.