Skip to content

Commit 4222701

Browse files
Burak Emiradriaanm
Burak Emir
authored andcommitted
* TupleN extends ProductN, again (genprod updated)
* better comments and parameter names in scala.xml.MetaData typechecker * now handles special cases (n=0, n=1) for unapply correctly * * even if one returns a Option[Product1[T]] * typechecker now handles unapply return types correctly * * e.g. when returning Option[{A,B}] instead of Option[Product2[A,B]]
1 parent 586c329 commit 4222701

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/library/scala/xml/MetaData.scala

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ abstract class MetaData extends Iterable[MetaData] {
3737
next.append(copy(m))
3838

3939
/**
40-
* @param s ...
41-
* @return ...
40+
* Gets value of unqualified (unprefixed) attribute with given key, null if not found
41+
*
42+
* @param key
43+
* @return value as Seq[Node] if key is found, null otherwise
4244
*/
43-
def apply(s: String): Seq[Node]
45+
def apply(key: String): Seq[Node]
4446

4547
/** convenience method, same as <code>apply(namespace, owner.scope, key)</code>.
4648
*
@@ -52,6 +54,14 @@ abstract class MetaData extends Iterable[MetaData] {
5254
final def apply(namespace: String, owner: Node, key: String): Seq[Node] =
5355
apply(namespace, owner.scope, key)
5456

57+
/**
58+
* Gets value of prefixed attribute with given key and namespace, null if not found
59+
*
60+
* @param uri namespace of key
61+
* @param scp a namespace scp (usually of the element owning this attribute list)
62+
* @param key to be looked fore
63+
* @return value as Seq[Node] if key is found, null otherwise
64+
*/
5565
def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node]
5666

5767
/**
@@ -122,25 +132,30 @@ abstract class MetaData extends Iterable[MetaData] {
122132
/** returns Null or the next MetaData item */
123133
def next: MetaData
124134

125-
/** gets value of unqualified (unprefixed) attribute with given key */
135+
/**
136+
* Gets value of unqualified (unprefixed) attribute with given key, None if not found
137+
*
138+
* @param key
139+
* @return value in Some(Seq[Node]) if key is found, None otherwise
140+
*/
126141
final def get(key: String): Option[Seq[Node]] = apply(key) match {
127142
case null => None
128143
case x => Some(x)
129144
}
130145

131-
/** same as get(namespace, owner.scope, key) */
132-
final def get(namespace: String, owner: Node, key: String): Option[Seq[Node]] =
133-
get(namespace, owner.scope, key)
146+
/** same as get(uri, owner.scope, key) */
147+
final def get(uri: String, owner: Node, key: String): Option[Seq[Node]] =
148+
get(uri, owner.scope, key)
149+
134150

135151
/** gets value of qualified (prefixed) attribute with given key.
136-
*
137-
* @param namespace ...
138-
* @param scope ...
139-
* @param key ...
140-
* @return <code>Some(x)</code> iff ...
152+
* @param uri namespace of key
153+
* @param scope a namespace scp (usually of the element owning this attribute list)
154+
* @param key to be looked fore
155+
* @return value as Some[Seq[Node]] if key is found, None otherwise
141156
*/
142-
final def get(namespace: String, scope: NamespaceBinding, key: String): Option[Seq[Node]] =
143-
apply(namespace, scope, key) match {
157+
final def get(uri: String, scope: NamespaceBinding, key: String): Option[Seq[Node]] =
158+
apply(uri, scope, key) match {
144159
case null => None
145160
case x => Some(x)
146161
}

src/library/scala/xml/UnprefixedAttribute.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class UnprefixedAttribute(val key: String, val value: Seq[Node], next1: MetaData
3636
null
3737

3838
/**
39-
* Gets value of unqualified (unprefixed) attribute with given key.
39+
* Gets value of unqualified (unprefixed) attribute with given key, null if not found
4040
*
4141
* @param key
42-
* @return ..
42+
* @return value as Seq[Node] if key is found, null otherwise
4343
*/
4444
def apply(key: String): Seq[Node] =
4545
if (key == this.key) value else next(key)

0 commit comments

Comments
 (0)