01: /*
02: * Created on 20 Aug 2006
03: */
04: package uk.org.ponder.rsf.template;
05:
06: import java.util.ArrayList;
07: import java.util.List;
08:
09: import uk.org.ponder.rsf.content.ContentTypeInfo;
10:
11: // We don't make this a FactoryBean since it may return null.
12: public class TPIAggregator {
13:
14: private ContentTypeInfo contenttypeinfo;
15: private List tpis;
16:
17: public void setTemplateParseInterceptors(List tpis) {
18: this .tpis = tpis;
19: }
20:
21: public void setContentTypeInfoProxy(ContentTypeInfo contenttypeinfo) {
22: this .contenttypeinfo = contenttypeinfo;
23: }
24:
25: public List getFilteredTPIs() {
26: if (tpis == null)
27: return null;
28:
29: List togo = new ArrayList();
30: ContentTypeInfo requestinfo = contenttypeinfo.get();
31: for (int i = 0; i < tpis.size(); ++i) {
32: TemplateParseInterceptor tpi = (TemplateParseInterceptor) tpis
33: .get(i);
34: if (!(tpi instanceof NullTemplateParseInterceptor)) {
35: if (tpi instanceof ContentTypedTPI) {
36: String[] actives = ((ContentTypedTPI) tpi)
37: .getInterceptedContentTypes();
38: for (int j = 0; j < actives.length; ++j) {
39: if (requestinfo.typename.equals(actives[j])) {
40: togo.add(tpi);
41: break;
42: }
43: }
44: } else { // add non ContentTyped TPIs unconditionally
45: togo.add(tpi);
46: }
47: }
48: }
49: return togo.size() == 0 ? null : togo;
50: }
51: }
|