Class MwRevisionImpl

java.lang.Object
org.wikidata.wdtk.dumpfiles.MwRevisionImpl
All Implemented Interfaces:
MwRevision

public class MwRevisionImpl extends Object implements 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
  • Constructor Details

    • MwRevisionImpl

      public MwRevisionImpl()
      Constructor.
    • MwRevisionImpl

      public MwRevisionImpl(MwRevision mwRevision)
      Copy constructor.
  • Method Details

    • getPrefixedTitle

      public String 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 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.

      Specified by:
      getPrefixedTitle in interface MwRevision
      Returns:
      title string
    • getTitle

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

      Specified by:
      getTitle in interface MwRevision
      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 interface MwRevision
      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 interface MwRevision
      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 interface MwRevision
      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 interface MwRevision
      Returns:
      revision id
    • getTimeStamp

      public String 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 interface MwRevision
      Returns:
      time stamp string
    • getText

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

      public String 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 from MwRevision.getFormat().
      Specified by:
      getModel in interface MwRevision
      Returns:
      content model as a string
    • getFormat

      public 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 by MwRevision.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 interface MwRevision
      Returns:
      MIME type for revision text
    • getComment

      public String 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 interface MwRevision
      Returns:
      comment string
    • getContributor

      public 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 using MwRevision.hasRegisteredContributor().
      Specified by:
      getContributor in interface MwRevision
      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 interface MwRevision
      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 interface MwRevision
      Returns:
      true if the contributor was looged in
    • toString

      public String toString()
      Overrides:
      toString in class Object