aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2014-03-15 00:25:37 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2014-04-03 15:38:37 +0200
commit82f28cc18b9371c81f3e6fa147080371a00443f5 (patch)
tree9f6e9f65dbe1b930d90d01ba09ae438cac2a0bd2 /pdf-as-lib/src/main/java/at/gv
parent0f8777952974daf03099bf48c6db1d91bd431bb2 (diff)
downloadpdf-as-4-82f28cc18b9371c81f3e6fa147080371a00443f5.tar.gz
pdf-as-4-82f28cc18b9371c81f3e6fa147080371a00443f5.tar.bz2
pdf-as-4-82f28cc18b9371c81f3e6fa147080371a00443f5.zip
Don't use raw types! Also check casts where possible
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderContext.java4
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderExtractor.java30
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/StamperFactory.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java9
6 files changed, 36 insertions, 31 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderContext.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderContext.java
index f09202ae..3c8a6d76 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderContext.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderContext.java
@@ -54,7 +54,7 @@ package at.gv.egiz.pdfas.lib.impl.placeholder;
*/
public class SignaturePlaceholderContext {
- private ThreadLocal sigHolder = new ThreadLocal();
+ private ThreadLocal<SignaturePlaceholderData> sigHolder = new ThreadLocal<SignaturePlaceholderData>();
private static SignaturePlaceholderContext instance = new SignaturePlaceholderContext();
@@ -72,7 +72,7 @@ public class SignaturePlaceholderContext {
* @return
*/
public static SignaturePlaceholderData getSignaturePlaceholderData(){
- return (SignaturePlaceholderData)instance.sigHolder.get();
+ return instance.sigHolder.get();
}
/**
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderExtractor.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderExtractor.java
index 52e25781..816ca04f 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderExtractor.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/SignaturePlaceholderExtractor.java
@@ -59,6 +59,7 @@ import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.exceptions.WrappedIOException;
import org.apache.pdfbox.pdmodel.PDDocument;
@@ -107,7 +108,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1;
public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2;
- private List placeholders = new Vector();
+ private List<SignaturePlaceholderData> placeholders = new Vector<SignaturePlaceholderData>();
private int currentPage = 0;
private SignaturePlaceholderExtractor(String placeholderId, int placeholderMatchMode) throws IOException {
@@ -143,8 +144,8 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
} catch (IOException e2) {
throw new PDFIOException("error.pdf.io.04", e2);
}
- List pages = doc.getDocumentCatalog().getAllPages();
- Iterator iter = pages.iterator();
+ List<?> pages = doc.getDocumentCatalog().getAllPages();
+ Iterator<?> iter = pages.iterator();
int pageNr = 0;
while (iter.hasNext()) {
pageNr++;
@@ -185,7 +186,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
}
private static SignaturePlaceholderData matchPlaceholderDocument(
- List placeholders, String placeholderId, int matchMode) throws PlaceholderExtractionException {
+ List<SignaturePlaceholderData> placeholders, String placeholderId, int matchMode) throws PlaceholderExtractionException {
if (matchMode == PLACEHOLDER_MATCH_MODE_STRICT)
throw new PlaceholderExtractionException("error.pdf.stamp.09");
@@ -195,24 +196,24 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
for (int i = 0; i < placeholders.size(); i++)
{
- SignaturePlaceholderData spd = (SignaturePlaceholderData)placeholders.get(i);
+ SignaturePlaceholderData spd = placeholders.get(i);
if (spd.getId() == null)
return spd;
}
if (matchMode == PLACEHOLDER_MATCH_MODE_LENIENT)
- return (SignaturePlaceholderData)placeholders.get(0);
+ return placeholders.get(0);
return null;
}
- private static SignaturePlaceholderData matchPlaceholderPage(List placeholders,
+ private static SignaturePlaceholderData matchPlaceholderPage(List<SignaturePlaceholderData> placeholders,
String placeholderId, int matchMode) {
if (placeholders.size() == 0)
return null;
for (int i = 0; i < placeholders.size(); i++)
{
- SignaturePlaceholderData data = (SignaturePlaceholderData)placeholders.get(i);
+ SignaturePlaceholderData data = placeholders.get(i);
if (placeholderId != null && placeholderId.equals(data.getId()))
return data;
if (placeholderId == null && data.getId() == null)
@@ -225,13 +226,14 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
this.currentPage = pageNr;
}
- protected void processOperator( PDFOperator operator, List arguments ) throws IOException
+ @Override
+ protected void processOperator(PDFOperator operator, List<COSBase> arguments) throws IOException
{
String operation = operator.getOperation();
if( operation.equals( "Do" ) )
{
COSName objectName = (COSName)arguments.get( 0 );
- Map xobjects = getResources().getXObjects();
+ Map<?, ?> xobjects = getResources().getXObjects();
PDXObject xobject = (PDXObject)xobjects.get( objectName.getName() );
if( xobject instanceof PDXObjectImage )
{
@@ -278,7 +280,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
}
else
{
- super.processOperator( operator, arguments );
+ super.processOperator(operator, arguments);
}
}
@@ -311,8 +313,8 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
Result result;
long before = System.currentTimeMillis();
try {
- Hashtable hints = new Hashtable();
- Vector formats = new Vector();
+ Hashtable<DecodeHintType, Vector<BarcodeFormat>> hints = new Hashtable<DecodeHintType, Vector<BarcodeFormat>>();
+ Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
formats.add(BarcodeFormat.QR_CODE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
result = new MultiFormatReader().decode(bitmap, hints);
@@ -326,7 +328,7 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine {
if (text.startsWith(QR_PLACEHOLDER_IDENTIFIER)) {
String[] data = text.split(";");
if (data.length > 1) {
- for (int i = 1; i < data.length; i++) {
+ for (int i = 1; i < data.length; i++) {
String kvPair = data[i];
String[] kv = kvPair.split("=");
if (kv.length != 2) {
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/StamperFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/StamperFactory.java
index 42dee32d..ffed4da6 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/StamperFactory.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/StamperFactory.java
@@ -33,9 +33,11 @@ public class StamperFactory {
public static IPDFStamper createDefaultStamper(ISettings settings) throws PdfAsException {
try {
- Class<? extends IPDFStamper> cls = (Class<? extends IPDFStamper>)
- Class.forName(DEFAULT_STAMPER_CLASS);
- IPDFStamper stamper = cls.newInstance();
+ Class<?> cls = Class.forName(DEFAULT_STAMPER_CLASS);
+ Object st = cls.newInstance();
+ if (!(st instanceof IPDFStamper))
+ throw new ClassCastException();
+ IPDFStamper stamper = (IPDFStamper) st;
stamper.setSettings(settings);
return stamper;
} catch (Throwable e) {
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
index 429aa6d0..8f945414 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/TableFactory.java
@@ -66,7 +66,7 @@ public class TableFactory implements IProfileConstants {
/**
* Reference from signature key to there corresponding value
*/
- private static Hashtable sigEntries_ = new Hashtable(8);
+ private static Hashtable<String, SignatureEntry> sigEntries_ = new Hashtable<String, SignatureEntry>(8);
static {
setDefaultStyles();
@@ -151,7 +151,7 @@ public class TableFactory implements IProfileConstants {
{
// analyse the row definition
String[] elems = table_def_string.split("\\|");
- ArrayList row = new ArrayList();
+ ArrayList<Entry> row = new ArrayList<Entry>();
for (int elem_idx = 0; elem_idx < elems.length; elem_idx++)
{
String elem = elems[elem_idx];
@@ -268,7 +268,7 @@ public class TableFactory implements IProfileConstants {
SignatureEntry sigEntry = null;
if (sigEntries_.containsKey(key))
{
- sigEntry = (SignatureEntry) sigEntries_.get(key);
+ sigEntry = sigEntries_.get(key);
value = sigEntry.getValue();
}
/*
@@ -305,7 +305,7 @@ public class TableFactory implements IProfileConstants {
String caption = null;
if (sigEntries_.containsKey(key))
{
- caption = ((SignatureEntry) sigEntries_.get(key)).getCaption();
+ caption = sigEntries_.get(key).getCaption();
if (caption == null)
{
caption = key;
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java
index 509494b2..4fb883a3 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/VerifierDispatcher.java
@@ -69,9 +69,11 @@ public class VerifierDispatcher {
try {
for (int i = 0; i < currentClasses.length; i++) {
String clsName = currentClasses[i];
- Class<? extends IVerifyFilter> cls = (Class<? extends IVerifyFilter>) Class
- .forName(clsName);
- IVerifyFilter filter = cls.newInstance();
+ Class<?> cls = Class.forName(clsName);
+ Object f = cls.newInstance();
+ if (!(f instanceof IVerifyFilter))
+ throw new ClassCastException();
+ IVerifyFilter filter = (IVerifyFilter) f;
filter.setConfiguration((Configuration) settings);
List<FilterEntry> entries = filter.getFiters();
Iterator<FilterEntry> it = entries.iterator();
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
index 9545b32f..c0a0b8aa 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
@@ -104,10 +104,9 @@ public class BKUSLConnector extends BaseSLConnector {
}
}
- @SuppressWarnings("rawtypes")
public InfoboxReadResponseType sendInfoboxReadRequest(
InfoboxReadRequestType request) throws PdfAsException {
- JAXBElement element = null;
+ JAXBElement<?> element = null;
String slRequest;
try {
slRequest = SLMarschaller.marshalToString(of
@@ -116,7 +115,7 @@ public class BKUSLConnector extends BaseSLConnector {
String slResponse = performHttpRequestToBKU(slRequest);
- element = (JAXBElement) SLMarschaller
+ element = (JAXBElement<?>) SLMarschaller
.unmarshalFromString(slResponse);
} catch (JAXBException e) {
@@ -146,7 +145,7 @@ public class BKUSLConnector extends BaseSLConnector {
public CreateCMSSignatureResponseType sendCMSRequest(
CreateCMSSignatureRequestType request) throws PdfAsException {
- JAXBElement element = null;
+ JAXBElement<?> element = null;
String slRequest;
try {
slRequest = SLMarschaller.marshalToString(of
@@ -155,7 +154,7 @@ public class BKUSLConnector extends BaseSLConnector {
String slResponse = performHttpRequestToBKU(slRequest);
- element = (JAXBElement) SLMarschaller
+ element = (JAXBElement<?>) SLMarschaller
.unmarshalFromString(slResponse);
} catch (JAXBException e) {
throw new PDFIOException("error.pdf.io.03", e);