// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.parser.modules; import org.xml.sax.Attributes; import xaal.objects.Animation; import xaal.objects.Defs; import xaal.objects.Initial; import xaal.objects.Xaal; import xaal.parser.ParserModule; /** * @author vkaravir * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class XaalMainParserModule extends ParserModule { public static final String ADD_DATASTRUCTURE_OBJECT = "adddsobj"; public static final String XAAL_ROOT_OBJECT = "xaal-root"; public static final String ADD_GRAPHICALPRIMITIVE_OBJECT = "addgpobj"; public static final String ADD_ANIMATIONOPERATION_OBJECT = "addaoobj"; public static final String STYLED_OBJECT = "stylobj"; public XaalMainParserModule() { } public void characters(char[] text, int start, int length) { } public void startElementAnimation(String namespaceURI, String localName, String qName, Attributes atts) { Xaal xaal = (Xaal) ParserModule.getProperty(XAAL_ROOT_OBJECT); Animation anim = new Animation(xaal); xaal.setAnimation(anim); push(anim); ParserModule.setProperty(ADD_DATASTRUCTURE_OBJECT, anim); ParserModule.setProperty(ADD_GRAPHICALPRIMITIVE_OBJECT, anim); ParserModule.setProperty(ADD_ANIMATIONOPERATION_OBJECT, anim); } public void startElementDefs(String namespaceURI, String localName, String qName, Attributes atts) { Defs d = new Defs(); Xaal x = (Xaal) ParserModule.getProperty(XAAL_ROOT_OBJECT); x.setDefs(d); push(d); } public void startElementInitial(String namespaceURI, String localName, String qName, Attributes atts) { Xaal xaal = (Xaal) getProperty(XAAL_ROOT_OBJECT); Initial init = new Initial(xaal); xaal.setInitial(init); setProperty(ADD_DATASTRUCTURE_OBJECT, init); ParserModule.setProperty(ADD_GRAPHICALPRIMITIVE_OBJECT, init); push(init); } public void startElementOption(String namespaceURI, String localName, String qName, Attributes atts) { Defs d = ((Xaal) getProperty(XAAL_ROOT_OBJECT)).getDefs(); String value = atts.getValue("value"); String name = atts.getValue("name"); d.addOption(name, value); } private void startRemoveElement(String namespaceURI, String localName, String qName, Attributes atts) { } private void startReplaceElement(String namespaceURI, String localName, String qName, Attributes atts) { } private void startSearchElement(String namespaceURI, String localName, String qName, Attributes atts) { } public void startElementXaal(String namespaceURI, String localName, String qName, Attributes atts) { Xaal xaal = new Xaal(); push(xaal); setProperty(XAAL_ROOT_OBJECT, xaal); if (atts.getIndex("version") != -1) { xaal.setVersion(atts.getValue("version")); } } public void endElementAnimation(String namespaceURI, String localName, String qName) { pop(); } public void endElementDefs(String namespaceURI, String localName, String qName) { pop(); } public void endElementInitial(String namespaceURI, String localName, String qName) { pop(); } private void endRemoveElement(String namespaceURI, String localName, String qName) { } private void endReplaceElement(String namespaceURI, String localName, String qName) { } private void endSearchElement(String namespaceURI, String localName, String qName) { } public void endElementXaal(String namespaceURI, String localName, String qName) { pop(); } }