01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.storage.search;
11:
12: import java.util.*;
13: import org.mmbase.bridge.Field;
14: import org.mmbase.module.core.*;
15:
16: /**
17: * A <code>ResultBuilder</code> is a builder for
18: * {@link ResultNode ResultNodes}, that represent the results of executing
19: * an arbitrary search query.
20: * <p>
21: * This builder contains info on the fields of the resultnodes.
22: *
23: * @author Rob van Maris
24: * @version $Id: ResultBuilder.java,v 1.9 2007/02/24 21:57:50 nklasens Exp $
25: * @since MMBase-1.7
26: */
27: public class ResultBuilder extends VirtualBuilder {
28:
29: /**
30: * Creator.
31: * Creates new <code>ResultBuilder</code> instance, used to represent
32: * the results of executing a search query.
33: *
34: * @param mmbase MMBase instance.
35: * @param query The search query that defines the search.
36: */
37: public ResultBuilder(MMBase mmbase, SearchQuery query) {
38: super (mmbase);
39:
40: // Create fieldsByAlias map.
41: List<StepField> queryFields = query.getFields();
42: Iterator<StepField> i = queryFields.iterator();
43: while (i.hasNext()) {
44: StepField field = i.next();
45: String fieldAlias = field.getAlias();
46: if (fieldAlias == null) {
47: fieldAlias = field.getFieldName();
48: }
49: fields.put(fieldAlias, org.mmbase.core.util.Fields
50: .createField(fieldAlias, field.getType(), -1,
51: Field.STATE_VIRTUAL, null));
52: ;
53: }
54: }
55:
56: // javadoc is inherited
57: public MMObjectNode getNewNode(String owner) {
58: return new ResultNode(this);
59: }
60:
61: }
|