2 * Moxkiriya standalone Wiki.
5 * @author Ryuhei Terada
6 * See the '<a href="{@docRoot}/copyright.html">Copyright</a>'
8 package com.wiki.standalone.moxkiriya;
10 import java.util.ArrayList;
12 import javax.jcr.Property;
15 * Manage wiki history.
19 public class WikiHistory {
21 private ArrayList<PageData> histories_ = new ArrayList<PageData>();
23 /** Position on history list. */
24 private int position_ = 0;
29 public WikiHistory() {
34 * Is there an older node on a history list.
37 public boolean canBack() {
38 boolean canBack = false;
40 if(histories_.size() > 1) {
50 * Is there an newer node on a history list.
53 public boolean canForward() {
54 boolean canForward = false;
56 if(histories_.size() > 0) {
57 if(position_ < histories_.size() - 1) {
66 * Execute history back.
69 public PageData back() {
70 PageData pageData = null;
72 if(canBack() == true) {
74 pageData = histories_.get(position_);
81 * Execute history forward.
84 public PageData forward() {
85 PageData pageData = null;
87 if(canForward() == true) {
89 pageData = histories_.get(position_);
96 * Add PageData to history list.
100 public void add(PageData pageData) throws Exception {
101 if(histories_.size() > 0) {
102 PageData latestPage = histories_.get(position_);
103 String uuid = latestPage.getNode().getProperty(Property.JCR_UUID).getString();
105 if(pageData.getNode().getProperty(Property.JCR_UUID).getString().equals(uuid) == true) {
107 * History中に同じページを連続登録しようとした場合、
109 histories_.remove(position_);
116 for(int count = position_; count < histories_.size(); count++) {
117 histories_.remove(count);
120 histories_.add(pageData);
121 position_ = histories_.size() - 1;
127 public void clear() {