01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.views.xslt;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09: import org.w3c.dom.Node;
10:
11: import java.util.ArrayList;
12: import java.util.Collection;
13: import java.util.Iterator;
14: import java.util.List;
15:
16: /**
17: * @author <a href="mailto:meier@meisterbohne.de">Philipp Meier</a>
18: * @author Pat Niemeyer (pat@pat.net)
19: */
20: public class CollectionAdapter extends AbstractAdapterElement {
21: //~ Instance fields ////////////////////////////////////////////////////////
22:
23: private Log log = LogFactory.getLog(this .getClass());
24:
25: //~ Constructors ///////////////////////////////////////////////////////////
26:
27: public CollectionAdapter() {
28: }
29:
30: public CollectionAdapter(AdapterFactory rootAdapterFactory,
31: AdapterNode parent, String propertyName, Object value) {
32: setContext(rootAdapterFactory, parent, propertyName, value);
33: }
34:
35: //~ Methods ////////////////////////////////////////////////////////////////
36:
37: protected List buildChildAdapters() {
38: Collection values = (Collection) getPropertyValue();
39: List children = new ArrayList(values.size());
40:
41: for (Iterator i = values.iterator(); i.hasNext();) {
42: Node childAdapter = getAdapterFactory().adaptNode(this ,
43: "item", i.next());
44: if (childAdapter != null)
45: children.add(childAdapter);
46:
47: if (log.isDebugEnabled()) {
48: log.debug(this + " adding adapter: " + childAdapter);
49: }
50: }
51:
52: return children;
53: }
54: }
|