Package org.javacord.core.util
Class FileContainer
- java.lang.Object
-
- org.javacord.core.util.FileContainer
-
public class FileContainer extends java.lang.Object
A helper class which contains a file which can be in different formats.
-
-
Constructor Summary
Constructors Constructor Description FileContainer(byte[] file, java.lang.String type)
Creates a new file container with an url.FileContainer(byte[] file, java.lang.String type, java.lang.String description)
Creates a new file container with a byte array.FileContainer(java.awt.image.BufferedImage file, java.lang.String type)
Creates a new file container with a buffered image.FileContainer(java.awt.image.BufferedImage file, java.lang.String type, java.lang.String description)
Creates a new file container with a buffered image.FileContainer(java.io.File file)
Creates a new file container with a file.FileContainer(java.io.File file, boolean isSpoiler)
Creates a new file container with a file.FileContainer(java.io.File file, boolean isSpoiler, java.lang.String description)
Creates a new file container with a file.FileContainer(java.io.File file, java.lang.String description)
Creates a new file container with a file.FileContainer(java.io.InputStream file, java.lang.String type)
Creates a new file container with an input stream.FileContainer(java.io.InputStream file, java.lang.String type, java.lang.String description)
Creates a new file container with an input stream.FileContainer(java.net.URL file)
Creates a new file container with an url.FileContainer(java.net.URL file, boolean isSpoiler)
Creates a new file container with an url.FileContainer(java.net.URL file, boolean isSpoiler, java.lang.String description)
Creates a new file container with a byte array.FileContainer(java.net.URL file, java.lang.String description)
Creates a new file container with an url.FileContainer(Icon file)
Creates a new file container with an icon.FileContainer(Icon file, boolean isSpoiler)
Creates a new file container with an icon.FileContainer(Icon file, boolean isSpoiler, java.lang.String description)
Creates a new file container with an icon.FileContainer(Icon file, java.lang.String description)
Creates a new file container with an icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage>
asBufferedImage(DiscordApi api)
Gets the file asBufferedImage
.java.util.concurrent.CompletableFuture<byte[]>
asByteArray(DiscordApi api)
Gets the byte array for the file.java.io.InputStream
asInputStream(DiscordApi api)
Gets the input stream for the file.java.lang.String
getDescription()
Gets the description of the file.java.lang.String
getFileType()
Gets the type ("png", "txt", ...) of the file.java.lang.String
getFileTypeOrName()
Gets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.void
setFileTypeOrName(java.lang.String type)
Sets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
-
-
-
Constructor Detail
-
FileContainer
public FileContainer(java.awt.image.BufferedImage file, java.lang.String type)
Creates a new file container with a buffered image.- Parameters:
file
- The file as a buffered image.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
-
FileContainer
public FileContainer(java.awt.image.BufferedImage file, java.lang.String type, java.lang.String description)
Creates a new file container with a buffered image.- Parameters:
file
- The file as a buffered image.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.description
- The description of the file.
-
FileContainer
public FileContainer(java.io.File file)
Creates a new file container with a file.- Parameters:
file
- The file as a file.
-
FileContainer
public FileContainer(java.io.File file, boolean isSpoiler)
Creates a new file container with a file.- Parameters:
file
- The file as a file.isSpoiler
- Whether the file is to be marked as spoiler.
-
FileContainer
public FileContainer(java.io.File file, java.lang.String description)
Creates a new file container with a file.- Parameters:
file
- The file as a file.description
- The description of the file.
-
FileContainer
public FileContainer(java.io.File file, boolean isSpoiler, java.lang.String description)
Creates a new file container with a file.- Parameters:
file
- The file as a file.isSpoiler
- Whether the file is to be marked as spoiler.description
- The description of the file.
-
FileContainer
public FileContainer(Icon file)
Creates a new file container with an icon.- Parameters:
file
- The file as an icon.
-
FileContainer
public FileContainer(Icon file, boolean isSpoiler)
Creates a new file container with an icon.- Parameters:
file
- The file as an icon.isSpoiler
- Whether the icon is marked as a spoiler.
-
FileContainer
public FileContainer(Icon file, java.lang.String description)
Creates a new file container with an icon.- Parameters:
file
- The file as an icon.description
- The description of the icon.
-
FileContainer
public FileContainer(Icon file, boolean isSpoiler, java.lang.String description)
Creates a new file container with an icon.- Parameters:
file
- The file as an icon.isSpoiler
- Whether the icon is marked as a spoiler.description
- The description of the icon.
-
FileContainer
public FileContainer(java.net.URL file)
Creates a new file container with an url.- Parameters:
file
- The file as an url.
-
FileContainer
public FileContainer(java.net.URL file, java.lang.String description)
Creates a new file container with an url.- Parameters:
file
- The file as an url.description
- The description of the url.
-
FileContainer
public FileContainer(java.net.URL file, boolean isSpoiler)
Creates a new file container with an url.- Parameters:
file
- The file as an url.isSpoiler
- Whether the file is to be marked as spoiler.
-
FileContainer
public FileContainer(java.net.URL file, boolean isSpoiler, java.lang.String description)
Creates a new file container with a byte array.- Parameters:
file
- The file as an url.isSpoiler
- Whether the file is to be marked as spoiler.description
- The description of the url.
-
FileContainer
public FileContainer(byte[] file, java.lang.String type)
Creates a new file container with an url.- Parameters:
file
- The file as a byte array.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
-
FileContainer
public FileContainer(byte[] file, java.lang.String type, java.lang.String description)
Creates a new file container with a byte array.- Parameters:
file
- The file as a byte array.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.description
- The description of the file.
-
FileContainer
public FileContainer(java.io.InputStream file, java.lang.String type)
Creates a new file container with an input stream.- Parameters:
file
- The file as an input stream.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
-
FileContainer
public FileContainer(java.io.InputStream file, java.lang.String type, java.lang.String description)
Creates a new file container with an input stream.- Parameters:
file
- The file as an input stream.type
- The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.description
- The description of the file.
-
-
Method Detail
-
setFileTypeOrName
public void setFileTypeOrName(java.lang.String type)
Sets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.- Parameters:
type
- The type or name of the file.
-
getFileType
public java.lang.String getFileType()
Gets the type ("png", "txt", ...) of the file.- Returns:
- The type of the file.
-
getFileTypeOrName
public java.lang.String getFileTypeOrName()
Gets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.- Returns:
- The type or name of the file.
-
getDescription
public java.lang.String getDescription()
Gets the description of the file.- Returns:
- The description of the file.
-
asByteArray
public java.util.concurrent.CompletableFuture<byte[]> asByteArray(DiscordApi api)
Gets the byte array for the file.- Parameters:
api
- The discord api instance.- Returns:
- The byte array stream for the file.
-
asInputStream
public java.io.InputStream asInputStream(DiscordApi api) throws java.io.IOException
Gets the input stream for the file.- Parameters:
api
- The discord api instance.- Returns:
- The input stream for the file.
- Throws:
java.io.IOException
- If an IO error occurs.
-
asBufferedImage
public java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage> asBufferedImage(DiscordApi api)
Gets the file asBufferedImage
.- Parameters:
api
- The discord api instance.- Returns:
- The file as BufferedImage.
-
-