blob: 9a128be66a1a5a449f9d8f0dfa938fbd9c2b886f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package scala.xml ;
import javaAdapter.Map;
/** superclass for specific representation of XML elements. These are created by the dtd2scala tool, together
* with a parsing facility.
*/
abstract class Element {
def getName: String; // the real element name
def getChildren: Seq[ Element ]; // the children
def getAttribs: Map[ String, String ]; // disabled
def setAttribs( m:Map[ String, String ] ):Unit ;
/** see Element.hashValue
*/
override def hashCode() = Element.hashValue( getName, getAttribs, getChildren );
def toXML: String = {
"<" + getName + Generic.toXML( getAttribs ) + ">"
+ toXML_( getChildren )
+ "</" + getName +">"
}
def toXML_( elems:Seq[Element] ):String = elems match {
case head :: tail => head.toXML + toXML_( tail );
case Nil => "";
}
override def toString() = getName.concat("(").concat(getChildren.toString().concat(")"));
} // abstract class Element
/** static helper methods for specific representations of XML elemens
*/
object Element {
/** returns a hash value computed from the element name, attributes and hash values of children.
*/
def hashValue( name:String, attribs:Map[ String, String ], children:Seq[ Element ] ) = {
name.hashCode() + attribs.hashCode() + children.hashCode()
}
/** returns a hash value computed from the element name, attributes and hash values of children.
*/
def hashValue( name:String, attribs:java.util.Map, children:Seq[ Element ] ) = {
name.hashCode() + attribs.hashCode() + children.hashCode()
}
}
|