/* SwingML
* Copyright (C) 2002 Robert Morris.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Morris <robertj@morris.net>
* Alessandro Di Bella <alessandro.dibella@bpeng.com>
*/
package org.swingml.xml.mapper;
import java.awt.*;
import org.swingml.Constants;
import org.swingml.model.ControllerActionModel;
import org.swingml.model.ListenerModel;
import org.swingml.xml.Mapper;
import org.swingml.xml.MapperUtil;
import org.w3c.dom.Node;
/**
* @author DPITT
*
*/
public class ControllerActionMapper extends MapperUtil implements Mapper {
/**
* @see org.swingml.xml.Mapper#getModelToMap(Node, Object)
*/
public Object getModelToMap(Node aNode, Object aParent, Container aContainer) {
ControllerActionModel theModel = new ControllerActionModel();
ListenerModel theListener = (ListenerModel) aParent;
theListener.addAction(theModel);
return theModel;
}
/**
* @see org.swingml.xml.Mapper#mapModel(Node, Object)
*/
public void mapModel(Node aNode, Object aParent, Container aContainer) {
ControllerActionModel theModel = (ControllerActionModel) this.getModelToMap(aNode, aParent, aContainer);
this.mapModelAttributes(aNode, theModel, aParent);
super.iterate(aNode, theModel, aContainer);
}
/**
* @see org.swingml.xml.Mapper#mapModelAttributes(Node, Object, Object)
*/
public void mapModelAttributes(Node aNode, Object aModel, Object aParent) {
ControllerActionModel theActionModel = (ControllerActionModel) aModel;
Node theResultNode = null;
theResultNode = super.getAttribute(aNode, Constants.COMPONENT);
if (theResultNode != null) {
theActionModel.setComponent(theResultNode.getNodeValue());
}
theResultNode = super.getAttribute(aNode, Constants.URL);
if (theResultNode != null) {
theActionModel.setUrl(theResultNode.getNodeValue());
}
theResultNode = super.getAttribute(aNode, Constants.OPERATION);
if (theResultNode != null) {
theActionModel.setOperation(theResultNode.getNodeValue());
}
}
}