summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-10 09:49:46 -0800
committerPaul Phillips <paulp@improving.org>2012-01-10 09:49:46 -0800
commit5f2568e36b87d183fd4e4442d5c304db628846c4 (patch)
tree6a19560879d63dd3c8f8341b6c9c198428288a87
parent3bdd7aa24567be7c21d33759d7e42a0c43e6bbcd (diff)
downloadscala-5f2568e36b87d183fd4e4442d5c304db628846c4.tar.gz
scala-5f2568e36b87d183fd4e4442d5c304db628846c4.tar.bz2
scala-5f2568e36b87d183fd4e4442d5c304db628846c4.zip
Revert "Accept prefixed xml attributes with null value"
This reverts commit 51089b34a7a535498dee42e6465d4d577d65b7d5. A scaladoc test is failing and I have no time to look at it.
-rw-r--r--src/library/scala/xml/PrefixedAttribute.scala15
-rw-r--r--test/files/run/xml-attribute.scala25
2 files changed, 9 insertions, 31 deletions
diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala
index b80d6a1c73..436dfcda43 100644
--- a/src/library/scala/xml/PrefixedAttribute.scala
+++ b/src/library/scala/xml/PrefixedAttribute.scala
@@ -13,25 +13,22 @@ package scala.xml
*
* @param pre ...
* @param key ...
- * @param value the attribute value
+ * @param value the attribute value, which may not be null
* @param next ...
*/
class PrefixedAttribute(
val pre: String,
val key: String,
val value: Seq[Node],
- val next1: MetaData)
+ val next: MetaData)
extends Attribute
{
- val next = if (value ne null) next1 else next1.remove(key)
+ if (value eq null)
+ throw new UnsupportedOperationException("value is null")
- /** same as this(pre, key, Text(value), next), or no attribute if value is null */
+ /** same as this(key, Utility.parseAttributeValue(value), next) */
def this(pre: String, key: String, value: String, next: MetaData) =
- this(pre, key, if (value ne null) Text(value) else null: NodeSeq, next)
-
- /** same as this(pre, key, value.get, next), or no attribute if value is None */
- def this(pre: String, key: String, value: Option[Seq[Node]], next: MetaData) =
- this(pre, key, value.orNull, next)
+ this(pre, key, Text(value), next)
/** Returns a copy of this unprefixed attribute with the given
* next field.
diff --git a/test/files/run/xml-attribute.scala b/test/files/run/xml-attribute.scala
index 8b261acc94..2b83f70b22 100644
--- a/test/files/run/xml-attribute.scala
+++ b/test/files/run/xml-attribute.scala
@@ -5,29 +5,10 @@ object Test {
val noAttr = <t/>
val attrNull = <t a={ null: String }/>
val attrNone = <t a={ None: Option[Seq[Node]] }/>
- val preAttrNull = <t p:a={ null: String }/>
- val preAttrNone = <t p:a={ None: Option[Seq[Node]] }/>
assert(noAttr == attrNull)
assert(noAttr == attrNone)
- assert(noAttr == preAttrNull)
- assert(noAttr == preAttrNone)
-
- val noAttrStr = "<t></t>"
- assert(noAttr.toString() == noAttrStr)
- assert(attrNull.toString() == noAttrStr)
- assert(attrNone.toString() == noAttrStr)
- assert(preAttrNull.toString() == noAttrStr)
- assert(preAttrNone.toString() == noAttrStr)
-
- val xml1 = <t b="1" d="2"/>
- val xml2 = <t a={ null: String } p:a={ null: String } b="1" c={ null: String } d="2"/>
- val xml3 = <t b="1" c={ null: String } d="2" a={ null: String } p:a={ null: String }/>
- assert(xml1 == xml2)
- assert(xml1 == xml3)
-
- val xml1Str = "<t d=\"2\" b=\"1\"></t>"
- assert(xml1.toString() == xml1Str)
- assert(xml2.toString() == xml1Str)
- assert(xml3.toString() == xml1Str)
+ assert(noAttr.toString() == "<t></t>")
+ assert(attrNull.toString() == "<t></t>")
+ assert(attrNone.toString() == "<t></t>")
}
}