01: package com.technoetic.xplanner.importer.spreadsheet;
02:
03: import java.io.*;
04: import java.util.*;
05:
06: import com.technoetic.xplanner.importer.SpreadsheetStory;
07: import com.technoetic.xplanner.importer.SpreadsheetStoryFactory;
08: import com.technoetic.xplanner.importer.util.IOStreamFactory;
09:
10: public class Spreadsheet {
11: protected String path;
12: protected List/*<Story>*/stories = new ArrayList();
13: private IOStreamFactory streamFactory;
14: private SpreadsheetStoryFactory spreadsheetStoryFactory;
15:
16: public Spreadsheet(IOStreamFactory streamFactory,
17: SpreadsheetStoryFactory spreadsheetStoryFactory) {
18: this .streamFactory = streamFactory;
19: this .spreadsheetStoryFactory = spreadsheetStoryFactory;
20: }
21:
22: public List getStories() {
23: return Collections.unmodifiableList(stories);
24: }
25:
26: public String getPath() {
27: return path;
28: }
29:
30: public void open(String path) throws IOException {
31: this .path = path;
32:
33: try {
34: InputStream stream = streamFactory.newInputStream(path);
35: //TODO
36: stories = new SpreadsheetStoryReader(
37: spreadsheetStoryFactory).readStories(null, stream);
38: } catch (IOException e) {
39: }
40: }
41:
42: public void save() throws IOException {
43: new SpreadsheetStoryWriter(new FileOutputStream(path))
44: .writeStories(stories);
45: }
46:
47: public void saveAs(String path) throws IOException {
48: this .path = path;
49: save();
50: }
51:
52: public void setStories(List stories) {
53: this .stories = new ArrayList(stories);
54: }
55:
56: public SpreadsheetStoryFactory getStoryFactory() {
57: return spreadsheetStoryFactory;
58: }
59:
60: public void setStoryFactory(
61: SpreadsheetStoryFactory spreadsheetStoryFactory) {
62: this .spreadsheetStoryFactory = spreadsheetStoryFactory;
63: }
64:
65: public void addStory(SpreadsheetStory spreadsheetStory) {
66: stories.add(spreadsheetStory);
67: }
68:
69: }
|