KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > query > SQLResultSetMapping


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19 package org.apache.cayenne.query;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Collections JavaDoc;
23 import java.util.List JavaDoc;
24
25 /**
26  * A metadata object that defines how a DataRow can be converted to result objects. This
27  * object provides mapping in a JPA-compilant manner, i.e. the DataRow is mapped either to
28  * a single Object or an Object[]. Each object (single result object or an array element
29  * object) can be a scalar or a Persistent object.
30  *
31  * @since 3.0
32  * @author Andrus Adamchik
33  */

34 // TODO: andrus, 6/22/2007 - support entity results mapping.
35
public class SQLResultSetMapping {
36
37     protected String JavaDoc name;
38     protected List JavaDoc columnResults;
39
40     public SQLResultSetMapping() {
41
42     }
43
44     public SQLResultSetMapping(String JavaDoc name) {
45         this.name = name;
46     }
47
48     public String JavaDoc getName() {
49         return name;
50     }
51
52     public void setName(String JavaDoc name) {
53         this.name = name;
54     }
55
56     /**
57      * Returns a collection of mapped columns.
58      */

59     public List JavaDoc getColumnResults() {
60         return columnResults != null ? columnResults : Collections.EMPTY_LIST;
61     }
62
63     /**
64      * Adds a result set column name to the mapping.
65      */

66     public void addColumnResult(String JavaDoc column) {
67         if (columnResults == null) {
68             columnResults = new ArrayList JavaDoc(3);
69         }
70
71         columnResults.add(column);
72     }
73 }
74
Popular Tags