From ee8b49fc0b85730d90e34a1fe81e4dbef49b36f7 Mon Sep 17 00:00:00 2001 From: wprinz Date: Fri, 30 May 2008 09:57:51 +0000 Subject: CR Unsichtbare Felder git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@265 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/sig/SignatureTypeDefinition.java | 81 ++++++++++++++++++++-- 1 file changed, 74 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/knowcenter/wag') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypeDefinition.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypeDefinition.java index c8d8818..30ec211 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypeDefinition.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypeDefinition.java @@ -74,6 +74,22 @@ public class SignatureTypeDefinition implements Serializable * The settings reader reference */ private SettingsReader settings_ = null; + + /** + * List of (visible) field definitions. + */ + protected List field_definitions_ = null; + + /** + * List of invisible field definitions. + * + *

+ * If empty, all definitions are visible. + *

+ */ + protected List invisible_field_definitions = null; + + /** * The constructor of the signature type definition. It reads the configured @@ -94,6 +110,48 @@ public class SignatureTypeDefinition implements Serializable readSigTable(SignatureTypes.MAIN_TABLE); loadTypeDefinition(); readFieldDefinitions(); + readInvisibleFieldDefinitions(); + } + + protected void readInvisibleFieldDefinitions() + { + this.invisible_field_definitions = new ArrayList(); + for (int i = 0; i < SignatureTypes.REQUIRED_SIG_KEYS.length; i++) + { + String requiredKey = SignatureTypes.REQUIRED_SIG_KEYS[i]; + if (!this.sortedKeys_.contains(requiredKey)) + { + SignatureFieldDefinition sfd = readFieldDefinition(requiredKey); + this.invisible_field_definitions.add(sfd); + } + } + } + + /** + * Returns the List of invisible field definitions, if any. + * + *

+ * Invisible field definitions are the field definitions of required fields that are not explicitely specified in the signature profile. + *

+ *

+ * Note that the concept of invisible fields can only be used by binary signatures. + *

+ * + * @return Returns the List of invisible field definitions, if any. + */ + public List getInvisibleFieldDefinitions() + { + return this.invisible_field_definitions; + } + + /** + * Tells, if the signature type is text-extractable, which means that all required fields are visible. + * + * @return Returns true, if the signature type is text-extractable. + */ + public boolean isTextExtractable() + { + return this.invisible_field_definitions.isEmpty(); } /** @@ -367,7 +425,7 @@ public class SignatureTypeDefinition implements Serializable protected String getSettingsKeyBase() { - return SignatureTypes.SIG_OBJ + type_; + return getSettingsKeyBase(type_); } /** @@ -385,11 +443,7 @@ public class SignatureTypeDefinition implements Serializable sfd.caption = this.settings_.getValueFromKey(getSettingsKeyBase() + ".key." + field_name); sfd.value = this.settings_.getValueFromKey(getSettingsKeyBase() + type_ + ".value." + field_name); sfd.placeholder_length = -1; - String phlen_str = this.settings_.getValueFromKey(getSettingsKeyBase() + ".phlength." + field_name); - if (phlen_str == null) - { - phlen_str = this.settings_.getValueFromKey("defaults.phlength." + field_name); - } + String phlen_str = readPhLenStringFromSettings(this.settings_, this.type_, field_name); if (phlen_str != null) { sfd.placeholder_length = Integer.parseInt(phlen_str); @@ -398,7 +452,20 @@ public class SignatureTypeDefinition implements Serializable return sfd; } - List field_definitions_ = null; + protected static String getSettingsKeyBase (String type) + { + return SignatureTypes.SIG_OBJ + type; + } + + public static String readPhLenStringFromSettings(SettingsReader settings, String profile, String field_name) + { + String phlen_str = settings.getValueFromKey(getSettingsKeyBase(profile) + ".phlength." + field_name); + if (phlen_str == null) + { + phlen_str = settings.getValueFromKey("defaults.phlength." + field_name); + } + return phlen_str; + } protected void readFieldDefinitions() { -- cgit v1.2.3