View Javadoc
1   /*
2    * Copyright 2012 Olivier Godineau
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at http://www.apache.org/licenses/LICENSE-2.0
7    * 
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11   * License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package olg.csv.bean.loader.getter.impl;
15  
16  import java.util.ArrayList;
17  import java.util.List;
18  
19  import javax.xml.xpath.XPathConstants;
20  import javax.xml.xpath.XPathExpressionException;
21  
22  import olg.csv.bean.getter.AbstractGetter;
23  import olg.csv.bean.loader.LoadException;
24  import olg.csv.bean.loader.Util;
25  import olg.csv.bean.loader.getter.AbstractGetterLoader;
26  
27  import org.w3c.dom.Element;
28  import org.w3c.dom.NodeList;
29  
30  /**
31   * The loader characteristic of the concate getter.
32   * 
33   * @see AbstractGetter#getConcate(List, String)
34   */
35  public final class ConcateGetterLoader extends AbstractGetterLoader {
36  
37  	/**
38  	 * Constructs a loader bound with the assemble node.
39  	 * 
40  	 * @param successor
41  	 *            the next getter loader in the loader chain.
42  	 */
43  	public ConcateGetterLoader(AbstractGetterLoader successor) {
44  		super("assemble", successor);
45  
46  	}
47  
48  	@Override
49  	protected AbstractGetter getConcreteGetter(Element node, String defaultValue) throws XPathExpressionException,
50  			LoadException {
51  		List<AbstractGetter> getters = new ArrayList<AbstractGetter>();
52  		NodeList liste = (NodeList) Util.evaluerDOM(node, "getter", XPathConstants.NODESET);
53  		for (int index = 0; index < liste.getLength(); index++) {
54  			getters.add(AbstractGetterLoader.getInstance().getGetter((Element) liste.item(index)));
55  		}
56  		return AbstractGetter.getConcate(getters, defaultValue);
57  	}
58  
59  }