Interface MwRevision

All Known Implementing Classes:
MwRevisionImpl

public interface MwRevision
Representation of one revision of a page in MediaWiki.
Author:
Markus Kroetzsch
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The model used for MediaWiki revisions representing Wikibase items.
    static final String
    The model used for MediaWiki revisions representing Wikibase lexemes.
    static final String
    The model used for MediaWiki revisions representing Wikibase properties.
    static final String
    The model used for MediaWiki revisions in traditional Wikitext.
    static final long
    The revision id set when the revision does not exist
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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.
    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.
    Returns the text content of the current revision.
    Returns the time stamp at which the current revision was made.
    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.
  • Field Details

    • MODEL_WIKITEXT

      static final String MODEL_WIKITEXT
      The model used for MediaWiki revisions in traditional Wikitext. Revisions with this format should always use "text/x-wiki" as their format.
      See Also:
    • MODEL_WIKIBASE_ITEM

      static final String MODEL_WIKIBASE_ITEM
      The model used for MediaWiki revisions representing Wikibase items. Revisions with this format should always use "application/json" as their format.
      See Also:
    • MODEL_WIKIBASE_PROPERTY

      static final String MODEL_WIKIBASE_PROPERTY
      The model used for MediaWiki revisions representing Wikibase properties. Revisions with this format should always use "application/json" as their format.
      See Also:
    • MODEL_WIKIBASE_LEXEME

      static final String MODEL_WIKIBASE_LEXEME
      The model used for MediaWiki revisions representing Wikibase lexemes. Revisions with this format should always use "application/json" as their format.
      See Also:
    • NO_REVISION_ID

      static final long NO_REVISION_ID
      The revision id set when the revision does not exist
      See Also:
  • Method Details

    • getPrefixedTitle

      String getPrefixedTitle()
      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 example

      On 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.

      Returns:
      title string
    • getTitle

      String getTitle()
      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 example

      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.

      Returns:
      title string
    • getNamespace

      int getNamespace()
      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.

      Returns:
      integer namespace id
    • getPageId

      int getPageId()
      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).
      Returns:
      integer page id
    • getRevisionId

      long getRevisionId()
      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.
      Returns:
      long revision id
    • getParentRevisionId

      long getParentRevisionId()
      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.
      Returns:
      revision id
    • getTimeStamp

      String getTimeStamp()
      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".
      Returns:
      time stamp string
    • getText

      String getText()
      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 by getFormat(). To interpret it properly, one should also know the content model, obtained from getModel().
      Returns:
      text content of the revision
    • getModel

      String getModel()
      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 from getFormat().
      Returns:
      content model as a string
    • getFormat

      String getFormat()
      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 by getModel(). Like the content model, the format might change between revisions of a page, but this is very rare in practice.
      Returns:
      MIME type for revision text
    • getComment

      String getComment()
      Returns the comment string that was used for making the edit that led to this revision.
      Returns:
      comment string
    • getContributor

      String getContributor()
      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 using hasRegisteredContributor().
      Returns:
      contributor name or IP address
    • getContributorId

      int getContributorId()
      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:
      user id or -1 for anonymous users
    • hasRegisteredContributor

      boolean hasRegisteredContributor()
      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).
      Returns:
      true if the contributor was looged in