codesimian
Class DefaultWiki

java.lang.Object
  extended by codesimian.DefaultWiki
All Implemented Interfaces:
Wiki

public class DefaultWiki
extends java.lang.Object
implements Wiki

This class is the start of a decentralized WIKI where each user of CodeSimian will have a different version of the WIKI and have many versions of each page and many pages.

PARAMETERS OF THOSE CODESIMIAN COMMANDS: versionIndex - 0 is oldest, wikiCountPages("somename")-1 is newest, and any index outside that range returns the newest index name - a string that is a valid codesimian name inputPageBytes or returnedPageBytes - convert bytes to string then compile NEW CODESIMIAN COMMANDS: wikiCountPages(name) returns quantity of versions of of wiki pages with specific string name wikiRestoreOldPage(name versionIndex) wikiGetPage(name versionIndex returnedPageBytes) returns quantity of bytes returned to index 2 use backupIndex wikiCountPages(name)-1 for newest page, 0 for oldest. wikiNewPage(name inputPageBytes) same as viewPage except creates a new newest page and pushes all others up 1 index. wikiGetNewestPage(name returnedPageBytes) wikiListOfAllPages(when executed fills self with list of all page names)

Stores all wiki files in path: CodeSimian.jar/wiki/ and all the pages whose versionIndex is 5 in CodeSimian.jar/wiki/5/

Or should all versions of X be stored in CodeSimian.jar/wiki/X.zip ? That would take much less space since all versions of the same page are zipped together. Each version of the page is named as the System.currentTimeMillis() number when it was saved.

??? What should I do if some of the old versions are deleted, making it look like the newest version is the one before the deleted one??? How would I know?


Method Summary
 java.lang.String[] allPageNames()
           
 int countPages(java.lang.String name)
           
 java.lang.String newestPage(java.lang.String name)
           
 boolean newPage(java.lang.String name, ImmutBytes bytes, Liquid liquidModifyWiki)
          requires a certain amount of liquid per byte plus an amount depending on the name
 java.lang.String page(java.lang.String name, int versionIndex)
          returns null if file does not exist
 boolean restoreOldPage(java.lang.String name, int versionIndex, Liquid liquidModifyWiki)
          requires a certain amount of liquid depending on the page and version.
 java.lang.String rootPath()
          returns a path of an inner folder (see InnerFiles.java) that ends with "/", like "wiki/".
 java.lang.String[] search(java.lang.String searchForThis, int targetReturnedArraySize, Liquid liquidCpuTime)
          Returns a list of page names which certainly contain the search text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

rootPath

public java.lang.String rootPath()
Description copied from interface: Wiki
returns a path of an inner folder (see InnerFiles.java) that ends with "/", like "wiki/". This is where the pages of this Wiki are stored.

Specified by:
rootPath in interface Wiki

countPages

public int countPages(java.lang.String name)
Specified by:
countPages in interface Wiki

restoreOldPage

public boolean restoreOldPage(java.lang.String name,
                              int versionIndex,
                              Liquid liquidModifyWiki)
                       throws NeedLiquid
requires a certain amount of liquid depending on the page and version. Try more and more liquid until this returns true (the only time Liquid will be removed).

Specified by:
restoreOldPage in interface Wiki
Throws:
NeedLiquid

newPage

public boolean newPage(java.lang.String name,
                       ImmutBytes bytes,
                       Liquid liquidModifyWiki)
                throws NeedLiquid
requires a certain amount of liquid per byte plus an amount depending on the name

Specified by:
newPage in interface Wiki
Throws:
NeedLiquid

allPageNames

public java.lang.String[] allPageNames()
Specified by:
allPageNames in interface Wiki

page

public java.lang.String page(java.lang.String name,
                             int versionIndex)
returns null if file does not exist

Specified by:
page in interface Wiki

newestPage

public java.lang.String newestPage(java.lang.String name)
Specified by:
newestPage in interface Wiki

search

public java.lang.String[] search(java.lang.String searchForThis,
                                 int targetReturnedArraySize,
                                 Liquid liquidCpuTime)
Returns a list of page names which certainly contain the search text.

Requires a Liquid (type "liquidCpuTime") to pay for the possibly long time required for search.

Does not throw NeedLiquid because the search uses the parameter Liquid and stops when it runs out. If the search has not found anything, empty array is returned.

Specified by:
search in interface Wiki