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