Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-12-17 00:03:01 +0000
committerslewis@composent.com2010-12-17 00:03:01 +0000
commit2d4cf6c71555055289ae09f8d5ce3244a8d865fe (patch)
tree065c8b3b5bf8d2f2784a7932ed2841b8694dfb83 /incubation
parent15825aa36bb594179d1b87ebc21a81b003ccdb6e (diff)
downloadorg.eclipse.ecf-2d4cf6c71555055289ae09f8d5ce3244a8d865fe.tar.gz
org.eclipse.ecf-2d4cf6c71555055289ae09f8d5ce3244a8d865fe.tar.xz
org.eclipse.ecf-2d4cf6c71555055289ae09f8d5ce3244a8d865fe.zip
rsa fixes
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java43
1 files changed, 26 insertions, 17 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
index d0c033bc9..855343bb8 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
@@ -28,7 +28,9 @@ import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
public abstract class AbstractMetadataFactory {
- protected static final String COLLECTION_SEPARATOR = ",";
+ protected static final String LIST_PREFIX = "{ ";
+ protected static final String LIST_SUFFIX = " }";
+ protected static final String LIST_SEPARATOR = ",";
protected void encodeString(IServiceProperties props, String name,
String value) {
@@ -51,29 +53,36 @@ public abstract class AbstractMetadataFactory {
}
protected void encodeList(IServiceProperties props, String name,
- List<String> value) {
- final StringBuffer result = new StringBuffer();
- for (final Iterator<String> i = value.iterator(); i.hasNext();) {
- final String item = (String) i.next();
- result.append(item);
- if (i.hasNext()) {
- result.append(COLLECTION_SEPARATOR);
+ List<String> list) {
+ if (list == null) return;
+ if (list.size() == 1) {
+ props.setPropertyString(name, list.get(0));
+ } else {
+ final StringBuffer result = new StringBuffer(LIST_PREFIX);
+ for (Iterator<String> i = list.iterator(); i.hasNext(); ) {
+ result.append(i.next());
+ if (i.hasNext())
+ result.append(LIST_SEPARATOR);
}
+ result.append(LIST_SUFFIX);
+ // Now add to props
+ props.setPropertyString(name, result.toString());
}
- // Now add to props
- props.setPropertyString(name, result.toString());
}
- protected List decodeList(IServiceProperties props, String name) {
+ protected List<String> decodeList(IServiceProperties props, String name) {
String value = props.getPropertyString(name);
if (value == null)
return Collections.EMPTY_LIST;
- List result = new ArrayList();
- final StringTokenizer t = new StringTokenizer(value,
- COLLECTION_SEPARATOR);
- while (t.hasMoreTokens()) {
- result.add(t.nextToken());
- }
+ List<String> result = new ArrayList<String>();
+ if (value.startsWith(LIST_PREFIX)) {
+ // trim prefix
+ value = value.substring(LIST_PREFIX.length());
+ // trim suffix
+ value = value.substring(0, value.length() - LIST_SUFFIX.length());
+ final StringTokenizer t = new StringTokenizer(value, LIST_SEPARATOR);
+ while (t.hasMoreTokens()) result.add(t.nextToken());
+ } else result.add(value);
return result;
}

Back to the top