summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/Reference.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2002-08-28 01:16:24 +0000
committerMark Spruiell <mes@zeroc.com>2002-08-28 01:16:24 +0000
commit71c8c443160e2dbaae3faec9fe3c0f0193d4d692 (patch)
treea6b61d979a34b2e791f97bb5f44f1220efa3b286 /java/src/IceInternal/Reference.java
parentimproving xerces workaround (diff)
downloadice-71c8c443160e2dbaae3faec9fe3c0f0193d4d692.tar.bz2
ice-71c8c443160e2dbaae3faec9fe3c0f0193d4d692.tar.xz
ice-71c8c443160e2dbaae3faec9fe3c0f0193d4d692.zip
adding encoding for references, identities
Diffstat (limited to 'java/src/IceInternal/Reference.java')
-rw-r--r--java/src/IceInternal/Reference.java79
1 files changed, 63 insertions, 16 deletions
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index a9dfeebbf19..a105c3fb139 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -153,22 +153,53 @@ public final class Reference
toString()
{
StringBuffer s = new StringBuffer();
- s.append(Ice.Util.identityToString(identity));
+
+ //
+ // If the encoded identity string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the identity string in quotes.
+ //
+ String id = Ice.Util.identityToString(identity);
+ if(StringUtil.findFirstOf(id, " \t\n\r:@") != -1)
+ {
+ s.append('"');
+ s.append(id);
+ s.append('"');
+ }
+ else
+ {
+ s.append(id);
+ }
if(facet.length > 0)
{
+ StringBuffer f = new StringBuffer();
+ for(int i = 0; i < facet.length ; i++)
+ {
+ f.append(StringUtil.encodeString(facet[i], "/"));
+ if(i < facet.length - 1)
+ {
+ f.append('/');
+ }
+ }
+
+ //
+ // If the encoded facet string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the facet string in quotes.
+ //
s.append(" -f ");
- for(int i = 0; i < facet.length ; i++)
- {
- //
- // TODO: Escape for whitespace and slashes.
- //
- s.append(facet[i]);
- if(i < facet.length - 1)
- {
- s.append('/');
- }
- }
+ String fs = f.toString();
+ if(StringUtil.findFirstOf(fs, " \t\n\r:@") != -1)
+ {
+ s.append('"');
+ s.append(fs);
+ s.append('"');
+ }
+ else
+ {
+ s.append(fs);
+ }
}
switch(mode)
@@ -224,10 +255,26 @@ public final class Reference
s.append(endpoints[i].toString());
}
}
- else
- {
- s.append(" @ " + adapterId);
- }
+ else
+ {
+ String a = StringUtil.encodeString(adapterId, null);
+ //
+ // If the encoded adapter id string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the adapter id string in quotes.
+ //
+ s.append(" @ ");
+ if(StringUtil.findFirstOf(a, " \t\n\r") != -1)
+ {
+ s.append('"');
+ s.append(a);
+ s.append('"');
+ }
+ else
+ {
+ s.append(a);
+ }
+ }
return s.toString();
}