Package com.atlassian.adf.model.node
Interface Media
-
- All Superinterfaces:
Element,Fold3<Media.FileMedia,Media.LinkMedia,Media.ExternalMedia>,Marked<Media,MediaMark>,Node
- All Known Implementing Classes:
Media.AbstractMedia,Media.ExternalMedia,Media.FileMedia,Media.FileOrLinkMedia,Media.LinkMedia
@Documentation(state=WRONG, date="2023-07-26", comment="\'external\' type, its different requirements, and the \'link\' and \'border\' marks are undocumented") public interface Media extends Node, Marked<Media,MediaMark>, Fold3<Media.FileMedia,Media.LinkMedia,Media.ExternalMedia>
Represents a single file or link stored in media services. There is also anexternalmedia type which takes a URL instead of Media Services information.Example
Java
Or equivalently:Media.fileMedia( "6e7c7f2c-dd7a-499c-bceb-6f32bfbf30b5", "my project files" ).size(200, 183);Media.media() .file() .id("6e7c7f2c-dd7a-499c-bceb-6f32bfbf30b5") .collection("my project files"); .size(200, 183);ADF
{ "type": "media", "attrs": { "id": "6e7c7f2c-dd7a-499c-bceb-6f32bfbf30b5", "collection": "my project files", "type": "file", "width": 200, "height": 183 } }Result
Notes:
- The media
collectionis being phased out, but it is currently still required by the JSON schema. This node allows the caller to fail to set it or set it tonull, but will substitute the empty string""instead, for the time being. - This example uses a data URI to embed the image instead of retrieving the image from media services, which uses a different mechanism to supply the image content.
- See Also:
- Node - media
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMedia.AbstractMedia<N extends Media.AbstractMedia<N>>static classMedia.ExternalMediastatic classMedia.FileMediastatic classMedia.FileOrLinkMedia<T extends Media.FileOrLinkMedia<T>>static classMedia.LinkMediastatic classMedia.MediaTypestatic interfaceMedia.PartialTypes that represent a partially constructedmedia.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description Optional<String>alt()Mediaalt(String alt)Optional<Border>border()Mediaborder(int size, String color)Mediaborder(Border border)Mediaborder(String color)Optional<Media.ExternalMedia>external()static Media.Partial.ExternalNeedsUrlexternalMedia()static Media.ExternalMediaexternalMedia(String url)static Media.ExternalMediaexternalMedia(URI url)static Media.ExternalMediaexternalMedia(URL url)Optional<Media.FileMedia>file()static Media.Partial.FileNeedsIdfileMedia()Begins the fluent construction of afilemedia node.static Media.FileMediafileMedia(String id)static Media.FileMediafileMedia(String id, String collection)Creates a newFILEmedia node with the given media ID and collection ID.<R> Rfold(Function<? super Media.FileMedia,? extends R> ifFile, Function<? super Media.LinkMedia,? extends R> ifLink, Function<? super Media.ExternalMedia,? extends R> ifExternal)Optional<Number>height()Returns the media node's display height, if set.Mediaheight(Number height)Sets the height of the media.voidifExternal(Consumer<? super Media.ExternalMedia> effect)voidifFile(Consumer<? super Media.FileMedia> effect)voidifLink(Consumer<? super Media.LinkMedia> effect)Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.booleanisExternal()booleanisFile()booleanisLink()Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.Optional<Media.LinkMedia>link()Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.Optional<Link>linkMark()MedialinkMark(Link link)MedialinkMark(String href)MedialinkMark(URL url)static Media.Partial.LinkNeedsIdlinkMedia()Begins the fluent construction of alinkmedia node.static Media.LinkMedialinkMedia(String id)static Media.LinkMedialinkMedia(String id, String collection)Creates a newLINKmedia node with the given media ID and collection ID.static Media.Partial.NeedsTypemedia()Begins the fluent construction of a media node.Mediasize(Number width, Number height)Sets the width and height of the media.Media.MediaTypetype()Returns the media node's type.Optional<Number>width()Returns the media node's display width, if set.Mediawidth(Number width)Sets the width of the media.-
Methods inherited from interface com.atlassian.adf.model.Element
elementType, isSupported, toMap, validate
-
Methods inherited from interface com.atlassian.adf.model.node.type.Marked
copy, mark, mark, markClass, marks, marks, markTypes
-
Methods inherited from interface com.atlassian.adf.model.node.Node
appendPlainText, toPlainText
-
-
-
-
Method Detail
-
media
@CheckReturnValue static Media.Partial.NeedsType media()
Begins the fluent construction of a media node.- Returns:
- an incomplete media node that needs the type to be specified
-
fileMedia
@CheckReturnValue static Media.Partial.FileNeedsId fileMedia()
Begins the fluent construction of afilemedia node. All required fields must also be specified before the media node is valid.- Returns:
- a partial
filemedia node
-
fileMedia
@CheckReturnValue static Media.FileMedia fileMedia(String id)
-
fileMedia
static Media.FileMedia fileMedia(String id, @Nullable String collection)
Creates a newFILEmedia node with the given media ID and collection ID.- Parameters:
id- the Media Services ID used for querying the media services API to retrieve metadata, such as the filename. Consumers of the document should always fetch fresh metadata using the Media API rather than cache it locally.collection- the Media Services Collection name for the media- Returns:
- the new
medianode
-
linkMedia
@CheckReturnValue static Media.Partial.LinkNeedsId linkMedia()
Begins the fluent construction of alinkmedia node. All required fields must also be specified before the media node is valid.- Returns:
- a partial
linkmedia node
-
linkMedia
@CheckReturnValue static Media.LinkMedia linkMedia(String id)
-
linkMedia
static Media.LinkMedia linkMedia(String id, @Nullable String collection)
Creates a newLINKmedia node with the given media ID and collection ID.- Parameters:
id- the Media Services ID used for querying the media services API to retrieve metadata, such as the filename. Consumers of the document should always fetch fresh metadata using the Media API rather than cache it locally.collection- the Media Services Collection name for the media- Returns:
- the new
medianode
-
externalMedia
@CheckReturnValue static Media.Partial.ExternalNeedsUrl externalMedia()
-
externalMedia
static Media.ExternalMedia externalMedia(String url)
-
externalMedia
static Media.ExternalMedia externalMedia(URL url)
-
externalMedia
static Media.ExternalMedia externalMedia(URI url)
-
type
Media.MediaType type()
Returns the media node's type.- Returns:
- the media node's type.
-
width
Optional<Number> width()
Returns the media node's display width, if set.- Returns:
- the media node's display width, or
empty()if not set.
-
width
Media width(@Nullable Number width)
Sets the width of the media. Although this attribute is optional, it must be set for themediaitem in amediaSinglenode, or the media is not displayed.- Parameters:
width- the display width of the media item, in pixels; must be positive- Returns:
this
-
height
Optional<Number> height()
Returns the media node's display height, if set.- Returns:
- the media node's display height, or
empty()if not set.
-
height
Media height(@Nullable Number height)
Sets the height of the media. Although this attribute is optional, it must be set for themediaitem in amediaSinglenode, or the media is not displayed.- Parameters:
height- the display height of the media item, in pixels; must be positive- Returns:
this
-
size
Media size(@Nullable Number width, @Nullable Number height)
Sets the width and height of the media.This convenience method is exactly equivalent to calling
.width(width).height(height)- Parameters:
width- as forwidth(Number)height- as forheight(Number)- Returns:
this
-
fold
<R> R fold(Function<? super Media.FileMedia,? extends R> ifFile, Function<? super Media.LinkMedia,? extends R> ifLink, Function<? super Media.ExternalMedia,? extends R> ifExternal)
- Specified by:
foldin interfaceFold3<Media.FileMedia,Media.LinkMedia,Media.ExternalMedia>
-
file
Optional<Media.FileMedia> file()
-
link
@Deprecated Optional<Media.LinkMedia> link()
Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.
-
external
Optional<Media.ExternalMedia> external()
-
ifFile
void ifFile(Consumer<? super Media.FileMedia> effect)
-
ifLink
@Deprecated void ifLink(Consumer<? super Media.LinkMedia> effect)
Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.
-
ifExternal
void ifExternal(Consumer<? super Media.ExternalMedia> effect)
-
isFile
boolean isFile()
-
isLink
@Deprecated boolean isLink()
Deprecated.Most of the support forlinkmedia no longer functions in the editor code base, so clients are unlikely to encounter it in the wild and should not use it in new ADF.
-
isExternal
boolean isExternal()
-
-