Spreadsheet.java :  » Project-Management » XPlanner-0.7b7 » com » technoetic » xplanner » importer » spreadsheet » Java Open Source

Java Open Source » Project Management » XPlanner 0.7b7 
XPlanner 0.7b7 » com » technoetic » xplanner » importer » spreadsheet » Spreadsheet.java
package com.technoetic.xplanner.importer.spreadsheet;

import java.io.*;
import java.util.*;

import com.technoetic.xplanner.importer.SpreadsheetStory;
import com.technoetic.xplanner.importer.SpreadsheetStoryFactory;
import com.technoetic.xplanner.importer.util.IOStreamFactory;

public class Spreadsheet
{
   protected String path;
   protected List/*<Story>*/ stories = new ArrayList();
   private IOStreamFactory streamFactory;
   private SpreadsheetStoryFactory spreadsheetStoryFactory;

   public Spreadsheet(IOStreamFactory streamFactory, SpreadsheetStoryFactory spreadsheetStoryFactory)
   {
      this.streamFactory = streamFactory;
      this.spreadsheetStoryFactory = spreadsheetStoryFactory;
   }

   public List getStories()
   {
      return Collections.unmodifiableList(stories);
   }

   public String getPath()
   {
      return path;
   }

   public void open(String path) throws IOException
   {
      this.path = path;

      try
      {
         InputStream stream = streamFactory.newInputStream(path);
         //TODO
         stories = new SpreadsheetStoryReader(spreadsheetStoryFactory).readStories(null, stream);
      }
      catch (IOException e)
      {
      }
   }

   public void save() throws IOException
   {
      new SpreadsheetStoryWriter(new FileOutputStream(path)).writeStories(stories);
   }

   public void saveAs(String path) throws IOException
   {
      this.path = path;
      save();
   }

   public void setStories(List stories)
   {
      this.stories = new ArrayList(stories);
   }

   public SpreadsheetStoryFactory getStoryFactory()
   {
      return spreadsheetStoryFactory;
   }

   public void setStoryFactory(SpreadsheetStoryFactory spreadsheetStoryFactory)
   {
      this.spreadsheetStoryFactory = spreadsheetStoryFactory;
   }

   public void addStory(SpreadsheetStory spreadsheetStory)
   {
      stories.add(spreadsheetStory);
   }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.