1
1
/*
2
- * Copyright (c) 2003, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2003, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -329,28 +329,16 @@ public final int hashCode() {
329
329
}
330
330
331
331
/**
332
- * <p><code>String</code> representation of this
333
- * <code>QName</code>.</p>
334
- *
335
- * <p>The commonly accepted way of representing a <code>QName</code>
336
- * as a <code>String</code> was
337
- * <a href="http://jclark.com/xml/xmlns.htm">defined</a>
338
- * by James Clark. Although this is not a <em>standard</em>
339
- * specification, it is in common use, e.g. {@link
340
- * javax.xml.transform.Transformer#setParameter(String name, Object value)}.
341
- * This implementation represents a <code>QName</code> as:
342
- * "{" + Namespace URI + "}" + local part. If the Namespace URI
343
- * <code>.equals(XMLConstants.NULL_NS_URI)</code>, only the
344
- * local part is returned. An appropriate use of this method is
345
- * for debugging or logging for human consumption.</p>
346
- *
347
- * <p>Note the prefix value is <strong><em>NOT</em></strong>
348
- * returned as part of the <code>String</code> representation.</p>
332
+ * Returns the string representation of this {@code QName}.
333
+ * The format is:
334
+ * <pre> {@code
335
+ * {NamespaceURI}LocalPart
336
+ * }</pre>
337
+ * If {@code NamespaceURI} is {@code null}, only {@code LocalPart} is returned.
349
338
*
350
- * <p>This method satisfies the general contract of {@link
351
- * java.lang.Object#toString() Object.toString()}.</p>
339
+ * @apiNote The {@code Prefix} is not returned in the string representation.
352
340
*
353
- * @return <code>String</code> representation of this < code> QName</code>
341
+ * @return the string representation of this {@ code QName}
354
342
*/
355
343
public String toString () {
356
344
if (namespaceURI .equals (XMLConstants .NULL_NS_URI )) {
@@ -361,48 +349,27 @@ public String toString() {
361
349
}
362
350
363
351
/**
364
- * <p><code>QName</code> derived from parsing the formatted
365
- * <code>String</code>.</p>
366
- *
367
- * <p>If the <code>String</code> is <code>null</code> or does not conform to
368
- * {@link #toString() QName.toString()} formatting, an
369
- * <code>IllegalArgumentException</code> is thrown.</p>
370
- *
371
- * <p><em>The <code>String</code> <strong>MUST</strong> be in the
372
- * form returned by {@link #toString() QName.toString()}.</em></p>
373
- *
374
- * <p>The commonly accepted way of representing a <code>QName</code>
375
- * as a <code>String</code> was
376
- * <a href="http://jclark.com/xml/xmlns.htm">defined</a>
377
- * by James Clark. Although this is not a <em>standard</em>
378
- * specification, it is in common use, e.g. {@link
379
- * javax.xml.transform.Transformer#setParameter(String name, Object value)}.
380
- * This implementation parses a <code>String</code> formatted
381
- * as: "{" + Namespace URI + "}" + local part. If the Namespace
382
- * URI <code>.equals(XMLConstants.NULL_NS_URI)</code>, only the
383
- * local part should be provided.</p>
384
- *
385
- * <p>The prefix value <strong><em>CANNOT</em></strong> be
386
- * represented in the <code>String</code> and will be set to
387
- * {@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX
388
- * XMLConstants.DEFAULT_NS_PREFIX}.</p>
389
- *
390
- * <p>This method does not do full validation of the resulting
391
- * <code>QName</code>.
392
- * <p>The Namespace URI is not validated as a
352
+ * Returns a {@code QName} from its string representation.
353
+ * The string representation must be in the format returned by {@link #toString()}:
354
+ * <pre> {@code
355
+ * {NamespaceURI}LocalPart
356
+ * }</pre>
357
+ * Since the {@code Prefix} is not represented in the string form, it will be
358
+ * set to {@link javax.xml.XMLConstants#DEFAULT_NS_PREFIX XMLConstants.DEFAULT_NS_PREFIX}.
359
+ *
360
+ * @apiNote This method does not perform full validation of the resulting
361
+ * {@code QName}. The {@code NamespaceURI} is not validated as a
393
362
* <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
394
- * The local part is not validated as a
363
+ * The {@code LocalPart} is not validated as a
395
364
* <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
396
365
* as specified in
397
- * <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.</p>
398
- *
399
- * @param qNameAsString <code>String</code> representation
400
- * of the <code>QName</code>
366
+ * <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a>.
401
367
*
402
- * @throws IllegalArgumentException When <code>qNameAsString</code> is
403
- * <code>null</code> or malformed
368
+ * @param qNameAsString the string representation of the {@code QName}
404
369
*
405
- * @return <code>QName</code> corresponding to the given <code>String</code>
370
+ * @return a {@code QName} from its string representation
371
+ * @throws IllegalArgumentException if {@code qNameAsString} is {@code null}
372
+ * or malformed
406
373
* @see #toString() QName.toString()
407
374
*/
408
375
public static QName valueOf (String qNameAsString ) {
0 commit comments