diff options
author | pdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-12-06 16:34:52 +0000 |
---|---|---|
committer | pdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2010-12-06 16:34:52 +0000 |
commit | 29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d (patch) | |
tree | 5b75b34c822a79f70b83c266465dda70b9baeaf2 /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java | |
parent | 04375406fc1634adbf9b37143a2125327da6a11e (diff) | |
download | pdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.tar.gz pdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.tar.bz2 pdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.zip |
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@671 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java new file mode 100644 index 0000000..de5c7a8 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/io/TextDataSource.java @@ -0,0 +1,50 @@ +package at.gv.egiz.pdfas.web.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import at.gv.egiz.pdfas.api.io.DataSource;
+
+/**
+ *
+ * @author exthex
+ *
+ */
+public class TextDataSource implements DataSource {
+
+ private String text;
+
+ public TextDataSource(String text) {
+ this.text = text;
+ }
+
+ public InputStream createInputStream() {
+ try {
+ return new ByteArrayInputStream(text.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public int getLength() {
+ return 0;
+ }
+
+ public byte[] getAsByteArray() {
+ try{
+ return text.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getMimeType() {
+ return "text/plain";
+ }
+
+ public String getCharacterEncoding() {
+ return "UTF-8";
+ }
+
+}
|