Returns a QName holding the value of the specified String. The string must be in the form returned by the QName.toString() method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}" part being optional. This method doesn't do a full validation of the resulting QName. In particular, it
(String s)
| 247 | * @return QName corresponding to the given String |
| 248 | */ |
| 249 | public static QName valueOf(String s) { |
| 250 | |
| 251 | if ((s == null) || s.isEmpty()) { |
| 252 | throw new IllegalArgumentException("invalid QName literal"); |
| 253 | } |
| 254 | |
| 255 | if (s.charAt(0) == '{') { |
| 256 | int i = s.indexOf('}'); |
| 257 | |
| 258 | if (i == -1) { |
| 259 | throw new IllegalArgumentException("invalid QName literal"); |
| 260 | } |
| 261 | |
| 262 | if (i == s.length() - 1) { |
| 263 | throw new IllegalArgumentException("invalid QName literal"); |
| 264 | } else { |
| 265 | return new QName(s.substring(1, i), s.substring(i + 1)); |
| 266 | } |
| 267 | } else { |
| 268 | return new QName(s); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Returns a hash code value for this QName object. The hash code |