Package org.wikidata.wdtk.dumpfiles
Class MwRevisionImpl
java.lang.Object
org.wikidata.wdtk.dumpfiles.MwRevisionImpl
- All Implemented Interfaces:
MwRevision
Implementation of
MwRevision
. The implementation is meant to be used
as a lightweight container that is reusable and thus mutable, but only using
package-private access. Even without the re-use (which might be reconsidered)
the package-private mutability makes sense during the stateful XML parsing
process.- Author:
- Markus Kroetzsch
-
Field Summary
Fields inherited from interface org.wikidata.wdtk.dumpfiles.MwRevision
MODEL_WIKIBASE_ITEM, MODEL_WIKIBASE_LEXEME, MODEL_WIKIBASE_PROPERTY, MODEL_WIKITEXT, NO_REVISION_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the comment string that was used for making the edit that led to this revision.Returns the name for the contributor that made the edit that led to this revision.int
Returns the user id of the contributor who made the edit that led to this revision, or -1 if the edit was not made by a registered user.Returns the format of the revision text.getModel()
Returns the content model of the revision.int
Returns the id of the MediaWiki namespace of the revised page.int
Returns the numeric page id of the revised page.long
Returns the numeric id of the parent revision.Returns the title string of the revised page, including namespace prefixes and subpages, if any.long
Returns the numeric id of the current revision.getText()
Returns the text content of the current revision.Returns the time stamp at which the current revision was made.getTitle()
Returns the title string of the revised page without any namespace prefixes.boolean
Returns true if the contributor who made the edit that led to this revision was logged in with a user account.toString()
-
Constructor Details
-
MwRevisionImpl
public MwRevisionImpl()Constructor. -
MwRevisionImpl
Copy constructor.
-
-
Method Details
-
getPrefixedTitle
Description copied from interface:MwRevision
Returns the title string of the revised page, including namespace prefixes and subpages, if any. The string is formatted as it would be on an HTML page and not as in the URL used by MediaWiki for the page. For example, spaces are represented as spaces and not as underscores. For exampleOn a single MediaWiki site, the prefixed page title is a key for a page at any given moment. However, users may change the title and namespace by moving pages. The page id provides a better clue to identify pages across history.
- Specified by:
getPrefixedTitle
in interfaceMwRevision
- Returns:
- title string
-
getTitle
Description copied from interface:MwRevision
Returns the title string of the revised page without any namespace prefixes. The string is formatted as it would be on an HTML page and not as in the URL used by MediaWiki for the page. For example, spaces are represented as spaces and not as underscores. For exampleOn a single MediaWiki site, the combination of page title and page namespace is a key for a page at any given moment. However, users may change the title and namespace by moving pages. The page id provides a better clue to identify pages across history.
- Specified by:
getTitle
in interfaceMwRevision
- Returns:
- title string
-
getNamespace
public int getNamespace()Description copied from interface:MwRevision
Returns the id of the MediaWiki namespace of the revised page. The meaning of this id depends on the configuration of the site that the page is from. Usually, 0 is the main namespace. Even ids usually refer to normal article pages while their odd successors represent the corresponding talk namespace.On a single MediaWiki site, the combination of page title and page namespace is a key for a page at any given moment. However, users may change the title and namespace by moving pages. The page id provides a better clue to identify pages across history.
- Specified by:
getNamespace
in interfaceMwRevision
- Returns:
- integer namespace id
-
getPageId
public int getPageId()Description copied from interface:MwRevision
Returns the numeric page id of the revised page. For any given MediaWiki site, pages are uniquely identified by their page id. MediaWiki will try to preserve the page id even across title changes (moves).- Specified by:
getPageId
in interfaceMwRevision
- Returns:
- integer page id
-
getRevisionId
public long getRevisionId()Description copied from interface:MwRevision
Returns the numeric id of the current revision. For any given MediaWiki site, revisions are uniquely identified by their revision id. In particular, two distinct revisions can never have the same id, even if they belong to different pages.- Specified by:
getRevisionId
in interfaceMwRevision
- Returns:
- long revision id
-
getParentRevisionId
public long getParentRevisionId()Description copied from interface:MwRevision
Returns the numeric id of the parent revision. It is the id of the revision the current revision is based on. It returns -1 if there is no parent revision i.e. the page have been created.- Specified by:
getParentRevisionId
in interfaceMwRevision
- Returns:
- revision id
-
getTimeStamp
Description copied from interface:MwRevision
Returns the time stamp at which the current revision was made. The time stamp is a string that is formatted according to ISO 8601, such as "2014-02-19T23:34:16Z".- Specified by:
getTimeStamp
in interfaceMwRevision
- Returns:
- time stamp string
-
getText
Description copied from interface:MwRevision
Returns the text content of the current revision. Traditionally, this is a wiki text that is edited by users. More recently, however, other formats, such as JSON, have been introduced by extensions like Wikibase. The format of the text is specified byMwRevision.getFormat()
. To interpret it properly, one should also know the content model, obtained fromMwRevision.getModel()
.- Specified by:
getText
in interfaceMwRevision
- Returns:
- text content of the revision
-
getModel
Description copied from interface:MwRevision
Returns the content model of the revision. This specifies how the text content should be interpreted. Content models are usually configured for namespaces and thus remain rather stable across the history of a page. However, a page could in principle change its content model over time and every revision therefore specifies its own content model. All known models require a single format, obtained fromMwRevision.getFormat()
.- Specified by:
getModel
in interfaceMwRevision
- Returns:
- content model as a string
-
getFormat
Description copied from interface:MwRevision
Returns the format of the revision text. This string should be formatted as a MIME media type. Typical examples are "application/json" (JSON) and "text/x-wiki" (MediaWiki wikitext). To interpret the meaning of this format, one should also consider the content model obtained byMwRevision.getModel()
. Like the content model, the format might change between revisions of a page, but this is very rare in practice.- Specified by:
getFormat
in interfaceMwRevision
- Returns:
- MIME type for revision text
-
getComment
Description copied from interface:MwRevision
Returns the comment string that was used for making the edit that led to this revision.- Specified by:
getComment
in interfaceMwRevision
- Returns:
- comment string
-
getContributor
Description copied from interface:MwRevision
Returns the name for the contributor that made the edit that led to this revision. This might be a user name or an IP address. This can be checked usingMwRevision.hasRegisteredContributor()
.- Specified by:
getContributor
in interfaceMwRevision
- Returns:
- contributor name or IP address
-
getContributorId
public int getContributorId()Description copied from interface:MwRevision
Returns the user id of the contributor who made the edit that led to this revision, or -1 if the edit was not made by a registered user.- Specified by:
getContributorId
in interfaceMwRevision
- Returns:
- user id or -1 for anonymous users
-
hasRegisteredContributor
public boolean hasRegisteredContributor()Description copied from interface:MwRevision
Returns true if the contributor who made the edit that led to this revision was logged in with a user account. False is returned if the contributor was not logged in (in which case there is only an IP address).- Specified by:
hasRegisteredContributor
in interfaceMwRevision
- Returns:
- true if the contributor was looged in
-
toString
-