Revision: 18198
http://sourceforge.net/p/gate/code/18198
Author: markagreenwood
Date: 2014-07-18 09:55:27 +0000 (Fri, 18 Jul 2014)
Log Message:
-----------
a little bit of refactoring
Modified Paths:
--------------
gate/trunk/src/main/gate/DocumentExporter.java
gate/trunk/src/main/gate/gui/DocumentExportMenu.java
gate/trunk/src/main/gate/resources/creole/creole.xml
Added Paths:
-----------
gate/trunk/src/main/gate/corpora/export/
gate/trunk/src/main/gate/corpora/export/GateXMLExporter.java
Removed Paths:
-------------
gate/trunk/src/main/gate/creole/GateXMLExporter.java
Modified: gate/trunk/src/main/gate/DocumentExporter.java
===================================================================
--- gate/trunk/src/main/gate/DocumentExporter.java 2014-07-18 09:53:54 UTC
(rev 18197)
+++ gate/trunk/src/main/gate/DocumentExporter.java 2014-07-18 09:55:27 UTC
(rev 18198)
@@ -69,6 +69,11 @@
public String getDefaultExtension() {
return defaultExtension;
}
+
+ @Override
+ public String getName() {
+ return fileType;
+ }
/**
* A filter used in the file chooser to restrict the view to files of
@@ -101,6 +106,7 @@
try {
out = new FileOutputStream(file);
export(doc, new FileOutputStream(file), options);
+ out.flush();
} finally {
IOUtils.closeQuietly(out);
}
Copied: gate/trunk/src/main/gate/corpora/export/GateXMLExporter.java (from rev
18193, gate/trunk/src/main/gate/creole/GateXMLExporter.java)
===================================================================
--- gate/trunk/src/main/gate/corpora/export/GateXMLExporter.java
(rev 0)
+++ gate/trunk/src/main/gate/corpora/export/GateXMLExporter.java
2014-07-18 09:55:27 UTC (rev 18198)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1995-2014, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ *
+ * This file is part of GATE (see http://gate.ac.uk/), and is free
+ * software, licenced under the GNU Library General Public License,
+ * Version 2, June 1991 (in the distribution as file licence.html,
+ * and also available at http://gate.ac.uk/gate/licence.html).
+ *
+ * Mark A. Greenwood 16/07/2014
+ *
+ */
+
+package gate.corpora.export;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import gate.Document;
+import gate.DocumentExporter;
+import gate.FeatureMap;
+import gate.corpora.DocumentStaxUtils;
+import gate.creole.metadata.AutoInstance;
+import gate.creole.metadata.CreoleResource;
+
+@CreoleResource(name = "GATE XML Exporter", tool = true, autoinstances =
@AutoInstance, icon = "GATE")
+public class GateXMLExporter extends DocumentExporter {
+
+ private static final long serialVersionUID = -5725505758491779035L;
+
+ public GateXMLExporter() {
+ super("GATE XML", "xml");
+ }
+
+ @Override
+ public void export(Document doc, File file, FeatureMap options)
+ throws IOException {
+ super.export(doc, file, options);
+
+ // not sure why this was being done in the old code, but I'll make
+ // sure we do it here as well
+ doc.setSourceUrl(file.toURI().toURL());
+ }
+
+ @Override
+ public void export(Document doc, OutputStream out, FeatureMap options)
+ throws IOException {
+ try {
+ DocumentStaxUtils.writeDocument(doc, out, "");
+ } catch(XMLStreamException e) {
+ throw new IOException(e);
+ }
+ }
+}
Deleted: gate/trunk/src/main/gate/creole/GateXMLExporter.java
===================================================================
--- gate/trunk/src/main/gate/creole/GateXMLExporter.java 2014-07-18
09:53:54 UTC (rev 18197)
+++ gate/trunk/src/main/gate/creole/GateXMLExporter.java 2014-07-18
09:55:27 UTC (rev 18198)
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1995-2014, The University of Sheffield. See the file
- * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- * This file is part of GATE (see http://gate.ac.uk/), and is free
- * software, licenced under the GNU Library General Public License,
- * Version 2, June 1991 (in the distribution as file licence.html,
- * and also available at http://gate.ac.uk/gate/licence.html).
- *
- * Mark A. Greenwood 16/07/2014
- *
- */
-
-package gate.creole;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.stream.XMLStreamException;
-
-import gate.Document;
-import gate.DocumentExporter;
-import gate.FeatureMap;
-import gate.corpora.DocumentStaxUtils;
-import gate.creole.metadata.AutoInstance;
-import gate.creole.metadata.CreoleResource;
-
-@CreoleResource(name = "GATE XML Exporter", tool = true, autoinstances =
@AutoInstance, icon = "GATE")
-public class GateXMLExporter extends DocumentExporter {
-
- private static final long serialVersionUID = -5725505758491779035L;
-
- public GateXMLExporter() {
- super("GATE XML", "xml");
- }
-
- @Override
- public void export(Document doc, File file, FeatureMap options)
- throws IOException {
- super.export(doc, file, options);
-
- // not sure why this was being done in the old code, but I'll make
- // sure we do it here as well
- doc.setSourceUrl(file.toURI().toURL());
- }
-
- @Override
- public void export(Document doc, OutputStream out, FeatureMap options)
- throws IOException {
- try {
- DocumentStaxUtils.writeDocument(doc, out, "");
- } catch(XMLStreamException e) {
- throw new IOException(e);
- }
- }
-}
Modified: gate/trunk/src/main/gate/gui/DocumentExportMenu.java
===================================================================
--- gate/trunk/src/main/gate/gui/DocumentExportMenu.java 2014-07-18
09:53:54 UTC (rev 18197)
+++ gate/trunk/src/main/gate/gui/DocumentExportMenu.java 2014-07-18
09:55:27 UTC (rev 18198)
@@ -20,7 +20,7 @@
import gate.FeatureMap;
import gate.Gate;
import gate.Resource;
-import gate.creole.GateXMLExporter;
+import gate.corpora.export.GateXMLExporter;
import gate.creole.Parameter;
import gate.creole.ResourceData;
import gate.event.CreoleEvent;
Modified: gate/trunk/src/main/gate/resources/creole/creole.xml
===================================================================
--- gate/trunk/src/main/gate/resources/creole/creole.xml 2014-07-18
09:53:54 UTC (rev 18197)
+++ gate/trunk/src/main/gate/resources/creole/creole.xml 2014-07-18
09:55:27 UTC (rev 18198)
@@ -50,7 +50,7 @@
<!-- Document Exporters -->
<RESOURCE>
- <CLASS>gate.creole.GateXMLExporter</CLASS>
+ <CLASS>gate.corpora.export.GateXMLExporter</CLASS>
</RESOURCE>
</CREOLE>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs