KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > xslt > CollectionAdapter


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.xslt;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Collection JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.List JavaDoc;
14
15
16 /**
17  * @author <a HREF="mailto:meier@meisterbohne.de">Philipp Meier</a>
18  * Date: 14.10.2003
19  * Time: 18:59:07
20  */

21 public class CollectionAdapter extends DefaultElementAdapter {
22     //~ Instance fields ////////////////////////////////////////////////////////
23

24     private Log log = LogFactory.getLog(this.getClass());
25
26     //~ Constructors ///////////////////////////////////////////////////////////
27

28     public CollectionAdapter(DOMAdapter rootAdapter, AdapterNode parent, String JavaDoc propertyName, Object JavaDoc value) {
29         super(rootAdapter, parent, propertyName, value);
30     }
31
32     //~ Methods ////////////////////////////////////////////////////////////////
33

34     protected List JavaDoc buildChildrenAdapters() {
35         Collection JavaDoc values = (Collection JavaDoc) getValue();
36         List JavaDoc children = new ArrayList JavaDoc(values.size());
37
38         for (Iterator JavaDoc i = values.iterator(); i.hasNext();) {
39             AdapterNode childAdapter = getRootAdapter().adapt(getRootAdapter(), this, "item", i.next());
40             children.add(childAdapter);
41
42             if (log.isDebugEnabled()) {
43                 log.debug(this + " adding adapter: " + childAdapter);
44             }
45         }
46
47         return children;
48     }
49 }
50
Popular Tags