Class MediaFile

java.lang.Object
io.github.mastodonContentMover.MediaFile

public class MediaFile extends Object
Holds in an XML-persistable object the metadata associated with a media file attached to a Post object. Because this class uses JAXB and instances of it are held within Post objects, persistance is managed by the associated Post object (instances of this class are saved when the Post object that contains them are saved), so no marshalling or unmarshalling code is needed here.
Since:
0.01.00
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a MediaFile object with the filename specified.
    protected
    MediaFile(String fn, String d, String tfn, String mm, String at, float x, float y)
    Creates a MediaFile object with the filename, directory, Mastodon media type, thumbnail filename, alt text (description) and focal point coordinates (x and y) specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    Retrieves the alt text or description of the content in the media file associated with this MediaFile, corresponding to the description field within Mastodon.
    protected String
    Retrieves the path on the local file system for the media file associated with this MediaFile object.
    protected float
    Retrieves x coordinate of the focal point for the media file associated with this MediaFile object.
    protected float
    Retrieves y coordinate of the focal point for the media file associated with this MediaFile object.
    protected String
    Retrieves the Mastodon media type for the media file associated with this MediaFile, corresponding to the description field within Mastodon.
    protected String
    Retrieves the MIME type of the media file associated with this MediaFile object, used when reuploading the file to Mastodon to attach to a reposted status.
    protected String
    Retrieves the path on the local file system for the thumbnail for the media file associated with this MediaFile object.
    protected static String
    Obtain the suffix that should be attached to the name of a media file (without the file extension) when naming a thumbnail for that media file.
    protected void
    Stores the value of the Mastodon description field, which is an alt text or description, for the media file associated with this MediaFile object.
    protected void
    Stores the directory where the media file associated with this MediaFile object is stored on the local file system.
    protected void
    setFocalPoint(float x, float y)
    Stores the x and y coordinates of the focal point for the media file associated with this MediaFile object, which allow Mastodon to preview a limited area of an image according to the user's preferences when not all of it is visible in the user interface.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MediaFile

      protected MediaFile(String fn)
      Creates a MediaFile object with the filename specified.

      Parameters:
      fn - the filename for the media file to be associated with this MediaFile object
      Since:
      0.01.00
    • MediaFile

      protected MediaFile(String fn, String d, String tfn, String mm, String at, float x, float y)
      Creates a MediaFile object with the filename, directory, Mastodon media type, thumbnail filename, alt text (description) and focal point coordinates (x and y) specified.

      MIME type is determined based on the extension of the media file, so it can be used when reuploading the file to Mastodon to attach to a reposted status.

      Parameters:
      fn - the filename for the media file to be associated with this MediaFile object
      d - the directory where the media file is stored within the local file system
      tfn - the filename of a thumbnail for the media file
      mm - the Mastodon media type
      at - the alt text or description of the content in this media file
      x - the x coordinate for the focal point for this media file
      y - the y coordinate for the focal point for this media file

      Since:
      0.01.00
      See Also:
  • Method Details

    • setDirectory

      protected void setDirectory(String d)
      Stores the directory where the media file associated with this MediaFile object is stored on the local file system.

      Parameters:
      d - the directory where the media file is stored

      Since:
      0.01.00
    • getFilepath

      protected String getFilepath()
      Retrieves the path on the local file system for the media file associated with this MediaFile object.

      Returns:
      the path on the local file system for the media file

      Since:
      0.01.00
    • getThumbnailFilepath

      protected String getThumbnailFilepath()
      Retrieves the path on the local file system for the thumbnail for the media file associated with this MediaFile object.

      Returns:
      the path on the local file system for the thumbnail file

      Since:
      0.01.00
    • getThumbnailFileSuffix

      protected static String getThumbnailFileSuffix()
      Obtain the suffix that should be attached to the name of a media file (without the file extension) when naming a thumbnail for that media file.

      Returns:
      the suffix

      Since:
      0.01.00
    • getMimeType

      protected String getMimeType()
      Retrieves the MIME type of the media file associated with this MediaFile object, used when reuploading the file to Mastodon to attach to a reposted status.

      Returns:
      the MIME type of the media file

      Since:
      0.01.00
    • getMastodonMediaType

      protected String getMastodonMediaType()
      Retrieves the Mastodon media type for the media file associated with this MediaFile, corresponding to the description field within Mastodon. object.

      Returns:
      the Mastodon media type for the media file

      Since:
      0.01.00
      See Also:
    • setAltText

      protected void setAltText(String at)
      Stores the value of the Mastodon description field, which is an alt text or description, for the media file associated with this MediaFile object.

      Parameters:
      at - the alt text or description of the content in the media file

      Since:
      0.01.00
      See Also:
    • getAltText

      protected String getAltText()
      Retrieves the alt text or description of the content in the media file associated with this MediaFile, corresponding to the description field within Mastodon. object.

      Returns:
      the alt text or description of the content in the media file

      Since:
      0.01.00
      See Also:
    • setFocalPoint

      protected void setFocalPoint(float x, float y)
      Stores the x and y coordinates of the focal point for the media file associated with this MediaFile object, which allow Mastodon to preview a limited area of an image according to the user's preferences when not all of it is visible in the user interface.

      Parameters:
      x - the x coordinate for the focal point for this media file
      y - the y coordinate for the focal point for this media file

      Since:
      0.01.00
      See Also:
    • getFocalPointX

      protected float getFocalPointX()
      Retrieves x coordinate of the focal point for the media file associated with this MediaFile object.

      Returns:
      the x coordinate for the focal point for this media file

      Since:
      0.01.00
      See Also:
    • getFocalPointY

      protected float getFocalPointY()
      Retrieves y coordinate of the focal point for the media file associated with this MediaFile object.

      Returns:
      the y coordinate for the focal point for this media file

      Since:
      0.01.00
      See Also: