summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/xml/DeclToScala.java21
-rw-r--r--sources/scala/xml/Element.scala22
2 files changed, 29 insertions, 14 deletions
diff --git a/sources/scala/xml/DeclToScala.java b/sources/scala/xml/DeclToScala.java
index 07343ace6e..990efe62c9 100644
--- a/sources/scala/xml/DeclToScala.java
+++ b/sources/scala/xml/DeclToScala.java
@@ -17,21 +17,21 @@ import scalac.ast.parser.Scanner ;
public class DeclToScala {
-
+ /*
static final String ATTRIBS_VALDEF =
"val _at:scala.Map[String,String] = if( attribs == null ) { new scala.HashMap[String,String] } else attribs ;";
static final String ATTRIB_MAP = "attribs";
static final String ATTRIB_T = "scala.Map[String,String]";
-
+ */
static final String CHILDREN_VALDEF =
-"val _ch:List[Element] = if( children == null ) { scala.Nil[Element] } else children ;";
+"val _ch:List[Element] = if( children == null ) { scala.Nil } else children ;";
static final String CHILDREN_SEQ = "children";
static final String CHILDREN_T = "scala.List[Element]";
static final String RAW_NAME_DEF = "def getName:String = ";
static final String GET_CHILDREN_DEF = "def getChildren:scala.List[Element] = _ch ;";
- static final String GET_ATTRIBS_DEF = "def getAttribs:scala.Map[String,String] = _at ;";
+ //static final String GET_ATTRIBS_DEF = "def getAttribs:scala.Map[String,String] = _at ;";
static final int IND_STEP = 5;
@@ -61,7 +61,7 @@ public class DeclToScala {
fOut.println(" {");
fIndent = IND_STEP;
printIndent();
- fOut.println("import scala.xml ;");
+ fOut.println("import scala.xml._ ;");
}
public void end() {
@@ -118,8 +118,8 @@ public class DeclToScala {
fOut.print( clazzName );
fOut.print('(');
- fOut.print( ATTRIB_MAP ); fOut.print(':'); fOut.print( ATTRIB_T );
- fOut.print(',');
+ //fOut.print( ATTRIB_MAP ); fOut.print(':'); fOut.print( ATTRIB_T );
+ //fOut.print(',');
fOut.print( CHILDREN_SEQ ); fOut.print(':'); fOut.print( CHILDREN_T );
fOut.print(')');
@@ -131,14 +131,15 @@ public class DeclToScala {
fOut.print('"'); fOut.print( decl.name ); fOut.print('"');
fOut.println(';');
- printIndent(); fOut.println( ATTRIBS_VALDEF );
- printIndent(); fOut.println( GET_ATTRIBS_DEF );
+ //printIndent(); fOut.println( ATTRIBS_VALDEF );
+ //printIndent(); fOut.println( GET_ATTRIBS_DEF );
printIndent(); fOut.println( CHILDREN_VALDEF );
printIndent(); fOut.println( GET_CHILDREN_DEF );
-
+ /*
for( Iterator it = decl.attribs.keySet().iterator(); it.hasNext() ; )
toScala( (AttrDecl) decl.attribs.get( it.next() ));
+ */
fIndent -= IND_STEP ;
printIndent();
diff --git a/sources/scala/xml/Element.scala b/sources/scala/xml/Element.scala
index 66542db82b..a882cf7548 100644
--- a/sources/scala/xml/Element.scala
+++ b/sources/scala/xml/Element.scala
@@ -9,17 +9,31 @@ abstract class Element {
def getName: String; // the real element name
def getChildren: List[Element]; // the children
-// def getAttribs: Map[ String, String ]; // disabled
+ def getAttribs: java.Map[ String, String ]; // disabled
+
+ def toXML: String = {
+ "<" + getName + " " + toXML( getAttribs ) + ">" + toXML( getChildren ) + "</" + getName +">"
+ }
def toXML( elems:List[Element] ):String = elems match {
case head :: tail => head.toString() + toXML( tail );
case Nil => "";
}
- def toXML: String =
- "<" + getName +">" + toXML( getChildren ) + "</" + getName +">"
-
+ def toXML( attrib:java.Map[ String, String ] ):String = {
+ def iterate( keys:Iterator[String] ) =
+ if( keys.hasNext )
+ {
+ val key = keys.next;
+ " " + key + "=\"" + attrib.get( key ) + "\" ";
+ }
+ else
+ {
+ ""
+ }
+ iterate( attrib.keys.elements );
+ }
/*
def toXML : String = {
val attribs = getAttribs;