01: /*
02: * SwingML Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Adi Rosenblum <arosenblum@crosslogic.com>
19: */
20:
21: package org.swingml.xml.mapper;
22:
23: import java.awt.*;
24:
25: import org.swingml.*;
26: import org.swingml.errors.*;
27: import org.swingml.model.*;
28: import org.swingml.xml.*;
29: import org.w3c.dom.*;
30:
31: public class ErrorHandlerMapper extends MapperUtil implements Mapper {
32:
33: public Object getModelToMap(Node aNode, Object aParent,
34: Container aContainer) {
35: ErrorHandlerModel theModel = new ErrorHandlerModel();
36: SwingMLModel theContainer = (SwingMLModel) aParent;
37: theContainer.addChild(theModel);
38: theModel.setParent(theContainer);
39:
40: return theModel;
41: }
42:
43: public void mapModel(Node aNode, Object aParent,
44: Container aContainer) {
45: ErrorHandlerModel theModel = (ErrorHandlerModel) this
46: .getModelToMap(aNode, aParent, aContainer);
47: this .mapModelAttributes(aNode, theModel, aParent);
48: super .iterate(aNode, theModel, aContainer);
49: }
50:
51: public void mapModelAttributes(Node aNode, Object aModel,
52: Object aParent) {
53: ErrorHandlerModel theModel = (ErrorHandlerModel) aModel;
54: super .mapCommonAttributes(theModel, aNode);
55:
56: Node theResultNode = super .getAttribute(aNode, Constants.TYPE);
57: if (theResultNode != null) {
58: try {
59: theModel.setErrorType(Integer.parseInt(theResultNode
60: .getNodeValue()));
61: } catch (Throwable t) {
62: theModel.setErrorType(ISwingMLError.ERROR_UNKNOWN);
63: }
64: }
65: }
66: }
|