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 fl...@apache.org on 2003/07/22 13:05:14 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb Namer.java DBColumn.java DBTable.java
florianbruckner 2003/07/22 04:05:14
Modified: src/java/org/apache/ojb/tools/mapping/reversedb
DBColumn.java DBTable.java
Added: src/java/org/apache/ojb/tools/mapping/reversedb Namer.java
Log:
add a name beautifier (courtesy G.Wayne Kidd)
Revision Changes Path
1.6 +8 -3 db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBColumn.java
Index: DBColumn.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBColumn.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DBColumn.java 21 Jun 2003 10:27:45 -0000 1.5
+++ DBColumn.java 22 Jul 2003 11:05:13 -0000 1.6
@@ -84,8 +84,9 @@
dbMeta = pdbMeta;
aTable = paTable;
strColumnName = pstrColumnName;
- this.strJavaFieldName = Character.toLowerCase(pstrColumnName.charAt(0))
- + pstrColumnName.substring(1);
+/* 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;
@@ -332,6 +333,9 @@
/***************************** Changelog *****************************
// $Log$
+// 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.
1.6 +7 -2 db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBTable.java
Index: DBTable.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/DBTable.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DBTable.java 21 Jun 2003 10:35:03 -0000 1.5
+++ DBTable.java 22 Jul 2003 11:05:13 -0000 1.6
@@ -86,7 +86,8 @@
String pstrTableName)
{
strTableName = pstrTableName;
- this.strClassName = Character.toUpperCase (strTableName.charAt(0)) + strTableName.substring(1).toLowerCase();
+ // this.strClassName = Character.toUpperCase (strTableName.charAt(0)) + strTableName.substring(1).toLowerCase();
+ this.strClassName = Namer.nameClass(this.strTableName);
aSchema = paSchema;
dbMeta = pdbMeta;
}
@@ -622,6 +623,9 @@
/***************************** Changelog *****************************
// $Log$
+// 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.
1.1 db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb/Namer.java
Index: Namer.java
===================================================================
package org.apache.ojb.tools.mapping.reversedb;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache ObjectRelationalBridge" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* @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();
int loc = 0;
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();
int loc = 0;
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();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org