01: /* SwingML
02: * Copyright (C) 2002 Robert Morris.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: *
19: * Authors:
20: * Robert Morris <robertj@morris.net>
21: * Alessandro Di Bella <alessandro.dibella@bpeng.com>
22: */
23:
24: package org.swingml.xml.mapper;
25:
26: import java.awt.*;
27:
28: import org.swingml.Constants;
29: import org.swingml.model.ControllerActionModel;
30: import org.swingml.model.ListenerModel;
31: import org.swingml.xml.Mapper;
32: import org.swingml.xml.MapperUtil;
33: import org.w3c.dom.Node;
34:
35: /**
36: * @author DPITT
37: *
38: */
39: public class ControllerActionMapper extends MapperUtil implements
40: Mapper {
41:
42: /**
43: * @see org.swingml.xml.Mapper#getModelToMap(Node, Object)
44: */
45: public Object getModelToMap(Node aNode, Object aParent,
46: Container aContainer) {
47: ControllerActionModel theModel = new ControllerActionModel();
48: ListenerModel theListener = (ListenerModel) aParent;
49: theListener.addAction(theModel);
50: return theModel;
51: }
52:
53: /**
54: * @see org.swingml.xml.Mapper#mapModel(Node, Object)
55: */
56: public void mapModel(Node aNode, Object aParent,
57: Container aContainer) {
58: ControllerActionModel theModel = (ControllerActionModel) this
59: .getModelToMap(aNode, aParent, aContainer);
60: this .mapModelAttributes(aNode, theModel, aParent);
61: super .iterate(aNode, theModel, aContainer);
62: }
63:
64: /**
65: * @see org.swingml.xml.Mapper#mapModelAttributes(Node, Object, Object)
66: */
67: public void mapModelAttributes(Node aNode, Object aModel,
68: Object aParent) {
69: ControllerActionModel theActionModel = (ControllerActionModel) aModel;
70: Node theResultNode = null;
71: theResultNode = super.getAttribute(aNode, Constants.COMPONENT);
72: if (theResultNode != null) {
73: theActionModel.setComponent(theResultNode.getNodeValue());
74: }
75:
76: theResultNode = super.getAttribute(aNode, Constants.URL);
77: if (theResultNode != null) {
78: theActionModel.setUrl(theResultNode.getNodeValue());
79: }
80:
81: theResultNode = super.getAttribute(aNode, Constants.OPERATION);
82: if (theResultNode != null) {
83: theActionModel.setOperation(theResultNode.getNodeValue());
84: }
85:
86: }
87: }
|