Class WikiPage

java.lang.Object
org.apache.wiki.WikiPage
All Implemented Interfaces:
Cloneable, Comparable<org.apache.wiki.api.core.Page>, org.apache.wiki.api.core.Page
Direct Known Subclasses:
Attachment

public class WikiPage extends Object implements org.apache.wiki.api.core.Page
Simple wrapper class for the Wiki page attributes. The Wiki page content is moved around in Strings, though.
  • Field Summary

    Fields inherited from interface org.apache.wiki.api.core.Page

    ALIAS, AUTHOR, CHANGENOTE, DESCRIPTION, REDIRECT, VIEWCOUNT
  • Constructor Summary

    Constructors
    Constructor
    Description
    WikiPage(org.apache.wiki.api.core.Engine engine, String name)
    Create a new WikiPage using a given engine and name.
    WikiPage(WikiEngine engine, String name)
    Deprecated.
    kept for compatibility with page/attachment providers not using public API.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a deep clone of a WikiPage.
    int
    compareTo(org.apache.wiki.api.core.Page page)
    Compares a page with another by name using the defined PageNameComparator.
    boolean
    A page is equal to another page if its name and version are equal.
    Returns the Acl for this page.
    <T> T
    A WikiPage may have a number of attributes, which might or might not be available.
    Returns the full attributes Map, in case external code needs to iterate through the attributes.
    Returns author name, or null, if no author has been defined.
    Returns the date when this page was last modified.
    Returns the name of the page.
    long
    Returns the size of the page.
    int
    Returns the version that this WikiPage instance represents.
    Returns the wiki name for this page
    int
    boolean
    Returns true if the page has valid metadata; that is, it has been parsed.
    void
    This method will remove all metadata from the page.
    <T> T
    Removes an attribute from the page, if it exists.
    void
    setAcl(org.apache.wiki.api.core.Acl acl)
    Sets the Acl for this page.
    void
    setAcl(Acl acl)
    void
    setAttribute(String key, Object attribute)
    Sets an metadata attribute.
    void
    setAuthor(String author)
    Sets the author of the page.
    void
    Sets the metadata flag to true.
    void
    Sets the last modification date.
    void
    setSize(long size)
    Sets the size.
    void
    setVersion(int version)
    Sets the page version.
    Returns a debug-suitable version of the page.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • WikiPage

      public WikiPage(org.apache.wiki.api.core.Engine engine, String name)
      Create a new WikiPage using a given engine and name.
      Parameters:
      engine - The Engine that owns this page.
      name - The name of the page.
    • WikiPage

      @Deprecated public WikiPage(WikiEngine engine, String name)
      Deprecated.
      kept for compatibility with page/attachment providers not using public API. Use WikiPage(Engine, String) instead.
      Create a new WikiPage using a given engine and name.
      Parameters:
      engine - The Engine that owns this page.
      name - The name of the page.
  • Method Details

    • getName

      public String getName()
      Returns the name of the page.
      Specified by:
      getName in interface org.apache.wiki.api.core.Page
      Returns:
      The page name.
    • getAttribute

      public <T> T getAttribute(String key)
      A WikiPage may have a number of attributes, which might or might not be available. Typically attributes are things that do not need to be stored with the wiki page to the page repository, but are generated on-the-fly. A provider is not required to save them, but they can do that if they really want.
      Specified by:
      getAttribute in interface org.apache.wiki.api.core.Page
      Parameters:
      key - The key using which the attribute is fetched
      Returns:
      The attribute. If the attribute has not been set, returns null.
    • setAttribute

      public void setAttribute(String key, Object attribute)
      Sets an metadata attribute.
      Specified by:
      setAttribute in interface org.apache.wiki.api.core.Page
      Parameters:
      key - The key for the attribute used to fetch the attribute later on.
      attribute - The attribute value
      See Also:
    • getAttributes

      Returns the full attributes Map, in case external code needs to iterate through the attributes.
      Specified by:
      getAttributes in interface org.apache.wiki.api.core.Page
      Returns:
      The attribute Map. Please note that this is a direct reference, not a copy.
    • removeAttribute

      public <T> T removeAttribute(String key)
      Removes an attribute from the page, if it exists.
      Specified by:
      removeAttribute in interface org.apache.wiki.api.core.Page
      Parameters:
      key - The key for the attribute
      Returns:
      If the attribute existed, returns the object.
      Since:
      2.1.111
    • getLastModified

      Returns the date when this page was last modified.
      Specified by:
      getLastModified in interface org.apache.wiki.api.core.Page
      Returns:
      The last modification date
    • setLastModified

      public void setLastModified(Date date)
      Sets the last modification date. In general, this is only changed by the provider.
      Specified by:
      setLastModified in interface org.apache.wiki.api.core.Page
      Parameters:
      date - The date
    • setVersion

      public void setVersion(int version)
      Sets the page version. In general, this is only changed by the provider.
      Specified by:
      setVersion in interface org.apache.wiki.api.core.Page
      Parameters:
      version - The version number
    • getVersion

      public int getVersion()
      Returns the version that this WikiPage instance represents.
      Specified by:
      getVersion in interface org.apache.wiki.api.core.Page
      Returns:
      the version number of this page.
    • getSize

      public long getSize()
      Returns the size of the page.
      Specified by:
      getSize in interface org.apache.wiki.api.core.Page
      Returns:
      the size of the page.
      Since:
      2.1.109
    • setSize

      public void setSize(long size)
      Sets the size. Typically called by the provider only.
      Specified by:
      setSize in interface org.apache.wiki.api.core.Page
      Parameters:
      size - The size of the page.
      Since:
      2.1.109
    • getAcl

      public Acl getAcl()
      Returns the Acl for this page. May return null, in case there is no Acl defined, or it has not yet been set by setAcl(Acl).
      Specified by:
      getAcl in interface org.apache.wiki.api.core.Page
      Returns:
      The access control list. May return null, if there is no acl.
    • setAcl

      @Deprecated public void setAcl(Acl acl)
      Sets the Acl for this page. Note that method does not persist the Acl itself to back-end storage or in page markup; it merely sets the internal field that stores the Acl. To persist the Acl, callers should invoke AclManager.setPermissions(Page, org.apache.wiki.api.core.Acl).
      Parameters:
      acl - The Acl to set
      See Also:
    • setAcl

      public void setAcl(org.apache.wiki.api.core.Acl acl)
      Sets the Acl for this page. Note that method does not persist the Acl itself to back-end storage or in page markup; it merely sets the internal field that stores the Acl. To persist the Acl, callers should invoke AclManager.setPermissions(Page, org.apache.wiki.api.core.Acl).
      Specified by:
      setAcl in interface org.apache.wiki.api.core.Page
      Parameters:
      acl - The Acl to set
    • setAuthor

      public void setAuthor(String author)
      Sets the author of the page. Typically called only by the provider.
      Specified by:
      setAuthor in interface org.apache.wiki.api.core.Page
      Parameters:
      author - The author name.
    • getAuthor

      public String getAuthor()
      Returns author name, or null, if no author has been defined.
      Specified by:
      getAuthor in interface org.apache.wiki.api.core.Page
      Returns:
      Author name, or possibly null.
    • getWiki

      public String getWiki()
      Returns the wiki name for this page
      Specified by:
      getWiki in interface org.apache.wiki.api.core.Page
      Returns:
      The name of the wiki.
    • invalidateMetadata

      public void invalidateMetadata()
      This method will remove all metadata from the page.
      Specified by:
      invalidateMetadata in interface org.apache.wiki.api.core.Page
    • hasMetadata

      public boolean hasMetadata()
      Returns true if the page has valid metadata; that is, it has been parsed. Note that this method is a kludge to support our pre-3.0 metadata system, and as such will go away with the new API.
      Specified by:
      hasMetadata in interface org.apache.wiki.api.core.Page
      Returns:
      true, if the page has metadata.
    • setHasMetadata

      public void setHasMetadata()
      Sets the metadata flag to true. Never call.
      Specified by:
      setHasMetadata in interface org.apache.wiki.api.core.Page
    • toString

      public String toString()
      Returns a debug-suitable version of the page.
      Overrides:
      toString in class Object
      Returns:
      A debug string.
    • clone

      public WikiPage clone()
      Creates a deep clone of a WikiPage. Strings are not cloned, since they're immutable. Attributes are not cloned, only the internal HashMap (so if you modify the contents of a value of an attribute, these will reflect back to everyone).
      Specified by:
      clone in interface org.apache.wiki.api.core.Page
      Overrides:
      clone in class Object
      Returns:
      A deep clone of the WikiPage
    • compareTo

      public int compareTo(org.apache.wiki.api.core.Page page)
      Compares a page with another by name using the defined PageNameComparator. If the same name, compares their versions.
      Specified by:
      compareTo in interface Comparable<org.apache.wiki.api.core.Page>
      Parameters:
      page - The page to compare against
      Returns:
      -1, 0 or 1
    • equals

      public boolean equals(Object o)
      A page is equal to another page if its name and version are equal.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object