This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes HELP: Suitable datastructure for classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

HELP: Suitable datastructure for classes

Fahd Shariff
Ranch Hand

Joined: Nov 22, 2002
Posts: 38
Hi,
Can anyone suggest a suitable datastructure to represent java classes?
I have information of a given class e.g what its name is, what methods it has, what
fields etc. I need to store this information in some way.
Should i just have something like this:
//a classstructure object which has a list of methods and fields and
whatever else there is...
class ClassStructure
{
String name ;
List methods ;
List fields ;
//the usual getter/setter methods
addMethod(MethodStructure m) ;
addField(FieldStructure f) ;
}
class MethodStructure
{
String name ;
List parameters ;
String body ;
//etc
}
I hope you understand what i am doing.
Is this the best way to represent a java class???
I need to do this so that i can carry out quick searches on source code. For example,
I want to be able to say something like: "Get me all the
methods whose names begin with "get*" and return a String". So the program would
return
getName(), getAddress() etc. I do not want to carry out a full text search.
Any comments would be appreciated


Fahd Shariff<br />"Let the code do the talking"
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Please do not cross post. Continue the conversation here.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
GeeCON Prague 2014
 
subject: HELP: Suitable datastructure for classes