com.atlassian.confluence.util
Class LabelUtil

java.lang.Object
  extended by com.atlassian.confluence.util.LabelUtil

public final class LabelUtil
extends Object

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
 
Constructor Summary
LabelUtil()
           
 
Method Summary
static boolean addLabel(String labelReference, LabelManager labelManager, User user, Labelable dest)
           
static String convertToDelimitedString(Labelable obj, User user, LabelManager labelManager)
          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 String convertToDelimitedString(List names, String seperator)
          Utility function to convert a List into a delimited string with a custom seperator
static List extractLabelsFromLabellings(List labellings)
          Simple utility method to extract the label instances from the given list of labelling instances.
static void fixLabels(List suggestedLabels)
           
static ListFilter getLabelFilters(User user, boolean hideSpecialLabels)
          returns only labels the user can see and also strips out special labels if 'hideSpecialLabels' flag is set
static List getRecentAndPopularLabels(String spaceKey, LabelManager labelManager, int maxResults, String user)
           
static List getRecentAndPopularLabelsForEntity(ContentEntityObject entity, LabelManager labelManager, int maxResults, String user)
           
static boolean isValidLabelName(String input)
           
static boolean isValidLabelNames(String input)
           
static List rankResults(List results)
           
static void recordLabelInteractionInHistory(Label label)
           
static List split(String input)
          Split the input string according to the label delimitation rules.
static boolean syncState(String source, LabelManager labelManager, 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

LABEL_DELIM_CHARS

public static final String LABEL_DELIM_CHARS
The characters accepted as label delimiters

See Also:
Constant Field Values

LABEL_DELIM

public static final String LABEL_DELIM
The canonical delimiter in output

See Also:
Constant Field Values
Constructor Detail

LabelUtil

public LabelUtil()
Method Detail

convertToDelimitedString

public static String convertToDelimitedString(Labelable obj,
                                              User user,
                                              LabelManager labelManager)
Helper method converting list of labels associated with the labelable object into a space separated string of the label names.

Parameters:
obj -

convertToDelimitedString

public static String convertToDelimitedString(List names)

convertToDelimitedString

public static String convertToDelimitedString(List names,
                                              String seperator)
Utility function to convert a List into a delimited string with a custom seperator


isValidLabelNames

public static boolean isValidLabelNames(String input)
Parameters:
input -
Returns:
true if the input represents a string of valid label names, false otherwise.

isValidLabelName

public static boolean isValidLabelName(String input)

split

public static List split(String input)
Split the input string according to the label delimitation rules.

Parameters:
input -
Returns:
a collection of strings, each representing a label name, in the order in which they appeared in the original input.

syncState

public static boolean syncState(String source,
                                LabelManager labelManager,
                                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. Labels that do not exist in the comma separated list will be removed, and labels that appear in the comma separated list will be created.

If a label is removed and that label no longer labels any labelable content, then it will be deleted if the removeUnusedLabels is set to true.

Parameters:
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'
labelManager -
removeUnusedLabels -

addLabel

public static boolean addLabel(String labelReference,
                               LabelManager labelManager,
                               User user,
                               Labelable dest)

recordLabelInteractionInHistory

public static void recordLabelInteractionInHistory(Label label)

rankResults

public static List rankResults(List results)

getRecentAndPopularLabelsForEntity

public static List getRecentAndPopularLabelsForEntity(ContentEntityObject entity,
                                                      LabelManager labelManager,
                                                      int maxResults,
                                                      String user)

getRecentAndPopularLabels

public static List getRecentAndPopularLabels(String spaceKey,
                                             LabelManager labelManager,
                                             int maxResults,
                                             String user)

fixLabels

public static void fixLabels(List suggestedLabels)

extractLabelsFromLabellings

public static List extractLabelsFromLabellings(List labellings)
Simple utility method to extract the label instances from the given list of labelling instances.

Parameters:
labellings -
Returns:
a new list containing the referenced label instances.

getLabelFilters

public static ListFilter getLabelFilters(User user,
                                         boolean hideSpecialLabels)
returns only labels the user can see and also strips out special labels if 'hideSpecialLabels' flag is set



Confluence is developed by Atlassian.