KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > queryframework > SQLResultSetMapping


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.queryframework;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 import oracle.toplink.essentials.internal.localization.ExceptionLocalization;
29
30 /**
31  * <p><b>Purpose</b>:
32  * Concrete class to represent the SQLResultSetMapping structure as defined by
33  * the EJB 3.0 Persistence specification. This class is used by the
34  * ResultSetMappingQuery and is a component of the TopLink Project
35  *
36  * @see oracle.toplink.essentials.sessions.Project
37  * @author Gordon Yorke
38  * @since TopLink Java Essentials
39  */

40
41 public class SQLResultSetMapping {
42     /** Stores the name of this SQLResultSetMapping. This name is unique within
43      * The project.
44      */

45     protected String JavaDoc name;
46     
47     /** Stores the list of SQLResult in the order they were
48      * added to the Mapping
49      */

50     protected List JavaDoc results;
51     
52    
53     public SQLResultSetMapping(String JavaDoc name){
54         this.name = name;
55         if (this.name == null){
56             throw new IllegalArgumentException JavaDoc(ExceptionLocalization.buildMessage("null_value_in_sqlresultsetmapping"));
57         }
58     }
59
60     /**
61      * INTERNAL:
62      * Convert all the class-name-based settings in this SQLResultSetMapping to actual class-based
63      * settings. This method is used when converting a project that has been built
64      * with class names to a project with classes.
65      * @param classLoader
66      */

67     public void convertClassNamesToClasses(ClassLoader JavaDoc classLoader){
68         Iterator JavaDoc iterator = getResults().iterator();
69         while (iterator.hasNext()){
70             ((SQLResult)iterator.next()).convertClassNamesToClasses(classLoader);
71         }
72     };
73
74     public String JavaDoc getName(){
75         return this.name;
76     }
77     
78     public void addResult(SQLResult result){
79         if (result == null){
80             return;
81         }
82         getResults().add(result);
83     }
84     
85     /**
86      * Accessor for the internally stored list of ColumnResult. Calling this
87      * method will result in a collection being created to store the ColumnResult
88      */

89     public List JavaDoc getResults(){
90         if (this.results == null){
91             this.results = new ArrayList JavaDoc();
92         }
93         return this.results;
94     }
95
96 }
97
Popular Tags