Getting method parameter names
Hello everyone,
I need to get parameter names of class methods. I checked the API for java.lang.reflect.Method, I found that it gives the types but not the names.
The following should print parameter names but it displays nulls for parameter descriptors. Any idea why ?
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.IntrospectionException;
import java.beans.MethodDescriptor;
public class pd
public static void main( String[] args ) throws IntrospectionException
BeanInfo info = Introspector.getBeanInfo( javax.swing.JLabel.class,javax.swing.JComponent.class );
System.out.println("MethodDescriptors:");
for ( MethodDescriptor md : info.getMethodDescriptors() )
System.out.println( md.getName() );
System.out.println("ParameterDescriptors:"+md.getParameterDescriptors());
}
Knowing the "true name" of the parameter gives one power over it?
I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
Not that I can offer much help if the reflection classes don't provide for it already.
Similar Messages
-
J2SE - Get Method Parameter Names
Hello Gurus,
I am trying to make a method in Java showing current running method's parameter name, the result will be some kind like below (showed in arrows):
FUNCTION1()::BEGIN
-TIME: 12-Jun-2013 05:39
FUNCTION1()::PARAMETERS
-PARAM01: val01 <!-------
-PARAM02: val02 <!-------
-PARAM03: val03 <!-------
FUNCTION1()::ERROR
-PATH: FUNCTION1()«FUNCTION2()«MAIN()
-MSG : '/ by zero'
FUNCTION1()::END
So I want to retrieve the parameter names and values automatically and dynamically using the function. So far, after googling, information that I get is by using spring framework:
private ParameterNameDiscoverer parameterNameDiscoverer;
Method m = ... <!------ what should I put here?
String[] names = parameterNameDiscoverer.getParameterNames(m).
In my idea, when we call a function, e.g: public String function1(String str, int i) {} and we put the code inside, we will get the function's parameter names which are "str" and "i", also with their current values.
Any help?Knowing the "true name" of the parameter gives one power over it?
I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
Not that I can offer much help if the reflection classes don't provide for it already. -
I'm using jwsdp-2.0 and jdk1.4
my question is
How can i change method parameter names that generated on WSDL file ?
when I'm trying to use (-g) option with javac command i have the same result.The parameter names aren't included in the bytecode.
Therefor it is impossible to get them.
Not with reflection, not with other tools.
I'm afraid, but you'll have to scan the source. -
How to get all parameter names along with their values in stored procedure which is being executed
Im using sql server 2012, is there any possible way to get all the parameters of a stored procedure along with the values passed to it.
I need these things to build a xml. I mean this should happen in the procedure which being executed and it should be common for all the procedures.
For example, let us suppose we have to procedures,
uspSave, @name='test' @age=20
uspDelete @id=2
now in uspSave procedure, i need to get @name, @age and the values 'test', 20 and in uspDelete, i should get @id with value 2.
For getting the column names, i tried this,
select parameter_name from information_schema.PARAMETERS where specific_name=OBJECT_NAME(@@procid)
now is it possible to loop through the result of above query and can we get the values.I think you need running SQL Server Profiler to capture this info even in SQL Server 2012.
Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/
Blog : MS SQL Development and Optimization
Blog : Large
scale of database and cleansing -
How to get the parameter name of a generic class?
Is it possible to get the name of generic class parameter type without having an instance of that type?
e.g.
class MyClass<T> {
public MyClass() {
// get the name here
}I need to get a string containing "Object" (or "java.lang.Object") if the class would be used like this:
MyClass<Object> mc = new MyClass<Object>() -
Query to get parameter name and value after ran the conccurent program
Hi All,
Query to get the parameter name and value for completed concurrent program using the request id. can any one help me in this regard.
Thanks,
Red.Red,
I have tried the same query and it works properly here.
I have submitted "Purge Signon Audit data" concurrent program with "Audit Date" parameter set to 01-06-2009, and here is the query output:
SQL> select request_id, phase_code, status_code,
argument_text, argument1
from fnd_concurrent_requests
where request_id = '739664';
REQUEST_ID P S ARGUMENT_TEXT ARGUMENT1
739664 C C 2009/06/01 00:00:00 2009/06/01 00:00:00Regards,
Hussein -
How to retrieve the parameter names from a JSP page ? Urgent Please
Hello,
Can anybody tell me how to retrieve the parameter names from the JSP
page. (without using getParameterNames() method.)
The problem with the getParameterNames() method is I get the Jumbled output.
I need it very badly
With regards
Ananth R
email:[email protected]
[email protected]Dear duffymo,
My primary intention is to convert the JSP form information into a XML file.
If I do not get the Parameter names in the correct order how can I maintain
tag order in XML file.
For ex: (JSP PAGE VIEW)
Name--
FirstName
MiddleName
LastName
Address--
Street1
Street2
City
Country
&so on
(XML File to be generated)
<Name>
<FirstName>Value</FirstName>
</Name>
<Address>
<street1>value</street1>
</Address>
& so on
If I use getParameterNames() to get all the parameter names(Which form the tag names in the XML file ) the Enumeration object it returns will not be in the same order as the text fields in JSP.From this I can not construct a meaningful XML file.
order means: Order of entry on the page, from top to bottom
That's it
Waiting for your responses -
How to get a parameter without name in JSP?
hi everyone, My question is how to get a parameter without name in JSP? I have two pages, 1.html and 2.jsp.
in 1.html, I embeds some Javascript codes in HTML contents like below ( changed < to ( , > to )):
function toSubWin( obj )
window.open('test.jsp?'+obj.firstChild.toString(),'sw');
(a onClick='toSubWin(this)'style="background:green")focus(/a)
How can I get the parameter in 2.jsp?
THANK YOU IN ADVANCE!!Does obj.firstChild.toString() evaluate to a "name=value" type of String ?
Or better what does obj.firstChild.toString(),'sw' evaluate to ? It has to end up in a name=value format, else its just gibberish appended to the url.
In the jsp, you have to obviously know the name to get the parameter. There's a getParameterNames() method which returns you a Collection of parameter names as Strings, you could probably use that to retrieve the param values.
Then there's a getParameterMap() method which returns an immutable Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.
However to what ends you employ them in a program which doesnt know its inputs is a different story.
cheers,
ram. -
Getting method parameters variable names
Hi,
I am trying to generate a list of methods, their parameter types as well as their localnames for a given class.
Example
TestClass
method1 (String name, int number)
method2 (Employee emp)
I checked the reflection API and it doesnt seem to give me the option to get the param name. Now its surely possible as some tools do it, like JBuilder whwne I type the method name, it give me the complete description.
Also javadocs provides the info. I wrote a subclassed doclet that provides the info, but the trouble is that I can run it from the command line using javadocs - doclet....
But how do I run it from code.
Any tips
Thanks in advance
Revonhi,
there you are wrong: You can't retrieve the parameter name from a class file because this information isn't saved (otherwise this would have been a feature in the reflection api). Tools like JBuilder use the source files and the comment tags to retrieve further information.
best regards, Michael -
How can I get parameter name?
ODatabase odb("test", "scott", "tiger");
OParameterCollection params = odb.GetParameters();
-------> and next how can I get parameter name?
I hope get stored procedure parameter names and settiing parameter Add just like below.
Plz tell me how can I get parameter name?
I'm Korean, and my english is poor. sorry : )
// add a parameter named 'DEPTNO'
params.Add("DEPTNO", 20, OPARAMETER_INVAR, OTYPE_NUMBER);
// add a parameter named 'EMPCURSOR'
params.Add("EMPCURSOR", "", OPARAMETER_OUTVAR, OTYPE_CURSOR);
//Execute the SQL statement
odb.ExecuteSQL("BEGIN Employee.GetEmpData (:DEPTNO, :EMPCURSOR); END;");ok, alright. I'm trying to write a program to easily test EJBs with a user giving input and directly seeing the results of function calls to the Bean. The user gives the JNDI name of the EJB, I instantiate the bean, give the user a list of function calls from the bean, and then he/she chooses the function they want to execute and give input of the parameters values they want. Everything is done remotely and at runtime, and the only real problem is that the user only sees "myFunc ( String )" and it would be confusing if there are several parameters of the same type.
Yes, I do realize there are other ways to test, I was developing this to try a new method that I thought could be beneficial to me. -
APT - getting declared variables and parameter names
Hi,
I would like start using APT, but if I am not mistaken, there are severe limitations what you can do with the tool. How is it possible to get the declared name of variables or parameters and methods from the apt tool?
@someAnnotation
public void someMethod(A para1, B para2) {...}I would need to get the name of the method and the name of the parameters to generate new sourcecode (AspectJ -Source), how is this possible? Without the names I cannot call the method from another place right?
Where can I find the planned features for APT? It is a pitty that the tool is in a way very powerful and in another so limitated because you cannot extract the sourcecode or names.
Regards,
KlaasWhat about getSimpleName? This method is defined on
declarations.You know, ParameterDeclaration is a Declaration ...
All of the declarations returned by
the mirror API are for elements that exist inside
classes, not inside methods.Huh? Parameters are an integral part of methods and methods are elements that exist inside classes (or types in general). What's your point?
The apt API does not expose any information about the
interiors of methods or constructors.Oh boy. For a ParameterDeclaration getSimpleName() will return the name of the parameter, e.g. suppose you are "scanning" a standard main method:public static void main(String[] args) {...}and you already have the ParameterDeclaration instance representing the sole parameter of the method, then getSimpleName() will return "args".
BTW - this has nothing to do with exposing interiors. Just try it. -
The %5BOut%5D gets Stuck to Parameter name in Additional Results
The in or out tag from a LV VI gets added to the parameter name
any method to remve it%5B = [
[In]
[Out] -
How to get the Text name to pass in the parameter header in save_text
Hi,
I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how to get the text name in order to pass the parameter header in save_text.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates and where is this value updated in the table so that i can link it thru the order no to get the link and pass it in the text_name.
can anyone help me out?
krishnanHi,
Your query is.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates
In above number
300 - Client
1000000092 - AUFPL - Routing number of operations in the order (You can fetch this from table HIVG)
00000001 - APLZL - General counter for order ( You can fetch this from table HIVG).
BR,
Vijay -
Method to get all File names in a directory
Hallo together,
has Java any method, to get the file names in a specific directory?
Regards,
Martin... or simply list() if you're interested in file names only.
-
It is possible to get giving parameter field name in function module
i have one question like below .
at main report .
call funciton Fm1
exporting
var1 = W_A
var2 = W_B
at function module i want to get giving parameter field name, in here value was "W_A" and "W_B" .
plz give me some hints or any advise .Only a hint:
If you have a fm with an unspecified parameter like
FUNCTION ZTESTBABLFM.
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(INPUT)
type-pools: sydes.
data: fieldinfo type SYDES_DESC.
describe field input into fieldinfo.
ENDFUNCTION.
you can get some information from DESCRIBE FIELD either using INTO as above or with other options as LENGTH, TYPE ...
Maybe you are looking for
-
Help needed! I cannot restore my iPhone 5, An unknown error occupied (1)
Help needed! I cannot restore my iPhone 5, An unknown error occupied (1)..
-
How can I include a MySQL table and records with the PUT of my Dreamweaver site?
I am using .php to validate a user code against one of four codes that I am providing to potential clients. They enter that code, along with a default user id and the appropriate page is then displayed for them. Everything is working fine on the de
-
how do you put html in flash? like...I have a code that uses html (javascript) and I want to put it in there. its a voting poll...ether way how do I do that? thanks
-
i keep getting this problem when i use safari on my iphone 4 and it happens on both wifi connections and 3G connections. i will be viewing a site example wikipedia, and then i will click on a link on the page to view more info on the topic and it wil
-
Table for the recorded result.Result automatically calculated using formula
Hi experts, I want to know where this results will be saved(table name) when we use formula in inspection plan.I have marked char.calc in control indicator and formula has been entered in inspection plan.While entering the result when i cli