01: package com.jeta.forms.store.xml.parser;
02:
03: import java.awt.Insets;
04:
05: import org.xml.sax.SAXException;
06:
07: import com.jeta.forms.store.jml.dom.JMLAttributes;
08:
09: public class InsetsHandler extends InlineObjectHandler {
10:
11: protected void setProperty(Object key, Object value,
12: JMLAttributes attribs) throws SAXException {
13: Insets insets = (Insets) getObject();
14: if ("top".equalsIgnoreCase(key.toString())) {
15: insets.top = Integer.parseInt(value.toString());
16: } else if ("left".equalsIgnoreCase(key.toString())) {
17: insets.left = Integer.parseInt(value.toString());
18: } else if ("bottom".equalsIgnoreCase(key.toString())) {
19: insets.bottom = Integer.parseInt(value.toString());
20: } else if ("right".equalsIgnoreCase(key.toString())) {
21: insets.right = Integer.parseInt(value.toString());
22: }
23: }
24:
25: /**
26: *
27: */
28: protected Object instantiateObject(JMLAttributes attribs,
29: String value) throws InstantiationException,
30: IllegalAccessException, ClassNotFoundException {
31: if (value != null) {
32: String[] tokens = value.split(",");
33: return new Insets(Integer.parseInt(tokens[0]), Integer
34: .parseInt(tokens[1]), Integer.parseInt(tokens[2]),
35: Integer.parseInt(tokens[3]));
36: } else {
37: return new Insets(0, 0, 0, 0);
38: }
39: }
40: }
|