Package com.atlassian.confluence.labels
Class Label
- java.lang.Object
-
- com.atlassian.core.bean.EntityObject
-
- com.atlassian.confluence.labels.Label
-
- All Implemented Interfaces:
Addressable,ContentTypeAware,DisplayableLabel,Serializable,Cloneable,Comparable<Label>
public class Label extends com.atlassian.core.bean.EntityObject implements Comparable<Label>, Addressable, Serializable, DisplayableLabel
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Label()Label(String name)Label(String name, Namespace namespace)Label(String name, Namespace namespace, @Nullable ConfluenceUser owner)Label(String name, Namespace namespace, @Nullable String owner)Deprecated.since 5.2.Label(String name, String namespace)Label(String name, String namespace, ConfluenceUser owner)Label(String name, String namespace, String owner)Deprecated.since 5.2.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(Label otherlabel)booleanequals(Object o)Equals implementation is a value based implementation.StringgetDisplayTitle()StringgetName()Returns the label's name only.NamespacegetNamespace()@Nullable StringgetOwner()Deprecated.since 5.2.@Nullable ConfluenceUsergetOwnerUser()StringgetRealTitle()Return the title as a combination of the namespace and the label name.StringgetType()StringgetUrlPath()Generates the url path for a label.StringgetUrlPath(String spaceKey)Generates the url path for a label in the context of a given space i.e.inthashCode()booleanisNew()Deprecated.since Confluence 5.1, do not use.booleanisPersistent()This label is persistent iff the id is not 0.booleanisRealTitleSafeForUrl()Returns true if the label's title is safe to pass in the URL.booleanisTeamLabel()booleanisVisibleTo(@Nullable String username)Determines whether the label should be made visible to a particular user.StringtoString()StringtoStringWithNamespace()StringtoStringWithOwnerPrefix()-
Methods inherited from class com.atlassian.core.bean.EntityObject
clone, getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.core.Addressable
getId
-
-
-
-
Constructor Detail
-
Label
public Label()
-
Label
public Label(String name)
-
Label
public Label(String name, String namespace, ConfluenceUser owner)
-
Label
@Deprecated public Label(String name, String namespace, String owner)
Deprecated.since 5.2. UseLabel(String, Namespace, com.atlassian.confluence.user.ConfluenceUser)instead.
-
Label
@Deprecated public Label(String name, Namespace namespace, @Nullable String owner)
Deprecated.since 5.2.- Parameters:
name-namespace-owner- username of the owner of this label.- Throws:
IllegalArgumentException- if the username supplied as the owner does not identify a known user.
-
Label
public Label(String name, Namespace namespace, @Nullable ConfluenceUser owner)
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:DisplayableLabelReturns the label's name only.eg. label name for label my:foo is "foo".
- Specified by:
getNamein interfaceDisplayableLabel
-
getOwner
@Deprecated public @Nullable String getOwner()
Deprecated.since 5.2. SeegetOwnerUser()instead.- Returns:
- the username of the owner of this label.
-
getOwnerUser
public @Nullable ConfluenceUser getOwnerUser()
- Since:
- 5.2
-
getNamespace
public Namespace getNamespace()
-
getType
public String getType()
- Specified by:
getTypein interfaceContentTypeAware- Returns:
- the content type
-
equals
public boolean equals(Object o)
Equals implementation is a value based implementation. It does not take into account the 'persistence' state of this label instance.- Overrides:
equalsin classcom.atlassian.core.bean.EntityObject- Returns:
- true if the specified object is considered value equivalent.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classcom.atlassian.core.bean.EntityObject
-
compareTo
public int compareTo(Label otherlabel)
- Specified by:
compareToin interfaceComparable<Label>
-
getRealTitle
public String getRealTitle()
Description copied from interface:DisplayableLabelReturn the title as a combination of the namespace and the label name.- Specified by:
getRealTitlein interfaceDisplayableLabel
-
getDisplayTitle
public String getDisplayTitle()
- Specified by:
getDisplayTitlein interfaceAddressable- Returns:
- the title of the addressable object, suitable for display in a list
-
isRealTitleSafeForUrl
public boolean isRealTitleSafeForUrl()
Description copied from interface:DisplayableLabelReturns true if the label's title is safe to pass in the URL.eg. my:foo is safe, perc% is not safe. chicken+cheese is safe in a "combined" label.
- Specified by:
isRealTitleSafeForUrlin interfaceDisplayableLabel- Returns:
- true if the label's title is safe to pass in the URL.
-
getUrlPath
public String getUrlPath()
Description copied from interface:DisplayableLabelGenerates the url path for a label.- Specified by:
getUrlPathin interfaceAddressable- Specified by:
getUrlPathin interfaceDisplayableLabel
-
getUrlPath
public String getUrlPath(String spaceKey)
Description copied from interface:DisplayableLabelGenerates the url path for a label in the context of a given space i.e. the user is taken to a page that contains content for that space only.If no space if provided,
DisplayableLabel.getUrlPath()is called.- Specified by:
getUrlPathin interfaceDisplayableLabel
-
isNew
@Deprecated public boolean isNew()
Deprecated.since Confluence 5.1, do not use.Deprecated since Confluence 5.1 because this method does not seem to do anything useful.Can not find a way to edit a label in Confluence, so getCreationDate() and getLastModificationDate() seem to always be equal, so this method will likely always return true.
Lack of documentation and seemingly no usage (in Confluence) indicates this method can be removed.
-
isPersistent
public boolean isPersistent()
This label is persistent iff the id is not 0.- Returns:
- true if this instance is a persisted label.
-
isVisibleTo
public boolean isVisibleTo(@Nullable String username)
Determines whether the label should be made visible to a particular user. This does not check the permissions on labelled content, you will need to do that separately- Parameters:
username- the username of the user who wishes to see the label- Returns:
- true if the user is permitted to see it, false otherwise
-
toStringWithOwnerPrefix
public String toStringWithOwnerPrefix()
-
toStringWithNamespace
public String toStringWithNamespace()
-
isTeamLabel
public boolean isTeamLabel()
-
-