You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/09/14 06:33:52 UTC
svn commit: r996754 - in
/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator:
configuration/ configuration/source/ file/ source/ source/jdbc/
source/stream/
Author: tfischer
Date: Tue Sep 14 04:33:52 2010
New Revision: 996754
URL: http://svn.apache.org/viewvc?rev=996754&view=rev
Log:
Fixed findbugs and checkstyle issues.
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/source/FileSourceSaxHandler.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/SourceElement.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSource.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/FileSourceProvider.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/PropertiesSourceFormat.java
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/UnitConfigurationReader.java Tue Sep 14 04:33:52 2010
@@ -206,13 +206,15 @@ class UnitConfigurationReader
Map<String, byte[]> inheritedReferences
= inheritedConfiguration.getEntityReferences()
.getEntityReferences();
- for (String systemId : inheritedReferences.keySet())
+ for (Map.Entry<String, byte[]> inheritedReference
+ : inheritedReferences.entrySet())
{
+ String systemId = inheritedReference.getKey();
if (!entityReferences.containsSystemId(systemId))
{
entityReferences.addEntityReference(
systemId,
- inheritedReferences.get(systemId));
+ inheritedReference.getValue());
log.debug("entityReferences with system id "
+ systemId
+ " is inherited from the parent.");
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/source/FileSourceSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/source/FileSourceSaxHandler.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/source/FileSourceSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/source/FileSourceSaxHandler.java Tue Sep 14 04:33:52 2010
@@ -152,7 +152,7 @@ public class FileSourceSaxHandler extend
{
throw new SAXException("Unknown source format : "
+ format
- + " Known types are: " + sourceFormat);
+ + " Known types are: " + sourceFormats);
}
}
Fileset sourceFileset = new Fileset(
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/file/Fileset.java Tue Sep 14 04:33:52 2010
@@ -247,7 +247,7 @@ public class Fileset
if (log.isTraceEnabled())
{
log.trace("getAllFiles() : Adding files "
- + filesInDir
+ + Arrays.toString(filesInDir)
+ " to candidate list");
}
toAddTo.addAll(Arrays.asList(filesInDir));
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/SourceElement.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/SourceElement.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/SourceElement.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/SourceElement.java Tue Sep 14 04:33:52 2010
@@ -614,16 +614,7 @@ public class SourceElement
}
else
{
- if (child instanceof SourceElement)
- {
-
- ((SourceElement) child).toString(
- alreadyProcessed, result);
- }
- else
- {
- result.append(child);
- }
+ child.toString(alreadyProcessed, result);
}
if (childIt.hasNext())
{
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSource.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSource.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSource.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/jdbc/JdbcMetadataSource.java Tue Sep 14 04:33:52 2010
@@ -49,6 +49,71 @@ import org.apache.torque.generator.sourc
*/
public class JdbcMetadataSource extends SourceImpl
{
+ /**
+ * The position in table metadata containing the table name.
+ */
+ private static final int TABLE_NAME_POS_IN_TABLE_METADATA = 3;
+
+ /**
+ * The position in column metadata containing the column name.
+ */
+ private static final int COLUMN_NAME_POS_IN_COLUMN_METADATA = 4;
+
+ /**
+ * The position in column metadata containing the data type
+ * (as SQL type from java.sql.Types).
+ */
+ private static final int DATA_TYPE_POS_COLUMN_METADATA = 5;
+
+ /**
+ * The position in column metadata containing the column size.
+ */
+ private static final int COLUMN_SIZE_POS_IN_COLUMN_METADATA = 7;
+
+ /**
+ * The position in column metadata containing the number
+ * of fractional digits.
+ */
+ private static final int DECIMAL_DIGITS_POS_IN_COLUMN_METADATA = 9;
+
+ /**
+ * The position in column metadata telling whether null is allowed as value
+ * for that column.
+ */
+ private static final int NULLABLE_POS_IN_COLUMN_METADATA = 11;
+
+ /**
+ * The position in column metadata containing the column's default value.
+ */
+ private static final int DEFAULT_VALUE_POS_IN_COLUMN_METADATA = 13;
+
+ /**
+ * The position in primary key metadata containing the column name.
+ */
+ private static final int COLUMN_NAME_POS_IN_PRIMARY_KEY_METADATA = 4;
+
+ /**
+ * The position in foreign key metadata containing the column name.
+ */
+ private static final int TABLE_NAME_POS_IN_FOREIGN_KEY_METADATA = 3;
+
+ /**
+ * The position in foreign key metadata containing the foreign column name.
+ */
+ private static final int FOREIGN_COLUMN_NAME_POS_IN_FOREIGN_KEY_METADATA
+ = 4;
+
+ /**
+ * The position in foreign key metadata containing the localcolumn name.
+ */
+ private static final int LOCAL_COLUMN_NAME_POS_IN_FOREIGN_KEY_METADATA = 8;
+
+ /**
+ * The position in foreign key metadata containing the foreign key name.
+ */
+ private static final int FOREIGN_KEY_NAME_POS_IN_FOREIGN_KEY_METADATA = 12;
+
+
/** The class log. */
private static Log log = LogFactory.getLog(JdbcMetadataSource.class);
@@ -268,7 +333,8 @@ public class JdbcMetadataSource extends
tableNames = dbMeta.getTables(null, dbSchema, "%", types);
while (tableNames.next())
{
- String name = tableNames.getString(3);
+ String name = tableNames.getString(
+ TABLE_NAME_POS_IN_TABLE_METADATA);
tables.add(name);
}
}
@@ -306,12 +372,18 @@ public class JdbcMetadataSource extends
columnSet = dbMeta.getColumns(null, dbSchema, tableName, null);
while (columnSet.next())
{
- String name = columnSet.getString(4);
- Integer sqlType = new Integer(columnSet.getString(5));
- Integer size = new Integer(columnSet.getInt(7));
- Integer decimalDigits = new Integer(columnSet.getInt(9));
- Integer nullType = new Integer(columnSet.getInt(11));
- String defValue = columnSet.getString(13);
+ String name = columnSet.getString(
+ COLUMN_NAME_POS_IN_COLUMN_METADATA);
+ Integer sqlType = Integer.valueOf(columnSet.getString(
+ DATA_TYPE_POS_COLUMN_METADATA));
+ Integer size = Integer.valueOf(columnSet.getInt(
+ COLUMN_SIZE_POS_IN_COLUMN_METADATA));
+ Integer decimalDigits = Integer.valueOf(columnSet.getInt(
+ DECIMAL_DIGITS_POS_IN_COLUMN_METADATA));
+ Integer nullType = Integer.valueOf(columnSet.getInt(
+ NULLABLE_POS_IN_COLUMN_METADATA));
+ String defValue = columnSet.getString(
+ DEFAULT_VALUE_POS_IN_COLUMN_METADATA);
ColumnMetadata column = new ColumnMetadata(
name,
@@ -355,7 +427,8 @@ public class JdbcMetadataSource extends
parts = dbMeta.getPrimaryKeys(null, schemaName, tableName);
while (parts.next())
{
- pk.add(parts.getString(4));
+ pk.add(parts.getString(
+ COLUMN_NAME_POS_IN_PRIMARY_KEY_METADATA));
}
}
finally
@@ -390,8 +463,10 @@ public class JdbcMetadataSource extends
resultSet = dbMeta.getImportedKeys(null, schemaName, tableName);
while (resultSet.next())
{
- String refTableName = resultSet.getString(3);
- String fkName = resultSet.getString(12);
+ String refTableName = resultSet.getString(
+ TABLE_NAME_POS_IN_FOREIGN_KEY_METADATA);
+ String fkName = resultSet.getString(
+ FOREIGN_KEY_NAME_POS_IN_FOREIGN_KEY_METADATA);
// if FK has no name - make it up (use tablename instead)
if (fkName == null)
{
@@ -405,8 +480,10 @@ public class JdbcMetadataSource extends
fk.setForeignKeyName(fkName);
foreignKeys.put(fkName, fk);
}
- fk.getLocalColumns().add(resultSet.getString(8));
- fk.getForeignColumns().add(resultSet.getString(4));
+ fk.getLocalColumns().add(resultSet.getString(
+ LOCAL_COLUMN_NAME_POS_IN_FOREIGN_KEY_METADATA));
+ fk.getForeignColumns().add(resultSet.getString(
+ FOREIGN_COLUMN_NAME_POS_IN_FOREIGN_KEY_METADATA));
}
}
catch (SQLException e)
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/FileSourceProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/FileSourceProvider.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/FileSourceProvider.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/FileSourceProvider.java Tue Sep 14 04:33:52 2010
@@ -142,7 +142,7 @@ public class FileSourceProvider extends
paths = null;
pathIt = null;
streamSourceFormats = null;
- controllerState = null;
+ this.controllerState = null;
}
public boolean hasNext()
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/PropertiesSourceFormat.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/PropertiesSourceFormat.java?rev=996754&r1=996753&r2=996754&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/PropertiesSourceFormat.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/source/stream/PropertiesSourceFormat.java Tue Sep 14 04:33:52 2010
@@ -136,7 +136,7 @@ public final class PropertiesSourceForma
}
/**
- * Returns a hash code of this instance consistent with equals..
+ * Returns a hash code of this instance consistent with equals.
* As all instances of this class are equal to each other,
* the hash code is always the same.
*
@@ -205,6 +205,7 @@ public final class PropertiesSourceForma
/**
* Returns the set of keys, ordered by the order of addition.
+ *
* @return the ordered set of keys, not null.
* The returned set is unmodifiable.
*/
@@ -212,5 +213,49 @@ public final class PropertiesSourceForma
{
return Collections.unmodifiableSet(keySet);
}
+
+ /**
+ * Returns a hash code consistent with equals().
+ *
+ * @return a hash code consistent with equals().
+ */
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Returns whether this object is equal to another object.
+ * This object is considered equal to another object if
+ * the other object has the same class and if it has the same
+ * content in the same order as this object.
+ *
+ * @param obj the object to compare.
+ *
+ * @return true if the other object is equal, false otherwise.
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (!super.equals(obj))
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ OrderedProperties other = (OrderedProperties) obj;
+ if (!keySet.equals(other.keySet))
+ {
+ return false;
+ }
+ return true;
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org