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.List;
13:
14: /**
15: * @author <a href="mailto:meier@meisterbohne.de">Philipp Meier</a> Date: 14.10.2003 Time: 18:59:07
16: */
17: public class ArrayAdapter extends AbstractAdapterElement {
18: //~ Instance fields ////////////////////////////////////////////////////////
19:
20: private Log log = LogFactory.getLog(this .getClass());
21:
22: //~ Constructors ///////////////////////////////////////////////////////////
23:
24: public ArrayAdapter() {
25: }
26:
27: public ArrayAdapter(AdapterFactory adapterFactory,
28: AdapterNode parent, String propertyName, Object value) {
29: setContext(adapterFactory, parent, propertyName, value);
30: }
31:
32: //~ Methods ////////////////////////////////////////////////////////////////
33:
34: protected List buildChildAdapters() {
35: List children = new ArrayList();
36: Object[] values = (Object[]) getPropertyValue();
37:
38: for (int i = 0; i < values.length; i++) {
39: Node childAdapter = getAdapterFactory().adaptNode(this ,
40: "item", values[i]);
41: if (childAdapter != null)
42: children.add(childAdapter);
43:
44: if (log.isDebugEnabled()) {
45: log.debug(this + " adding adapter: " + childAdapter);
46: }
47: }
48:
49: return children;
50: }
51: }
|