01: package org.conform.mdl;
02:
03: import org.conform.*;
04: import org.conform.format.Format;
05: import org.xml.sax.AttributeList;
06: import org.xml.sax.SAXException;
07: import org.apache.commons.logging.LogFactory;
08:
09: import java.beans.ExceptionListener;
10:
11: public class FormatHandler extends ScopeHandler implements ObjectScope {
12: private static org.apache.commons.logging.Log LOG = LogFactory
13: .getLog(Meta.class);
14:
15: private Object object;
16:
17: public FormatHandler(ExceptionListener exceptionListener) {
18: super (exceptionListener);
19: }
20:
21: public void startElement(String name, AttributeList attributes)
22: throws SAXException {
23: if ("format".equals(name)) {
24: LOG.trace("format");
25: } else {
26: getHandler("java").setScope(this );
27: getHandler("java").startElement(name, attributes);
28: }
29: }
30:
31: public void endElement(String name) throws SAXException {
32: if ("format".equals(name)) {
33: if (getScope() instanceof PropertyMeta) {
34: PropertyMeta propertyMeta = (PropertyMeta) getScope();
35: propertyMeta.setFormat((Format) object);
36: } else if (getScope() instanceof BeanMeta) {
37: BeanMeta beanMeta = (BeanMeta) getScope();
38: beanMeta.setFormat((Format) object);
39: }
40: } else
41: getHandler("java").endElement(name);
42: }
43:
44: public void characters(char ch[], int start, int length)
45: throws SAXException {
46: getHandler("java").characters(ch, start, length);
47: }
48:
49: public void setObject(Object object) {
50: LOG.debug("format = " + object);
51: this .object = object;
52: }
53:
54: public Object getObject() {
55: return object;
56: }
57: }
|