01: package org.conform.mdl;
02:
03: import org.xml.sax.*;
04:
05: import java.beans.ExceptionListener;
06:
07: import org.conform.*;
08:
09: public class RelationBeanHandler extends ScopeHandler {
10: private BeanMeta relationBean;
11:
12: public RelationBeanHandler(ExceptionListener exceptionListener) {
13: super (exceptionListener);
14: }
15:
16: public void startElement(String name, AttributeList attributes)
17: throws SAXException {
18: if (!"relation-bean".equals(name))
19: exceptionListener.exceptionThrown(new SAXParseException(
20: "relation-bean doesn't have nested elements",
21: locator));
22: relationBean = null;
23: }
24:
25: public void endElement(String name) throws SAXException {
26: if ("relation-bean".equals(name))
27: ((PropertyMeta) getScope()).setRelationBean(relationBean);
28: }
29:
30: public void characters(char ch[], int start, int length)
31: throws SAXException {
32: String string = new String(ch, start, length);
33: ClassLoader classLoader = Thread.currentThread()
34: .getContextClassLoader();
35: if (classLoader == null)
36: classLoader = getClass().getClassLoader();
37: try {
38: relationBean = MDLModifier.getBeans().getBeanMeta(
39: classLoader.loadClass(string));
40: if (relationBean == null)
41: exceptionListener
42: .exceptionThrown(new SAXParseException(
43: "relation-bean expected: " + string,
44: locator));
45: } catch (ClassNotFoundException e) {
46: e.printStackTrace(System.err);
47: }
48: }
49: }
|