tidy-up copyright header, imports and comments
split test and visitor into separate classes
(thats how it was done originally, but I made them nested static
classes, then changed my mind!)
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/AllTests.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/AllTests.java
index f07fbdc..12c5eab 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/AllTests.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/AllTests.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test;
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/TestHelper.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/TestHelper.java
index 6cefbcd..6b48720 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/TestHelper.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/TestHelper.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test;
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/DatabaseTypeBuilderTestSuite.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/DatabaseTypeBuilderTestSuite.java
index 08da383..65c9972 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/DatabaseTypeBuilderTestSuite.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/DatabaseTypeBuilderTestSuite.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.databasetypebuilder;
@@ -25,7 +26,6 @@
//testing imports
import org.eclipse.persistence.tools.oracleddl.test.AllTests;
import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder;
-
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.buildConnection;
@RunWith(Suite.class)
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/IOTTableDDLTestSuite.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/IOTTableDDLTestSuite.java
index 83b6723..ecfb77a 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/IOTTableDDLTestSuite.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/IOTTableDDLTestSuite.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.databasetypebuilder;
@@ -26,7 +27,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-//Oracleddl (domain) imports
+
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType;
import org.eclipse.persistence.tools.oracleddl.metadata.FieldType;
import org.eclipse.persistence.tools.oracleddl.metadata.NumericType;
@@ -38,7 +40,6 @@
//testing imports
import org.eclipse.persistence.tools.oracleddl.test.AllTests;
-
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.buildConnection;
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.createTable;
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.dropTable;
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TableDDLTestSuite.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TableDDLTestSuite.java
index 2b9b9ae..a2ad00f 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TableDDLTestSuite.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TableDDLTestSuite.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.databasetypebuilder;
@@ -27,7 +28,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-//Oracleddl (domain) imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType;
import org.eclipse.persistence.tools.oracleddl.metadata.FieldType;
import org.eclipse.persistence.tools.oracleddl.metadata.ScalarDatabaseTypeEnum;
@@ -38,7 +39,6 @@
//testing imports
import org.eclipse.persistence.tools.oracleddl.test.AllTests;
-
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.buildConnection;
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.createTable;
import static org.eclipse.persistence.tools.oracleddl.test.TestHelper.dropTable;
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TransformsTestSuite.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TransformsTestSuite.java
index 5c14fc3..4a2845a 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TransformsTestSuite.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/databasetypebuilder/TransformsTestSuite.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.databasetypebuilder;
@@ -24,9 +25,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-//testing imports
-
-//Oracleddl (domain) imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder;
import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilderException;
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/ddlparser/DDLParserTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/ddlparser/DDLParserTest.java
index 19fa69f..6c99840 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/ddlparser/DDLParserTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/ddlparser/DDLParserTest.java
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.ddlparser;
//javase imports
@@ -10,11 +23,11 @@
import org.junit.BeforeClass;
//import org.junit.Ignore;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
-//DDL parser imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.FieldType;
import org.eclipse.persistence.tools.oracleddl.metadata.NumericType;
import org.eclipse.persistence.tools.oracleddl.metadata.TableType;
@@ -24,8 +37,6 @@
import org.eclipse.persistence.tools.oracleddl.parser.ParseException;
import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypesRepository;
-import static org.junit.Assert.assertEquals;
-
public class DDLParserTest {
//JUnit fixture(s)
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeTest.java
index 7ca08ca..650a693 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeTest.java
@@ -8,14 +8,11 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
- * David McCann - July 22, 2011 - 2.4 - Initial implementation
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;
-//javase imports
-import java.util.ArrayList;
-import java.util.List;
-
//JUnit4 imports
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -26,7 +23,6 @@
import org.eclipse.persistence.tools.oracleddl.metadata.FloatType;
import org.eclipse.persistence.tools.oracleddl.metadata.FunctionType;
import org.eclipse.persistence.tools.oracleddl.metadata.VarCharType;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
/**
* Test FunctionType visit method chain. Ensures that all required
@@ -65,46 +61,5 @@
function.accept(visitor);
assertEquals("FunctionType test failed:\n" + visitor.toString(), visitor.toString(), FUNCTION);
}
-
- static class FunctionTypeVisitor extends BaseDatabaseTypeVisitor {
- public String funcName;
- public String schema;
- public List<String> argData = new ArrayList<String>();
- public String returnArg;
-
- public void beginVisit(FunctionType funcType) {
- funcName = funcType.getProcedureName();
- schema = funcType.getSchema();
- returnArg = funcType.getReturnArgument().getTypeName();
- }
-
- public void beginVisit(ArgumentType argType) {
- if (argType.optional()) {
- argData.add(argType.getArgumentName() + "(opt) " + argType.getDirection() + " " + argType.getDataType());
- } else {
- argData.add(argType.getArgumentName() + " " + argType.getDirection() + " " + argType.getDataType());
- }
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder("FUNCTION ");
- if (schema != null) {
- sb.append(schema);
- sb.append(".");
- }
- sb.append(funcName);
- sb.append(" (");
- for(int i=0; i<argData.size();) {
- String arg = argData.get(i);
- sb.append(arg);
- if (++i < argData.size()) {
- sb.append(", ");
- }
- }
- sb.append(") RETURN ");
- sb.append(returnArg);
- return sb.toString();
- }
- }
}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeVisitor.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeVisitor.java
new file mode 100644
index 0000000..361fc79
--- /dev/null
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/FunctionTypeVisitor.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
+package org.eclipse.persistence.tools.oracleddl.test.visit;
+
+//javase imports
+import java.util.ArrayList;
+import java.util.List;
+
+//DDL imports
+import org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType;
+import org.eclipse.persistence.tools.oracleddl.metadata.FunctionType;
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
+
+class FunctionTypeVisitor extends BaseDatabaseTypeVisitor {
+
+ public String funcName;
+ public String schema;
+ public List<String> argData = new ArrayList<String>();
+ public String returnArg;
+
+ public void beginVisit(FunctionType funcType) {
+ funcName = funcType.getProcedureName();
+ schema = funcType.getSchema();
+ returnArg = funcType.getReturnArgument().getTypeName();
+ }
+
+ public void beginVisit(ArgumentType argType) {
+ if (argType.optional()) {
+ argData.add(argType.getArgumentName() + "(opt) " + argType.getDirection() + " " + argType.getDataType());
+ } else {
+ argData.add(argType.getArgumentName() + " " + argType.getDirection() + " " + argType.getDataType());
+ }
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder("FUNCTION ");
+ if (schema != null) {
+ sb.append(schema);
+ sb.append(".");
+ }
+ sb.append(funcName);
+ sb.append(" (");
+ for(int i=0; i<argData.size();) {
+ String arg = argData.get(i);
+ sb.append(arg);
+ if (++i < argData.size()) {
+ sb.append(", ");
+ }
+ }
+ sb.append(") RETURN ");
+ sb.append(returnArg);
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalTypeTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalTypeTest.java
index ad06abd..b35a576 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalTypeTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalTypeTest.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
- * David McCann - July 22, 2011 - 2.4 - Initial implementation
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;
@@ -17,10 +18,9 @@
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-//DDL parser imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.IntervalDayToSecond;
import org.eclipse.persistence.tools.oracleddl.metadata.IntervalYearToMonth;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
/**
* Test Interval visit method chain. Ensures that all required
@@ -67,31 +67,4 @@
yearToMonth.accept(visitor);
assertEquals("IntervalYearToMonth(1L) test failed:\n", visitor.toString(), IYTM_1);
}
-
- /**
- * Visitor for use with IntervalDayToSecond and IntervalYearToMonth.
- * The visit methods simply gather all relevant information such
- * that it can be returned as a String when visiting is complete.
- */
- static class IntervalVisitor extends BaseDatabaseTypeVisitor {
- //protected long dayPrecision;
- //protected long secondPrecision;
- //protected long yearPrecision;
- protected String typeName;
-
- public void visit(IntervalDayToSecond databaseType) {
- //dayPrecision = databaseType.getDayPrecision();
- //secondPrecision = databaseType.getSecondPrecision();
- typeName = databaseType.getTypeName();
- }
-
- public void visit(IntervalYearToMonth databaseType) {
- //yearPrecision = databaseType.getYearPrecision();
- typeName = databaseType.getTypeName();
- }
-
- public String toString() {
- return typeName;
- }
- }
}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalVisitor.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalVisitor.java
new file mode 100644
index 0000000..1b6a70a
--- /dev/null
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/IntervalVisitor.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
+package org.eclipse.persistence.tools.oracleddl.test.visit;
+
+//DDL imports
+import org.eclipse.persistence.tools.oracleddl.metadata.IntervalDayToSecond;
+import org.eclipse.persistence.tools.oracleddl.metadata.IntervalYearToMonth;
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
+
+/**
+ * Visitor for use with IntervalDayToSecond and IntervalYearToMonth.
+ * The visit methods simply gather all relevant information such
+ * that it can be returned as a String when visiting is complete.
+ */
+class IntervalVisitor extends BaseDatabaseTypeVisitor {
+ //protected long dayPrecision;
+ //protected long secondPrecision;
+ //protected long yearPrecision;
+ protected String typeName;
+
+ public void visit(IntervalDayToSecond databaseType) {
+ //dayPrecision = databaseType.getDayPrecision();
+ //secondPrecision = databaseType.getSecondPrecision();
+ typeName = databaseType.getTypeName();
+ }
+
+ public void visit(IntervalYearToMonth databaseType) {
+ //yearPrecision = databaseType.getYearPrecision();
+ typeName = databaseType.getTypeName();
+ }
+
+ public String toString() {
+ return typeName;
+ }
+}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeTest.java
index 5394786..b5a8900 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeTest.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
- * David McCann - July 22, 2011 - 2.4 - Initial implementation
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;
@@ -17,14 +18,13 @@
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-//DDL parser imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.DecimalType;
import org.eclipse.persistence.tools.oracleddl.metadata.DoubleType;
import org.eclipse.persistence.tools.oracleddl.metadata.FloatType;
import org.eclipse.persistence.tools.oracleddl.metadata.NumericType;
import org.eclipse.persistence.tools.oracleddl.metadata.PrecisionType;
import org.eclipse.persistence.tools.oracleddl.metadata.RealType;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
/**
* Test SizedType visit method chain. Ensures that all required
@@ -147,54 +147,5 @@
realType.accept(visitor);
assertEquals("RealType(LONG_19, LONG_1) test failed:\n", visitor.toString(), REAL_19);
}
-
- static class PrecisionTypeVisitor extends BaseDatabaseTypeVisitor {
-
- protected String typeName;
- protected long precision;
- protected long defaultPrecision;
- protected long scale;
-
- public void visit(PrecisionType databaseType) {
- typeName = databaseType.getTypeName();
- precision = databaseType.getPrecision();
- defaultPrecision = databaseType.getDefaultPrecision();
- scale = databaseType.getScale();
- }
-
- public void visit(DecimalType databaseType) {
- visit((PrecisionType)databaseType);
- }
-
- public void visit(DoubleType databaseType) {
- visit((PrecisionType)databaseType);
- }
-
- public void visit(FloatType databaseType) {
- visit((PrecisionType)databaseType);
- }
-
- public void visit(NumericType databaseType) {
- visit((PrecisionType)databaseType);
- }
-
- public void visit(RealType databaseType) {
- visit((PrecisionType)databaseType);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder(typeName);
- if (precision != defaultPrecision) {
- sb.append('(');
- sb.append(precision);
- if (scale != 0) {
- sb.append(',');
- sb.append(scale);
- }
- sb.append(')');
- }
- return sb.toString();
- }
- }
}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeVisitor.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeVisitor.java
new file mode 100644
index 0000000..d06f226
--- /dev/null
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/PrecisionTypeVisitor.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
+package org.eclipse.persistence.tools.oracleddl.test.visit;
+
+//DDL imports
+import org.eclipse.persistence.tools.oracleddl.metadata.DecimalType;
+import org.eclipse.persistence.tools.oracleddl.metadata.DoubleType;
+import org.eclipse.persistence.tools.oracleddl.metadata.FloatType;
+import org.eclipse.persistence.tools.oracleddl.metadata.NumericType;
+import org.eclipse.persistence.tools.oracleddl.metadata.PrecisionType;
+import org.eclipse.persistence.tools.oracleddl.metadata.RealType;
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
+
+class PrecisionTypeVisitor extends BaseDatabaseTypeVisitor {
+
+ protected String typeName;
+ protected long precision;
+ protected long defaultPrecision;
+ protected long scale;
+
+ public void visit(PrecisionType databaseType) {
+ typeName = databaseType.getTypeName();
+ precision = databaseType.getPrecision();
+ defaultPrecision = databaseType.getDefaultPrecision();
+ scale = databaseType.getScale();
+ }
+
+ public void visit(DecimalType databaseType) {
+ visit((PrecisionType)databaseType);
+ }
+
+ public void visit(DoubleType databaseType) {
+ visit((PrecisionType)databaseType);
+ }
+
+ public void visit(FloatType databaseType) {
+ visit((PrecisionType)databaseType);
+ }
+
+ public void visit(NumericType databaseType) {
+ visit((PrecisionType)databaseType);
+ }
+
+ public void visit(RealType databaseType) {
+ visit((PrecisionType)databaseType);
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder(typeName);
+ if (precision != defaultPrecision) {
+ sb.append('(');
+ sb.append(precision);
+ if (scale != 0) {
+ sb.append(',');
+ sb.append(scale);
+ }
+ sb.append(')');
+ }
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeTest.java
index c2f85ee..31f4ed5 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeTest.java
@@ -8,14 +8,11 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
- * David McCann - July 22, 2011 - 2.4 - Initial implementation
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;
-//javase imports
-import java.util.ArrayList;
-import java.util.List;
-
//JUnit4 imports
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -27,7 +24,6 @@
import org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType;
import org.eclipse.persistence.tools.oracleddl.metadata.VarChar2Type;
import org.eclipse.persistence.tools.oracleddl.metadata.VarCharType;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
/**
* Test ProcedureType visit method chain. Ensures that all required
@@ -72,49 +68,5 @@
assertEquals("ProcedureTypeVisitor test failed:\n", visitor.toString(), PROCEDURE);
//System.out.print(procedure.toString());
}
-
-
- /**
- * Visitor for use with ProcedureType. The visit methods
- * simply gather all relevant information such that it
- * can be returned as a String when visiting is complete.
- */
- static class ProcedureTypeVisitor extends BaseDatabaseTypeVisitor {
- public String procName;
- public String schema;
- public List<String> argData = new ArrayList<String>();
-
- public void beginVisit(ProcedureType procType) {
- procName = procType.getProcedureName();
- schema = procType.getSchema();
- }
-
- public void beginVisit(ArgumentType argType) {
- if (argType.optional()) {
- argData.add(argType.getArgumentName() + "(opt) " + argType.getDirection() + " " + argType.getDataType());
- } else {
- argData.add(argType.getArgumentName() + " " + argType.getDirection() + " " + argType.getDataType());
- }
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder("PROCEDURE ");
- if (schema != null) {
- sb.append(schema);
- sb.append(".");
- }
- sb.append(procName);
- sb.append(" (");
- for (int i=0; i<argData.size();) {
- String arg = argData.get(i);
- sb.append(arg);
- if (++i < argData.size()) {
- sb.append(", ");
- }
- }
- sb.append(")");
- return sb.toString();
- }
- }
}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeVisitor.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeVisitor.java
new file mode 100644
index 0000000..0c3c618
--- /dev/null
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/ProcedureTypeVisitor.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
+package org.eclipse.persistence.tools.oracleddl.test.visit;
+
+//javase imports
+import java.util.ArrayList;
+import java.util.List;
+
+//DDL imports
+import org.eclipse.persistence.tools.oracleddl.metadata.ArgumentType;
+import org.eclipse.persistence.tools.oracleddl.metadata.ProcedureType;
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
+
+/**
+ * Visitor for use with ProcedureType. The visit methods
+ * simply gather all relevant information such that it
+ * can be returned as a String when visiting is complete.
+ */
+class ProcedureTypeVisitor extends BaseDatabaseTypeVisitor {
+ public String procName;
+ public String schema;
+ public List<String> argData = new ArrayList<String>();
+
+ public void beginVisit(ProcedureType procType) {
+ procName = procType.getProcedureName();
+ schema = procType.getSchema();
+ }
+
+ public void beginVisit(ArgumentType argType) {
+ if (argType.optional()) {
+ argData.add(argType.getArgumentName() + "(opt) " + argType.getDirection() + " " + argType.getDataType());
+ } else {
+ argData.add(argType.getArgumentName() + " " + argType.getDirection() + " " + argType.getDataType());
+ }
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder("PROCEDURE ");
+ if (schema != null) {
+ sb.append(schema);
+ sb.append(".");
+ }
+ sb.append(procName);
+ sb.append(" (");
+ for (int i=0; i<argData.size();) {
+ String arg = argData.get(i);
+ sb.append(arg);
+ if (++i < argData.size()) {
+ sb.append(", ");
+ }
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeTest.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeTest.java
index 783717d..6874e82 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeTest.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeTest.java
@@ -8,7 +8,8 @@
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
- * David McCann - July 22, 2011 - 2.4 - Initial implementation
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;
@@ -17,7 +18,7 @@
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-//DDL parser imports
+//DDL imports
import org.eclipse.persistence.tools.oracleddl.metadata.BinaryType;
import org.eclipse.persistence.tools.oracleddl.metadata.BlobType;
import org.eclipse.persistence.tools.oracleddl.metadata.CharType;
@@ -32,7 +33,6 @@
import org.eclipse.persistence.tools.oracleddl.metadata.URowIdType;
import org.eclipse.persistence.tools.oracleddl.metadata.VarChar2Type;
import org.eclipse.persistence.tools.oracleddl.metadata.VarCharType;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
/**
* Test SizedType visit method chain. Ensures that all required
@@ -248,71 +248,4 @@
nVarchar2Type.accept(visitor);
assertEquals("NVarChar2Type(L10) test failed:\n", visitor.toString(), NVARCHAR2_10);
}
-
- /**
- * Visitor for use with SizedType. The visit methods simply
- * gather all relevant information such that it can be
- * returned as a String when visiting is complete.
- */
- static class SizedTypeVisitor extends BaseDatabaseTypeVisitor {
- protected long size;
- protected long defaultSize;
- protected String typeName;
-
- public void visit(SizedType databaseType) {
- size = databaseType.getSize();
- typeName = databaseType.getTypeName();
- defaultSize = databaseType.getDefaultSize();
- }
- public void visit(BinaryType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(BlobType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(LongRawType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(RawType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(CharType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(NCharType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(ClobType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(NClobType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(URowIdType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(VarCharType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(VarChar2Type databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(LongType databaseType) {
- visit((SizedType)databaseType);
- }
- public void visit(NVarChar2Type databaseType) {
- visit((SizedType)databaseType);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder(typeName);
- if (size != defaultSize) {
- sb.append('(');
- sb.append(size);
- sb.append(')');
- }
- return sb.toString();
-
- }
- }
}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeVisitor.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeVisitor.java
new file mode 100644
index 0000000..31b997c
--- /dev/null
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/SizedTypeVisitor.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
+ ******************************************************************************/
+package org.eclipse.persistence.tools.oracleddl.test.visit;
+
+//DDL imports
+import org.eclipse.persistence.tools.oracleddl.metadata.BinaryType;
+import org.eclipse.persistence.tools.oracleddl.metadata.BlobType;
+import org.eclipse.persistence.tools.oracleddl.metadata.CharType;
+import org.eclipse.persistence.tools.oracleddl.metadata.ClobType;
+import org.eclipse.persistence.tools.oracleddl.metadata.LongRawType;
+import org.eclipse.persistence.tools.oracleddl.metadata.LongType;
+import org.eclipse.persistence.tools.oracleddl.metadata.NCharType;
+import org.eclipse.persistence.tools.oracleddl.metadata.NClobType;
+import org.eclipse.persistence.tools.oracleddl.metadata.NVarChar2Type;
+import org.eclipse.persistence.tools.oracleddl.metadata.RawType;
+import org.eclipse.persistence.tools.oracleddl.metadata.SizedType;
+import org.eclipse.persistence.tools.oracleddl.metadata.URowIdType;
+import org.eclipse.persistence.tools.oracleddl.metadata.VarChar2Type;
+import org.eclipse.persistence.tools.oracleddl.metadata.VarCharType;
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
+
+/**
+ * Visitor for use with SizedType. The visit methods simply
+ * gather all relevant information such that it can be
+ * returned as a String when visiting is complete.
+ */
+class SizedTypeVisitor extends BaseDatabaseTypeVisitor {
+ protected long size;
+ protected long defaultSize;
+ protected String typeName;
+
+ public void visit(SizedType databaseType) {
+ size = databaseType.getSize();
+ typeName = databaseType.getTypeName();
+ defaultSize = databaseType.getDefaultSize();
+ }
+ public void visit(BinaryType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(BlobType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(LongRawType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(RawType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(CharType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(NCharType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(ClobType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(NClobType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(URowIdType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(VarCharType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(VarChar2Type databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(LongType databaseType) {
+ visit((SizedType)databaseType);
+ }
+ public void visit(NVarChar2Type databaseType) {
+ visit((SizedType)databaseType);
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder(typeName);
+ if (size != defaultSize) {
+ sb.append('(');
+ sb.append(size);
+ sb.append(')');
+ }
+ return sb.toString();
+
+ }
+}
\ No newline at end of file
diff --git a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/VisitorsTestSuite.java b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/VisitorsTestSuite.java
index 17aa023..3839b91 100644
--- a/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/VisitorsTestSuite.java
+++ b/java/src/org/eclipse/persistence/tools/oracleddl/test/visit/VisitorsTestSuite.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Mike Norman - June 10 2011, created DDL parser package
+ * David McCann - July 2011, visit tests
******************************************************************************/
package org.eclipse.persistence.tools.oracleddl.test.visit;