01: /* DataRowDecorator.java
02: *
03: * DDSteps - Data Driven JUnit Test Steps
04: * Copyright (C) 2005 Jayway AB
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License version 2.1 as published by the Free Software Foundation.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, visit
17: * http://www.opensource.org/licenses/lgpl-license.php
18: */
19: package org.ddsteps.dataset.decorator;
20:
21: import java.util.Iterator;
22:
23: import org.apache.commons.collections.Transformer;
24: import org.apache.commons.collections.functors.NOPTransformer;
25: import org.apache.commons.collections.iterators.TransformIterator;
26: import org.ddsteps.dataset.DataRow;
27:
28: /**
29: * @author Adam
30: * @version $Id: DataRowDecorator.java,v 1.1 2005/12/03 12:51:40 adamskogman Exp $
31: */
32: public class DataRowDecorator implements DataRow {
33:
34: final DataRow dataRow;
35:
36: Transformer dataValueTransformer = NOPTransformer.INSTANCE;
37:
38: /**
39: * @param dataRow
40: */
41: public DataRowDecorator(DataRow dataRow) {
42: super ();
43: this .dataRow = dataRow;
44: }
45:
46: /**
47: * @return Row id
48: */
49: public String getId() {
50: return dataRow.getId();
51: }
52:
53: /**
54: * @see DataRow#iterator()
55: */
56: public Iterator iterator() {
57: return new TransformIterator(dataRow.iterator(),
58: new DataValueDecoratorTransformer(dataValueTransformer));
59: }
60:
61: /**
62: * @param dataValueTransformer
63: * The dataValueTransformer to set.
64: */
65: public void setDataValueTransformer(Transformer dataValueTransformer) {
66: this .dataValueTransformer = dataValueTransformer;
67: }
68:
69: /**
70: * Test accessor.
71: *
72: * @return Returns the dataRow that this decorator decorates.
73: */
74: public DataRow getDataRow() {
75: return dataRow;
76: }
77: }
|