01: /*
02: * JMLWriter.java
03: *
04: * Created on July 12, 2002, 3:00 PM
05: */
06: /*
07: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
08: * for visualizing and manipulating spatial features with geometry and attributes.
09: *
10: * Copyright (C) 2003 Vivid Solutions
11: *
12: * This program is free software; you can redistribute it and/or
13: * modify it under the terms of the GNU General Public License
14: * as published by the Free Software Foundation; either version 2
15: * of the License, or (at your option) any later version.
16: *
17: * This program is distributed in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: * GNU General Public License for more details.
21: *
22: * You should have received a copy of the GNU General Public License
23: * along with this program; if not, write to the Free Software
24: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25: *
26: * For more information, contact:
27: *
28: * Vivid Solutions
29: * Suite #1A
30: * 2328 Government Street
31: * Victoria BC V8T 5G5
32: * Canada
33: *
34: * (250)385-6040
35: * www.vividsolutions.com
36: */
37:
38: package com.vividsolutions.jump.io;
39:
40: import com.vividsolutions.jump.feature.FeatureCollection;
41:
42: /**
43: * JMLWriter is a {@link JUMPWriter} specialized to write JML.
44: *
45: * <p>
46: * This is a simple class that passes the work off to the {@link GMLWriter} class that
47: * knows how to auto-generate a JML compatible {@link GMLOutputTemplate}.
48: * </p>
49: *
50: * <p>
51: * DataProperties for the JMLWriter write(DataProperties) interface:<br><br>
52: * </p>
53: *
54: * <p>
55: * <table border='1' cellspacing='0' cellpadding='4'>
56: * <tr>
57: * <th>Parameter</th>
58: * <th>Meaning</th>
59: * </tr>
60: * <tr>
61: * <td>OutputFile or DefaultValue</td>
62: * <td>File name for the output JML file</td>
63: * </tr>
64: * </table><br>
65: * </p>
66: */
67: public class JMLWriter implements JUMPWriter {
68: /** Creates new JMLWriter */
69: public JMLWriter() {
70: }
71:
72: /**
73: * Writes the feature collection to the specified file in JML format.
74: * @param featureCollection features to write
75: * @param dp 'OutputFile' or 'DefaultValue' to specify what file to write.
76: */
77: public void write(FeatureCollection featureCollection,
78: DriverProperties dp) throws IllegalParametersException,
79: Exception {
80: GMLWriter gmlWriter;
81: String outputFname;
82:
83: outputFname = dp.getProperty("File");
84:
85: if (outputFname == null) {
86: outputFname = dp.getProperty("DefaultValue");
87: }
88:
89: if (outputFname == null) {
90: throw new IllegalParametersException(
91: "call to JMLWriter.write() has DataProperties w/o a OutputFile specified");
92: }
93:
94: gmlWriter = new GMLWriter();
95:
96: gmlWriter.write(featureCollection, dp);
97: }
98: }
|