Leon Messerschmidt wrote:
> 
> Hi
> 
> I tried to compile NewGenerateMapBuilderTask.java but I got 2 errors:
> 
> line 409: No variable sperator defined in class java.io.File.
>         return p.replace('.', File.sperator.charAt(0) ) + s;
> 
> line 409: Undefined variable: s
>         return p.replace('.', File.sperator.charAt(0) ) + s;
> 
> The first should probably read "File.separator", but I can't understand the
> second.  Changing s to "s" does not make any sense and there is no s
> variable that provides an obvious solution.  Could you maybe help me with
> this error?
> 
> I'm very interested in a working copy of a MapBuilder so I would be willing
> to do some work here.  I haven't studied the Peer model in detail yet so my
> knowledge may be a bit behind, but I might be of some use :-)

Hmm, looks a bit fishy to me too Leon.  Here's a patch.

This patch renames the getPackages() method--which is perhaps misnamed
as it only returns *one* package name, the name of the package for which
the map is being generated--to getPackage().  It removes one extraneous
line of code from the getPackageAsPath() method, and hopefully corrects
the crud which was causing the compiler errors.  It also adds JavaDoc to
that method.  I changed the private member "packages" to "packageName". 
Also, note the spots marked HELP where some paths that are concatenated
together may not have file separators.  Thoughts on these changes?


Index: NewGenerateMapBuilderTask.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/examples/NewGenerateMapBuilderTask.java,v
retrieving revision 1.1
diff -u -u -r1.1 NewGenerateMapBuilderTask.java
--- NewGenerateMapBuilderTask.java      2000/07/02 02:12:39     1.1
+++ NewGenerateMapBuilderTask.java      2000/07/04 20:43:40
@@ -123,7 +123,7 @@
     /** The SQL file to use */
     private static String sqlfile = "";
     /** The package name */
-    private static String packages = "";
+    private static String packageName = "";
     /** The class extended */
     private static String extend = "";
     /** The class prefix used */
@@ -190,13 +190,13 @@
        * Get the value of package.
        * @return Value of package.
        */
-    public String getPackages() {return packages;}
+    public String getPackage() {return packageName;}
 
     /**
        * Set the value of package.
        * @param v  Value to assign to package.
        */
-    public void setPackages(String  v) {this.packages = v;}
+    public void setPackage(String  v) {this.packageName = v;}
             
     /**
        * Get the value of sqlfile.
@@ -260,6 +260,7 @@
         for (int i=0; i<tMaps.length; i++ )
         {
             TableMap tmap = tMaps[i];
+            // HELP: May need separator?
             String pth = rootdir + getPackageAsPath();
             System.out.println("Parsed path..." + pth);
             
@@ -401,12 +402,13 @@
         return firstLetter + restLetters;
     }
     /**
-     * Make directories for packages
+     * Turn the package name into an OS-specific directory name.
+     *
+     * @return The package name as a path name.
      */
     private String getPackageAsPath()
     {
-        String p = getPackages();
-        return p.replace('.', File.sperator.charAt(0) ) + s;
+        return getPackage().replace( '.', File.separator.charAt(0) );
     }
     
     /**
@@ -421,16 +423,13 @@
             String shortTableName = removeUnderScores(realTableName);
             String className = shortTableName + suffix;
             
-           
-
+            // HELP: May need separators?
             String fullpath = rootdir + getPackageAsPath() +  "map/" +
className + ".java";
             
-            
-            
             System.out.println ( "Generating " + fullpath + "..." );
    
             outFile = new PrintWriter(new FileWriter( fullpath ),true);
-            outFile.println( "package " + getPackages() + ";" );
+            outFile.println( "package " + getPackage() + ";" );
             outFile.println( "" );
             writeLicense( outFile );
             outFile.println( "" );
@@ -442,7 +441,7 @@
             outFile.println( "public class " + className + getExtend()
);
             outFile.println( "{" );
             outFile.println( "    /** the name of this class */" );
-            outFile.println( "    public static final String CLASS_NAME
= \"" + getPackages() + "." + className + "\";");
+            outFile.println( "    public static final String CLASS_NAME
= \"" + getPackage() + "." + className + "\";");
             outFile.println( "" );
             outFile.println( "    /** " + realTableName + " */");
             outFile.println( "    public static String getTable( )" );
@@ -529,7 +528,7 @@
         String tableClassname = removeUnderScores(realTableName); //
FooBar
         String peerclassName = tableClassname + "Peer"; // FooBarPeer
         String mapclassName = tableClassname + "MapBuilder"; //
FooBarMapBuilder
-        String subPackage = getPackages() + ".peer"; //
org.apache.turbine.peer
+        String subPackage = getPackage() + ".peer"; //
org.apache.turbine.peer
         String primaryKey = "?";
         PrintWriter outFile = null;
 
@@ -544,7 +543,7 @@
             outFile.println( imports1 );
             outFile.println( imports2 );
             outFile.println( imports3 );
-            outFile.println( "import " + getPackages() + ".*;" ); //
import the package with the DO
+            outFile.println( "import " + getPackage() + ".*;" ); //
import the package with the DO
             outFile.println( "" );
             outFile.println ("/** This class was autogenerated by
GenerateMapBuilder on: " + new Date().toString() + " */");
             outFile.println( "public class " + peerclassName + "
extends BasePeer" );
@@ -650,7 +649,7 @@
     {
         String realTableName = tmap.getName(); // Includes  Suffix  -
TURBINE_FOOBAR
         String tableClassname = removeUnderScores(realTableName); //
FooBar
-        String subPackage = getPackages(); // org.apache.turbine
+        String subPackage = getPackage(); // org.apache.turbine
         PrintWriter outFile = null;
         
         String fullpath = rootdir + getPackageAsPath() + 
tableClassname + ".java";
@@ -765,7 +764,7 @@
         gm.setRootdir("/home/dave/tmp/");
        
gm.setSqlfile("/home/dave/turbine/dataobjectbuilder/src/test.sql");
        
gm.setLicenseFile("/home/dave/turbine/dataobjectbuilder/src/codeheader.txt");
-        gm.setPackages("org.test");
+        gm.setPackage("org.test");
         gm.setExtend("MapBuilder");
         gm.setMapname("TestMap");
         gm.setSuffix("MapBuilder");

-- 

Daniel Rall <[EMAIL PROTECTED]>


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to