01: /*
02: * Created on Dec 20, 2004
03: */
04: package net.sourceforge.orbroker;
05:
06: import java.util.HashMap;
07: import java.util.Map;
08:
09: /**
10: * @author Nils Kilden-Pedersen
11: */
12: class MapWith extends ValueType {
13:
14: private final ResultObjectDefinition resultObjectDef;
15: private Map aliasColumns;
16:
17: /**
18: * Constructor.
19: * @param type
20: * @param resultObjectDef
21: */
22: MapWith(ResultObjectDefinition resultObjectDef) {
23: super (resultObjectDef.getType());
24: this .resultObjectDef = resultObjectDef;
25: }
26:
27: void addAlias(String mappedColumn, String queryColumn) {
28: if (this .aliasColumns == null) {
29: this .aliasColumns = new HashMap();
30: }
31: this .aliasColumns.put(mappedColumn, queryColumn);
32: }
33:
34: /**
35: * @inheritDoc
36: * @see net.sourceforge.orbroker.ValueType#getValue(net.sourceforge.orbroker.ResultRow)
37: */
38: Object getValue(ResultRow row) throws BrokerException {
39: row.pushAliases(this .aliasColumns);
40: Object value = this.resultObjectDef.buildObject(row);
41: row.pullAliases();
42: return value;
43: }
44:
45: }
|