diff options
author | michelou <michelou@epfl.ch> | 2004-04-30 08:53:18 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2004-04-30 08:53:18 +0000 |
commit | cd2030986ec30291e171af519a6cdace2fc0274a (patch) | |
tree | d9ba560e3d40a77bb50f9171011bd954cc4cd291 /sources | |
parent | f9624981411a06b3a6404f47f9af23164f6edef1 (diff) | |
download | scala-cd2030986ec30291e171af519a6cdace2fc0274a.tar.gz scala-cd2030986ec30291e171af519a6cdace2fc0274a.tar.bz2 scala-cd2030986ec30291e171af519a6cdace2fc0274a.zip |
- added header and comments.
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/xml/Elem.scala | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/sources/scala/xml/Elem.scala b/sources/scala/xml/Elem.scala index 5ef1da62b9..4411b75494 100644 --- a/sources/scala/xml/Elem.scala +++ b/sources/scala/xml/Elem.scala @@ -1,43 +1,67 @@ -package scala.xml ; +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ -import scala.collection.mutable.HashMap ; -case class Elem( label:String, child:Node* ) extends Node { +package scala.xml; - def similar( x:Any ) = { - x match { - case that:Node => (label == that.label) && child.equals( that.child ) - // sameElements - case _ => false; - } +import scala.collection.mutable.HashMap; + + +/** The case class <code>Elem</code> implements... + * + * @author Burak Emir + * @version 1.0, 26/04/2004 + */ +case class Elem(label: String, child: Node*) extends Node { + + def similar(x: Any) = x match { + case that: Node => (label == that.label) && child.equals(that.child) + // sameElements + case _ => false } - def `@` = new HashMap[String,String](); + def `@` = new HashMap[String, String](); /** the attributes axis - default is Nil - */ + * + * @return a list + */ def attribute: Seq[Pair[String, String]] = `@`.toList; - /** returns a new element with updated attributes - */ - final def %(attrs: Seq[Pair[String, String]]):Elem = { - val newmap = new HashMap[String,String](); - for( val p <- `@`.elements ) { newmap += p._1 -> p._2 }; - for( val p <- attrs ) { newmap += p._1 -> p._2 }; - new Elem( label, child:_* ) { + /** Return a new element with updated attributes + * + * @param attrs + * @return a new symbol with updated attributes + */ + final def %(attrs: Seq[Pair[String, String]]): Elem = { + val newmap = new HashMap[String, String](); + for ( val p <- `@`.elements ) { newmap += p._1 -> p._2 }; + for ( val p <- attrs ) { newmap += p._1 -> p._2 }; + new Elem(label, child:_*) { override def `@` = newmap; override def attribute = `@`.toList; - }; + } } - /** returns a new symbol with updated attribute - */ - final def %(attr: Pair[String, String]):Elem = { - val newmap = new HashMap[String,String](); - for( val p <- `@`.elements ) { newmap += p._1 -> p._2 }; + + /** Return a new symbol with updated attribute + * + * @param attr + * @return a new symbol with updated attribute + */ + final def %(attr: Pair[String, String]): Elem = { + val newmap = new HashMap[String, String](); + for ( val p <- `@`.elements ) { newmap += p._1 -> p._2 }; newmap += attr._1 -> attr._2; - new Elem( label, child:_* ) { + new Elem(label, child:_*) { override def `@` = newmap; override def attribute = `@`.toList; - }; + } } + } |