Added xstream handiling for Wikipedia upload/download
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / xml / Page.java
diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/xml/Page.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/xml/Page.java
new file mode 100644 (file)
index 0000000..adafff1
--- /dev/null
@@ -0,0 +1,95 @@
+package net.sourceforge.phpeclipse.wiki.xml;
+
+import java.util.ArrayList;
+
+//
+
+public class Page {
+  /**
+   * &lt;page&gt; XML data from Wikipedia Special:Export pages may be <code>null</code>
+   *  
+   */
+
+  /* package private */String title = null;
+
+  /* package private */ArrayList listOfRevisions = null;
+
+  //  Revision revision = null;
+
+  /* package private */Page() {
+  }
+
+  public Page(String timeStamp, String title, String body) {
+    listOfRevisions = new ArrayList();
+    Revision revision = new Revision(timeStamp, body);
+    listOfRevisions.add(revision);
+    this.title = title;
+  }
+
+  public void add(Revision revision) {
+    listOfRevisions.add(revision);
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see java.lang.Object#toString()
+   */
+  public String toString() {
+    StringBuffer buffer = new StringBuffer();
+
+    if (title != null) {
+      buffer.append("==>Title: ");
+      buffer.append(title);
+      buffer.append("\n");
+    }
+
+    //    if (revision != null) {
+    //      buffer.append("==>Revision:\n");
+    //      buffer.append(revision);
+    //      buffer.append("\n");
+    //    }
+    for (int i = 0; i < listOfRevisions.size(); i++) {
+      Revision revision = (Revision) listOfRevisions.get(i);
+      if (revision != null) {
+        buffer.append("==>Revision:\n");
+        buffer.append(revision);
+        buffer.append("\n");
+      }
+    }
+    return buffer.toString();
+  }
+
+  /**
+   * @return Returns the title.
+   */
+  public String getTitle() {
+    return title;
+  }
+
+  public String getURLTitle() {
+    return title.replaceAll(" ", "_");
+  }
+
+  /**
+   * @return
+   */
+  public boolean isEmpty() {
+    return listOfRevisions.isEmpty();
+  }
+
+  /**
+   * @return
+   */
+  public int size() {
+    return listOfRevisions.size();
+  }
+
+  /**
+   * @param index
+   * @return
+   */
+  public Revision get(int index) {
+    return (Revision) listOfRevisions.get(index);
+  }
+}
\ No newline at end of file