Package io.github.mastodonContentMover
Class Post
java.lang.Object
io.github.mastodonContentMover.Post
Holds in an XML-persistable object all the data associated with a Mastodon status,
using
MediaFile objects to store metadata
associated with media files.
- Since:
- 0.01.00
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPost(String postId, String mastodonId, PostArchive pa) Loads thePostobject with the specified archiveId in the specifiedPostArchivefrom file if it is available, or creates a newPostobject if no data is found for that archiveId on the filesystem within the given data directory for the specifiedPostArchive. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddMastodonId(String mi) protected voidprotected Stringprotected longObtains as a primitivelongthe number of a count of favourites for the status represented by thisPostobject.protected Stringprotected Stringprotected StringReturns the most recent Mastodon instance id used for thisPoston the instance specified as a parameter.protected String[]getMedia()protected longObtains as a primitivelongthe number of times the Mastodon status represented by thisPostobject was reblogged.protected Stringprotected StringRetrieves the value of the Mastodonspoiler_textfield stored for thisPostobject.protected StringgetText()Retrieves the plain text that comprises the body of the Mastodon status thisPostobject represents.protected Stringprotected booleanhasMastodonId(String mi) protected booleanhasMedia()Indicates whether thisPostobject has any media attachments.protected booleanprotected booleanprotected booleanObtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is bookmarked by the account used to save it to the archive.protected booleanObtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is favourited by the account used to save it to the archive.protected booleanisPinned()Obtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is pinned by the account used to save it to the archive.protected booleanObtains as a primitivebooleanvalue the sensitivity of the Mastodon status represented by thisPostobject.protected voidHalts the saving to file of changes to thisPostobject as and when they are made, until this behaviour is restored with .protected voidResumes the saving to file of changes to thisPostobject as and when they are made, and saves its current state to file.protected voidsetFavouritesCount(long fc) Stores as a primitivelongthe number of favourites for the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.protected voidsetInReplyToArchiveId(String irtai) protected voidsetIsBookmarked(boolean ib) Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is bookmarked by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected voidsetIsFavourited(boolean ifav) Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is favourited by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected voidsetIsPinned(boolean ip) Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is pinned by the account used to save it to the archive, and saves the change to file if persistance has not been paused.protected voidsetIsSensitive(boolean is) Stores as a primitivebooleanvalue the sensitivity of the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.protected voidprotected voidsetReblogsCount(long rc) Stores as a primitivelongthe number of times the Mastodon status represented by thisPostobject was reblogged, and saves the change to file if persistance has not been paused.protected voidsetReblogUrl(String ru) protected voidsetSpoilerText(String st) Stores the value of the Mastodonspoiler_textfield in thisPostobject, and saves the change to file if persistance has not been paused.protected voidStores the Mastodon StatusSource, which is the plain text used to compose the status, to thisPostobject, and saves the change to file if persistance has not been paused.protected void
-
Constructor Details
-
Post
protected Post(String postId, String mastodonId, PostArchive pa) throws jakarta.xml.bind.JAXBException, IOException Loads thePostobject with the specified archiveId in the specifiedPostArchivefrom file if it is available, or creates a newPostobject if no data is found for that archiveId on the filesystem within the given data directory for the specifiedPostArchive.
Currently themastodonIdparameter can be null, but it would be better if a separate constructor was made without themastodonIdparameter. This constructor could then call that constructor and perform the processing required for themastodonIdspecified after receiving thePostobject from that constructor (including registering it with the archive). Then parameters would never need to be null. Also the postId parameter would really be better if it was named archiveId. (TODO)
Would also be good to mention in this doc info when this is likely to be called (TODO)- Parameters:
postId- the MastodonContentMover internal archiveId for this postmastodonId- the id for this post on a specific Mastodon instancepa- thePostArchivefrom which to load thePostobject- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)IllegalStateException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
-
Method Details
-
getArchiveId
Gives the MastodonContentMover internal id for thisPostobject, based on the creation date of the Mastodon post that was first downloaded and from which thisPostobject, in this archive, was first created.
For example, if you create an archive from "instance #1", use that archive to populate "instance #2", then create a fresh archive from "instance #2", the date that will be used for this comparison will be the date you used your initial archive to populate "instance #2" (not the date you first created the post on "instance #1").- Returns:
- the archiveId of this
Postobject - Since:
- 0.01.00
-
getLatestMastodonId
Returns the most recent Mastodon instance id used for thisPoston the instance specified as a parameter.- Parameters:
i- the instance address or hostname, specified as aString- Returns:
- the most recent Mastodon instance id, comprised of the address or hostname for that
instance and the internal id for this post on that instance, that was
retrieved when reposting this
Postfrom this archive to the instance specified. - Since:
- 0.01.00
- See Also:
-
addMastodonId
Associates with thisPostobject a new mastodonIdStringvalue, comprised of the Mastodon instance hostname/address concatenated with the id used for the status on that instance, and saves the change to file if persistance has not been paused.- Parameters:
mi- a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
hasMastodonId
Checks whether the specified mastodonIdStringvalue, comprised of a Mastodon instance hostname/address concatenated with the id used for the status on that instance, is already among those associated with thisPostobject.- Parameters:
mi- a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance- Since:
- 0.01.05
-
getMastodonIds
Obtains an ordered primitiveStringarray of all the mastodonId values associated with thisPostobject, each comprised of a Mastodon instance hostname/address concatenated with the id used for the status on that instance.
The array is ordered according to the sequence in which thisPostobject was reposted to each Mastodon instance. The same Mastodon instance may appear more than once in the list (although presumably not with the same id - if that has happened it probably means something has gone wrong, as the alternative of the same status having been assigned the same numeric id by the same instance on two separate occasions is highly unlikely - TODO: check for duplicates on adding?)- Returns:
- an array of
Stringobjects each containing a Mastodon instance hostname/address concatenated with a separator and the id used for the status on that instance - Since:
- 0.01.00
- See Also:
-
pausePersistence
protected void pausePersistence()Halts the saving to file of changes to thisPostobject as and when they are made, until this behaviour is restored with .- Since:
- 0.01.00
-
resumePersistence
Resumes the saving to file of changes to thisPostobject as and when they are made, and saves its current state to file.- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
-
setText
Stores the Mastodon StatusSource, which is the plain text used to compose the status, to thisPostobject, and saves the change to file if persistance has not been paused.- Parameters:
pt- the plain text that comprises the body of this post- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
-
getText
Retrieves the plain text that comprises the body of the Mastodon status thisPostobject represents.- Returns:
- the body text of this
Postobject in plain text - Since:
- 0.01.00
-
setSpoilerText
Stores the value of the Mastodonspoiler_textfield in thisPostobject, and saves the change to file if persistance has not been paused.- Parameters:
st- the text used to apply a spoiler or content warning on this post, also known elsewhere on ActivityPub as a summary- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getSpoilerText
- Returns:
- the text used to apply a spoiler or content warning on this post, also
known elsewhere on ActivityPub as a summary
- Since:
- 0.01.00
- See Also:
-
setVisibility
Stores as aStringvalue the visibility of the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.
At time of writing, values are:
- public = Visible to everyone, shown in public timelines.
- unlisted = Visible to public, but not included in public timelines.
- private = Visible to followers only, and to any mentioned users.
- direct = Visible only to mentioned users.
- Parameters:
v- the visibility of the status represented by thisPostobject- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getVisibility
Obtains as aStringvalue the visibility of the Mastodon status represented by thisPostobject.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.
At time of writing, values are:
- public = Visible to everyone, shown in public timelines.
- unlisted = Visible to public, but not included in public timelines.
- private = Visible to followers only, and to any mentioned users.
- direct = Visible only to mentioned users.
- Returns:
- the visibility of the status represented by this
Postobject - Since:
- 0.01.00
- See Also:
-
setIsSensitive
Stores as a primitivebooleanvalue the sensitivity of the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.- Parameters:
is-truefor statuses that should be concealed beneath a spoiler or content warning, orfalsewhere that is not the case- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isSensitive
protected boolean isSensitive()Obtains as a primitivebooleanvalue the sensitivity of the Mastodon status represented by thisPostobject.- Returns:
truefor statuses that should be concealed beneath a spoiler or content warning, orfalsewhere that is not the case- Since:
- 0.01.00
- See Also:
-
setInReplyToArchiveId
protected void setInReplyToArchiveId(String irtai) throws jakarta.xml.bind.JAXBException, IOException Stores the MastodonContentMover internal archiveId for aPostobject to which thisPostobject is a reply, and saves the change to file if persistance has not been paused.
This tool only links self-replies in this way, not replies to statuses by other users.- Parameters:
irtai- thearchiveIdfor aPostobject to which thisPostobject is a reply- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getInReplyToArchiveId
Obtains the MastodonContentMover internal archiveId for aPostobject to which thisPostobject is a reply.
This tool only links self-replies in this way, not replies to statuses by other users. -
setReblogUrl
Stores as aStringthe URL of a Mastodon status that was reblogged in the status thisPostobject represents, and saves the change to file if persistance has not been paused.- Parameters:
ru- the url of a Mastodon status reblogged in thisPostobject- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getReblogUrl
Obtains as aStringthe URL of a Mastodon status that was reblogged in the status thisPostobject represents.
In order to repost this reblogged status, it is necessary to search for this URL on the Mastodon instance where thisPostobject is being reposted, using "resolve=true", to get the status id on that instance. (This is not implemented yet - TODO!)- Returns:
- the url of a Mastodon status reblogged in this
Postobject - Since:
- 0.01.00
- See Also:
-
setLanguage
Stores as aStringvalue an ISO 639 Part 1 two-letter language code for the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.- Parameters:
l- an ISO 639 Part 1 two-letter language code for the status represented by thisPostobject- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getLanguage
Obtains as aStringvalue an ISO 639 Part 1 two-letter language code for the Mastodon status represented by thisPostobject.
As specified in the Mastodon API documentation, and must match the value used in the BigBone API used by this tool to interact with the Mastodon API.- Returns:
- an ISO 639 Part 1 two-letter language code for the status represented by
this
Postobject - Since:
- 0.01.00
- See Also:
-
setIsFavourited
Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is favourited by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether a status created when thisPostis reposted should be favourited again, based also on the parameters specified when the tool is run. (TODO)- Parameters:
ifav-truefor statuses that have been favourited by the account used to save it to the archive, orfalseotherwise- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isFavourited
protected boolean isFavourited()Obtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is favourited by the account used to save it to the archive.
This field may later be used to determine whether a status created when thisPostis reposted should be favourited again, based also on the parameters specified when the tool is run. (TODO)- Returns:
truefor statuses that have been favourited by the account used to save it to the archive, orfalseotherwise- Since:
- 0.01.00
- See Also:
-
setIsBookmarked
Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is bookmarked by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field is used to determine whether a status created when thisPostis reposted should be bookmarked again, based also on the parameters specified when the tool is run.- Parameters:
ib-truefor statuses that have been bookmarked by the account used to save it to the archive, orfalseotherwise- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isBookmarked
protected boolean isBookmarked()Obtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is bookmarked by the account used to save it to the archive.
This field is used to determine whether a status created when thisPostis reposted should be bookmarked again, based also on the parameters specified when the tool is run.- Returns:
truefor statuses that have been bookmarked by the account used to save it to the archive, orfalseotherwise- Since:
- 0.01.00
- See Also:
-
setIsPinned
Stores as a primitivebooleanwhether the Mastodon status represented by thisPostobject is pinned by the account used to save it to the archive, and saves the change to file if persistance has not been paused.
This field is used to determine whether a status created when thisPostis reposted should be pinned again, based also on the parameters specified when the tool is run.- Parameters:
ip-truefor statuses that have been pinned by the account used to save it to the archive, orfalseotherwise- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
isPinned
protected boolean isPinned()Obtains a primitivebooleanvalue that indicates whether the Mastodon status represented by thisPostobject is pinned by the account used to save it to the archive.
This field is used to determine whether a status created when thisPostis reposted should be pinned again, based also on the parameters specified when the tool is run.- Returns:
truefor statuses that have been pinned by the account used to save it to the archive, orfalseotherwise- Since:
- 0.01.00
- See Also:
-
setFavouritesCount
Stores as a primitivelongthe number of favourites for the Mastodon status represented by thisPostobject, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether or not to repost thisPostobject, based on a threshold specified when the tool is run. (TODO)- Parameters:
fc- the number of favourites for the Mastodon status represented by thisPostobject when it was saved to the archive- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getFavouritesCount
protected long getFavouritesCount()Obtains as a primitivelongthe number of a count of favourites for the status represented by thisPostobject.
This may later be used to determine whether or not to repost thisPostobject, based on a threshold specified when the tool is run. (TODO)- Returns:
- the count of favourites for the Mastodon status represented by this
Postobject when it was saved to the archive - Since:
- 0.01.00
- See Also:
-
setReblogsCount
Stores as a primitivelongthe number of times the Mastodon status represented by thisPostobject was reblogged, and saves the change to file if persistance has not been paused.
This field may later be used to determine whether or not to repost thisPostobject, based on a threshold specified when the tool is run. (TODO)- Parameters:
rc- the number of times the Mastodon status represented by thisPostobject had been reblogged when it was saved to the archive- Throws:
jakarta.xml.bind.JAXBException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
getReblogsCount
protected long getReblogsCount()Obtains as a primitivelongthe number of times the Mastodon status represented by thisPostobject was reblogged.
This may later be used to determine whether or not to repost thisPostobject, based on a threshold specified when the tool is run. (TODO)- Returns:
- the number of times the Mastodon status represented by this
Postobject had been reblogged when it was saved to the archive - Since:
- 0.01.00
- See Also:
-
addMedia
protected void addMedia(String u, String mmt, String tu, String at, float x, float y) throws FileNotFoundException, MalformedURLException, IOException Saves media from a URL and attaches it to thisPostobject, together with its thumbnail (when it is a video) and other metadata used by Mastodon, as aMediaFileobject.- Parameters:
u- the URL for the media filemmt- the media type as specified by/for Mastodontu- the URL of the thumbnail for this mediaat- the "alt text" or description of this mediax- the x-coordinate of the Mastodon focal point for this mediay- the y-coordinate of the Mastodon focal point for this media- Throws:
FileNotFoundException- (TODO: add more info here on when this happens)MalformedURLException- (TODO: add more info here on when this happens)IOException- (TODO: add more info here on when this happens)- Since:
- 0.01.00
- See Also:
-
hasMedia
protected boolean hasMedia()- Returns:
trueif thisPostobject has any media attachments, orfalseotherwise- Since:
- 0.01.00
-
getMedia
Obtains media attached to thisPostobject, as aListofMediaFileobjects.
A read-only, deep-cloned version *should* be returned here; right now the objects returned are the actual data objects held within thisPostobject, when there is no need to modify them programmatically. This should be fixed *asap* as inadvertent changes to the data within could then be persisted and the archive may be damaged (TODO: make MediaFile cloneable then do a deep copy of the array list here) -
isAfter
Determines whether thisPostobject was created (so far as the tool is aware) after the given date and time, specified as an ISO 8601 compliantString.
This relies on the archiveId of the post, which in turn is based on the creation date of the Mastodon post that was first downloaded and from which thisPostobject, in this archive, was first created.
Handling of dates and their conversion into archiveIds is done byPostArchive -
isBefore
Determines whether thisPostobject was created (so far as the tool is aware) before the given date and time, specified as an ISO 8601 compliantString.
This relies on the archiveId of the post, which in turn is based on the creation date of the Mastodon post that was first downloaded and from which thisPostobject, in this archive, was first created.
Handling of dates and their conversion into archiveIds is done byPostArchive
-