473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Depth of Inheritance

I need a java program to find the Depth of Inheritance of a java program source code is given as input file :)
Can any1 help me out with this
If so:) Thanks in Advance for Helping
Jun 29 '09 #1
17 4006
dmjpro
2,476 2GB
@chrisjohn2009
Are you talking about level of inheritance?
Then no need to have the source file, instead you need Class files of all the dependent classes.
Now have a look at Class.
Then look at Class.getSuperClass.
Jun 29 '09 #2
Sir,
could u help me out by explaining me a little bit in detail pl...
Jul 1 '09 #3
Sir,
i'm doing a Phd work on quality metrics . So basically i'm developing a tool for just checking out the number of classes,elements,inheritances & level of inheritance in a given source code like of morilla firefox ,rhino...

could me help me out with this sir... pl
Thanks in Advance for reply....& Guidance
Jul 1 '09 #4
JosAH
11,448 Expert 8TB
@chrisjohn2009
Have you read the API documentation for the Class class? Have a look at the very first article in this group; it contains a link to the API download site (from Sun). Download the API documentation and read it.

kind regards,

Jos
Jul 1 '09 #5
Thank you sir :)
i will read the documentation and if there is any sort of doubt i ll ask you sir...
Thank you for ur guidence sir :)


with Regards,
john
Jul 1 '09 #6
JosAH
11,448 Expert 8TB
@chrisjohn2009
You're welcome of course; that API documentation is a must read and you should have it stored on your hard drive; without it you're in the dark. Look at the Object class first; it's the 'mother of all classes'. It has a getClass() method that gives you a Class object; it describes the class the particular object is instantiated from. Next look at the API documentation for the Class class; it can return another Class object that represents the super class of the current class if any; otherwise it returns null. That is the building block for what you want to calculate.

kind regards,

Jos
Jul 1 '09 #7
Thank you sir :)
i will concentrate on it
Jul 1 '09 #8
i need to find the number of files & folders available in a particular folder...
i need to develop a program using java...
can any1 help me out with this using some code... pl
thanks for ur help in advance..

In regards,
john
Jul 9 '09 #9
JosAH
11,448 Expert 8TB
@chrisjohn2009
There's hardly any code to write because the File class does about all; have a look at the list() or listFiles() methods in that class.

kind regards,

Jos
Jul 9 '09 #10
dmjpro
2,476 2GB
@chrisjohn2009
First of all this is a different question, no relation with this thread.
Anyway for your solution, see File.listFiles.
Jul 10 '09 #11
Why do programmers are not comfortable with command line arguments or y they dont opt this techinique???
Jul 18 '09 #12
JosAH
11,448 Expert 8TB
@chrisjohn2009
Programmers who aren't comfortable with shells etc. are just junior programmers, too much influenced by a windows, graphical environment. Granted, the shell/cmd in Microsoft Windows isn't worth much but still ...

kind regards,

Jos
Jul 18 '09 #13
Thanks sir :)

Kind Regards,
john
Jul 19 '09 #14
Expand|Select|Wrap|Line Numbers
  1. public class ListFilesSubs {
  2.  
  3.  
  4.     private static void doSimpleFileListing(String dirName) {
  5.  
  6.         System.out.println();
  7.         System.out.println("Simple file listing...");
  8.         System.out.println("----------------------");
  9.  
  10.         File dir = new File(dirName);
  11.  
  12.         String[] children = dir.list();
  13.  
  14.         printFiles(children, dirName);
  15.  
  16.     }
  17.  
This is a sample code taken from the internet .
Could you help me with this. i get an error as
Error with new_dir
Either directory does not exist or is not a directory
i need to run this program .Pl do help me with this.
Thanks for ur help in advance :)

Kind Regards,
john
Jul 22 '09 #15
Expand|Select|Wrap|Line Numbers
  1. import java.io.File;
  2. import java.io.FilenameFilter;
  3. import java.io.FileFilter;
  4.  
  5.  
  6. public class ListFilesSubs {
  7.  
  8.  
  9.     private static void doSimpleFileListing(String dirName) {
  10.  
  11.         System.out.println();
  12.         System.out.println("Simple file listing...");
  13.         System.out.println("----------------------");
  14.  
  15.         File dir = new File(dirName);
  16.  
  17.         String[] children = dir.list();
  18.  
  19.         printFiles(children, dirName);
  20.  
  21.     }
  22.  
  23.  
  24.     /**
  25.      * Used to list the files / subdirectories in a given directory and also
  26.      * provide a filter class.
  27.      * @param dir Directory to start listing from
  28.      * @param ff  A string that can be used to filter out files from the
  29.      *            returned list of files. In this example, the String
  30.      *            values is used to only return those values that start
  31.      *            with the given String.
  32.      */
  33.     private static void doFileFilterListing(String dirName, String ff) {
  34.  
  35.         System.out.println("Filter file listing...");
  36.         System.out.println("----------------------");
  37.  
  38.         final String fileFilter = ff;
  39.  
  40.         File dir = new File(dirName);
  41.         FilenameFilter filter  = null;
  42.  
  43.         if (fileFilter != null) {
  44.  
  45.             // It is also possible to filter the list of returned files.
  46.             // This example uses the passed in String value (if any) to only
  47.             // list those files that start with the given String.
  48.             filter = new FilenameFilter() {
  49.                 public boolean accept(File dir, String name) {
  50.                      return name.startsWith(fileFilter);
  51.                 }
  52.             };
  53.         }
  54.  
  55.         String[] children = dir.list(filter);
  56.  
  57.         printFiles(children, dirName);
  58.  
  59.     }
  60.  
  61.  
  62.     /**
  63.      * Used to list the files / subdirectories in a given directory and also
  64.      * provide a filter class that only lists the directories.
  65.      * @param dir Directory to start listing from
  66.      */
  67.     private static void doFileFilterDirectoryListing(String dirName) {
  68.  
  69.         System.out.println("Filter Directory listing...");
  70.         System.out.println("---------------------------");
  71.  
  72.         File dir = new File(dirName);
  73.  
  74.         // The list of files can also be retrieved as File objects. In this
  75.         // case, we are just listing all files in the directory. For the sake
  76.         // of this example, we will not print them out here.
  77.         File[] files = (new File(dirName)).listFiles();
  78.  
  79.         // This filter only returns directories
  80.         FileFilter dirFilter = new FileFilter() {
  81.             public boolean accept(File dir) {
  82.                 return dir.isDirectory();
  83.             }
  84.         };
  85.  
  86.         files = dir.listFiles(dirFilter);
  87.  
  88.         for (int i=0; i<files.length; i++) {
  89.             System.out.println("[D] : " + files[i]);
  90.         }
  91.         System.out.println();
  92.  
  93.  
  94.     }
  95.  
  96.  
  97.     /**
  98.      * Utility method to print the list of files to the terminal
  99.      * @param children A String array of the file names to print out
  100.      * @param dirName  The given directory to start the listing at.
  101.      */
  102.     private static void printFiles(String[] children, String dirName) {
  103.  
  104.         if (children == null) {
  105.             System.out.println("Error with " + dirName);
  106.             System.out.println("Either directory does not exist or is not a directory");
  107.         } else {
  108.             for (int i=0; i<children.length; i++) {
  109.                 // Get filename of file or directory
  110.                 String filename = children[i];
  111.                 if ((new File(dirName + File.separatorChar + filename)).isDirectory()) {
  112.                     System.out.print("[D] : ");
  113.                 } else {
  114.                     System.out.print("[F] : ");
  115.                 }
  116.                 System.out.println(dirName + File.separatorChar + filename);
  117.             }
  118.         }
  119.         System.out.println();
  120.  
  121.     }
  122.  
  123.     /**
  124.      * Sole entry point to the class and application.
  125.      * @param args Array of String arguments.
  126.      */
  127.     public static void main(String[] args) {
  128.  
  129.         // Call the simple file listing method
  130.         doSimpleFileListing("new_dir");
  131.  
  132.         // Now do the file listing but pass in a String to filter the file list
  133.         if (args.length == 0) {
  134.             doFileFilterListing("new_dir", null);
  135.         } else {
  136.             doFileFilterListing("new_dir", args[0]);
  137.         }
  138.  
  139.         // Now do another example that only prints out the directories
  140.         doFileFilterDirectoryListing("new_dir");
  141.  
  142.     }
  143. }
Jul 22 '09 #16
I need help as soon as possible .
Kind regards.
john
Jul 22 '09 #17
JosAH
11,448 Expert 8TB
@chrisjohn2009
Don't rush us; first copy/paste the actual error message you get; don't make us guess. Then tell us what you expected and what the actual output of your program was. Your problem isn't more urgent to us than the other problems posted here.

kind regards,

Jos
Jul 22 '09 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hoagie | last post by:
Hello all. Is it possible to set a new depth of field (View.setBackClipDistance) when using a SimpleUniverse? I've been unable to learn a way to extract the View being used, in order to set...
4
by: Ingo Nolden | last post by:
Hi, I want to write a template class that holds another class that uses the same template. This recursion should stop after a predefined number. I think it's either impossible or easy, but I...
2
by: Raed Sawalha | last post by:
I have following XML: How can I find the depth of XML? in other word max level of the XML <Root> ----- level 0 <Name>----- level 1 <FirstName>name</FirstName> ---- level 2...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
2
by: Onwuka Emeka | last post by:
is there a way to reduce or modify the color depth of a jpeg image, i currently need to programatically change the color depth of a jpeg image from 24bits to 8bits. any help would be appreciated
8
by: darrel | last post by:
I've decided that instead of doing an XSLT transformation on a file, I might be better off bringing it in as a dataset and having a bit more direct control over it at that point. The question I...
6
by: datamodel | last post by:
Hello I have an XML tree of which you can see a mini-version here: http://paste.uni.cc/11838 (the tree is actually over 30,000 levels deep) How do I count the depth of a given...
13
by: softwaredoug | last post by:
I can't see to easily find this on google or in a newsgroup Is there a standard function/macro/whatever you can call and determine the distance in a C program how deep one is in the C call stack...
2
by: Gentr1 | last post by:
Hi everybody! I am presently working on a Genetic Programming API in python. I have a bit of a problem at the moment... For some specific reasons, I am using nested lists data structure to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.