Package org.apache.wiki
Class WikiPage
java.lang.Object
org.apache.wiki.WikiPage
- All Implemented Interfaces:
Cloneable,Comparable<Page>,Page
- Direct Known Subclasses:
Attachment
public class WikiPage extends Object implements 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
-
Method Summary
Modifier and Type Method Description WikiPageclone()Creates a deep clone of a WikiPage.intcompareTo(Page page)Compares a page with another by name using the defined PageNameComparator.booleanequals(Object o)A page is equal to another page if its name and version are equal.AclgetAcl()Returns the Acl for this page.<T> TgetAttribute(String key)A WikiPage may have a number of attributes, which might or might not be available.Map<String,Object>getAttributes()Returns the full attributes Map, in case external code needs to iterate through the attributes.StringgetAuthor()Returns author name, or null, if no author has been defined.DategetLastModified()Returns the date when this page was last modified.StringgetName()Returns the name of the page.longgetSize()Returns the size of the page.intgetVersion()Returns the version that this WikiPage instance represents.StringgetWiki()Returns the wiki name for this pageinthashCode()booleanhasMetadata()Returnstrueif the page has valid metadata; that is, it has been parsed.voidinvalidateMetadata()This method will remove all metadata from the page.<T> TremoveAttribute(String key)Removes an attribute from the page, if it exists.voidsetAcl(Acl acl)Sets the Acl for this page.voidsetAcl(Acl acl)Deprecated.voidsetAttribute(String key, Object attribute)Sets an metadata attribute.voidsetAuthor(String author)Sets the author of the page.voidsetHasMetadata()Sets the metadata flag to true.voidsetLastModified(Date date)Sets the last modification date.voidsetSize(long size)Sets the size.voidsetVersion(int version)Sets the page version.StringtoString()Returns a debug-suitable version of the page.
-
Constructor Details
-
WikiPage
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.kept for compatibility with page/attachment providers not using public API. UseWikiPage(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
Returns the name of the page. -
getAttribute
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:
getAttributein interfacePage- Parameters:
key- The key using which the attribute is fetched- Returns:
- The attribute. If the attribute has not been set, returns null.
-
setAttribute
Sets an metadata attribute.- Specified by:
setAttributein interfacePage- Parameters:
key- The key for the attribute used to fetch the attribute later on.attribute- The attribute value- See Also:
getAttribute(String)
-
getAttributes
Returns the full attributes Map, in case external code needs to iterate through the attributes.- Specified by:
getAttributesin interfacePage- Returns:
- The attribute Map. Please note that this is a direct reference, not a copy.
-
removeAttribute
Removes an attribute from the page, if it exists.- Specified by:
removeAttributein interfacePage- 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:
getLastModifiedin interfacePage- Returns:
- The last modification date
-
setLastModified
Sets the last modification date. In general, this is only changed by the provider.- Specified by:
setLastModifiedin interfacePage- Parameters:
date- The date
-
setVersion
Sets the page version. In general, this is only changed by the provider.- Specified by:
setVersionin interfacePage- Parameters:
version- The version number
-
getVersion
Returns the version that this WikiPage instance represents.- Specified by:
getVersionin interfacePage- Returns:
- the version number of this page.
-
getSize
Returns the size of the page. -
setSize
Sets the size. Typically called by the provider only. -
getAcl
Returns the Acl for this page. May returnnull, in case there is no Acl defined, or it has not yet been set bysetAcl(Acl). -
setAcl
Deprecated.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 invokeAclManager.setPermissions(Page, org.apache.wiki.api.core.Acl).- Parameters:
acl- The Acl to set- See Also:
setAcl(org.apache.wiki.api.core.Acl)
-
setAcl
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 invokeAclManager.setPermissions(Page, org.apache.wiki.api.core.Acl). -
setAuthor
Sets the author of the page. Typically called only by the provider. -
getAuthor
Returns author name, or null, if no author has been defined. -
getWiki
Returns the wiki name for this page -
invalidateMetadata
This method will remove all metadata from the page.- Specified by:
invalidateMetadatain interfacePage
-
hasMetadata
Returnstrueif 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:
hasMetadatain interfacePage- Returns:
- true, if the page has metadata.
-
setHasMetadata
Sets the metadata flag to true. Never call.- Specified by:
setHasMetadatain interfacePage
-
toString
Returns a debug-suitable version of the page. -
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). -
compareTo
Compares a page with another by name using the defined PageNameComparator. If the same name, compares their versions.- Specified by:
compareToin interfaceComparable<Page>- Parameters:
page- The page to compare against- Returns:
- -1, 0 or 1
-
equals
A page is equal to another page if its name and version are equal. -
hashCode
-