/**
  * Writes the given WikiWord to the output stream.
  *
  * @param word The word to write
  * @param dataOut The stream to write to
  * @throws IOException
  */
 private void writeWikiWord(WikiWord word, DataOutputStream dataOut) throws IOException {
   /*
    * Serialization format is as follows:
    * (String) name of the word
    * (String) wiki text
    * (int) number of child words
    * (WikiWord) child 1
    * ... repeat for each child
    */
   dataOut.writeUTF(word.getName());
   dataOut.writeUTF(word.getWikiText());
   List children = word.getWikiWords();
   log.debug("Word has " + children.size() + " children");
   dataOut.writeInt(children.size());
   for (int i = 0, size = children.size(); i < size; ++i) {
     writeWikiWord((WikiWord) children.get(i), dataOut);
   }
 }
  /**
   * Reads and returns a single WikiWord from the given stream
   *
   * @param parent Parent word
   * @param dataIn Stream to read the data from
   * @return The WikiWord contained in the data stream
   * @throws IOException
   */
  private WikiWord readWikiWord(WikiWord parent, DataInputStream dataIn) throws IOException {
    /*
     * Serialization format is as follows:
     * (String) name of the word
     * (String) wiki text
     * (int) number of child words
     * (WikiWord) child 1
     * ... repeat for each child
     */
    String title = dataIn.readUTF();
    String text = dataIn.readUTF();
    int n = dataIn.readInt();
    log.debug(title + " has " + n + " children");
    WikiWord newParent = new WikiWord(title, text);
    newParent.setParent(parent);

    for (int i = 0; i < n; ++i) {
      readWikiWord(newParent, dataIn);
    }

    return newParent;
  }
 /** @see org.eclipse.jface.action.IAction#run() */
 public void run() {
   WikiWord newWiki = new WikiWord();
   newWiki.setName("root");
   snippad.openWiki(newWiki, null);
 }