diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-15 18:34:59 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-15 18:34:59 +0000 |
commit | 80f7efa886898658571776162c633bd5399d43e6 (patch) | |
tree | 8d7f8512c152052624b04058dac5d8e7cffa16df /java/sca/modules/node-impl/src/main | |
parent | 2a4b87ac24f89038777fda750c467515caf7e1fb (diff) |
Update NodeUtil and add a test case
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775282 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-impl/src/main')
-rw-r--r-- | java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java index c46d2116a3..83f17bc718 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.node.impl; import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; @@ -47,26 +48,6 @@ public class NodeUtil { } /** - * Escape the space in URL string - * @param uri - * @return - */ - static URI createURI(String uri) { - URI returnURI = null; - - try { - returnURI = URI.create(uri); - } catch( Exception e) { - try { - returnURI = new URI(null, uri, null); - } catch (Exception ee) { - throw new IllegalArgumentException("Invalid URI :" + uri, ee); - } - } - return returnURI; - } - - /** * Open a URL connection without cache * @param url * @return @@ -79,4 +60,25 @@ public class NodeUtil { is = connection.getInputStream(); return is; } + + /** + * Escape the space in URL string + * @param uri + * @return + */ + static URI createURI(String uri) { + int index = uri.indexOf(':'); + String scheme = null; + String ssp = uri; + if (index != -1) { + scheme = uri.substring(0, index); + ssp = uri.substring(index + 1); + } + try { + return new URI(scheme, ssp, null); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + } |