From 73c30d3a15a33d02f7ea675e267b39310913ba4d Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 6 Dec 2010 17:02:56 +0000 Subject: Necessary changes for separation of pdf-as-web and rest of the project git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@680 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../impl/api/commons/SignatureProfileImpl.java | 16 ++++- .../api/commons/TextBasedDataSourceApiAdapter.java | 72 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java (limited to 'src/main/java/at/gv/egiz/pdfas/impl/api/commons') diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java index 90e2ca0..b825c82 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java @@ -36,6 +36,11 @@ public class SignatureProfileImpl implements SignatureProfile { * Short description of the profile. */ protected String profileDescription; + + /** + * true if this is the default profile, false otherwise. + */ + protected boolean defaultProfile = false; /** * Constructor. @@ -60,12 +65,14 @@ public class SignatureProfileImpl implements SignatureProfile { * The profile description. * @param moaKeyIdentifier * The MOA key identifier of this profile. + * @param isDefault */ - public SignatureProfileImpl(String profileId, String profileDescription, String moaKeyIdentifier) { + public SignatureProfileImpl(String profileId, String profileDescription, String moaKeyIdentifier, boolean isDefault) { this.profileId = profileId; this.moaKeyIdentifier = moaKeyIdentifier; this.profileDescription = profileDescription; this.signatureBlockEntries = new Properties(); + this.defaultProfile = isDefault; } /** @@ -121,4 +128,11 @@ public class SignatureProfileImpl implements SignatureProfile { .toString(); } + /** + * + */ + public boolean isDefault() { + return this.defaultProfile; + } + } diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java new file mode 100644 index 0000000..5363c42 --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java @@ -0,0 +1,72 @@ +/** + * + */ +package at.gv.egiz.pdfas.impl.api.commons; + +import java.io.InputStream; + +import at.gv.egiz.pdfas.api.io.TextBased; +import at.gv.egiz.pdfas.framework.input.TextDataSource; + +/** + * Adapter that converts a framework DataSource to an API PdfDataSource. + * + * @author wprinz + */ +public class TextBasedDataSourceApiAdapter implements at.gv.egiz.pdfas.api.io.DataSource, TextBased +{ + /** + * The framework DataSource to be adapted to an API DataSource. + */ + protected TextDataSource frameworkDataSource = null; + + /** + * Constructor. + * + * @param frameworkDataSource + * The framework DataSource to be adapted to an API DataSource. + */ + public TextBasedDataSourceApiAdapter(TextDataSource frameworkDataSource) + { + this.frameworkDataSource = frameworkDataSource; + } + + /** + * @see at.gv.egiz.pdfas.api.io.DataSource#createInputStream() + */ + public InputStream createInputStream() + { + return this.frameworkDataSource.createInputStream(); + } + + /** + * @see at.gv.egiz.pdfas.api.io.DataSource#getAsByteArray() + */ + public byte[] getAsByteArray() + { + return this.frameworkDataSource.getAsByteArray(); + } + + /** + * @see at.gv.egiz.pdfas.api.io.DataSource#getLength() + */ + public int getLength() + { + return this.frameworkDataSource.getLength(); + } + + public String getCharacterEncoding() + { + return "UTF-8"; + } + + public String getMimeType() + { + return "text/plain"; + } + + public String getText() { + return this.frameworkDataSource.getText(); + } + +} -- cgit v1.2.3