Package com.atlassian.adf.model.mark
Class Link
- java.lang.Object
-
- com.atlassian.adf.model.mark.Link
-
- All Implemented Interfaces:
Element,Mark,CodeTextMark,FormattedTextMark,MediaInlineMark,MediaMark,MediaSingleMark,TextMark
@Documentation(state=INCOMPLETE, date="2023-07-26", comment="missing descriptions for media attributes") public class Link extends Object implements CodeTextMark, FormattedTextMark, MediaMark, MediaInlineMark, MediaSingleMark
Thelinkmark sets a hyperlink. This mark applies toTextnodes and cannot be combined with thetextColormark.Example
Java
text("Hello world").mark(link("http://atlassian.com") .title("Atlassian") );ADF
{ "type": "text", "text": "Hello world", "marks": [ { "type": "link", "attrs": { "href": "http://atlassian.com", "title": "Atlassian" } } ] }Result
- See Also:
- Mark - link
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.adf.model.Element
Element.Key
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Linka(String href)static Linka(URI href)static Linka(URL href)Optional<String>collection()Linkcollection(String collection)Linkcopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.StringelementType()Thetypevalue that identifies this element, such as"paragraph"or"strong".booleanequals(Object o)inthashCode()Stringhref()Returns thehrefvalue for the link; that is, its target URI.Linkhref(String href)Modifies this link's target.Linkhref(URI href)Modifies this link's target.Linkhref(URL href)Modifies this link's target.Optional<String>id()Linkid(String id)booleanisSupported()Indicates whether this element is fully supported by this library.static Linklink(String href)static Linklink(URI href)static Linklink(URL href)protected FieldMapmapWithType()Optional<String>occurrenceKey()LinkoccurrenceKey(String occurrenceKey)Optional<String>title()Returns thetitlevalue for this link, if set.Linktitle(String title)Map<String,?>toMap()Transforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.StringtoString()voidvalidate()Verifies that the node is well-formed (including the state of any descendents that it has).-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.adf.model.Element
isSupported, validate
-
-
-
-
Method Detail
-
a
public static Link a(String href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark - Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
a
public static Link a(URL href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark - Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
a
public static Link a(URI href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark
-
link
public static Link link(String href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark - Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
link
public static Link link(URL href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark - Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
link
public static Link link(URI href)
- Parameters:
href- the URI for the hyperlink, equivalent to thehrefvalue for an HTML<a>element- Returns:
- a
linkmark
-
copy
public Link copy()
Description copied from interface:ElementReturns a deep copy of this element, including copies of any nodes or marks that it contains. The copy will not necessarily be in exactly the same state as the original in some cases. For example, atextnode that is used inside acodeBlockwill have the ability to use marks on it disabled, but a copy made of the text node using this method will not similarly disallow marks unless it is also added to a content node with those same restrictions.Implementations notes:
- Implementations should narrow the return type.
- Implementations should
return thisif the element is immutable. The@Immutableannotation should be used on the class to offer additional confirmation of this intent. - Implementations should
return parse(toMap())if they have state. - While there may be cases where it is worthwhile to do something more efficient than
the conversion to a map and back, this is discouraged because it would add yet another
fragile piece of code that breaks when new data is added to the node. The
parseandtoMapmethods already have to be updated in these circumstances, so it makes sense to take advantage of that.
- Specified by:
copyin interfaceCodeTextMark- Specified by:
copyin interfaceElement- Specified by:
copyin interfaceFormattedTextMark- Specified by:
copyin interfaceMark- Specified by:
copyin interfaceMediaInlineMark- Specified by:
copyin interfaceMediaMark- Specified by:
copyin interfaceMediaSingleMark- Specified by:
copyin interfaceTextMark- Returns:
- a copy of this element, or
thisif the element is immutable anyway
-
title
public Optional<String> title()
Returns thetitlevalue for this link, if set.- Returns:
- the
titlevalue for this link, orempty()if not set.
-
href
public String href()
Returns thehrefvalue for the link; that is, its target URI.
-
href
public Link href(String href)
Modifies this link's target.- Parameters:
href- the new target URI for this link- Returns:
this- Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
href
public Link href(URL href)
Modifies this link's target.- Parameters:
href- the new target URI for this link- Returns:
this- Throws:
AdfException.InvalidURI- ifhrefcannot be parsed as a valid URI
-
href
public Link href(URI href)
Modifies this link's target.- Parameters:
href- the new target URI for this link- Returns:
this
-
title
public Link title(@Nullable String title)
- Parameters:
title- the title text for the hyperlink, equivalent to thetitlevalue for an HTML<a>element- Returns:
this
-
elementType
public String elementType()
Description copied from interface:ElementThetypevalue that identifies this element, such as"paragraph"or"strong".- Specified by:
elementTypein interfaceElement
-
toMap
public Map<String,?> toMap()
Description copied from interface:ElementTransforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.
-
toString
public String toString()
-
mapWithType
protected FieldMap mapWithType()
-
isSupported
public boolean isSupported()
Description copied from interface:ElementIndicates whether this element is fully supported by this library. This library includes a small amount of support for preserving new, unrecognized node types during a round trip. These are represented by immutable placeholder objects that returnfalsefor this value.- Specified by:
isSupportedin interfaceElement- Returns:
truefor fully supported elements;falsefor immutable placeholders
-
-