From 535a04fa05f739ec16dd81666e3b0f82dfbd442d Mon Sep 17 00:00:00 2001 From: tknall Date: Wed, 9 Jan 2013 15:41:29 +0000 Subject: pdf-as-lib maven project files moved to pdf-as-lib git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@926 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../pdfas/impl/api/commons/DataSinkAdapter.java | 103 -------------- .../impl/api/commons/DataSourceApiAdapter.java | 105 -------------- .../impl/api/commons/PdfDataSourceAdapter.java | 72 ---------- .../api/commons/SignatureInformationAdapter.java | 133 ----------------- .../impl/api/commons/SignatureProfileImpl.java | 158 --------------------- .../api/commons/TextBasedDataSourceApiAdapter.java | 92 ------------ .../impl/api/commons/TextDataSourceAdapter.java | 72 ---------- 7 files changed, 735 deletions(-) delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.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/DataSinkAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java deleted file mode 100644 index 2aee44f..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.IOException; -import java.io.OutputStream; - -import at.gv.egiz.pdfas.api.io.DataSink; - -/** - * Adapter that converts an API DataSink to a framework DataSink. - * - * @author wprinz - */ -public class DataSinkAdapter implements at.gv.egiz.pdfas.framework.output.DataSink -{ - /** - * The API DataSink to be adapted to a framework DataSink. - */ - protected at.gv.egiz.pdfas.api.io.DataSink apiDataSink = null; - - /** - * Constructor. - * - * @param apiDataSink - * The API DataSink to be adapted to a framework DataSink. - */ - public DataSinkAdapter(DataSink apiDataSink) - { - this.apiDataSink = apiDataSink; - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#createOutputStream(java.lang.String) - */ - public OutputStream createOutputStream(String mimeType) - { - try - { - return this.apiDataSink.createOutputStream(mimeType); - } - catch (IOException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#createOutputStream(java.lang.String, - * java.lang.String) - */ - public OutputStream createOutputStream(String mimeType, String characterEncoding) - { - try - { - return this.apiDataSink.createOutputStream(mimeType, characterEncoding); - } - catch (IOException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#getCharacterEncoding() - */ - public String getCharacterEncoding() - { - return this.apiDataSink.getCharacterEncoding(); - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#getMimeType() - */ - public String getMimeType() - { - return this.apiDataSink.getMimeType(); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java deleted file mode 100644 index 8db3fcf..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.InputStream; - -import at.gv.egiz.pdfas.framework.input.PdfDataSource; -import at.gv.egiz.pdfas.framework.input.TextDataSource; - -/** - * Adapter that converts a framework DataSource to an API PdfDataSource. - * - * @author wprinz - */ -public class DataSourceApiAdapter implements at.gv.egiz.pdfas.api.io.DataSource -{ - /** - * The framework DataSource to be adapted to an API DataSource. - */ - protected at.gv.egiz.pdfas.framework.input.DataSource frameworkDataSource = null; - - /** - * Constructor. - * - * @param frameworkDataSource - * The framework DataSource to be adapted to an API DataSource. - */ - public DataSourceApiAdapter(at.gv.egiz.pdfas.framework.input.DataSource 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() - { - if (this.frameworkDataSource instanceof PdfDataSource) - { - return null; - } - if (this.frameworkDataSource instanceof TextDataSource) - { - return "UTF-8"; - } - return null; - } - - public String getMimeType() - { - if (this.frameworkDataSource instanceof PdfDataSource) - { - return "application/pdf"; - } - if (this.frameworkDataSource instanceof TextDataSource) - { - return "text/plain"; - } - - return null; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java deleted file mode 100644 index 6336071..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.InputStream; - -/** - * Adapter that converts an API DataSource to a framework PdfDataSource. - * - * @author wprinz - */ -public class PdfDataSourceAdapter implements at.gv.egiz.pdfas.framework.input.PdfDataSource -{ - /** - * The API DataSource to be adapted to a framework PdfDataSource. - */ - protected at.gv.egiz.pdfas.api.io.DataSource apiDataSource = null; - - /** - * Constructor. - * @param apiDataSource The API DataSource to be adapted to a framework PdfDataSource. - */ - public PdfDataSourceAdapter(at.gv.egiz.pdfas.api.io.DataSource apiDataSource) - { - this.apiDataSource = apiDataSource; - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#createInputStream() - */ - public InputStream createInputStream() - { - return this.apiDataSource.createInputStream(); - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#getAsByteArray() - */ - public byte[] getAsByteArray() - { - return this.apiDataSource.getAsByteArray(); - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#getLength() - */ - public int getLength() - { - return this.apiDataSource.getLength(); - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java deleted file mode 100644 index 34c706b..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.security.cert.X509Certificate; -import java.util.Date; -import java.util.List; - -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.commons.SignatureInformation; -import at.gv.egiz.pdfas.api.io.DataSource; -import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.EGIZDate; -import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; - -/** - * Adapter that converts a framework SignatureHolder to an API - * SignatureInformation. - * - * @author wprinz - */ -public class SignatureInformationAdapter implements SignatureInformation -{ - /** - * The framework SignatureHolder to be adapted to an API SignatureInformation. - */ - protected SignatureHolder signatureHolder = null; - - protected String timeStamp = null; - - protected List nonTextualObjects = null; - - /** - * Constructor. - * - * @param signatureHolder - * The framework SignatureHolder to be adapted to an API - * SignatureInformation. - */ - public SignatureInformationAdapter(SignatureHolder signatureHolder) - { - this.signatureHolder = signatureHolder; - if (signatureHolder instanceof BinarySignatureHolder) { - this.timeStamp = ((BinarySignatureHolder)signatureHolder).getSignatureObject().getTimeStamp(); - } - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignedData() - */ - public DataSource getSignedData() - { - return new DataSourceApiAdapter(this.signatureHolder.getDataSource()); - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getInternalSignatureInformation() - */ - public Object getInternalSignatureInformation() - { - return this.signatureHolder; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignatureType() - */ - public String getSignatureType() - { - if (this.signatureHolder.getSignatureObject().isBinary()) - { - return Constants.SIGNATURE_TYPE_BINARY; - } - return Constants.SIGNATURE_TYPE_TEXTUAL; - } - - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignerCertificate() - */ - public X509Certificate getSignerCertificate() - { - return this.signatureHolder.getSignatureObject().getX509Cert().getX509Certificate(); - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSigningTime() - */ - public Date getSigningTime() - { - String date_value = this.signatureHolder.getSignatureObject().getSignationDate(); - Date date = EGIZDate.parseDateFromString(date_value); - return date; - } - - public String getTimeStampValue() { - return this.timeStamp; - } - - public List getNonTextualObjects() { - return this.nonTextualObjects; - } - - public boolean hasNonTextualObjects() { - return this.nonTextualObjects != null && this.nonTextualObjects.size() > 0; - } - - public void setNonTextualObjects(List nonTextualObjects) { - this.nonTextualObjects = nonTextualObjects; - } - - -} 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 deleted file mode 100644 index 35d8c17..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.util.Properties; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import at.gv.egiz.pdfas.api.commons.SignatureProfile; - -/** - * Holds the data of a signature profile. - * - * @author wprinz - */ -public class SignatureProfileImpl implements SignatureProfile { - - /** - * The profile identifier. - */ - protected String profileId = null; - - /** - * The MOA key identifiert of this profile. - */ - protected String moaKeyIdentifier = null; - - /** - * Properties containing the layout settings relevant to the search algorithm - * for signature blocks. - */ - protected Properties signatureBlockEntries; - - /** - * Short description of the profile. - */ - protected String profileDescription; - - /** - * true if this is the default profile, false otherwise. - */ - protected boolean defaultProfile = false; - - /** - * Constructor. - * - * @param profileId - * The profile identifier. - * @param moaKeyIdentifier - * The MOA key identifier of this profile. - */ - public SignatureProfileImpl(String profileId, String moaKeyIdentifier) { - this.profileId = profileId; - this.moaKeyIdentifier = moaKeyIdentifier; - this.signatureBlockEntries = new Properties(); - } - - /** - * Constructor. - * - * @param profileId - * The profile identifier. - * @param profileDescription - * The profile description. - * @param moaKeyIdentifier - * The MOA key identifier of this profile. - * @param isDefault - */ - 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; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getProfileId() - */ - public String getProfileId() { - return this.profileId; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getMOAKeyIdentifier() - */ - public String getMOAKeyIdentifier() { - return this.moaKeyIdentifier; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getSignatureBlockEntries() - */ - public Properties getSignatureBlockEntries() { - return this.signatureBlockEntries; - } - - /** - * Sets the entries relevant to the search algorithm for signature blocks.
- * e.g. properties starting with sig_obj.PROFILE.key. and - * properties of the form sig_obj.PROFILE.table.TABLENAME.NUMBER - * where PROFILE is the name of the current profile, - * TABLENAME is the name of a table and NUMBER - * is the number of the specific row within the table TABLENAME. - * - * @param signatureBlockEntries - * The entries relevant to the signature block search algorithm as - * Java properties. - */ - public void setSignatureBlockEntries(Properties signatureBlockEntries) { - this.signatureBlockEntries = signatureBlockEntries; - } - - /** - * Returns the profile description. - * @return The profile description. - */ - public String getProfileDescription() { - return this.profileDescription; - } - - public String toString() { - return new ToStringBuilder(this) - .append("profileId", this.profileId) - .append("profileDescription", this.profileDescription) - .append("moaKeyIdentifier", this.moaKeyIdentifier) - .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 deleted file mode 100644 index 5685490..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -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(); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java deleted file mode 100644 index 39f88e2..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2006 by Know-Center, Graz, Austria - * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a - * joint initiative of the Federal Chancellery Austria and Graz University of - * Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.UnsupportedEncodingException; - -import at.gv.egiz.pdfas.api.io.TextBased; -import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl; - -/** - * Adapter that converts an API DataSource to a framework TextDataSource. - * - * @author wprinz - */ -public class TextDataSourceAdapter extends TextDataSourceImpl -{ - /** - * The API DataSource to be adapted to a framework TextDataSource. - */ - protected at.gv.egiz.pdfas.api.io.DataSource apiDataSource = null; - - /** - * Constructor. - * - * @param apiDataSource - * The API DataSource to be adapted to a framework TextDataSource. - * @throws UnsupportedEncodingException - */ - public TextDataSourceAdapter(at.gv.egiz.pdfas.api.io.DataSource apiDataSource) throws UnsupportedEncodingException - { - super(null); - this.apiDataSource = apiDataSource; - - if (this.apiDataSource instanceof TextBased) - { - TextBased tb = (TextBased) this.apiDataSource; - this.text = tb.getText(); - } - else - { - byte[] data = this.apiDataSource.getAsByteArray(); - String characterEncoding = this.apiDataSource.getCharacterEncoding(); - if (characterEncoding == null) - { - throw new UnsupportedEncodingException("The characterEncoding must not be null. Specify a correct encoding."); - } - this.text = new String(data, characterEncoding); - } - assert this.text != null; - } -} -- cgit v1.2.3