get the code of a given method
Hi,
I work on java project and I have the task to get the code of a java method. For example we suppose that we have this method on the project :
public void action() {
Etat = Etats.MEDECIN_MARCHE;
sousEtat_Marche = Marche.RECHERCHE_VICTIME;
Ontologie.ordreExplorer oE = (Ontologie.ordreExplorer) objet;
NZone = oE.getNumZone();
etape = param.getParam().etape;
Finished = true;
}
And I just know the method name and the list of parameters so the result of my issue will be :
Etat = Etats.MEDECIN_MARCHE;
sousEtat_Marche = Marche.RECHERCHE_VICTIME;
Ontologie.ordreExplorer oE = (Ontologie.ordreExplorer) objet;
NZone = oE.getNumZone();
etape = param.getParam().etape;
Finished = true;
thank you
Re: get the code of a given method
So what seems to be the problem?
Where are you stuck?
Re: get the code of a given method
Hi jps,
I search a solution to retreive the contain of the method "action". we suppose that I don't know the implementation of the method I have just the method name and parameters.
Thank you
Re: get the code of a given method
Well we don't just write code to solve problems for people. If you need help, ask a question that doesn't ask someone to do the code for you.
If you plan to write the code, you must provide information on where the information is stored you must search, and all those icky details that makes solving the problem possible
Re: get the code of a given method
I don't search a complete solution just an idea if there is defined method as getCode(method)
I am searching and I found that it will be may be a parser for a java file that contains the asked method.
Re: get the code of a given method
Quote:
I don't know the implementation of the method I have just the method name and parameters.
Are you asking how to determine how some programmer implemented a method?
There can be many different ways to implement a method.
Do you have the class file? There are decompilers that will create a source file from a class file.
Re: get the code of a given method
@Norm:
I have the java files but I need in my application to retreive some information from the code of methods for examples the noun of the used ontologie in the method action, thus i need to parser the code and extract the noun "ordreExplorer"
Re: get the code of a given method
That sounds like you need an algorithm to read source code, parse it and extract the desired information. I've never seen one like that.
Re: get the code of a given method
Quote:
Originally Posted by
aroua_doudou
I don't search a complete solution just an idea if there is defined method as getCode(method)
If I understand what you want, I doubt there is code for that just available with a search. It does not sound like a common or difficult task.
Quote:
Originally Posted by
aroua_doudou
@Norm:
I have the java files but I need in my application to retreive some information from the code of methods for examples the noun of the used ontologie in the method action, thus i need to parser the code and extract the noun "ordreExplorer"
Quote:
Originally Posted by
aroua_doudou
I am searching and I found that it will be may be a parser for a java file that contains the asked method.
It sounds to me like you have the source code in the form of the class.java files, and you want to read them as text and parse the nouns(variable names?) and methods from the source code. Is that what you want?