01: /*
02: * Copyright (C) 2004 TiongHiang Lee
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.1 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 Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.render;
22:
23: import org.onemind.awtbridge.BridgeContext;
24: import org.onemind.awtbridge.render.RenderDelegate;
25: import org.onemind.commons.java.xml.digest.SaxDigesterHandler;
26: import org.onemind.swingweb.SwingWebContext;
27: import org.onemind.swingweb.util.DelegateResolver;
28: import org.xml.sax.Attributes;
29: import org.xml.sax.SAXException;
30:
31: /**
32: *An abstract swing web render context
33: * @author TiongHiang Lee (thlee@onemindsoft.org)
34: *
35: */
36: public abstract class AbstractSwingWebRenderContext implements
37: SwingWebRenderContext {
38:
39: /** the delegates * */
40: private DelegateResolver _delegateResolver = new DelegateResolver(
41: "renderdelegates");
42:
43: /** the context **/
44: private SwingWebContext _context;
45:
46: /**
47: * Constructor
48: * @param context the context
49: */
50: protected AbstractSwingWebRenderContext(SwingWebContext context) {
51: _context = context;
52: }
53:
54: /**
55: * {@inheritDoc}
56: */
57: public void startDigest(SaxDigesterHandler handler, Attributes attrs) {
58: handler.addSubDigester(_delegateResolver);
59: }
60:
61: /**
62: * {@inheritDoc}
63: */
64: public final BridgeContext getContext() {
65: return _context;
66: }
67:
68: /**
69: * {@inheritDoc}
70: */
71: public void endDigest(SaxDigesterHandler handler)
72: throws SAXException {
73: }
74:
75: /**
76: * Resolve delegate
77: * @param comClass the component class
78: * @return the delegate for the comObject
79: */
80: public RenderDelegate resolveDelegate(Class comClass) {
81: Object obj = _delegateResolver.resolve(comClass);
82: return (RenderDelegate) obj;
83: }
84:
85: /**
86: * {@inheritDoc}
87: */
88: public void characters(SaxDigesterHandler handler, char[] chars,
89: int offset, int length) throws SAXException {
90: //do nothing
91: }
92: }
|