KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > query > jqlc > QueryValueFetcher


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * QueryValueFetcher.java
26  *
27  * Created on March 15, 2002
28  * @author Daniel Tonn
29  */

30
31 package com.sun.jdo.spi.persistence.support.sqlstore.query.jqlc;
32
33 import java.util.ResourceBundle JavaDoc;
34
35 import com.sun.jdo.api.persistence.support.JDOFatalInternalException;
36 import com.sun.jdo.spi.persistence.support.sqlstore.ValueFetcher;
37 import com.sun.jdo.spi.persistence.utility.I18NHelper;
38
39 /**
40  * Class wrapping the actual query parameters to make them
41  * accessible through the ValueFetcher interface.
42  */

43 public class QueryValueFetcher implements ValueFetcher
44 {
45     /** I18N support */
46     protected final static ResourceBundle JavaDoc messages =
47         I18NHelper.loadBundle(QueryValueFetcher.class);
48
49     /** The actual parameter values. */
50     private Object JavaDoc[] parameters;
51     
52     /**
53      * Constructor.
54      * @param parameters the actual parameter values.
55      */

56     public QueryValueFetcher(Object JavaDoc[] parameters)
57     {
58         this.parameters = parameters;
59     }
60     
61     /**
62      * Returns the parameter value for the specified parameter index
63      * @param whichOne the parameter index
64      * @return the parameter value
65      */

66     public Object JavaDoc getValue(int whichOne)
67     {
68         if (parameters == null || whichOne >= parameters.length)
69         {
70             throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
71                 "jqlc.queryvaluefetcher.getvalue.invalidparam", //NOI18N
72
String.valueOf(whichOne),
73                 String.valueOf((parameters == null) ? 0 : parameters.length)));
74         }
75         return parameters[whichOne];
76     }
77 }
78
Popular Tags