mpoeschl 2002/10/08 11:17:07
Modified: src/java/org/apache/torque/engine/database/transform
DTDResolver.java SQLToAppData.java
XmlToAppData.java XmlToData.java
Log:
code cleanup (formatting + javadocs)
no functional changes
Revision Changes Path
1.9 +3 -1
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/DTDResolver.java
Index: DTDResolver.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/DTDResolver.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DTDResolver.java 13 Sep 2002 05:06:39 -0000 1.8
+++ DTDResolver.java 8 Oct 2002 18:17:06 -0000 1.9
@@ -107,6 +107,8 @@
/**
* called by the XML parser
*
+ * @param publicId The public identifier of the external entity
+ * @param systemId The system identifier of the external entity
* @return an InputSource for the database.dtd file
*/
public InputSource resolveEntity(String publicId, String systemId)
1.7 +38 -26
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java
Index: SQLToAppData.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SQLToAppData.java 7 May 2002 18:24:43 -0000 1.6
+++ SQLToAppData.java 8 Oct 2002 18:17:06 -0000 1.7
@@ -92,6 +92,8 @@
/**
* Create a new class with an input Reader
+ *
+ * @param sqlFile the sql file
*/
public SQLToAppData(String sqlFile)
{
@@ -102,6 +104,10 @@
* Create a new class with an input Reader. This ctor is not used
* but putting here in the event db.props properties are found to
* be useful converting sql to xml, the infrastructure will exist
+ *
+ * @param sqlFile the sql file
+ * @param databaseType
+ * @param basePropsFilePath
*/
public SQLToAppData(String sqlFile, String databaseType,
String basePropsFilePath)
@@ -111,7 +117,6 @@
this.basePropsFilePath = basePropsFilePath;
}
-
/**
* Get the current input sql file
*/
@@ -122,8 +127,10 @@
/**
* Set the current input sql file
+ *
+ * @param sqlFile the sql file
*/
- public void setSqlFile (String sqlFile)
+ public void setSqlFile(String sqlFile)
{
this.sqlFile = sqlFile;
}
@@ -131,6 +138,8 @@
/**
* Move to the next token. Throws an exception
* if there is no more tokens available.
+ *
+ * @throws ParseException
*/
private void next() throws ParseException
{
@@ -140,7 +149,7 @@
}
else
{
- throw new ParseException ("No More Tokens");
+ throw new ParseException("No More Tokens");
}
}
@@ -148,11 +157,14 @@
* Creates an error condition and adds the line and
* column number of the current token to the error
* message.
+ *
+ * @param name name of the error
+ * @throws ParseException
*/
- private void err (String name) throws ParseException
+ private void err(String name) throws ParseException
{
- throw new ParseException (name + " at [ line: " + token.getLine() +
- " col: " + token.getCol() + " ]");
+ throw new ParseException (name + " at [ line: " + token.getLine()
+ + " col: " + token.getCol() + " ]");
}
/**
@@ -165,6 +177,8 @@
/**
* Parses a CREATE TABLE FOO command.
+ *
+ * @throws ParseException
*/
private void Create() throws ParseException
{
@@ -223,19 +237,19 @@
if (token.getStr().toUpperCase().equals("PRIMARY"))
{
- Create_Table_Column_Primary (tbl);
+ Create_Table_Column_Primary(tbl);
}
else if (token.getStr().toUpperCase().equals("FOREIGN"))
{
- Create_Table_Column_Foreign (tbl);
+ Create_Table_Column_Foreign(tbl);
}
else if (token.getStr().toUpperCase().equals("UNIQUE"))
{
- Create_Table_Column_Unique (tbl);
+ Create_Table_Column_Unique(tbl);
}
else
{
- Create_Table_Column_Data (tbl);
+ Create_Table_Column_Data(tbl);
}
}
@@ -247,12 +261,12 @@
next();
if (!token.getStr().toUpperCase().equals("KEY"))
{
- err ("KEY expected");
+ err("KEY expected");
}
next();
if (!token.getStr().toUpperCase().equals("("))
{
- err ("( expected");
+ err("( expected");
}
next();
@@ -370,12 +384,12 @@
{
next();
int i = 0;
- fk.addReference((String) localColumns.get(i++),token.getStr());
+ fk.addReference((String) localColumns.get(i++), token.getStr());
next();
while (token.getStr().equals(","))
{
next();
- fk.addReference((String) localColumns.get(i++),token.getStr());
+ fk.addReference((String) localColumns.get(i++), token.getStr());
next();
}
if (!token.getStr().toUpperCase().equals(")"))
@@ -389,7 +403,7 @@
/**
* Parse the data definition of the column statement.
*/
- private void Create_Table_Column_Data (Table tbl) throws ParseException
+ private void Create_Table_Column_Data(Table tbl) throws ParseException
{
String columnSize = null;
String columnPrecision = null;
@@ -445,29 +459,29 @@
next();
columnSize = token.getStr();
next();
- if (token.getStr().equals (","))
+ if (token.getStr().equals(","))
{
next();
columnPrecision = token.getStr();
next();
}
- if (!token.getStr().equals (")"))
+ if (!token.getStr().equals(")"))
{
- err (") expected");
+ err(") expected");
}
next();
}
- Column col = new Column (columnName);
+ Column col = new Column(columnName);
if (columnPrecision != null)
{
columnSize = columnSize + columnPrecision;
}
- col.setTypeFromString (columnType,columnSize);
+ col.setTypeFromString(columnType, columnSize);
tbl.addColumn(col);
- if ( inEnum )
+ if (inEnum)
{
col.setNotNull(true);
if (columnDefault != null)
@@ -484,7 +498,7 @@
next();
if (!token.getStr().toUpperCase().equals("NULL"))
{
- err ("NULL expected after NOT");
+ err("NULL expected after NOT");
}
col.setNotNull(true);
next();
@@ -494,7 +508,7 @@
next();
if (!token.getStr().toUpperCase().equals("KEY"))
{
- err ("KEY expected after PRIMARY");
+ err("KEY expected after PRIMARY");
}
col.setPrimaryKey(true);
next();
@@ -567,10 +581,8 @@
next();
}
}
-
return appData;
}
-
/**
* Just 4 testing.
1.16 +34 -24
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
Index: XmlToAppData.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XmlToAppData.java 15 Sep 2002 03:16:57 -0000 1.15
+++ XmlToAppData.java 8 Oct 2002 18:17:06 -0000 1.16
@@ -58,10 +58,7 @@
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.File;
-import java.util.List;
-import java.util.Iterator;
-import org.apache.torque.Torque;
import org.apache.torque.engine.database.model.AppData;
import org.apache.torque.engine.database.model.Column;
import org.apache.torque.engine.database.model.Database;
@@ -102,7 +99,6 @@
private Unique currUnique;
private boolean firstPass;
- private Table foreignTable;
private String errorMessage;
private boolean isExternalSchema;
private String currentPackage;
@@ -111,7 +107,7 @@
private static SAXParserFactory saxFactory;
- static
+ static
{
saxFactory = SAXParserFactory.newInstance();
saxFactory.setValidating(true);
@@ -121,10 +117,11 @@
* Creates a new instance for the specified database type.
*
* @param databaseType The type of database for the application.
+ * @param defaultPackage the default java package used for the om
* @param basePropsFilePath The base of the path to the properties
* file, including trailing slash.
*/
- public XmlToAppData(String databaseType, String defaultPackage,
+ public XmlToAppData(String databaseType, String defaultPackage,
String basePropsFilePath)
{
app = new AppData(databaseType, basePropsFilePath);
@@ -141,13 +138,13 @@
* @return AppData populated by <code>xmlFile</code>.
*/
public AppData parseFile(String xmlFile)
- {
+ {
try
{
// in case I am missing something, make it obvious
- if (!firstPass)
+ if (!firstPass)
{
- throw new Error("No more double pass");
+ throw new Error("No more double pass");
}
currentXmlFile = xmlFile;
@@ -178,21 +175,22 @@
{
e.printStackTrace();
}
- if (!isExternalSchema)
+ if (!isExternalSchema)
{
firstPass = false;
- }
- if ( errorMessage.length() > 0 )
+ }
+ if (errorMessage.length() > 0)
{
System.out.println("Error in XML schema: " + errorMessage);
}
-
return app;
}
/**
* EntityResolver implementation. Called by the XML parser
*
+ * @param publicId The public identifier of the external entity
+ * @param systemId The system identifier of the external entity
* @return an InputSource for the database.dtd file
*/
public InputSource resolveEntity(String publicId, String systemId)
@@ -203,6 +201,13 @@
/**
* Handles opening elements of the xml file.
+ *
+ * @param uri
+ * @param localName The local name (without prefix), or the empty string if
+ * Namespace processing is not being performed.
+ * @param rawName The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param attributes The specified or defaulted attributes
*/
public void startElement(String uri, String localName, String rawName,
Attributes attributes)
@@ -214,10 +219,10 @@
if (isExternalSchema)
{
currentPackage = attributes.getValue("package");
- if (currentPackage == null)
+ if (currentPackage == null)
{
currentPackage = defaultPackage;
- }
+ }
}
else
{
@@ -228,19 +233,19 @@
{
isExternalSchema = true;
String xmlFile = attributes.getValue("filename");
- if (xmlFile.charAt(0) != '/')
+ if (xmlFile.charAt(0) != '/')
{
File f = new File(currentXmlFile);
xmlFile = new File(f.getParent(), xmlFile).getPath();
}
-
+
parseFile(xmlFile);
isExternalSchema = false;
}
else if (rawName.equals("table"))
{
currTable = currDB.addTable(attributes);
- if (isExternalSchema)
+ if (isExternalSchema)
{
currTable.setForReferenceOnly(true);
currTable.setPackage(currentPackage);
@@ -291,13 +296,19 @@
/**
* Handles closing elements of the xml file.
+ *
+ * @param uri
+ * @param localName The local name (without prefix), or the empty string if
+ * Namespace processing is not being performed.
+ * @param rawName The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
*/
public void endElement(String uri, String localName, String rawName)
{
if (DEBUG)
{
- System.out.println("endElement(" + uri + ", " + localName + ", " +
- rawName + ") called");
+ System.out.println("endElement(" + uri + ", " + localName + ", "
+ + rawName + ") called");
}
}
@@ -333,8 +344,7 @@
private final void printParseError(String type, SAXParseException spe)
{
- System.err.println(type + " [line " + spe.getLineNumber() +
- ", row " + spe.getColumnNumber() + "]: " +
- spe.getMessage());
+ System.err.println(type + " [line " + spe.getLineNumber()
+ + ", row " + spe.getColumnNumber() + "]: " + spe.getMessage());
}
}
1.9 +12 -13
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToData.java
Index: XmlToData.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToData.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XmlToData.java 7 May 2002 18:24:43 -0000 1.8
+++ XmlToData.java 8 Oct 2002 18:17:06 -0000 1.9
@@ -98,7 +98,6 @@
private static SAXParserFactory saxFactory;
-
static
{
saxFactory = SAXParserFactory.newInstance();
@@ -146,7 +145,7 @@
//System.out.println("Error : "+e);
e.printStackTrace();
}
- if ( errorMessage.length() > 0 )
+ if (errorMessage.length() > 0)
{
System.out.println("ERROR in data file!!!\n" + errorMessage);
}
@@ -180,7 +179,7 @@
data.add(new DataRow(table, columnValues));
}
}
- catch(Exception e)
+ catch (Exception e)
{
e.printStackTrace();
}
@@ -193,9 +192,9 @@
*/
public void warning(SAXParseException spe)
{
- System.out.println("Warning Line: " + spe.getLineNumber() +
- " Row: " + spe.getColumnNumber() +
- " Msg: " + spe.getMessage());
+ System.out.println("Warning Line: " + spe.getLineNumber()
+ + " Row: " + spe.getColumnNumber()
+ + " Msg: " + spe.getMessage());
}
/**
@@ -205,9 +204,9 @@
*/
public void error(SAXParseException spe)
{
- System.out.println("Error Line: " + spe.getLineNumber() +
- " Row: " + spe.getColumnNumber() +
- " Msg: " + spe.getMessage());
+ System.out.println("Error Line: " + spe.getLineNumber()
+ + " Row: " + spe.getColumnNumber()
+ + " Msg: " + spe.getMessage());
}
/**
@@ -217,9 +216,9 @@
*/
public void fatalError(SAXParseException spe)
{
- System.out.println("Fatal Error Line: " + spe.getLineNumber() +
- " Row: " + spe.getColumnNumber() +
- " Msg: " + spe.getMessage());
+ System.out.println("Fatal Error Line: " + spe.getLineNumber()
+ + " Row: " + spe.getColumnNumber()
+ + " Msg: " + spe.getMessage());
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>