You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2004/05/05 18:39:05 UTC

cvs commit: db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb DBCatalog.java DBColumn.java DBFKRelation.java DBMeta.java DBSchema.java DBTable.java IdGeneratorSingleton.java Main.java MetadataNodeInterface.java Namer.java README Utilities.java

arminw      2004/05/05 09:39:05

  Added:       src/tools/org/apache/ojb/tools/mapping/reversedb
                        DBCatalog.java DBColumn.java DBFKRelation.java
                        DBMeta.java DBSchema.java DBTable.java
                        IdGeneratorSingleton.java Main.java
                        MetadataNodeInterface.java Namer.java README
                        Utilities.java
  Log:
  fix fault
  wrong package structure used:
  org.apache.ojb.tools.reversdb
  org.apache.ojb.tools.reversdb2
  
  instead of
  org.apache.ojb.tools.mapping.reversdb
  org.apache.ojb.tools.mapping.reversdb2
  
  Revision  Changes    Path
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBCatalog.java
  
  Index: DBCatalog.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.Iterator;
  import javax.swing.tree.TreeNode;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
   * @version $Id: DBCatalog.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class DBCatalog implements MetadataNodeInterface, TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    private DBMeta parsedMetaData;
    private java.sql.DatabaseMetaData dbMeta;
    
    private boolean enabled = true;
    
    private String strCatalogName;
    private java.util.TreeMap hmSchemas = new java.util.TreeMap();
    /** Creates a new instance of DBCatalog */
    public DBCatalog(java.sql.DatabaseMetaData pdbMeta, DBMeta paMeta,
    String pstrCatalogName)
    {
      this.dbMeta = pdbMeta;
      this.parsedMetaData = paMeta;
      this.strCatalogName = pstrCatalogName;
    }
    
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }
    
    public DBSchema getSchema(String strSchemaName)
    {
      return (DBSchema)this.hmSchemas.get(strSchemaName);
    }
    
    public void putSchema(String key, DBSchema schema)
    {
      this.hmSchemas.put(key, schema);
    }
    
    public String getCatalogName()
    {
      return this.strCatalogName;
    }
    
    public DBMeta getDBMeta()
    {
      return parsedMetaData;
    }
    
    public boolean isTreeEnabled()
    {
      return getDBMeta().isEnabled() && this.isEnabled();
    }
    
    public void generateReferences()
    throws java.sql.SQLException
    {
      // Set the catalog name of the connection before accessing the metadata object
      dbMeta.getConnection().setCatalog(this.getCatalogName());
      Iterator it = this.hmSchemas.values().iterator();
      while (it.hasNext())
      {
        ((DBSchema)it.next()).generateReferences();
      }
    }
    
    public void read()
    throws java.sql.SQLException
    {
      // Set the catalog name of the connection before accessing the metadata object
      java.sql.ResultSet rs = dbMeta.getSchemas();
      int count = 0;
      while (rs.next())
      {
        count++;
        String strSchemaName = rs.getString("TABLE_SCHEM");
        // Fix for IBM Informix JDBC 2.21JC2; Schema is padded with spaces, needs to be trimmed
        strSchemaName = strSchemaName.trim();
        try
        {
          if (new org.apache.regexp.RE(this.getDBMeta().getSchemaPattern()).match(strSchemaName))
          {
            this.hmSchemas.put(strSchemaName, new DBSchema(dbMeta, this, strSchemaName));
          }
        }
        catch (org.apache.regexp.RESyntaxException ex)
        {
          // This expception should be reported, but this does not fit currently.
          ex.printStackTrace();
        }
        
      }
      // Fix for MySQL: Create an empty schema
      if (count == 0)
      {
        this.hmSchemas.put("", new DBSchema(dbMeta, this, ""));
      }
      
      rs.close();
      Iterator it = hmSchemas.values().iterator();
      while (it.hasNext()) ((DBSchema)it.next()).read();
      
    }
    
    public void addTable(String strSchemaName, String strTableName, String strTableType)
    throws java.sql.SQLException
    {
      DBSchema aDBSchema= this.getSchema(strSchemaName);
      if (aDBSchema == null)
      {
        aDBSchema = new DBSchema(dbMeta, this, strSchemaName);
        this.putSchema(strSchemaName, aDBSchema);
        aDBSchema.read();
      }
      aDBSchema.addTable(strTableName, strTableType);
    }
    
    public void addColumn(String strSchemaName, String strTableName, String strColumnName,
    int iDataType, String strTypeName, int iColumnSize, int iNullable)
    {
      DBSchema aDBSchema = this.getSchema(strSchemaName);
      if (aDBSchema != null)
      {
        aDBSchema.addColumn(strTableName, strColumnName,
        iDataType, strTypeName, iColumnSize, iNullable);
      }
    }
    
    public void addPrimaryKeyColumn(String strSchemaName, String strTableName,
    String strColumnName)
    {
      DBSchema aDBSchema = this.getSchema(strSchemaName);
      if (aDBSchema != null)
      {
        aDBSchema.addPrimaryKeyColumn(strTableName, strColumnName);
      }
    }
    
    
    public java.util.Enumeration children()
    {
      return java.util.Collections.enumeration(this.hmSchemas.values());
    }
    
    public boolean getAllowsChildren()
    {
      return true;
    }
    
    public TreeNode getChildAt(int param)
    {
      TreeNode tn = (TreeNode)this.hmSchemas.values().toArray()[param];
      return tn;
    }
    
    public int getChildCount()
    {
      return this.hmSchemas.size();
    }
    
    public int getIndex(TreeNode treeNode)
    {
      int indexOf = new java.util.Vector(this.hmSchemas.values()).indexOf(treeNode);
      return indexOf;
    }
    
    public TreeNode getParent()
    {
      return this.parsedMetaData;
    }
    
    public boolean isLeaf()
    {
      return false;
    }
    
    public String toString()
    {
      if (this.strCatalogName == null || this.strCatalogName.trim().length() == 0)
        return "<empty catalog>";
      else return this.strCatalogName;
    }
    
    public Class getPropertySheetClass()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBCatalogPropertySheet.class;
    }
    
    public String getXML()
    {
        java.io.StringWriter swr = new java.io.StringWriter();
        writeXML(new java.io.PrintWriter(swr));
        return swr.getBuffer().toString();
    }
    
    public void writeXML(java.io.PrintWriter pw) 
    {
      Iterator i = this.hmSchemas.values().iterator();
      while (i.hasNext())
      {
        ((DBSchema)i.next()).writeXML(pw);
      }
    }
    
    
    public void generateJava(java.io.File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      Iterator i = this.hmSchemas.values().iterator();
      while (i.hasNext()) ((DBSchema)i.next()).generateJava(aFile, strHeader, strFooter);
    }
    
    public void setPackage(String packageName)
    {
      Iterator i = this.hmSchemas.values().iterator();
      while (i.hasNext()) ((DBSchema)i.next()).setPackage(packageName);
    }
    
    public void disableClassesWithRegex(org.apache.regexp.RE aRegexp)
    {
      Iterator it = this.hmSchemas.values().iterator();
      while (it.hasNext()) ((DBSchema)it.next()).disableClassesWithRegex(aRegexp);
    }
    
    
  }
  
  
  /***************************** Changelog *****************************
   * // $Log: DBCatalog.java,v $
   * // Revision 1.1  2004/05/05 16:39:05  arminw
   * // fix fault
   * // wrong package structure used:
   * // org.apache.ojb.tools.reversdb
   * // org.apache.ojb.tools.reversdb2
   * //
   * // instead of
   * // org.apache.ojb.tools.mapping.reversdb
   * // org.apache.ojb.tools.mapping.reversdb2
   * //
   * // Revision 1.1  2004/05/04 13:45:00  arminw
   * // move reverseDB stuff
   * //
   * // Revision 1.7  2004/04/04 23:53:42  brianm
   * // Fixed initial copyright dates to match cvs repository
   * //
   * // Revision 1.6  2004/03/11 18:16:22  brianm
   * // ASL 2.0
   * //
   * // Revision 1.5  2003/06/21 10:23:25  florianbruckner
   * // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
   * //
   * // Revision 1.4  2003/01/28 21:42:53  florianbruckner
   * // update XML generation
   * //
   * // Revision 1.3  2003/01/28 19:59:14  florianbruckner
   * // some updates to schema reading to make it a bit more compatible
   * //
   * // Revision 1.2  2002/06/17 19:34:33  jvanzyl
   * // Correcting all the package references.
   * // PR:
   * // Obtained from:
   * // Submitted by:
   * // Reviewed by:
   * //
   * // Revision 1.1.1.1  2002/06/17 18:16:51  jvanzyl
   * // Initial OJB import
   * //
   * // Revision 1.3  2002/05/16 11:47:09  florianbruckner
   * // fix CR/LF issue, change license to ASL
   * //
   * // Revision 1.2  2002/05/16 10:43:59  florianbruckner
   * // use jakarta-regexp instead of gnu-regexp due to the move to jakarta.
   * //
   * // Revision 1.1  2002/04/18 11:44:16  mpoeschl
   * //
   * // move files to new location
   * //
   * // Revision 1.3  2002/04/07 09:05:16  thma
   * // *** empty log message ***
   * //
   * // Revision 1.2  2002/03/11 17:36:04  florianbruckner
   * // fix line break issue for these files that were previously checked in with -kb
   * //
   * // Revision 1.1  2002/03/04 17:19:32  thma
   * // initial checking for Florians Reverse engineering tool
   * //
   * // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
   * // initial import
   * //
   * /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBColumn.java
  
  Index: DBColumn.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: DBColumn.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class DBColumn implements MetadataNodeInterface, javax.swing.tree.TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    private DBTable aTable;
    private String strColumnName;
    private String strJavaFieldName;
    private String strJavaFieldType;
    private int iColumnType;
    private String strColumnTypeName;
    private boolean isPrimaryKeyPart = false;
    private boolean bAutoIncrement = false;
    
    
    private boolean enabled = true;  
    
    
    /** Creates a new instance of DBColumn */
    
    public DBColumn (java.sql.DatabaseMetaData pdbMeta, DBTable paTable,
                     String pstrColumnName, int piColumnType, 
                     String pstrColumnTypeName)
    {
      aTable = paTable;
      strColumnName = pstrColumnName;
  /*    this.strJavaFieldName = Character.toLowerCase(pstrColumnName.charAt(0)) 
        + pstrColumnName.substring(1);*/
      this.strJavaFieldName = Namer.nameField(this.strColumnName);
      iColumnType = piColumnType;
      this.strJavaFieldType = Utilities.hmJDBCTypeToJavaType.get(new Integer(iColumnType)).toString();    
      strColumnTypeName = pstrColumnTypeName;
    }
    
    public boolean getAutoIncrement()
    {
      return this.bAutoIncrement;
    }
    
    public void setAutoIncrement(boolean b)
    {
      this.bAutoIncrement = b;
    }
    
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }  
    
    public int getColumnType()
    {
      return this.iColumnType;
    }
    
    public String getJavaFieldName()
    {
      return this.strJavaFieldName;
    }
    
    public void setJavaFieldName(String s)
    {
      this.strJavaFieldName = s;
    }
    
    public String getJavaFieldType()
    {
      return this.strJavaFieldType;
    }
    
    public void setJavaFieldType(String s)
    {
      this.strJavaFieldType = s;
    }
    
    public void setColumnType(int i)
    {
      this.iColumnType = i;
    }
    
    public void setColumnType(String s)
    {
      Integer i = (Integer)Utilities.mJDBCNameToType.get(s);
      if (i != null)
      {
        this.iColumnType = i.intValue();
      }
    }
    
    public String getColumnTypeName()
    {
      return this.strColumnTypeName;
    }
    
    public DBTable getDBTable()
    {
      return this.aTable;
    }
    
    public boolean isTreeEnabled()
    {
      return this.aTable.isTreeEnabled() && this.isEnabled();
    }
    
  
    public void read()
      throws java.sql.SQLException
    {
    }      
    
    public void generateReferences()
      throws java.sql.SQLException
    {
    }      
    
    public void setPrimaryKeyPart(boolean b)
    {
      this.isPrimaryKeyPart = b;
    }
    
    public boolean isPrimaryKeyPart()
    {
      return this.isPrimaryKeyPart;
    }
    
    public String getColumnName()
    {
      return this.strColumnName;
    }
    
    public java.util.Enumeration children ()
    {
      return null;
    }
    
    public boolean getAllowsChildren ()
    {
      return false;
    }
    
    public javax.swing.tree.TreeNode getChildAt (int param)
    {
      return null;
    }
    
    public int getChildCount ()
    {
      return 0;
    }
    
    public int getIndex (javax.swing.tree.TreeNode treeNode)
    {
      return 0;
    }
    
    public javax.swing.tree.TreeNode getParent ()
    {
      return this.aTable;
    }
    
    public boolean isLeaf ()
    {
      return true;
    }
  
    public String toString()
    {
      if (this.isPrimaryKeyPart) return strColumnName + " (PK)";
      else return this.strColumnName;
    }
  
    
    public Class getPropertySheetClass ()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBColumnPropertySheet.class;
    }
    
    public String getXML()
    {
      if (this.isTreeEnabled())
      {
          java.io.StringWriter sw = new java.io.StringWriter();
          writeXML(new java.io.PrintWriter(sw));
          return sw.getBuffer().toString();
  /*        
        String strReturn =  
            "  <field-descriptor id=\"" + this.id + "\"" + System.getProperty("line.separator")
         +  "    name=\"" + this.strJavaFieldName + "\"" + System.getProperty("line.separator")
         +  "    column=\"" + this.strColumnName + "\"" + System.getProperty("line.separator")
         +  "    jdbc-type=\"" + Utilities.hmJDBCTypeToName.get(new Integer(this.iColumnType)) + "\"" + System.getProperty("line.separator");
        if (this.isPrimaryKeyPart())
            strReturn += "    primarykey=\"true\"" + System.getProperty("line.separator");
        if (this.getAutoIncrement())
            strReturn += "    <autoincrement>true</autoincrement>" + System.getProperty("line.separator");
        strReturn += "  />";
        return strReturn;      
   */
      }
      else return "";
   
    }  
    
    public void writeXML(java.io.PrintWriter pw)
    {
        pw.println("  <field-descriptor ");
        pw.println("     name=\"" + this.strJavaFieldName + "\"");
        pw.println("     column=\"" + this.strColumnName + "\"");
        pw.println("     jdbc-type=\"" + Utilities.hmJDBCTypeToName.get(new Integer(this.iColumnType)) + "\"" );
        if (this.isPrimaryKeyPart())
            pw.println( "     primarykey=\"true\"" );
        if (this.getAutoIncrement())
            pw.println( "     <autoincrement>true</autoincrement>");
        pw.println("  />");
    }
    
    public void generateJava (java.io.File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      throw new UnsupportedOperationException("Generate Java on DBColumn is not allowed");    
    }  
    
    public void setPackage (String packageName)
    {
      throw new UnsupportedOperationException("Set Package on DBColumn is not allowed");    
    }
    
    public String getJavaFieldDefinition()
    {
      if (this.isTreeEnabled())
      {
        return "  private " + this.getJavaFieldType() + " " + this.getJavaFieldName() + ";";
      }
      else return "";
    }
    
     public String getJavaGetterSetterDefinition()
    {
      if (this.isTreeEnabled())
      {
        String strReturn = "";
        strReturn = "  public " + this.getJavaFieldType() + " get" 
          + this.getJavaFieldName().substring(0,1).toUpperCase() 
          + this.getJavaFieldName().substring(1) + "()" 
          + System.getProperty("line.separator");
  
        strReturn += "  {" + System.getProperty("line.separator");    
        strReturn += "     return this." + this.getJavaFieldName() + ";" + System.getProperty("line.separator");    
        strReturn += "  }" + System.getProperty("line.separator"); 
        strReturn += "  public void set" 
          + this.getJavaFieldName().substring(0,1).toUpperCase() 
          + this.getJavaFieldName().substring(1) + "(" + this.getJavaFieldType() + " param)" 
          + System.getProperty("line.separator");
        strReturn += "  {" + System.getProperty("line.separator");    
        strReturn += "    this." + this.getJavaFieldName() + " = param;" + System.getProperty("line.separator"); 
        strReturn += "  }" + System.getProperty("line.separator");    
        return strReturn;
      }
      else return "";
    }
  
    /**
     *  @deprecated
     */
    public int getId()
    {
      return 0;
    }
    
  }
  
  /***************************** Changelog *****************************
  // $Log: DBColumn.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:00  arminw
  // move reverseDB stuff
  //
  // Revision 1.9  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.8  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.7  2003/12/12 16:37:16  brj
  // removed unnecessary casts, semicolons etc.
  //
  // Revision 1.6  2003/07/22 11:05:13  florianbruckner
  // add a name beautifier (courtesy G.Wayne Kidd)
  //
  // Revision 1.5  2003/06/21 10:27:45  florianbruckner
  // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
  // getId() is deprecated and returns 0 now; Ids are not used for XML generation.
  //
  // Revision 1.4  2003/01/28 21:42:53  florianbruckner
  // update XML generation
  //
  // Revision 1.3  2003/01/28 19:59:14  florianbruckner
  // some updates to schema reading to make it a bit more compatible
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:51  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.4  2002/04/09 17:08:32  thma
  // *** empty log message ***
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBFKRelation.java
  
  Index: DBFKRelation.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: DBFKRelation.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class DBFKRelation implements MetadataNodeInterface, javax.swing.tree.TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    DBTable pkTable;
    DBTable fkTable;
    
    private boolean bAutoRetrieve = true;
    private boolean bAutoUpdate   = false;
    private boolean bAutoDelete   = false;
    
    private String strFieldName = null;
    
    /* The field type is only relevant, if the parent table is the pk table
     * and this is a collection, then it is set to Vector as default. If
     * this is a refenece it is of the type of the target class.
     */
    private String strFieldType = null;
    
    private boolean enabled = true;  
    
    boolean pkTableIsParent = true;
    java.util.ArrayList alColumnPairs = new java.util.ArrayList();
    /** Creates a new instance of DBFKReference */
    public DBFKRelation (DBTable pPkTable, DBTable pFkTable, boolean ppkTableIsParent)
    {
      pkTable = pPkTable;
      fkTable = pFkTable;
      pkTableIsParent = ppkTableIsParent;
      if (pkTableIsParent)
      {
        this.strFieldName = "coll" + fkTable.getClassName ();
        this.strFieldType = "java.util.Vector";
      }
      else 
      {
        this.strFieldName = "a" + pkTable.getClassName ();
      }
    }
    
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }
    
    public String getFieldName()
    {
      return this.strFieldName;
    }
    
    public void setFieldName(String s)
    {
      strFieldName = s;
    }  
    
    public String getFieldType()
    {
      if (this.isPkTableParent ()) return this.strFieldType;
      else return this.pkTable.getFQClassName();
    }
    
    public void setFieldType(String s)
    {
      if (!this.isPkTableParent()) throw new java.lang.UnsupportedOperationException("Cannot set Field type on this type of relation");
      strFieldType = s;
    }
    
    public boolean isPkTableParent()
    {
      return this.pkTableIsParent;
    }
      
    public void setAutoRetrieve(boolean b)
    {
      this.bAutoRetrieve = b;
    }
    
    public boolean getAutoRetrieve()
    {
      return this.bAutoRetrieve;
    }
  
    public void setAutoUpdate(boolean b)
    {
      this.bAutoUpdate = b;
    }
    
    public boolean getAutoUpdate()
    {
      return this.bAutoUpdate;
    }
    
    public void setAutoDelete(boolean b)
    {
      this.bAutoDelete = b;
    }
    
    public boolean getAutoDelete()
    {
      return this.bAutoDelete;
    }
  
    public DBTable getFKTable()
    {
      return fkTable;
    }
    
    public DBTable getPKTable()
    {
      return pkTable;
    }
    
    public boolean isTreeEnabled()
    {
      if (this.pkTableIsParent) return this.pkTable.isTreeEnabled() && this.isEnabled();
      else return this.fkTable.isTreeEnabled() && this.isEnabled();
    }
    
    
    public void addColumnPair(DBColumn pPkColumn, DBColumn pFkColumn)
    {
      alColumnPairs.add(new Object[]{pPkColumn, pFkColumn});
    }
    
    public java.util.Iterator getColumnPairIterator()
    {
      return alColumnPairs.iterator();
    }
    
    public java.util.Enumeration children ()
    {
      if (pkTableIsParent) return this.fkTable.children();
      else return this.pkTable.children();
    }
    
    public boolean getAllowsChildren ()
    {
      if (pkTableIsParent) return this.fkTable.getAllowsChildren();
      else return this.pkTable.getAllowsChildren();
    }
    
    public javax.swing.tree.TreeNode getChildAt (int param)
    {
      if (pkTableIsParent) return this.fkTable.getChildAt(param);
      else return this.pkTable.getChildAt(param);
    }
    
    public int getChildCount ()
    {
      if (pkTableIsParent) return this.fkTable.getChildCount();
      else return this.pkTable.getChildCount();
    }
    
    public int getIndex (javax.swing.tree.TreeNode treeNode)
    {
      if (pkTableIsParent) return this.fkTable.getIndex(treeNode);
      else return this.pkTable.getIndex(treeNode);
    }
    
    public javax.swing.tree.TreeNode getParent ()
    {
      if (pkTableIsParent) return this.pkTable;
      else return this.fkTable;
    }
    
    public boolean isLeaf ()
    {
      if (pkTableIsParent) return this.fkTable.isLeaf();
      else return this.pkTable.isLeaf();
    }
  
    public String toString()
    {
      if (pkTableIsParent) return this.fkTable.toString() + " (Collection)";
      else return this.pkTable.toString() + " (Reference)";
    }
    
    
    public Class getPropertySheetClass ()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBFKRelationPropertySheet.class;
    }
    
    private void writeXMLReference(java.io.PrintWriter pw)
    {
      pw.println("  <reference-descriptor");
      pw.println("    name=\"" + this.getFieldName()+ "\"" );
      pw.println("    class-ref=\"" + this.getPKTable().getFQClassName() + "\"" );
      pw.println("    auto-retrieve=\"" + this.getAutoRetrieve()+ "\"" );
      pw.println("    auto-update=\"" + this.getAutoUpdate() + "\"");
      pw.println("    auto-delete=\"" + this.getAutoDelete() + "\">");
  
      pw.print("    <foreignkey field-ref=\"");
      java.util.Iterator it = this.getColumnPairIterator();
      // TODO: dtd dictate one refid
      // while (it.hasNext()) strReturn += ((DBColumn)((Object[])it.next())[1]).getId() + " ";
      if (it.hasNext()) pw.print(((DBColumn)((Object[])it.next())[1]).getJavaFieldName()) ;
      pw.println("\" />");
  
      pw.println("  </reference-descriptor>");
    }
    
    private void writeXMLCollection(java.io.PrintWriter pw)
    {
      pw.println("  <collection-descriptor");
      pw.println("    name=\"" + this.getFieldName() + "\"");
      pw.println("    element-class-ref=\"" + this.getFKTable().getFQClassName() + "\"" );
      pw.println("    auto-retrieve=\"" + this.getAutoRetrieve() + "\"" );
      pw.println("    auto-update=\"" + this.getAutoUpdate() + "\"" );
      pw.println("    auto-delete=\"" + this.getAutoDelete() + "\">");
      pw.print("    <inverse-foreignkey field-ref=\"");
      java.util.Iterator it = this.getColumnPairIterator();
      while (it.hasNext()) pw.print(((DBColumn)((Object[])it.next())[1]).getJavaFieldName() + " ");
      pw.println("\"    />");
      pw.println("  </collection-descriptor>");
    }
    
    public String getXML()
    {
          java.io.StringWriter sw = new java.io.StringWriter();
          writeXML(new java.io.PrintWriter(sw));
          return sw.getBuffer().toString();      
    }
    
    public void writeXML(java.io.PrintWriter pw) 
    {
      if (this.isPkTableParent())
      {
        writeXMLCollection(pw);
      }
      else
      {
        writeXMLReference(pw);
      }          
    }
    
    
    public void generateJava (java.io.File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      throw new UnsupportedOperationException("Generate Java on DBFKReference is not allowed");
    }
    
    public void setPackage (String packageName)
    {
      throw new UnsupportedOperationException("Set Package on DBFKReference is not allowed");       
    }
  
    public String getJavaFieldDefinition()
    {
      // Only return a field definition if this Relation and both
      // participating tables are enabled;
      if (this.isTreeEnabled() 
          && this.getFKTable().isTreeEnabled() 
          && this.getPKTable().isTreeEnabled())
      {
        return "  private " + this.getFieldType() + " " + this.getFieldName() + ";";
      }
      else return "";
    }
    
    public String getJavaGetterSetterDefinition()
    {
      if (this.isTreeEnabled() 
          && this.getFKTable().isTreeEnabled() 
          && this.getPKTable().isTreeEnabled())
      {
        String strReturn = "";
        strReturn = "  public " + this.getFieldType() + " get" 
          + this.getFieldName().substring(0,1).toUpperCase() 
          + this.getFieldName().substring(1) + "()" 
          + System.getProperty("line.separator");
  
        strReturn += "  {" + System.getProperty("line.separator");    
        strReturn += "     return this." + this.getFieldName() + ";" + System.getProperty("line.separator");    
        strReturn += "  }" + System.getProperty("line.separator"); 
        strReturn += "  public void set" 
          + this.getFieldName().substring(0,1).toUpperCase() 
          + this.getFieldName().substring(1) + "(" + this.getFieldType() + " param)" 
          + System.getProperty("line.separator");
        strReturn += "  {" + System.getProperty("line.separator");    
        strReturn += "    this." + this.getFieldName() + " = param;" + System.getProperty("line.separator"); 
        strReturn += "  }" + System.getProperty("line.separator");    
        return strReturn;
      }
      else return "";
    }
    
    
  }
  
  /***************************** Changelog *****************************
  // $Log: DBFKRelation.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:00  arminw
  // move reverseDB stuff
  //
  // Revision 1.8  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.7  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.6  2003/12/12 16:37:16  brj
  // removed unnecessary casts, semicolons etc.
  //
  // Revision 1.5  2003/09/10 06:45:00  mpoeschl
  // remove duplicated license
  //
  // Revision 1.4  2003/06/21 10:28:44  florianbruckner
  // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
  // Ids are not used for XML generation.
  //
  // Revision 1.3  2003/01/28 21:42:53  florianbruckner
  // update XML generation
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:51  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBMeta.java
  
  Index: DBMeta.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.Iterator;
  import javax.swing.tree.TreeNode;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: DBMeta.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class DBMeta implements MetadataNodeInterface, TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    private boolean enabled = true;
    
    private java.sql.DatabaseMetaData dbMeta;
    
    // private java.util.TreeMap hmCatalogs = new java.util.TreeMap();
    private java.util.HashMap hmCatalogs = new java.util.HashMap();
    private String catalogTerm;
    private String catalogSeparator;
    private boolean isCatalogAtStart;
    private boolean supportsCatalogsInDataManipulation;
    private boolean supportsCatalogsInIndexDefinitions;
    private boolean supportsCatalogsInPrivilegeDefinitions;
    private boolean supportsCatalogsInProcedureCalls;
    private boolean supportsCatalogsInTableDefinitions;
    private String schemaTerm;
    
    private String catalogPattern;
    private String schemaPattern;
    
    private String databaseProductName = null;
    private String databaseProductVersion = null;
    
    
    /** Creates a new instance of DBSchema */
    public DBMeta (String pCatalogPattern, String pSchemaPattern, java.sql.DatabaseMetaData pDbMeta) throws java.sql.SQLException
    {
      super();
      this.dbMeta = pDbMeta;
      this.catalogPattern = pCatalogPattern;
      this.schemaPattern  = pSchemaPattern;
      System.err.println("Using " + dbMeta.getDriverName() + " "  + dbMeta.getDriverVersion());
    }
    
    public DBMeta (java.sql.DatabaseMetaData pDbMeta) throws java.sql.SQLException
    {
        this(null, null, pDbMeta);
    }
    
    public String getSchemaPattern()
    {
      return this.schemaPattern;
    }
    
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }
  
    public String getDatabaseProductVersion()
    {
      return this.databaseProductVersion;
    }
    
    public String getDatabaseProductName()
    {
      return this.databaseProductName;
    }
    
    public boolean getSupportsCatalogsInIndexDefinitions()
    {
      return this.supportsCatalogsInIndexDefinitions;
    }
    
    public boolean getSupportsCatalogsInDataManipulation()
    {
      return this.supportsCatalogsInDataManipulation;
    }
    
    public boolean getSupportsCatalogsInPrivilegeDefinitions()
    {
      return this.supportsCatalogsInPrivilegeDefinitions;
    }
    
    public boolean getSupportsCatalogsInProcedureCalls()
    {
      return this.supportsCatalogsInProcedureCalls;
    }
    
    public boolean getSupportsCatalogsInTableDefinitions()
    {
      return this.supportsCatalogsInTableDefinitions;
    }
    
    public String getCatalogTerm()
    {
      return this.catalogTerm;
    }
    
    public String getSchemaTerm()
    {
      return this.schemaTerm;
    }
    
    public String getCatalogSeparator()
    {
      return this.catalogSeparator;
    }
    
    public boolean getIsCatalogAtStart()
    {
      return this.isCatalogAtStart;
    }
    
    public DBCatalog getCatalog(String catalogName)
    {
      return (DBCatalog)this.hmCatalogs.get(catalogName);
    }
    
    public void read()
      throws java.sql.SQLException
    {
      this.databaseProductName = dbMeta.getDatabaseProductName ();
      this.databaseProductVersion = dbMeta.getDatabaseProductVersion ();
      catalogTerm = dbMeta.getCatalogTerm();
      catalogSeparator = dbMeta.getCatalogSeparator();
      isCatalogAtStart = dbMeta.isCatalogAtStart();
      supportsCatalogsInDataManipulation = dbMeta.supportsCatalogsInDataManipulation();
      supportsCatalogsInIndexDefinitions = dbMeta.supportsCatalogsInIndexDefinitions();
      supportsCatalogsInPrivilegeDefinitions = dbMeta.supportsCatalogsInPrivilegeDefinitions();
      supportsCatalogsInProcedureCalls = dbMeta.supportsCatalogsInProcedureCalls();
      supportsCatalogsInTableDefinitions = dbMeta.supportsCatalogsInTableDefinitions();
      schemaTerm = dbMeta.getSchemaTerm();
      
      java.sql.ResultSet rs = dbMeta.getCatalogs();
      int count = 0;
      while(rs.next())
      {
          count++;
          String strCatalogName = rs.getString("TABLE_CAT");
          try
          {
            if (new org.apache.regexp.RE(this.catalogPattern).match(strCatalogName))
            {
              DBCatalog aDBCatalog = new DBCatalog(dbMeta, this, strCatalogName);
              this.hmCatalogs.put(strCatalogName, aDBCatalog);
            }
          }
          catch (org.apache.regexp.RESyntaxException ex)
          {
            // This expception should be reported, but this does not fit currently.
            ex.printStackTrace();
          }
      }
      rs.close();
      if (count==0)
      {
          DBCatalog aDBCatalog = new DBCatalog(dbMeta, this, null);
          this.hmCatalogs.put(null, aDBCatalog); 
      }
      
      // Read after closing recordset.
      Iterator it = hmCatalogs.values().iterator();
      while (it.hasNext()) ((DBCatalog)it.next()).read();
    }
    
    public void generateReferences()
      throws java.sql.SQLException
    {
      Iterator it = this.hmCatalogs.values().iterator();
      while (it.hasNext())
      {
        ((DBCatalog)it.next()).generateReferences();
      }    
    }
    
    public void debug()
    {
  
    }
    
    public java.util.Enumeration children ()
    {
      return java.util.Collections.enumeration(this.hmCatalogs.values());
    }
    
    public boolean getAllowsChildren ()
    {
      return true;
    }
    
    public TreeNode getChildAt(int param)
    {
      return (TreeNode)this.hmCatalogs.values().toArray()[param];
    }
    
    public int getChildCount ()
    {
      return this.hmCatalogs.size();
    }
    
    public int getIndex(TreeNode treeNode)
    {
      return new java.util.Vector(hmCatalogs.values()).indexOf(treeNode);
    }
    
    public TreeNode getParent()
    {
      return null;
    }
    
    public boolean isLeaf ()
    {
      return false;
    }
    
    public String toString()
    {
      return "DBMeta";
    }
      
    public Class getPropertySheetClass ()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBMetaPropertySheet.class;
    }
  
    public String getXML()
    {
          java.io.StringWriter sw = new java.io.StringWriter();
          writeXML(new java.io.PrintWriter(sw));
          return sw.getBuffer().toString();      
    }
    
    public void writeXML(java.io.PrintWriter pw) 
    {
        
      
      pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
      pw.println("<!DOCTYPE descriptor-repository SYSTEM \"repository.dtd\">" );
      pw.println("<descriptor-repository version=\"0.9.9\">" );
      pw.println("  <jdbc-connection-descriptor" );
      pw.println("    jcd-alias=\"default\"" );
      pw.println("    default-connection=\"true\"" );
      pw.println("    platform=\"XXXX\"" );
      pw.println("    jdbc-level=\"1.0\"");
      pw.println("    driver=\"XXX\"" );
      pw.println("    protocol=\"XXX\"" );
      pw.println("    subprotocol=\"XXX\"");
      pw.println("    dbalias=\"XXX\"" );
      pw.println("    username=\"XXX\"");
      pw.println("    password=\"XXX\">");
      pw.println("  </jdbc-connection-descriptor>");
      
      Iterator i = this.hmCatalogs.values().iterator();
      while (i.hasNext())
      {
        ((DBCatalog)i.next()).writeXML(pw);
      }
      pw.println("</descriptor-repository>");      
    }
    
    public void generateJava (java.io.File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      Iterator it = this.hmCatalogs.values().iterator();
      while (it.hasNext()) ((DBCatalog)it.next()).generateJava(aFile, strHeader, strFooter);
    }
    
    public void setPackage (String packageName)
    {
      Iterator it = this.hmCatalogs.values().iterator();
      while (it.hasNext()) ((DBCatalog)it.next()).setPackage(packageName);    
    }
    
    public void disableClassesWithRegex(org.apache.regexp.RE aRegexp)
    {
      Iterator it = this.hmCatalogs.values().iterator();
      while (it.hasNext()) ((DBCatalog)it.next()).disableClassesWithRegex(aRegexp);        
    }
    
    
  }
  
  
  /***************************** Changelog *****************************
  // $Log: DBMeta.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:00  arminw
  // move reverseDB stuff
  //
  // Revision 1.7  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.6  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.5  2003/06/21 10:31:45  florianbruckner
  // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
  //
  // Revision 1.4  2003/01/28 21:42:53  florianbruckner
  // update XML generation
  //
  // Revision 1.3  2003/01/28 19:59:14  florianbruckner
  // some updates to schema reading to make it a bit more compatible
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.3  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.2  2002/05/16 10:43:59  florianbruckner
  // use jakarta-regexp instead of gnu-regexp due to the move to jakarta.
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBSchema.java
  
  Index: DBSchema.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.Iterator;
  import javax.swing.tree.TreeNode;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: DBSchema.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  
  public class DBSchema implements MetadataNodeInterface, TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    private java.sql.DatabaseMetaData dbMeta;
    private DBCatalog aDBCatalog;
    
    private boolean enabled = true;
  
    private java.util.TreeMap tmTables = new java.util.TreeMap();
    
    private String m_strSchemaName;  
    
    
    /** Creates a new instance of DBSchema */
    public DBSchema( java.sql.DatabaseMetaData pdbMeta, DBCatalog paDBCatalog,
                     String pstrSchemaName)
    {
      aDBCatalog = paDBCatalog;
      dbMeta = pdbMeta;
      m_strSchemaName = pstrSchemaName;
    }
  
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }
    
    
    public DBCatalog getDBCatalog()
    {
      return this.aDBCatalog;
    }
    
    public String getSchemaName()
    {
      return this.m_strSchemaName;
    }
    
    public boolean isTreeEnabled()
    {
      return this.getDBCatalog().isTreeEnabled() && this.isEnabled();
    }
    
    
    public void read()
      throws java.sql.SQLException
    {
      java.sql.ResultSet rs = dbMeta.getTables(this.getDBCatalog().getCatalogName(), this.getSchemaName(), "%", null);
      while (rs.next())
      {
        String strTableCat = rs.getString("TABLE_CAT");
        String strSchemaName = rs.getString("TABLE_SCHEM");
        String strTableName = rs.getString("TABLE_NAME");
        String strTableType = rs.getString("TABLE_TYPE");
        // Pointbase returns the catalog name in uppercase here and in mixed
        // case in getCatalogs(). Therefore we have to use toUpper().
        if (   
            (strTableCat!=null && strTableCat.equalsIgnoreCase(this.getDBCatalog().getCatalogName()) || strTableCat==this.getDBCatalog().getCatalogName())
            &&
            (strSchemaName!=null && strSchemaName.equals(this.getSchemaName()) || strSchemaName==this.getSchemaName())
           )
          this.addTable(strTableName, strTableType);
        
      }
      rs.close();
      
      rs = dbMeta.getColumns(this.getDBCatalog().getCatalogName(), this.getSchemaName(), "%", "%");
      while (rs.next())
      {
        String strSchemaName = rs.getString("TABLE_SCHEM");
        String strTableName = rs.getString("TABLE_NAME");
        String strColumnName = rs.getString("COLUMN_NAME");
        int iDataType = rs.getInt("DATA_TYPE");
        String strTypeName = rs.getString("TYPE_NAME");
        int iColumnSize = rs.getInt("COLUMN_SIZE");
        int iNullable = rs.getInt("NULLABLE");
        this.addColumn(strTableName, strColumnName,
        iDataType, strTypeName, iColumnSize, iNullable);
      }
      rs.close();    
    }
    
    public void addTable(String strTableName, String strTableType)
      throws java.sql.SQLException
    {
      DBTable aDBTable = new DBTable(dbMeta, this, strTableName);
      this.tmTables.put(strTableName, aDBTable);
      aDBTable.read();
    }
  
    public void addColumn(String strTableName, String strColumnName,
              int iDataType, String strTypeName, int iColumnSize, int iNullable)
    {
      DBTable aDBTable= this.getTable(strTableName);
      if (aDBTable != null)
      {
        aDBTable.addColumn( strColumnName,
                            iDataType, strTypeName, iColumnSize, iNullable);
      }
    }
    
    public void addPrimaryKeyColumn(String strTableName, String strColumnName)
    {
      DBTable aDBTable = this.getTable(strTableName);
      if (aDBTable != null)
      {
        aDBTable.addPrimaryKeyColumn(strColumnName);
      }
    }
    
    
    public DBTable getTable(String strTableName)
    {
      return (DBTable)tmTables.get(strTableName);
    }
    
    public void generateReferences()
      throws java.sql.SQLException
    {
      Iterator it = tmTables.values().iterator();
      while (it.hasNext())
      {
        ((DBTable)it.next()).generateReferences();
      }    
    }  
    
    public java.util.Enumeration children ()
    {
      return java.util.Collections.enumeration(this.tmTables.values());
    }
    
    public boolean getAllowsChildren ()
    {
      return true;
    }
    
    public TreeNode getChildAt(int param)
    {
      TreeNode tn = (TreeNode)tmTables.values().toArray()[param];
      return tn;
    }
    
    public int getChildCount ()
    {
      return this.tmTables.size();
    }
    
    public int getIndex(TreeNode treeNode)
    {
      int indexOf = new java.util.Vector(tmTables.values()).indexOf(treeNode);
      return indexOf;
    }
    
    public TreeNode getParent()
    {
      return this.aDBCatalog;
    }
    
    public boolean isLeaf ()
    {
      return false;
    }  
    
    public String toString()
    {
      if (m_strSchemaName == null || m_strSchemaName.trim().length() == 0) 
         return "<empty  schema>";
      else return this.m_strSchemaName;
    }
      
    public Class getPropertySheetClass ()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBSchemaPropertySheet.class;
    }
    
    public String getXML()
    {
        java.io.StringWriter swr = new java.io.StringWriter();
        writeXML(new java.io.PrintWriter(swr));
        return swr.getBuffer().toString();
    }
  
    public void writeXML(java.io.PrintWriter pw) 
    {
        Iterator i = this.tmTables.values().iterator();
        while (i.hasNext())
        {
          ((DBTable)i.next()).writeXML(pw);
        }      
    }
    
    public void generateJava (java.io.File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      Iterator i = this.tmTables.values().iterator();
      while (i.hasNext()) ((DBTable)i.next()).generateJava(aFile, strHeader, strFooter);
    }
    
    public void setPackage (String packageName)
    {
      Iterator i = this.tmTables.values().iterator();
      while (i.hasNext()) ((DBTable)i.next()).setPackage(packageName);            
    }
  
    public void disableClassesWithRegex(org.apache.regexp.RE aRegexp)
    {
      Iterator it = this.tmTables.values().iterator();
      while (it.hasNext()) ((DBTable)it.next()).disableClassesWithRegex(aRegexp);        
    }
      
    
  }
  
  /***************************** Changelog *****************************
  // $Log: DBSchema.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.11  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.10  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.9  2003/09/13 16:59:44  brj
  // prevent NPE
  // patch by Jason Pyeron
  //
  // Revision 1.8  2003/06/29 14:28:07  florianbruckner
  // fix a bug that could cause problems with all databases that use mixed or lower case catalog names (e.g. Informix, MySQL)
  //
  // Revision 1.7  2003/06/21 10:34:01  florianbruckner
  // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
  //
  // Revision 1.6  2003/06/07 10:10:04  brj
  // some style fixes
  //
  // Revision 1.5  2003/02/21 12:44:10  florianbruckner
  // add support for PointBase. The version distributed with Sun ONE AppServer
  // returns a mixed case catalog name ("PointBase") in getCatalogs() and an upper
  // case catalog name in getTables().
  //
  // Revision 1.4  2003/01/28 21:42:53  florianbruckner
  // update XML generation
  //
  // Revision 1.3  2003/01/28 19:59:14  florianbruckner
  // some updates to schema reading to make it a bit more compatible
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.3  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.2  2002/05/16 10:43:59  florianbruckner
  // use jakarta-regexp instead of gnu-regexp due to the move to jakarta.
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/DBTable.java
  
  Index: DBTable.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import javax.swing.tree.TreeNode;
  import java.sql.SQLException;
  import java.io.File;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: DBTable.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class DBTable implements MetadataNodeInterface, TreeNode, org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel
  {
    private java.sql.DatabaseMetaData dbMeta;
    private DBSchema aSchema;
    private java.util.HashMap hmReferences = new java.util.HashMap(0);
    private java.util.HashMap hmCollections = new java.util.HashMap(0);
    private java.util.TreeMap tmColumns = new java.util.TreeMap();
    private java.util.Vector  vSubTreeNodes = new java.util.Vector();
    private String strTableName;
    private String strClassName;
    private String strPackageName = ""; // In default package by default ;-)
    private String strConversionStrategyClass = "";
    
    private boolean dynamicProxy = false;
  
    private boolean enabled = true;
  
    
    /** Creates a new instance of DBTable */
    public DBTable (java.sql.DatabaseMetaData pdbMeta, DBSchema paSchema,
                    String pstrTableName)
    {
      strTableName = pstrTableName;
      // this.strClassName = Character.toUpperCase (strTableName.charAt(0)) + strTableName.substring(1).toLowerCase();
      this.strClassName = Namer.nameClass(this.strTableName);
      aSchema = paSchema;
      dbMeta = pdbMeta;
    }
    
    public boolean hasDynamicProxy()
    {
      return dynamicProxy;
    }
    
    public void setDynamicProxy(boolean b)
    {
      dynamicProxy = b;
    }
    
    public String getConversionStrategyClass()
    {
      return this.strConversionStrategyClass;
    }
    
    public void setConversionStrategyClass(String s)
    {
      this.strConversionStrategyClass = s;
    }
    
    public boolean isEnabled()
    {
      return this.enabled;
    }
    
    public void setEnabled(boolean b)
    {
      this.enabled = b;
    }
    
    public boolean isTreeEnabled()
    {
      return this.aSchema.isTreeEnabled() && this.isEnabled();
    }
    
    
    public DBColumn getColumn(String colName)
    {
      return (DBColumn)tmColumns.get(colName);
    }
    
    public String getTableName()
    {
      return strTableName;
    }
    
    public String getFQTableName()
    {
      String strReturn = null;
      // Are table names supported in table definitions?
      if (aSchema.getDBCatalog().getDBMeta().getSupportsCatalogsInTableDefinitions ())
      {
        // Yes, include catalog name in fq table name
        // Now check, where we have to specify the catalog
        if (aSchema.getDBCatalog().getDBMeta().getIsCatalogAtStart ())
        {
          // At the beginning
          strReturn = aSchema.getDBCatalog().getCatalogName() 
            + aSchema.getDBCatalog().getDBMeta().getCatalogSeparator ()
            + aSchema.getSchemaName() + "." + this.getTableName();
        }
        else
        {
          // At the end
          strReturn = aSchema.getSchemaName() + "." + this.getTableName()
            + aSchema.getDBCatalog().getDBMeta().getCatalogSeparator ()
            + aSchema.getDBCatalog().getCatalogName();
        }
      }
      else
      {
        strReturn = aSchema.getSchemaName() + "." + this.getTableName();
      }
      return strReturn;
    }
    
    public String getClassName()
    {
      return strClassName;
    }
    
    public void setClassName(String s)
    {
      this.strClassName = s;
    }
    
    public String getPackageName()
    {
      return strPackageName;
    }
  
    public void setPackageName(String s)
    {
      this.strPackageName = s;
    }
    
    public String getFQClassName()
    {
      if (this.getPackageName() != null && this.getPackageName().trim().length() > 0)
        return this.getPackageName() + "." + this.getClassName();
      else
        return this.getClassName();
    }
    
    public DBSchema getDBSchema()
    {
      return this.aSchema;
    }
    
    
    public void read() throws SQLException
    {
  
    }
    
    public void addColumn(String strColumnName,
              int iDataType, String strTypeName, int iColumnSize, int iNullable)
    {
      DBColumn aDBColumn = new DBColumn(this.dbMeta, this, strColumnName, iDataType, strTypeName);
      this.tmColumns.put(strColumnName, aDBColumn);
    }
    
    public void addPrimaryKeyColumn(String strColumnName)
    {
      DBColumn aDBColumn = this.getColumn(strColumnName);
      if (aDBColumn != null)
      {
        aDBColumn.setPrimaryKeyPart(true);
      }
    }  
    
    public void generateReferences() throws SQLException
    {
      // Check if primary keys for this table have already been set. If not, do it now...
      // This is necessary because Oracle doesn't return the Primary Keys for all tables
      // and for Informix it speeds up things significantly if we do it onve for all tables.
      java.util.Iterator it = this.tmColumns.values().iterator();
      boolean hasNoPrimaryKey = true;
      while (hasNoPrimaryKey && it.hasNext()) if ( ((DBColumn)it.next()).isPrimaryKeyPart()) hasNoPrimaryKey = false;
      if (hasNoPrimaryKey) readPrimaryKeys();        
      
      // Now generate References and Collections
      generateFKReferences();
      generateFKCollections();
      vSubTreeNodes.addAll(this.tmColumns.values());
      vSubTreeNodes.addAll(this.hmCollections.values());
      vSubTreeNodes.addAll(this.hmReferences.values());
    }    
    
    public java.util.Enumeration children ()
    {
      return vSubTreeNodes.elements();
    }
    
    public boolean getAllowsChildren ()
    {
      return true;
    }
    
    public TreeNode getChildAt(int param)
    {
      TreeNode tn = 
        (TreeNode)vSubTreeNodes.elementAt(param);
      return tn;
    }
    
    public int getChildCount ()
    {
      return this.vSubTreeNodes.size();
    }
    
    public int getIndex(TreeNode treeNode)
    {
      return this.vSubTreeNodes.indexOf(treeNode);
    }
    
    public TreeNode getParent()
    {
      return this.aSchema;
    }
    
    public boolean isLeaf ()
    {
      if (this.vSubTreeNodes.size() == 0) return true;
      else return false;
    }  
    
    public String toString()
    {
      return this.strTableName;
    }
    
    
    private void readPrimaryKeys() throws SQLException
    {
      // Now get the primary keys for this table. Ignore any exceptions thrown here as
      // primary keys are not absolutely necessary for reverse engineering
      java.sql.ResultSet rs = null;
      try
      {
        rs = dbMeta.getPrimaryKeys(null, 
                                    this.getDBSchema().getSchemaName(), this.strTableName);
        while (rs.next())
        {
          String strCatalogName = rs.getString("TABLE_CAT");
          String strSchemaName = rs.getString("TABLE_SCHEM");
          if ( (strSchemaName == null && this.aSchema.getSchemaName() == null || strSchemaName.equals(this.aSchema.getSchemaName())) 
               &&
               (strCatalogName == null && this.aSchema.getDBCatalog().getCatalogName() == null 
                || strCatalogName.equals(this.aSchema.getDBCatalog().getCatalogName())))
          {
            String strColumnName = rs.getString("COLUMN_NAME");
            String pkName = rs.getString("PK_NAME");
            DBColumn dbcol = (DBColumn)tmColumns.get(strColumnName);
            if (dbcol != null) dbcol.setPrimaryKeyPart(true);
          }
        }
      }
      catch (SQLException sqlEx)
      {
        // Ignore excpetions here.
      }
      finally
      {
        try
        {
          rs.close();    
        }
        catch (Throwable t)
        {} // Ignore this exception
      }
    }
  
    private void generateFKReferences() throws SQLException
    {
      // References, points from this class to another class using attributes
      // of this class
      // Ignore any exceptions thrown here.
      java.sql.ResultSet rs = null;
      try
      {
        rs = dbMeta.getImportedKeys(this.getDBSchema().getDBCatalog().getCatalogName(), 
                                                       this.getDBSchema().getSchemaName(), strTableName);
        while (rs.next())
        {
          String strFKSchemaName = rs.getString("FKTABLE_SCHEM");
          String strFKCatalogName = rs.getString("FKTABLE_CAT");
  
          if (   (strFKCatalogName == null && this.aSchema.getDBCatalog().getCatalogName() == null || strFKCatalogName.equals(this.aSchema.getDBCatalog().getCatalogName()))
              && (strFKSchemaName  == null && this.aSchema.getSchemaName() == null || strFKSchemaName.equals(this.aSchema.getSchemaName())))
          {
            String strPKCatalogName = rs.getString("PKTABLE_CAT");
            String strPKSchemaName = rs.getString("PKTABLE_SCHEM");
            String strPKTableName  = rs.getString("PKTABLE_NAME");
            String strPKColumnName = rs.getString("PKCOLUMN_NAME");
            String strFKTableName  = rs.getString("FKTABLE_NAME");
            String strFKColumnName = rs.getString("FKCOLUMN_NAME");
  
            // Resolove the primaryKey column
            DBCatalog dbPKCatalog = this.aSchema.getDBCatalog().getDBMeta().getCatalog(strPKCatalogName);
            if (dbPKCatalog != null)
            {
              DBSchema dbPKSchem = dbPKCatalog.getSchema(strPKSchemaName);
              if (dbPKSchem != null)
              {
                DBTable dbPKTable = dbPKSchem.getTable(strPKTableName);
                if (dbPKTable != null)
                {
                  DBColumn dbPKColumn = dbPKTable.getColumn(strPKColumnName);
                  // The FK column is always from this table.
                  DBColumn dbFKColumn = getColumn(strFKColumnName);
  
                  // Now retrieve the FKReference to this table from the collection
                  DBFKRelation aFKRef = 
                    (DBFKRelation)this.hmReferences.get(dbPKSchem.getSchemaName() 
                      + "." + dbPKTable.getTableName());
                  if (aFKRef == null)
                  {
                    aFKRef = new DBFKRelation(dbPKTable, this, false);
                    this.hmReferences.put(dbPKSchem.getSchemaName() 
                      + "." + dbPKTable.getTableName(), aFKRef);
                  }
                  aFKRef.addColumnPair(dbPKColumn, dbFKColumn);
                }
              }
            }
          }
        }
      }
      catch (SQLException sqlEx)
      {
        // sqlEx.printStackTrace();
      }
      try
      {
        rs.close();    
      }
      catch (Throwable t) {}
    }
    
    private void generateFKCollections() throws SQLException
    {
      // Collections, points from this class to a collection of objects using
      // attributes from the referenced class
      // Ignore any exceptions thrown here
      java.sql.ResultSet rs = null;
      try
      {
        rs = dbMeta.getExportedKeys(this.getDBSchema().getDBCatalog().getCatalogName(), 
                                                         this.getDBSchema().getSchemaName(), strTableName);
        while (rs.next())
        {
          String strPKSchemaName = rs.getString("PKTABLE_SCHEM");
          String strPKCatalogName = rs.getString("PKTABLE_CAT");
  
          if (    (strPKSchemaName == null && this.aSchema.getSchemaName()==null || strPKSchemaName.equals(this.aSchema.getSchemaName()))
               && (strPKCatalogName == null && this.aSchema.getDBCatalog().getCatalogName() == null 
                   || strPKCatalogName.equals(this.aSchema.getDBCatalog().getCatalogName())))
          {
            String strPKTableName  = rs.getString("PKTABLE_NAME");
            String strPKColumnName = rs.getString("PKCOLUMN_NAME");
            String strFKCatalogName= rs.getString("FKTABLE_CAT");
            String strFKTableName  = rs.getString("FKTABLE_NAME");
            String strFKColumnName = rs.getString("FKCOLUMN_NAME");
            String strFKSchemaName = rs.getString("FKTABLE_SCHEM");        
  
            // Resolve the FK column. If catalog is supported in the index
            // definition, resolve the catalog of the FK column, otherwise
            // assume the current catalog (Note: This is needed for Informix,
            // because the driver reports null for the catalog in this case.
            DBCatalog dbFKCatalog = null;
            if (this.aSchema.getDBCatalog().getDBMeta().getSupportsCatalogsInIndexDefinitions())
            {
              dbFKCatalog = this.aSchema.getDBCatalog().getDBMeta().getCatalog(strFKCatalogName);
            }
            else
            {
              dbFKCatalog = this.aSchema.getDBCatalog();
            }
            if (dbFKCatalog != null)
            {
              DBSchema dbFKSchema = dbFKCatalog.getSchema(strFKSchemaName);
              if (dbFKSchema != null)
              {
                DBTable dbFKTable = dbFKSchema.getTable(strFKTableName);
                if (dbFKTable != null)
                {
                  DBColumn dbFKColumn = dbFKTable.getColumn(strFKColumnName);
                  // The PK column is always from this table
                  DBColumn dbPKColumn = getColumn(strPKColumnName);
                  //Retrieve the FK Reference for the FK Table
                  DBFKRelation aFKRef = 
                    (DBFKRelation)this.hmCollections.get(dbFKSchema.getSchemaName() 
                      + "." + dbFKTable.getTableName());
                  if (aFKRef == null)
                  {
                    aFKRef = new DBFKRelation(this, dbFKTable, true);
                    this.hmCollections.put(dbFKSchema.getSchemaName() 
                      + "." + dbFKTable.getTableName(), aFKRef);
                  }
                  aFKRef.addColumnPair(dbPKColumn, dbFKColumn);
                }
              }
            }
          }
        }
      }
      catch (SQLException sqlEx)
      {
        // sqlEx.printStackTrace();
      }
      try
      {
        rs.close();    
      }
      catch (Throwable t)
      {
      }
    }
    
    
    public Class getPropertySheetClass ()
    {
      return org.apache.ojb.tools.mapping.reversedb.gui.DBTablePropertySheet.class;
    }
    
    public String getXML()
    {
          java.io.StringWriter sw = new java.io.StringWriter();
          writeXML(new java.io.PrintWriter(sw));
          return sw.getBuffer().toString();
    }  
    
    public void writeXML(java.io.PrintWriter pw)
    {
      // Only generate a Classdescriptor if this table is enabled 
      if (this.isTreeEnabled())
      {
        java.util.Iterator it = tmColumns.values().iterator();
        if (it.hasNext())     
        {
          // Generate the class descriptor
            pw.println("<class-descriptor ");
            pw.println("  class=\"" + this.getFQClassName() + "\"");
            pw.println("  table=\"" + this.getFQTableName() + "\">");
            if (this.hasDynamicProxy())
              pw.println("  <class.proxy>dynamic</class.proxy>");
            if (this.getConversionStrategyClass () != null 
              && this.getConversionStrategyClass ().trim().length() > 0)
              pw.println("  <conversionStrategy>" + this.getConversionStrategyClass () + "</conversionStrategy>");
  
            it = this.tmColumns.values().iterator();
          
          while (it.hasNext())
          {
              ((DBColumn)it.next()).writeXML(pw);
          }
          
          // Generate references
          it = this.hmReferences.values().iterator();
          while (it.hasNext())
          {
            ((DBFKRelation)it.next()).writeXML(pw);
          }
          // Generate collections
          it = this.hmCollections.values().iterator();
          while (it.hasNext())
          {
            ((DBFKRelation)it.next()).writeXML(pw);
          }        
          pw.println("</class-descriptor>");
        }
      }
    }
    
    public void generateJava(File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
    {
      if (this.isTreeEnabled())
      {
        // 1. Generate the package directories
        String dirName = this.getPackageName().replace('.', File.separatorChar);
        File packageDir;
        if (this.getPackageName() != null && this.getPackageName().trim().length() > 0)
        {
          packageDir = new File(aFile, dirName);
        }
        else
        {
          packageDir = aFile;
        }
  
        if (!packageDir.exists()) packageDir.mkdirs();
        File javaFile = new File(packageDir, this.getClassName()+ ".java");
        if (!javaFile.exists()) javaFile.createNewFile();
        java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileOutputStream(javaFile));
        pw.println(strHeader);
        pw.println("// Generated by OJB SchemeGenerator");
        pw.println();
        if (this.getPackageName().trim().length() > 0)
        {
          pw.println("package " + this.getPackageName() + ";");
          pw.println();
        }
        pw.println("public class " + this.getClassName());
        pw.println("{");
  
        // Generate Fields
        java.util.Iterator it = this.tmColumns.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBColumn)it.next()).getJavaFieldDefinition());
          pw.println();
        }
  
        it = this.hmReferences.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBFKRelation)it.next()).getJavaFieldDefinition());
          pw.println();
        }
  
        it = this.hmCollections.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBFKRelation)it.next()).getJavaFieldDefinition());
          pw.println();
        }
  
        // Generate Getter/Setter
        it = this.tmColumns.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBColumn)it.next()).getJavaGetterSetterDefinition());
          pw.println();
        }
  
        it = this.hmReferences.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBFKRelation)it.next()).getJavaGetterSetterDefinition());
          pw.println();
        }
  
        it = this.hmCollections.values().iterator();
        while (it.hasNext())
        {
          pw.println(((DBFKRelation)it.next()).getJavaGetterSetterDefinition());
          pw.println();
        }
  
        pw.println("}");
        pw.println(strFooter);
        pw.close();
      }
    }
    
    public void setPackage (String packageName)
    {
      this.setPackageName(packageName);
    }
    
    public void disableClassesWithRegex(org.apache.regexp.RE aRegexp)
    {
      if (aRegexp.match(this.getClassName())) this.setEnabled(false);
    }  
    
  }
  
  
  /***************************** Changelog *****************************
  // $Log: DBTable.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.9  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.8  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.7  2003/12/12 16:37:16  brj
  // removed unnecessary casts, semicolons etc.
  //
  // Revision 1.6  2003/07/22 11:05:13  florianbruckner
  // add a name beautifier (courtesy G.Wayne Kidd)
  //
  // Revision 1.5  2003/06/21 10:35:03  florianbruckner
  // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
  // does not generate an Id anymore.
  //
  // Revision 1.4  2003/01/28 21:42:53  florianbruckner
  // update XML generation
  //
  // Revision 1.3  2003/01/28 19:59:14  florianbruckner
  // some updates to schema reading to make it a bit more compatible
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.3  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.2  2002/05/16 10:43:59  florianbruckner
  // use jakarta-regexp instead of gnu-regexp due to the move to jakarta.
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.2  2002/02/20 13:55:11  Administrator
  // add semicolon after package name
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/IdGeneratorSingleton.java
  
  Index: IdGeneratorSingleton.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.HashMap;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: IdGeneratorSingleton.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   * @deprecated since 2003-06-21
   */
  public class IdGeneratorSingleton
  {
    private static IdGeneratorSingleton singleton = new IdGeneratorSingleton();
  
    /** Creates a new instance of IdGeneratorSingleton */
    
    private HashMap hmIds = new HashMap();
    
    private IdGeneratorSingleton ()
    {
    }
    
    private int _getId(String type, String instance)
    {
      HashMap hmTypeId = (HashMap)hmIds.get(type);
      if (hmTypeId == null)
      {
        hmTypeId = new HashMap();
        hmIds.put(type, hmTypeId);
      }
      Integer storedId  = (Integer)hmTypeId.get(instance);
      int id;
      if (storedId == null)
      {
        id = 0;
      }
      else id = storedId.intValue()+1;
      hmTypeId.put(instance, new Integer(id));
      return id;
    }
    
    public static int getId(String type, String instance)
    {
      return singleton._getId (type, instance);
    }
  }
  
  
  /***************************** Changelog *****************************
  // $Log: IdGeneratorSingleton.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.5  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.4  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.3  2003/06/21 10:36:40  florianbruckner
  // remove double license header, deprecate class
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/Main.java
  
  Index: Main.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: Main.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  public class Main {
      
      private java.util.Properties theProperties;
      
      /** Creates a new instance of Main */
      public Main() 
      {
        try
        {
          theProperties = new java.util.Properties();
          theProperties.load(new java.io.FileInputStream(System.getProperty("user.home") +
              System.getProperty("file.separator") + "SchemeGenerator.properties"));
        }
        catch (java.io.IOException ioex)
        {
          // report nothing, because the worst thing that can happen is
          // that the properties arent there.
        }
        new org.apache.ojb.tools.mapping.reversedb.gui.JFrmMainFrame(theProperties).show();
      }
      
      /**
       * @param args the command line arguments
       * @param args ghjghjghj
       */
      public static void main(String[] args) 
      {
          new Main();
      }
  }
  /***************************** Changelog *****************************
  // $Log: Main.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.5  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.4  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.3  2003/09/10 06:45:00  mpoeschl
  // remove duplicated license
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/MetadataNodeInterface.java
  
  Index: MetadataNodeInterface.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: MetadataNodeInterface.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  
  public interface MetadataNodeInterface
  {
  
    public String getXML();
    
    public void writeXML(java.io.PrintWriter pw);
    
    public void generateJava(java.io.File aFile, String strHeader, String strFooter)
      throws java.io.IOException, java.io.FileNotFoundException;
    
    public void setPackage(String packageName);
  }
  
  /***************************** Changelog *****************************
  // $Log: MetadataNodeInterface.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.5  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.4  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.3  2003/06/21 10:37:34  florianbruckner
  // remove double license header; add writeXML(PrintWriter) to interface
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/Namer.java
  
  Index: Namer.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2003-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  
  
  /**
   * @author <a href="mailto:wk5657@henleykidd.ns01.us">G. Wayne Kidd</a>
   *
   * To change the template for this generated type comment go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  public class Namer
  {
  	/* (non-Javadoc)
  	 * @see org.apache.ojb.tools.mapping.reversedb.Namer#nameClass(java.lang.String, java.lang.String)
  	 */
  	public static String nameClass(String tableName) 
      {
  		StringBuffer sb = new StringBuffer();
  		char[] chars = new char[tableName.length()];
  		chars = tableName.toCharArray();
  		char c;
  		boolean nextup = false;
  		for (int i = 0; i < chars.length; i++) {
  			if (i==0) c = Character.toUpperCase(chars[i]);
  			else if (chars[i]=='_') {
  				 nextup = true;
  				 continue;
  			}
  			else if (nextup) {
  				nextup = false;
  				c = Character.toUpperCase(chars[i]);
  			} 
  			else c = Character.toLowerCase(chars[i]);
  			sb.append(c);
  		}
  		return sb.toString();
  	}
  
  	/* (non-Javadoc)
  	 * @see org.apache.ojb.tools.mapping.reversedb.Namer#nameField(java.lang.String, java.lang.String)
  	 */
  	public static String nameField(String columnName)
      {
  		StringBuffer sb = new StringBuffer();
  		char[] chars = new char[columnName.length()];
  		chars = columnName.toCharArray();
  		char c;
  		boolean nextup = false;
  		for (int i = 0; i < chars.length; i++) {
  			if (chars[i]=='_') {
  				 nextup = true;
  				 continue;
  			}
  			else if (nextup) {
  				nextup = false;
  				c = Character.toUpperCase(chars[i]);
  			} 
  			else c = Character.toLowerCase(chars[i]);
  			sb.append(c);
  		}
  		return sb.toString();
  	}
  }
  
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/README
  
  Index: README
  ===================================================================
  The GUI of this application is built using Netbeans version 3.5 (see also
  http://www.netbeans.org). If you want to modify the GUI of the application
  please do so using Netbeans, so the .form files get updated as well. Otherwise
  your changes might be overwritten once somebody else opens the forms in Netbeans.
  
  
  1.1                  db-ojb/src/tools/org/apache/ojb/tools/mapping/reversedb/Utilities.java
  
  Index: Utilities.java
  ===================================================================
  package org.apache.ojb.tools.mapping.reversedb;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  import java.sql.Types;
  
  /**
   *
   * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
   * @version $Id: Utilities.java,v 1.1 2004/05/05 16:39:05 arminw Exp $
   */
  
  public class Utilities
  {
    public static final java.util.Map hmJDBCTypeToName 
        = new java.util.HashMap();
    public static final java.util.Map mJDBCNameToType
        = new java.util.TreeMap();
  
    public static final java.util.Vector vJDBCTypeNames = new java.util.Vector();
  
    public static final java.util.HashMap hmJDBCTypeToJavaType 
        = new java.util.HashMap();
    
    public static final java.util.Vector vJavaTypes = new java.util.Vector();  
    
    static
    {
        hmJDBCTypeToName.put(new Integer(Types.ARRAY), "ARRAY");
        hmJDBCTypeToName.put(new Integer(Types.BIGINT), "BIGINT");
        hmJDBCTypeToName.put(new Integer(Types.BINARY), "BINARY");
        hmJDBCTypeToName.put(new Integer(Types.BIT), "BIT");
        hmJDBCTypeToName.put(new Integer(Types.BLOB), "BLOB");
        hmJDBCTypeToName.put(new Integer(Types.CHAR), "CHAR");
        hmJDBCTypeToName.put(new Integer(Types.CLOB), "CLOB");
        hmJDBCTypeToName.put(new Integer(Types.DATE), "DATE");
        hmJDBCTypeToName.put(new Integer(Types.DECIMAL), "DECIMAL");
        hmJDBCTypeToName.put(new Integer(Types.DISTINCT), "DISTINCT");
        hmJDBCTypeToName.put(new Integer(Types.DOUBLE), "DOUBLE");
        hmJDBCTypeToName.put(new Integer(Types.FLOAT), "FLOAT");
        hmJDBCTypeToName.put(new Integer(Types.INTEGER), "INTEGER");
        hmJDBCTypeToName.put(new Integer(Types.JAVA_OBJECT), "OBJECT");
        hmJDBCTypeToName.put(new Integer(Types.LONGVARBINARY), "LONGVARBINARY");
        hmJDBCTypeToName.put(new Integer(Types.LONGVARCHAR), "LONGVARCHAR");
        hmJDBCTypeToName.put(new Integer(Types.NULL), "NULL");
        hmJDBCTypeToName.put(new Integer(Types.NUMERIC), "NUMERIC");
        hmJDBCTypeToName.put(new Integer(Types.OTHER), "OTHER");
        hmJDBCTypeToName.put(new Integer(Types.REAL), "REAL");
        hmJDBCTypeToName.put(new Integer(Types.REF), "REF");
        hmJDBCTypeToName.put(new Integer(Types.SMALLINT), "SMALLINT");
        hmJDBCTypeToName.put(new Integer(Types.STRUCT), "STRUCT");
        hmJDBCTypeToName.put(new Integer(Types.TIME), "TIME");
        hmJDBCTypeToName.put(new Integer(Types.TIMESTAMP), "TIMESTAMP");
        hmJDBCTypeToName.put(new Integer(Types.TINYINT), "TINYINT");
        hmJDBCTypeToName.put(new Integer(Types.VARBINARY), "VARBINARY");
        hmJDBCTypeToName.put(new Integer(Types.VARCHAR), "VARCHAR");
  
        // Build a map containing the name to typecode mapping
        java.util.Iterator it = hmJDBCTypeToName.entrySet().iterator();
        while (it.hasNext()) 
        {
          java.util.Map.Entry aEntry = (java.util.Map.Entry)it.next();
          mJDBCNameToType.put (aEntry.getValue(), aEntry.getKey());
        }
        
        hmJDBCTypeToJavaType.put(new Integer(Types.ARRAY), "Object[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.BIGINT), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.BINARY), "byte[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.BIT), "Byte");
        hmJDBCTypeToJavaType.put(new Integer(Types.BLOB), "byte[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.CHAR), "String");
        hmJDBCTypeToJavaType.put(new Integer(Types.CLOB), "String");
        hmJDBCTypeToJavaType.put(new Integer(Types.DATE), "java.sql.Date");
        hmJDBCTypeToJavaType.put(new Integer(Types.DECIMAL), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.DISTINCT), "????");
        hmJDBCTypeToJavaType.put(new Integer(Types.DOUBLE), "Double");
        hmJDBCTypeToJavaType.put(new Integer(Types.FLOAT), "Double");
        hmJDBCTypeToJavaType.put(new Integer(Types.INTEGER), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.JAVA_OBJECT), "Object");
        hmJDBCTypeToJavaType.put(new Integer(Types.LONGVARBINARY), "byte[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.LONGVARCHAR), "byte[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.NULL), "Object");
        hmJDBCTypeToJavaType.put(new Integer(Types.NUMERIC), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.OTHER), "Object");
        hmJDBCTypeToJavaType.put(new Integer(Types.REAL), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.REF), "Object");
        hmJDBCTypeToJavaType.put(new Integer(Types.SMALLINT), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.STRUCT), "Object");
        hmJDBCTypeToJavaType.put(new Integer(Types.TIME), "java.sql.Time");
        hmJDBCTypeToJavaType.put(new Integer(Types.TIMESTAMP), "java.sql.Timestamp");
        hmJDBCTypeToJavaType.put(new Integer(Types.TINYINT), "Long");
        hmJDBCTypeToJavaType.put(new Integer(Types.VARBINARY), "byte[]");
        hmJDBCTypeToJavaType.put(new Integer(Types.VARCHAR), "String");      
        
        vJavaTypes.addAll(new java.util.TreeSet(hmJDBCTypeToJavaType.values()));
        java.util.Collections.sort(vJavaTypes);
        
        vJDBCTypeNames.addAll(new java.util.TreeSet(hmJDBCTypeToName.values()));
        java.util.Collections.sort(vJDBCTypeNames);
    }
    
    /** Creates a new instance of Utilities */
    private Utilities ()
    {
    }
    
    public static String getTypeNameFromJDBCType(int jdbcType)
    {
      return (String)Utilities.hmJDBCTypeToName.get(new Integer(jdbcType));
    }  
  }
  
  /***************************** Changelog *****************************
  // $Log: Utilities.java,v $
  // Revision 1.1  2004/05/05 16:39:05  arminw
  // fix fault
  // wrong package structure used:
  // org.apache.ojb.tools.reversdb
  // org.apache.ojb.tools.reversdb2
  //
  // instead of
  // org.apache.ojb.tools.mapping.reversdb
  // org.apache.ojb.tools.mapping.reversdb2
  //
  // Revision 1.1  2004/05/04 13:45:01  arminw
  // move reverseDB stuff
  //
  // Revision 1.6  2004/04/04 23:53:42  brianm
  // Fixed initial copyright dates to match cvs repository
  //
  // Revision 1.5  2004/03/11 18:16:22  brianm
  // ASL 2.0
  //
  // Revision 1.4  2003/12/12 16:37:16  brj
  // removed unnecessary casts, semicolons etc.
  //
  // Revision 1.3  2003/09/10 06:45:00  mpoeschl
  // remove duplicated license
  //
  // Revision 1.2  2002/06/17 19:34:33  jvanzyl
  // Correcting all the package references.
  // PR:
  // Obtained from:
  // Submitted by:
  // Reviewed by:
  //
  // Revision 1.1.1.1  2002/06/17 18:16:52  jvanzyl
  // Initial OJB import
  //
  // Revision 1.2  2002/05/16 11:47:09  florianbruckner
  // fix CR/LF issue, change license to ASL
  //
  // Revision 1.1  2002/04/18 11:44:16  mpoeschl
  //
  // move files to new location
  //
  // Revision 1.3  2002/04/07 09:05:16  thma
  // *** empty log message ***
  //
  // Revision 1.2  2002/03/11 17:36:05  florianbruckner
  // fix line break issue for these files that were previously checked in with -kb
  //
  // Revision 1.1  2002/03/04 17:19:32  thma
  // initial checking for Florians Reverse engineering tool
  //
  // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
  // initial import
  //
  /***************************** Changelog *****************************/
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org