|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.confluence.util.LabelUtil
public final class LabelUtil
Utility class designed to assist dealing with the client interface. In particular, the conversion from a string to a label and back, and the conversion from a list of strings to a list of labels and back.
Field Summary | |
---|---|
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 Summary | |
---|---|
LabelUtil()
|
Method Summary | |
---|---|
static Label |
addLabel(String labelReference,
LabelManager labelManager,
Labelable object)
Adds the label to the specified object. |
static boolean |
addLabel(String labelReference,
LabelManager labelManager,
com.atlassian.user.User user,
Labelable dest)
Deprecated. since 2.9 |
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 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,
boolean removeUnusedLabels)
Neat method that will synchronize a space separated list of label names with the labels contained within the labelable object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
public LabelUtil()
Method Detail |
---|
public static String convertToDelimitedString(Labelable obj, com.atlassian.user.User user)
public static String convertToDelimitedString(List names)
public static String joinIds(List labels, String separator)
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)
labels
- the list of Label
objects to filterusername
- the user who the list is being filtered for
String
s that the user can seepublic static List<String> split(String input)
input
-
public static int countLabels(String input)
input
- a string of labels delimited by the characters in LABEL_DELIM_CHARS
. May be null or empty.
public static boolean syncState(String source, LabelManager labelManager, com.atlassian.user.User user, Labelable dest, boolean removeUnusedLabels)
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'@Deprecated public static boolean addLabel(String labelReference, LabelManager labelManager, com.atlassian.user.User user, Labelable dest)
addLabel(String, LabelManager, Labelable)
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 rankResults(List results)
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.atlassian.core.util.filter.ListFilter getLabelFilters(com.atlassian.user.User user, boolean hideSpecialLabels)
public static List<Label> getLabelsFor(String labels, LabelManager labelManager)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |