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/06/21 12:35:03 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/tools/mapping/reversedb DBTable.java
florianbruckner 2003/06/21 03:35:03
Modified: src/java/org/apache/ojb/tools/mapping/reversedb DBTable.java
Log:
implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
does not generate an Id anymore.
Revision Changes Path
1.5 +29 -24 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DBTable.java 28 Jan 2003 21:42:53 -0000 1.4
+++ DBTable.java 21 Jun 2003 10:35:03 -0000 1.5
@@ -75,7 +75,6 @@
private String strClassName;
private String strPackageName = ""; // In default package by default ;-)
private String strConversionStrategyClass = "";
- private int id;
private boolean dynamicProxy = false;
@@ -88,7 +87,6 @@
{
strTableName = pstrTableName;
this.strClassName = Character.toUpperCase (strTableName.charAt(0)) + strTableName.substring(1).toLowerCase();
- id = IdGeneratorSingleton.getId(this.getClass().getName(), this.getClass().getName());
aSchema = paSchema;
dbMeta = pdbMeta;
}
@@ -481,51 +479,52 @@
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
- String strReturn = "";
if (this.isTreeEnabled())
{
java.util.Iterator it = tmColumns.values().iterator();
if (it.hasNext())
{
// Generate the class descriptor
- strReturn +=
- "<class-descriptor " + System.getProperty("line.separator");
- strReturn +=
- " class=\"" + this.getFQClassName() + "\"" + System.getProperty("line.separator");
- strReturn +=
- " table=\"" + this.getFQTableName() + "\">" + System.getProperty("line.separator");
- if (this.hasDynamicProxy())
- strReturn += " <class.proxy>dynamic</class.proxy>" + System.getProperty("line.separator");
- if (this.getConversionStrategyClass () != null
+ 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)
- strReturn += " <conversionStrategy>" + this.getConversionStrategyClass () + "</conversionStrategy>" + System.getProperty("line.separator");
+ pw.println(" <conversionStrategy>" + this.getConversionStrategyClass () + "</conversionStrategy>");
- it = this.tmColumns.values().iterator();
+ it = this.tmColumns.values().iterator();
- // Generate columns
while (it.hasNext())
{
- strReturn += ((DBColumn)it.next()).getXML() + System.getProperty("line.separator");
+ ((DBColumn)it.next()).writeXML(pw);
}
// Generate references
it = this.hmReferences.values().iterator();
while (it.hasNext())
{
- strReturn += ((DBFKRelation)it.next()).getXML() + System.getProperty("line.separator");
+ ((DBFKRelation)it.next()).writeXML(pw);
}
// Generate collections
it = this.hmCollections.values().iterator();
while (it.hasNext())
{
- strReturn += ((DBFKRelation)it.next()).getXML() + System.getProperty("line.separator");
+ ((DBFKRelation)it.next()).writeXML(pw);
}
- strReturn += "</class-descriptor>" + System.getProperty("line.separator");
+ pw.println("</class-descriptor>");
}
}
- return strReturn;
- }
+ }
public void generateJava(File aFile, String strHeader, String strFooter) throws java.io.IOException, java.io.FileNotFoundException
{
@@ -550,8 +549,11 @@
pw.println(strHeader);
pw.println("// Generated by OJB SchemeGenerator");
pw.println();
- pw.println("package " + this.getPackageName() + ";");
- pw.println();
+ if (this.getPackageName().trim().length() > 0)
+ {
+ pw.println("package " + this.getPackageName() + ";");
+ pw.println();
+ }
pw.println("public class " + this.getClassName());
pw.println("{");
@@ -620,6 +622,10 @@
/***************************** Changelog *****************************
// $Log$
+// 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
//