01: /* DataRowDecoratorTransformer.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 org.apache.commons.collections.Transformer;
22: import org.apache.commons.lang.Validate;
23: import org.ddsteps.dataset.DataRow;
24:
25: /**
26: * @author Adam
27: * @version $Id: DataRowDecoratorTransformer.java,v 1.1 2005/12/03 12:51:40 adamskogman Exp $
28: */
29: public class DataRowDecoratorTransformer implements Transformer {
30:
31: final Transformer dataValueTransformer;
32:
33: /**
34: * @param dataValueTransformer
35: */
36: public DataRowDecoratorTransformer(Transformer dataValueTransformer) {
37: super ();
38: Validate.notNull(dataValueTransformer);
39: this .dataValueTransformer = dataValueTransformer;
40: }
41:
42: /**
43: * Decorate a DataRow with a DataRowDecorator.
44: *
45: * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
46: */
47: public Object transform(Object arg0) {
48: Validate.notNull(arg0, "Argument must not be null");
49: Validate.isTrue(arg0 instanceof DataRow,
50: "Argument must be a DataRow");
51: DataRow row = (DataRow) arg0;
52:
53: DataRowDecorator decorator = new DataRowDecorator(row);
54: decorator.setDataValueTransformer(dataValueTransformer);
55: return decorator;
56: }
57:
58: }
|