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.templaterender;
22:
23: import java.util.logging.Level;
24: import java.util.logging.Logger;
25: import org.onemind.jxp.JxpPageSource;
26: import org.onemind.swingweb.util.LazyInheritedValueMap;
27:
28: /**
29: * For resolving templates
30: * @author TiongHiang Lee (thlee@onemindsoft.org)
31: *
32: */
33: public class JxpTemplateResolver extends LazyInheritedValueMap {
34:
35: /** the logger * */
36: private static final Logger _logger = Logger
37: .getLogger(JxpTemplateResolver.class.getName());
38:
39: /** the page source * */
40: private JxpPageSource _source;
41:
42: /** the template extension **/
43: private String _templateExt;
44:
45: /**
46: * Constructor
47: * @param source the page source
48: */
49: public JxpTemplateResolver(JxpPageSource source, String templateExt) {
50: _source = source;
51: _templateExt = templateExt;
52: }
53:
54: /**
55: * {@inheritDoc}
56: */
57: protected Object delayedResolve(Class c) {
58: String s = c.toString().substring(6);
59: s = s.replace('.', '/') + _templateExt;
60: if (_logger.isLoggable(Level.FINEST)) {
61: _logger.finest("Resolving template for component " + c);
62: }
63: if (_source.hasJxpPage(s)) {
64: if (_logger.isLoggable(Level.FINEST)) {
65: _logger.finest("Found " + s);
66: }
67: return s;
68: } else {
69: return null;
70: }
71: }
72: }
|