From 06b900642342afb680aab3b36fba9247e1e29aa9 Mon Sep 17 00:00:00 2001 From: pdanner Date: Fri, 26 Nov 2010 12:02:47 +0000 Subject: Placeholder-image handling git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@613 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../placeholder/SignaturePlaceholderContext.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderContext.java (limited to 'src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderContext.java') diff --git a/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderContext.java b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderContext.java new file mode 100644 index 0000000..e8c157c --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/placeholder/SignaturePlaceholderContext.java @@ -0,0 +1,49 @@ +package at.gv.egiz.pdfas.placeholder; + +/** + * Store and retrieve {@link SignaturePlaceholderData} in/from a thread local context. + * + * @author exthex + * + */ +public class SignaturePlaceholderContext { + + private ThreadLocal sigHolder = new ThreadLocal(); + + private static SignaturePlaceholderContext instance = new SignaturePlaceholderContext(); + + /** + * Constructor. Private because this is a singleton. + */ + private SignaturePlaceholderContext() { + + } + + /** + * Get the {@link SignaturePlaceholderData} which is currently bound to this thread. + * Might be null. + * + * @return + */ + public static SignaturePlaceholderData getSignaturePlaceholderData(){ + return (SignaturePlaceholderData)instance.sigHolder.get(); + } + + /** + * + * @return true if there is currently a {@link SignaturePlaceholderData} bound to this thread, false otherwise. + */ + public static boolean isSignaturePlaceholderDataSet() { + return instance.sigHolder.get() != null; + } + + /** + * Bind a {@link SignaturePlaceholderData} to this thread. + * If the given data is null, the context will be cleared. + * + * @param data if null, clears the ThreadLocal, else binds the data to the current thread. + */ + public static void setSignaturePlaceholderData(SignaturePlaceholderData data) { + instance.sigHolder.set(data); + } +} -- cgit v1.2.3