src/share/jaxws_classes/com/sun/xml/internal/ws/util/JAXWSUtils.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
90 return url; 90 return url;
91 } 91 }
92 92
93 private static String escapeSpace( String url ) { 93 private static String escapeSpace( String url ) {
94 // URLEncoder didn't work. 94 // URLEncoder didn't work.
95 StringBuffer buf = new StringBuffer(); 95 StringBuilder buf = new StringBuilder();
96 for (int i = 0; i < url.length(); i++) { 96 for (int i = 0; i < url.length(); i++) {
97 // TODO: not sure if this is the only character that needs to be escaped. 97 // TODO: not sure if this is the only character that needs to be escaped.
98 if (url.charAt(i) == ' ') 98 if (url.charAt(i) == ' ')
99 buf.append("%20"); 99 buf.append("%20");
100 else 100 else
107 // absolutize all the system IDs in the input, 107 // absolutize all the system IDs in the input,
108 // so that we can map system IDs to DOM trees. 108 // so that we can map system IDs to DOM trees.
109 try { 109 try {
110 URL baseURL = new File(".").getCanonicalFile().toURL(); 110 URL baseURL = new File(".").getCanonicalFile().toURL();
111 return new URL(baseURL, name).toExternalForm(); 111 return new URL(baseURL, name).toExternalForm();
112 } catch( IOException e ) { 112 } catch( IOException e) {
113 ; // ignore 113 //ignore
114 } 114 }
115 return name; 115 return name;
116 } 116 }
117 117
118 /** 118 /**
119 * Checks if the system ID is absolute. 119 * Checks if the system ID is absolute.
120 */ 120 */
121 @SuppressWarnings("ResultOfObjectAllocationIgnored")
121 public static void checkAbsoluteness(String systemId) { 122 public static void checkAbsoluteness(String systemId) {
122 // we need to be able to handle system IDs like "urn:foo", which java.net.URL can't process, 123 // we need to be able to handle system IDs like "urn:foo", which java.net.URL can't process,
123 // but OTOH we also need to be able to process system IDs like "file://a b c/def.xsd", 124 // but OTOH we also need to be able to process system IDs like "file://a b c/def.xsd",
124 // which java.net.URI can't process. So for now, let's fail only if both of them fail. 125 // which java.net.URI can't process. So for now, let's fail only if both of them fail.
125 // eventually we need a proper URI class that works for us. 126 // eventually we need a proper URI class that works for us.
126 try { 127 try {
127 new URL(systemId); 128 new URL(systemId);
128 } catch( MalformedURLException _ ) { 129 } catch( MalformedURLException mue) {
129 try { 130 try {
130 new URI(systemId); 131 new URI(systemId);
131 } catch (URISyntaxException e ) { 132 } catch (URISyntaxException e) {
132 throw new IllegalArgumentException("system ID '"+systemId+"' isn't absolute",e); 133 throw new IllegalArgumentException("system ID '"+systemId+"' isn't absolute",e);
133 } 134 }
134 } 135 }
135 } 136 }
136 137

mercurial