From edd4ad9b35b1f1684c91e45da0ee2f7bfba363e5 Mon Sep 17 00:00:00 2001 From: Anders Nilsson <anders.nilsson@control.lth.se> Date: Tue, 12 Jul 2011 11:37:11 +0200 Subject: [PATCH] Added generation of prettyPrint methods for default element and attribute. --- CompilerGeneration.jrag | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag index b4d00c0..737433a 100644 --- a/CompilerGeneration.jrag +++ b/CompilerGeneration.jrag @@ -529,6 +529,28 @@ aspect GenPrettyPrinter { pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); pStream.println(" }\n"); + pStream.println(" public void __DefaultElement__.prettyPrint(String ind, PrintStream pStream) {"); + pStream.println(" pStream.print(ind+\"<\"+getTAG()+\" \");"); + pStream.println(" for (int i=0; i<getNumAttribute(); i++) {"); + pStream.println(" getAttribute(i).prettyPrint(ind,pStream);"); + pStream.println(" }"); + pStream.println(" if (getNumElement() == 0) {"); + pStream.println(" pStream.println(\"/> \");"); + pStream.println(" } else {"); + pStream.println(" pStream.println(\"> \");"); + pStream.println(" String newInd = ind+\" \";"); + pStream.println(" for (int i=0; i<getNumElement(); i++) {"); + pStream.println(" getElement(i).prettyPrint(newInd,pStream);"); + pStream.println(" }"); + pStream.println(" pStream.println(ind+\"</\"+getTAG()+\"> \");"); + pStream.println(" }"); + pStream.println(" }\n"); + + pStream.println(" public void __DefaultAttribute__.prettyPrint(String indent, PrintStream pStream) {"); + pStream.println(" pStream.print(\" \"+getNAME()+\"=\");"); + pStream.println(" getAttrValue().prettyPrint(indent,pStream);"); + pStream.println(" }\n"); + Hashtable h = elementTypes(); h.putAll(attributeTypes()); Iterator iter = h.values().iterator(); -- GitLab