lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmarsch...@apache.org
Subject cvs commit: jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/util ClassInfo.java
Date Tue, 22 Oct 2002 15:36:05 GMT
cmarschner    2002/10/22 08:36:05

  Modified:    contributions/webcrawler-LARM/src/de/lanlab/larm/util
                        ClassInfo.java
  Log:
  
  
  Revision  Changes    Path
  1.3       +98 -93    jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/util/ClassInfo.java
  
  Index: ClassInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/webcrawler-LARM/src/de/lanlab/larm/util/ClassInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassInfo.java	22 May 2002 23:09:19 -0000	1.2
  +++ ClassInfo.java	22 Oct 2002 15:36:05 -0000	1.3
  @@ -83,127 +83,132 @@
           try
           {
               Class cls = Class.forName(name);
  -            name = cls.getName();
  -            String pkg =  getPackageName(name);
  -            String clss = getClassName(name);
  -
  -            StringWriter importsWriter = new StringWriter();
  -            PrintWriter imports = new PrintWriter(importsWriter);
  -            StringWriter outWriter = new StringWriter();
  -            PrintWriter out = new PrintWriter(outWriter);
  +            classInfo(derivedName, cls);
  +        }
  +        catch(Throwable t)
  +        {
  +            t.printStackTrace();
  +        }
  +    }
   
  -            TreeSet importClasses = new TreeSet();
  -            importClasses.add(getImportStatement(name));
  +    public static void classInfo(String derivedName, Class cls) throws SecurityException
  +    {
  +        String name = cls.getName();
  +        String pkg =  getPackageName(name);
  +        String clss = getClassName(name);
  +
  +        StringWriter importsWriter = new StringWriter();
  +        PrintWriter imports = new PrintWriter(importsWriter);
  +        StringWriter outWriter = new StringWriter();
  +        PrintWriter out = new PrintWriter(outWriter);
   
  -            out.println("/**\n * (class description here)\n */\npublic class " + derivedName
+ " " + (cls.isInterface() ? "implements " : "extends ") + clss + "\n{");
  +        TreeSet importClasses = new TreeSet();
  +        importClasses.add(getImportStatement(name));
   
  -            Method[] m = cls.getMethods();
  -            for(int i= 0; i< m.length; i++)
  +        out.println("/**\n * (class description here)\n */\npublic class " + derivedName
+ " " + (cls.isInterface() ? "implements " : "extends ") + clss + "\n{");
  +
  +        Method[] m = cls.getMethods();
  +        for(int i= 0; i< m.length; i++)
  +        {
  +            Method thism = m[i];
  +            if((thism.getModifiers() & Modifier.PRIVATE) == 0 && ((thism.getModifiers()
& Modifier.FINAL) == 0)
  +               && (thism.getDeclaringClass().getName() != "java.lang.Object"))
               {
  -                Method thism = m[i];
  -                if((thism.getModifiers() & Modifier.PRIVATE) == 0 && ((thism.getModifiers()
& Modifier.FINAL) == 0)
  -                   && (thism.getDeclaringClass().getName() != "java.lang.Object"))
  -                {
  -                    out.println("    /**");
  -                    out.println("     * (method description here)");
  -                    out.println("     * defined in " + thism.getDeclaringClass().getName());
  +                out.println("    /**");
  +                out.println("     * (method description here)");
  +                out.println("     * defined in " + thism.getDeclaringClass().getName());
   
  -                    Class[] parameters = thism.getParameterTypes();
  -                    for(int j = 0; j < parameters.length; j ++)
  +                Class[] parameters = thism.getParameterTypes();
  +                for(int j = 0; j < parameters.length; j ++)
  +                {
  +                    if(getPackageName(parameters[j].getName()) != "")
                       {
  -                        if(getPackageName(parameters[j].getName()) != "")
  -                        {
  -                            importClasses.add(getImportStatement(parameters[j].getName()));
  -                        }
  -                        out.println("     * @param p" + j + " (parameter description here)");
  +                        importClasses.add(getImportStatement(parameters[j].getName()));
                       }
  +                    out.println("     * @param p" + j + " (parameter description here)");
  +                }
   
  -                    if(thism.getReturnType().getName() != "void")
  +                if(thism.getReturnType().getName() != "void")
  +                {
  +                    String returnPackage = getPackageName(thism.getReturnType().getName());
  +                    if(returnPackage != "")
                       {
  -                        String returnPackage = getPackageName(thism.getReturnType().getName());
  -                        if(returnPackage != "")
  -                        {
  -                            importClasses.add(getImportStatement(thism.getReturnType().getName()));
  -                        }
  -                        out.println("     * @return (return value description here)");
  +                        importClasses.add(getImportStatement(thism.getReturnType().getName()));
                       }
  +                    out.println("     * @return (return value description here)");
  +                }
   
  -                    out.println("     */");
  +                out.println("     */");
   
  -                    out.print("    " + getModifierString(thism.getModifiers()) + getClassName(thism.getReturnType().getName())
+ " ");
  -                    out.print(thism.getName() + "(");
  +                out.print("    " + getModifierString(thism.getModifiers()) + getClassName(thism.getReturnType().getName())
+ " ");
  +                out.print(thism.getName() + "(");
   
  -                    for(int j = 0; j < parameters.length; j ++)
  +                for(int j = 0; j < parameters.length; j ++)
  +                {
  +                    if(j>0)
                       {
  -                        if(j>0)
  -                        {
  -                            out.print(", ");
  -                        }
  -                        out.print(getClassName(parameters[j].getName()) + " p" + j);
  +                        out.print(", ");
                       }
  -                    out.print(")");
  -                    Class[] exceptions = thism.getExceptionTypes();
  +                    out.print(getClassName(parameters[j].getName()) + " p" + j);
  +                }
  +                out.print(")");
  +                Class[] exceptions = thism.getExceptionTypes();
   
  -                    if (exceptions.length > 0)
  -                    {
  -                       out.print(" throws ");
  -                    }
  +                if (exceptions.length > 0)
  +                {
  +                   out.print(" throws ");
  +                }
   
  -                    for(int k = 0; k < exceptions.length; k++)
  -                    {
  -                       if(k > 0)
  -                       {
  -                           out.print(", ");
  -                       }
  -                       String exCompleteName = exceptions[k].getName();
  -                       String exName = getClassName(exCompleteName);
  -                       importClasses.add(getImportStatement(exCompleteName));
  +                for(int k = 0; k < exceptions.length; k++)
  +                {
  +                   if(k > 0)
  +                   {
  +                       out.print(", ");
  +                   }
  +                   String exCompleteName = exceptions[k].getName();
  +                   String exName = getClassName(exCompleteName);
  +                   importClasses.add(getImportStatement(exCompleteName));
   
  -                       out.print(exName);
  -                    }
  -                    out.print("\n" +
  -                              "    {\n" +
  -                              "        /**@todo: Implement this " + thism.getName() + "()
method */\n" +
  -                              "        throw new UnsupportedOperationException(\"Method
" + thism.getName() + "() not yet implemented.\");\n" +
  -                              "    }\n\n");
  +                   out.print(exName);
  +                }
  +                out.print("\n" +
  +                          "    {\n" +
  +                          "        /**@todo: Implement this " + thism.getName() + "() method
*/\n" +
  +                          "        throw new UnsupportedOperationException(\"Method " +
thism.getName() + "() not yet implemented.\");\n" +
  +                          "    }\n\n");
   
   
  -                }
               }
  -            out.println("}");
  +        }
  +        out.println("}");
   
  -            Iterator importIterator = importClasses.iterator();
  -            while(importIterator.hasNext())
  +        Iterator importIterator = importClasses.iterator();
  +        while(importIterator.hasNext())
  +        {
  +            String importName = (String)importIterator.next();
  +            if(!importName.startsWith("java.lang"))
               {
  -                String importName = (String)importIterator.next();
  -                if(!importName.startsWith("java.lang"))
  -                {
  -                    imports.println("import " + importName + ";");
  -                }
  +                imports.println("import " + importName + ";");
               }
  +        }
   
  -            out.flush();
  -            imports.flush();
  +        out.flush();
  +        imports.flush();
   
  -            if(getPackageName(derivedName) != "")
  -            {
  -                System.out.println("package " + getPackageName(derivedName) + ";\n");
  -            }
  -            System.out.println( "/**\n" +
  -                                " * Title:        \n" +
  -                                " * Description:\n" +
  -                                " * Copyright:    Copyright (c)\n" +
  -                                " * Company:\n" +
  -                                " * @author\n" +
  -                                " * @version 1.0\n" +
  -                                " */\n");
  -            System.out.println(importsWriter.getBuffer());
  -            System.out.print(outWriter.getBuffer());
  -        }
  -        catch(Throwable t)
  +        if(getPackageName(derivedName) != "")
           {
  -            t.printStackTrace();
  +            System.out.println("package " + getPackageName(derivedName) + ";\n");
           }
  +        System.out.println( "/**\n" +
  +                            " * Title:        \n" +
  +                            " * Description:\n" +
  +                            " * Copyright:    Copyright (c)\n" +
  +                            " * Company:\n" +
  +                            " * @author\n" +
  +                            " * @version 1.0\n" +
  +                            " */\n");
  +        System.out.println(importsWriter.getBuffer());
  +        System.out.print(outWriter.getBuffer());
       }
   
       public static String getPackageName(String className)
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message