From a3ecdb4630518b8dc00d0183bed435d8131b578c Mon Sep 17 00:00:00 2001 From: knowcenter Date: Wed, 16 May 2007 20:01:24 +0000 Subject: enveloping connectors git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@85 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../egov/egiz/sig/sigid/DetachedIdFormatter.java | 58 ++++++++++++++++++++++ .../wag/egov/egiz/sig/sigid/HotfixIdFormatter.java | 54 ++++++++++++++++++++ .../wag/egov/egiz/sig/sigid/IdFormatter.java | 14 ++++++ 3 files changed, 126 insertions(+) create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/HotfixIdFormatter.java create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/IdFormatter.java (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java new file mode 100644 index 0000000..273be52 --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/DetachedIdFormatter.java @@ -0,0 +1,58 @@ +/** + * + */ +package at.knowcenter.wag.egov.egiz.sig.sigid; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author wprinz + * + */ +public class DetachedIdFormatter implements IdFormatter +{ + /** + * The SIG_ID prefix. + */ + public static final String SIG_ID_PREFIX = "etsi-bku-detached@"; //$NON-NLS-1$ + + /** + * The log. + */ + private static Log log = LogFactory.getLog(DetachedIdFormatter.class); + + /** + * @see at.knowcenter.wag.egov.egiz.sig.sigid.IdFormatter#formatIds(java.lang.String[]) + */ + public String formatIds(String[] ids) + { + // ids algorithm: + String join = ""; //$NON-NLS-1$ + String base = null; + for (int arr_idx = 0; arr_idx < ids.length; arr_idx++) + { + String id = ids[arr_idx]; + if (log.isDebugEnabled()) + { + log.debug("Set BKU id:" + id); //$NON-NLS-1$ + } + int id_idx = id.lastIndexOf("-"); //$NON-NLS-1$ + if (arr_idx == 0) + { + base = id.substring(0, id_idx); + } + String cur_id = id.substring(id_idx + 1); + if (cur_id.equalsIgnoreCase("")) //$NON-NLS-1$ + { + cur_id = "0"; //$NON-NLS-1$ + } + + join += "-" + cur_id; //$NON-NLS-1$ + } + String idstr = base + "@" + join.substring(1); //$NON-NLS-1$ + String final_ids = SIG_ID_PREFIX + idstr; + return final_ids; + } + +} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/HotfixIdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/HotfixIdFormatter.java new file mode 100644 index 0000000..cb04d03 --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/HotfixIdFormatter.java @@ -0,0 +1,54 @@ +/** + * + */ +package at.knowcenter.wag.egov.egiz.sig.sigid; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author wprinz + * + */ +public class HotfixIdFormatter implements IdFormatter +{ + /** + * The SIG_ID prefix. + */ + public static final String SIG_ID_PREFIX = "etsi-bka-1.0@"; //$NON-NLS-1$ + + /** + * The log. + */ + private static Log log = LogFactory.getLog(HotfixIdFormatter.class); + + /** + * @see at.knowcenter.wag.egov.egiz.sig.sigid.IdFormatter#formatIds(java.lang.String[]) + */ + public String formatIds(String[] ids) + { + // ids algorithm: + String join = ""; //$NON-NLS-1$ + String base = null; + for (int arr_idx = 0; arr_idx < ids.length; arr_idx++) + { + String id = ids[arr_idx]; + if (log.isDebugEnabled()) + { + log.debug("Set BKU id:" + id); //$NON-NLS-1$ + } + int id_idx = id.lastIndexOf("-"); //$NON-NLS-1$ + if (arr_idx == 0) + { + base = id.substring(0, id_idx); + } + String cur_id = id.substring(id_idx + 1); + join += "-" + cur_id; //$NON-NLS-1$ + } + + String idstr = base + "@" + join.substring(1); //$NON-NLS-1$ + String final_ids = SIG_ID_PREFIX + idstr; + + return final_ids; + } +} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/IdFormatter.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/IdFormatter.java new file mode 100644 index 0000000..e86e352 --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/sigid/IdFormatter.java @@ -0,0 +1,14 @@ +/** + * + */ +package at.knowcenter.wag.egov.egiz.sig.sigid; + +/** + * @author wprinz + * + */ +public interface IdFormatter +{ + public String formatIds (String [] ids); + +} -- cgit v1.2.3