org.apache.wiki
Class WikiPage

java.lang.Object
  extended by org.apache.wiki.WikiPage
All Implemented Interfaces:
Cloneable, Comparable
Direct Known Subclasses:
Attachment

public class WikiPage
extends Object
implements Cloneable, Comparable

Simple wrapper class for the Wiki page attributes. The Wiki page content is moved around in Strings, though.


Field Summary
static String ALIAS
          A special variable name for storing a page alias.
static String CHANGENOTE
          A special variable name for storing a changenote.
static String DESCRIPTION
          "Summary" is a short summary of the page.
static String REDIRECT
          A special variable name for storing a redirect note
 
Constructor Summary
WikiPage(WikiEngine engine, String name)
          Create a new WikiPage using a given engine and name.
 
Method Summary
 Object clone()
          Creates a deep clone of a WikiPage.
 int compareTo(Object page)
          Compares a page with another using the defined PageNameComparator.
 Acl getAcl()
          Returns the Acl for this page.
 Object getAttribute(String key)
          A WikiPage may have a number of attributes, which might or might not be available.
 Map getAttributes()
          Returns the full attributes Map, in case external code needs to iterate through the attributes.
 String getAuthor()
          Returns author name, or null, if no author has been defined.
 Date getLastModified()
          Returns the date when this page was last modified.
 String getName()
          Returns the name of the page.
 long getSize()
          Returns the size of the page.
 int getVersion()
          Returns the version that this WikiPage instance represents.
 String getWiki()
          Returns the wiki nanme for this page
 int hashCode()
          
 boolean hasMetadata()
          Returns true if the page has valid metadata; that is, it has been parsed.
 void invalidateMetadata()
          This method will remove all metadata from the page.
 Object removeAttribute(String key)
          Removes an attribute from the page, if it exists.
 void setAcl(Acl acl)
          Sets the Acl for this page.
 void setAttribute(String key, Object attribute)
          Sets an metadata attribute.
 void setAuthor(String author)
          Sets the author of the page.
 void setHasMetadata()
          Sets the metadata flag to true.
 void setLastModified(Date date)
          Sets the last modification date.
 void setSize(long size)
          Sets the size.
 void setVersion(int version)
          Sets the page version.
 String toString()
          Returns a debug-suitable version of the page.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DESCRIPTION

public static final String DESCRIPTION
"Summary" is a short summary of the page. It is a String.

See Also:
Constant Field Values

ALIAS

public static final String ALIAS
A special variable name for storing a page alias.

See Also:
Constant Field Values

REDIRECT

public static final String REDIRECT
A special variable name for storing a redirect note

See Also:
Constant Field Values

CHANGENOTE

public static final String CHANGENOTE
A special variable name for storing a changenote.

See Also:
Constant Field Values
Constructor Detail

WikiPage

public WikiPage(WikiEngine engine,
                String name)
Create a new WikiPage using a given engine and name.

Parameters:
engine - The WikiEngine that owns this page.
name - The name of the page.
Method Detail

getName

public String getName()
Returns the name of the page.

Returns:
The page name.

getAttribute

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

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.

Parameters:
key - The key for the attribute used to fetch the attribute later on.
attribute - The attribute value
See Also:
getAttribute(String)

getAttributes

public Map getAttributes()
Returns the full attributes Map, in case external code needs to iterate through the attributes.

Returns:
The attribute Map. Please note that this is a direct reference, not a copy.

removeAttribute

public Object removeAttribute(String key)
Removes an attribute from the page, if it exists.

Parameters:
key - The key for the attribute
Returns:
If the attribute existed, returns the object.
Since:
2.1.111

getLastModified

public Date getLastModified()
Returns the date when this page was last modified.

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.

Parameters:
date - The date

setVersion

public void setVersion(int version)
Sets the page version. In general, this is only changed by the provider.

Parameters:
version - The version number

getVersion

public int getVersion()
Returns the version that this WikiPage instance represents.

Returns:
the version number of this page.

getSize

public long getSize()
Returns the size of the 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.

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

Returns:
The access control list. May return null, if there is no acl.

setAcl

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(WikiPage, Acl).

Parameters:
acl - The Acl to set

setAuthor

public void setAuthor(String author)
Sets the author of the page. Typically called only by the provider.

Parameters:
author - The author name.

getAuthor

public String getAuthor()
Returns author name, or null, if no author has been defined.

Returns:
Author name, or possibly null.

getWiki

public String getWiki()
Returns the wiki nanme for this page

Returns:
The name of the wiki.

invalidateMetadata

public void invalidateMetadata()
This method will remove all metadata from the 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.

Returns:
true, if the page has metadata.

setHasMetadata

public void setHasMetadata()
Sets the metadata flag to true. Never call.


toString

public String toString()
Returns a debug-suitable version of the page.

Overrides:
toString in class Object
Returns:
A debug string.

clone

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

Overrides:
clone in class Object
Returns:
A deep clone of the WikiPage

compareTo

public int compareTo(Object page)
Compares a page with another using the defined PageNameComparator. See org.apache.wiki.util.PageSorter.

Specified by:
compareTo in interface Comparable
Parameters:
page - The object to compare against
Returns:
-1, 0 or 1

hashCode

public int hashCode()

Overrides:
hashCode in class Object


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.