- Revision
- 574
- Author
- rfscholte
- Date
- 2009-03-02 16:55:10 -0600 (Mon, 02 Mar 2009)
Log Message
renamed JavaModelObject's toString() to getCodeBlock()
Modified Paths
- trunk/qdox/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java
- trunk/qdox/src/site/content/upgrade.html
- trunk/qdox/src/test/com/thoughtworks/qdox/MethodsTest.java
- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaClassTest.java
- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java
- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java
Diff
Modified: trunk/qdox/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java (573 => 574)
--- trunk/qdox/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java 2009-03-02 22:55:10 UTC (rev 574) @@ -96,7 +96,7 @@ } } - public String toString() { + public String getCodeBlock() { IndentBuffer result = new IndentBuffer(); write(result); return result.toString();
Modified: trunk/qdox/src/site/content/upgrade.html (573 => 574)
--- trunk/qdox/src/site/content/upgrade.html 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/site/content/upgrade.html 2009-03-02 22:55:10 UTC (rev 574) @@ -3,6 +3,16 @@ <title>Upgrading</title> </head> <body> + <h2>Upgrading to 1.10 or above</h2> + <p> + This section describes what needs to be done when upgrading to QDox + 1.9.</a>. + </p> + <h2>Things that might break your code</h2> + <p> The toString()-method in most of the JavaObjects under com.thoughtworks.qdox.models used to return the corresponding codeblock. + This method has been renamed to getCodeBlock(). The toString() will follow the Java API Specs as described for each equivalent object under the java.lang.reflect-package. + </p> + <h2>Upgrading to 1.9 or above</h2> <p> This section describes what needs to be done when upgrading to QDox
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/MethodsTest.java (573 => 574)
--- trunk/qdox/src/test/com/thoughtworks/qdox/MethodsTest.java 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/test/com/thoughtworks/qdox/MethodsTest.java 2009-03-02 22:55:10 UTC (rev 574) @@ -38,7 +38,7 @@ public void testVarArgsIncludedInToString() { JavaMethod javaMethod = buildMethod("void doStuff(AThing param1, BThing... param2);"); - assertEquals("void doStuff(AThing param1, BThing... param2);\n", javaMethod.toString()); + assertEquals("void doStuff(AThing param1, BThing... param2);\n", javaMethod.getCodeBlock()); } private JavaMethod buildMethod(String methodSource) {
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaClassTest.java (573 => 574)
--- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaClassTest.java 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaClassTest.java 2009-03-02 22:55:10 UTC (rev 574) @@ -20,46 +20,46 @@ src.addClass(cls); } - public void testToStringSimpleClass() throws Exception { + public void testGetCodeBlockSimpleClass() throws Exception { cls.setName("MyClass"); String expected = "" + "class MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringSimpleInterface() throws Exception { + public void testGetCodeBlockSimpleInterface() throws Exception { cls.setName("MyClass"); cls.setInterface(true); String expected = "" + "interface MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringSimpleEnum() throws Exception { + public void testGetCodeBlockSimpleEnum() throws Exception { cls.setName("MyEnum"); cls.setEnum(true); String expected = "" + "enum MyEnum {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassExtends() throws Exception { + public void testGetCodeBlockClassExtends() throws Exception { cls.setName("MyClass"); cls.setSuperClass(new Type("SuperClass")); String expected = "" + "class MyClass extends SuperClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringInterfaceExtends() throws Exception { + public void testGetCodeBlockInterfaceExtends() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface"})); cls.setInterface(true); @@ -67,10 +67,10 @@ + "interface MyClass extends SomeInterface {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringInterfaceExtendsTwo() throws Exception { + public void testGetCodeBlockInterfaceExtendsTwo() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface"})); cls.setInterface(true); @@ -78,10 +78,10 @@ + "interface MyClass extends SomeInterface, AnotherInterface {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringInterfaceExtendsThree() throws Exception { + public void testGetCodeBlockInterfaceExtendsThree() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface", "Thingy"})); cls.setInterface(true); @@ -89,30 +89,30 @@ + "interface MyClass extends SomeInterface, AnotherInterface, Thingy {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassImplements() throws Exception { + public void testGetCodeBlockClassImplements() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface"})); String expected = "" + "class MyClass implements SomeInterface {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassImplementsTwo() throws Exception { + public void testGetCodeBlockClassImplementsTwo() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface", "Xx"})); String expected = "" + "class MyClass implements SomeInterface, AnotherInterface, Xx {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassImplementsAndExtends() throws Exception { + public void testGetCodeBlockClassImplementsAndExtends() throws Exception { cls.setName("MyClass"); cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface", "Xx"})); cls.setSuperClass(new Type("SubMarine")); @@ -120,37 +120,37 @@ + "class MyClass extends SubMarine implements SomeInterface, AnotherInterface, Xx {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringModifers() throws Exception { + public void testGetCodeBlockModifers() throws Exception { cls.setName("MyClass"); cls.setModifiers(new String[]{"public", "final"}); String expected = "" + "public final class MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringModifersProtectionAlwaysFirst() throws Exception { + public void testGetCodeBlockModifersProtectionAlwaysFirst() throws Exception { cls.setName("MyClass"); cls.setModifiers(new String[]{"final", "public"}); String expected = "" + "public final class MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); cls.setModifiers(new String[]{"abstract", "protected"}); expected = "" + "protected abstract class MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithOneMethod() throws Exception { + public void testGetCodeBlockClassWithOneMethod() throws Exception { cls.setName("MyClass"); JavaMethod mth = new JavaMethod(); mth.setName("doStuff"); @@ -162,10 +162,10 @@ + "\tvoid doStuff();\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithThreeMethods() throws Exception { + public void testGetCodeBlockClassWithThreeMethods() throws Exception { cls.setName("MyClass"); { @@ -199,10 +199,10 @@ + "\tvoid eat();\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithTwoFields() throws Exception { + public void testGetCodeBlockClassWithTwoFields() throws Exception { cls.setName("MyClass"); { @@ -228,10 +228,10 @@ + "\tpublic String thing;\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithInnerClass() throws Exception { + public void testGetCodeBlockClassWithInnerClass() throws Exception { cls.setName("Outer"); JavaClass innerClass = new JavaClass(); innerClass.setName("Inner"); @@ -245,10 +245,10 @@ + "\t}\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithInnerEnum() throws Exception { + public void testGetCodeBlockClassWithInnerEnum() throws Exception { cls.setName("Outer"); JavaClass innerEnum = new JavaClass(); innerEnum.setEnum(true); @@ -263,10 +263,10 @@ + "\t}\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringEnumWithInnerClass() throws Exception { + public void testGetCodeBlockEnumWithInnerClass() throws Exception { cls.setName("Outer"); cls.setEnum(true); JavaClass innerClass = new JavaClass(); @@ -281,11 +281,11 @@ + "\t}\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithComment() throws Exception { + public void testGetCodeBlockClassWithComment() throws Exception { cls.setName("MyClass"); cls.setComment("Hello World"); @@ -296,10 +296,10 @@ + "class MyClass {\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } - public void testToStringClassWithIndentedCommentsForFieldAndMethod() throws Exception { + public void testGetCodeBlockClassWithIndentedCommentsForFieldAndMethod() throws Exception { cls.setName("MyClass"); cls.setComment("Hello World"); @@ -332,7 +332,7 @@ + "\tString thingy();\n" + "\n" + "}\n"; - assertEquals(expected, cls.toString()); + assertEquals(expected, cls.getCodeBlock()); } public void testIsPublic() {
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java (573 => 574)
--- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java 2009-03-02 22:55:10 UTC (rev 574) @@ -8,22 +8,22 @@ super(s); } - public void testToString() throws Exception { + public void testGetCodeBlock() throws Exception { JavaField fld = new JavaField(); fld.setName("count"); fld.setType(new Type("int")); - assertEquals("int count;\n", fld.toString()); + assertEquals("int count;\n", fld.getCodeBlock()); } - public void testToStringWithModifiers() throws Exception { + public void testGetCodeBlockWithModifiers() throws Exception { JavaField fld = new JavaField(); fld.setName("count"); fld.setType(new Type("int")); fld.setModifiers(new String[]{"public", "final"}); - assertEquals("public final int count;\n", fld.toString()); + assertEquals("public final int count;\n", fld.getCodeBlock()); } - public void testToStringWithComment() throws Exception { + public void testGetCodeBlockWithComment() throws Exception { JavaField fld = new JavaField(); fld.setName("count"); fld.setType(new Type("int")); @@ -33,32 +33,32 @@ + " * Hello\n" + " */\n" + "int count;\n"; - assertEquals(expected, fld.toString()); + assertEquals(expected, fld.getCodeBlock()); } - public void testToString1dArray() throws Exception { + public void testGetCodeBlock1dArray() throws Exception { JavaField fld = new JavaField(); fld.setName("count"); fld.setType(new Type("int", 1)); String expected = "int[] count;\n"; - assertEquals(expected, fld.toString()); + assertEquals(expected, fld.getCodeBlock()); } - public void testToString2dArray() throws Exception { + public void testGetCodeBlock2dArray() throws Exception { JavaField fld = new JavaField(); fld.setName("count"); fld.setType(new Type("int", 2)); String expected = "int[][] count;\n"; - assertEquals(expected, fld.toString()); + assertEquals(expected, fld.getCodeBlock()); } - public void testToStringWithValue() throws Exception { + public void testGetCodeBlockWithValue() throws Exception { JavaField fld = new JavaField(); fld.setName("stuff"); fld.setType(new Type("String")); fld.setInitializationExpression("STUFF + getThing()"); String expected = "String stuff = STUFF + getThing();\n"; - assertEquals(expected, fld.toString()); + assertEquals(expected, fld.getCodeBlock()); } public void testShouldReturnFieldNameForCallSignature() throws Exception {
Modified: trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java (573 => 574)
--- trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java 2009-03-02 18:26:08 UTC (rev 573) +++ trunk/qdox/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java 2009-03-02 22:55:10 UTC (rev 574) @@ -53,30 +53,30 @@ }); } - public void testToStringSimple() throws Exception { + public void testGetCodeBlockSimple() throws Exception { mth.setName("doSomething"); mth.setReturns(new Type("java.lang.String")); - assertEquals("java.lang.String doSomething();\n", mth.toString()); + assertEquals("java.lang.String doSomething();\n", mth.getCodeBlock()); } - public void testToStringOneParam() throws Exception { + public void testGetCodeBlockOneParam() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setParameters(new JavaParameter[]{new JavaParameter(new Type("String"), "thingy")}); - assertEquals("void blah(String thingy);\n", mth.toString()); + assertEquals("void blah(String thingy);\n", mth.getCodeBlock()); } - public void testToStringTwoParams() throws Exception { + public void testGetCodeBlockTwoParams() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setParameters(new JavaParameter[]{ new JavaParameter(new Type("int"), "count"), new JavaParameter(new Type("MyThing"), "t") }); - assertEquals("void blah(int count, MyThing t);\n", mth.toString()); + assertEquals("void blah(int count, MyThing t);\n", mth.getCodeBlock()); } - public void testToStringThreeParams() throws Exception { + public void testGetCodeBlockThreeParams() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setParameters(new JavaParameter[]{ @@ -84,45 +84,45 @@ new JavaParameter(new Type("MyThing"), "t"), new JavaParameter(new Type("java.lang.Meat"), "beef") }); - assertEquals("void blah(int count, MyThing t, java.lang.Meat beef);\n", mth.toString()); + assertEquals("void blah(int count, MyThing t, java.lang.Meat beef);\n", mth.getCodeBlock()); } - public void testToStringModifiersWithAccessLevelFirst() throws Exception { + public void testGetCodeBlockModifiersWithAccessLevelFirst() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setModifiers(new String[]{"synchronized", "public", "final"}); - assertEquals("public synchronized final void blah();\n", mth.toString()); + assertEquals("public synchronized final void blah();\n", mth.getCodeBlock()); } - public void testToStringOneException() throws Exception { + public void testGetCodeBlockOneException() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setExceptions(new Type[]{new Type("RuntimeException")}); - assertEquals("void blah() throws RuntimeException;\n", mth.toString()); + assertEquals("void blah() throws RuntimeException;\n", mth.getCodeBlock()); } - public void testToStringTwoException() throws Exception { + public void testGetCodeBlockTwoException() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setExceptions(new Type[]{new Type("RuntimeException"), new Type("java.lang.SheepException", 1)}); - assertEquals("void blah() throws RuntimeException, java.lang.SheepException;\n", mth.toString()); + assertEquals("void blah() throws RuntimeException, java.lang.SheepException;\n", mth.getCodeBlock()); } - public void testToStringThreeException() throws Exception { + public void testGetCodeBlockThreeException() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setExceptions(new Type[]{new Type("RuntimeException"), new Type("java.lang.SheepException", 1), new Type("CowException", 1)}); - assertEquals("void blah() throws RuntimeException, java.lang.SheepException, CowException;\n", mth.toString()); + assertEquals("void blah() throws RuntimeException, java.lang.SheepException, CowException;\n", mth.getCodeBlock()); } - public void testToStringConstructor() throws Exception { + public void testGetCodeBlockConstructor() throws Exception { mth.setName("Blah"); mth.setModifiers(new String[]{"public"}); mth.setConstructor(true); - assertEquals("public Blah();\n", mth.toString()); + assertEquals("public Blah();\n", mth.getCodeBlock()); } - public void testToStringWithComment() throws Exception { + public void testGetCodeBlockWithComment() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setComment("Hello"); @@ -131,32 +131,32 @@ + " * Hello\n" + " */\n" + "void blah();\n"; - assertEquals(expect, mth.toString()); + assertEquals(expect, mth.getCodeBlock()); } - public void testToString1dArray() throws Exception { + public void testGetCodeBlock1dArray() throws Exception { mth.setName("doSomething"); mth.setReturns(new Type("java.lang.String", 1)); - assertEquals("java.lang.String[] doSomething();\n", mth.toString()); + assertEquals("java.lang.String[] doSomething();\n", mth.getCodeBlock()); } - public void testToString2dArray() throws Exception { + public void testGetCodeBlock2dArray() throws Exception { mth.setName("doSomething"); mth.setReturns(new Type("java.lang.String", 2)); - assertEquals("java.lang.String[][] doSomething();\n", mth.toString()); + assertEquals("java.lang.String[][] doSomething();\n", mth.getCodeBlock()); } - public void testToStringParamArray() throws Exception { + public void testGetCodeBlockParamArray() throws Exception { mth.setName("blah"); mth.setReturns(new Type("void")); mth.setParameters(new JavaParameter[]{ new JavaParameter(new Type("int", 2), "count"), new JavaParameter(new Type("MyThing", 1), "t") }); - assertEquals("void blah(int[][] count, MyThing[] t);\n", mth.toString()); + assertEquals("void blah(int[][] count, MyThing[] t);\n", mth.getCodeBlock()); } - public void testToStringWithBody() throws Exception { + public void testGetCodeBlockWithBody() throws Exception { mth.setName("doStuff"); mth.setReturns(new Type("java.lang.String")); mth.setSourceCode(" int x = 2;\n return STUFF;\n"); @@ -166,7 +166,7 @@ " int x = 2;\n" + " return STUFF;\n" + "}\n", - mth.toString()); + mth.getCodeBlock()); } public void testEquals() throws Exception {
To unsubscribe from this list please visit:
