KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > common > ParamInfoWithPrimitives


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 package com.sun.enterprise.admin.common;
26
27
28 /**
29     A specialization of ParamInfo class that can handle both primitives and
30     Objects. With this class, callers can form signatures of any methods.
31     <p>
32     Note a limitation of this class: It is not possible to use this class to
33     call methods like <code> methodName(java.lang.Integer INTEGER, int integer)
34     </code>. i.e. to say that the methods which contain both primitives and
35     their object counterparts are not callable using this class.
36     The reason for this is that when specifying the value of a primitive
37     in Object array, one has to create an instance of Object equivalent(e.g.
38     int:java.lang.Integer, boolean:java.lang.Boolean and so on). It is not
39     possible in Java to have Object[] params = new Object[]{10}.
40     <p>
41     Note that the names of primitives in signature will be: "int", "char",
42     "float", "double", "byte", "short" and "long".
43  
44     @author Senthil Chidambaram
45     @version 1.0
46 */

47
48 public class ParamInfoWithPrimitives extends ParamInfo
49 {
50
51     public void initCoercionOptions()
52     {
53         mForcePrimitives = true;
54     }
55
56     /**
57      * Constructor takes the operationName, and an array of params object.
58      * This constructor calls the paramstoClassNames to set the signature
59      * of the params array object.
60      */

61
62
63     public ParamInfoWithPrimitives( String JavaDoc operationName, Object JavaDoc[] params )
64     {
65         super(operationName, params);
66     }
67
68
69     /**
70      * Constructor takes the operationName, and a single param Object.
71      * This constructor calls the ParamInfo array object constructor to
72      * set the signature for the param object.
73      */

74
75
76     public ParamInfoWithPrimitives( String JavaDoc operationName, Object JavaDoc param )
77     {
78         this(operationName, new Object JavaDoc[]{param} );
79     }
80
81
82     /**
83      * This constructor takes an operationName, and two param Objects.
84      * Then it calls the ParamInfo array object constructor to set the
85      * signature for the parameters.
86      */

87
88
89     public ParamInfoWithPrimitives( String JavaDoc operationName, Object JavaDoc param1, Object JavaDoc param2 )
90     {
91         this(operationName, new Object JavaDoc[]{param1, param2});
92     }
93
94
95     /**
96      * This constructor takes an operationName, and three param Objects.
97      * Then it calls the ParamInfo array object constructor like other
98      * constructors to set the signature for the parameters.
99      */

100
101
102     public ParamInfoWithPrimitives( String JavaDoc operationName, Object JavaDoc param1,
103             Object JavaDoc param2, Object JavaDoc param3 )
104     {
105
106         this(operationName, new Object JavaDoc[]{param1, param2,
107                 param3});
108     }
109
110
111     /**
112      * This constructor takes an operationName, and four param objects.
113      * Then it calls the array object constructor to set the signature
114      * for the parameters.
115      */

116
117
118     public ParamInfoWithPrimitives( String JavaDoc operationName, Object JavaDoc param1,
119             Object JavaDoc param2, Object JavaDoc param3, Object JavaDoc param4 )
120     {
121
122         this(operationName, new Object JavaDoc[]{param1, param2,
123                 param3, param4});
124     }
125
126 }
127
Popular Tags