Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
    Bookmark Topic Watch Topic
  • New Topic

HELP: Suitable datastructure for classes

 
Fahd Shariff
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross post. Continue the conversation here.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!