[qdox] 01/01: Imported Debian patch 1.12.1-2
Markus Koschany
apo at moszumanska.debian.org
Wed Jul 27 16:33:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
apo pushed a commit to branch master
in repository qdox.
commit 45bef0ba143d2fea7136aa3b2616bb5dcc6084cc
Author: Markus Koschany <apo at debian.org>
Date: Wed Jul 27 18:03:00 2016 +0200
Imported Debian patch 1.12.1-2
---
debian/README.Debian | 10 +
debian/build-classpath | 4 +
debian/build.properties | 5 +
debian/build.xml | 71 +
debian/changelog | 32 +-
debian/clean | 7 -
debian/control | 46 +-
debian/copyright | 3 +-
debian/libqdox-java-doc.doc-base.api | 10 -
debian/libqdox-java-doc.docs | 1 +
debian/libqdox-java-doc.install | 1 -
debian/libqdox-java.poms | 30 +-
debian/maven.ignoreRules | 12 -
debian/maven.properties | 1 -
debian/maven.publishedRules | 3 +-
debian/maven.rules | 6 +-
debian/patches/jflex-1.6.1.patch | 42 +
debian/patches/series | 2 +-
debian/patches/workingDirectory.patch | 33 -
debian/rules | 15 +-
debian/watch | 2 +-
pom.xml | 398 ++-
src/changes/changes.xml | 425 +++
src/grammar/commentlexer.flex | 206 --
src/grammar/commentparser.y | 132 -
src/grammar/lexer.flex | 287 +-
src/grammar/parser.y | 2392 +++++-----------
src/grammar/skeleton.inner | 425 +++
src/it/lambda-examples/LambdaExamples01.zip | Bin 20121 -> 0 bytes
src/it/lambda-examples/invoker.properties | 1 -
src/it/lambda-examples/pom.xml | 22 -
src/it/lambda-examples/test.properties | 2 -
src/it/lambda-examples/verify.groovy | 8 -
src/it/qdox-223/pom.xml | 35 -
src/it/qdox-223/src/main/java/com/AnnotationA.java | 4 -
src/it/qdox-223/src/main/java/com/x/QClass.java | 8 -
.../qdox-223/src/main/java/com/x/package-info.java | 2 -
src/it/qdox-223/src/main/java/com/y/BClass.java | 10 -
.../qdox-223/src/main/java/com/y/package-info.java | 2 -
.../src/test/java/MissingAnnotationsTest.java | 24 -
src/it/qdox-224/pom.xml | 41 -
.../src/test/java/ClasspathSourcesTest.java | 32 -
src/it/qdox-241/pom.xml | 39 -
src/it/qdox-241/src/main/resources/qdox.properties | 1 -
.../qdox-241/src/test/java/QDoxPropertiesTest.java | 21 -
src/it/qdox-241/src/test/resources/Test.java | 46 -
src/it/settings.xml | 55 -
.../thoughtworks/qdox/DefaultJavaClassCache.java | 25 +
.../com/thoughtworks/qdox/JavaClassContext.java | 119 +
src/java/com/thoughtworks/qdox/JavaDocBuilder.java | 559 ++++
src/java/com/thoughtworks/qdox/Searcher.java | 9 +
.../thoughtworks/qdox/ant/AbstractQdoxTask.java | 92 +
.../qdox/directorywalker/DirectoryScanner.java | 54 +
.../qdox/directorywalker/FileVisitor.java | 9 +
.../thoughtworks/qdox/directorywalker/Filter.java | 9 +
.../qdox/directorywalker/SuffixFilter.java | 15 +
.../com/thoughtworks/qdox/junit/APITestCase.java | 345 +++
.../qdox/model/AbstractBaseJavaEntity.java | 66 +
.../qdox/model/AbstractInheritableJavaEntity.java | 16 +
.../qdox/model/AbstractJavaEntity.java | 229 ++
.../com/thoughtworks/qdox/model/Annotation.java | 128 +
.../com/thoughtworks/qdox/model/BeanProperty.java | 46 +
.../com/thoughtworks/qdox/model/ClassLibrary.java | 142 +
.../thoughtworks/qdox/model/DefaultDocletTag.java | 66 +
.../qdox/model/DefaultDocletTagFactory.java | 20 +
.../com/thoughtworks/qdox/model/DocletTag.java | 51 +
.../thoughtworks/qdox/model/DocletTagFactory.java | 21 +
.../com/thoughtworks/qdox/model/IndentBuffer.java | 43 +
.../com/thoughtworks/qdox/model/JavaClass.java | 740 +++++
.../thoughtworks/qdox/model/JavaClassCache.java | 9 +
.../thoughtworks/qdox/model/JavaClassParent.java | 25 +
.../com/thoughtworks/qdox/model/JavaField.java | 103 +
.../com/thoughtworks/qdox/model/JavaMethod.java | 543 ++++
.../qdox/model}/JavaMethodDelegate.java | 231 +-
.../com/thoughtworks/qdox/model/JavaPackage.java | 126 +
.../com/thoughtworks/qdox/model/JavaParameter.java | 82 +
.../com/thoughtworks/qdox/model/JavaSource.java | 346 +++
src/java/com/thoughtworks/qdox/model/Member.java | 11 +
.../com/thoughtworks/qdox/model/ModelBuilder.java | 336 +++
src/java/com/thoughtworks/qdox/model/Type.java | 424 +++
.../com/thoughtworks/qdox/model/TypeVariable.java | 56 +
.../com/thoughtworks/qdox/model/WildcardType.java | 38 +
.../qdox/model/annotation/AnnotationAdd.java | 21 +
.../qdox/model/annotation/AnnotationAnd.java | 21 +
.../model/annotation/AnnotationBinaryOperator.java | 22 +
.../qdox/model/annotation/AnnotationCast.java | 36 +
.../qdox/model/annotation/AnnotationConstant.java | 36 +
.../qdox/model/annotation/AnnotationDivide.java | 21 +
.../qdox/model/annotation/AnnotationEquals.java | 21 +
.../model/annotation/AnnotationExclusiveOr.java | 21 +
.../qdox/model/annotation/AnnotationFieldRef.java | 151 ++
.../model/annotation/AnnotationGreaterEquals.java | 21 +
.../model/annotation/AnnotationGreaterThan.java | 21 +
.../model/annotation/AnnotationLessEquals.java | 21 +
.../qdox/model/annotation/AnnotationLessThan.java | 21 +
.../model/annotation/AnnotationLogicalAnd.java | 21 +
.../model/annotation/AnnotationLogicalNot.java | 20 +
.../qdox/model/annotation/AnnotationLogicalOr.java | 21 +
.../qdox/model/annotation/AnnotationMinusSign.java | 20 +
.../qdox/model/annotation/AnnotationMultiply.java | 21 +
.../qdox/model/annotation/AnnotationNot.java | 20 +
.../qdox/model/annotation/AnnotationNotEquals.java | 21 +
.../qdox/model/annotation/AnnotationOr.java | 21 +
.../annotation/AnnotationParenExpression.java | 27 +
.../qdox/model/annotation/AnnotationPlusSign.java | 20 +
.../qdox/model/annotation/AnnotationQuery.java | 41 +
.../qdox/model/annotation/AnnotationRemainder.java | 21 +
.../qdox/model/annotation/AnnotationShiftLeft.java | 21 +
.../model/annotation/AnnotationShiftRight.java | 21 +
.../qdox/model/annotation/AnnotationSubtract.java | 21 +
.../qdox/model/annotation/AnnotationTypeRef.java | 28 +
.../model/annotation/AnnotationUnaryOperator.java | 15 +
.../annotation/AnnotationUnsignedShiftRight.java | 21 +
.../qdox/model/annotation/AnnotationValue.java | 27 +
.../qdox/model/annotation/AnnotationValueList.java | 54 +
.../qdox/model/annotation/AnnotationVisitor.java | 74 +
.../qdox/model/annotation/EvaluatingVisitor.java | 737 +++++
.../annotation/RecursiveAnnotationVisitor.java | 217 ++
.../thoughtworks/qdox/model/util/OrderedMap.java | 121 +
.../thoughtworks/qdox/model/util/TagParser.java | 47 +-
src/java/com/thoughtworks/qdox/parser/Builder.java | 41 +
src/java/com/thoughtworks/qdox/parser/Lexer.java | 17 +
.../thoughtworks/qdox/parser/ParseException.java | 33 +
.../thoughtworks/qdox/parser/structs/AnnoDef.java | 34 +
.../thoughtworks/qdox/parser/structs/ClassDef.java | 52 +
.../thoughtworks/qdox/parser/structs/FieldDef.java | 50 +
.../qdox/parser/structs/LocatedDef.java | 7 +
.../qdox/parser/structs/MethodDef.java | 66 +
.../qdox/parser/structs/PackageDef.java | 20 +
.../thoughtworks/qdox/parser/structs/TagDef.java | 40 +
.../thoughtworks/qdox/parser/structs/TypeDef.java | 31 +
.../qdox/parser/structs/TypeVariableDef.java | 21 +
.../qdox/parser/structs/WildcardTypeDef.java | 35 +
.../com/thoughtworks/qdox/tools/QDoxTester.java | 41 +-
.../com/thoughtworks/qdox/JavaProjectBuilder.java | 371 ---
src/main/java/com/thoughtworks/qdox/Searcher.java | 40 -
.../com/thoughtworks/qdox/builder/Builder.java | 69 -
.../qdox/builder/ModelBuilderFactory.java | 43 -
.../thoughtworks/qdox/builder/TypeAssembler.java | 107 -
.../impl/DefaultJavaAnnotationAssembler.java | 459 ----
.../qdox/builder/impl/EvaluatingVisitor.java | 986 -------
.../qdox/builder/impl/ModelBuilder.java | 514 ----
.../qdox/builder/impl/package-info.java | 4 -
.../thoughtworks/qdox/builder/package-info.java | 4 -
.../qdox/directorywalker/DirectoryScanner.java | 106 -
.../qdox/directorywalker/FileVisitor.java | 36 -
.../thoughtworks/qdox/directorywalker/Filter.java | 34 -
.../qdox/directorywalker/SuffixFilter.java | 51 -
.../qdox/directorywalker/package-info.java | 4 -
.../qdox/library/AbstractClassLibrary.java | 354 ---
.../thoughtworks/qdox/library/ClassLibrary.java | 96 -
.../qdox/library/ClassLibraryBuilder.java | 182 --
.../qdox/library/ClassLoaderLibrary.java | 232 --
.../qdox/library/ClassNameLibrary.java | 59 -
.../thoughtworks/qdox/library/ErrorHandler.java | 28 -
.../qdox/library/JavaClassContext.java | 157 --
.../qdox/library/OrderedClassLibraryBuilder.java | 334 ---
.../qdox/library/SortedClassLibraryBuilder.java | 176 --
.../qdox/library/SourceFolderLibrary.java | 105 -
.../thoughtworks/qdox/library/SourceLibrary.java | 404 ---
.../thoughtworks/qdox/library/package-info.java | 19 -
.../com/thoughtworks/qdox/model/BeanProperty.java | 57 -
.../com/thoughtworks/qdox/model/DocletTag.java | 82 -
.../thoughtworks/qdox/model/DocletTagFactory.java | 40 -
.../qdox/model/JavaAnnotatedElement.java | 94 -
.../thoughtworks/qdox/model/JavaAnnotation.java | 41 -
.../com/thoughtworks/qdox/model/JavaClass.java | 517 ----
.../thoughtworks/qdox/model/JavaConstructor.java | 109 -
.../com/thoughtworks/qdox/model/JavaField.java | 86 -
.../qdox/model/JavaGenericDeclaration.java | 39 -
.../thoughtworks/qdox/model/JavaInitializer.java | 54 -
.../com/thoughtworks/qdox/model/JavaMember.java | 135 -
.../com/thoughtworks/qdox/model/JavaMethod.java | 190 --
.../com/thoughtworks/qdox/model/JavaModel.java | 46 -
.../thoughtworks/qdox/model/JavaModelUtils.java | 66 -
.../com/thoughtworks/qdox/model/JavaPackage.java | 82 -
.../com/thoughtworks/qdox/model/JavaParameter.java | 110 -
.../qdox/model/JavaParameterizedType.java | 33 -
.../com/thoughtworks/qdox/model/JavaSource.java | 120 -
.../java/com/thoughtworks/qdox/model/JavaType.java | 142 -
.../thoughtworks/qdox/model/JavaTypeVariable.java | 32 -
.../thoughtworks/qdox/model/JavaWildcardType.java | 27 -
.../qdox/model/ParameterDeclarator.java | 13 -
.../thoughtworks/qdox/model/expression/Add.java | 45 -
.../thoughtworks/qdox/model/expression/And.java | 45 -
.../qdox/model/expression/AnnotationValue.java | 38 -
.../qdox/model/expression/AnnotationValueList.java | 88 -
.../qdox/model/expression/Assignment.java | 55 -
.../qdox/model/expression/BinaryOperator.java | 46 -
.../thoughtworks/qdox/model/expression/Cast.java | 62 -
.../qdox/model/expression/Constant.java | 327 ---
.../thoughtworks/qdox/model/expression/Divide.java | 45 -
.../thoughtworks/qdox/model/expression/Equals.java | 45 -
.../qdox/model/expression/ExclusiveOr.java | 45 -
.../qdox/model/expression/Expression.java | 30 -
.../qdox/model/expression/ExpressionVisitor.java | 106 -
.../qdox/model/expression/FieldRef.java | 222 --
.../qdox/model/expression/GreaterEquals.java | 45 -
.../qdox/model/expression/GreaterThan.java | 45 -
.../qdox/model/expression/LessEquals.java | 45 -
.../qdox/model/expression/LessThan.java | 45 -
.../qdox/model/expression/LogicalAnd.java | 45 -
.../qdox/model/expression/LogicalNot.java | 45 -
.../qdox/model/expression/LogicalOr.java | 45 -
.../qdox/model/expression/MethodInvocation.java | 56 -
.../qdox/model/expression/MinusSign.java | 45 -
.../qdox/model/expression/Multiply.java | 45 -
.../thoughtworks/qdox/model/expression/Not.java | 45 -
.../qdox/model/expression/NotEquals.java | 45 -
.../com/thoughtworks/qdox/model/expression/Or.java | 45 -
.../qdox/model/expression/ParenExpression.java | 52 -
.../qdox/model/expression/PlusSign.java | 45 -
.../qdox/model/expression/PostDecrement.java | 47 -
.../qdox/model/expression/PostIncrement.java | 47 -
.../qdox/model/expression/PreDecrement.java | 47 -
.../qdox/model/expression/PreIncrement.java | 47 -
.../thoughtworks/qdox/model/expression/Query.java | 69 -
.../qdox/model/expression/Remainder.java | 45 -
.../qdox/model/expression/ShiftLeft.java | 45 -
.../qdox/model/expression/ShiftRight.java | 45 -
.../qdox/model/expression/Subtract.java | 45 -
.../qdox/model/expression/TypeRef.java | 54 -
.../qdox/model/expression/UnaryOperator.java | 37 -
.../qdox/model/expression/UnsignedShiftRight.java | 45 -
.../qdox/model/expression/package-info.java | 4 -
.../qdox/model/impl/AbstractBaseJavaEntity.java | 120 -
.../qdox/model/impl/AbstractBaseMethod.java | 151 --
.../model/impl/AbstractInheritableJavaEntity.java | 39 -
.../qdox/model/impl/AbstractJavaEntity.java | 176 --
.../qdox/model/impl/AbstractJavaModel.java | 68 -
.../qdox/model/impl/DefaultBeanProperty.java | 81 -
.../qdox/model/impl/DefaultDocletTag.java | 107 -
.../qdox/model/impl/DefaultDocletTagFactory.java | 43 -
.../qdox/model/impl/DefaultJavaAnnotation.java | 167 --
.../qdox/model/impl/DefaultJavaClass.java | 931 -------
.../qdox/model/impl/DefaultJavaConstructor.java | 144 -
.../qdox/model/impl/DefaultJavaField.java | 230 --
.../qdox/model/impl/DefaultJavaInitializer.java | 60 -
.../qdox/model/impl/DefaultJavaMethod.java | 432 ---
.../qdox/model/impl/DefaultJavaPackage.java | 154 --
.../qdox/model/impl/DefaultJavaParameter.java | 193 --
.../model/impl/DefaultJavaParameterizedType.java | 157 --
.../qdox/model/impl/DefaultJavaSource.java | 384 ---
.../qdox/model/impl/DefaultJavaType.java | 978 -------
.../qdox/model/impl/DefaultJavaTypeVariable.java | 184 --
.../qdox/model/impl/DefaultJavaWildcardType.java | 141 -
.../qdox/model/impl/JavaClassParent.java | 48 -
.../thoughtworks/qdox/model/impl/package-info.java | 5 -
.../com/thoughtworks/qdox/model/package-info.java | 5 -
.../thoughtworks/qdox/model/util/package-info.java | 4 -
.../java/com/thoughtworks/qdox/package-info.java | 4 -
.../thoughtworks/qdox/parser/CommentHandler.java | 40 -
.../thoughtworks/qdox/parser/CommentScanner.java | 37 -
.../com/thoughtworks/qdox/parser/JavaLexer.java | 30 -
.../java/com/thoughtworks/qdox/parser/Lexer.java | 36 -
.../thoughtworks/qdox/parser/ParseException.java | 93 -
.../qdox/parser/expression/AddDef.java | 33 -
.../qdox/parser/expression/AndDef.java | 33 -
.../qdox/parser/expression/AssignmentDef.java | 55 -
.../qdox/parser/expression/BinaryOperatorDef.java | 47 -
.../qdox/parser/expression/CastDef.java | 51 -
.../qdox/parser/expression/ConstantDef.java | 49 -
.../qdox/parser/expression/CreatorDef.java | 79 -
.../qdox/parser/expression/DivideDef.java | 33 -
.../qdox/parser/expression/ElemValueDef.java | 7 -
.../qdox/parser/expression/ElemValueListDef.java | 25 -
.../parser/expression/ElemValueTransformer.java | 101 -
.../qdox/parser/expression/EqualsDef.java | 32 -
.../qdox/parser/expression/ExclusiveOrDef.java | 32 -
.../qdox/parser/expression/ExpressionDef.java | 25 -
.../qdox/parser/expression/FieldRefDef.java | 38 -
.../qdox/parser/expression/GreaterEqualsDef.java | 32 -
.../qdox/parser/expression/GreaterThanDef.java | 32 -
.../qdox/parser/expression/LessEqualsDef.java | 32 -
.../qdox/parser/expression/LessThanDef.java | 33 -
.../qdox/parser/expression/LogicalAndDef.java | 32 -
.../qdox/parser/expression/LogicalNotDef.java | 32 -
.../qdox/parser/expression/LogicalOrDef.java | 32 -
.../parser/expression/MethodInvocationDef.java | 50 -
.../qdox/parser/expression/MinusSignDef.java | 32 -
.../qdox/parser/expression/MultiplyDef.java | 33 -
.../qdox/parser/expression/NotDef.java | 32 -
.../qdox/parser/expression/NotEqualsDef.java | 32 -
.../thoughtworks/qdox/parser/expression/OrDef.java | 32 -
.../qdox/parser/expression/ParenExpressionDef.java | 41 -
.../qdox/parser/expression/PlusSignDef.java | 32 -
.../qdox/parser/expression/PostDecrementDef.java | 33 -
.../qdox/parser/expression/PostIncrementDef.java | 33 -
.../qdox/parser/expression/PreDecrementDef.java | 33 -
.../qdox/parser/expression/PreIncrementDef.java | 33 -
.../qdox/parser/expression/QueryDef.java | 64 -
.../qdox/parser/expression/RemainderDef.java | 32 -
.../qdox/parser/expression/ShiftLeftDef.java | 32 -
.../qdox/parser/expression/ShiftRightDef.java | 32 -
.../qdox/parser/expression/SubtractDef.java | 32 -
.../qdox/parser/expression/TypeRefDef.java | 40 -
.../qdox/parser/expression/UnaryOperatorDef.java | 37 -
.../parser/expression/UnsignedShiftRightDef.java | 32 -
.../qdox/parser/expression/package-info.java | 4 -
.../qdox/parser/impl/BinaryClassParser.java | 231 --
.../qdox/parser/impl/package-info.java | 4 -
.../com/thoughtworks/qdox/parser/package-info.java | 4 -
.../thoughtworks/qdox/parser/structs/AnnoDef.java | 55 -
.../thoughtworks/qdox/parser/structs/ClassDef.java | 133 -
.../thoughtworks/qdox/parser/structs/FieldDef.java | 166 --
.../thoughtworks/qdox/parser/structs/InitDef.java | 63 -
.../qdox/parser/structs/LocatedDef.java | 44 -
.../qdox/parser/structs/MethodDef.java | 124 -
.../qdox/parser/structs/PackageDef.java | 42 -
.../thoughtworks/qdox/parser/structs/TagDef.java | 63 -
.../thoughtworks/qdox/parser/structs/TypeDef.java | 83 -
.../qdox/parser/structs/TypeVariableDef.java | 54 -
.../qdox/parser/structs/WildcardTypeDef.java | 54 -
.../qdox/parser/structs/package-info.java | 5 -
.../com/thoughtworks/qdox/tools/package-info.java | 4 -
.../com/thoughtworks/qdox/writer/ModelWriter.java | 184 --
.../qdox/writer/ModelWriterFactory.java | 33 -
.../qdox/writer/impl/DefaultModelWriter.java | 476 ----
.../qdox/writer/impl/IndentBuffer.java | 87 -
.../qdox/writer/impl/package-info.java | 4 -
.../com/thoughtworks/qdox/writer/package-info.java | 4 -
src/site/apt/migrationplan.apt.vm | 70 -
src/site/content/changes.html | 15 +
src/site/content/download.html | 21 +
src/site/content/faq.html | 49 +
src/site/{xhtml/index.xhtml => content/index.html} | 0
.../{xhtml/license.xhtml => content/license.html} | 0
src/site/{xhtml/model.xhtml => content/model.html} | 198 +-
.../{xhtml/upgrade.xhtml => content/upgrade.html} | 2 +-
src/site/{xhtml/usage.xhtml => content/usage.html} | 27 +-
src/site/content/website.xml | 34 +
.../{xhtml/whouses.xhtml => content/whouses.html} | 2 +-
src/site/fml/faq.fml | 60 -
src/site/resources/{images => }/blue2white.jpg | Bin
src/site/resources/{images => }/breadcrumbs.jpg | Bin
src/site/resources/images/arrow_blue_collapsed.png | Bin 1388 -> 0 bytes
src/site/resources/images/arrow_blue_expanded.png | Bin 1412 -> 0 bytes
src/site/resources/{images => }/logo.gif | Bin
src/site/resources/{css => }/style.css | 850 +++---
src/site/resources/{images => }/tekton_logo.png | Bin
src/site/resources/{images => }/white2blue.jpg | Bin
src/site/site.xml | 49 -
src/site/templates/site-template.vm | 15 +
src/site/templates/site.vm | 369 ---
src/site/templates/skin.html | 52 +
src/site/xhtml/download.xhtml | 30 -
src/site/xhtml/migration.xhtml | 34 -
.../resources => test-resources}/qdox-140/X.jav | 0
src/{test/resources => test-resources}/readme.txt | 0
.../thoughtworks/qdox/AnnotationsModelTest.java | 331 +++
.../com/thoughtworks/qdox/AnnotationsTest.java | 267 ++
.../com/thoughtworks/qdox/ClassResolutionTest.java | 96 +
.../com/thoughtworks/qdox/EnumsModelTest.java | 74 +-
.../com/thoughtworks/qdox/EnumsTest.java | 77 +-
src/test/com/thoughtworks/qdox/FieldsTest.java | 61 +
.../com/thoughtworks/qdox/GenericsTest.java | 59 +-
src/test/com/thoughtworks/qdox/JSR14Test.java | 405 +++
.../thoughtworks/qdox/JavaDocBuilderTest.java} | 997 +++----
src/test/com/thoughtworks/qdox/MethodsTest.java | 51 +
src/test/com/thoughtworks/qdox/TestQDoxBug131.java | 30 +
.../qdox/ant/AbstractQdoxTaskTest.java | 128 +
.../qdox/directorywalker/DirectoryScannerTest.java | 136 +
.../qdox/model/AbstractDocletTagTest.java | 37 +-
.../qdox/model/AbstractJavaEntityTest.java | 244 ++
.../thoughtworks/qdox/model/ClassLibraryTest.java | 70 +
.../qdox/model}/DefaultDocletTagTest.java | 7 +-
.../thoughtworks/qdox/model}/IndentBufferTest.java | 21 +-
.../com/thoughtworks/qdox/model/JavaClassTest.java | 639 +++++
.../com/thoughtworks/qdox/model/JavaFieldTest.java | 105 +
.../thoughtworks/qdox/model/JavaMethodTest.java | 397 +++
.../thoughtworks/qdox/model/JavaPackageTest.java | 11 +
.../thoughtworks/qdox/model/JavaParameterTest.java | 20 +
.../thoughtworks/qdox/model/JavaSourceTest.java | 219 ++
.../thoughtworks/qdox/model/ModelBuilderTest.java | 816 ++++++
src/test/com/thoughtworks/qdox/model/TypeTest.java | 86 +
.../qdox/model/util/OrderedMapTest.java | 54 +
.../qdox/model/util/SerializationUtils.java | 6 +-
.../qdox/model/util/TagParserTest.java | 22 +-
.../com/thoughtworks/qdox/parser/LexerTest.java | 310 ++-
.../com/thoughtworks/qdox/parser/MockBuilder.java | 183 ++
.../com/thoughtworks/qdox/parser/MockLexer.java | 38 +
.../com/thoughtworks/qdox/parser/ParserTest.java | 2586 ++++++++++++++++++
.../thoughtworks/qdox/testdata/DefaultCtor.java | 0
.../thoughtworks/qdox/testdata/PropertyClass.java | 0
.../com/thoughtworks/qdox/testdata/Unicode.java | 0
.../thoughtworks/qdox/traversal/TraversalTest.java | 17 +-
.../qdox/AnnotationExpressionTest.java | 169 --
.../thoughtworks/qdox/AnnotationsModelTest.java | 252 --
.../com/thoughtworks/qdox/AnnotationsTest.java | 247 --
.../com/thoughtworks/qdox/ClassResolutionTest.java | 89 -
.../com/thoughtworks/qdox/EmptyTestClasses.java | 8 -
.../java/com/thoughtworks/qdox/FieldsTest.java | 111 -
src/test/java/com/thoughtworks/qdox/JSR14Test.java | 509 ----
.../java/com/thoughtworks/qdox/MethodsTest.java | 63 -
.../qdox/TestMultipleLevelGenericInheritance.java | 90 -
.../qdox/builder/impl/EvaluatingVisitorTest.java | 1336 ---------
.../qdox/builder/impl/ModelBuilderTest.java | 862 ------
.../qdox/directorywalker/DirectoryScannerTest.java | 200 --
.../qdox/directorywalker/SuffixFilterTest.java | 55 -
.../qdox/library/AbstractClassLibraryTest.java | 140 -
.../qdox/library/ClassLibraryBuilderTest.java | 69 -
.../qdox/library/ClassLoaderLibraryTest.java | 36 -
.../qdox/library/JavaClassContextTest.java | 161 --
.../library/OrderedClassLibraryBuilderTest.java | 11 -
.../library/SortedClassLibraryBuilderTest.java | 10 -
.../qdox/library/SourceLibraryTest.java | 108 -
.../com/thoughtworks/qdox/model/JavaClassTest.java | 883 ------
.../qdox/model/JavaConstructorTest.java | 208 --
.../com/thoughtworks/qdox/model/JavaFieldTest.java | 247 --
.../thoughtworks/qdox/model/JavaMethodTest.java | 580 ----
.../thoughtworks/qdox/model/JavaPackageTest.java | 52 -
.../thoughtworks/qdox/model/JavaParameterTest.java | 80 -
.../thoughtworks/qdox/model/JavaSourceTest.java | 254 --
.../com/thoughtworks/qdox/model/JavaTypeTest.java | 93 -
.../qdox/model/expression/AddTest.java | 42 -
.../qdox/model/expression/AndTest.java | 42 -
.../model/expression/AnnotationValueListTest.java | 94 -
.../qdox/model/expression/AssignmentTest.java | 41 -
.../qdox/model/expression/CastTest.java | 43 -
.../qdox/model/expression/ConstantTest.java | 280 --
.../qdox/model/expression/DivideTest.java | 43 -
.../qdox/model/expression/EqualsTest.java | 43 -
.../qdox/model/expression/ExclusiveOrTest.java | 43 -
.../qdox/model/expression/FieldRefTest.java | 37 -
.../qdox/model/expression/GreaterEqualsTest.java | 43 -
.../qdox/model/expression/GreaterThanTest.java | 43 -
.../qdox/model/expression/LessEqualsTest.java | 43 -
.../qdox/model/expression/LessThanTest.java | 43 -
.../qdox/model/expression/LogicalAndTest.java | 42 -
.../qdox/model/expression/LogicalNotTest.java | 40 -
.../qdox/model/expression/LogicalOrTest.java | 43 -
.../qdox/model/expression/MinusSignTest.java | 40 -
.../qdox/model/expression/MultiplyTest.java | 43 -
.../qdox/model/expression/NotEqualsTest.java | 43 -
.../qdox/model/expression/NotTest.java | 40 -
.../thoughtworks/qdox/model/expression/OrTest.java | 43 -
.../qdox/model/expression/ParenExpressionTest.java | 40 -
.../qdox/model/expression/PlusSignTest.java | 40 -
.../qdox/model/expression/PostDecrementTest.java | 39 -
.../qdox/model/expression/PostIncrementTest.java | 39 -
.../qdox/model/expression/PreDecrementTest.java | 39 -
.../qdox/model/expression/PreIncrementTest.java | 39 -
.../qdox/model/expression/QueryTest.java | 46 -
.../qdox/model/expression/RemainderTest.java | 43 -
.../qdox/model/expression/ShiftLeftTest.java | 43 -
.../qdox/model/expression/ShiftRightTest.java | 43 -
.../qdox/model/expression/SubtractTest.java | 42 -
.../model/expression/UnsignedShiftRightTest.java | 41 -
.../qdox/model/impl/AbstractJavaEntityTest.java | 131 -
.../qdox/model/impl/DefaultJavaClassIT.java | 104 -
.../qdox/model/impl/DefaultJavaClassTest.java | 123 -
.../model/impl/DefaultJavaConstructorTest.java | 41 -
.../qdox/model/impl/DefaultJavaFieldTest.java | 69 -
.../qdox/model/impl/DefaultJavaMethodTest.java | 64 -
.../qdox/model/impl/DefaultJavaPackageTest.java | 18 -
.../qdox/model/impl/DefaultJavaParameterTest.java | 40 -
.../qdox/model/impl/DefaultJavaSourceTest.java | 43 -
.../qdox/model/impl/DefaultJavaTypeIT.java | 35 -
.../qdox/model/impl/DefaultTypeTest.java | 72 -
.../qdox/parser/ParseExceptionTest.java | 52 -
.../com/thoughtworks/qdox/parser/ParserTest.java | 2853 --------------------
.../parser/impl/DefaultJavaCommentLexerTest.java | 255 --
.../parser/impl/DefaultJavaCommentParserTest.java | 218 --
.../qdox/writer/impl/DefaultModelWriterTest.java | 395 ---
.../com/thoughtworks/qdox/testdata/Latin1.java | 8 -
.../thoughtworks/qdox/testdata/PropertyClass.java | 61 -
.../com/thoughtworks/qdox/testdata/UTF8.java | 9 -
467 files changed, 17955 insertions(+), 36735 deletions(-)
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..dc6b1a8
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,10 @@
+libqdox-java
+------------
+
+QDox is a high speed, small footprint parser for extracting
+class/interface/method definitions from source files complete with JavaDoc
+ at tags. It is designed to be used by active code generators or documentation
+tools.
+
+--
+Trygve Laugstøl
diff --git a/debian/build-classpath b/debian/build-classpath
new file mode 100644
index 0000000..7c714f1
--- /dev/null
+++ b/debian/build-classpath
@@ -0,0 +1,4 @@
+/usr/share/java/ant-nodeps.jar
+/usr/share/java/ant-junit.jar
+/usr/share/java/junit.jar
+
diff --git a/debian/build.properties b/debian/build.properties
new file mode 100644
index 0000000..1c67897
--- /dev/null
+++ b/debian/build.properties
@@ -0,0 +1,5 @@
+maven.test.skip=true
+javadoc.dir=build/docs/api
+build.sourceDirectory=src/java
+build.testSourceDirectory=src/test
+qdox.byaccj.executable=byaccj
diff --git a/debian/build.xml b/debian/build.xml
new file mode 100644
index 0000000..d5b12ba
--- /dev/null
+++ b/debian/build.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+
+<project name="pkg-java" default="all" basedir="..">
+
+ <property file="debian/build.properties"/>
+ <property name="maven.build" value="/usr/share/maven-ant-helper/maven-build.xml"/>
+ <property file="/usr/share/maven-ant-helper/maven-defaults.properties"/>
+
+ <macrodef name="cleanmodule">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="clean" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="packagemodule">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="package" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="javadocmodule">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="javadoc-jar"
+ antfile="${maven.build}" dir="@{dir}"/>
+ </sequential>
+ </macrodef>
+
+ <target name="clean">
+ <delete dir="build"/>
+ <cleanmodule dir=""/>
+ </target>
+
+ <target name="package">
+ <java classpath="/usr/share/java/jflex.jar" classname="jflex.Main" fork="true">
+ <arg value="-d" />
+ <arg value="${build.directory}/generated-sources/com/thoughtworks/qdox/parser/impl" />
+ <arg value="--skel" />
+ <arg value="src/grammar/skeleton.inner" />
+ <arg value="src/grammar/lexer.flex" />
+ </java>
+ <exec executable="${qdox.byaccj.executable}" dir="${build.directory}/generated-sources/com/thoughtworks/qdox/parser/impl"
+ failonerror="true">
+ <arg value="-v" />
+ <arg value="-Jnorun" />
+ <arg value="-Jnoconstruct" />
+ <arg value="-Jclass=Parser" />
+ <arg value="-Jsemantic=Value" />
+ <arg value="-Jpackage=com.thoughtworks.qdox.parser.impl" />
+ <arg value="${basedir}/src/grammar/parser.y" />
+ </exec>
+ <move tofile="${build.directory}/yacc-states.txt" file="${build.directory}/generated-sources/com/thoughtworks/qdox/parser/impl/y.output" />
+
+ <packagemodule dir=""/>
+ </target>
+
+ <target name="javadoc">
+ <javadocmodule dir="."/>
+ </target>
+
+ <target name="all" depends="package,javadoc" />
+
+</project>
diff --git a/debian/changelog b/debian/changelog
index 52981ac..f690bd9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,29 +1,13 @@
-qdox (2.0-M3-1) experimental; urgency=medium
+qdox (1.12.1-2) unstable; urgency=medium
* Team upload.
- * Imported Upstream version 2.0-M3.
- * debian/control:
- - Vcs-Browser: Use https.
- - Use only Build-Depends field for declaring build-dependencies.
- - Add maven substvars to binary packages.
- - Add libmaven-exec-plugin-java and libmaven-javadoc-plugin-java to B-D.
- - Switch to junit4.
- - Drop libjmock-java from Build-Depends. Not needed. Add libmockito-java
- instead.
- * Switch from cdbs to dh-sequencer.
- * Build with maven-debian-helper. Switch to maven build system.
- Remove maven-repo-helper, ant, ant-optional and maven-ant-helper
- from Build-Depends.
- * Drop build-classpath and build.xml. Now obsolete since we use Maven.
- * Rename build.properties to maven.properties. Change value of build source
- directory variable to main.
- * Drop README.Debian because it does not contain Debian specific information.
- * Register documentation with doc-base.
- * Add workingDirectory.patch to fix a FTBFS. The parser class could not be
- found.
- * Add clean file to ensure the package can be built twice in a row.
-
- -- Markus Koschany <apo at debian.org> Sun, 01 Nov 2015 19:15:11 +0100
+ * Declare compliance with Debian Policy 3.9.8.
+ * Vcs-fields: Use https.
+ * Tighten build-dependency on jflex.
+ * Fix build.xml and use new jflex.Main classname.
+ * Fix FTBFS with jflex 1.6.1. Add jflex-1.6.1.patch.
+
+ -- Markus Koschany <apo at debian.org> Wed, 27 Jul 2016 18:03:00 +0200
qdox (1.12.1-1) unstable; urgency=medium
diff --git a/debian/clean b/debian/clean
deleted file mode 100644
index cd1f4b9..0000000
--- a/debian/clean
+++ /dev/null
@@ -1,7 +0,0 @@
-src/main/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentLexer.java
-src/main/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentParser.java
-src/main/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentParserVal.java
-src/main/java/com/thoughtworks/qdox/parser/impl/JFlexLexer.java
-src/main/java/com/thoughtworks/qdox/parser/impl/Parser.java
-src/main/java/com/thoughtworks/qdox/parser/impl/y.output
-
diff --git a/debian/control b/debian/control
index f7c4139..ef00a3c 100644
--- a/debian/control
+++ b/debian/control
@@ -2,33 +2,25 @@ Source: qdox
Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
-Uploaders:
- Ludovic Claude <ludovic.claude at laposte.net>,
- Damien Raude-Morvan <drazzib at debian.org>
-Build-Depends:
- byacc-j,
- debhelper (>= 9),
- default-jdk,
- default-jdk-doc,
- jflex (>= 1.4.3),
- junit4,
- libmaven-exec-plugin-java,
- libmaven-javadoc-plugin-java,
- libmockito-java,
- maven-debian-helper
-Standards-Version: 3.9.6
-Vcs-Git: git://anonscm.debian.org/pkg-java/qdox.git
+Uploaders: Ludovic Claude <ludovic.claude at laposte.net>, Damien Raude-Morvan <drazzib at debian.org>
+Build-Depends: byacc-j, debhelper (>= 9), default-jdk
+Build-Depends-Indep: ant,
+ ant-optional,
+ default-jdk-doc,
+ jflex (>= 1.6.1),
+ junit (>= 3.8.1),
+ libjmock-java (>= 1.0.1),
+ maven-ant-helper (>= 7.1),
+ maven-repo-helper (>= 1.5)
+Standards-Version: 3.9.8
+Vcs-Git: https://anonscm.debian.org/git/pkg-java/qdox.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/qdox.git
Homepage: https://github.com/codehaus/qdox
Package: libqdox-java
Architecture: all
-Depends:
- ${maven:Depends},
- ${misc:Depends}
-Suggests:
- libqdox-java-doc,
- ${maven:OptionalDepends}
+Depends: ${misc:Depends}
+Suggests: libqdox-java-doc
Description: Quickly parses declarations and Javadoc from Java source
qdox quickly parses Java source files looking for key items of
interest:
@@ -45,13 +37,9 @@ Description: Quickly parses declarations and Javadoc from Java source
Package: libqdox-java-doc
Section: doc
Architecture: all
-Depends:
- ${misc:Depends}
-Recommends:
- ${maven:DocDepends},
- ${maven:DocOptionalDepends}
-Suggests:
- libqdox-java
+Depends: ${misc:Depends}
+Recommends: default-jdk-doc
+Suggests: libqdox-java
Description: Documentation for qdox (javadoc)
This package contains the documentation for qdox, generated from
Javadoc.
diff --git a/debian/copyright b/debian/copyright
index 4ba5b82..1543452 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -4,13 +4,12 @@ Source: https://github.com/codehaus/qdox
Files-Excluded: bootstrap/yacc*
Files: *
-Copyright: 2002-2014, Joe Walnes and QDox Project Team
+Copyright: 2002-2009, Joe Walnes and QDox Project Team
License: Apache-2.0
Files: debian/*
Copyright: 2005, Trygve Laugstøl <trygvis at inamo.no>
2009, Ludovic Claude <ludovic.claude at laposte.net>
- 2015, Markus Koschany <apo at debian.org>
License: Apache-2.0
License: Apache-2.0
diff --git a/debian/libqdox-java-doc.doc-base.api b/debian/libqdox-java-doc.doc-base.api
deleted file mode 100644
index de944cb..0000000
--- a/debian/libqdox-java-doc.doc-base.api
+++ /dev/null
@@ -1,10 +0,0 @@
-Document: libqdox-java
-Title: API Javadoc for QDox
-Author: QDox developers
-Abstract: This is the API Javadoc provided for the
- libqdox-java library.
-Section: Programming
-
-Format: HTML
-Index: /usr/share/doc/libqdox-java/api/index.html
-Files: /usr/share/doc/libqdox-java/api/*
diff --git a/debian/libqdox-java-doc.docs b/debian/libqdox-java-doc.docs
new file mode 100644
index 0000000..e551a05
--- /dev/null
+++ b/debian/libqdox-java-doc.docs
@@ -0,0 +1 @@
+build/docs/api
diff --git a/debian/libqdox-java-doc.install b/debian/libqdox-java-doc.install
deleted file mode 100644
index 1c11c0f..0000000
--- a/debian/libqdox-java-doc.install
+++ /dev/null
@@ -1 +0,0 @@
-target/apidocs/* usr/share/doc/libqdox-java/api
diff --git a/debian/libqdox-java.poms b/debian/libqdox-java.poms
index 5ad70f2..6269869 100644
--- a/debian/libqdox-java.poms
+++ b/debian/libqdox-java.poms
@@ -1,28 +1,2 @@
-# List of POM files for the package
-# Format of this file is:
-# <path to pom file> [option]*
-# where option can be:
-# --ignore: ignore this POM and its artifact if any
-# --ignore-pom: don't install the POM. To use on POM files that are created
-# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms]
-# --no-parent: remove the <parent> tag from the POM
-# --package=<package>: an alternative package to use when installing this POM
-# and its artifact
-# --has-package-version: to indicate that the original version of the POM is the same as the upstream part
-# of the version for the package.
-# --keep-elements=<elem1,elem2>: a list of XML elements to keep in the POM
-# during a clean operation with mh_cleanpom or mh_installpom
-# --artifact=<path>: path to the build artifact associated with this POM,
-# it will be installed when using the command mh_install. [mh_install]
-# --java-lib: install the jar into /usr/share/java to comply with Debian
-# packaging guidelines
-# --usj-name=<name>: name to use when installing the library in /usr/share/java
-# --usj-version=<version>: version to use when installing the library in /usr/share/java
-# --no-usj-versionless: don't install the versionless link in /usr/share/java
-# --dest-jar=<path>: the destination for the real jar.
-# It will be installed with mh_install. [mh_install]
-# --classifier=<classifier>: Optional, the classifier for the jar. Empty by default.
-# --site-xml=<location>: Optional, the location for site.xml if it needs to be installed.
-# Empty by default. [mh_install]
-#
-pom.xml --no-parent --has-package-version
+pom.xml --no-parent --has-package-version --java-lib --artifact=build/qdox-*.jar
+build/qdox.javadoc.pom --has-package-version --artifact=build/qdox.javadoc.jar --classifier=javadoc --ignore-pom --package=libqdox-java-doc
diff --git a/debian/maven.ignoreRules b/debian/maven.ignoreRules
deleted file mode 100644
index a7c394d..0000000
--- a/debian/maven.ignoreRules
+++ /dev/null
@@ -1,12 +0,0 @@
-
-de.jflex maven-jflex-plugin * * * *
-org.apache.maven.plugins maven-assembly-plugin * * * *
-org.apache.maven.plugins maven-changes-plugin * * * *
-org.apache.maven.plugins maven-enforcer-plugin * * * *
-org.apache.maven.plugins maven-failsafe-plugin * * * *
-org.apache.maven.plugins maven-invoker-plugin * * * *
-org.apache.maven.plugins maven-jxr-plugin * * * *
-org.apache.maven.plugins maven-project-info-reports-plugin * * * *
-org.apache.maven.wagon wagon-webdav-jackrabbit * * * *
-org.codehaus.mojo animal-sniffer-maven-plugin * * * *
-org.codehaus.mojo cobertura-maven-plugin * * * *
diff --git a/debian/maven.properties b/debian/maven.properties
deleted file mode 100644
index fbf819a..0000000
--- a/debian/maven.properties
+++ /dev/null
@@ -1 +0,0 @@
-qdox.byaccj.executable=byaccj
diff --git a/debian/maven.publishedRules b/debian/maven.publishedRules
index 5a9300b..dbd7b9b 100644
--- a/debian/maven.publishedRules
+++ b/debian/maven.publishedRules
@@ -1,2 +1 @@
-
-s/qdox/com.thoughtworks.qdox/ * * s/.*/debian/ * *
+s/qdox/com.thoughtworks.qdox/ * * s/.*/debian/
diff --git a/debian/maven.rules b/debian/maven.rules
index ef43f7b..51a25cc 100644
--- a/debian/maven.rules
+++ b/debian/maven.rules
@@ -1,4 +1,4 @@
+junit junit jar s/3\..*/3.x/
+jmock jmock jar s/1\..*/1.x/
+s/ant/org.apache.ant/ * * s/.*/debian/
-com.thoughtworks.qdox qdox jar s/.*/debian/ * *
-junit junit jar s/4\..*/4.x/ * *
-org.mockito mockito-core * s/.*/debian/ * *
diff --git a/debian/patches/jflex-1.6.1.patch b/debian/patches/jflex-1.6.1.patch
new file mode 100644
index 0000000..736a82d
--- /dev/null
+++ b/debian/patches/jflex-1.6.1.patch
@@ -0,0 +1,42 @@
+From: Markus Koschany <apo at debian.org>
+Date: Wed, 27 Jul 2016 18:01:12 +0200
+Subject: jflex 1.6.1
+
+Fix FTBFS with jflex 1.6.1.
+
+Origin: https://github.com/jflex-de/jflex/commit/f312d563777d907bbb12d1e2ac79835ba83ca53c
+Forwarded: no
+---
+ src/grammar/skeleton.inner | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/src/grammar/skeleton.inner b/src/grammar/skeleton.inner
+index 42cc796..7739c66 100644
+--- a/src/grammar/skeleton.inner
++++ b/src/grammar/skeleton.inner
+@@ -407,18 +407,18 @@
+ zzMarkedPos = zzMarkedPosL;
+ --- char count update
+
+---- actions
+- default:
+- if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+- zzAtEOF = true;
++ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
++ zzAtEOF = true;
+ --- eofvalue
+- }
+- else {
++ }
++ else {
++--- actions
++ default:
+ --- no match
+ }
++ }
+ }
+ }
+- }
+
+ --- main
+
diff --git a/debian/patches/series b/debian/patches/series
index ba8516f..db75729 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1 @@
-workingDirectory.patch
+jflex-1.6.1.patch
diff --git a/debian/patches/workingDirectory.patch b/debian/patches/workingDirectory.patch
deleted file mode 100644
index 3872522..0000000
--- a/debian/patches/workingDirectory.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Markus Koschany <apo at debian.org>
-Date: Sun, 4 Oct 2015 23:48:27 +0200
-Subject: workingDirectory
-
-Fix a FTBFS. The parser class could not be found.
-
-Forwarded: not-needed
----
- pom.xml | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/pom.xml b/pom.xml
-index 5b1c760..8252f6f 100644
---- a/pom.xml
-+++ b/pom.xml
-@@ -274,7 +274,7 @@
- <argument>-Jpackage=com.thoughtworks.qdox.parser.impl</argument>
- <argument>${basedir}/src/grammar/commentparser.y</argument>
- </arguments>
-- <workingDirectory>${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl</workingDirectory>
-+ <workingDirectory>src/main/java/com/thoughtworks/qdox/parser/impl</workingDirectory>
- </configuration>
- </execution>
- <execution>
-@@ -296,7 +296,7 @@
- <argument>-Jstack=${qdox.javaparser.stack}</argument>
- <argument>${basedir}/src/grammar/parser.y</argument>
- </arguments>
-- <workingDirectory>${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl</workingDirectory>
-+ <workingDirectory>src/main/java/com/thoughtworks/qdox/parser/impl</workingDirectory>
- </configuration>
- </execution>
- </executions>
diff --git a/debian/rules b/debian/rules
index 0434585..7940821 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,14 +1,15 @@
#!/usr/bin/make -f
+
+DEB_SOURCE_PACKAGE := $(shell dpkg-parsechangelog | grep '^Source:' | cut -f 2 -d ' ')
+DEB_UPSTREAM_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ' | cut -d: -f2- | sed 's/-[^-]*$$//')
+
export JAVA_HOME=/usr/lib/jvm/default-java
+export CLASSPATH=$(shell for jar in `cat debian/build-classpath`; do if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; done)
+export ANT_ARGS=-Dbasedir=$(realpath .) -Dpackage=$(DEB_SOURCE_PACKAGE) -Dversion=$(DEB_UPSTREAM_VERSION) -f debian/build.xml
%:
- dh $@ --buildsystem=maven
-
-override_dh_auto_build:
- jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/lexer.flex
- jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/commentlexer.flex
- dh_auto_build
+ dh $@ --buildsystem=ant --with maven_repo_helper
get-orig-source:
- -uscan --verbose --download-current-version --force-download
+ -uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
diff --git a/debian/watch b/debian/watch
index 596e0c0..998bbe7 100644
--- a/debian/watch
+++ b/debian/watch
@@ -1,2 +1,2 @@
version=3
-https://github.com/codehaus/qdox/tags .*/qdox-([\d\.].*)\.tar\.gz
+https://github.com/codehaus/qdox/tags .*/qdox-([\d\.]+).tar.gz
diff --git a/pom.xml b/pom.xml
index 5b1c760..123972e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,17 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
+
<parent>
<groupId>org.codehaus</groupId>
<artifactId>codehaus-parent</artifactId>
<version>4</version>
</parent>
-
+
<name>QDox</name>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
- <version>2.0-M3</version>
- <packaging>jar</packaging>
+ <version>1.12.1</version>
+
<url>http://qdox.codehaus.org</url>
<description>
QDox is a high speed, small footprint parser for extracting class/interface/method definitions from source files
@@ -26,7 +26,7 @@
<distribution>repo</distribution>
</license>
</licenses>
-
+
<mailingLists>
<mailingList>
<name>announce at QDox</name>
@@ -61,15 +61,11 @@
<system>jira</system>
<url>http://jira.codehaus.org/browse/QDOX</url>
</issueManagement>
- <ciManagement>
- <system>bamboo</system>
- <url>http://bamboo.ci.codehaus.org/browse/QDOX</url>
- </ciManagement>
<scm>
- <connection>scm:svn:https://svn.codehaus.org/qdox/tags/qdox-2.0-M3</connection>
- <developerConnection>scm:svn:https://svn.codehaus.org/qdox/tags/qdox-2.0-M3</developerConnection>
- <url>http://svn.qdox.codehaus.org/browse/qdox/tags/qdox-2.0-M3</url>
+ <connection>scm:svn:http://svn.codehaus.org/qdox/tags/qdox-1.12.1</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/qdox/tags/qdox-1.12.1</developerConnection>
+ <url>http://svn.qdox.codehaus.org/browse/qdox/tags/qdox-1.12.1</url>
</scm>
<developers>
@@ -158,81 +154,37 @@
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>2.2</version>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
</extension>
</extensions>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.4.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <forkMode>always</forkMode>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.3.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.7</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <templateFile>${basedir}/src/site/templates/site.vm</templateFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.5.1</version>
- </plugin>
- </plugins>
- </pluginManagement>
+ <sourceDirectory>${basedir}/src/java</sourceDirectory>
+ <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>${basedir}/src/test-resources</directory>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <id>enforce-maven</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireMavenVersion>
- <version>3.0</version>
- </requireMavenVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.3</version>
</plugin>
<plugin>
<groupId>de.jflex</groupId>
@@ -246,154 +198,199 @@
</execution>
</executions>
<configuration>
- <outputDirectory>${project.build.directory}/generated-sources/parser</outputDirectory>
- <lexDefinitions>
- <lexFile>${basedir}/src/grammar/lexer.flex</lexFile>
- <lexFile>${basedir}/src/grammar/commentlexer.flex</lexFile>
- </lexDefinitions>
- </configuration>
+ <outputDirectory>${project.build.directory}/generated-sources/parser</outputDirectory>
+ <lexDefinitions>
+ <lexFile>${basedir}/src/grammar/lexer.flex</lexFile>
+ </lexDefinitions>
+ <skeleton>${basedir}/src/grammar/skeleton.inner</skeleton>
+ </configuration>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+ <configuration>
+ <tasks>
+ <echo>OS Arch = ${os.arch}</echo>
+ <exec executable="${qdox.byaccj.executable}" dir="${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl" failonerror="true">
+ <arg value="-v" />
+ <arg value="-Jnorun" />
+ <arg value="-Jnoconstruct" />
+ <arg value="-Jclass=Parser" />
+ <arg value="-Jsemantic=Value" />
+ <arg value="-Jpackage=com.thoughtworks.qdox.parser.impl" />
+ <arg value="${basedir}/src/grammar/parser.y" />
+ </exec>
+ <move tofile="${project.build.directory}/yacc-states.txt" file="${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl/y" failonerror="false" />
+ </tasks>
+ <sourceRoot>${project.build.directory}/generated-sources/parser</sourceRoot>
+ </configuration>
<executions>
<execution>
- <id>javacommentparser</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>${qdox.byaccj.executable}</executable>
- <arguments>
- <argument>-v</argument>
- <argument>-Jnorun</argument>
- <argument>-Jnoconstruct</argument>
- <argument>-Jclass=DefaultJavaCommentParser</argument>
- <argument>-Jpackage=com.thoughtworks.qdox.parser.impl</argument>
- <argument>${basedir}/src/grammar/commentparser.y</argument>
- </arguments>
- <workingDirectory>${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl</workingDirectory>
- </configuration>
- </execution>
- <execution>
- <id>javasourceparser</id>
+ <id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
- <goal>exec</goal>
+ <goal>run</goal>
</goals>
- <configuration>
- <executable>${qdox.byaccj.executable}</executable>
- <arguments>
- <argument>-v</argument>
- <argument>-Jnorun</argument>
- <argument>-Jnoconstruct</argument>
- <argument>-Jclass=Parser</argument>
- <argument>-Jimplements=CommentHandler</argument>
- <argument>-Jsemantic=Value</argument>
- <argument>-Jpackage=com.thoughtworks.qdox.parser.impl</argument>
- <argument>-Jstack=${qdox.javaparser.stack}</argument>
- <argument>${basedir}/src/grammar/parser.y</argument>
- </arguments>
- <workingDirectory>${project.build.directory}/generated-sources/parser/com/thoughtworks/qdox/parser/impl</workingDirectory>
- </configuration>
</execution>
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.7</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.4</version>
<executions>
<execution>
- <id>check-java15</id>
- <phase>process-classes</phase>
+ <id>attach-javadoc</id>
+ <phase>package</phase>
<goals>
- <goal>check</goal>
+ <goal>jar</goal>
</goals>
<configuration>
- <signature>
- <groupId>org.codehaus.mojo.signature</groupId>
- <artifactId>java15</artifactId>
- <version>1.0</version>
- </signature>
+ <links>
+ <link>http://java.sun.com/j2se/1.5/docs/api</link>
+ </links>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.9</version>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+ </configuration>
<executions>
<execution>
+ <id>make-assembly</id> <!-- this is used for inheritance merges -->
+ <phase>package</phase> <!-- append to the packaging phase. -->
<goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
+ <goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-invoker-plugin</artifactId>
- <version>1.5</version>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.2</version>
<configuration>
- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
- <postBuildHookScript>verify</postBuildHookScript>
- <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
- <goals>
- <goal>clean</goal>
- <goal>test</goal>
- </goals>
- <settingsFile>src/it/settings.xml</settingsFile>
- <debug>true</debug>
+ <templateFile>${basedir}/src/site/templates/site-template.vm</templateFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.xsite</groupId>
+ <artifactId>xsite-maven-plugin</artifactId>
+ <version>1.0</version>
+ <configuration>
+ <sitemapPath>content/website.xml</sitemapPath>
+ <skinPath>templates/skin.html</skinPath>
+ <sourceDirectoryPath>${xsite.sourceDirectoryPath}</sourceDirectoryPath>
+ <outputDirectoryPath>${project.build.directory}/site</outputDirectoryPath>
+ <resourcePaths>resources</resourcePaths>
</configuration>
<executions>
<execution>
- <id>integration-test</id>
+ <phase>site</phase>
<goals>
- <goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2.2</version>
- <configuration>
- <descriptorRefs>
- <descriptorRef>project</descriptorRef>
- </descriptorRefs>
- <tarLongFileMode>gnu</tarLongFileMode>
- </configuration>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.3</version>
<executions>
<execution>
- <id>make-assembly</id> <!-- this is used for inheritance merges -->
- <phase>package</phase> <!-- append to the packaging phase. -->
+ <id>pre-copy-resources</id>
+ <phase>pre-site</phase>
<goals>
- <goal>single</goal> <!-- goals == mojos -->
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${xsite.sourceDirectoryPath}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/site</directory>
+ <excludes>
+ <exclude>**/download.html</exclude>
+ <exclude>**/skin.html</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>src/site</directory>
+ <includes>
+ <include>**/download.html</include>
+ <include>**/skin.html</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>post-copy-resources</id>
+ <phase>site</phase>
+ <goals>
+ <goal>copy-resources</goal>
</goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/site</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${xsite.sourceDirectoryPath}/content</directory>
+ <includes>
+ <include>images/*.*</include>
+ <include>apidocs/**/*.*</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <goals>deploy</goals> <!-- deploy-site by hand -->
+ </configuration>
+ </plugin>
</plugins>
</build>
<dependencies>
<dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.5.1</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
- <scope>test</scope>
+ <version>3.8.1</version>
+ <scope>compile</scope>
+ <optional>true</optional>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>1.8.5</version>
+ <groupId>jmock</groupId>
+ <artifactId>jmock</artifactId>
+ <version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -464,18 +461,16 @@
<qdox.byaccj.executable>${basedir}/bootstrap/yacc.exe</qdox.byaccj.executable>
</properties>
</profile>
- <!-- <profile> <id>release-site</id> <activation> <file> <exists>release.properties</exists>
- </file> </activation> <build> <filters> <filter>release.properties</filter>
- </filters> </build> </profile> -->
</profiles>
<!-- Reports -->
<reporting>
+ <outputDirectory>${xsite.sourceDirectoryPath}/content</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>2.1</version>
<reportSets>
<reportSet>
<reports>
@@ -491,54 +486,42 @@
</reportSets>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
- <version>2.4</version>
+ <version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
+ <version>2.4</version>
<configuration>
<packagenames>com.thoughtworks.qdox.*</packagenames>
+ <use>true</use>
+ <version>true</version>
+ <windowtitle>${project.name} ${project.version} API</windowtitle>
<tag name="noinspection" description="IntelliJ Inspection Ignore tag" enabled="false" />
+ <encoding>UTF-8</encoding>
</configuration>
- <reportSets>
- <reportSet>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
</plugin>
<!-- Manual Changelist -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
- <version>2.6</version>
+ <version>2.1</version>
<configuration>
- <!-- jira-report -->
- <columnNames>Key,Summary,Fix Version,Status,Resolution</columnNames>
- <sortColumnNames>Fix Version DESC, Priority DESC, Created DESC</sortColumnNames>
- <statusIds>Resolved, Closed</statusIds>
+ <!-- changes-report -->
+ <issueLinkTemplate>%URL%/%ISSUE%</issueLinkTemplate>
+<!-- jira-report -->
+<!-- <resolutionIds>Closed</resolutionIds>-->
+<!-- <statusIds>Resolved, Closed</statusIds>-->
+<!-- <onlyCurrentVersion>false</onlyCurrentVersion>-->
</configuration>
<reportSets>
<reportSet>
<reports>
- <report>jira-report</report>
+ <report>changes-report</report>
+<!-- <report>jira-report</report>-->
</reports>
</reportSet>
</reportSets>
@@ -547,8 +530,7 @@
</reporting>
<properties>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
- <qdox.javaparser.stack>500</qdox.javaparser.stack>
+ <xsite.sourceDirectoryPath>${project.build.directory}/generated-site</xsite.sourceDirectoryPath>
</properties>
</project>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
new file mode 100644
index 0000000..344b1a5
--- /dev/null
+++ b/src/changes/changes.xml
@@ -0,0 +1,425 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+ <title>Changes</title>
+ <author>Joe Walnes</author>
+ </properties>
+
+ <body>
+
+ <release version="1.10" date="2009-09-04">
+ <action dev="rfscholte" type="update" issue="QDOX-171" due-to="Vincent Siveton">
+ AbstractJavaEntity#getCodeBlock() skips Javadoc separator
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-173" due-to="Vincent Siveton">
+ Unwanted DocletTag.getParameters()[0]=< in generic case
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-82" due-to="Grégory Joseph">
+ Multilined tag attribute values not working anymore
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-168" due-to="Robert Scholte">
+ Parsing JavadocComment improvement
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-176" due-to="Benjamin Bentmann">
+ Add method to safely and easily get the package name for a JavaClass
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-146" due-to="Grégory Joseph">
+ Retaining whitespace in comments
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-164" due-to="Robert Scholte">
+ QDox Site overhaul
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-151" due-to="Robert Scholte">
+ Introduce toString() according to the Java Language Specification
+ </action>
+ </release>
+
+ <release version="1.9.1" date="2009-05-05">
+ <action dev="rfscholte" type="update" issue="QDOX-152" due-to="Leonardo Uribe">
+ JavaClass.getFullyQualifiedName() does not work on version 1.9 (version 1.6.3 works without problem). Manual resolve scanning imports are required
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-118" due-to="Rune Flobakk">
+ Annotation parsing fails on enum constant when javadoc present
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-161" due-to="Lars Huber">
+ Annotation with comment can't be parsed
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-150" due-to="Vincent Siveton">
+ Better handler of generics in Type
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-155" due-to="Vincent Siveton">
+ JavaField#getInitializationExpression() is wrong for char
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-158" due-to="Vincent Siveton">
+ ParseException when using annotations in methods
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-140" due-to="Benjamin Bentmann">
+ Parser fails to translate Unicode escapes
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-153" due-to="Leonardo Uribe">
+ Qdox fails to parse enums inside class
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-157" due-to="Vincent Siveton">
+ QDOX-156 Remove single comment in JavaField#getInitializationExpression()
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-156" due-to="Vincent Siveton">
+ Wrong whitespace in JavaField#getInitializationExpression()
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-160" due-to="Frantisek Kucera">
+ error parsing clauses with indexOf
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-159" due-to="Robert Scholte">
+ most simple annotation, like @Override, results in a parseexception
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-149" due-to="Robert Scholte">
+ make use of maven-jflex-plugin instead of an antrun
+ </action>
+
+
+ </release>
+
+ <release version="1.9" date="2009-02-21">
+ <action dev="rfscholte" type="update" issue="QDOX-127" due-to="Richard Craddock">
+ getInitializationExpression() includes comment text
+ </action>
+ <action dev="paul" type="update" issue="QDOX-65" due-to="Jose Peleteiro">
+ More package information, not just package name.
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-98" due-to="Guillaume Nodet">
+ Parser fails on package with annotations
+ </action>
+ </release>
+
+ <release version="1.8" date="2009-01-31">
+ <action dev="rfscholte" type="update" issue="QDOX-144" due-to="Stanislaw Osinski">
+ QDox fails to parse correct code
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-135" due-to="Louis R. Marascio">
+ Annotation with value in method signature does not parse
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-113" due-to="Jukka Lindström">
+ Annotations With Parameters do not work
+ </action>
+ <action dev="paul" type="update" issue="QDOX-124" due-to="Jochen Kuhnlei">
+ Field modifiers of binary classes ignored
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-101" due-to="David Blevins">
+ Multiple annotations on one field and generics
+ </action>
+ <action dev="paul" type="update" issue="QDOX-125" due-to="Jochen Kuhnle">
+ Name resolution of imported nested types does not work correctly
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-144" due-to="alex322">
+ ParseException for private static String[] allConstants = {C1,C2,C3};
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-138" due-to="Stanislaw Osinski">
+ Parser fails depending on the position of an internal enum
+ </action>
+ <action dev="mauro" type="update" issue="QDOX-92" due-to="Wolfgang Jung">
+ Performance Improvement of JavaDocBuilder.getClassByName()
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-145" due-to="Elliot Schwartz">
+ Static block source code gets associated with source code of subsequent method
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-54" due-to="Aslak Hellesoy">
+ Support for retrieval of generic type information (JSR 14)
+ </action>
+ <action dev="mauro" type="update" issue="QDOX-74" due-to="Mike Williams">
+ add parser support for enumerated types
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-117" due-to="Ron Saito">
+ annotation value poluted with class instance block
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-86" due-to="Alexandre Vasseur">
+ inner classes not resolved correctly when appears as method param
+ </action>
+ <action dev="rfscholte" type="update" issue="QDOX-147" due-to="Robert Scholte">
+ packaging with java5+ fails due to incorrect javadocs
+ </action>
+
+ </release>
+
+ <release version="1.7" date="2008-12-22">
+ <action dev="paul" type="update" issue="QDOX-126" due-to="Jochen Kuhnle">
+ Improved annotation support including types, fields and expressions.
+ </action>
+ <action dev="paul" type="fix" issue="QDOX-114" due-to="Louis R. Marascio">
+ Fix to lexer bug.
+ </action>
+ <action dev="paul" type="fix" issue="QDOX-129" due-to="Paul Duffin">
+ Inconsistency between getMethods(), getFields() in binary and source JavaClass fixed.
+ </action>
+ </release>
+
+ <release version="1.6.3" date="2007-06-15">
+ <action dev="paul" type="fix" issue="QDOX-102">
+ Project version control web page shows CVS instead of SVN.
+ </action>
+ <action dev="mauro" type="update" issue="QDOX-119">
+ Migrate site to use XSite.
+ </action>
+ </release>
+
+ <release version="1.6.2" date="2007-05-26">
+ <action dev="joe" type="update" due-to="Brian Slesinsky">
+ Improved generic parsing support.
+ </action>
+ <action dev="paul" type="update" issue="QDOX-94" due-to="Eric Redmond">
+ Also fixes QDOX-108.
+ Improved annotation parsing support.
+ </action>
+ <action dev="paul" type="update" due-to="Eric Redmond">
+ Improved anon inner class parsing support.
+ </action>
+ <action dev="mauro" type="update" due-to="Eric Redmond">
+ Maven2 support.
+ </action>
+ </release>
+
+ <release version="1.6.1" date="2006-10-28">
+ <action dev="joe" type="add" issue="QDOX-83" due-to="Shawn Chain">
+ Original body of method can be obtained using JavaMethod.getSourceCode().
+ Original field initialization expression can be obtained by JavaField.getInitializationExpression().
+ </action>
+ <action dev="joe" type="update" due-to="Brian Slesinsky and James Lee">
+ Improved Enum parsing support.
+ </action>
+ </release>
+
+ <release version="1.6" date="2006-10-15">
+ <action dev="joe" type="update">
+ Switched license from 'Ironsmith' Apache license clone to genuine Apache 2 license.
+ </action>
+ <action dev="pkaminsk" type="add" issue="QDOX-52">
+ Provide line numbers for all java entities.
+ </action>
+ <action dev="mdub" type="update" issue="QDOX-59">
+ Ensure that things (e.g. named tag-parameters,
+ bean-properties) are consistently returned in declared
+ order.
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-66">
+ Support for wildcard generic-type arguments.
+ </action>
+ <action dev="joe" type="add" issue="QDOX-67">
+ Convenience methods - Type.isPrimitive() and Type.isVoid().
+ </action>
+ <action dev="joe" type="add">
+ Parser can now handle Java 5 annotations.
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-68">
+ Support for generic-type parameters on methods.
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-70">
+ Support for Java 5 varargs syntax: "printf(Object... stuff)". New method, JavaParameter.isVarArgs().
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-78">
+ JavaDoc comments now preserve end of line characters.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-61">
+ Support legal Unicode characters in identifiers.
+ </action>
+ <action dev="joe" type="fix" issue="QDOX-63" due-to="Philippe Gaudin">
+ Inner/nested classes are now resolved correctly between packages.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-72">
+ Correct terminology re "inner" vs "nested" classes.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-73">
+ Reinstate public constructors on concrete model classes.
+ </action>
+ <action dev="joe" type="fix" issue="QDOX-75">
+ Support for methods that specify array dimensions at end: String doStuff()[]
+ </action>
+ <action dev="joe" type="fix" issue="QDOX-80">
+ Static blocks do not add static modifier to next method.
+ </action>
+ <action dev="joe" type="fix">
+ Support for trailing semicolon after class definition.
+ </action>
+ <action dev="joe" type="fix">
+ Bugfix: Support for empty /**/ comments.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-77">
+ Patch from Mario Siegenthaler and Daniel Müller to improve
+ tolerance of Java 5 syntax, including: annotations with
+ classes as parameters, generic field initialization, static
+ imports and enums with enumeration ending with a semicolon.
+ </action>
+ <action dev="joe" type="add">
+ Added QDoxTester to test that QDox can successfully parse a load of Java source.
+ </action>
+ </release>
+
+ <release version="1.5" date="2004-06-20">
+ <action dev="mdub" type="update" issue="QDOX-47">
+ Refactor DocletTag handling so that all context information
+ is provided via the DocletTagFactory.
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-53">
+ Add support for parsing of JSR-14 generic types.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-45">
+ Also fixes QDOX-50.
+ Improve parsing of tag parameters, particularly where
+ whitespace is involved.
+ </action>
+ <action dev="rinkrank" type="fix" issue="QDOX-49">
+ Fixed generation of Eclipse ".classpath".
+ </action>
+ <action dev="rinkrank" type="fix" issue="QDOX-57">
+ Problems compiling against jmock-1.0.0.
+ </action>
+ </release>
+
+ <!-- action types are add/update/fix/remove -->
+ <release version="1.4" date="2004-04-29">
+ <action dev="mdub" type="fix" issue="QDOX-27">
+ Handle extra stars in Javadoc start/end tokens.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-28">
+ Handle unclosed quotes in tag values.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-30">
+ Support for strictfp modifier (and volatile and native).
+ </action>
+ <action dev="rinkrank" type="fix" issue="QDOX-33">
+ JavaClass.getTagsByName() is buggy.
+ </action>
+ <action dev="rinkrank" type="fix" issue="QDOX-34">
+ recursive retrieval of tags from superclasses got a bug.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-29">
+ Also fixes QDOX-37:
+ Handle inner-classes in type-resolution.
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-39">
+ Support multiple fields in a single field-declaration.
+ </action>
+ <action dev="mdub" type="add">
+ Throw a ParseException, including location info, if a
+ syntax error is encountered.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-42">
+ Fix handling of MAC line-endings.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-43">
+ Allow "$" in identifiers.
+ </action>
+ <action dev="mdub" type="add" issue="QDOX-44">
+ Added DocletTag.getNamedParameterMap().
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-46">
+ Added JavaField.getDeclarationSignature().
+ </action>
+ </release>
+
+ <release version="1.3" date="2003-11-03" issue="">
+ <action dev="rinkrank" type="add" issue="QDOX-3">
+ Support for binary classes.
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-6">
+ Support for bean properties.
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-7">
+ New isA(String fullyQualifiedName) method in JavaClass.
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-12">
+ Pluggable DocletTag implementations via DocletTagFactory.
+ This opens up for tag validation, ${property} substitution
+ and other goodies that shouldn't go directly into QDox'
+ core, but rather into pluggable extensions.
+ </action>
+ <action dev="pkaminsk" type="fix" issue="QDOX-13">
+ Line numbers in the lexer.
+ </action>
+ <action dev="rinkrank" type="fix" issue="QDOX-14">
+ resolveTypeInternal doesn't work for nested types.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-17">
+ JavaMethod.equals() failed for constructors.
+ </action>
+ <action dev="rinkrank" type="add" issue="QDOX-18">
+ BeanProperty : support for type retrieval.
+ </action>
+ <action dev="mdub" type="fix" issue="QDOX-16">
+ Also fixes QDOX-19.
+ More robust handling of "*" and "@" in Javadoc body.
+ </action>
+ <action dev="rinkrank" type="update" issue="QDOX-24">
+ Encoding support for internationalization.
+ </action>
+ <action dev="rinkrank" type="add">
+ Type now has a getJavaClass() method making
+ it easier to find the JavaClass of a Type from e.g. Velocity.
+ Example: $method.returns.javaClass
+ </action>
+ <action dev="rinkrank" type="add">
+ Implemented tag inheritance on classes and methods. (It makes no sense
+ to have it on fields or constructors). Accessed with clazz|method.getTag[s]ByName(String name, boolean superclasses).
+ </action>
+ <action dev="rinkrank" type="update">
+ DocletTag is an interface.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added a getClasses() method to JavaDocBuilder that will
+ return all JavaClasses.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added a getDerivedClasses() method to JavaClass that will
+ return all derived classes, i.e. subclasses or subinterfaces.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added getDeclarationSignature() and getCallSignature() methods
+ to JavaMethod.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added a getNamedParameter(String tagName, String parameterName)
+ convenience method to AbstractJavaEntity for easier retrieval
+ of tag parameters without having to null-check the tag.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added APITestCase. This is a JUnit extension that can be used
+ to compare the equality of two Java sources on the API level.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added int getLineNumber() to DocletTag.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added JavaSource getJavaSource() to DocletTag.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added boolean isInner() to JavaClass.
+ </action>
+ <action dev="rinkrank" type="add">
+ Added JavaMethod[] getMethods(boolean superclasses) to JavaClass.
+ </action>
+ </release>
+
+ <release version="1.2" date="2003-03-23">
+ <action dev="joe" type="fix">
+ Quoted tokens allowed in doclet tags.
+ </action>
+ <action dev="joe" type="fix">
+ Asterix symbol allowed in doclet tags.
+ </action>
+ </release>
+
+ <release version="1.1" date="2002-12-08">
+ <action dev="mdub" type="add">
+ Added support for inner classes.
+ </action>
+ <action dev="joe" type="update">
+ Moved build system over to Maven.
+ </action>
+ </release>
+
+ <release version="1.0" date="2002-09-25">
+ <action dev="joe" type="add">
+ Initial release.
+ </action>
+ </release>
+
+ </body>
+</document>
+
diff --git a/src/grammar/commentlexer.flex b/src/grammar/commentlexer.flex
deleted file mode 100644
index d674699..0000000
--- a/src/grammar/commentlexer.flex
+++ /dev/null
@@ -1,206 +0,0 @@
-package com.thoughtworks.qdox.parser.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.parser.*;
-%%
-
-// class and lexer definitions
-%class DefaultJavaCommentLexer
-%public
-%implements Lexer
-%byaccj
-%unicode
-%line
-%column
-
-%{
- private int lineOffset = 1;
- private int columnOffset =1;
-
- private int stateDepth = 0;
- private int[] stateStack = new int[10];
-
- private StringBuffer codeBody = new StringBuffer(8192);
- private boolean appendingToCodeBody;
-
- public int lex() throws java.io.IOException {
- return yylex();
- }
-
- public String text() {
- return yytext();
- }
-
- public int getLine() {
- return yyline + lineOffset;
- }
-
- public void setLineOffset(int lineOffset) {
- this.lineOffset = lineOffset;
- }
-
- public int getColumn() {
- return yycolumn + columnOffset;
- }
-
- public void setColumnOffset(int columnOffset) {
- this.columnOffset = columnOffset;
- }
-
- public String getCodeBody(){
- String s = codeBody.toString();
- codeBody = new StringBuffer(8192);
- return s;
- }
-
- private void pushState(int newState) {
- stateStack[stateDepth++] = zzLexicalState;
- yybegin(newState);
- }
-
- private void popState() {
- yybegin(stateStack[--stateDepth]);
- }
-
- private int peekState(int relative) {
- if(relative > stateDepth) {
- return -1;
- }
- else {
- return stateStack[stateDepth - relative];
- }
- }
-%}
-
-Eol = \r|\n|\r\n
-JavadocEnd = "*"+ "/"
-
-%state JAVADOC JAVADOCCONTENT JAVADOCLINE JAVADOCTAG MULTILINECOMMENT SINGLELINECOMMENT
-
-%%
-
-<YYINITIAL> {
- "//" {
- codeBody.append( "//" );
- pushState( SINGLELINECOMMENT );
- }
- "/**/" {
- codeBody.append( "/**/" );
- }
- "/*" [*]+ {
- pushState( JAVADOC );
- pushState( JAVADOCCONTENT );
- return DefaultJavaCommentParser.JAVADOCSTART;
- }
- "/*" {
- codeBody.append( "/*" );
- pushState( MULTILINECOMMENT );
- }
-}
-
-<JAVADOC> {
- "*"+ [ \t]* / "@" {
- pushState(JAVADOCTAG);
- }
- "*"+ [ \t]? {
- pushState(JAVADOCLINE);
- }
- {JavadocEnd} {
- popState();
- return DefaultJavaCommentParser.JAVADOCEND;
- }
- "@" {
- yypushback(1);
- pushState(JAVADOCTAG);
- }
- [^ \t\r] {
- yypushback(1);
- pushState(JAVADOCLINE);
- }
-}
-<JAVADOCCONTENT> {
- [ \t]* "@" {
- yypushback(1);
- popState();
- pushState(JAVADOCTAG);
- }
- [^ \t] {
- yypushback(1);
- popState();
- pushState(JAVADOCLINE);
- }
- {Eol} {
- popState();
- return DefaultJavaCommentParser.JAVADOCLINE;
- }
-}
-
-<JAVADOCLINE> {
- ~{Eol} {
- popState();
- return DefaultJavaCommentParser.JAVADOCLINE;
- }
- .* [^ \t*] / [ \t]* {JavadocEnd} {
- popState();
- return DefaultJavaCommentParser.JAVADOCLINE;
- }
- {JavadocEnd} {
- popState();
- popState();
- return DefaultJavaCommentParser.JAVADOCEND;
- }
-}
-
-<JAVADOCTAG> {
- "@" [^ \t\n\r]+ / {JavadocEnd} {
- popState();
- return DefaultJavaCommentParser.JAVADOCTAG;
- }
- "@" [^ \t\n\r]+ {
- return DefaultJavaCommentParser.JAVADOCTAG;
- }
- [ \t]+ {
- popState();
- pushState(JAVADOCLINE);
- }
- {Eol} {
- popState();
- return DefaultJavaCommentParser.JAVADOCLINE;
- }
-}
-
-<MULTILINECOMMENT, JAVADOC> {
- "*/" {
- codeBody.append("*/");
- popState();
- }
-}
-
-<SINGLELINECOMMENT> {
- {Eol} {
- codeBody.append(yytext());
- popState();
- }
-}
-
-.|\r|\n|\r\n {
- codeBody.append(yytext());
- }
\ No newline at end of file
diff --git a/src/grammar/commentparser.y b/src/grammar/commentparser.y
deleted file mode 100644
index d2beb3f..0000000
--- a/src/grammar/commentparser.y
+++ /dev/null
@@ -1,132 +0,0 @@
-%{
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.parser.Lexer;
-import com.thoughtworks.qdox.parser.ParseException;
-import com.thoughtworks.qdox.parser.structs.TagDef;
-%}
-
-%token JAVADOCSTART JAVADOCEND
-
-// strongly typed tokens/types
-%token <sval> JAVADOCTAG JAVADOCLINE
-%%
-javadoc: JAVADOCSTART javadocdescription_opt javadoctags_opt JAVADOCEND;
-
-javadocdescription_opt:
- | javadocdescription;
-
-javadocdescription: javadoctokens
- {
- builder.addJavaDoc(buffer());
- };
-
-javadoctokens_opt:
- | javadoctokens;
-
-javadoctokens: javadoctoken
- | javadoctokens javadoctoken;
-
-javadoctoken: JAVADOCLINE
- {
- appendToBuffer($1);
- };
-
-javadoctags_opt:
- | javadoctags;
-
-javadoctags: javadoctag
- | javadoctags javadoctag;
-
-javadoctag: JAVADOCTAG
- {
- line = lexer.getLine();
- }
- javadoctokens_opt
- {
- builder.addJavaDocTag(new TagDef($1.substring(1), buffer(), line));
- };
-
-%%
-
-private Lexer lexer;
-private Builder builder;
-
-private int line;
-private int column;
-private boolean debugLexer;
-
-private StringBuffer textBuffer = new StringBuffer();
-
-public DefaultJavaCommentParser(Lexer lexer, Builder builder) {
- this.lexer = lexer;
- this.builder = builder;
-}
-
-public void setDebugParser(boolean debug) {
- yydebug = debug;
-}
-
-public void setDebugLexer(boolean debug) {
- debugLexer = debug;
-}
-
-private void appendToBuffer(String word) {
- if (textBuffer.length() > 0) {
- char lastChar = textBuffer.charAt(textBuffer.length() - 1);
- if (!Character.isWhitespace(lastChar)) {
- textBuffer.append(' ');
- }
- }
- textBuffer.append(word);
-}
-
-private String buffer() {
- String result = textBuffer.toString().trim();
- textBuffer.setLength(0);
- return result;
-}
-
-public boolean parse() {
- return yyparse() == 0;
-}
-
-private int yylex() {
- try {
- final int result = lexer.lex();
- yylval = new DefaultJavaCommentParserVal();
- yylval.sval = lexer.text();
- if (debugLexer) {
- System.err.println("Token: " + yyname[result] + " \"" + yylval.sval + "\"");
- }
- return result;
- }
- catch(IOException e) {
- return 0;
- }
-}
-
-private void yyerror(String msg) {
- throw new ParseException(msg, lexer.getLine(), lexer.getColumn());
-}
-
\ No newline at end of file
diff --git a/src/grammar/lexer.flex b/src/grammar/lexer.flex
index 98504be..4e04f91 100644
--- a/src/grammar/lexer.flex
+++ b/src/grammar/lexer.flex
@@ -1,69 +1,18 @@
+// class headers
package com.thoughtworks.qdox.parser.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import com.thoughtworks.qdox.parser.*;
-import java.util.*;
-
%%
// class and lexer definitions
%class JFlexLexer
%public
-%implements JavaLexer
+%implements Lexer
%byaccj
%unicode
%line
%column
-%init{
- java.io.InputStream qdoxProperties = this.getClass().getClassLoader().getResourceAsStream( "qdox.properties" );
- if( qdoxProperties != null )
- {
- Properties props = new Properties();
- try
- {
- props.load( qdoxProperties );
- stateStack = new int[ parseValue( props.getProperty( "lexer.statestack.size" ), stateStack.length ) ];
- }
- catch ( java.io.IOException e )
- {
- // failed to load qdoxProperties
- }
- finally
- {
- try
- {
- qdoxProperties.close();
- }
- catch( java.io.IOException e )
- {
- // noop, we did our best
- }
- }
- }
-%init}
-
%{
- private java.io.Writer writer;
- private List<CommentHandler> commentHandlers = new ArrayList<CommentHandler>();
private int classDepth = 0;
private int parenDepth = 0;
@@ -75,32 +24,26 @@ import java.util.*;
private int[] stateStack = new int[10];
private int braceMode = CODEBLOCK;
private int parenMode = -1;
+ private String className;
+ private boolean javaDocNewLine;
+ private boolean javaDocStartedContent;
private StringBuffer codeBody = new StringBuffer(8192);
private boolean newMode;
private boolean bracketMode;
private boolean anonymousMode;
- private boolean enumConstantMode;
private boolean appendingToCodeBody;
+ private boolean shouldCaptureCodeBody;
+ private boolean isConstructor;
- private void write() {
- write( text() );
- }
-
- private void write( String text ) {
- try {
- if( writer != null ) {
- writer.write( text );
- }
- }
- catch( java.io.IOException ioe ) {}
- }
+ public void setCaptureCodeBody(boolean shouldCaptureCodeBody) {
+ this.shouldCaptureCodeBody = shouldCaptureCodeBody;
+ }
public String text() {
return yytext();
}
public int lex() throws java.io.IOException {
-// write();
return yylex();
}
@@ -121,72 +64,47 @@ import java.util.*;
yybegin(stateStack[--stateDepth]);
}
+ private int peekState(int relative) {
+ if(relative > stateDepth) {
+ return -1;
+ }
+ else {
+ return stateStack[stateDepth - relative];
+ }
+ }
+
public String getCodeBody(){
String s = codeBody.toString();
codeBody = new StringBuffer(8192);
return s;
}
-
- public void addCommentHandler(CommentHandler handler) {
- this.commentHandlers.add(handler);
- }
-
- private int parseValue( String value, int defaultValue )
- {
- int result;
- try
- {
- result = Integer.parseInt( value );
- }
- catch( NumberFormatException e )
- {
- result = defaultValue;
- }
- return result;
- }
-
- public JFlexLexer( java.io.Reader reader, java.io.Writer writer ) {
- this( reader );
- this.writer = writer;
- }
-
- public JFlexLexer( java.io.InputStream stream, java.io.Writer writer ) {
- this( stream );
- this.writer = writer;
- }
%}
-Eol = \r|\n|\r\n
-WhiteSpace = {Eol} | [ \t\f]
-CommentChar = ( [^ \t\r\n*] | "*"+ [^ \t\r\n/*] )
-DecimalNumeral = ( [0-9] | [1-9] [_0-9]* [0-9] )
-Digits = ( [0-9] | [0-9] [_0-9]* [0-9] )
-HexDigits = ( [0-9a-fA-F] | [0-9a-fA-F] [_0-9a-fA-F]* [0-9a-fA-F] )
-HexNumeral = ( "0" [xX] {HexDigits} )
-OctalNumeral = ( "0" [_0-7]* [0-7] )
-BinaryNumeral = ( "0" [bB] ( [01] | [01] [_01]* [01] ) )
-IntegerLiteral = ( {DecimalNumeral} | {BinaryNumeral} | {HexNumeral} | {OctalNumeral} ) ([lL])?
-Exponent = [eE] [+-]? {DecimalNumeral}
-FloatingPointLiteral = ( {DecimalFloatingPointLiteral} | {HexadecimalFloatingPointLiteral} )
-DecimalFloatingPointLiteral = ( {Digits} ("." {Digits})? ({Exponent})? ([dDfF])? ) |
- ( "." {Digits} ({Exponent})? ([dDfF])?) |
- ( {Digits} {Exponent} ([dDfF])?) |
- ( {Digits} ({Exponent} )? ([dDfF]) )
-BinaryExponent = [pP] [+-]? ({DecimalNumeral})+
-HexSignificand = ( {HexNumeral} "."? ) |
- ( "0" [xX] ( {HexDigits} )? "." ( {HexDigits} ) )
-HexadecimalFloatingPointLiteral = {HexSignificand} {BinaryExponent} ([dDfF])?
-UnicodeChar = \\u[a-fA-F0-9]{4}
-Id = ([:jletter:]|{UnicodeChar}) ([:jletterdigit:]|{UnicodeChar})*
-Annotation = "@" {WhiteSpace}* {Id} ("."{Id})* {WhiteSpace}*
-JavadocEnd = "*"+ "/"
-
-%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATIONTYPE ANNOTATION ANNOSTRING ANNOCHAR ENUM ARGUMENTS
+Eol = \r|\n|\r\n
+WhiteSpace = {Eol} | [ \t\f]
+CommentChar = ( [^ \t\r\n*] | "*"+ [^ \t\r\n/*] )
+IntegerLiteral = (( [1-9] ([0-9])* ) | ( "0" [xX] ([0-9]|[a-f]|[A-F])+ ) | ( "0" ([0-7])* ))
+LongLiteral = (( [1-9] ([0-9])* ) | ( "0" [xX] ([0-9]|[a-f]|[A-F])+ ) | ( "0" ([0-7])* )) [lL]
+Exponent = [eE] [+-]? ([0-9])+
+FloatLiteral = ( [0-9]+ ("." [0-9]+)? ({Exponent})? ([fF])? ) |
+ ( "." [0-9]+ ({Exponent})? ([fF])? ) |
+ ( ([0-9])+ {Exponent} ([fF])? ) |
+ ( ([0-9])+ ({Exponent})? [fF] )
+DoubleLiteral = ( [0-9]+ ("." [0-9]+)? ({Exponent})? [dD] ) |
+ ( "." [0-9]+ ({Exponent})? [dD] ) |
+ ( ([0-9])+ {Exponent} [dD] ) |
+ ( ([0-9])+ ({Exponent})? [dD] )
+UnicodeChar = \\u[a-fA-F0-9]{4}
+Id = ([:jletter:]|{UnicodeChar}) ([:jletterdigit:]|{UnicodeChar})*
+Annotation = "@" {WhiteSpace}* {Id} ("."{Id})* {WhiteSpace}*
+JavadocEnd = "*"+ "/"
+
+%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ENUM
%%
-<YYINITIAL, ANNOTATIONTYPE, ENUM> {
+<YYINITIAL, ENUM> {
"." { return Parser.DOT; }
"..." { return Parser.DOTDOTDOT; }
"," { return Parser.COMMA; }
@@ -209,7 +127,6 @@ JavadocEnd = "*"+ "/"
"extends" { return Parser.EXTENDS; }
"implements" { return Parser.IMPLEMENTS; }
"super" { return Parser.SUPER; }
- "new" { return Parser.NEW; }
"[" { nestingDepth++; return Parser.SQUAREOPEN; }
"]" { nestingDepth--; return Parser.SQUARECLOSE; }
@@ -221,7 +138,7 @@ JavadocEnd = "*"+ "/"
"@" {WhiteSpace}* "interface" {
classDepth++;
- braceMode = ANNOTATIONTYPE;
+ braceMode = YYINITIAL;
return Parser.ANNOINTERFACE;
}
@@ -254,7 +171,7 @@ JavadocEnd = "*"+ "/"
"{" {
if(braceMode >= 0) {
if(braceMode == ENUM) {
- enumConstantMode = true;
+ isConstructor = true;
} else if (braceMode == CODEBLOCK) {
getCodeBody(); /* reset codebody */
appendingToCodeBody = true;
@@ -265,14 +182,7 @@ JavadocEnd = "*"+ "/"
}
else {
nestingDepth++;
- if (enumConstantMode && yystate() == ENUM)
- {
- braceMode = YYINITIAL;
- }
- else
- {
- braceMode = CODEBLOCK;
- }
+ braceMode = CODEBLOCK;
return Parser.BRACEOPEN;
}
}
@@ -280,21 +190,14 @@ JavadocEnd = "*"+ "/"
nestingDepth--;
classDepth--;
popState();
- if ( yystate() == ENUM && enumConstantMode)
- {
- braceMode = YYINITIAL;
- }
- else
- {
- braceMode = CODEBLOCK;
- }
+ braceMode = CODEBLOCK;
return Parser.BRACECLOSE;
}
"/**" ~"*/" {
- for( CommentHandler handler: commentHandlers ) {
- handler.onComment( text(), getLine(), getColumn() );
- }
+ pushState(JAVADOC);
+ yypushStream(new java.io.StringReader(text().substring(2)));
+ return Parser.JAVADOCSTART;
}
"=" {WhiteSpace}* {
@@ -303,8 +206,16 @@ JavadocEnd = "*"+ "/"
appendingToCodeBody = true;
pushState(ASSIGNMENT);
}
+ "default" {
+ assignmentDepth = nestingDepth;
+ appendingToCodeBody = true;
+ pushState(ASSIGNMENT);
+ }
+ {Id} {
+ return Parser.IDENTIFIER;
+ }
}
-<YYINITIAL, ANNOTATIONTYPE> {
+<YYINITIAL> {
";" { return Parser.SEMI; }
"(" {
nestingDepth++;
@@ -317,11 +228,7 @@ JavadocEnd = "*"+ "/"
}
}
<ENUM> {
- ";" {
- enumConstantMode = false;
- braceMode = CODEBLOCK;
- return Parser.SEMI;
- }
+ ";" { isConstructor = false; return Parser.SEMI; }
"(" {
nestingDepth++;
if(parenMode >= 0) {
@@ -330,28 +237,38 @@ JavadocEnd = "*"+ "/"
parenMode = -1;
return Parser.PARENOPEN;
}
- else if(enumConstantMode)
- {
- annotationDepth = nestingDepth;
- pushState(ARGUMENTS);
- return Parser.PARENOPEN;
- }
else {
+ if(isConstructor) {
+ parenDepth = classDepth;
+ pushState(PARENBLOCK);
+ return Parser.PARENBLOCK;
+ }
+ else {
return Parser.PARENOPEN;
+ }
}
- }
+ }
}
-<YYINITIAL, ENUM> {
- "default" { return Parser.DEFAULT; }
+<JAVADOC> {
+ "@" { yypushback(1); pushState(JAVADOCTAG); }
+ [^ \t\r*@] { yypushback(1); pushState(JAVADOCLINE); }
+ "*"+ [ \t]* / "@" { pushState(JAVADOCTAG); }
+ "*"+ [ \t]? { pushState(JAVADOCLINE); }
+ {JavadocEnd} { popState(); yypopStream(); return Parser.JAVADOCEND; }
}
-<ANNOTATIONTYPE> {
- "default" { assignmentDepth = nestingDepth; appendingToCodeBody = true; pushState(ASSIGNMENT); }
+<JAVADOCLINE> {
+ ~{Eol} { popState(); return Parser.JAVADOCLINE; }
+ .* [^ \t*] / [ \t]* {JavadocEnd} { popState(); return Parser.JAVADOCLINE;}
+ {JavadocEnd} { popState(); popState(); yypopStream(); return Parser.JAVADOCEND; }
}
-<YYINITIAL, ANNOTATIONTYPE, ENUM> {
- {Id} {
- return Parser.IDENTIFIER;
- }
+
+<JAVADOCTAG> {
+ "@" [^ \t\n\r]+ / {JavadocEnd} { popState(); return Parser.JAVADOCTAG; }
+ "@" [^ \t\n\r]+ { return Parser.JAVADOCTAG; }
+ [ \t]+ { popState();pushState(JAVADOCLINE);}
+ {Eol} { popState();return Parser.JAVADOCLINE;}
}
+
<CODEBLOCK> {
"{" {
if(codeblockDepth++ > 0 ) {
@@ -370,27 +287,13 @@ JavadocEnd = "*"+ "/"
}
}
-<ANNOTATION,ARGUMENTS> {
+<ANNOTATION> {
"(" { ++ nestingDepth; return Parser.PARENOPEN; }
")" { if( nestingDepth-- == annotationDepth) { popState(); } return Parser.PARENCLOSE; }
"," { return Parser.COMMA; }
"=" { return Parser.EQUALS; }
- "*=" { return Parser.STAREQUALS; }
- "/=" { return Parser.SLASHEQUALS; }
- "%=" { return Parser.PERCENTEQUALS; }
- "+=" { return Parser.PLUSEQUALS; }
- "-=" { return Parser.MINUSEQUALS; }
- "<<=" { return Parser.LESSTHAN2EQUALS; }
- ">>=" { return Parser.GREATERTHAN2EQUALS; }
- ">>>=" { return Parser.GREATERTHAN3EQUALS; }
- "&=" { return Parser.AMPERSANDEQUALS; }
- "^=" { return Parser.CIRCUMFLEXEQUALS; }
- "|=" { return Parser.VERTLINEEQUALS; }
-
- "++" { return Parser.PLUSPLUS; }
- "--" { return Parser.MINUSMINUS; }
-
+
"{" { nestingDepth++; return Parser.BRACEOPEN; }
"}" { nestingDepth--; return Parser.BRACECLOSE; }
@@ -434,14 +337,16 @@ JavadocEnd = "*"+ "/"
"~" { return Parser.TILDE; }
{IntegerLiteral} { return Parser.INTEGER_LITERAL; }
- {FloatingPointLiteral} { return Parser.FLOAT_LITERAL; }
+ {LongLiteral} { return Parser.LONG_LITERAL; }
+ {FloatLiteral} { return Parser.FLOAT_LITERAL; }
+ {DoubleLiteral} { return Parser.DOUBLE_LITERAL; }
"true" | "false" { return Parser.BOOLEAN_LITERAL; }
"class" { return Parser.CLASS; }
-
- "new" { return Parser.NEW; }
- {Id} { return Parser.IDENTIFIER; }
+ {Id} {
+ return Parser.IDENTIFIER;
+ }
"@" { return Parser.AT; }
}
@@ -499,9 +404,11 @@ JavadocEnd = "*"+ "/"
}
"}" {
codeBody.append('}');
- nestingDepth--;
- if (nestingDepth==assignmentDepth) {
- anonymousMode=false;
+ if (anonymousMode) {
+ nestingDepth--;
+ if (nestingDepth==assignmentDepth) {
+ anonymousMode=false;
+ }
}
}
@@ -550,12 +457,12 @@ JavadocEnd = "*"+ "/"
}
}
-<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE> {
+<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM> {
"\"" { if (appendingToCodeBody) { codeBody.append('"'); } pushState(STRING); }
\' { if (appendingToCodeBody) { codeBody.append('\''); } pushState(CHAR); }
}
-<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, ANNOTATION, ARGUMENTS> {
+<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATION> {
"//" { if (appendingToCodeBody) { codeBody.append("//"); } pushState(SINGLELINECOMMENT); }
"/*" { if (appendingToCodeBody) { codeBody.append("/*"); } pushState(MULTILINECOMMENT); }
"/**/" { if (appendingToCodeBody) { codeBody.append("/**/"); } }
diff --git a/src/grammar/parser.y b/src/grammar/parser.y
index a96321d..d902936 100644
--- a/src/grammar/parser.y
+++ b/src/grammar/parser.y
@@ -1,37 +1,18 @@
%{
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.builder.Builder;
import com.thoughtworks.qdox.parser.*;
-import com.thoughtworks.qdox.parser.expression.*;
import com.thoughtworks.qdox.parser.structs.*;
+import com.thoughtworks.qdox.model.*;
+import com.thoughtworks.qdox.model.annotation.*;
import java.io.IOException;
import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
%}
%token SEMI DOT DOTDOTDOT COMMA STAR PERCENT EQUALS ANNOSTRING ANNOCHAR SLASH PLUS MINUS
-%token STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS
-%token PACKAGE IMPORT PUBLIC PROTECTED PRIVATE STATIC FINAL ABSTRACT NATIVE STRICTFP SYNCHRONIZED TRANSIENT VOLATILE DEFAULT
-%token CLASS INTERFACE ENUM ANNOINTERFACE THROWS EXTENDS IMPLEMENTS SUPER DEFAULT NEW
+%token PACKAGE IMPORT PUBLIC PROTECTED PRIVATE STATIC FINAL ABSTRACT NATIVE STRICTFP SYNCHRONIZED TRANSIENT VOLATILE
+%token CLASS INTERFACE ENUM ANNOINTERFACE THROWS EXTENDS IMPLEMENTS SUPER DEFAULT
%token BRACEOPEN BRACECLOSE SQUAREOPEN SQUARECLOSE PARENOPEN PARENCLOSE
%token LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS
%token LESSTHAN2 GREATERTHAN2 GREATERTHAN3
@@ -39,1641 +20,557 @@ import java.util.Stack;
%token TILDE AMPERSAND VERTLINE CIRCUMFLEX
%token VOID
%token QUERY COLON AT
+%token JAVADOCSTART JAVADOCEND JAVADOCEOL
%token CODEBLOCK PARENBLOCK
%token BYTE SHORT INT LONG CHAR FLOAT DOUBLE BOOLEAN
// strongly typed tokens/types
-%token <sval> IDENTIFIER
+%token <sval> IDENTIFIER JAVADOCTAG JAVADOCLINE
%token <sval> BOOLEAN_LITERAL
%token <sval> INTEGER_LITERAL
+%token <sval> LONG_LITERAL
%token <sval> FLOAT_LITERAL
+%token <sval> DOUBLE_LITERAL
%token <sval> CHAR_LITERAL
%token <sval> STRING_LITERAL
%token <ival> VERTLINE2 AMPERSAND2 VERTLINE CIRCUMFLEX AMPERSAND EQUALS2 NOTEQUALS
%token <ival> LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS LESSTHAN2 GREATERTHAN2 GREATERTHAN3
%token <ival> PLUS MINUS STAR SLASH PERCENT TILDE EXCLAMATION
-%token <ival> PLUSPLUS MINUSMINUS
-%token <sval> SUPER
-%token <sval> EQUALS STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS
-%type <type> PrimitiveType ReferenceType ArrayType ClassOrInterfaceType
-%type <annoval> Expression Literal Annotation ElementValue ElementValueArrayInitializer
-%type <annoval> ConditionalExpression ConditionalOrExpression ConditionalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression
-%type <annoval> EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression
-%type <annoval> UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation ClassInstanceCreationExpression
-%type <annoval> PostfixExpression PostIncrementExpression PostDecrementExpression CastExpression Assignment LeftHandSide AssignmentExpression
-%type <ival> Dims Dims_opt
-%type <sval> QualifiedIdentifier TypeDeclSpecifier MethodBody AssignmentOperator
-%type <type> Type ReferenceType Wildcard WildcardBounds VariableDeclaratorId ClassOrInterfaceType TypeArgument
+%type <sval> name primitiveType
+%type <annoval> value expression literal annotation arrayInitializer
+%type <annoval> conditionalExpression conditionalOrExpression conditionalAndExpression inclusiveOrExpression exclusiveOrExpression andExpression
+%type <annoval> equalityExpression relationalExpression shiftExpression additiveExpression multiplicativeExpression
+%type <annoval> unaryExpression unaryExpressionNotPlusMinus primary
+%type <ival> dims
+%type <sval> fullidentifier modifier typedeclspecifier typename memberend
+%type <ival> dimensions
+%type <bval> varargs
+%type <type> type arrayidentifier classtype typearg
%%
-// Source: Java Language Specification - Third Edition
-// The Java(TM) Language Specification - Java SE 8 Edition ( Chapter 19. Syntax )
-
-// ------------------------------
-// Productions from �7 (Packages)
-// ------------------------------
-
-// CompilationUnit:
-// [PackageDeclaration] {ImportDeclaration} {TypeDeclaration}
-CompilationUnit: PackageDeclaration_opt ImportDeclarations_opt TypeDeclarations_opt
- ;
-
-// PackageDeclaration:
-// {PackageModifier} package Identifier {. Identifier} ;
-// PackageModifier:
-// Annotation
-PackageDeclaration: package
- | Annotation
- ;
-PackageDeclaration_opt:
- | PackageDeclaration_opt PackageDeclaration
- ;
-
-package: PACKAGE
- {
- line = lexer.getLine();
- }
- QualifiedIdentifier /* =PackageName */SEMI
- {
- builder.addPackage(new PackageDef($3, line));
- }
- ;
-
-// ImportDeclaration:
-// SingleTypeImportDeclaration
-// TypeImportOnDemandDeclaration
-// SingleStaticImportDeclaration
-// StaticImportOnDemandDeclaration
-ImportDeclaration: SingleTypeImportDeclaration
- | TypeImportOnDemandDeclaration
- | SingleStaticImportDeclaration
- | StaticImportOnDemandDeclaration
- ;
-ImportDeclarations_opt:
- | ImportDeclarations_opt ImportDeclaration
- ;
-
-// SingleTypeImportDeclaration:
-// import TypeName ;
-SingleTypeImportDeclaration: IMPORT QualifiedIdentifier SEMI
- {
- builder.addImport( $2 );
- }
- ;
-
-// TypeImportOnDemandDeclaration:
-// import PackageOrTypeName . * ;
-TypeImportOnDemandDeclaration: IMPORT QualifiedIdentifier DOT STAR SEMI
- {
- builder.addImport( $2 + ".*" );
- }
- ;
-
-// SingleStaticImportDeclaration:
-// import static TypeName . Identifier ;
-SingleStaticImportDeclaration: IMPORT STATIC QualifiedIdentifier SEMI
- {
- builder.addImport( "static " + $3);
- }
- ;
-
-// StaticImportOnDemandDeclaration:
-// import static TypeName . * ;
-StaticImportOnDemandDeclaration: IMPORT STATIC QualifiedIdentifier DOT STAR SEMI
- {
- builder.addImport( "static " + $3 + ".*" );
- }
- ;
-
-// TypeDeclaration:
-// ClassDeclaration
-// InterfaceDeclaration
-// ;
-TypeDeclaration: ClassDeclaration
- | InterfaceDeclaration
- | SEMI
- ;
-TypeDeclarations_opt:
- | TypeDeclarations_opt
- {
- line = lexer.getLine();
- }
- TypeDeclaration
- ;
-
-// -----------------------------
-// Productions from �8 (Classes)
-// -----------------------------
-
-// ClassDeclaration:
-// NormalClassDeclaration
-// EnumDeclaration
-ClassDeclaration: NormalClassDeclaration
- | EnumDeclaration
- ;
-
-// NormalClassDeclaration:
-// {ClassModifier} class Identifier [TypeParameters] [Superclass] [Superinterfaces] ClassBody
-NormalClassDeclaration: Modifiers_opt CLASS IDENTIFIER TypeParameters_opt Superclass_opt Superinterfaces_opt
- {
- cls.setType(ClassDef.CLASS);
- cls.setLineNumber(line);
- cls.getModifiers().addAll(modifiers); modifiers.clear();
- cls.setName( $3 );
- cls.setTypeParameters(typeParams);
- builder.beginClass(cls);
- cls = new ClassDef();
- }
- ClassBody
- {
- builder.endClass();
- }
- ;
-
-// TypeParameters:
-// < TypeParameterList >
-TypeParameters: LESSTHAN
- {
- typeParams = new LinkedList<TypeVariableDef>();
- }
- TypeParameterList GREATERTHAN
- ;
-TypeParameters_opt:
- | TypeParameters
- ;
-
-// TypeParameterList:
-// TypeParameter {, TypeParameter}
-TypeParameterList: TypeParameter
- | TypeParameterList COMMA TypeParameter
- ;
-
-// Superclass:
-// extends ClassType
-Superclass_opt:
- | EXTENDS ReferenceType
- {
- cls.getExtends().add($2);
- }
- ;
-
-// Superinterfaces:
-// implements InterfaceTypeList
-Superinterfaces_opt:
- | IMPLEMENTS TypeList
- {
- cls.getImplements().addAll( typeList );
- }
- ;
-
-// InterfaceTypeList:
-// InterfaceType {, InterfaceType}
-//// -> InterfaceTypeList is for QDox the same as TypeList
-
-// ClassBody:
-// { { ClassBodyDeclaration } }
-ClassBody: BRACEOPEN ClassBodyDeclarations_opt BRACECLOSE
- ;
-ClassBody_opt:
- | ClassBody
- ;
-
-// ClassBodyDeclaration:
-// ClassMemberDeclaration
-// InstanceInitializer
-// StaticInitializer
-// ConstructorDeclaration
-// ## for now StaticInitializer includes InstanceInitializer due to parsing errors
-ClassBodyDeclaration: StaticInitializer
- | ClassMemberDeclaration
- | ConstructorDeclaration
- ;
-ClassBodyDeclarations_opt:
- | ClassBodyDeclarations_opt
- {
- line = lexer.getLine();
- }
- ClassBodyDeclaration
- ;
-
-// ClassMemberDeclaration:
-// FieldDeclaration
-// MethodDeclaration
-// ClassDeclaration
-// InterfaceDeclaration
-// ;
-ClassMemberDeclaration: FieldDeclaration
- | MethodDeclaration
- | ClassDeclaration
- | InterfaceDeclaration
- | SEMI
- ;
-
-// FieldDeclaration:
-// {FieldModifier} UnannType VariableDeclaratorList ;
-FieldDeclaration: Modifiers_opt Type VariableDeclaratorId
- {
- fieldType = $2;
- // we're doing some lexer magic: lexer.getCodeBody() contains [= VariableInitializer]
- makeField($3, lexer.getCodeBody(), false);
- builder.beginField(fd);
- builder.endField();
- }
- extrafields SEMI
- {
- modifiers.clear();
- }
- ;
-
-extrafields:
- | extrafields COMMA
- {
- line = lexer.getLine();
- }
- VariableDeclaratorId
- {
- // we're doing some lexer magic: lexer.getCodeBody() contains [= VariableInitializer]
- makeField($4, lexer.getCodeBody(), false);
- builder.beginField(fd);
- builder.endField();
- }
- ;
-
-// VariableDeclaratorId:
-// Identifier [Dims]
-VariableDeclaratorId: IDENTIFIER Dims_opt
- {
- $$ = new TypeDef($1,$2);
- }
- ;
-
-// MethodDeclaration:
-// {MethodModifier} MethodHeader MethodBody
-MethodDeclaration: Modifiers_opt MethodHeader MethodBody
- {
- mth.setBody($3);
- builder.endMethod(mth);
- mth = new MethodDef();
- }
- ;
-
-// VariableInitializer:
-// Expression
-// ArrayInitializer
-VariableInitializer: ArrayInitializer
- | Expression
- ;
-
-// MethodHeader:
-// Result MethodDeclarator [Throws]
-// TypeParameters {Annotation} Result MethodDeclarator [Throws]
-// MethodDeclarator:
-// Identifier ( [FormalParameterList] ) [Dims]
-//## MethodDeclarator must be part of MethodHeader so Parser recognizes this as a Method
-MethodHeader: TypeParameters Type /* =Result */ IDENTIFIER
- {
- builder.beginMethod();
- mth.setLineNumber(lexer.getLine());
- mth.getModifiers().addAll(modifiers); modifiers.clear();
- mth.setTypeParams(typeParams);
- mth.setReturnType($2);
- mth.setName($3);
- }
- PARENOPEN FormalParameterList_opt PARENCLOSE Dims_opt Throws_opt
- {
- mth.setDimensions($8);
- }
- | Type /* =Result */ IDENTIFIER
- {
- builder.beginMethod();
- mth.setLineNumber(lexer.getLine());
- mth.getModifiers().addAll(modifiers); modifiers.clear();
- mth.setReturnType($1);
- mth.setName($2);
- }
- PARENOPEN FormalParameterList_opt PARENCLOSE Dims_opt Throws_opt
- {
- mth.setDimensions($7);
- };
-
-// FormalParameterList:
-// FormalParameters , LastFormalParameter
-// LastFormalParameter
-FormalParameterList: FormalParameters COMMA LastFormalParameter
- | LastFormalParameter
- ;
-FormalParameterList_opt:
- | FormalParameterList
- ;
-
-// FormalParameters:
-// FormalParameter {, FormalParameter}
-// ReceiverParameter {, FormalParameter}
-FormalParameters: FormalParameter
- | FormalParameters COMMA FormalParameter
-// | ReceiverParameter {, FormalParameter}
-// | ReceiverParameter COMMA FormalParameter
- ;
-
-// FormalParameter:
-// {VariableModifier} UnannType VariableDeclaratorId
-FormalParameter: Modifiers_opt Type VariableDeclaratorId
- {
- param.getModifiers().addAll(modifiers); modifiers.clear();
- param.setType($2);
- param.setName($3.getName());
- param.setDimensions($3.getDimensions());
- param.setVarArgs(false);
- builder.addParameter(param);
- param = new FieldDef();
- }
- ;
-
-// LastFormalParameter:
-// {VariableModifier} UnannType {Annotation} ... VariableDeclaratorId
-// FormalParameter
-LastFormalParameter: Modifiers_opt Type DOTDOTDOT VariableDeclaratorId
- {
- param.getModifiers().addAll(modifiers); modifiers.clear();
- param.setType($2);
- param.setName($4.getName());
- param.setDimensions($4.getDimensions());
- param.setVarArgs(true);
- builder.addParameter(param);
- param = new FieldDef();
- }
- | FormalParameter
- ;
-
-// ReceiverParameter:
-// {Annotation} UnannType [Identifier .] this
-// ## todo
-
-// Throws:
-// throws ExceptionTypeList
-Throws_opt:
- | THROWS ExceptionTypeList
- ;
-
-// ExceptionTypeList:
-// ExceptionType {, ExceptionType}
-ExceptionTypeList: ClassOrInterfaceType /* =ExceptionType */
- {
- mth.getExceptions().add($1);
- }
- | ExceptionTypeList COMMA ClassOrInterfaceType /* =ExceptionType */
- {
- mth.getExceptions().add($3);
- }
- ;
-
-// MethodBody:
-// Block
-// ;
-MethodBody: CODEBLOCK
- {
- $$ = lexer.getCodeBody();
- }
- | SEMI
- {
- $$ = "";
- }
- ;
-
-// InstanceInitializer:
-// CODEBLOCK
-// {
-// InitDef def = new InitDef();
-// def.setBlockContent(lexer.getCodeBody());
-// builder.addInitializer(def);
-// };
-
-// StaticInitializer:
-// static Block
-StaticInitializer: Modifiers_opt CODEBLOCK
- {
- InitDef def = new InitDef();
- def.setStatic(modifiers.contains("static"));modifiers.clear();
- def.setBlockContent(lexer.getCodeBody());
- builder.addInitializer(def);
- }
- ;
-
-// ConstructorDeclaration:
-// {ConstructorModifier} ConstructorDeclarator [Throws] ConstructorBody
-ConstructorDeclaration: Modifiers_opt IDENTIFIER
- {
- builder.beginConstructor();
- mth.setLineNumber(lexer.getLine());
- mth.getModifiers().addAll(modifiers); modifiers.clear();
- mth.setConstructor(true);
- mth.setName($2);
- }
- PARENOPEN FormalParameterList_opt PARENCLOSE Throws_opt MethodBody /* =ConstructorBody */
- {
- mth.setBody($8);
- builder.endConstructor(mth);
- mth = new MethodDef();
- }
- | Modifiers_opt TypeParameters IDENTIFIER
- {
- builder.beginConstructor();
- mth.setLineNumber(lexer.getLine());
- mth.setTypeParams(typeParams);
- mth.getModifiers().addAll(modifiers); modifiers.clear();
- mth.setConstructor(true);
- mth.setName($3);
- }
- PARENOPEN FormalParameterList_opt PARENCLOSE Throws_opt CODEBLOCK
- {
- mth.setBody(lexer.getCodeBody());
- builder.endConstructor(mth);
- mth = new MethodDef();
- }
- ;
-
-// ConstructorDeclarator:
-// [TypeParameters] SimpleTypeName ( [FormalParameterList] )
-// ** ConstructorBody, ExplicitConstructorInvocation not used by QDox, out of scope
-// ConstructorBody:
-// { [ExplicitConstructorInvocation] [BlockStatements] }
-// ExplicitConstructorInvocation:
-// [TypeArguments] this ( [ArgumentList] ) ;
-// [TypeArguments] super ( [ArgumentList] ) ;
-// ExpressionName . [TypeArguments] super ( [ArgumentList] ) ;
-// Primary . [TypeArguments] super ( [ArgumentList] ) ;
-
-// EnumDeclaration:
-// {ClassModifier} enum Identifier [Superinterfaces] EnumBody
-EnumDeclaration: Modifiers_opt ENUM IDENTIFIER Superinterfaces_opt
- {
- cls.setLineNumber(line);
- cls.getModifiers().addAll(modifiers);
- cls.setName( $3 );
- cls.setType(ClassDef.ENUM);
- builder.beginClass(cls);
- cls = new ClassDef();
- fieldType = new TypeDef($3, 0);
- }
- EnumBody
- ;
-
-// EnumBody:
-// { [EnumConstantList] [,] [EnumBodyDeclarations] }
-/* The optional COMMA causes trouble for the parser
- For that reason the adjusted options of EnumConstants_opt, which will accept all cases
-*/
-EnumBody: BRACEOPEN EnumConstants_opt EnumBodyDeclarations_opt BRACECLOSE
- {
- builder.endClass();
- fieldType = null;
- modifiers.clear();
- }
- ;
-
-// EnumConstantList:
-// EnumConstant {, EnumConstant}
-
-// EnumConstants:
-// EnumConstant
-// EnumConstants , EnumConstant
-EnumConstants_opt:
- | EnumConstants_opt COMMA
- | EnumConstants_opt EnumConstant
- ;
-
-// EnumConstant:
-// {EnumConstantModifier} Identifier [( [ArgumentList] )] [ClassBody]
-EnumConstant: Annotations_opt IDENTIFIER
- {
- TypeDef td = new TypeDef($2, 0);
- typeStack.push(td);
- makeField( td, "", true );
- builder.beginField( fd );
- }
- Arguments_opt ClassBody_opt
- {
- builder.endField();
- typeStack.pop();
- }
- ;
-
-// EnumBodyDeclarations:
-// ; {ClassBodyDeclaration}
-EnumBodyDeclarations_opt:
- | SEMI ClassBodyDeclarations_opt
- ;
-
-// -----------------------------
-// Productions from �9 (Interfaces)
-// -----------------------------
-
-// InterfaceDeclaration:
-// NormalInterfaceDeclaration
-// AnnotationTypeDeclaration
-InterfaceDeclaration: NormalInterfaceDeclaration
- | AnnotationTypeDeclaration
- ;
-
-// NormalInterfaceDeclaration:
-// {InterfaceModifier} interface Identifier [TypeParameters] [ExtendsInterfaces] InterfaceBody
-NormalInterfaceDeclaration: Modifiers_opt INTERFACE IDENTIFIER TypeParameters_opt ExtendsInterfaces_opt
- {
- cls.setType(ClassDef.INTERFACE);
- cls.setLineNumber(line);
- cls.getModifiers().addAll(modifiers); modifiers.clear();
- cls.setName( $3 );
- cls.setTypeParameters(typeParams);
- builder.beginClass(cls);
- cls = new ClassDef();
- }
- ClassBody
- {
- builder.endClass();
- }
- ;
-
-// ExtendsInterfaces:
-// extends InterfaceTypeList
-ExtendsInterfaces: EXTENDS TypeList
- {
- cls.getExtends().addAll( typeList );
- typeList.clear();
- }
- ;
-ExtendsInterfaces_opt:
- | ExtendsInterfaces
- ;
-
-// InterfaceBody:
-// { {InterfaceMemberDeclaration} }
-// InterfaceMemberDeclaration:
-// ConstantDeclaration
-// InterfaceMethodDeclaration
-// ClassDeclaration
-// InterfaceDeclaration
-// ;
-// ConstantDeclaration:
-// {ConstantModifier} UnannType VariableDeclaratorList ;
-// ConstantModifier:
-// Annotation public
-// static final
-// InterfaceMethodDeclaration:
-// {InterfaceMethodModifier} MethodHeader MethodBody
-// InterfaceMethodModifier:
-// Annotation public
-// abstract default static strictfp
-
-// AnnotationTypeDeclaration:
-// {InterfaceModifier} @ interface Identifier AnnotationTypeBody
-AnnotationTypeDeclaration: Modifiers_opt ANNOINTERFACE IDENTIFIER
- {
- cls.setType(ClassDef.ANNOTATION_TYPE);
- cls.setLineNumber(line);
- cls.getModifiers().addAll(modifiers); modifiers.clear();
- cls.setName( $3 );
- builder.beginClass(cls);
- cls = new ClassDef();
- }
- ClassBody
- {
- builder.endClass();
- }
- ;
-
-// AnnotationTypeBody:
-// { {AnnotationTypeMemberDeclaration} }
-// AnnotationTypeMemberDeclaration:
-// AnnotationTypeElementDeclaration
-// ConstantDeclaration
-// ClassDeclaration
-// InterfaceDeclaration
-// ;
-// AnnotationTypeElementDeclaration:
-// {AnnotationTypeElementModifier} UnannType Identifier ( ) [Dims] [DefaultValue] ;
-// AnnotationTypeElementModifier:
-// Annotation public
-// abstract
-// DefaultValue:
-// default ElementValue
-
-// Annotation:
-// NormalAnnotation
-// MarkerAnnotation
-// SingleElementAnnotation
-// NormalAnnotation:
-// @ TypeName ( [ElementValuePairList] )
-// MarkerAnnotation:
-// @ TypeName
-// SingleElementAnnotation:
-// @ TypeName ( ElementValue )
-Annotation: AT QualifiedIdentifier
- {
- AnnoDef annotation = new AnnoDef( new TypeDef($2) );
- annotation.setLineNumber(lexer.getLine());
- annotationStack.addFirst(annotation);
- }
- _AnnotationParens_opt
- {
- AnnoDef annotation = annotationStack.removeFirst();
- if(annotationStack.isEmpty())
- {
- builder.addAnnotation(annotation);
- }
- $$ = annotation;
- }
- ;
-
-// ElementValuePairList:
-// ElementValuePair { , ElementValuePair }
-ElementValuePairList: ElementValuePair
- | ElementValuePairList COMMA ElementValuePair
- ;
-
-// ElementValuePair:
-// Identifier = ElementValue
-ElementValuePair: IDENTIFIER EQUALS ElementValue
- {
- annotationStack.getFirst().getArgs().put($1, $3);
- }
- ;
-
-// ElementValue:
-// ConditionalExpression
-// ElementValueArrayInitializer
-// Annotation
-ElementValue: ConditionalExpression
- | Annotation
- | ElementValueArrayInitializer
- ;
-
-// ElementValueArrayInitializer:
-// { [ElementValueList] [,] }
-/* Specs say: { ElementValues_opt COMMA_opt }
- The optional COMMA causes trouble for the parser
- For that reason the adjusted options of ElementValues_opt, which will accept all cases
-*/
-ElementValueArrayInitializer: {
- annoValueListStack.add(annoValueList);
- annoValueList = new LinkedList<ElemValueDef>();
- }
- BRACEOPEN ElementValues_opt BRACECLOSE
- {
- $$ = new ElemValueListDef(annoValueList);
- annoValueList = annoValueListStack.remove(annoValueListStack.size() - 1);
- }
- ;
-
-
-// AnnotationElement:
-// ElementValuePairList
-// ElementValue
-AnnotationElement_opt:
- | ElementValuePairList
- | ElementValue
- {
- annotationStack.getFirst().getArgs().put("value", $1);
- }
- ;
-
-ElementValues_opt:
- | ElementValues_opt ElementValue
- {
- annoValueList.add($2);
- }
- | ElementValues_opt COMMA;
-
-//--------------------------------------------------------
- _AnnotationParens_opt:
- | PARENOPEN AnnotationElement_opt PARENCLOSE
- ;
-
-
-Annotations_opt:
- | Annotations_opt Annotation;
-
-// -----------------------------
-// Productions from �10 (Arrays)
-// -----------------------------
-
-// ArrayInitializer:
-// { [VariableInitializerList] [,] }
-ArrayInitializer: BRACEOPEN VariableInitializerList_opt BRACECLOSE
- ;
-
-// VariableInitializerList:
-// VariableInitializer {, VariableInitializer}
-VariableInitializerList: VariableInitializerList VariableInitializer
- | VariableInitializerList COMMA
- ;
-VariableInitializerList_opt:
- | VariableInitializerList
- ;
-// ----------------------------------
-// Productions from �15 (Expressions)
-// ----------------------------------
-
-// Primary:
-// PrimaryNoNewArray
-// ArrayCreationExpression
-Primary: PrimaryNoNewArray
- | ArrayCreationExpression
- ;
-
-// PrimaryNoNewArray:
-// Literal
-// TypeName {[ ]} . class
-// void . class
-// this
-// TypeName . this
-// ( Expression )
-// ClassInstanceCreationExpression
-// FieldAccess
-// ArrayAccess
-// MethodInvocation
-// MethodReference
-PrimaryNoNewArray: Literal
- | PrimitiveType Dims_opt DOT CLASS
- {
- $$ = new TypeRefDef(new TypeDef($1.getName(), $2));
- }
- | PARENOPEN Expression PARENCLOSE
- {
- $$ = new ParenExpressionDef($2);
- }
- | ClassInstanceCreationExpression
- | QualifiedIdentifier DOT CLASS
- {
- $$ = new TypeRefDef(new TypeDef($1, 0));
- }
- | QualifiedIdentifier Dims DOT CLASS
- {
- $$ = new TypeRefDef(new TypeDef($1, $2));
- }
- | QualifiedIdentifier
- {
- $$ = new FieldRefDef($1);
- }
- | MethodInvocation
- ;
-
-// ClassInstanceCreationExpression:
-// new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
-// ExpressionName . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
-// Primary . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody]
-//// TypeArguments_opt confuses parser
-ClassInstanceCreationExpression: NEW TypeArguments_opt IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE ClassBody_opt
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $3 );
- $$ = creator;
- }
- | NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE ClassBody_opt
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $2 );
- $$ = creator;
- }
- ;
-
-// TypeArgumentsOrDiamond:
-// TypeArguments
-// <>
-TypeArgumentsOrDiamond: TypeArguments
- | LESSTHAN GREATERTHAN
- ;
-TypeArgumentsOrDiamond_opt:
- | TypeArgumentsOrDiamond
- ;
-
-// FieldAccess:
-// Primary . Identifier
-// super . Identifier
-// TypeName . super . Identifier
-// ArrayAccess:
-// ExpressionName [ Expression ]
-// PrimaryNoNewArray [ Expression ]
-
-// MethodInvocation:
-// MethodName ( [ArgumentList] )
-// TypeName . [TypeArguments] Identifier ( [ArgumentList] )
-// ExpressionName . [TypeArguments] Identifier ( [ArgumentList] )
-// Primary . [TypeArguments] Identifier ( [ArgumentList] )
-// super . [TypeArguments] Identifier ( [ArgumentList] )
-// TypeName . super . [TypeArguments] Identifier ( [ArgumentList] )
-MethodInvocation: IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
- {
- $$ = new MethodInvocationDef($1, null);
- }
- | SUPER DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
- {
- $$ = new MethodInvocationDef($1, null);
- }
- | QualifiedIdentifier DOT SUPER DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
- {
- $$ = new MethodInvocationDef($1 + ".super", null);
- }
- | QualifiedIdentifier DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
- {
- $$ = new MethodInvocationDef($1, null);
- }
- ;
-
-// ArgumentList:
-// Expression {, Expression}
-ArgumentList: Expression
- {
- builder.addArgument( (ExpressionDef) $1);
- }
- | ArgumentList COMMA Expression
- {
- builder.addArgument( (ExpressionDef) $3);
- }
- ;
-ArgumentList_opt:
- | ArgumentList
- ;
-
-// MethodReference:
-// ExpressionName :: [TypeArguments] Identifier
-// ReferenceType :: [TypeArguments] Identifier
-// Primary :: [TypeArguments] Identifier
-// super :: [TypeArguments] Identifier
-// TypeName . super :: [TypeArguments] Identifier
-// ClassType :: [TypeArguments] new
-// ArrayType :: new
-
-// ArrayCreationExpression:
-// new PrimitiveType DimExprs [Dims]
-// new ClassOrInterfaceType DimExprs [Dims]
-// new PrimitiveType Dims ArrayInitializer
-// new ClassOrInterfaceType Dims ArrayInitializer
-ArrayCreationExpression: NEW PrimitiveType DimExprs Dims_opt
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $2.getName() );
- $$ = creator;
- }
- | NEW ClassOrInterfaceType DimExprs Dims_opt
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $2.getName() );
- $$ = creator;
- }
- | NEW PrimitiveType Dims ArrayInitializer
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $2.getName() );
- $$ = creator;
- }
- | NEW ClassOrInterfaceType Dims ArrayInitializer
- {
- CreatorDef creator = new CreatorDef();
- creator.setCreatedName( $2.getName() );
- $$ = creator;
- }
- ;
-
-// DimExprs:
-// DimExpr {DimExpr}
-DimExprs: DimExpr
- | DimExprs DimExpr
- ;
-
-// DimExpr:
-// {Annotation} [ Expression ]
-DimExpr: SQUAREOPEN Expression SQUARECLOSE
- ;
-
-// ConstantExpression:
-// Expression
-
-// Expression:
-// LambdaExpression
-// AssignmentExpression
-Expression: AssignmentExpression
- ;
-
-// LambdaExpression:
-// LambdaParameters -> LambdaBody
-// LambdaParameters:
-// Identifier
-// ( [FormalParameterList] )
-// ( InferredFormalParameterList )
-// InferredFormalParameterList:
-// Identifier {, Identifier}
-// LambdaBody:
-// Expression
-// Block
-
-// AssignmentExpression:
-// ConditionalExpression
-// Assignment
-AssignmentExpression: ConditionalExpression
- | Assignment
- ;
-
-// Assignment:
-// LeftHandSide AssignmentOperator Expression
-Assignment: LeftHandSide AssignmentOperator Expression
- {
- $$ = new AssignmentDef($1, $2, $3);
- }
- ;
-
-// LeftHandSide:
-// ExpressionName
-// FieldAccess
-// ArrayAccess
-LeftHandSide: QualifiedIdentifier
- {
- $$ = new FieldRefDef($1);
- }
- ;
-
-// AssignmentOperator:
-// =
-// *=
-// /=
-// %=
-// +=
-// -=
-// <<=
-// >>=
-// >>>=
-// &=
-// ^=
-// |=
-AssignmentOperator: EQUALS
- | STAREQUALS
- | SLASHEQUALS
- | PERCENTEQUALS
- | PLUSEQUALS
- | MINUSEQUALS
- | LESSTHAN2EQUALS
- | GREATERTHAN2EQUALS
- | GREATERTHAN3EQUALS
- | AMPERSANDEQUALS
- | CIRCUMFLEXEQUALS
- | VERTLINEEQUALS
- ;
-
-// ConditionalExpression:
-// ConditionalOrExpression
-// ConditionalOrExpression ? Expression : ConditionalExpression
-ConditionalExpression: ConditionalOrExpression
- | ConditionalOrExpression QUERY Expression COLON ConditionalExpression
- {
- $$ = new QueryDef($1, $3, $5);
- }
- ;
-
-// ConditionalOrExpression:
-// ConditionalAndExpression
-// ConditionalOrExpression || ConditionalAndExpression
-ConditionalOrExpression: ConditionalAndExpression
- | ConditionalOrExpression VERTLINE2 ConditionalAndExpression
- {
- $$ = new LogicalOrDef($1, $3);
- }
- ;
-
-// ConditionalAndExpression:
-// InclusiveOrExpression
-// ConditionalAndExpression && InclusiveOrExpression
-ConditionalAndExpression: InclusiveOrExpression
- | ConditionalAndExpression AMPERSAND2 InclusiveOrExpression
- {
- $$ = new LogicalAndDef($1, $3);
- }
- ;
-
-// InclusiveOrExpression:
-// ExclusiveOrExpression
-// InclusiveOrExpression | ExclusiveOrExpression
-InclusiveOrExpression: ExclusiveOrExpression
- | InclusiveOrExpression VERTLINE ExclusiveOrExpression
- {
- $$ = new OrDef($1, $3);
- }
- ;
-
-// ExclusiveOrExpression:
-// AndExpression
-// ExclusiveOrExpression ^ AndExpression
-ExclusiveOrExpression: AndExpression
- | ExclusiveOrExpression CIRCUMFLEX AndExpression
- {
- $$ = new ExclusiveOrDef($1, $3);
- }
- ;
-
-// AndExpression:
-// EqualityExpression
-// AndExpression & EqualityExpression
-AndExpression: EqualityExpression
- | AndExpression AMPERSAND EqualityExpression
- {
- $$ = new AndDef($1, $3);
- }
- ;
-
-// EqualityExpression:
-// RelationalExpression
-// EqualityExpression == RelationalExpression
-// EqualityExpression != RelationalExpression
-EqualityExpression: RelationalExpression
- | EqualityExpression EQUALS2 RelationalExpression
- {
- $$ = new EqualsDef($1, $3);
- }
- | EqualityExpression NOTEQUALS RelationalExpression
- {
- $$ = new NotEqualsDef($1, $3);
- }
- ;
-
-// RelationalExpression:
-// ShiftExpression
-// RelationalExpression < ShiftExpression
-// RelationalExpression > ShiftExpression
-// RelationalExpression <= ShiftExpression
-// RelationalExpression >= ShiftExpression
-// RelationalExpression instanceof ReferenceType
-RelationalExpression: ShiftExpression
- | RelationalExpression LESSTHAN ShiftExpression
- {
- $$ = new LessThanDef($1, $3);
- }
- | RelationalExpression GREATERTHAN ShiftExpression
- {
- $$ = new GreaterThanDef($1, $3);
- }
- | RelationalExpression LESSEQUALS ShiftExpression
- {
- $$ = new LessEqualsDef($1, $3);
- }
- | RelationalExpression GREATEREQUALS ShiftExpression
- {
- $$ = new GreaterEqualsDef($1, $3);
- }
- ;
-
-// ShiftExpression:
-// AdditiveExpression
-// ShiftExpression << AdditiveExpression
-// ShiftExpression >> AdditiveExpression
-// ShiftExpression >>> AdditiveExpression
-ShiftExpression: AdditiveExpression
- | ShiftExpression LESSTHAN2 AdditiveExpression
- {
- $$ = new ShiftLeftDef($1, $3);
- }
- | ShiftExpression GREATERTHAN2 AdditiveExpression
- {
- $$ = new ShiftRightDef($1, $3);
- }
- | ShiftExpression GREATERTHAN3 AdditiveExpression
- {
- $$ = new UnsignedShiftRightDef($1, $3);
- }
- ;
-
-// AdditiveExpression:
-// MultiplicativeExpression
-// AdditiveExpression + MultiplicativeExpression
-// AdditiveExpression - MultiplicativeExpression
-AdditiveExpression: MultiplicativeExpression
- | AdditiveExpression PLUS MultiplicativeExpression
- {
- $$ = new AddDef($1, $3);
- }
- | AdditiveExpression MINUS MultiplicativeExpression
- {
- $$ = new SubtractDef($1, $3);
- }
- ;
-
-// MultiplicativeExpression:
-// UnaryExpression
-// MultiplicativeExpression * UnaryExpression
-// MultiplicativeExpression / UnaryExpression
-// MultiplicativeExpression % UnaryExpression
-MultiplicativeExpression: UnaryExpression
- | MultiplicativeExpression STAR UnaryExpression
- {
- $$ = new MultiplyDef($1, $3);
- }
- | MultiplicativeExpression SLASH UnaryExpression
- {
- $$ = new DivideDef($1, $3);
- }
- | MultiplicativeExpression PERCENT UnaryExpression
- {
- $$ = new RemainderDef($1, $3);
- }
- ;
-
-// UnaryExpression:
-// PreIncrementExpression
-// PreDecrementExpression
-// + UnaryExpression
-// - UnaryExpression
-// UnaryExpressionNotPlusMinus
-UnaryExpression: PreIncrementExpression
- | PreDecrementExpression
- | PLUS UnaryExpression
- {
- $$ = new PlusSignDef($2);
- }
- | MINUS UnaryExpression
- {
- $$ = new MinusSignDef($2);
- }
- | UnaryExpressionNotPlusMinus
- ;
-
-// PreIncrementExpression:
-// ++ UnaryExpression
-PreIncrementExpression: PLUSPLUS UnaryExpression
- {
- $$ = new PreIncrementDef($2);
- }
- ;
-
-// PreDecrementExpression:
-// -- UnaryExpression
-PreDecrementExpression: MINUSMINUS UnaryExpression
- {
- $$ = new PreDecrementDef($2);
- }
- ;
-
-// UnaryExpressionNotPlusMinus:
-// PostfixExpression
-// ~ UnaryExpression
-// ! UnaryExpression
-// CastExpression
-UnaryExpressionNotPlusMinus: PostfixExpression
- | TILDE UnaryExpression
- {
- $$ = new NotDef($2);
- }
- | EXCLAMATION UnaryExpression
- {
- $$ = new LogicalNotDef($2);
- }
- | CastExpression
- ;
-
-// PostfixExpression:
-// Primary
-// ExpressionName
-// PostIncrementExpression
-// PostDecrementExpression
-PostfixExpression: Primary
- | PostIncrementExpression
- | PostDecrementExpression
- ;
-
-// PostIncrementExpression:
-// PostfixExpression ++
-PostIncrementExpression: PostfixExpression PLUSPLUS
- {
- $$ = new PostIncrementDef($1);
- }
- ;
-
-// PostDecrementExpression:
-// PostfixExpression --
-PostDecrementExpression: PostfixExpression MINUSMINUS
- {
- $$ = new PostDecrementDef($1);
- }
- ;
-
-// CastExpression:
-// ( PrimitiveType ) UnaryExpression
-// ( ReferenceType {AdditionalBound} ) UnaryExpressionNotPlusMinus
-// ( ReferenceType {AdditionalBound} ) LambdaExpression
-CastExpression: PARENOPEN PrimitiveType Dims_opt PARENCLOSE UnaryExpression
- {
- $$ = new CastDef(new TypeDef($2.getName(), $3), $5);
- }
- | PARENOPEN QualifiedIdentifier PARENCLOSE UnaryExpressionNotPlusMinus
- {
- $$ = new CastDef(new TypeDef($2, 0), $4);
- }
- | PARENOPEN QualifiedIdentifier Dims PARENCLOSE UnaryExpressionNotPlusMinus
- {
- $$ = new CastDef(new TypeDef($2, $3), $5);
- }
- ;
-
-
-// --------------------------------------------------
-// Productions from §4 (Types, Values, and Variables)
-// --------------------------------------------------
-
-// Type:
-// PrimitiveType
-// ReferenceType
-Type: PrimitiveType
- | ReferenceType
+
+// ----- TOP LEVEL
+
+// A file consists of 0-n fileparts...
+file: | file { line = lexer.getLine(); } filepart;
+
+// And a filepart is a package/import statement, javadoc comment, or class declaration.
+filepart: annotation { builder.addAnnotation((Annotation) $1); } | package | import | javadoc | class | enum | SEMI;
+
+// Package statement
+package: PACKAGE fullidentifier SEMI { builder.addPackage(new PackageDef($2, line)); };
+
+// Import statement
+import: IMPORT fullidentifier SEMI { builder.addImport($2); } |
+ IMPORT STATIC fullidentifier SEMI { builder.addImport("static " + $3); };
+
+
+// ----- JAVADOC
+
+javadoclist:
+ javadoc |
+ javadoclist javadoc;
+
+javadoc: JAVADOCSTART javadocdescription javadoctags JAVADOCEND;
+
+javadocdescription:
+ javadoctokens {
+ builder.addJavaDoc(buffer());
+ };
+
+javadoctokens: | javadoctokens javadoctoken;
+
+javadoctoken:
+ JAVADOCLINE {
+ appendToBuffer($1);
+ }
+
+javadoctags: | javadoctags javadoctag;
+
+javadoctag:
+ JAVADOCTAG { line = lexer.getLine(); }
+ javadoctokens {
+ builder.addJavaDocTag(new TagDef($1.substring(1), buffer(), line));
+ };
+
+
+// ----- COMMON TOKENS
+
+// A fullidentifier is "a", "a.b", "a.b.c", "a.b.*", etc...
+fullidentifier:
+ IDENTIFIER { $$ = $1; } |
+ fullidentifier DOT IDENTIFIER { $$ = $1 + '.' + $3; } |
+ fullidentifier DOT STAR { $$ = $1 + ".*"; };
+
+arrayidentifier:
+ IDENTIFIER dimensions {
+ $$ = new TypeDef($1,$2);
+ };
+
+dimensions:
+ /* empty */ { $$ = 0; }
+ | dimensions SQUAREOPEN SQUARECLOSE {
+ $$ = $1 + 1;
+ };
+
+// Modifiers to methods, fields, classes, interfaces, parameters, etc...
+modifier:
+ PUBLIC { $$ = "public"; } |
+ PROTECTED { $$ = "protected"; } |
+ PRIVATE { $$ = "private"; } |
+ STATIC { $$ = "static"; } |
+ FINAL { $$ = "final"; } |
+ ABSTRACT { $$ = "abstract"; } |
+ NATIVE { $$ = "native"; } |
+ SYNCHRONIZED { $$ = "synchronized"; } |
+ VOLATILE { $$ = "volatile"; } |
+ TRANSIENT { $$ = "transient"; } |
+ STRICTFP { $$ = "strictfp"; } ;
+
+modifiers:
+ modifiers modifier { modifiers.add($2); } |
+ modifiers annotation { builder.addAnnotation((Annotation) $2); } |
+ modifiers javadoc |
;
-// PrimitiveType:
-// {Annotation} NumericType
-// {Annotation} boolean
-// NumericType:
-// IntegralType
-// FloatingPointType
-// IntegralType:
-// byte short int long char
-// FloatingPointType:
-// float double
-
-// ReferenceType:
-// ClassOrInterfaceType
-// TypeVariable
-// ArrayType
-ReferenceType: ArrayType
- | ClassOrInterfaceType
- ;
-
-// ClassOrInterfaceType:
-// ClassType
-// InterfaceType
-// ClassType:
-// {Annotation} Identifier [TypeArguments]
-// ClassOrInterfaceType . {Annotation} Identifier [TypeArguments]
-// InterfaceType:
-// ClassType
-// TypeVariable:
-// {Annotation} Identifier
-
-// ArrayType:
-// PrimitiveType Dims
-// ClassOrInterfaceType Dims
-// TypeVariable Dims
-ArrayType: ClassOrInterfaceType Dims
- {
- TypeDef td = $1;
- td.setDimensions($2);
- $$ = td;
- }
- | PrimitiveType Dims
- {
- TypeDef td = $1;
- td.setDimensions($2);
- $$ = td;
- }
- ;
-
-// Dims:
-// {Annotation} [ ] {{Annotation} [ ]}
-Dims: SQUAREOPEN SQUARECLOSE
- {
- $$ = 1;
- }
- | Dims SQUAREOPEN SQUARECLOSE
- {
- $$ = $1 + 1;
- };
-Dims_opt: {
- $$ = 0;
- }
- | Dims
- ;
-
-// TypeParameter:
-// {TypeParameterModifier} Identifier [TypeBound]
-TypeParameter: IDENTIFIER
- {
- typeVariable = new TypeVariableDef($1);
- typeVariable.setBounds(new LinkedList<TypeDef>());
- }
- TypeBound_opt
- {
- typeParams.add(typeVariable);
- typeVariable = null;
- };
-
-// TypeBound:
-// extends TypeVariable
-// extends ClassOrInterfaceType {AdditionalBound}
-TypeBound: EXTENDS ClassOrInterfaceType
- {
- typeVariable.setBounds(new LinkedList<TypeDef>());
- typeVariable.getBounds().add($2);
- }
- AdditionalBound_opts
- ;
-TypeBound_opt:
- | TypeBound
- ;
-
-// AdditionalBound:
-// & InterfaceType
-AdditionalBound: AMPERSAND ClassOrInterfaceType
- {
- typeVariable.getBounds().add($2);
- }
- ;
-AdditionalBound_opts:
- | AdditionalBound AdditionalBound_opts
- ;
-
-// TypeArguments:
-// < TypeArgumentList >
-TypeArguments: LESSTHAN
- {
- typeStack.peek().setActualArgumentTypes(new LinkedList<TypeDef>());
- }
- TypeArgumentList GREATERTHAN
- ;
-TypeArguments_opt:
- | TypeArguments
- ;
-
-// TypeArgumentList:
-// TypeArgument {, TypeArgument}
-TypeArgumentList: TypeArgument
- {
- (typeStack.peek()).getActualArgumentTypes().add($1);
- }
- | TypeArgumentList COMMA TypeArgument
- {
- (typeStack.peek()).getActualArgumentTypes().add($3);
- }
- ;
-
-// TypeArgument:
-// ReferenceType
-// Wildcard
-TypeArgument: ReferenceType
- | Wildcard
- ;
-
-// Wildcard:
-// {Annotation} ? [WildcardBounds]
-Wildcard: QUERY WildcardBounds
- {
- $$ = $2;
- }
- | QUERY
- {
- $$ = new WildcardTypeDef();
- }
- ;
-
-// WildcardBounds:
-// extends ReferenceType
-// super ReferenceType
-WildcardBounds: EXTENDS ReferenceType
- {
- $$ = new WildcardTypeDef($2, "extends" );
- }
- | SUPER ReferenceType
- {
- $$ = new WildcardTypeDef($2, "super" );
- }
- ;
-
-//========================================================
-// QualifiedIdentifier:
-// Identifier { . Identifier }
-QualifiedIdentifier: IDENTIFIER
- | QualifiedIdentifier DOT IDENTIFIER
- {
- $$ = $1 + '.' + $3;
- }
- ;
-
-// TypeName:
-// Identifier
-// PackageOrTypeName . Identifier
-
-// PackageOrTypeName:
-// Identifier
-// PackageOrTypeName . Identifier
-
-//========================================================
-
-
-// PrimitiveType:
-// byte
-// short
-// char
-// int
-// long
-// float
-// double
-// boolean
-PrimitiveType: BYTE
- {
- $$ = new TypeDef("byte");
- }
- | SHORT
- {
- $$ = new TypeDef("short");
- }
- | CHAR
- {
- $$ = new TypeDef("char");
- }
- | INT
- {
- $$ = new TypeDef("int");
- }
- | LONG
- {
- $$ = new TypeDef("long");
- }
- | FLOAT
- {
- $$ = new TypeDef("float");
- }
- | DOUBLE
- {
- $$ = new TypeDef("double");
- }
- | BOOLEAN
- {
- $$ = new TypeDef("boolean");
- }
- ;
-
-// Actually
-// ClassOrInterfaceType: ClassType | InterfaceType;
-// ClassType: TypeDeclSpecifier TypeArguments_opt
-// InterfaceType: TypeDeclSpecifier TypeArguments_opt
-// Parser can't see the difference
-ClassOrInterfaceType: TypeDeclSpecifier
- {
- TypeDef td = new TypeDef($1,0);
- $$ = typeStack.push(td);
- }
- TypeArguments_opt
- {
- $$ = typeStack.pop();
- };
-// Actually
-// TypeDeclSpecifier: TypeName | ClassOrInterfaceType . Identifier
-// TypeName: Identifier | TypeName . Identifier
-TypeDeclSpecifier: QualifiedIdentifier
- | ClassOrInterfaceType DOT IDENTIFIER
- {
- $$ = $1.getName() + '.' + $3;
- };
-
-
-
-
-
-//========================================================
-
-// TypeList:
-// ReferenceType { , ReferenceType }
-TypeList: ReferenceType
- {
- typeList.add( $1 );
- }
- | TypeList COMMA ReferenceType
- {
- typeList.add( $3 );
- }
- ;
-//========================================================
-Modifiers_opt:
- | Modifiers_opt Modifier;
-
-// Modifier:
-// Annotation
-// public
-// protected
-// private
-// static
-// abstract
-// final
-// native
-// synchronized
-// transient
-// volatile
-// strictfp
-Modifier: Annotation
- | PUBLIC
- {
- modifiers.add("public");
- }
- | PROTECTED
- {
- modifiers.add("protected");
- }
- | PRIVATE
- {
- modifiers.add("private");
- }
- | STATIC
- {
- modifiers.add("static");
- }
- | FINAL
- {
- modifiers.add("final");
- }
- | ABSTRACT
- {
- modifiers.add("abstract");
- }
- | NATIVE
- {
- modifiers.add("native");
- }
- | SYNCHRONIZED
- {
- modifiers.add("synchronized");
- }
- | VOLATILE
- {
- modifiers.add("volatile");
- }
- | TRANSIENT
- {
- modifiers.add("transient");
- }
- | STRICTFP
- {
- modifiers.add("strictfp");
- }
- | DEFAULT
- {
- modifiers.add("default");
- }
- ;
-
-Arguments_opt:
- | PARENOPEN ArgumentList_opt PARENCLOSE
- ;
-
-
-
-//========================================================
-
-
-
-// Literal:
-// IntegerLiteral
-// FloatingPointLiteral
-// CharacterLiteral
-// StringLiteral
-// BooleanLiteral
-// NullLiteral
-Literal: INTEGER_LITERAL
- {
- $$ = new ConstantDef($1, Integer.class);
- }
- | FLOAT_LITERAL
- {
- $$ = new ConstantDef($1, Float.class);
- }
- | CHAR_LITERAL
- {
- String s = lexer.getCodeBody();
- $$ = new ConstantDef(s, Character.class);
- }
- | STRING_LITERAL
- {
- String s = lexer.getCodeBody();
- $$ = new ConstantDef(s, String.class);
- }
- | BOOLEAN_LITERAL
- {
- $$ = new ConstantDef($1, Boolean.class);
- }
- ;
-
-//========================================================
+
+//--------------------------------------------------------------------------------
+// ANNOTATIONS
+//--------------------------------------------------------------------------------
+
+annotation:
+ AT name
+ {
+ annotationStack.add(annotation);
+ annotation = new Annotation(builder.createType($2, 0), lexer.getLine());
+ }
+ annotationParensOpt
+ {
+ $$ = annotation;
+ annotation = (Annotation)annotationStack.remove(annotationStack.size() - 1);
+ };
+
+annotationParensOpt:
+ |
+ PARENOPEN value PARENCLOSE { annotation.setProperty("value", $2); } |
+ PARENOPEN valuePairs PARENCLOSE |
+ PARENOPEN PARENCLOSE;
+
+valuePairs:
+ valuePair |
+ valuePairs COMMA valuePair;
+
+valuePair:
+ IDENTIFIER EQUALS value { annotation.setProperty($1, $3); };
+
+arrayInitializer:
+ {
+ annoValueListStack.add(annoValueList);
+ annoValueList = new ArrayList();
+ }
+ BRACEOPEN valuesOpt BRACECLOSE
+ {
+ $$ = new AnnotationValueList(annoValueList);
+ annoValueList = (List)annoValueListStack.remove(annoValueListStack.size() - 1);
+ };
+
+valuesOpt:
+ |
+ values;
+
+values:
+ value { annoValueList.add($1); } |
+ values COMMA value { annoValueList.add($3); };
+
+value:
+ expression { $$ = $1; } |
+ annotation { $$ = $1; } |
+ arrayInitializer { $$ = $1; };
+
+expression:
+ conditionalExpression { $$ = $1; };
+
+conditionalExpression:
+ conditionalOrExpression { $$ = $1; } |
+ conditionalOrExpression QUERY expression COLON expression { $$ = new AnnotationQuery($1, $3, $5); };
+
+conditionalOrExpression:
+ conditionalAndExpression { $$ = $1; } |
+ conditionalOrExpression VERTLINE2 conditionalAndExpression { $$ = new AnnotationLogicalOr($1, $3); };
+
+conditionalAndExpression:
+ inclusiveOrExpression { $$ = $1; } |
+ conditionalAndExpression AMPERSAND2 inclusiveOrExpression { $$ = new AnnotationLogicalAnd($1, $3); };
+
+inclusiveOrExpression:
+ exclusiveOrExpression { $$ = $1; } |
+ inclusiveOrExpression VERTLINE exclusiveOrExpression { $$ = new AnnotationOr($1, $3); };
+
+exclusiveOrExpression:
+ andExpression { $$ = $1; } |
+ exclusiveOrExpression CIRCUMFLEX andExpression { $$ = new AnnotationExclusiveOr($1, $3); };
+
+andExpression:
+ equalityExpression { $$ = $1; } |
+ andExpression AMPERSAND equalityExpression { $$ = new AnnotationAnd($1, $3); };
+
+equalityExpression:
+ relationalExpression { $$ = $1; } |
+ equalityExpression EQUALS2 relationalExpression { $$ = new AnnotationEquals($1, $3); } |
+ equalityExpression NOTEQUALS relationalExpression { $$ = new AnnotationNotEquals($1, $3); };
+
+relationalExpression:
+ shiftExpression { $$ = $1; } |
+ relationalExpression LESSEQUALS shiftExpression { $$ = new AnnotationLessEquals($1, $3); } |
+ relationalExpression GREATEREQUALS shiftExpression { $$ = new AnnotationGreaterEquals($1, $3); } |
+ relationalExpression LESSTHAN shiftExpression { $$ = new AnnotationLessThan($1, $3); } |
+ relationalExpression GREATERTHAN shiftExpression { $$ = new AnnotationGreaterThan($1, $3); };
+
+shiftExpression:
+ additiveExpression { $$ = $1; } |
+ shiftExpression LESSTHAN2 additiveExpression { $$ = new AnnotationShiftLeft($1, $3); } |
+ shiftExpression GREATERTHAN3 additiveExpression { $$ = new AnnotationUnsignedShiftRight($1, $3); } |
+ shiftExpression GREATERTHAN2 additiveExpression { $$ = new AnnotationShiftRight($1, $3); };
+
+additiveExpression:
+ multiplicativeExpression { $$ = $1; } |
+ additiveExpression PLUS multiplicativeExpression { $$ = new AnnotationAdd($1, $3); } |
+ additiveExpression MINUS multiplicativeExpression { $$ = new AnnotationSubtract($1, $3); };
+
+multiplicativeExpression:
+ unaryExpression { $$ = $1; } |
+ multiplicativeExpression STAR unaryExpression { $$ = new AnnotationMultiply($1, $3); } |
+ multiplicativeExpression SLASH unaryExpression { $$ = new AnnotationDivide($1, $3); } |
+ multiplicativeExpression PERCENT unaryExpression { $$ = new AnnotationRemainder($1, $3); };
+
+unaryExpression:
+ PLUS unaryExpression { $$ = new AnnotationPlusSign($2); } |
+ MINUS unaryExpression { $$ = new AnnotationMinusSign($2); } |
+ unaryExpressionNotPlusMinus { $$ = $1; };
+
+unaryExpressionNotPlusMinus:
+ TILDE unaryExpression { $$ = new AnnotationNot($2); } |
+ EXCLAMATION unaryExpression { $$ = new AnnotationLogicalNot($2); } |
+ primary;
+
+primary:
+ PARENOPEN primitiveType PARENCLOSE unaryExpression { $$ = new AnnotationCast(builder.createType($2, 0), $4); } |
+ PARENOPEN primitiveType dims PARENCLOSE unaryExpression { $$ = new AnnotationCast(builder.createType($2, $3), $5); } |
+ PARENOPEN name dims PARENCLOSE unaryExpressionNotPlusMinus { $$ = new AnnotationCast(builder.createType($2, $3), $5); } |
+ PARENOPEN name PARENCLOSE unaryExpressionNotPlusMinus { $$ = new AnnotationCast(builder.createType($2, 0), $4); } |
+ PARENOPEN expression PARENCLOSE { $$ = new AnnotationParenExpression($2); } |
+ literal { $$ = $1; } |
+ primitiveType dims DOT CLASS { $$ = new AnnotationTypeRef(builder.createType($1, 0)); } |
+ primitiveType DOT CLASS { $$ = new AnnotationTypeRef(builder.createType($1, 0)); } |
+ name DOT CLASS { $$ = new AnnotationTypeRef(builder.createType($1, 0)); } |
+ name dims DOT CLASS { $$ = new AnnotationTypeRef(builder.createType($1, 0)); } |
+ name { $$ = new AnnotationFieldRef($1); };
+
+dims:
+ SQUAREOPEN SQUARECLOSE { $$ = 1; } |
+ dims SQUAREOPEN SQUARECLOSE { $$ = $1 + 1; };
+
+name:
+ IDENTIFIER { $$ = $1; } |
+ name DOT IDENTIFIER { $$ = $1 + "." + $3; };
+
+literal:
+ DOUBLE_LITERAL { $$ = new AnnotationConstant(toDouble($1), $1); } |
+ FLOAT_LITERAL { $$ = new AnnotationConstant(toFloat($1), $1); } |
+ LONG_LITERAL { $$ = new AnnotationConstant(toLong($1), $1); } |
+ INTEGER_LITERAL { $$ = new AnnotationConstant(toInteger($1), $1); } |
+ BOOLEAN_LITERAL { $$ = new AnnotationConstant(toBoolean($1), $1); } |
+ CHAR_LITERAL { String s = lexer.getCodeBody(); $$ = new AnnotationConstant(toChar(s), s); } |
+ STRING_LITERAL { String s = lexer.getCodeBody(); $$ = new AnnotationConstant(toString(s), s); };
+
+primitiveType:
+ BOOLEAN { $$ = "boolean"; } |
+ BYTE { $$ = "byte"; } |
+ SHORT { $$ = "short"; } |
+ INT { $$ = "int"; } |
+ LONG { $$ = "long"; } |
+ CHAR { $$ = "char"; } |
+ FLOAT { $$ = "float"; } |
+ DOUBLE { $$ = "double"; };
+
+
+// ----- TYPES
+
+type:
+ classtype dimensions {
+ TypeDef td = $1;
+ td.dimensions = $2;
+ $$ = td;
+ };
+
+classtype:
+ typedeclspecifier LESSTHAN {
+ TypeDef td = new TypeDef($1,0);
+ td.actualArgumentTypes = new ArrayList();
+ $$ = (TypeDef) typeStack.push(td);
+ } typearglist {
+ $$ = (TypeDef) typeStack.pop();
+ } GREATERTHAN {
+ $$ = $5;
+ } |
+ typedeclspecifier {
+ $$ = new TypeDef($1,0);
+ };
+
+typedeclspecifier:
+ typename { $$ = $1; } |
+ classtype DOT IDENTIFIER { $$ = $1.name + '.' + $3; };
+
+typename:
+ IDENTIFIER { $$ = $1; } |
+ typename DOT IDENTIFIER { $$ = $1 + '.' + $3; };
+
+typearglist:
+ typearg { ((TypeDef) typeStack.peek()).actualArgumentTypes.add($1);}|
+ typearglist COMMA typearg { ((TypeDef) typeStack.peek()).actualArgumentTypes.add($3);};
+
+typearg:
+ type { $$ = $1;} |
+ QUERY { $$ = new WildcardTypeDef();} |
+ QUERY EXTENDS type { $$ = new WildcardTypeDef($3, "extends");} |
+ QUERY SUPER type { $$ = new WildcardTypeDef($3, "super");};
+
+opt_typeparams: | typeparams;
+
+typeparams: LESSTHAN { typeParams = new ArrayList(); } typeparamlist GREATERTHAN;
+
+typeparamlist:
+ typeparam |
+ typeparamlist COMMA typeparam;
+
+typeparam:
+ IDENTIFIER { typeParams.add(new TypeVariableDef($1)); } |
+ IDENTIFIER EXTENDS {
+ typeVariable = new TypeVariableDef($1);
+ typeVariable.bounds = new ArrayList();
+ } typeboundlist {
+ typeParams.add(typeVariable);
+ typeVariable = null;
+ };
+
+typeboundlist:
+ type { typeVariable.bounds.add($1); } |
+ typeboundlist AMPERSAND type { typeVariable.bounds.add($3); };
+
+// ----- ENUM
+
+enum: enum_definition BRACEOPEN enum_body BRACECLOSE {
+ builder.endClass();
+ fieldType = null;
+ modifiers.clear();
+};
+
+enum_definition: modifiers ENUM IDENTIFIER opt_implements {
+ cls.lineNumber = line;
+ cls.modifiers.addAll(modifiers);
+ cls.name = $3;
+ cls.type = ClassDef.ENUM;
+ builder.beginClass(cls);
+ cls = new ClassDef();
+ fieldType = new TypeDef($3, 0);
+};
+
+enum_body: enum_values | enum_values SEMI members;
+
+enum_values: | enum_value | enum_value COMMA enum_values;
+
+enum_value:
+ javadoclist opt_annotations enum_constructor |
+ opt_annotations enum_constructor;
+
+enum_constructor:
+ IDENTIFIER { makeField(new TypeDef($1, 0), ""); } |
+ IDENTIFIER CODEBLOCK { makeField(new TypeDef($1, 0), ""); } |
+ IDENTIFIER PARENBLOCK { makeField(new TypeDef($1, 0), ""); } |
+ IDENTIFIER PARENBLOCK CODEBLOCK { makeField(new TypeDef($1, 0), ""); };
+
+
+// ----- CLASS
+
+class:
+ classdefinition BRACEOPEN members BRACECLOSE {
+ builder.endClass();
+ };
+
+classdefinition:
+ modifiers classorinterface IDENTIFIER opt_typeparams opt_extends opt_implements {
+ cls.lineNumber = line;
+ cls.modifiers.addAll(modifiers); modifiers.clear();
+ cls.name = $3;
+ cls.typeParams = typeParams;
+ builder.beginClass(cls);
+ cls = new ClassDef();
+ };
+
+classorinterface:
+ CLASS { cls.type = ClassDef.CLASS; } |
+ INTERFACE { cls.type = ClassDef.INTERFACE; } |
+ ANNOINTERFACE { cls.type = ClassDef.ANNOTATION_TYPE; };
+
+opt_extends: | EXTENDS extendslist;
+
+extendslist:
+ classtype { cls.extendz.add($1); } |
+ extendslist COMMA classtype { cls.extendz.add($3); };
+
+opt_implements: | IMPLEMENTS implementslist;
+
+implementslist:
+ classtype { cls.implementz.add($1); } |
+ implementslist COMMA classtype { cls.implementz.add($3); };
+
+members: | members { line = lexer.getLine(); } member;
+
+member:
+ javadoc |
+ fields |
+ method |
+ constructor |
+ static_block |
+ class |
+ enum |
+ SEMI;
+
+memberend:
+ SEMI {
+ $$ = "";
+ }
+ | CODEBLOCK {
+ $$ = lexer.getCodeBody();
+ };
+
+static_block:
+ modifiers CODEBLOCK { lexer.getCodeBody(); modifiers.clear(); };
+
+// ----- FIELD
+
+fields:
+ modifiers type arrayidentifier {
+ fieldType = $2;
+ makeField($3, lexer.getCodeBody());
+ }
+ extrafields memberend {
+ modifiers.clear();
+ };
+
+extrafields: |
+ extrafields COMMA { line = lexer.getLine(); } arrayidentifier {
+ makeField($4, lexer.getCodeBody());
+ } |
+ extrafields COMMA javadoc { line = lexer.getLine(); } arrayidentifier {
+ makeField($5, lexer.getCodeBody());
+ };
+
+
+// ----- METHOD
+
+method:
+ modifiers typeparams type IDENTIFIER {
+ builder.beginMethod();
+ mth.typeParams = typeParams;
+ } methoddef dimensions opt_exceptions memberend {
+ mth.lineNumber = line;
+ mth.modifiers.addAll(modifiers); modifiers.clear();
+ mth.returnType = $3;
+ mth.dimensions = $7;
+ mth.name = $4;
+ mth.body = $9;
+ builder.endMethod(mth);
+ mth = new MethodDef();
+ } |
+ modifiers type IDENTIFIER {
+ builder.beginMethod();
+ } methoddef dimensions opt_exceptions memberend {
+ mth.lineNumber = line;
+ mth.modifiers.addAll(modifiers); modifiers.clear();
+ mth.returnType = $2;
+ mth.dimensions = $6;
+ mth.name = $3;
+ mth.body = $8;
+ builder.endMethod(mth);
+ mth = new MethodDef();
+ };
+
+constructor:
+ modifiers IDENTIFIER {
+ builder.beginMethod();
+ } methoddef opt_exceptions memberend {
+ mth.lineNumber = line;
+ mth.modifiers.addAll(modifiers); modifiers.clear();
+ mth.constructor = true; mth.name = $2;
+ mth.body = $6;
+ builder.endMethod(mth);
+ mth = new MethodDef();
+ } |
+ modifiers typeparams IDENTIFIER {
+ builder.beginMethod();
+ mth.typeParams = typeParams;
+ } methoddef opt_exceptions memberend {
+ mth.lineNumber = line;
+ mth.modifiers.addAll(modifiers); modifiers.clear();
+ mth.constructor = true; mth.name = $3;
+ mth.body = $7;
+ builder.endMethod(mth);
+ mth = new MethodDef();
+ };
+
+methoddef: PARENOPEN opt_params PARENCLOSE;
+
+opt_exceptions: | THROWS exceptionlist;
+
+exceptionlist:
+ fullidentifier { mth.exceptions.add($1); } |
+ exceptionlist COMMA fullidentifier { mth.exceptions.add($3); };
+
+opt_params: | paramlist;
+
+paramlist:
+ param |
+ paramlist COMMA param;
+
+param:
+ opt_parammodifiers type varargs arrayidentifier {
+ param.name = $4.name;
+ param.type = $2;
+ param.dimensions = $4.dimensions;
+ param.isVarArgs = $3;
+ builder.addParameter(param);
+ param = new FieldDef();
+ };
+
+varargs:
+ /* empty */ { $$ = false; } |
+ DOTDOTDOT { $$ = true; } ;
+
+opt_annotations: | opt_annotations annotation { builder.addAnnotation((Annotation) $2); };
+
+opt_parammodifiers: |
+ opt_parammodifiers modifier { param.modifiers.add($2); } |
+ opt_parammodifiers annotation { builder.addAnnotation((Annotation) $2); };
%%
-private JavaLexer lexer;
+private Lexer lexer;
private Builder builder;
-private StringBuilder textBuffer = new StringBuilder();
+private StringBuffer textBuffer = new StringBuffer();
private ClassDef cls = new ClassDef();
private MethodDef mth = new MethodDef();
-private FieldDef fd;
-private List<TypeVariableDef> typeParams = new LinkedList<TypeVariableDef>(); //for both JavaClass and JavaMethod
-private LinkedList<AnnoDef> annotationStack = new LinkedList<AnnoDef>(); // Use LinkedList instead of Stack because it is unsynchronized
-private List<List<ElemValueDef>> annoValueListStack = new LinkedList<List<ElemValueDef>>(); // Use LinkedList instead of Stack because it is unsynchronized
-private List<ElemValueDef> annoValueList = null;
+private List typeParams = new ArrayList(); //for both JavaClass and JavaMethod
+private List annotationStack = new ArrayList(); // Use ArrayList intead of Stack because it is unsynchronized
+private Annotation annotation = null;
+private List annoValueListStack = new ArrayList(); // Use ArrayList intead of Stack because it is unsynchronized
+private List annoValueList = null;
private FieldDef param = new FieldDef();
-private java.util.Set<String> modifiers = new java.util.LinkedHashSet<String>();
+private java.util.Set modifiers = new java.util.HashSet();
private TypeDef fieldType;
private TypeVariableDef typeVariable;
-private Stack<TypeDef> typeStack = new Stack<TypeDef>();
-private List<TypeDef> typeList = new LinkedList<TypeDef>();
+private Stack typeStack = new Stack();
private int line;
private int column;
private boolean debugLexer;
@@ -1694,9 +591,7 @@ private String buffer() {
return result;
}
-public Parser( JavaLexer lexer, Builder builder )
-{
- lexer.addCommentHandler( this );
+public Parser(Lexer lexer, Builder builder) {
this.lexer = lexer;
this.builder = builder;
}
@@ -1736,32 +631,217 @@ private void yyerror(String msg) {
}
private class Value {
- Object oval;
+ Object oval;
String sval;
int ival;
- boolean bval;
+ boolean bval;
TypeDef type;
- ElemValueDef annoval;
+ AnnotationValue annoval;
+}
+
+
+private void makeField(TypeDef field, String body) {
+ FieldDef fd = new FieldDef();
+ fd.lineNumber = line;
+ fd.modifiers.addAll(modifiers);
+ fd.name = field.name;
+ fd.type = fieldType;
+ fd.dimensions = field.dimensions;
+ fd.body = body;
+ builder.addField(fd);
}
+private String convertString(String str) {
+ StringBuffer buf = new StringBuffer();
+ boolean escaped = false;
+ int unicode = 0;
+ int value = 0;
+ int octal = 0;
+ boolean consumed = false;
+
+ for(int i = 0; i < str.length(); ++ i) {
+ char ch = str.charAt( i );
+
+ if(octal > 0) {
+ if( value >= '0' && value <= '7' ) {
+ value = ( value << 3 ) | Character.digit( ch, 8 );
+ -- octal;
+ consumed = true;
+ }
+ else {
+ octal = 0;
+ }
+
+ if( octal == 0 ) {
+ buf.append( (char) value );
+ value = 0;
+ }
+ }
+
+ if(!consumed) {
+ if(unicode > 0) {
+ value = ( value << 4 ) | Character.digit( ch, 16 );
+
+ -- unicode;
+
+ if(unicode == 0) {
+ buf.append( (char)value );
+ value = 0;
+ }
+ }
+ else if(escaped) {
+ if(ch == 'u' || ch == 'U') {
+ unicode = 4;
+ }
+ else if(ch >= '0' && ch <= '7') {
+ octal = (ch > '3') ? 1 : 2;
+ value = Character.digit( ch, 8 );
+ }
+ else {
+ switch( ch ) {
+ case 'b':
+ buf.append('\b');
+ break;
+
+ case 'f':
+ buf.append('\f');
+ break;
+
+ case 'n':
+ buf.append('\n');
+ break;
+
+ case 'r':
+ buf.append('\r');
+ break;
+
+ case 't':
+ buf.append('\t');
+ break;
+
+ case '\'':
+ buf.append('\'');
+ break;
+
+ case '\"':
+ buf.append('\"');
+ break;
+
+ case '\\':
+ buf.append('\\');
+ break;
+
+ default:
+ yyerror( "Illegal escape character '" + ch + "'" );
+ }
+ }
+
+ escaped = false;
+ }
+ else if(ch == '\\') {
+ escaped = true;
+ }
+ else {
+ buf.append( ch );
+ }
+ }
+ }
+
+ return buf.toString();
+}
+
+private Boolean toBoolean(String str) {
+ str = str.trim();
+
+ return new Boolean( str );
+}
-private void makeField(TypeDef field, String body, boolean enumConstant) {
- fd = new FieldDef( field.getName() );
- fd.setName(field.getName());
- fd.setLineNumber(line);
- fd.getModifiers().addAll(modifiers);
- fd.setType( fieldType );
- fd.setDimensions(field.getDimensions());
- fd.setEnumConstant(enumConstant);
- fd.setBody(body);
+private Integer toInteger(String str) {
+ str = str.trim();
+
+ Integer result;
+
+ if(str.startsWith("0x") || str.startsWith( "0X" ) ) {
+ result = new Integer( Integer.parseInt( str.substring( 2 ), 16 ) );
+ }
+ else if(str.length() > 1 && str.startsWith("0") ) {
+ result = new Integer( Integer.parseInt( str.substring( 1 ), 8 ) );
+ }
+ else {
+ result = new Integer( str );
+ }
+
+ return result;
}
-public void onComment( String comment, int line, int column ) {
- DefaultJavaCommentLexer commentLexer = new DefaultJavaCommentLexer( new java.io.StringReader( comment ) );
- commentLexer.setLineOffset( line );
- commentLexer.setColumnOffset( column );
- DefaultJavaCommentParser commentParser = new DefaultJavaCommentParser( commentLexer, builder);
- commentParser.setDebugLexer( this.debugLexer );
- commentParser.setDebugParser( this.yydebug );
- commentParser.parse();
+private Long toLong(String str) {
+ str = str.trim();
+
+ Long result;
+
+ if( !str.endsWith("l") && !str.endsWith("L") ) {
+ yyerror( "Long literal must end with 'l' or 'L'." );
+ }
+
+ int len = str.length() - 1;
+
+ if(str.startsWith("0x") || str.startsWith( "0X" ) ) {
+ result = new Long( Long.parseLong( str.substring( 2, len ), 16 ) );
+ }
+ else if(str.startsWith("0") ) {
+ result = new Long( Long.parseLong( str.substring( 1, len ), 8 ) );
+ }
+ else {
+ result = new Long( str.substring( 0, len ) );
+ }
+
+ return result;
+}
+
+private Float toFloat(String str) {
+ str = str.trim();
+ return new Float( str );
+}
+
+private Double toDouble(String str) {
+ str = str.trim();
+
+ if( !str.endsWith("d") && !str.endsWith("D") ) {
+ yyerror( "Double literal must end with 'd' or 'D'." );
+ }
+
+ return new Double( str.substring( 0, str.length() - 1 ) );
+}
+
+/**
+ * Convert a character literal into a character.
+ */
+private Character toChar(String str) {
+ str = str.trim();
+
+ if( !str.startsWith("'") && !str.endsWith("'") ) {
+ yyerror("Character must be single quoted.");
+ }
+
+ String str2 = convertString( str.substring( 1, str.length() - 1 ) );
+
+ if( str2.length() != 1) {
+ yyerror("Only one character allowed in character constants.");
+ }
+
+ return new Character( str2.charAt( 0 ) );
+}
+
+/**
+ * Convert a string literal into a string.
+ */
+private String toString(String str) {
+ str = str.trim();
+
+ if( str.length() < 2 && !str.startsWith("\"") && !str.endsWith("\"") ) {
+ yyerror("String must be double quoted.");
+ }
+
+ String str2 = convertString( str.substring( 1, str.length() - 1 ) );
+ return str2;
}
\ No newline at end of file
diff --git a/src/grammar/skeleton.inner b/src/grammar/skeleton.inner
new file mode 100644
index 0000000..42cc796
--- /dev/null
+++ b/src/grammar/skeleton.inner
@@ -0,0 +1,425 @@
+/*
+
+ This file is based on skeleton.nested, but this version skips resetting the line number and column.
+ It's used for parsing the javadoc comments. It's much more solid to extract the comment block and read it per line.
+
+*/
+ /** This character denotes the end of file */
+ public static final int YYEOF = -1;
+
+ /** initial size of the lookahead buffer */
+--- private static final int ZZ_BUFFERSIZE = ...;
+
+ /** lexical states */
+--- lexical states, charmap
+
+ /* error codes */
+ private static final int ZZ_UNKNOWN_ERROR = 0;
+ private static final int ZZ_NO_MATCH = 1;
+ private static final int ZZ_PUSHBACK_2BIG = 2;
+
+ /* error messages for the codes above */
+ private static final String ZZ_ERROR_MSG[] = {
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
+ };
+
+--- isFinal list
+ /** the input device */
+ private java.io.Reader zzReader;
+
+ /** the current state of the DFA */
+ private int zzState;
+
+ /** the current lexical state */
+ private int zzLexicalState = YYINITIAL;
+
+ /** this buffer contains the current text to be matched and is
+ the source of the yytext() string */
+ private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
+
+ /** the textposition at the last accepting state */
+ private int zzMarkedPos;
+
+ /** the current text position in the buffer */
+ private int zzCurrentPos;
+
+ /** startRead marks the beginning of the yytext() string in the buffer */
+ private int zzStartRead;
+
+ /** endRead marks the last character in the buffer, that has been read
+ from input */
+ private int zzEndRead;
+
+ /** number of newlines encountered up to the start of the matched text */
+ private int yyline;
+
+ /** the number of characters up to the start of the matched text */
+ private int yychar;
+
+ /**
+ * the number of characters from the last newline up to the start of the
+ * matched text
+ */
+ private int yycolumn;
+
+ /**
+ * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+ */
+ private boolean zzAtBOL = true;
+
+ /** zzAtEOF == true <=> the scanner is at the EOF */
+ private boolean zzAtEOF;
+
+ /** denotes if the user-EOF-code has already been executed */
+ private boolean zzEOFDone;
+
+ /** the stack of open (nested) input streams to read from */
+ private java.util.Stack zzStreams = new java.util.Stack();
+
+ /**
+ * inner class used to store info for nested
+ * input streams
+ */
+ private static final class ZzFlexStreamInfo {
+ java.io.Reader zzReader;
+ int zzEndRead;
+ int zzStartRead;
+ int zzCurrentPos;
+ int zzMarkedPos;
+ char [] zzBuffer;
+ boolean zzAtEOF;
+ boolean zzEOFDone;
+
+ /** sets all values stored in this class */
+ ZzFlexStreamInfo(java.io.Reader zzReader, int zzEndRead, int zzStartRead,
+ int zzCurrentPos, int zzMarkedPos,
+ char [] zzBuffer, boolean zzAtEOF) {
+ this.zzReader = zzReader;
+ this.zzEndRead = zzEndRead;
+ this.zzStartRead = zzStartRead;
+ this.zzCurrentPos = zzCurrentPos;
+ this.zzMarkedPos = zzMarkedPos;
+ this.zzBuffer = zzBuffer;
+ this.zzAtEOF = zzAtEOF;
+ this.zzEOFDone = zzEOFDone;
+ }
+ }
+
+--- user class code
+
+ /**
+ * Creates a new scanner
+ * There is also a java.io.InputStream version of this constructor.
+ *
+ * @param in the java.io.Reader to read input from.
+ */
+--- constructor declaration
+
+
+ /**
+ * Refills the input buffer.
+ *
+ * @return <code>false</code>, iff there was new input.
+ *
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+ private boolean zzRefill() throws java.io.IOException {
+
+ /* first: make room (if you can) */
+ if (zzStartRead > 0) {
+ System.arraycopy(zzBuffer, zzStartRead,
+ zzBuffer, 0,
+ zzEndRead-zzStartRead);
+
+ /* translate stored positions */
+ zzEndRead-= zzStartRead;
+ zzCurrentPos-= zzStartRead;
+ zzMarkedPos-= zzStartRead;
+ zzStartRead = 0;
+ }
+
+ /* is the buffer big enough? */
+ if (zzCurrentPos >= zzBuffer.length) {
+ /* if not: blow it up */
+ char newBuffer[] = new char[zzCurrentPos*2];
+ System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
+ zzBuffer = newBuffer;
+ }
+
+ /* finally: fill the buffer with new input */
+ int numRead = zzReader.read(zzBuffer, zzEndRead,
+ zzBuffer.length-zzEndRead);
+
+ if (numRead > 0) {
+ zzEndRead+= numRead;
+ return false;
+ }
+ // unlikely but not impossible: read 0 characters, but not at end of stream
+ if (numRead == 0) {
+ int c = zzReader.read();
+ if (c == -1) {
+ return true;
+ } else {
+ zzBuffer[zzEndRead++] = (char) c;
+ return false;
+ }
+ }
+
+ // numRead < 0)
+ return true;
+ }
+
+
+ /**
+ * Closes the input stream.
+ */
+ public final void yyclose() throws java.io.IOException {
+ zzAtEOF = true; /* indicate end of file */
+ zzEndRead = zzStartRead; /* invalidate buffer */
+
+ if (zzReader != null)
+ zzReader.close();
+ }
+
+
+ /**
+ * Stores the current input stream on a stack, and
+ * reads from a new stream. Lexical state, line,
+ * char, and column counting remain untouched.
+ *
+ * The current input stream can be restored with
+ * yypopstream (usually in an <<EOF>> action).
+ *
+ * @param reader the new input stream to read from
+ *
+ * @see #yypopStream()
+ */
+ public final void yypushStream(java.io.Reader reader) {
+ zzStreams.push(
+ new ZzFlexStreamInfo(zzReader, zzEndRead, zzStartRead, zzCurrentPos,
+ zzMarkedPos, zzBuffer, zzAtEOF)
+ );
+ zzAtEOF = false;
+ zzBuffer = new char[ZZ_BUFFERSIZE];
+ zzReader = reader;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ }
+
+
+ /**
+ * Closes the current input stream and continues to
+ * read from the one on top of the stream stack.
+ *
+ * @throws java.util.EmptyStackException
+ * if there is no further stream to read from.
+ *
+ * @throws java.io.IOException
+ * if there was an error in closing the stream.
+ *
+ * @see #yypushStream(java.io.Reader)
+ */
+ public final void yypopStream() throws java.io.IOException {
+ zzReader.close();
+ ZzFlexStreamInfo s = (ZzFlexStreamInfo) zzStreams.pop();
+ zzBuffer = s.zzBuffer;
+ zzReader = s.zzReader;
+ zzStartRead = s.zzStartRead + zzEndRead + 2; //skip javadoc-part
+ zzEndRead = s.zzEndRead;
+ zzCurrentPos = s.zzCurrentPos;
+ zzMarkedPos = s.zzMarkedPos ;
+ zzAtEOF = s.zzAtEOF;
+ zzEOFDone = s.zzEOFDone;
+ }
+
+
+ /**
+ * Returns true iff there are still streams left
+ * to read from on the stream stack.
+ */
+ public final boolean yymoreStreams() {
+ return !zzStreams.isEmpty();
+ }
+
+
+ /**
+ * Resets the scanner to read from a new input stream.
+ * Does not close the old reader.
+ *
+ * All internal variables are reset, the old input stream
+ * <b>cannot</b> be reused (internal buffer is discarded and lost).
+ * Lexical state is set to <tt>ZZ_INITIAL</tt>.
+ *
+ * @param reader the new input stream
+ *
+ * @see #yypushStream(java.io.Reader)
+ * @see #yypopStream()
+ */
+ public final void yyreset(java.io.Reader reader) {
+ zzReader = reader;
+ zzAtBOL = true;
+ zzAtEOF = false;
+ zzEOFDone = false;
+ zzEndRead = zzStartRead = 0;
+ zzCurrentPos = zzMarkedPos = 0;
+ yychar = 0;
+ zzLexicalState = YYINITIAL;
+ }
+
+
+ /**
+ * Returns the current lexical state.
+ */
+ public final int yystate() {
+ return zzLexicalState;
+ }
+
+
+ /**
+ * Enters a new lexical state
+ *
+ * @param newState the new lexical state
+ */
+ public final void yybegin(int newState) {
+ zzLexicalState = newState;
+ }
+
+
+ /**
+ * Returns the text matched by the current regular expression.
+ */
+ public final String yytext() {
+ return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
+ }
+
+
+ /**
+ * Returns the character at position <tt>pos</tt> from the
+ * matched text.
+ *
+ * It is equivalent to yytext().charAt(pos), but faster
+ *
+ * @param pos the position of the character to fetch.
+ * A value from 0 to yylength()-1.
+ *
+ * @return the character at position pos
+ */
+ public final char yycharat(int pos) {
+ return zzBuffer[zzStartRead+pos];
+ }
+
+
+ /**
+ * Returns the length of the matched text region.
+ */
+ public final int yylength() {
+ return zzMarkedPos-zzStartRead;
+ }
+
+
+ /**
+ * Reports an error that occured while scanning.
+ *
+ * In a wellformed scanner (no or only correct usage of
+ * yypushback(int) and a match-all fallback rule) this method
+ * will only be called with things that "Can't Possibly Happen".
+ * If this method is called, something is seriously wrong
+ * (e.g. a JFlex bug producing a faulty scanner etc.).
+ *
+ * Usual syntax/scanner level error handling should be done
+ * in error fallback rules.
+ *
+ * @param errorCode the code of the errormessage to display
+ */
+--- zzScanError declaration
+ String message;
+ try {
+ message = ZZ_ERROR_MSG[errorCode];
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+ }
+
+--- throws clause
+ }
+
+
+ /**
+ * Pushes the specified amount of characters back into the input stream.
+ *
+ * They will be read again by then next call of the scanning method
+ *
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
+ */
+--- yypushback decl (contains zzScanError exception)
+ if ( number > yylength() )
+ zzScanError(ZZ_PUSHBACK_2BIG);
+
+ zzMarkedPos -= number;
+ }
+
+
+--- zzDoEOF
+ /**
+ * Resumes scanning until the next regular expression is matched,
+ * the end of input is encountered or an I/O-Error occurs.
+ *
+ * @return the next token
+ * @exception java.io.IOException if any I/O-Error occurs
+ */
+--- yylex declaration
+ int zzInput;
+ int zzAction;
+
+--- local declarations
+
+ while (true) {
+ // cached fields:
+ int zzCurrentPosL;
+ int zzMarkedPosL = zzMarkedPos;
+ int zzEndReadL = zzEndRead;
+ char [] zzBufferL = zzBuffer;
+ char [] zzCMapL = ZZ_CMAP;
+
+--- start admin (line, char, col count)
+ zzAction = -1;
+
+ zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+--- start admin (lexstate etc)
+
+ zzForAction: {
+ while (true) {
+
+--- next input, line, col, char count, next transition, isFinal action
+ zzAction = zzState;
+ zzMarkedPosL = zzCurrentPosL;
+--- line count update
+ }
+
+ }
+ }
+
+ // store back cached position
+ zzMarkedPos = zzMarkedPosL;
+--- char count update
+
+--- actions
+ default:
+ if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+ zzAtEOF = true;
+--- eofvalue
+ }
+ else {
+--- no match
+ }
+ }
+ }
+ }
+
+--- main
+
+}
diff --git a/src/it/lambda-examples/LambdaExamples01.zip b/src/it/lambda-examples/LambdaExamples01.zip
deleted file mode 100644
index 466c6cd..0000000
Binary files a/src/it/lambda-examples/LambdaExamples01.zip and /dev/null differ
diff --git a/src/it/lambda-examples/invoker.properties b/src/it/lambda-examples/invoker.properties
deleted file mode 100644
index 63cdacd..0000000
--- a/src/it/lambda-examples/invoker.properties
+++ /dev/null
@@ -1 +0,0 @@
-invoker.goals = org.codehaus.mojo:exec-maven-plugin:1.3.1:java
\ No newline at end of file
diff --git a/src/it/lambda-examples/pom.xml b/src/it/lambda-examples/pom.xml
deleted file mode 100644
index f3bc81c..0000000
--- a/src/it/lambda-examples/pom.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.thoughtworks.qdox.it</groupId>
- <artifactId>lambda-examples</artifactId>
- <version>01</version>
- <packaging>pom</packaging>
-
- <url>http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html#section2</url>
-
- <dependencies>
- <dependency>
- <groupId>com.thoughtworks.qdox</groupId>
- <artifactId>qdox</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/src/it/lambda-examples/test.properties b/src/it/lambda-examples/test.properties
deleted file mode 100644
index d1e9231..0000000
--- a/src/it/lambda-examples/test.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-exec.mainClass = com.thoughtworks.qdox.tools.QDoxTester
-exec.arguments = LambdaExamples01.zip
\ No newline at end of file
diff --git a/src/it/lambda-examples/verify.groovy b/src/it/lambda-examples/verify.groovy
deleted file mode 100644
index 25e6fe5..0000000
--- a/src/it/lambda-examples/verify.groovy
+++ /dev/null
@@ -1,8 +0,0 @@
-def buildLog = new File( basedir, "build.log" )
-
-// zip contains 6 java files + empty LambdaExamples01/nbproject/private/config.properties
-assert buildLog.text.contains( "Success: 7" )
-// zip contains 9 non-java files
-assert buildLog.text.contains( "Failure: 9" )
-assert buildLog.text.contains( "Error : 0" )
-assert buildLog.text.contains( "Total : 16" )
diff --git a/src/it/qdox-223/pom.xml b/src/it/qdox-223/pom.xml
deleted file mode 100644
index 282e2aa..0000000
--- a/src/it/qdox-223/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.thoughtworks.qdox.it</groupId>
- <artifactId>qdox-223</artifactId>
- <version>1.0</version>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>com.thoughtworks.qdox</groupId>
- <artifactId>qdox</artifactId>
- <version>@project.version@</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/src/it/qdox-223/src/main/java/com/AnnotationA.java b/src/it/qdox-223/src/main/java/com/AnnotationA.java
deleted file mode 100644
index 657a309..0000000
--- a/src/it/qdox-223/src/main/java/com/AnnotationA.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com;
-
-public @interface AnnotationA {
-}
diff --git a/src/it/qdox-223/src/main/java/com/x/QClass.java b/src/it/qdox-223/src/main/java/com/x/QClass.java
deleted file mode 100644
index 9272834..0000000
--- a/src/it/qdox-223/src/main/java/com/x/QClass.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.x;
-
-public class QClass {
-
- public void someMethod() {
-
- }
-}
diff --git a/src/it/qdox-223/src/main/java/com/x/package-info.java b/src/it/qdox-223/src/main/java/com/x/package-info.java
deleted file mode 100644
index c429bbc..0000000
--- a/src/it/qdox-223/src/main/java/com/x/package-info.java
+++ /dev/null
@@ -1,2 +0,0 @@
- at com.AnnotationA()
-package com.x;
\ No newline at end of file
diff --git a/src/it/qdox-223/src/main/java/com/y/BClass.java b/src/it/qdox-223/src/main/java/com/y/BClass.java
deleted file mode 100644
index 474e768..0000000
--- a/src/it/qdox-223/src/main/java/com/y/BClass.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.y;
-
-public class BClass {
-
-
- public void someMethod() {
-
- }
-
-}
diff --git a/src/it/qdox-223/src/main/java/com/y/package-info.java b/src/it/qdox-223/src/main/java/com/y/package-info.java
deleted file mode 100644
index 4ac7b9b..0000000
--- a/src/it/qdox-223/src/main/java/com/y/package-info.java
+++ /dev/null
@@ -1,2 +0,0 @@
- at com.AnnotationA()
-package com.y;
\ No newline at end of file
diff --git a/src/it/qdox-223/src/test/java/MissingAnnotationsTest.java b/src/it/qdox-223/src/test/java/MissingAnnotationsTest.java
deleted file mode 100644
index 9df65e1..0000000
--- a/src/it/qdox-223/src/test/java/MissingAnnotationsTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.JavaProjectBuilder;
-
-public class MissingAnnotationsTest {
-
- @Test
- public void packageInfoAnnotationsMissing() {
-
- //package y, package-info not first file, deprecated annotation found
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSourceTree(new File("./src/main/java/com/y"));
- assertEquals(1, builder.getPackages().iterator().next().getAnnotations().size());
-
- //package x, package-info not first file, test fails, deprecated annotation not found
- builder = new JavaProjectBuilder();
- builder.addSourceTree(new File("./src/main/java/com/x"));
- assertEquals(1, builder.getPackages().iterator().next().getAnnotations().size());
- }
-}
diff --git a/src/it/qdox-224/pom.xml b/src/it/qdox-224/pom.xml
deleted file mode 100644
index 90aad68..0000000
--- a/src/it/qdox-224/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.thoughtworks.qdox.it</groupId>
- <artifactId>qdox-224</artifactId>
- <version>1.0</version>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>com.thoughtworks.qdox</groupId>
- <artifactId>qdox</artifactId>
- <version>@project.version@</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.1</version>
- <classifier>sources</classifier>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/src/it/qdox-224/src/test/java/ClasspathSourcesTest.java b/src/it/qdox-224/src/test/java/ClasspathSourcesTest.java
deleted file mode 100644
index 362986a..0000000
--- a/src/it/qdox-224/src/test/java/ClasspathSourcesTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.Collections;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.JavaProjectBuilder;
-import com.thoughtworks.qdox.model.*;
-
-public class ClasspathSourcesTest
-{
-
- @Test
- public void testCommonsLangSources()
- throws Exception
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addClassLoader( ClassLoader.getSystemClassLoader() );
- JavaClass clazz = builder.getClassByName( "org.apache.commons.lang.BitField" );
- JavaMethod method = clazz.getMethods().get( 0 );
- assertEquals( "getValue", method.getName() );
- assertEquals( "holder", method.getParameters().get( 0 ).getName() );
- assertEquals( "see", method.getTags().get( 0 ).getName() );
- assertEquals( "#setValue(int,int)", method.getTags().get( 0 ).getValue() );
- assertEquals( "param", method.getTags().get( 1 ).getName() );
- assertEquals( "holder the int data containing the bits we're interested\r\n in", method.getTags().get( 1 ).getValue() );
- assertEquals( "return", method.getTags().get( 2 ).getName() );
- assertEquals( "the selected bits, shifted right appropriately", method.getTags().get( 2 ).getValue() );
- }
-
-}
diff --git a/src/it/qdox-241/pom.xml b/src/it/qdox-241/pom.xml
deleted file mode 100644
index f12c695..0000000
--- a/src/it/qdox-241/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.thoughtworks.qdox.it</groupId>
- <artifactId>qdox-241</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <description>
- Set the StateStack size of the lexer through qdox.properties
- </description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>com.thoughtworks.qdox</groupId>
- <artifactId>qdox</artifactId>
- <version>@project.version@</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/src/it/qdox-241/src/main/resources/qdox.properties b/src/it/qdox-241/src/main/resources/qdox.properties
deleted file mode 100644
index 3c219bf..0000000
--- a/src/it/qdox-241/src/main/resources/qdox.properties
+++ /dev/null
@@ -1 +0,0 @@
-lexer.statestack.size = 15
\ No newline at end of file
diff --git a/src/it/qdox-241/src/test/java/QDoxPropertiesTest.java b/src/it/qdox-241/src/test/java/QDoxPropertiesTest.java
deleted file mode 100644
index 4ce5151..0000000
--- a/src/it/qdox-241/src/test/java/QDoxPropertiesTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-import static org.junit.Assert.*;
-
-import java.io.File;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.JavaProjectBuilder;
-import com.thoughtworks.qdox.model.JavaSource;
-
-public class QDoxPropertiesTest
-{
-
- @Test
- public void customStateStackSize() throws Exception
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- JavaSource source = builder.addSource( new File("./src/test/resources/Test.java") );
-
- assertNotNull( source.getClassByName( "Test$A$B$C$D$E$F$G$H$I$J$K$L$M$N" ) );
- }
-}
diff --git a/src/it/qdox-241/src/test/resources/Test.java b/src/it/qdox-241/src/test/resources/Test.java
deleted file mode 100644
index 27322fe..0000000
--- a/src/it/qdox-241/src/test/resources/Test.java
+++ /dev/null
@@ -1,46 +0,0 @@
-public interface Test
-{
- interface A
- {
- interface B
- {
- interface C
- {
- interface D
- {
- interface E
- {
- interface F
- {
- interface G
- {
- interface H
- {
- interface I
- {
- interface J
- {
- interface K
- {
- interface L
- {
- interface M
- {
- interface N
- {
-
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/src/it/settings.xml b/src/it/settings.xml
deleted file mode 100644
index c8f77f0..0000000
--- a/src/it/settings.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<settings>
- <profiles>
- <profile>
- <id>it-repo</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <repositories>
- <repository>
- <id>local.central</id>
- <url>@localRepositoryUrl@</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>local.central</id>
- <url>@localRepositoryUrl@</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- </profiles>
-</settings>
diff --git a/src/java/com/thoughtworks/qdox/DefaultJavaClassCache.java b/src/java/com/thoughtworks/qdox/DefaultJavaClassCache.java
new file mode 100644
index 0000000..63a26a2
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/DefaultJavaClassCache.java
@@ -0,0 +1,25 @@
+package com.thoughtworks.qdox;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaClassCache;
+
+public class DefaultJavaClassCache implements JavaClassCache {
+
+ private Map classes = new Hashtable();
+
+ public JavaClass getClassByName(String name) {
+ return (JavaClass) classes.get(name);
+ }
+
+ public JavaClass[] getClasses() {
+ return (JavaClass[]) classes.values().toArray(new JavaClass[0]);
+ }
+
+ public void putClassByName(String name, JavaClass javaClass) {
+ classes.put(name, javaClass);
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/JavaClassContext.java b/src/java/com/thoughtworks/qdox/JavaClassContext.java
new file mode 100644
index 0000000..3f24d32
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/JavaClassContext.java
@@ -0,0 +1,119 @@
+package com.thoughtworks.qdox;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.thoughtworks.qdox.model.ClassLibrary;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaClassCache;
+import com.thoughtworks.qdox.model.JavaPackage;
+
+/**
+ * JavaClassContext gives you a mechanism to get a JavaClass.
+ * If a class couldn't be found in the cache, the class will be pulled from the classLibrary, the builder will create the corresponding JavaClass and put it in the cache.
+ *
+ *
+ * @author Robert Scholte
+ *
+ */
+public class JavaClassContext implements Serializable {
+
+ private final JavaClassCache cache;
+ private ClassLibrary classLibrary;
+ private JavaDocBuilder builder;
+ private Map packageMap = new HashMap(); // <String, JavaPackage>
+
+ public JavaClassContext(JavaDocBuilder builder) {
+ this.builder = builder;
+ this.cache = new DefaultJavaClassCache();
+ }
+
+
+ public JavaClassContext(ClassLibrary classLibrary) {
+ this.classLibrary = classLibrary;
+ this.cache = new DefaultJavaClassCache();
+ }
+
+
+ public void setClassLibrary(ClassLibrary classLibrary) {
+ this.classLibrary = classLibrary;
+ }
+
+ /**
+ * temporary, this should be hidden
+ * @return classLibrary
+ * @todo remove
+ */
+ public ClassLibrary getClassLibrary() {
+ return classLibrary;
+ }
+
+
+ public JavaClass getClassByName(String name) {
+ JavaClass result = cache.getClassByName(name);
+ if(result == null && builder != null) {
+ result = builder.createBinaryClass(name);
+
+ if ( result == null ) {
+ result = builder.createSourceClass(name);
+ }
+ if ( result == null ) {
+ result = builder.createUnknownClass(name);
+ }
+
+ if(result != null) {
+ add(result);
+ result.setJavaClassContext(this);
+ }
+ }
+ return result;
+ }
+
+ public JavaClass[] getClasses() {
+ return cache.getClasses();
+ }
+ public void add(JavaClass javaClass) {
+ cache.putClassByName(javaClass.getFullyQualifiedName(), javaClass);
+
+ JavaPackage jPackage = getPackageByName( javaClass.getPackageName() );
+ if(jPackage != null) {
+ jPackage.addClass( javaClass );
+ }
+ }
+
+
+ public void add(String fullyQualifiedClassName) {
+ classLibrary.add(fullyQualifiedClassName);
+ }
+
+ public Class getClass(String name) {
+ return classLibrary.getClass(name);
+ }
+
+
+ public JavaPackage getPackageByName( String name )
+ {
+ return (JavaPackage) packageMap.get( name );
+ }
+
+
+ public void add( JavaPackage jPackage )
+ {
+ String packageName = jPackage.getName();
+ JavaPackage javaPackage = getPackageByName( packageName );
+ if ( javaPackage == null ) {
+ javaPackage = new JavaPackage( packageName );
+ javaPackage.setContext( this );
+ packageMap.put( packageName, javaPackage );
+ }
+ jPackage.setContext( this );
+ }
+
+
+ public JavaPackage[] getPackages()
+ {
+ return (JavaPackage[]) packageMap.values().toArray( new JavaPackage[0] );
+
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/JavaDocBuilder.java b/src/java/com/thoughtworks/qdox/JavaDocBuilder.java
new file mode 100644
index 0000000..10a83d0
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/JavaDocBuilder.java
@@ -0,0 +1,559 @@
+package com.thoughtworks.qdox;
+
+import com.thoughtworks.qdox.directorywalker.DirectoryScanner;
+import com.thoughtworks.qdox.directorywalker.FileVisitor;
+import com.thoughtworks.qdox.directorywalker.SuffixFilter;
+import com.thoughtworks.qdox.model.ClassLibrary;
+import com.thoughtworks.qdox.model.DefaultDocletTagFactory;
+import com.thoughtworks.qdox.model.DocletTagFactory;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaClassCache;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.ModelBuilder;
+import com.thoughtworks.qdox.model.JavaPackage;
+import com.thoughtworks.qdox.parser.Lexer;
+import com.thoughtworks.qdox.parser.ParseException;
+import com.thoughtworks.qdox.parser.impl.JFlexLexer;
+import com.thoughtworks.qdox.parser.impl.Parser;
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Simple facade to QDox allowing a source tree to be parsed and the resulting object model navigated.
+ *
+ * <h3>Example</h3>
+ * <pre><code>
+ * // -- Create JavaDocBuilder
+ *
+ * JavaDocBuilder builder = new JavaDocBuilder();
+ *
+ * // -- Add some files
+ *
+ * // Reading a single source file.
+ * builder.addSource(new FileReader("MyFile.java"));
+ *
+ * // Reading from another kind of input stream.
+ * builder.addSource(new StringReader("package test; public class Hello {}"));
+ *
+ * // Adding all .java files in a source tree (recursively).
+ * builder.addSourceTree(new File("mysrcdir"));
+ *
+ * // -- Retrieve source files
+ *
+ * JavaSource[] source = builder.getSources();
+ *
+ * </code></pre>
+ *
+ * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
+ * @author Aslak Hellesøy
+ * @author Robert Scholte
+ */
+public class JavaDocBuilder implements Serializable {
+
+ private final JavaClassContext context;
+
+ private Set packages = new HashSet();
+ private List sources = new ArrayList();
+ private DocletTagFactory docletTagFactory;
+ private String encoding = System.getProperty("file.encoding");
+ private boolean debugLexer;
+ private boolean debugParser;
+ private ErrorHandler errorHandler = new DefaultErrorHandler();
+
+ public static interface ErrorHandler {
+ void handle(ParseException parseException);
+ }
+
+ public static class DefaultErrorHandler implements ErrorHandler, Serializable {
+ public void handle(ParseException parseException) {
+ throw parseException;
+ }
+ }
+
+ public JavaDocBuilder() {
+ this(new DefaultDocletTagFactory());
+ }
+
+ public JavaDocBuilder(DocletTagFactory docletTagFactory) {
+ this.docletTagFactory = docletTagFactory;
+ ClassLibrary classLibrary = new ClassLibrary();
+ classLibrary.addDefaultLoader();
+ this.context = new JavaClassContext(this);
+ this.context.setClassLibrary(classLibrary);
+ }
+
+ public JavaDocBuilder(ClassLibrary classLibrary) {
+ this(new DefaultDocletTagFactory(), classLibrary);
+ }
+
+ public JavaDocBuilder(DocletTagFactory docletTagFactory, ClassLibrary classLibrary) {
+ this.docletTagFactory = docletTagFactory;
+ this.context = new JavaClassContext(this);
+ this.context.setClassLibrary(classLibrary);
+ }
+
+ private void addClasses(JavaSource source) {
+ Set resultSet = new HashSet();
+ addClassesRecursive(source, resultSet);
+ JavaClass[] javaClasses = (JavaClass[]) resultSet.toArray(new JavaClass[resultSet.size()]);
+ for (int classIndex = 0; classIndex < javaClasses.length; classIndex++) {
+ JavaClass cls = javaClasses[classIndex];
+ addClass(cls);
+ }
+ }
+
+ private void addClass(JavaClass cls) {
+ context.add(cls);
+ cls.setJavaClassContext(context);
+ }
+
+ public JavaClass getClassByName(String name) {
+ if (name == null) {
+ return null;
+ }
+ return context.getClassByName(name);
+ }
+
+ protected JavaClass createSourceClass(String name) {
+ File sourceFile = context.getClassLibrary().getSourceFile( name );
+ if (sourceFile != null) {
+ try
+ {
+ JavaSource source = addSource( sourceFile );
+ for (int index = 0; index < source.getClasses().length; index++) {
+ JavaClass clazz = source.getClasses()[index];
+ if (name.equals(clazz.getFullyQualifiedName())) {
+ return clazz;
+ }
+ }
+ return source.getNestedClassByName( name );
+ }
+ catch ( FileNotFoundException e )
+ {
+ //nop
+ }
+ catch ( IOException e )
+ {
+ //nop
+ }
+ }
+ return null;
+ }
+
+ protected JavaClass createUnknownClass(String name) {
+ ModelBuilder unknownBuilder = new ModelBuilder(context, docletTagFactory, new HashMap());
+ ClassDef classDef = new ClassDef();
+ classDef.name = name;
+ unknownBuilder.beginClass(classDef);
+ unknownBuilder.endClass();
+ JavaSource unknownSource = unknownBuilder.getSource();
+ JavaClass result = unknownSource.getClasses()[0];
+ return result;
+ }
+
+ protected JavaClass createBinaryClass(String name) {
+ // First see if the class exists at all.
+ Class clazz = context.getClass(name);
+ if (clazz == null) {
+ return null;
+ } else {
+ try {
+ // Create a new builder and mimic the behaviour of the parser.
+ // We're getting all the information we need via reflection instead.
+ ModelBuilder binaryBuilder = new ModelBuilder(context, docletTagFactory, new HashMap());
+
+ // Set the package name and class name
+ String packageName = getPackageName(name);
+ binaryBuilder.addPackage(new PackageDef(packageName));
+
+ ClassDef classDef = new ClassDef();
+ classDef.name = getClassName(name);
+
+ // Set the extended class and interfaces.
+ Class[] interfaces = clazz.getInterfaces();
+ if (clazz.isInterface()) {
+ // It's an interface
+ classDef.type = ClassDef.INTERFACE;
+ for (int i = 0; i < interfaces.length; i++) {
+ Class anInterface = interfaces[i];
+ classDef.extendz.add(new TypeDef(anInterface.getName()));
+ }
+ } else {
+ // It's a class
+ for (int i = 0; i < interfaces.length; i++) {
+ Class anInterface = interfaces[i];
+ classDef.implementz.add(new TypeDef(anInterface.getName()));
+ }
+ Class superclass = clazz.getSuperclass();
+ if (superclass != null) {
+ classDef.extendz.add(new TypeDef(superclass.getName()));
+ }
+ }
+
+ addModifiers(classDef.modifiers, clazz.getModifiers());
+
+ binaryBuilder.beginClass(classDef);
+
+ // add the constructors
+ //
+ // This also adds the default constructor if any which is different
+ // to the source code as that does not create a default constructor
+ // if no constructor exists.
+ Constructor[] constructors = clazz.getDeclaredConstructors();
+ for (int i = 0; i < constructors.length; i++) {
+ addMethodOrConstructor(constructors[i], binaryBuilder);
+ }
+
+ // add the methods
+ Method[] methods = clazz.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ addMethodOrConstructor(methods[i], binaryBuilder);
+ }
+
+ Field[] fields = clazz.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ addField(fields[i], binaryBuilder);
+ }
+
+ binaryBuilder.endClass();
+ JavaSource binarySource = binaryBuilder.getSource();
+ // There is always only one class in a "binary" source.
+ JavaClass result = binarySource.getClasses()[0];
+ return result;
+ } catch (NoClassDefFoundError e) {
+ return null;
+ }
+ }
+ }
+
+ private void addModifiers(Set set, int modifier) {
+ String modifierString = Modifier.toString(modifier);
+ for (StringTokenizer stringTokenizer = new StringTokenizer(modifierString); stringTokenizer.hasMoreTokens();) {
+ set.add(stringTokenizer.nextToken());
+ }
+ }
+
+ private void addField(Field field, ModelBuilder binaryBuilder) {
+ FieldDef fieldDef = new FieldDef();
+ Class fieldType = field.getType();
+ fieldDef.name = field.getName();
+ fieldDef.type = getTypeDef(fieldType);
+ fieldDef.dimensions = getDimension(fieldType);
+ addModifiers( fieldDef.modifiers, field.getModifiers());
+ binaryBuilder.addField(fieldDef);
+ }
+
+ private void addMethodOrConstructor(Member member, ModelBuilder binaryBuilder) {
+ MethodDef methodDef = new MethodDef();
+ // The name of constructors are qualified. Need to strip it.
+ // This will work for regular methods too, since -1 + 1 = 0
+ int lastDot = member.getName().lastIndexOf('.');
+ methodDef.name = member.getName().substring(lastDot + 1);
+
+ addModifiers(methodDef.modifiers, member.getModifiers());
+ Class[] exceptions;
+ Class[] parameterTypes;
+ if (member instanceof Method) {
+ methodDef.constructor = false;
+
+ // For some stupid reason, these methods are not defined in Member,
+ // but in both Method and Construcotr.
+ exceptions = ((Method) member).getExceptionTypes();
+ parameterTypes = ((Method) member).getParameterTypes();
+
+ Class returnType = ((Method) member).getReturnType();
+ methodDef.returnType = getTypeDef(returnType);
+ methodDef.dimensions = getDimension(returnType);
+
+ } else {
+ methodDef.constructor = true;
+
+ exceptions = ((Constructor) member).getExceptionTypes();
+ parameterTypes = ((Constructor) member).getParameterTypes();
+ }
+ for (int j = 0; j < exceptions.length; j++) {
+ Class exception = exceptions[j];
+ methodDef.exceptions.add(exception.getName());
+ }
+ binaryBuilder.addMethod(methodDef);
+ for (int j = 0; j < parameterTypes.length; j++) {
+ FieldDef param = new FieldDef();
+ Class parameterType = parameterTypes[j];
+ param.name = "p" + j;
+ param.type = getTypeDef(parameterType);
+ param.dimensions = getDimension(parameterType);
+ binaryBuilder.addParameter( param );
+ }
+ }
+
+ private static final int getDimension(Class c) {
+ return c.getName().lastIndexOf('[') + 1;
+ }
+
+ private static String getTypeName(Class c) {
+ return c.getComponentType() != null ? c.getComponentType().getName() : c.getName();
+ }
+
+ private static TypeDef getTypeDef(Class c) {
+ return new TypeDef(getTypeName(c));
+ }
+
+
+ private String getPackageName(String fullClassName) {
+ int lastDot = fullClassName.lastIndexOf('.');
+ return lastDot == -1 ? "" : fullClassName.substring(0, lastDot);
+ }
+
+ private String getClassName(String fullClassName) {
+ int lastDot = fullClassName.lastIndexOf('.');
+ return lastDot == -1 ? fullClassName : fullClassName.substring(lastDot + 1);
+ }
+
+ public JavaSource addSource(Reader reader) {
+ return addSource(reader, "UNKNOWN SOURCE");
+ }
+
+ public JavaSource addSource(Reader reader, String sourceInfo) {
+ ModelBuilder builder = new ModelBuilder(context, docletTagFactory, null);
+ Lexer lexer = new JFlexLexer(reader);
+ Parser parser = new Parser(lexer, builder);
+ parser.setDebugLexer(debugLexer);
+ parser.setDebugParser(debugParser);
+ try {
+ parser.parse();
+ } catch (ParseException e) {
+ e.setSourceInfo(sourceInfo);
+ errorHandler.handle(e);
+ }
+ finally {
+ try {
+ reader.close();
+ }
+ catch (IOException e) {
+ }
+ }
+ JavaSource source = builder.getSource();
+ sources.add(source);
+ addClasses(source);
+
+ JavaPackage pkg = context.getPackageByName( source.getPackageName() );
+ if (!packages.contains(pkg)) {
+ packages.add(pkg);
+ }
+// JavaClass[] classes = source.getClasses();
+// for (int i = 0; i < classes.length; i++) {
+// if (pkg != null) {
+// pkg.addClass(classes[i]);
+// }
+// }
+
+ return source;
+ }
+
+ public JavaSource addSource(File file) throws IOException, FileNotFoundException {
+ return addSource(file.toURL());
+ }
+
+ public JavaSource addSource(URL url) throws IOException, FileNotFoundException {
+ JavaSource source = addSource(new InputStreamReader(url.openStream(),encoding), url.toExternalForm());
+ source.setURL(url);
+ return source;
+ }
+
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ public JavaSource[] getSources() {
+ return (JavaSource[]) sources.toArray(new JavaSource[sources.size()]);
+ }
+
+ /**
+ * Returns all the classes found in all the sources, including inner classes
+ * and "extra" classes (multiple outer classes defined in the same source file).
+ *
+ * @return all the classes found in all the sources.
+ * @since 1.3
+ */
+ public JavaClass[] getClasses() {
+ Set resultSet = new HashSet();
+ JavaSource[] javaSources = getSources();
+ for (int i = 0; i < javaSources.length; i++) {
+ JavaSource javaSource = javaSources[i];
+ addClassesRecursive(javaSource, resultSet);
+ }
+ JavaClass[] result = (JavaClass[]) resultSet.toArray(new JavaClass[resultSet.size()]);
+ return result;
+ }
+
+ /**
+ * Returns all the packages found in all the sources.
+ *
+ * @return all the packages found in all the sources.
+ * @since 1.9
+ */
+ public JavaPackage[] getPackages() {
+ return (JavaPackage[]) packages.toArray(new JavaPackage[packages.size()]);
+ }
+
+ private void addClassesRecursive(JavaSource javaSource, Set resultSet) {
+ JavaClass[] classes = javaSource.getClasses();
+ for (int j = 0; j < classes.length; j++) {
+ JavaClass javaClass = classes[j];
+ addClassesRecursive(javaClass, resultSet);
+ }
+ }
+
+ private void addClassesRecursive(JavaClass javaClass, Set set) {
+ // Add the class...
+ set.add(javaClass);
+
+ // And recursively all of its inner classes
+ JavaClass[] innerClasses = javaClass.getNestedClasses();
+ for (int i = 0; i < innerClasses.length; i++) {
+ JavaClass innerClass = innerClasses[i];
+ addClassesRecursive(innerClass, set);
+ }
+ }
+
+ /**
+ * Add all files in a directory (and subdirs, recursively).
+ *
+ * If a file cannot be read, a RuntimeException shall be thrown.
+ */
+ public void addSourceTree(File file) {
+ FileVisitor errorHandler = new FileVisitor() {
+ public void visitFile(File badFile) {
+ throw new RuntimeException("Cannot read file : " + badFile.getName());
+ }
+ };
+ addSourceTree(file, errorHandler);
+ }
+
+ /**
+ * Add all files in a directory (and subdirs, recursively).
+ *
+ * If a file cannot be read, errorHandler will be notified.
+ */
+ public void addSourceTree(File file, final FileVisitor errorHandler) {
+ DirectoryScanner scanner = new DirectoryScanner(file);
+ scanner.addFilter(new SuffixFilter(".java"));
+ scanner.scan(new FileVisitor() {
+ public void visitFile(File currentFile) {
+ try {
+ addSource(currentFile);
+ } catch (IOException e) {
+ errorHandler.visitFile(currentFile);
+ }
+ }
+ });
+ }
+
+ public List search(Searcher searcher) {
+ List results = new LinkedList();
+ for (Iterator iterator = context.getClassLibrary().all().iterator(); iterator.hasNext();) {
+ String clsName = (String) iterator.next();
+ JavaClass cls = getClassByName(clsName);
+ if (searcher.eval(cls)) {
+ results.add(cls);
+ }
+ }
+ return results;
+ }
+
+ public ClassLibrary getClassLibrary() {
+ return context.getClassLibrary();
+ }
+
+ public void save(File file) throws IOException {
+ FileOutputStream fos = new FileOutputStream(file);
+ ObjectOutputStream out = new ObjectOutputStream(fos);
+ try {
+ out.writeObject(this);
+ } finally {
+ out.close();
+ fos.close();
+ }
+ }
+
+ /**
+ * Note that after loading JavaDocBuilder classloaders need to be re-added.
+ */
+ public static JavaDocBuilder load(File file) throws IOException {
+ FileInputStream fis = new FileInputStream(file);
+ ObjectInputStream in = new ObjectInputStream(fis);
+ JavaDocBuilder builder = null;
+ try {
+ builder = (JavaDocBuilder) in.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new Error("Couldn't load class : " + e.getMessage());
+ } finally {
+ in.close();
+ fis.close();
+ }
+ return builder;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
+ * Forces QDox to dump tokens returned from lexer to System.err.
+ */
+ public void setDebugLexer(boolean debugLexer) {
+ this.debugLexer = debugLexer;
+ }
+
+ /**
+ * Forces QDox to dump parser states to System.out.
+ */
+ public void setDebugParser(boolean debugParser) {
+ this.debugParser = debugParser;
+ }
+
+ public JavaPackage getPackageByName( String name )
+ {
+ if(name != null) {
+ Iterator iter = packages.iterator();
+ while(iter.hasNext()) {
+ JavaPackage pkg = (JavaPackage) iter.next();
+ if(name.equals( pkg.getName() )) {
+ return pkg;
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/Searcher.java b/src/java/com/thoughtworks/qdox/Searcher.java
new file mode 100644
index 0000000..4ba5061
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/Searcher.java
@@ -0,0 +1,9 @@
+package com.thoughtworks.qdox;
+
+import com.thoughtworks.qdox.model.JavaClass;
+
+public interface Searcher {
+
+ boolean eval(JavaClass cls);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/ant/AbstractQdoxTask.java b/src/java/com/thoughtworks/qdox/ant/AbstractQdoxTask.java
new file mode 100644
index 0000000..c3176f6
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/ant/AbstractQdoxTask.java
@@ -0,0 +1,92 @@
+package com.thoughtworks.qdox.ant;
+
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.DocletTagFactory;
+import com.thoughtworks.qdox.model.DefaultDocletTagFactory;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+
+public abstract class AbstractQdoxTask extends Task {
+ private Vector filesets = new Vector();
+ protected HashMap fileMap = new HashMap();
+ protected ArrayList allSources = new ArrayList();
+ protected ArrayList allClasses = new ArrayList();
+
+ public void addFileset(FileSet set) {
+ filesets.addElement(set);
+ }
+
+ protected void buildFileMap() {
+ for (int i = 0; i < filesets.size(); i++) {
+ FileSet fs = (FileSet) filesets.elementAt(i);
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ String[] srcFiles = ds.getIncludedFiles();
+ buildFileMap(fs.getDir(getProject()), srcFiles);
+ }
+ }
+
+ protected void buildFileMap(File directory, String[] sourceFiles) {
+ for (int i = 0; i < sourceFiles.length; i++) {
+ File src = new File(directory, sourceFiles[i]);
+ fileMap.put(src.getAbsolutePath(), src);
+ }
+ }
+
+ public void execute() throws BuildException {
+ validateAttributes();
+ buildFileMap();
+ JavaDocBuilder builder = new JavaDocBuilder(createDocletTagFactory());
+
+ // Add a classloader that has the taskdef's classpath.
+ builder.getClassLibrary().addClassLoader(getClass().getClassLoader());
+ mergeBuilderSources(builder);
+ JavaSource[] sources = builder.getSources();
+ processSources(sources);
+ }
+
+ protected DocletTagFactory createDocletTagFactory() {
+ return new DefaultDocletTagFactory();
+ }
+
+ private void mergeBuilderSources(JavaDocBuilder builder) {
+ for (Iterator iterator = fileMap.keySet().iterator(); iterator.hasNext();) {
+ String sourceFile = (String) iterator.next();
+ builder.addSourceTree((File) fileMap.get(sourceFile));
+
+ }
+ }
+
+ protected void processSources(JavaSource[] sources) {
+ for (int i = 0; i < sources.length; i++) {
+ JavaSource source = sources[i];
+ allSources.add(source);
+ JavaClass[] classes = source.getClasses();
+ processClasses(classes);
+ }
+ }
+
+ protected void processClasses(JavaClass[] classes) {
+ for (int j = 0; j < classes.length; j++) {
+ JavaClass clazz = classes[j];
+ allClasses.add(clazz);
+ }
+ }
+
+ protected void validateAttributes() throws BuildException {
+ if (filesets.size() == 0) {
+ throw new BuildException("Specify at least one source fileset.");
+ }
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java b/src/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java
new file mode 100644
index 0000000..519e87e
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java
@@ -0,0 +1,54 @@
+package com.thoughtworks.qdox.directorywalker;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+public class DirectoryScanner {
+ private File file;
+ private Collection filters = new HashSet();
+
+ public DirectoryScanner(File file) {
+ this.file = file;
+ }
+
+ public File[] scan() {
+ final List results = new ArrayList();
+ walk(new FileVisitor() {
+ public void visitFile(File file) {
+ results.add(file);
+ }
+ }, this.file);
+ File[] resultsArray = new File[results.size()];
+ results.toArray(resultsArray);
+ return resultsArray;
+ }
+
+ private void walk(FileVisitor visitor, File current) {
+ if (current.isDirectory()) {
+ File[] currentFiles = current.listFiles();
+ for (int i = 0; i < currentFiles.length; i++) {
+ walk(visitor, currentFiles[i]);
+ }
+ } else {
+ for (Iterator iterator = this.filters.iterator(); iterator.hasNext();) {
+ Filter filter = (Filter) iterator.next();
+ if (!filter.filter(current)) {
+ return;
+ }
+ }
+ visitor.visitFile(current);
+ }
+ }
+
+ public void addFilter(Filter filter) {
+ this.filters.add(filter);
+ }
+
+ public void scan(FileVisitor fileVisitor) {
+ walk(fileVisitor, this.file);
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java b/src/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java
new file mode 100644
index 0000000..7f26e03
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java
@@ -0,0 +1,9 @@
+package com.thoughtworks.qdox.directorywalker;
+
+import java.io.File;
+
+public interface FileVisitor {
+
+ void visitFile(File file);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/directorywalker/Filter.java b/src/java/com/thoughtworks/qdox/directorywalker/Filter.java
new file mode 100644
index 0000000..f6d2a51
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/directorywalker/Filter.java
@@ -0,0 +1,9 @@
+package com.thoughtworks.qdox.directorywalker;
+
+import java.io.File;
+
+public interface Filter {
+
+ boolean filter(File file);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java b/src/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java
new file mode 100644
index 0000000..76c8937
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java
@@ -0,0 +1,15 @@
+package com.thoughtworks.qdox.directorywalker;
+
+import java.io.File;
+
+public class SuffixFilter implements Filter {
+ private String suffixFilter;
+
+ public SuffixFilter(String suffixFilter) {
+ this.suffixFilter = suffixFilter;
+ }
+
+ public boolean filter(File file) {
+ return file.getName().endsWith(this.suffixFilter);
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/junit/APITestCase.java b/src/java/com/thoughtworks/qdox/junit/APITestCase.java
new file mode 100644
index 0000000..6c2fc88
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/junit/APITestCase.java
@@ -0,0 +1,345 @@
+package com.thoughtworks.qdox.junit;
+
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.AbstractBaseJavaEntity;
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+import com.thoughtworks.qdox.model.JavaSource;
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * APITestCase is a JUnit extension that will let you compare two sources
+ * (typically one kept as a static expected result and a generated one) on the API level.
+ * <p/>
+ * This class has been ported from XJavaDoc's CodeTestCase, carrying over only the
+ * parts that compare on the API level. The original CodeTestCase also has comparison
+ * of Java source AST (Abstract Syntax Trees). This will probably be extracted into
+ * a ASTTestCase class and hosted as a separate project somewhere else. It should
+ * probably be based on JavaCC for ease of porting.
+ *
+ * @author Aslak Hellesøy
+ * @author Laurent Etiemble
+ */
+public abstract class APITestCase extends TestCase {
+ /*
+ * Needed to sort JavaClass, JavaField and JavaMethod as they
+ * don't implement Comparable
+ */
+ private static Comparator ENTITY_COMPARATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ AbstractBaseJavaEntity entity1 = (AbstractBaseJavaEntity) o1;
+ AbstractBaseJavaEntity entity2 = (AbstractBaseJavaEntity) o2;
+ return entity1.getName().compareTo(entity2.getName());
+ }
+ };
+
+ public APITestCase() {
+ super();
+ }
+
+ /**
+ * Compares API of both sources in the readers.
+ * <p/>
+ * <p><b>Note:</b> This method is for backward naming compatiblity
+ * with xjavadoc.codeunit.CodeTestCase.</p>
+ *
+ * @param expected the expected source
+ * @param actual the actual source
+ */
+ public static void assertApiEquals(URL expected, URL actual) throws IOException {
+ JavaDocBuilder builder = new JavaDocBuilder();
+
+ builder.addSource(new InputStreamReader(expected.openStream()), expected.toExternalForm());
+ builder.addSource(new InputStreamReader(actual.openStream()), actual.toExternalForm());
+ JavaSource expectedSource = builder.getSources()[0];
+ JavaSource actualsource = builder.getSources()[1];
+
+ assertApiEquals(expectedSource, actualsource);
+ }
+
+ /**
+ * Compares API of both JavaSource objects.
+ *
+ * @param expected the expected source
+ * @param actual the actual source
+ */
+ private static void assertApiEquals(JavaSource expected,
+ JavaSource actual) {
+ List expectedClasses = Arrays.asList(expected.getClasses());
+ Collections.sort(expectedClasses, ENTITY_COMPARATOR);
+ List actualClasses = Arrays.asList(actual.getClasses());
+ Collections.sort(actualClasses, ENTITY_COMPARATOR);
+
+ assertEquals("Number of classes should be equal",
+ expectedClasses.size(),
+ actualClasses.size());
+
+ for (int i = 0; i < expectedClasses.size(); i++) {
+ assertClassesEqual((JavaClass) expectedClasses.get(i),
+ (JavaClass) actualClasses.get(i));
+ }
+ }
+
+ /**
+ * Compares an actual field to an expected one.
+ * <p/>
+ * <p>As JavaClass doesn't not implements <code>equals</code> and
+ * <code>hashCode</code> methods, the comparison is done by hand.</p>
+ *
+ * @param expected
+ * @param actual
+ */
+ private static void assertClassesEqual(JavaClass expected,
+ JavaClass actual) {
+ assertEquals("Package names should be equal",
+ expected.getPackage(),
+ actual.getPackage());
+ assertModifiersEquals("Class modifiers should be equal",
+ expected,
+ actual);
+ assertEquals("Class names should be equal",
+ expected.getName(),
+ actual.getName());
+
+ if ((expected.getSuperJavaClass() != null)
+ && (actual.getSuperJavaClass() != null)) {
+ assertEquals("Super class should be equal",
+ expected.getSuperJavaClass().getName(),
+ actual.getSuperJavaClass().getName());
+ }
+ if ((expected.getSuperJavaClass() == null)
+ ^ (actual.getSuperJavaClass() == null)) {
+ fail("Super class should be equal");
+ }
+
+ assertInterfacesEqual(expected, actual);
+ assertInnerClassesEquals(expected, actual);
+ assertFieldsEqual(expected, actual);
+ assertMethodsEqual(expected, actual);
+ }
+
+ /**
+ * Compares an actual field to an expected one.
+ * <p/>
+ * <p>As JavaField doesn't not implements <code>equals</code> and
+ * <code>hashCode</code> methods, the comparison is done by hand.</p>
+ *
+ * @param expected
+ * @param actual
+ */
+ private static void assertFieldEquals(JavaField expected,
+ JavaField actual) {
+ StringBuffer message = new StringBuffer("-> assertFieldEquals");
+ message.append("\n\tExcepted : ");
+ message.append(expected);
+ message.append("\n\tActual : ");
+ message.append(actual);
+ message.append("\n");
+
+ assertEquals(message.toString() + "Field types should be equal",
+ expected.getType(),
+ actual.getType());
+ assertEquals(message.toString() + "Field names should be equal",
+ expected.getName(),
+ actual.getName());
+ assertModifiersEquals(message.toString() + "Field modifiers should be equal",
+ expected,
+ actual);
+ }
+
+ /**
+ * Compares fields from an actual class to an expected one.
+ * <p/>
+ * <p>The fields are sorted by name before comparison to be sure
+ * that even if the fields are defined in a different order, the
+ * comparison is still right.</p>
+ */
+ private static void assertFieldsEqual(JavaClass expected,
+ JavaClass actual) {
+ List expectedFields = Arrays.asList(expected.getFields());
+ Collections.sort(expectedFields, ENTITY_COMPARATOR);
+ List actualFields = Arrays.asList(actual.getFields());
+ Collections.sort(actualFields, ENTITY_COMPARATOR);
+
+ StringBuffer message = new StringBuffer("-> assertFieldsEqual");
+ message.append("\n\tExcepted : ");
+ message.append(expectedFields);
+ message.append("\n\tActual : ");
+ message.append(actualFields);
+ message.append("\n");
+
+ assertEquals(message.toString() + "Number of fields should be equal",
+ expectedFields.size(),
+ actualFields.size());
+
+ for (int i = 0; i < expectedFields.size(); i++) {
+ assertFieldEquals((JavaField) expectedFields.get(i),
+ (JavaField) actualFields.get(i));
+ }
+
+ }
+
+ /**
+ * Compares inner classes from an actual class to an expected one.
+ * <p/>
+ * <p>The inner classes are sorted by name before comparison to be sure
+ * that even if the inner classes are defined in a different order, the
+ * comparison is still right.</p>
+ */
+ private static void assertInnerClassesEquals(JavaClass expected,
+ JavaClass actual) {
+ List expectedInnerClasses = Arrays.asList(expected.getNestedClasses());
+ Collections.sort(expectedInnerClasses, ENTITY_COMPARATOR);
+ List actualInnerClasses = Arrays.asList(actual.getNestedClasses());
+ Collections.sort(actualInnerClasses, ENTITY_COMPARATOR);
+
+ StringBuffer message = new StringBuffer("-> assertInnerClassesEquals");
+ message.append("\n\tExcepted : ");
+ message.append(expectedInnerClasses);
+ message.append("\n\tActual : ");
+ message.append(actualInnerClasses);
+ message.append("\n");
+
+ assertEquals(message.toString() + "Number of inner classes should be equal",
+ expectedInnerClasses.size(),
+ actualInnerClasses.size());
+
+ for (int i = 0; i < expectedInnerClasses.size(); i++) {
+ assertClassesEqual((JavaClass) expectedInnerClasses.get(i),
+ (JavaClass) actualInnerClasses.get(i));
+ }
+ }
+
+ /**
+ * Compares implemented interfaces from an actual class to an expected one.
+ * <p/>
+ * <p>The implemented interfaces are sorted by name before comparison to be sure
+ * that even if the implemented interfaces are defined in a different order, the
+ * comparison is still right.</p>
+ */
+ private static void assertInterfacesEqual(JavaClass expected,
+ JavaClass actual) {
+ List expectedImplements = Arrays.asList(expected.getImplements());
+ Collections.sort(expectedImplements);
+ List actualImplements = Arrays.asList(actual.getImplements());
+ Collections.sort(actualImplements);
+
+ StringBuffer message = new StringBuffer("-> assertInnerClassesEquals");
+ message.append("\n\tExcepted : ");
+ message.append(expectedImplements);
+ message.append("\n\tActual : ");
+ message.append(actualImplements);
+ message.append("\n");
+
+ assertEquals(message.toString() + "Number of implemented interface should be equal",
+ expectedImplements.size(),
+ actualImplements.size());
+
+ for (int i = 0; i < expectedImplements.size(); i++) {
+ assertEquals("Implemented interface should be equal",
+ expectedImplements.get(i),
+ actualImplements.get(i));
+ }
+ }
+
+ /**
+ * Compares constructors and methods from an actual class to an expected one.
+ * <p/>
+ * <p>The constructors and the methods are sorted by name before comparison to be sure
+ * that even if the constructors and methods are defined in a different order, the
+ * comparison is still right.</p>
+ */
+ private static void assertMethodsEqual(JavaClass expected,
+ JavaClass actual) {
+ List expectedMethods = Arrays.asList(expected.getMethods());
+ Collections.sort(expectedMethods, ENTITY_COMPARATOR);
+ List actualMethods = Arrays.asList(actual.getMethods());
+ Collections.sort(actualMethods, ENTITY_COMPARATOR);
+
+ StringBuffer message = new StringBuffer("-> assertMethodsEqual");
+ message.append("\n\tExcepted : ");
+ message.append(expectedMethods);
+ message.append("\n\tActual : ");
+ message.append(actualMethods);
+ message.append("\n");
+
+ assertEquals(message.toString() + "Number of methods should be equal",
+ expectedMethods.size(),
+ actualMethods.size());
+
+ for (int i = 0; i < expectedMethods.size(); i++) {
+ assertEquals("Method should be equal",
+ expectedMethods.get(i),
+ actualMethods.get(i));
+ }
+ }
+
+ /**
+ * Compares modifiers an actual entity.
+ * <p/>
+ * <p>The modifiers are sorted by name before comparison to be sure
+ * that even if the modifiers are defined in a different order, the
+ * comparison is still right.</p>
+ */
+ private static void assertModifiersEquals(String msg,
+ AbstractJavaEntity expected,
+ AbstractJavaEntity actual) {
+
+ List expectedModifiers = Arrays.asList(expected.getModifiers());
+ Collections.sort(expectedModifiers);
+ List actualModifiers = Arrays.asList(actual.getModifiers());
+ Collections.sort(actualModifiers);
+
+ StringBuffer message = new StringBuffer("-> assertModifiersEquals");
+ message.append("\n\tExcepted : ");
+ message.append(expectedModifiers);
+ message.append("\n\tActual : ");
+ message.append(actualModifiers);
+ message.append("\n");
+
+ assertEquals(message.toString() + msg + "\nNumber of modifiers should be equal",
+ expectedModifiers.size(),
+ actualModifiers.size());
+
+ for (int i = 0; i < expectedModifiers.size(); i++) {
+ assertEquals(msg + "\n" + message.toString() + "\nModifier should be equal",
+ expectedModifiers.get(i),
+ actualModifiers.get(i));
+ }
+ }
+
+ private static void assertNotDir(File expected, File actual) {
+ if (expected.isDirectory())
+ fail(expected.getAbsolutePath() + " - should not have been a directory");
+ if (actual.isDirectory())
+ fail(actual.getAbsolutePath() + " - should not have been a directory");
+ }
+
+ protected File getDir() {
+ return (
+ new File(getClass()
+ .getResource("/" + getClass().getName().replace('.', '/') + ".class")
+ .getFile()))
+ .getParentFile();
+ }
+
+ protected File getRootDir() {
+ File dir = getDir();
+ StringTokenizer st = new StringTokenizer(getClass().getName(), ".");
+ for (int i = 0; i < st.countTokens() - 1; i++) {
+ dir = dir.getParentFile();
+ }
+ return dir;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/AbstractBaseJavaEntity.java b/src/java/com/thoughtworks/qdox/model/AbstractBaseJavaEntity.java
new file mode 100644
index 0000000..77a2c82
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/AbstractBaseJavaEntity.java
@@ -0,0 +1,66 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+
+public class AbstractBaseJavaEntity implements Serializable {
+
+ protected String name;
+ private Annotation[] annotations = new Annotation[0];
+ private int lineNumber = -1;
+ protected JavaClassParent parent;
+
+ public AbstractBaseJavaEntity() {
+ super();
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Annotation[] getAnnotations() {
+ return annotations;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setAnnotations(Annotation[] annotations) {
+ this.annotations = annotations;
+ }
+
+ public void setLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ /**
+ *
+ * @return
+ * @deprecated
+ */
+ public JavaClassParent getParent() {
+ return parent;
+ }
+
+ /**
+ *
+ * @param parent
+ * @deprecated
+ */
+ public void setParent(JavaClassParent parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Not every entity has a parentClass, but AnnotationFieldRef requires access to it.
+ * When used with JavaClass, don't confuse this with getSuperClass()
+ *
+ * @return the surrounding class
+ */
+ public JavaClass getParentClass() { return null; }
+
+}
\ No newline at end of file
diff --git a/src/java/com/thoughtworks/qdox/model/AbstractInheritableJavaEntity.java b/src/java/com/thoughtworks/qdox/model/AbstractInheritableJavaEntity.java
new file mode 100644
index 0000000..d213d7c
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/AbstractInheritableJavaEntity.java
@@ -0,0 +1,16 @@
+package com.thoughtworks.qdox.model;
+
+/**
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ */
+public abstract class AbstractInheritableJavaEntity extends AbstractJavaEntity {
+
+ public DocletTag getTagByName(String name, boolean inherited) {
+ DocletTag[] tags = getTagsByName(name, inherited);
+ return tags.length > 0 ? tags[0] : null;
+ }
+
+ public abstract DocletTag[] getTagsByName(String name, boolean inherited);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java b/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java
new file mode 100644
index 0000000..048285c
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/AbstractJavaEntity.java
@@ -0,0 +1,229 @@
+package com.thoughtworks.qdox.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+public abstract class AbstractJavaEntity extends AbstractBaseJavaEntity implements Comparable {
+
+ protected List modifiers = new ArrayList();
+ private String comment;
+ private DocletTag[] tags = new DocletTag[0];
+
+ private JavaClass parentClass;
+ /**
+ * Return list of modifiers as Strings.
+ * (public, private, protected, final, abstract, static)
+ */
+ public String[] getModifiers() {
+ return (String[]) modifiers.toArray(new String[modifiers.size()]);
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public DocletTag[] getTags() {
+ return tags;
+ }
+
+ public DocletTag[] getTagsByName(String name) {
+ List specifiedTags = new ArrayList();
+ for (int i = 0; i < tags.length; i++) {
+ DocletTag docletTag = tags[i];
+ if (docletTag.getName().equals(name)) {
+ specifiedTags.add(docletTag);
+ }
+ }
+ return (DocletTag[]) specifiedTags.toArray(new DocletTag[specifiedTags.size()]);
+ }
+
+ public DocletTag getTagByName(String name) {
+ for (int i = 0; i < tags.length; i++) {
+ DocletTag docletTag = tags[i];
+ if (docletTag.getName().equals(name)) {
+ return docletTag;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Convenience method for <code>getTagByName(String).getNamedParameter(String)</code>
+ * that also checks for null tag.
+ * @since 1.3
+ */
+ public String getNamedParameter(String tagName, String parameterName) {
+ DocletTag tag = getTagByName(tagName);
+ if(tag != null) {
+ return tag.getNamedParameter(parameterName);
+ } else {
+ return null;
+ }
+ }
+
+ void commentHeader(IndentBuffer buffer) {
+ if (comment == null && (tags == null || tags.length == 0)) {
+ return;
+ } else {
+ buffer.write("/**");
+ buffer.newline();
+
+ if (comment != null && comment.length() > 0) {
+ buffer.write(" * ");
+
+ buffer.write(comment.replaceAll("\n", "\n * "));
+
+ buffer.newline();
+ }
+
+ if (tags != null && tags.length > 0) {
+ if (comment != null && comment.length() > 0) {
+ buffer.write(" *");
+ buffer.newline();
+ }
+ for (int i = 0; i < tags.length; i++) {
+ DocletTag docletTag = tags[i];
+ buffer.write(" * @");
+ buffer.write(docletTag.getName());
+ if (docletTag.getValue().length() > 0) {
+ buffer.write(' ');
+ buffer.write(docletTag.getValue());
+ }
+ buffer.newline();
+ }
+ }
+
+ buffer.write(" */");
+ buffer.newline();
+ }
+ }
+
+ public String getCodeBlock() {
+ IndentBuffer result = new IndentBuffer();
+ write(result);
+ return result.toString();
+ }
+
+ protected void write(IndentBuffer result) {
+ commentHeader(result);
+ writeBody(result);
+ }
+
+ protected abstract void writeBody(IndentBuffer result);
+
+ public void setModifiers(String[] modifiers) {
+ this.modifiers = Arrays.asList(modifiers);
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public void setTags(List tagList) {
+ this.tags = new DocletTag[tagList.size()];
+ tagList.toArray(this.tags);
+ }
+
+ //helper methods for querying the modifiers
+ public boolean isAbstract() {
+ return isModifierPresent("abstract");
+ }
+
+ public boolean isPublic() {
+ return isModifierPresent("public");
+ }
+
+ public boolean isPrivate() {
+ return isModifierPresent("private");
+ }
+
+ public boolean isProtected() {
+ return isModifierPresent("protected");
+ }
+
+ public boolean isStatic() {
+ return isModifierPresent("static");
+ }
+
+ public boolean isFinal() {
+ return isModifierPresent("final");
+ }
+
+ public boolean isSynchronized() {
+ return isModifierPresent("synchronized");
+ }
+
+ public boolean isTransient() {
+ return isModifierPresent("transient");
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isVolatile() {
+ return isModifierPresent("volatile");
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isNative() {
+ return isModifierPresent("native");
+ }
+
+ /**
+ * @since 1.4
+ */
+ public boolean isStrictfp() {
+ return isModifierPresent("strictfp");
+ }
+
+ private boolean isModifierPresent(String modifier) {
+ return modifiers.contains(modifier);
+ }
+
+ protected void writeNonAccessibilityModifiers(IndentBuffer result) {
+ // modifiers (anything else)
+ for (Iterator iter = modifiers.iterator(); iter.hasNext();) {
+ String modifier = (String) iter.next();
+ if (!modifier.startsWith("p")) {
+ result.write(modifier);
+ result.write(' ');
+ }
+ }
+ }
+
+ protected void writeAccessibilityModifier(IndentBuffer result) {
+ for (Iterator iter = modifiers.iterator(); iter.hasNext();) {
+ String modifier = (String) iter.next();
+ if (modifier.startsWith("p")) {
+ result.write(modifier);
+ result.write(' ');
+ }
+ }
+ }
+
+ protected void writeAllModifiers(IndentBuffer result) {
+ for (Iterator iter = modifiers.iterator(); iter.hasNext();) {
+ String modifier = (String) iter.next();
+ result.write(modifier);
+ result.write(' ');
+ }
+ }
+
+ public JavaSource getSource() {
+ return parentClass.getParentSource();
+ }
+
+ public void setParentClass( JavaClass parentClass )
+ {
+ this.parentClass = parentClass;
+ }
+
+ public JavaClass getParentClass()
+ {
+ return parentClass;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/Annotation.java b/src/java/com/thoughtworks/qdox/model/Annotation.java
new file mode 100644
index 0000000..7a8f4e8
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/Annotation.java
@@ -0,0 +1,128 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.thoughtworks.qdox.model.annotation.AnnotationValue;
+import com.thoughtworks.qdox.model.annotation.AnnotationVisitor;
+
+/**
+ *
+ * @author Eric Redmond
+ */
+public class Annotation implements AnnotationValue, Serializable
+{
+ private final Type type;
+ private final int lineNumber;
+
+ /**
+ * Annotation properties as AnnotationValues
+ * <p>
+ * This map contains the parsed AnnotationValue for each property and allows
+ * access to the full parse tree, including typerefs and expressions.
+ */
+ private final Map properties = new LinkedHashMap();
+
+ /**
+ * Annotation properties as Parameters
+ */
+ private final Map namedParameters = new LinkedHashMap();
+
+ private AbstractBaseJavaEntity context;
+
+ public Annotation(Type type,
+ AbstractBaseJavaEntity context,
+ Map namedParameters,
+ int lineNumber)
+ {
+ this.type = type;
+ this.context = context;
+ this.lineNumber = lineNumber;
+
+ if(properties != null) {
+ for(Iterator i = this.properties.entrySet().iterator(); i.hasNext(); ) {
+ Entry entry = (Entry) i.next();
+ String name = (String) entry.getKey();
+ AnnotationValue value = (AnnotationValue) entry.getValue();
+
+ setProperty(name, value);
+ }
+ }
+ }
+
+ public Annotation( Type type, int line ) {
+ this(type, null, null, line);
+ }
+
+ public void setProperty(String name, AnnotationValue value) {
+ properties.put( name, value );
+ namedParameters.put( name, value.getParameterValue() );
+ }
+
+ /**
+ * @return the annotation type
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * @param key name of a named-parameter
+ * @return the corresponding value,
+ * or null if no such named-parameter was present
+ */
+ public Object getNamedParameter(String key) {
+ return namedParameters.get( key );
+ }
+
+ /**
+ * @return a Map containing all the named-parameters
+ */
+ public Map getNamedParameterMap() {
+ return namedParameters;
+ }
+
+ public final AbstractBaseJavaEntity getContext() {
+ return context;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotation( this );
+ }
+
+ public Object getParameterValue() {
+ return this;
+ }
+
+ public Map getPropertyMap() {
+ return properties;
+ }
+
+ public AnnotationValue getProperty(String name) {
+ return (AnnotationValue) properties.get( name );
+ }
+
+ public void setContext( AbstractBaseJavaEntity context ) {
+ this.context = context;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append('@');
+ result.append(type.getValue());
+ result.append('(');
+ if( !namedParameters.isEmpty() ) {
+ for(Iterator i = namedParameters.entrySet().iterator(); i.hasNext();) result.append( i.next() + ",");
+ result.deleteCharAt( result.length()-1 );
+ }
+ result.append(')');
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/BeanProperty.java b/src/java/com/thoughtworks/qdox/model/BeanProperty.java
new file mode 100644
index 0000000..8b9460a
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/BeanProperty.java
@@ -0,0 +1,46 @@
+package com.thoughtworks.qdox.model;
+
+/**
+ *
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ */
+public class BeanProperty {
+
+ private final String name;
+ private JavaMethod accessor;
+ private JavaMethod mutator;
+ private Type type;
+
+ public BeanProperty(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public JavaMethod getAccessor() {
+ return accessor;
+ }
+
+ public void setAccessor(JavaMethod accessor) {
+ this.accessor = accessor;
+ }
+
+ public JavaMethod getMutator() {
+ return mutator;
+ }
+
+ public void setMutator(JavaMethod mutator) {
+ this.mutator = mutator;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/ClassLibrary.java b/src/java/com/thoughtworks/qdox/model/ClassLibrary.java
new file mode 100644
index 0000000..b1189c6
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/ClassLibrary.java
@@ -0,0 +1,142 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * <strong>Important!! Be sure to add a classloader with the bootstrap classes.</strong>
+ *
+ * <p>
+ * Normally you can generate your classLibrary like this:<br/>
+ * <code>
+ * ClassLibrary classLibrary = new ClassLibrary();
+ * classLibrary.addDefaultLoader();
+ * </code>
+ * </p>
+ *
+ * <p>
+ * If you want full control over the classLoaders you might want to create your library like:<br/>
+ * <code>
+ * ClassLibrary classLibrary = new ClassLibrary( ClassLoader.getSystemClassLoader() )
+ * </code>
+ * </p>
+ *
+ * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
+ * @author Aslak Hellesøy
+ * @author Robert Scholte
+ */
+public class ClassLibrary implements Serializable {
+
+ private final Set classNames = new TreeSet();
+ private final Map classNameToClassMap = new HashMap();
+ private boolean defaultClassLoadersAdded = false;
+ private transient List classLoaders = new ArrayList();
+ private List sourceFolders = new ArrayList(); //<File>
+
+ /**
+ * Remember to add bootstrap classes
+ */
+ public ClassLibrary() {}
+
+ /**
+ * Remember to add bootstrap classes
+ */
+ public ClassLibrary(ClassLoader loader) {
+ classLoaders.add(loader);
+ }
+
+ public void add(String className) {
+ classNames.add(className);
+ }
+
+ public boolean contains(String className) {
+ if (classNames.contains(className)) {
+ return true;
+ }
+ else if (getSourceFile(className) != null) {
+ return true;
+ } else {
+ return getClass(className) != null;
+ }
+ }
+
+ public File getSourceFile( String className )
+ {
+ for(Iterator iterator = sourceFolders.iterator(); iterator.hasNext();) {
+ File sourceFolder = (File) iterator.next();
+ String mainClassName = className.split( "\\$" )[0];
+ File classFile = new File(sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java");
+ if ( classFile.exists() && classFile.isFile() ) {
+ return classFile;
+ }
+ }
+ return null;
+ }
+
+ public Class getClass(String className) {
+ Class cachedClass = (Class) classNameToClassMap.get(className);
+ if (cachedClass != null) {
+ return cachedClass;
+ } else {
+ for (Iterator iterator = classLoaders.iterator(); iterator.hasNext();) {
+ ClassLoader classLoader = (ClassLoader) iterator.next();
+ if (classLoader == null) {
+ continue;
+ }
+ try {
+ Class clazz = classLoader.loadClass(className);
+ if (clazz != null) {
+ classNameToClassMap.put(className, clazz);
+ return clazz;
+ }
+ } catch (ClassNotFoundException e) {
+ // continue
+ } catch (NoClassDefFoundError e) {
+ // continue
+ }
+ }
+ }
+ return null;
+ }
+
+ public Collection all() {
+ return Collections.unmodifiableCollection(classNames);
+ }
+
+ public void addClassLoader(ClassLoader classLoader) {
+ classLoaders.add(classLoader);
+ }
+
+ public void addDefaultLoader() {
+ if (!defaultClassLoadersAdded) {
+ classLoaders.add(getClass().getClassLoader());
+ classLoaders.add(Thread.currentThread().getContextClassLoader());
+ }
+ defaultClassLoadersAdded = true;
+ }
+
+ public void addSourceFolder( File sourceFolder ) {
+ sourceFolders.add( sourceFolder );
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ classLoaders = new ArrayList();
+ if (defaultClassLoadersAdded) {
+ defaultClassLoadersAdded = false;
+ addDefaultLoader();
+ }
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/DefaultDocletTag.java b/src/java/com/thoughtworks/qdox/model/DefaultDocletTag.java
new file mode 100644
index 0000000..7e31b74
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/DefaultDocletTag.java
@@ -0,0 +1,66 @@
+package com.thoughtworks.qdox.model;
+
+import com.thoughtworks.qdox.model.util.TagParser;
+
+import java.util.Map;
+
+public class DefaultDocletTag implements DocletTag {
+
+ private final String name;
+ private final String value;
+ private final int lineNumber;
+
+ private String[] parameters;
+ private Map namedParameters;
+ private AbstractBaseJavaEntity context;
+
+ public DefaultDocletTag(String name, String value,
+ AbstractBaseJavaEntity context,
+ int lineNumber)
+ {
+ this.name = name;
+ this.value = value;
+ this.context = context;
+ this.lineNumber = lineNumber;
+ }
+
+ public DefaultDocletTag(String name, String value) {
+ this(name, value, null, 0);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String[] getParameters() {
+ if (parameters == null) {
+ parameters = TagParser.parseParameters(value);
+ }
+ return parameters;
+ }
+
+ public Map getNamedParameterMap() {
+ if (namedParameters == null) {
+ namedParameters = TagParser.parseNamedParameters(value);
+ }
+ return namedParameters;
+ }
+
+ public String getNamedParameter(String key) {
+ return (String) getNamedParameterMap().get(key);
+ }
+
+ public final AbstractBaseJavaEntity getContext() {
+ return context;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+}
+
+
diff --git a/src/java/com/thoughtworks/qdox/model/DefaultDocletTagFactory.java b/src/java/com/thoughtworks/qdox/model/DefaultDocletTagFactory.java
new file mode 100644
index 0000000..711ebfb
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/DefaultDocletTagFactory.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model;
+
+/**
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ */
+public class DefaultDocletTagFactory implements DocletTagFactory {
+
+ public DocletTag createDocletTag(
+ String tag, String text,
+ AbstractBaseJavaEntity context, int lineNumber
+ ) {
+ return new DefaultDocletTag(tag, text, context, lineNumber);
+ }
+
+ public DocletTag createDocletTag(String tag, String text) {
+ return createDocletTag(tag, text, null, 0);
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/DocletTag.java b/src/java/com/thoughtworks/qdox/model/DocletTag.java
new file mode 100644
index 0000000..78da578
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/DocletTag.java
@@ -0,0 +1,51 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author Joe Walnes
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ */
+public interface DocletTag extends Serializable {
+
+ /**
+ * @return the tag name
+ */
+ String getName();
+
+ /**
+ * @return the full tag-value
+ */
+ String getValue();
+
+ /**
+ * @return an array of whitespace-separatedtag parameters
+ */
+ String[] getParameters();
+
+ /**
+ * @param key name of a named-parameter
+ * @return the corresponding value,
+ * or null if no such named-parameter was present
+ */
+ String getNamedParameter(String key);
+
+ /**
+ * @return a Map containing all the named-parameters
+ */
+ Map getNamedParameterMap();
+
+ /**
+ * @return the line-number where the tag occurred
+ */
+ int getLineNumber();
+
+ /**
+ * @return the language element to which this tag applies
+ * @since 1.4
+ */
+ AbstractBaseJavaEntity getContext();
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/DocletTagFactory.java b/src/java/com/thoughtworks/qdox/model/DocletTagFactory.java
new file mode 100644
index 0000000..0c54c4f
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/DocletTagFactory.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+
+/**
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ */
+public interface DocletTagFactory extends Serializable {
+
+ /**
+ * @since 1.5
+ */
+ DocletTag createDocletTag(
+ String tag, String text,
+ AbstractBaseJavaEntity context, int lineNumber
+ );
+
+ DocletTag createDocletTag(String tag, String text);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/IndentBuffer.java b/src/java/com/thoughtworks/qdox/model/IndentBuffer.java
new file mode 100644
index 0000000..d4ef00f
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/IndentBuffer.java
@@ -0,0 +1,43 @@
+package com.thoughtworks.qdox.model;
+
+public class IndentBuffer {
+
+ private StringBuffer buffer = new StringBuffer();
+ private int depth = 0;
+ private boolean newLine;
+
+ public void write(String s) {
+ checkNewLine();
+ buffer.append(s);
+ }
+
+ public void write(char s) {
+ checkNewLine();
+ buffer.append(s);
+ }
+
+ public void newline() {
+ buffer.append('\n');
+ newLine = true;
+ }
+
+ public void indent() {
+ depth++;
+ }
+
+ public void deindent() {
+ depth--;
+ }
+
+ public String toString() {
+ return buffer.toString();
+ }
+
+ private void checkNewLine() {
+ if (newLine) {
+ for (int i = 0; i < depth; i++) buffer.append('\t');
+ newLine = false;
+ }
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaClass.java b/src/java/com/thoughtworks/qdox/model/JavaClass.java
new file mode 100644
index 0000000..d7b0c41
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaClass.java
@@ -0,0 +1,740 @@
+package com.thoughtworks.qdox.model;
+
+import com.thoughtworks.qdox.JavaClassContext;
+import com.thoughtworks.qdox.model.util.OrderedMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
+ * @author Aslak Hellesøy
+ */
+public class JavaClass extends AbstractInheritableJavaEntity implements JavaClassParent {
+
+ private static Type OBJECT = new Type("java.lang.Object");
+ private static Type ENUM = new Type("java.lang.Enum");
+ private static Type ANNOTATION = new Type("java.lang.annotation.Annotation");
+
+ private List methods = new LinkedList();
+ private JavaMethod[] methodsArray;
+ private List fields = new LinkedList();
+ private JavaField[] fieldsArray;
+ private List classes = new LinkedList();
+ private JavaClass[] classesArray;
+ private boolean interfce;
+ private boolean isEnum;
+ private boolean isAnnotation;
+
+ // Don't access this directly. Use asType() to get my Type
+ private Type type;
+ private Type superClass;
+ private Type[] implementz = new Type[0];
+ private TypeVariable[] typeParameters = TypeVariable.EMPTY_ARRAY;
+ private JavaClassContext context;
+
+ //sourceless class can use this property
+ private JavaPackage javaPackage;
+
+ private JavaSource source;
+
+ public JavaClass() {
+ }
+
+ public JavaClass(String name) {
+ setName(name);
+ }
+
+ public void setJavaClassContext(JavaClassContext context) {
+ this.context = context;
+
+ // reassign OBJECT. This will make it have a "source" too,
+ // causing Type.getJavaClass() to return a JavaClass, instead
+ // of null.
+ OBJECT = context.getClassByName("java.lang.Object").asType();
+ }
+
+ /**
+ * is interface? (otherwise enum or class)
+ */
+ public boolean isInterface() {
+ return interfce;
+ }
+
+ /**
+ * is enum? (otherwise class or interface)
+ */
+ public boolean isEnum() {
+ return isEnum;
+ }
+
+ public Type getSuperClass() {
+ boolean iAmJavaLangObject = OBJECT.equals(asType());
+
+ if (isEnum) {
+ return ENUM;
+ } else if (!interfce && !isAnnotation && (superClass == null) && !iAmJavaLangObject) {
+ return OBJECT;
+ }
+
+ return superClass;
+ }
+
+ /**
+ * Shorthand for getSuperClass().getJavaClass() with null checking.
+ */
+ public JavaClass getSuperJavaClass() {
+ if (getSuperClass() != null) {
+ return getSuperClass().getJavaClass();
+ } else {
+ return null;
+ }
+ }
+
+ public Type[] getImplements() {
+ return implementz;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public JavaClass[] getImplementedInterfaces() {
+ Type[] type = getImplements();
+ JavaClass[] result = new JavaClass[type.length];
+
+ for (int i = 0; i < result.length; i++) {
+ result[i] = type[i].getJavaClass();
+ }
+
+ return result;
+ }
+
+ protected void writeBody(IndentBuffer result) {
+ writeAccessibilityModifier(result);
+ writeNonAccessibilityModifiers(result);
+
+ result.write(isEnum ? "enum " : interfce ? "interface " : isAnnotation ? "@interface " : "class ");
+ result.write(name);
+
+ // subclass
+ if (superClass != null) {
+ result.write(" extends ");
+ result.write(superClass.getValue());
+ }
+
+ // implements
+ if (implementz.length > 0) {
+ result.write(interfce ? " extends " : " implements ");
+
+ for (int i = 0; i < implementz.length; i++) {
+ if (i > 0) {
+ result.write(", ");
+ }
+
+ result.write(implementz[i].getValue());
+ }
+ }
+
+ result.write(" {");
+ result.newline();
+ result.indent();
+
+ // fields
+ for (Iterator iterator = fields.iterator(); iterator.hasNext();) {
+ JavaField javaField = (JavaField) iterator.next();
+
+ result.newline();
+ javaField.write(result);
+ }
+
+ // methods
+ for (Iterator iterator = methods.iterator(); iterator.hasNext();) {
+ JavaMethod javaMethod = (JavaMethod) iterator.next();
+
+ result.newline();
+ javaMethod.write(result);
+ }
+
+ // inner-classes
+ for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
+ JavaClass javaClass = (JavaClass) iterator.next();
+
+ result.newline();
+ javaClass.write(result);
+ }
+
+ result.deindent();
+ result.newline();
+ result.write('}');
+ result.newline();
+ }
+
+ public void setInterface(boolean interfce) {
+ this.interfce = interfce;
+ }
+
+ public void setEnum(boolean isEnum) {
+ this.isEnum = isEnum;
+ }
+
+ public void setAnnotation(boolean isAnnotation) {
+ this.isAnnotation = isAnnotation;
+ }
+
+ public void addMethod(JavaMethod meth) {
+ meth.setParentClass( this );
+ methods.add(meth);
+ methodsArray = null;
+ }
+
+ public void setSuperClass(Type type) {
+ if (isEnum) throw new IllegalArgumentException("enums cannot extend other classes");
+ superClass = type;
+ }
+
+ public void setImplementz(Type[] implementz) {
+ this.implementz = implementz;
+ }
+
+ public TypeVariable[] getTypeParameters()
+ {
+ return typeParameters;
+ }
+
+ public void setTypeParameters( TypeVariable[] typeParameters )
+ {
+ this.typeParameters = typeParameters;
+ }
+
+ public void addField(JavaField javaField) {
+ javaField.setParentClass( this );
+ fields.add(javaField);
+ fieldsArray = null;
+ }
+
+ /**
+ * Only used when constructing the model by hand / without source
+ *
+ * @param javaPackage
+ */
+ public void setJavaPackage(JavaPackage javaPackage) {
+ this.javaPackage = javaPackage;
+ }
+
+ public void setSource( JavaSource source )
+ {
+ this.source = source;
+ }
+
+ public JavaSource getParentSource() {
+ return (getParentClass() != null ? getParentClass().getParentSource() : source);
+ }
+
+ public JavaSource getSource()
+ {
+ return getParentSource();
+ }
+
+ public JavaPackage getPackage() {
+ return getParentSource() != null ? getParentSource().getPackage() : javaPackage;
+ }
+
+ public JavaClassParent getParent()
+ {
+ JavaClassParent result = getParentClass();
+ if (result == null) {
+ result = getParentSource();
+ }
+ return result;
+ }
+
+ /**
+ * If this class has a package, the packagename will be returned.
+ * Otherwise an empty String.
+ *
+ * @return
+ */
+ public String getPackageName() {
+ JavaPackage javaPackage = getPackage();
+ return (javaPackage != null && javaPackage.getName() != null) ? javaPackage.getName() : "";
+ }
+
+ public String getFullyQualifiedName() {
+ return (getParentClass() != null ? (getParentClass().getClassNamePrefix()) : getPackage() != null ? (getPackage().getName()+".") : "") + getName();
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean isInner() {
+ return getParentClass() != null;
+ }
+
+ public String resolveType(String typeName) {
+ // Maybe it's an inner class?
+ JavaClass[] innerClasses = getNestedClasses();
+ for (int i = 0; i < innerClasses.length; i++) {
+ if (innerClasses[i].getName().equals(typeName)) {
+ return innerClasses[i].getFullyQualifiedName();
+ }
+ }
+
+ return getParent().resolveType(typeName);
+ }
+
+ public JavaClassContext getJavaClassContext() {
+ return getParent().getJavaClassContext();
+ }
+
+ public String getClassNamePrefix() {
+ return getFullyQualifiedName() + "$";
+ }
+
+ public Type asType() {
+ if (type == null) {
+ type = new Type(getFullyQualifiedName(), 0, this);
+ }
+
+ return type;
+ }
+
+ public JavaMethod[] getMethods() {
+ if (methodsArray == null) {
+ methodsArray = new JavaMethod[methods.size()];
+ methods.toArray(methodsArray);
+ }
+
+ return methodsArray;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public JavaMethod[] getMethods(boolean superclasses) {
+ if (superclasses) {
+ Set signatures = new HashSet();
+ List methods = new ArrayList();
+
+ addMethodsFromSuperclassAndInterfaces(signatures, methods, this);
+
+ return (JavaMethod[]) methods.toArray(new JavaMethod[methods.size()]);
+ } else {
+ return getMethods();
+ }
+ }
+
+ private void addMethodsFromSuperclassAndInterfaces(Set signatures,
+ List methodList, JavaClass callingClazz) {
+ JavaMethod[] methods = callingClazz.getMethods();
+
+ addNewMethods(signatures, methodList, methods);
+
+ JavaClass superclass = callingClazz.getSuperJavaClass();
+
+ // TODO workaround for a bug in getSuperJavaClass
+ if ((superclass != null) && (superclass != callingClazz)) {
+ callingClazz.addMethodsFromSuperclassAndInterfaces(signatures, methodList,
+ superclass);
+ }
+
+ JavaClass[] implementz = callingClazz.getImplementedInterfaces();
+
+ for (int i = 0; i < implementz.length; i++) {
+ if (implementz[i] != null) {
+ callingClazz.addMethodsFromSuperclassAndInterfaces(signatures, methodList,
+ implementz[i]);
+ }
+ }
+ }
+
+ private void addNewMethods(Set signatures, List methodList,
+ JavaMethod[] methods) {
+ for (int i = 0; i < methods.length; i++) {
+ JavaMethod method = methods[i];
+
+ if (!method.isPrivate()) {
+ String signature = method.getDeclarationSignature(false);
+
+ if (!signatures.contains(signature)) {
+ methodList.add( new JavaMethodDelegate( this, method ) );
+ signatures.add(signature);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param name method name
+ * @param parameterTypes parameter types or null if there are no parameters.
+ * @return the matching method or null if no match is found.
+ */
+ public JavaMethod getMethodBySignature(String name, Type[] parameterTypes) {
+ return getMethod( name, parameterTypes, false );
+ }
+
+ /**
+ * This should be the signature for getMethodBySignature
+ *
+ * @param name
+ * @param parameterTypes
+ * @param varArgs
+ * @return
+ */
+ public JavaMethod getMethod(String name, Type[] parameterTypes, boolean varArgs) {
+ JavaMethod[] methods = getMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].signatureMatches(name, parameterTypes, varArgs)) {
+ return methods[i];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param name
+ * @param parameterTypes
+ * @param superclasses
+ * @return
+ */
+ public JavaMethod getMethodBySignature(String name, Type[] parameterTypes,
+ boolean superclasses) {
+ return getMethodBySignature( name, parameterTypes, superclasses, false );
+ }
+
+ /**
+ *
+ * @param name
+ * @param parameterTypes
+ * @param superclasses
+ * @param varArg
+ * @return
+ */
+ public JavaMethod getMethodBySignature(String name, Type[] parameterTypes,
+ boolean superclasses, boolean varArg) {
+
+ JavaMethod[] result = getMethodsBySignature(name, parameterTypes,
+ superclasses, varArg);
+
+ return (result.length > 0) ? result[0] : null;
+ }
+
+ /**
+ *
+ * @param name
+ * @param parameterTypes
+ * @param superclasses
+ * @return
+ */
+ public JavaMethod[] getMethodsBySignature(String name,
+ Type[] parameterTypes, boolean superclasses) {
+ return getMethodsBySignature( name, parameterTypes, superclasses, false );
+ }
+
+ /**
+ *
+ * @param name
+ * @param parameterTypes
+ * @param superclasses
+ * @param varArg
+ * @return
+ */
+ public JavaMethod[] getMethodsBySignature(String name,
+ Type[] parameterTypes, boolean superclasses, boolean varArg) {
+ List result = new ArrayList();
+
+ JavaMethod methodInThisClass = getMethod(name, parameterTypes, varArg);
+
+ if (methodInThisClass != null) {
+ result.add(methodInThisClass);
+ }
+
+ if (superclasses) {
+ JavaClass superclass = getSuperJavaClass();
+
+ if (superclass != null) {
+ JavaMethod method = superclass.getMethodBySignature(name,
+ parameterTypes, true, varArg );
+
+ // todo: ideally we should check on package privacy too. oh well.
+ if ((method != null) && !method.isPrivate()) {
+ result.add( new JavaMethodDelegate( this, method ) );
+ }
+ }
+
+ JavaClass[] implementz = getImplementedInterfaces();
+
+ for (int i = 0; i < implementz.length; i++) {
+ JavaMethod method = implementz[i].getMethodBySignature(name,
+ parameterTypes, true, varArg );
+
+ if (method != null) {
+ result.add( new JavaMethodDelegate( this, method ) );
+ }
+ }
+ }
+
+ return (JavaMethod[]) result.toArray(new JavaMethod[result.size()]);
+ }
+
+ public JavaField[] getFields() {
+ if (fieldsArray == null) {
+ fieldsArray = new JavaField[fields.size()];
+ fields.toArray(fieldsArray);
+ }
+
+ return fieldsArray;
+ }
+
+ public JavaField getFieldByName(String name) {
+ JavaField[] fields = getFields();
+
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].getName().equals(name)) {
+ return fields[i];
+ }
+ }
+
+ return null;
+ }
+
+ public void addClass(JavaClass cls) {
+ cls.setParentClass( this );
+ classes.add(cls);
+ classesArray = null;
+ }
+
+ /**
+ * @deprecated Use {@link #getNestedClasses()} instead.
+ */
+ public JavaClass[] getClasses() {
+ return getNestedClasses();
+ }
+
+ /**
+ * @since 1.3
+ */
+ public JavaClass[] getNestedClasses() {
+ if (classesArray == null) {
+ classesArray = new JavaClass[classes.size()];
+ classes.toArray(classesArray);
+ }
+
+ return classesArray;
+ }
+
+ public JavaClass getNestedClassByName(String name) {
+ JavaClass[] classes = getNestedClasses();
+
+ int separatorIndex = name.indexOf('.');
+ String directInnerClassName = (separatorIndex > 0 ? name.substring(0, separatorIndex) : name);
+ for (int i = 0; i < classes.length; i++) {
+ JavaClass jClass = classes[i];
+ if (jClass.getName().equals(directInnerClassName)) {
+ if(separatorIndex > 0) {
+ return jClass.getNestedClassByName(name.substring(separatorIndex+1));
+ }
+ else {
+ return jClass;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @deprecated old name for {@link #getNestedClasses()}
+ */
+ public JavaClass[] getInnerClasses() {
+ return getNestedClasses();
+ }
+
+ /**
+ * @deprecated old name for {@link #getNestedClassByName(String)}
+ */
+ public JavaClass getInnerClassByName(String name) {
+ return getNestedClassByName(name);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean isA(String fullClassName) {
+ Type type = new Type(fullClassName, 0, this);
+ return asType().isA(type);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean isA(JavaClass javaClass) {
+ return asType().isA(javaClass.asType());
+ }
+
+ /**
+ * Gets bean properties without looking in superclasses or interfaces.
+ *
+ * @since 1.3
+ */
+ public BeanProperty[] getBeanProperties() {
+ return getBeanProperties(false);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public BeanProperty[] getBeanProperties(boolean superclasses) {
+ Map beanPropertyMap = getBeanPropertyMap(superclasses);
+ Collection beanPropertyCollection = beanPropertyMap.values();
+
+ return (BeanProperty[]) beanPropertyCollection.toArray(new BeanProperty[beanPropertyCollection
+ .size()]);
+ }
+
+ private Map getBeanPropertyMap(boolean superclasses) {
+ JavaMethod[] methods = getMethods(superclasses);
+ Map beanPropertyMap = new OrderedMap();
+
+ // loop over the methods.
+ for (int i = 0; i < methods.length; i++) {
+ JavaMethod method = methods[i];
+
+ if (method.isPropertyAccessor()) {
+ String propertyName = method.getPropertyName();
+ BeanProperty beanProperty = getOrCreateProperty(beanPropertyMap,
+ propertyName);
+
+ beanProperty.setAccessor(method);
+ beanProperty.setType(method.getPropertyType());
+ } else if (method.isPropertyMutator()) {
+ String propertyName = method.getPropertyName();
+ BeanProperty beanProperty = getOrCreateProperty(beanPropertyMap,
+ propertyName);
+
+ beanProperty.setMutator(method);
+ beanProperty.setType(method.getPropertyType());
+ }
+ }
+
+ return beanPropertyMap;
+ }
+
+ private BeanProperty getOrCreateProperty(Map beanPropertyMap,
+ String propertyName) {
+ BeanProperty result = (BeanProperty) beanPropertyMap.get(propertyName);
+
+ if (result == null) {
+ result = new BeanProperty(propertyName);
+ beanPropertyMap.put(propertyName, result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets bean property without looking in superclasses or interfaces.
+ *
+ * @since 1.3
+ */
+ public BeanProperty getBeanProperty(String propertyName) {
+ return getBeanProperty(propertyName, false);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public BeanProperty getBeanProperty(String propertyName,
+ boolean superclasses) {
+ return (BeanProperty) getBeanPropertyMap(superclasses).get(propertyName);
+ }
+
+ /**
+ * Gets the known derived classes. That is, subclasses or implementing classes.
+ */
+ public JavaClass[] getDerivedClasses() {
+ List result = new ArrayList();
+ JavaClass[] classes = context.getClasses();
+
+ for (int i = 0; i < classes.length; i++) {
+ JavaClass clazz = classes[i];
+
+ if (clazz.isA(this) && !(clazz == this)) {
+ result.add(clazz);
+ }
+ }
+
+ return (JavaClass[]) result.toArray(new JavaClass[result.size()]);
+ }
+
+ public DocletTag[] getTagsByName(String name, boolean superclasses) {
+ List result = new ArrayList();
+
+ addTagsRecursive(result, this, name, superclasses);
+
+ return (DocletTag[]) result.toArray(new DocletTag[result.size()]);
+ }
+
+ private void addTagsRecursive(List result, JavaClass javaClass,
+ String name, boolean superclasses) {
+ DocletTag[] tags = javaClass.getTagsByName(name);
+
+ addNewTags(result, tags);
+
+ if (superclasses) {
+ JavaClass superclass = javaClass.getSuperJavaClass();
+
+ // THIS IS A HACK AROUND A BUG THAT MUST BE SOLVED!!!
+ // SOMETIMES A CLASS RETURNS ITSELF AS SUPER ?!?!?!?!?!
+ if ((superclass != null) && (superclass != javaClass)) {
+ addTagsRecursive(result, superclass, name, superclasses);
+ }
+
+ JavaClass[] implementz = javaClass.getImplementedInterfaces();
+
+ for (int h = 0; h < implementz.length; h++) {
+ if (implementz[h] != null) {
+ addTagsRecursive(result, implementz[h], name, superclasses);
+ }
+ }
+ }
+ }
+
+ private void addNewTags(List list, DocletTag[] tags) {
+ for (int i = 0; i < tags.length; i++) {
+ DocletTag superTag = tags[i];
+
+ if (!list.contains(superTag)) {
+ list.add(superTag);
+ }
+ }
+ }
+
+ public int compareTo(Object o) {
+ return getFullyQualifiedName().compareTo(((JavaClass) o).getFullyQualifiedName());
+ }
+
+ /**
+ * @see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#toString()
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(asType().isPrimitive() || (Type.VOID.equals(asType()))) {
+ sb.append(asType().getValue());
+ }
+ else {
+ sb.append(isInterface() ? "interface" : "class");
+ sb.append(" ");
+ sb.append(getFullyQualifiedName());
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaClassCache.java b/src/java/com/thoughtworks/qdox/model/JavaClassCache.java
new file mode 100644
index 0000000..e4657e5
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaClassCache.java
@@ -0,0 +1,9 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+
+public interface JavaClassCache extends Serializable {
+ public JavaClass[] getClasses();
+ public JavaClass getClassByName(String name);
+ public void putClassByName(String name, JavaClass javaClass);
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaClassParent.java b/src/java/com/thoughtworks/qdox/model/JavaClassParent.java
new file mode 100644
index 0000000..fb4eaf7
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaClassParent.java
@@ -0,0 +1,25 @@
+package com.thoughtworks.qdox.model;
+
+import com.thoughtworks.qdox.JavaClassContext;
+
+public interface JavaClassParent {
+
+ /**
+ * Resolve a type-name within the context of this source or class.
+ * @param typeName name of a type
+ * @return the fully-qualified name of the type, or null if it cannot
+ * be resolved
+ */
+ public String resolveType(String typeName);
+
+ public JavaClassContext getJavaClassContext();
+
+ public String getClassNamePrefix();
+
+ public JavaSource getParentSource();
+
+ public void addClass(JavaClass cls);
+
+ public JavaClass getNestedClassByName(String name);
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaField.java b/src/java/com/thoughtworks/qdox/model/JavaField.java
new file mode 100644
index 0000000..16d7bf4
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaField.java
@@ -0,0 +1,103 @@
+package com.thoughtworks.qdox.model;
+
+public class JavaField extends AbstractJavaEntity implements Member {
+
+ private Type type;
+ private String initializationExpression;
+
+ public JavaField() {
+ }
+
+ public JavaField(String name) {
+ setName(name);
+ }
+
+ public JavaField(Type type, String name) {
+ setType(type);
+ setName(name);
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ protected void writeBody(IndentBuffer result) {
+ writeAllModifiers(result);
+ result.write(type.toString());
+ result.write(' ');
+ result.write(name);
+ if(initializationExpression != null && initializationExpression.length() > 0){
+ result.write(" = ");
+ result.write(initializationExpression);
+ }
+ result.write(';');
+ result.newline();
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public int compareTo(Object o) {
+ return getName().compareTo(((JavaField)o).getName());
+ }
+
+ public String getDeclarationSignature(boolean withModifiers) {
+ IndentBuffer result = new IndentBuffer();
+ if (withModifiers) {
+ writeAllModifiers(result);
+ }
+ result.write(type.toString());
+ result.write(' ');
+ result.write(name);
+ return result.toString();
+ }
+
+ public String getCallSignature() {
+ return getName();
+ }
+
+ /**
+ * Get the original expression used to initialize the field.
+ *
+ * @return initialization as string.
+ */
+ public String getInitializationExpression(){
+ return initializationExpression;
+ }
+
+ public void setInitializationExpression(String initializationExpression){
+ this.initializationExpression = initializationExpression;
+ }
+
+ /**
+ * @see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Field.html#toString()
+ */
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ if(isPrivate()) {
+ result.append("private ");
+ }
+ else if(isProtected()) {
+ result.append("protected ");
+ }
+ else if(isPublic()) {
+ result.append("public ");
+ }
+ if(isStatic()) {
+ result.append("static ");
+ }
+ if(isFinal()) {
+ result.append("final ");
+ }
+ if(isTransient()) {
+ result.append("transient ");
+ }
+ if(isVolatile()) {
+ result.append("volatile ");
+ }
+ result.append(getType().getValue() + " ");
+ result.append(getParentClass().getFullyQualifiedName() + "." +getName());
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaMethod.java b/src/java/com/thoughtworks/qdox/model/JavaMethod.java
new file mode 100644
index 0000000..aa777ae
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaMethod.java
@@ -0,0 +1,543 @@
+package com.thoughtworks.qdox.model;
+
+import java.beans.Introspector;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+public class JavaMethod extends AbstractInheritableJavaEntity implements Member {
+
+ private TypeVariable[] typeParameters = TypeVariable.EMPTY_ARRAY;
+ private Type returns = Type.VOID;
+ private List parameters = new LinkedList();
+ private JavaParameter[] parametersArray = JavaParameter.EMPTY_ARRAY;
+ private Type[] exceptions = Type.EMPTY_ARRAY;
+ private boolean constructor;
+ private String sourceCode;
+ private boolean varArgs;
+
+ /**
+ * The default constructor
+ */
+ public JavaMethod() {
+ }
+
+ /**
+ * Create new method without parameters and return type
+ *
+ * @param name the name of the method
+ */
+ public JavaMethod(String name) {
+ setName(name);
+ }
+
+ /**
+ * Create a new method without parameters
+ *
+ * @param returns the return type
+ * @param name the name of this method
+ */
+ public JavaMethod(Type returns, String name) {
+ setReturns(returns);
+ setName(name);
+ }
+
+ /**
+ *
+ * @return the return type
+ * @deprecated it is recommended to use getReturnType()
+ */
+ public Type getReturns() {
+ return returns;
+ }
+
+ public JavaParameter[] getParameters() {
+ if(parametersArray == null) {
+ parametersArray = new JavaParameter[parameters.size()];
+ parameters.toArray( parametersArray );
+ }
+ return parametersArray;
+ }
+
+ public JavaParameter getParameterByName(String name) {
+ JavaParameter[] parameters = getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ if (parameters[i].getName().equals(name)) {
+ return parameters[i];
+ }
+ }
+ return null;
+ }
+
+ public Type[] getExceptions() {
+ return exceptions;
+ }
+
+ /**
+ *
+ * @return true is this method is a constructor
+ */
+ public boolean isConstructor() {
+ return constructor;
+ }
+
+ /**
+ *
+ * @return true is this method conains varArgs
+ */
+ public boolean isVarArgs()
+ {
+ return varArgs;
+ }
+
+ protected void writeBody(IndentBuffer result) {
+ writeBody(result, true, true, true);
+ }
+
+ /**
+ * @since 1.3
+ */
+ protected void writeBody(IndentBuffer result, boolean withModifiers, boolean isDeclaration, boolean isPrettyPrint) {
+ if (withModifiers) {
+ writeAccessibilityModifier(result);
+ writeNonAccessibilityModifiers(result);
+ }
+
+ if (!constructor) {
+ if(isDeclaration) {
+ result.write(returns.toString());
+ result.write(' ');
+ }
+ }
+
+ result.write(name);
+ result.write('(');
+ for (int i = 0; i < getParameters().length; i++) {
+ JavaParameter parameter = parametersArray[i];
+ if (i > 0) result.write(", ");
+ if (isDeclaration) {
+ result.write(parameter.getType().toString());
+ if (parameter.isVarArgs()) {
+ result.write("...");
+ }
+ result.write(' ');
+ }
+ result.write(parameter.getName());
+ }
+ result.write(')');
+ if (isDeclaration && exceptions.length > 0) {
+ result.write(" throws ");
+ for (int i = 0; i < exceptions.length; i++) {
+ if (i > 0) result.write(", ");
+ result.write(exceptions[i].getValue());
+ }
+ }
+ if (isPrettyPrint) {
+ if (sourceCode != null && sourceCode.length() > 0) {
+ result.write(" {");
+ result.newline();
+ result.write(sourceCode);
+ result.write("}");
+ result.newline();
+ } else {
+ result.write(';');
+ result.newline();
+ }
+ }
+ }
+
+ /**
+ * @since 1.3
+ */
+ private String getSignature(boolean withModifiers, boolean isDeclaration) {
+ IndentBuffer result = new IndentBuffer();
+ writeBody(result, withModifiers, isDeclaration, false);
+ return result.toString();
+ }
+
+ /**
+ * @since 1.3
+ */
+ public String getDeclarationSignature(boolean withModifiers) {
+ return getSignature(withModifiers, true);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public String getCallSignature() {
+ return getSignature(false, false);
+ }
+
+ /**
+ * Define the return type of this method
+ *
+ * @param returns the return type
+ */
+ public void setReturns(Type returns) {
+ this.returns = returns;
+ }
+
+ public void addParameter(JavaParameter javaParameter) {
+ javaParameter.setParentMethod( this );
+ parameters.add( javaParameter );
+ parametersArray = null;
+ this.varArgs = javaParameter.isVarArgs();
+ }
+
+ public void setExceptions(Type[] exceptions) {
+ this.exceptions = exceptions;
+ }
+
+ public void setConstructor(boolean constructor) {
+ this.constructor = constructor;
+ }
+
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( !( obj instanceof JavaMethod ) )
+ {
+ return false;
+ }
+ JavaMethod m = (JavaMethod) obj;
+
+ if (m.isConstructor() != isConstructor())
+ {
+ return false;
+ }
+
+ if ( m.getName() != null && !m.getName().equals( this.getName() ) )
+ {
+ return false;
+ }
+ if ( this.getName() != null && !this.getName().equals( m.getName() ) )
+ {
+ return false;
+ }
+
+ if ( m.getReturns() != null && !m.getReturns().equals( this.getReturns() ) )
+ {
+ return false;
+ }
+ if ( this.getReturns() != null && !this.getReturns().equals( m.getReturns() ) )
+ {
+ return false;
+ }
+
+ JavaParameter[] myParams = getParameters();
+ JavaParameter[] otherParams = m.getParameters();
+ if (otherParams.length != myParams.length) return false;
+ for (int i = 0; i < myParams.length; i++) {
+ if (!otherParams[i].equals(myParams[i])) return false;
+ }
+
+ return this.varArgs == m.varArgs;
+ }
+
+ /**
+ * This method is NOT varArg aware. The overloaded method is.
+ *
+ * @param name
+ * @param parameterTypes
+ * @return
+ * @deprecated use overloaded method
+ */
+ public boolean signatureMatches(String name, Type[] parameterTypes) {
+ return signatureMatches( name, parameterTypes, false );
+ }
+
+ /**
+ * @param name method name
+ * @param parameterTypes parameter types or null if there are no parameters.
+ * @return true if the signature and parameters match.
+ */
+ public boolean signatureMatches(String name, Type[] parameterTypes, boolean varArg) {
+ if (!name.equals(this.name)) return false;
+ parameterTypes = (parameterTypes == null ? new Type[0] : parameterTypes);
+ if (parameterTypes.length != this.getParameters().length) return false;
+ for (int i = 0; i < parametersArray.length; i++) {
+ if (!parametersArray[i].getType().equals(parameterTypes[i])) {
+ return false;
+ }
+ }
+ return (this.varArgs == varArg);
+ }
+
+ public int hashCode() {
+ int hashCode = name.hashCode();
+ if (returns != null) hashCode *= returns.hashCode();
+ hashCode *= getParameters().length;
+ return hashCode;
+ }
+
+ public boolean isPublic() {
+ return super.isPublic() || (getParentClass() != null ? getParentClass().isInterface() : false);
+ }
+
+ /**
+ * @return true if this method is a Java Bean accessor
+ * @since 1.3
+ */
+ public boolean isPropertyAccessor() {
+ if (isStatic()) return false;
+ if (getParameters().length != 0) return false;
+
+ if (getName().startsWith("is")) {
+ return (getName().length() > 2
+ && Character.isUpperCase(getName().charAt(2)));
+ }
+ if (getName().startsWith("get")) {
+ return (getName().length() > 3
+ && Character.isUpperCase(getName().charAt(3)));
+ }
+
+ return false;
+ }
+
+ /**
+ * @return true if this method is a Java Bean accessor
+ * @since 1.3
+ */
+ public boolean isPropertyMutator() {
+ if (isStatic()) return false;
+ if (getParameters().length != 1) return false;
+
+ if (getName().startsWith("set")) {
+ return (getName().length() > 3
+ && Character.isUpperCase(getName().charAt(3)));
+ }
+
+ return false;
+ }
+
+ /**
+ * @return the type of the property this method represents, or null if this method
+ * is not a property mutator or property accessor.
+ * @since 1.3
+ */
+ public Type getPropertyType() {
+ if (isPropertyAccessor()) {
+ return getReturns();
+ }
+ if (isPropertyMutator()) {
+ return getParameters()[0].getType();
+ }
+ return null;
+ }
+
+ /**
+ * @return the name of the property this method represents, or null if this method
+ * is not a property mutator or property accessor.
+ * @since 1.3
+ */
+ public String getPropertyName() {
+ int start = -1;
+ if (getName().startsWith("get") || getName().startsWith("set")) {
+ start = 3;
+ } else if (getName().startsWith("is")) {
+ start = 2;
+ } else {
+ return null;
+ }
+ return Introspector.decapitalize(getName().substring(start));
+ }
+
+ public DocletTag[] getTagsByName(String name, boolean inherited) {
+ JavaClass clazz = getParentClass();
+ JavaParameter[] params = getParameters();
+ Type[] types = new Type[params.length];
+ for (int i = 0; i < types.length; i++) {
+ types[i] = params[i].getType();
+ }
+ JavaMethod[] methods = clazz.getMethodsBySignature(getName(), types, true);
+
+ List result = new ArrayList();
+ for (int i = 0; i < methods.length; i++) {
+ JavaMethod method = methods[i];
+ DocletTag[] tags = method.getTagsByName(name);
+ for (int j = 0; j < tags.length; j++) {
+ DocletTag tag = tags[j];
+ if(!result.contains(tag)) {
+ result.add(tag);
+ }
+ }
+ }
+ return (DocletTag[]) result.toArray(new DocletTag[result.size()]);
+ }
+
+ public int compareTo(Object o) {
+ return getDeclarationSignature(false).compareTo(((JavaMethod)o).getDeclarationSignature(false));
+ }
+
+ /**
+ * Get the original source code of the body of this method.
+ *
+ * @return Code as string.
+ */
+ public String getSourceCode(){
+ return sourceCode;
+ }
+
+ public void setSourceCode(String sourceCode){
+ this.sourceCode = sourceCode;
+ }
+
+ public void setTypeParameters(TypeVariable[] typeParameters) {
+ this.typeParameters = typeParameters;
+ }
+
+ public TypeVariable[] getTypeParameters() {
+ return typeParameters;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ if(isPrivate()) {
+ result.append("private ");
+ }
+ else if(isProtected()) {
+ result.append("protected ");
+ }
+ else if(isPublic()) {
+ result.append("public ");
+ }
+ if(isAbstract()) {
+ result.append("abstract ");
+ }
+ if(isStatic()) {
+ result.append("static ");
+ }
+ if(isFinal()) {
+ result.append("final ");
+ }
+ if(isSynchronized()) {
+ result.append("synchronized ");
+ }
+ if(isNative()) {
+ result.append("native ");
+ }
+ if (!constructor) {
+ result.append(getReturns().getValue() + " ");
+ }
+ if(getParentClass() != null) {
+ result.append(getParentClass().getFullyQualifiedName());
+ if (!constructor) {
+ result.append(".");
+ }
+ }
+ if (!constructor) {
+ result.append(getName());
+ }
+ result.append("(");
+ for(int paramIndex=0;paramIndex<getParameters().length;paramIndex++) {
+ if(paramIndex>0) {
+ result.append(",");
+ }
+ String typeValue = getParameters()[paramIndex].getType().getResolvedValue(getTypeParameters());
+ result.append(typeValue);
+ }
+ result.append(")");
+ for(int i = 0; i < exceptions.length; i++) {
+ result.append(i==0 ? " throws " : ",");
+ result.append(exceptions[i].getValue());
+ }
+ return result.toString();
+ }
+
+ /**
+ * Equivalent of java.lang.reflect.Method.getGenericReturnType()
+ *
+ * @return the generic returntype
+ * @since 1.12
+ */
+ public Type getGenericReturnType()
+ {
+ return returns;
+ }
+
+ /**
+ * Equivalent of java.lang.reflect.Method.getReturnType()
+ *
+ * @return
+ * @since 1.12
+ */
+ public Type getReturnType() {
+ return getReturnType( false );
+ }
+
+ /**
+ * If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
+ *
+ * @param resolve
+ * @return
+ * @since 1.12
+ */
+ public Type getReturnType( boolean resolve )
+ {
+ return getReturnType( resolve, getParentClass() );
+ }
+
+ /**
+ *
+ * @param resolve
+ * @param callingClass
+ * @return
+ * @since 1.12
+ */
+ protected Type getReturnType ( boolean resolve, JavaClass callingClass) {
+ Type result = null;
+ if (getReturns() != null) {
+ result = getReturns().resolve( this.getParentClass(), callingClass );
+
+ //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned
+ if ( !resolve && !returns.getFullyQualifiedName().equals( result.getFullyQualifiedName() ) )
+ {
+ result = new Type( "java.lang.Object" );
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @return the parameter types as array
+ * @since 1.12
+ */
+ public Type[] getParameterTypes() {
+ return getParameterTypes( false );
+ }
+
+ /**
+ * If a class inherits this method from a generic class or interface, you can use this method to get the resolved parameter types
+ *
+ * @param resolve
+ * @return the parameter types as array
+ * @since 1.12
+ */
+ public Type[] getParameterTypes( boolean resolve ) {
+ return getParameterTypes( resolve, getParentClass() );
+ }
+
+
+ protected Type[] getParameterTypes ( boolean resolve, JavaClass callingClass) {
+ Type[] result = new Type[getParameters().length];
+
+ for (int paramIndex = 0; paramIndex < getParameters().length; paramIndex++ )
+ {
+ Type curType = getParameters()[paramIndex].getType().resolve( this.getParentClass(), callingClass );
+ //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned
+ if ( !resolve && returns != null && !returns.getFullyQualifiedName().equals( curType.getFullyQualifiedName() ) )
+ {
+ result[paramIndex] = new Type( "java.lang.Object" );
+ }
+ else {
+ result[paramIndex] = curType;
+ }
+
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/JavaMethodDelegate.java b/src/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
similarity index 54%
rename from src/main/java/com/thoughtworks/qdox/model/impl/JavaMethodDelegate.java
rename to src/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
index 2ac1415..22bcc6a 100644
--- a/src/main/java/com/thoughtworks/qdox/model/impl/JavaMethodDelegate.java
+++ b/src/java/com/thoughtworks/qdox/model/JavaMethodDelegate.java
@@ -1,36 +1,7 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
+package com.thoughtworks.qdox.model;
-import java.util.LinkedList;
import java.util.List;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-
/**
* This class can be used to access overridden methods while keeping a reference to the original class.
* This is especially useful when trying to resolve generics
@@ -38,7 +9,7 @@ import com.thoughtworks.qdox.model.JavaTypeVariable;
* @author Robert Scholte
* @since 1.12
*/
-public class JavaMethodDelegate implements JavaMethod
+public class JavaMethodDelegate extends JavaMethod
{
private JavaClass callingClass;
@@ -50,50 +21,52 @@ public class JavaMethodDelegate implements JavaMethod
this.originalMethod = originalMethod;
}
- public JavaType getReturnType( boolean resolve )
- {
- JavaType result = originalMethod.getReturnType( resolve );
-
- if (result != null) {
- result = DefaultJavaType.resolve( result, originalMethod.getParentClass(), callingClass );
-
- //According to java-specs, if it could be resolved the upper boundary, so Object, should be returned
- if ( !resolve && !this.getReturns().getFullyQualifiedName().equals( result.getFullyQualifiedName() ) )
- {
- result = new DefaultJavaType( "java.lang.Object", 0, callingClass );
- }
- }
-
- return result;
+ public Type getReturnType( boolean resolve )
+ {
+ Type returnType = originalMethod.getReturnType( resolve, callingClass );
+ return returnType.resolve( originalMethod.getParentClass(), callingClass );
}
- /** {@inheritDoc} */
- public List<JavaType> getParameterTypes( boolean resolve )
+ protected Type getReturnType( boolean resolve, JavaClass _callingClass )
{
- List<JavaType> result = new LinkedList<JavaType>();
- for ( JavaType type : originalMethod.getParameterTypes( resolve ) )
+ //watch it!! use callingclass of constructor
+ return super.getReturnType( resolve, this.callingClass );
+ }
+
+ public Type[] getParameterTypes( boolean resolve )
+ {
+ Type[] parameterTypes = originalMethod.getParameterTypes( resolve, callingClass );
+ for ( int paramIndex = 0; paramIndex < parameterTypes.length; paramIndex++ )
{
- JavaType curType = DefaultJavaType.resolve( type, originalMethod.getParentClass(), callingClass );
- // According to java-specs, if it could be resolved the upper boundary, so Object, should be returned
- if ( !resolve && !type.getFullyQualifiedName().equals( curType.getFullyQualifiedName() ) )
- {
- result.add( new DefaultJavaType( "java.lang.Object", 0, callingClass ) );
- }
- else
- {
- result.add( curType );
- }
-
+ parameterTypes[paramIndex] = parameterTypes[paramIndex].resolve( originalMethod.getParentClass(), callingClass );
}
- return result;
+ return parameterTypes;
+ }
+
+ protected Type[] getParameterTypes( boolean resolve, JavaClass _callingClass )
+ {
+ //watch it!! use callingclass of constructor
+ return super.getParameterTypes( resolve, this.callingClass );
}
+ //Delegating methods
+
+ public void addParameter( JavaParameter javaParameter )
+ {
+ originalMethod.addParameter( javaParameter );
+ }
+
+ public int compareTo( Object o )
+ {
+ return originalMethod.compareTo( o );
+ }
+
public boolean equals( Object obj )
{
return originalMethod.equals( obj );
}
- public List<JavaAnnotation> getAnnotations()
+ public Annotation[] getAnnotations()
{
return originalMethod.getAnnotations();
}
@@ -113,28 +86,19 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.getComment();
}
- public JavaClass getDeclaringClass() {
- return originalMethod.getDeclaringClass();
- }
-
public String getDeclarationSignature( boolean withModifiers )
{
return originalMethod.getDeclarationSignature( withModifiers );
}
- public List<JavaClass> getExceptions()
+ public Type[] getExceptions()
{
return originalMethod.getExceptions();
}
-
- public List<JavaType> getExceptionTypes()
- {
- return originalMethod.getExceptionTypes();
- }
-
- public boolean isDefault()
+
+ public Type getGenericReturnType()
{
- return originalMethod.isDefault();
+ return originalMethod.getGenericReturnType();
}
public int getLineNumber()
@@ -142,7 +106,7 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.getLineNumber();
}
- public List<String> getModifiers()
+ public String[] getModifiers()
{
return originalMethod.getModifiers();
}
@@ -162,26 +126,46 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.getParameterByName( name );
}
- public List<JavaParameter> getParameters()
+ public JavaParameter[] getParameters()
{
return originalMethod.getParameters();
}
+ public Type[] getParameterTypes()
+ {
+ return originalMethod.getParameterTypes();
+ }
+
+ public JavaClassParent getParent()
+ {
+ return originalMethod.getParent();
+ }
+
+ public JavaClass getParentClass()
+ {
+ return originalMethod.getParentClass();
+ }
+
public String getPropertyName()
{
return originalMethod.getPropertyName();
}
- public JavaType getPropertyType()
+ public Type getPropertyType()
{
return originalMethod.getPropertyType();
}
- public JavaClass getReturns()
+ public Type getReturns()
{
return originalMethod.getReturns();
}
+ public Type getReturnType()
+ {
+ return getReturnType( false );
+ }
+
public JavaSource getSource()
{
return originalMethod.getSource();
@@ -202,22 +186,22 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.getTagByName( name );
}
- public List<DocletTag> getTags()
+ public DocletTag[] getTags()
{
return originalMethod.getTags();
}
- public List<DocletTag> getTagsByName( String name, boolean inherited )
+ public DocletTag[] getTagsByName( String name, boolean inherited )
{
return originalMethod.getTagsByName( name, inherited );
}
- public List<DocletTag> getTagsByName( String name )
+ public DocletTag[] getTagsByName( String name )
{
return originalMethod.getTagsByName( name );
}
- public List<JavaTypeVariable<JavaMethod>> getTypeParameters()
+ public TypeVariable[] getTypeParameters()
{
return originalMethod.getTypeParameters();
}
@@ -232,6 +216,11 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.isAbstract();
}
+ public boolean isConstructor()
+ {
+ return originalMethod.isConstructor();
+ }
+
public boolean isFinal()
{
return originalMethod.isFinal();
@@ -297,43 +286,83 @@ public class JavaMethodDelegate implements JavaMethod
return originalMethod.isVolatile();
}
- public boolean signatureMatches( String name, List<JavaType> parameterTypes, boolean varArg )
+ public void setAnnotations( Annotation[] annotations )
{
- return originalMethod.signatureMatches( name, parameterTypes, varArg );
+ originalMethod.setAnnotations( annotations );
}
- public boolean signatureMatches( String name, List<JavaType> parameterTypes )
+ public void setComment( String comment )
{
- return originalMethod.signatureMatches( name, parameterTypes );
+ originalMethod.setComment( comment );
}
- public String toString()
+ public void setConstructor( boolean constructor )
{
- return originalMethod.toString();
+ originalMethod.setConstructor( constructor );
}
- public JavaType getReturnType()
+ public void setExceptions( Type[] exceptions )
{
- return getReturnType( false );
+ originalMethod.setExceptions( exceptions );
}
- public List<JavaType> getParameterTypes()
+ public void setLineNumber( int lineNumber )
{
- return getParameterTypes( false );
+ originalMethod.setLineNumber( lineNumber );
}
-
- // deprecated methods
- // will be removed with QDox-2.0
- public JavaClass getParentClass()
+
+ public void setModifiers( String[] modifiers )
{
- return originalMethod.getParentClass();
+ originalMethod.setModifiers( modifiers );
}
- public JavaClass getGenericReturnType()
+ public void setName( String name )
{
- return originalMethod.getGenericReturnType();
+ originalMethod.setName( name );
+ }
+
+ public void setParent( JavaClassParent parent )
+ {
+ originalMethod.setParent( parent );
}
+ public void setParentClass( JavaClass parentClass )
+ {
+ originalMethod.setParentClass( parentClass );
+ }
+ public void setReturns( Type returns )
+ {
+ originalMethod.setReturns( returns );
+ }
+ public void setSourceCode( String sourceCode )
+ {
+ originalMethod.setSourceCode( sourceCode );
+ }
+
+ public void setTags( List tagList )
+ {
+ originalMethod.setTags( tagList );
+ }
+
+ public void setTypeParameters( TypeVariable[] typeParameters )
+ {
+ originalMethod.setTypeParameters( typeParameters );
+ }
+
+ public boolean signatureMatches( String name, Type[] parameterTypes, boolean varArg )
+ {
+ return originalMethod.signatureMatches( name, parameterTypes, varArg );
+ }
+
+ public boolean signatureMatches( String name, Type[] parameterTypes )
+ {
+ return originalMethod.signatureMatches( name, parameterTypes );
+ }
+
+ public String toString()
+ {
+ return originalMethod.toString();
+ }
}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaPackage.java b/src/java/com/thoughtworks/qdox/model/JavaPackage.java
new file mode 100644
index 0000000..366ee20
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaPackage.java
@@ -0,0 +1,126 @@
+package com.thoughtworks.qdox.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.thoughtworks.qdox.JavaClassContext;
+
+/**
+ * A representation of a package.
+ * @since 1.9
+ */
+public class JavaPackage extends AbstractBaseJavaEntity {
+
+ private JavaClassContext context;
+ private String name;
+ private Annotation[] annotations = new Annotation[0];
+ private int lineNumber = -1;
+ private List classes = new ArrayList();
+
+ public JavaPackage() {
+ }
+
+ public JavaPackage(String name) {
+ this(name, null);
+ }
+
+ /**
+ *
+ * @param name
+ * @param allPackages
+ * @deprecated allPackages is solved with the context
+ */
+ public JavaPackage(String name, Map allPackages) {
+ this.name= name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Annotation[] getAnnotations() {
+ return annotations;
+ }
+
+ public void setAnnotations(Annotation[] annotations) {
+ this.annotations = annotations;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ public void setContext( JavaClassContext context )
+ {
+ this.context = context;
+ }
+
+ public void addClass(JavaClass clazz) {
+ clazz.setJavaPackage(this);
+ classes.add(clazz);
+ }
+
+ /**
+ * Returns all the classes found for the package.
+ *
+ * @return all the classes found for the package
+ */
+ public JavaClass[] getClasses() {
+ //avoid infinitive recursion
+ if (this == context.getPackageByName( name )) {
+ return (JavaClass[]) classes.toArray(new JavaClass[classes.size()]);
+ }
+ else {
+ return context.getPackageByName( name ).getClasses();
+ }
+ }
+
+ public JavaPackage getParentPackage() {
+ String parentName = name.substring(0,name.lastIndexOf("."));
+ return (JavaPackage) context.getPackageByName( parentName );
+ }
+
+ public JavaPackage[] getSubPackages() {
+ String expected = name + ".";
+ JavaPackage[] jPackages = context.getPackages();
+ List retList = new ArrayList();
+ for (int index = 0; index < jPackages.length;index++) {
+ String pName = jPackages[index].getName();
+ if (pName.startsWith(expected) && !(pName.substring(expected.length()).indexOf(".") > -1)) {
+ retList.add(context.getPackageByName( pName ));
+ }
+ }
+ return (JavaPackage[]) retList.toArray(new JavaPackage[retList.size()]);
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ JavaPackage that = (JavaPackage) o;
+
+ if (!name.equals(that.name)) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ /**
+ * @see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html#toString()
+ */
+ public String toString() {
+ return "package " + name;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaParameter.java b/src/java/com/thoughtworks/qdox/model/JavaParameter.java
new file mode 100644
index 0000000..344abcf
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaParameter.java
@@ -0,0 +1,82 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+
+public class JavaParameter extends AbstractBaseJavaEntity implements Serializable {
+
+ public static final JavaParameter[]
+ EMPTY_ARRAY = new JavaParameter[0];
+
+ private String name;
+ private Type type;
+ private JavaMethod parentMethod;
+ private boolean varArgs;
+
+ public JavaParameter(Type type, String name) {
+ this(type, name, false);
+ }
+
+ public JavaParameter(Type type, String name, boolean varArgs) {
+ this.name = name;
+ this.type = type;
+ this.varArgs = varArgs;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public boolean equals(Object obj) {
+ JavaParameter p = (JavaParameter) obj;
+ // name isn't used in equality check.
+ return getType().equals(p.getType());
+ }
+
+ public int hashCode() {
+ return getType().hashCode();
+ }
+
+ public JavaMethod getParentMethod() {
+ return parentMethod;
+ }
+
+ public void setParentMethod(JavaMethod parentMethod) {
+ this.parentMethod = parentMethod;
+ }
+
+ public JavaClass getParentClass()
+ {
+ return getParentMethod().getParentClass();
+ }
+
+ /**
+ * Is this a Java 5 var args type specified using three dots. e.g. void doStuff(Object... thing)
+ * @since 1.6
+ */
+ public boolean isVarArgs() {
+ return varArgs;
+ }
+
+ public String toString() {
+ return getResolvedValue() + " "+ name;
+ }
+
+ /**
+ *
+ * @return the resolved value if the method has typeParameters, otherwise type's value
+ * @since 1.10
+ */
+ public String getResolvedValue() {
+ return type.getResolvedValue(getParentMethod().getTypeParameters());
+ }
+
+ public String getResolvedGenericValue() {
+ return type.getResolvedGenericValue(getParentMethod().getTypeParameters());
+ }
+
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/JavaSource.java b/src/java/com/thoughtworks/qdox/model/JavaSource.java
new file mode 100644
index 0000000..e2fe76f
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/JavaSource.java
@@ -0,0 +1,346 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.File;
+import java.io.Serializable;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+import com.thoughtworks.qdox.JavaClassContext;
+
+public class JavaSource implements Serializable, JavaClassParent {
+
+ private static final Set PRIMITIVE_TYPES = new HashSet();
+
+ static {
+ PRIMITIVE_TYPES.add("boolean");
+ PRIMITIVE_TYPES.add("byte");
+ PRIMITIVE_TYPES.add("char");
+ PRIMITIVE_TYPES.add("double");
+ PRIMITIVE_TYPES.add("float");
+ PRIMITIVE_TYPES.add("int");
+ PRIMITIVE_TYPES.add("long");
+ PRIMITIVE_TYPES.add("short");
+ PRIMITIVE_TYPES.add("void");
+ }
+
+ private JavaPackage packge;
+ private List imports = new LinkedList();
+ private String[] importsArray;
+ private List classes = new LinkedList();
+ private JavaClass[] classesArray;
+ private JavaClassContext context;
+ private Map resolvedTypeCache = new HashMap();
+ private URL url;
+
+ public JavaSource() {
+ this(new JavaClassContext((ClassLibrary) null));
+ }
+
+ public JavaSource(JavaClassContext context) {
+ this.context = context;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void setURL(URL url) {
+ this.url = url;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public URL getURL() {
+ return url;
+ }
+
+ /**
+ * @deprecated use setURL
+ */
+ public void setFile(File file) {
+ try {
+ setURL(file.toURL());
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException(e.getMessage());
+ }
+ }
+
+ /**
+ * @deprecated use getURL
+ */
+ public File getFile() {
+ return new File(url.getFile());
+ }
+
+ public JavaPackage getPackage() {
+ return packge;
+ }
+
+ public void setPackage(JavaPackage packge) {
+ this.packge = packge;
+ }
+
+ public void addImport(String imp) {
+ imports.add(imp);
+ importsArray = null;
+ }
+
+ public String[] getImports() {
+ if (importsArray == null) {
+ importsArray = new String[imports.size()];
+ imports.toArray(importsArray);
+ }
+ return importsArray;
+ }
+
+ public void addClass(JavaClass cls) {
+ cls.setSource( this );
+ classes.add(cls);
+ classesArray = null;
+ }
+
+ public JavaClass[] getClasses() {
+ if (classesArray == null) {
+ classesArray = new JavaClass[classes.size()];
+ classes.toArray(classesArray);
+ }
+ return classesArray;
+ }
+
+ public JavaClassContext getJavaClassContext() {
+ return this.context;
+ }
+
+ public void setClassLibrary(ClassLibrary classLibrary) {
+ this.context.setClassLibrary(classLibrary);
+ }
+
+ public String getCodeBlock() {
+ IndentBuffer result = new IndentBuffer();
+
+ // package statement
+ if (packge != null) {
+ result.write("package ");
+ result.write(packge.getName());
+ result.write(';');
+ result.newline();
+ result.newline();
+ }
+
+ // import statement
+ String[] imports = getImports();
+ for (int i = 0; imports != null && i < imports.length; i++) {
+ result.write("import ");
+ result.write(imports[i]);
+ result.write(';');
+ result.newline();
+ }
+ if (imports != null && imports.length > 0) {
+ result.newline();
+ }
+
+ // classes
+ JavaClass[] classes = getClasses();
+ for (int i = 0; i < classes.length; i++) {
+ if (i > 0) result.newline();
+ classes[i].write(result);
+ }
+
+ return result.toString();
+ }
+
+ public String toString() {
+ return getCodeBlock();
+ }
+
+ public String resolveType(String typeName) {
+ if (resolvedTypeCache.containsKey(typeName)) {
+ return (String) resolvedTypeCache.get(typeName);
+ }
+ String resolved = resolveTypeInternal(typeName);
+ if (resolved != null) {
+ resolvedTypeCache.put(typeName, resolved);
+ }
+ return resolved;
+ }
+
+ /**
+ * Resolves a type name
+ * <p>
+ * Follows the <a href="http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.1">
+ * Java Language Specification, Version 3.0</a>.
+ * <p>
+ * Current resolution order is:
+ * <ol>
+ * <li>Single-Type-Import Declaration</li>
+ * <li>Type-Import-on-Demand Declaration</li>
+ * <li>Automatic Imports</li>
+ * </ol>
+ * @todo Static imports are not handled yet
+ *
+ * @param typeName
+ * @return Resolved type name
+ */
+ private String resolveTypeInternal(String typeName) {
+ String resolvedName = null;
+
+ lookup : {
+ // primitive types
+ if(PRIMITIVE_TYPES.contains( typeName )) {
+ resolvedName = typeName;
+ break lookup;
+ }
+
+ String outerName = typeName;
+ String nestedName = typeName.replace('.', '$');
+ int dotpos = typeName.indexOf( '.' );
+
+ if(dotpos >= 0) {
+ outerName = typeName.substring( 0, dotpos );
+ }
+
+ // Check single-type-import with fully qualified name
+ resolvedName = resolveImportedType( typeName, nestedName, true );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+
+ // Check single-type-import with outer name
+ resolvedName = resolveImportedType( outerName, nestedName, false );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+
+ // check for a class globally
+ resolvedName = resolveFullyQualifiedType( typeName );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+
+ if(context.getClassLibrary() != null) {
+ // check for a class in the same package
+ resolvedName = resolveFromLibrary( getClassNamePrefix() + nestedName );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+
+ // try java.lang.*
+ resolvedName = resolveFromLibrary( "java.lang." + nestedName );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+ }
+
+ // Check type-import-on-demand
+ resolvedName = resolveImportedType( "*", nestedName, false );
+
+ if(resolvedName != null) {
+ break lookup;
+ }
+ }
+
+ return resolvedName;
+ }
+
+ private String resolveImportedType( String importSpec, String typeName, boolean fullMatch ) {
+ String[] imports = getImports();
+ String resolvedName = null;
+ String dotSuffix = "." + importSpec;
+
+ for (int i = 0; i < imports.length && resolvedName == null; i++) {
+ String imprt = imports[i];
+ //static imports can refer to inner classes
+ if(imprt.startsWith( "static " ) ) {
+ imprt = imprt.substring( 7 );
+ }
+
+ if (imprt.equals(importSpec) || (!fullMatch && imprt.endsWith(dotSuffix))) {
+ String candidateName = imprt.substring( 0, imprt.length() - importSpec.length()) + typeName;
+ resolvedName = resolveFullyQualifiedType( candidateName );
+ if(resolvedName == null && !"*".equals(importSpec)) {
+ resolvedName = candidateName;
+ }
+ }
+ }
+
+ return resolvedName;
+ }
+
+ private String resolveFromLibrary(String typeName) {
+ return context.getClassLibrary().contains( typeName ) ? typeName : null;
+ }
+
+ private String resolveFullyQualifiedType(String typeName) {
+ if (context.getClassLibrary() != null) {
+ int indexOfLastDot = typeName.lastIndexOf('.');
+
+ if (indexOfLastDot >= 0) {
+ String root = typeName.substring(0,indexOfLastDot);
+ String leaf = typeName.substring(indexOfLastDot+1);
+ String resolvedTypeName = resolveFullyQualifiedType(root + "$" + leaf);
+
+ if(resolvedTypeName != null) {
+ return resolvedTypeName;
+ }
+ }
+
+ // check for fully-qualified class
+ if (context.getClassLibrary().contains(typeName)) {
+ return typeName;
+ }
+ }
+
+ return null;
+ }
+
+ public String getClassNamePrefix() {
+ if (getPackage() == null) return "";
+ return getPackage().getName() + ".";
+ }
+
+ public JavaSource getParentSource() {
+ return this;
+ }
+
+ public JavaClass getNestedClassByName(String name) {
+ JavaClass result = null;
+
+ for (ListIterator i = classes.listIterator(); i.hasNext(); ) {
+ JavaClass candidateClass = (JavaClass) i.next();
+
+ if (candidateClass.getName().equals(name)) {
+ result = candidateClass;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ * @deprecated, use getJavaClassContext().getClassLibrary()
+ */
+ public ClassLibrary getClassLibrary() {
+ return this.context.getClassLibrary();
+ }
+
+ public String getPackageName()
+ {
+ return (packge == null ? "" : packge.getName());
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/Member.java b/src/java/com/thoughtworks/qdox/model/Member.java
new file mode 100644
index 0000000..38f4232
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/Member.java
@@ -0,0 +1,11 @@
+package com.thoughtworks.qdox.model;
+
+/**
+ * @author Aslak Hellesøy
+ * @version $Revision$
+ * @since 1.4
+ */
+public interface Member {
+ String getDeclarationSignature(boolean withModifiers);
+ String getCallSignature();
+}
\ No newline at end of file
diff --git a/src/java/com/thoughtworks/qdox/model/ModelBuilder.java b/src/java/com/thoughtworks/qdox/model/ModelBuilder.java
new file mode 100644
index 0000000..297bc09
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/ModelBuilder.java
@@ -0,0 +1,336 @@
+package com.thoughtworks.qdox.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+import com.thoughtworks.qdox.JavaClassContext;
+import com.thoughtworks.qdox.model.annotation.AnnotationFieldRef;
+import com.thoughtworks.qdox.model.annotation.AnnotationVisitor;
+import com.thoughtworks.qdox.model.annotation.RecursiveAnnotationVisitor;
+import com.thoughtworks.qdox.parser.Builder;
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TagDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+import com.thoughtworks.qdox.parser.structs.TypeVariableDef;
+
+/**
+ * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
+ * @author Robert Scholte
+ */
+public class ModelBuilder implements Builder {
+
+ private final JavaClassContext context;
+ private final JavaSource source;
+ private JavaClassParent currentParent;
+ private JavaClass currentClass;
+ private JavaMethod currentMethod;
+ private List currentAnnoDefs;
+ private String lastComment;
+ private List lastTagSet;
+ private DocletTagFactory docletTagFactory;
+
+ public ModelBuilder() {
+ this(new JavaClassContext(new ClassLibrary()), new DefaultDocletTagFactory(), new HashMap());
+ }
+
+ public ModelBuilder(JavaClassContext context, DocletTagFactory docletTagFactory, Map allPackages) {
+ this.context = context;
+ this.docletTagFactory = docletTagFactory;
+ source = new JavaSource(context);
+ currentParent = source;
+ currentAnnoDefs = new ArrayList();
+ }
+
+ public void addPackage(PackageDef packageDef) {
+ JavaPackage jPackage = context.getPackageByName( packageDef.name );;
+ if (jPackage == null) {
+ jPackage = new JavaPackage(packageDef.name);
+ context.add( jPackage );
+ }
+ jPackage.setLineNumber(packageDef.lineNumber);
+ setAnnotations(jPackage);
+ source.setPackage(jPackage);
+ }
+
+ public void addImport(String importName) {
+ source.addImport(importName);
+ }
+
+ public void addJavaDoc(String text) {
+ lastComment = text;
+ lastTagSet = new LinkedList();
+ }
+
+ public void addJavaDocTag(TagDef tagDef) {
+ lastTagSet.add(tagDef);
+ }
+
+ public void beginClass(ClassDef def) {
+ currentClass = new JavaClass();
+ currentClass.setLineNumber(def.lineNumber);
+
+ // basic details
+ currentClass.setName(def.name);
+ currentClass.setInterface(ClassDef.INTERFACE.equals(def.type));
+ currentClass.setEnum(ClassDef.ENUM.equals(def.type));
+ currentClass.setAnnotation(ClassDef.ANNOTATION_TYPE.equals(def.type));
+
+ // superclass
+ if (currentClass.isInterface()) {
+ currentClass.setSuperClass(null);
+ } else if (!currentClass.isEnum()) {
+ currentClass.setSuperClass(def.extendz.size() > 0 ? createType((TypeDef) def.extendz.toArray()[0], 0) : null);
+ }
+
+ // implements
+ {
+ Set implementSet = currentClass.isInterface() ? def.extendz : def.implementz;
+ Iterator implementIt = implementSet.iterator();
+ Type[] implementz = new Type[implementSet.size()];
+ for (int i = 0; i < implementz.length && implementIt.hasNext(); i++) {
+ implementz[i] = createType((TypeDef) implementIt.next(), 0);
+ }
+ currentClass.setImplementz(implementz);
+ }
+
+ // modifiers
+ {
+ String[] modifiers = new String[def.modifiers.size()];
+ def.modifiers.toArray(modifiers);
+ currentClass.setModifiers(modifiers);
+ }
+
+ // typeParameters
+ if (def.typeParams != null) {
+ TypeVariable[] typeParams = new TypeVariable[def.typeParams.size()];
+ int index = 0;
+ for(Iterator iterator = def.typeParams.iterator(); iterator.hasNext();) {
+ TypeVariableDef typeVariableDef = (TypeVariableDef) iterator.next();
+ typeParams[index++] = createTypeVariable(typeVariableDef);
+ }
+ currentClass.setTypeParameters(typeParams);
+ }
+
+ // javadoc
+ addJavaDoc(currentClass);
+
+// // ignore annotation types (for now)
+// if (ClassDef.ANNOTATION_TYPE.equals(def.type)) {
+// System.out.println( currentClass.getFullyQualifiedName() );
+// return;
+// }
+
+ // annotations
+ setAnnotations( currentClass );
+
+ currentParent.addClass(currentClass);
+ currentParent = currentClass;
+ context.add(currentClass.getFullyQualifiedName());
+ }
+
+ public void endClass() {
+ currentParent = currentClass.getParent();
+ if (currentParent instanceof JavaClass) {
+ currentClass = (JavaClass) currentParent;
+ } else {
+ currentClass = null;
+ }
+ }
+
+ public Type createType( String typeName, int dimensions ) {
+ if( typeName == null || typeName.equals( "" ) )
+ return null;
+ return createType(new TypeDef(typeName), dimensions);
+ }
+
+ public Type createType(TypeDef typeDef) {
+ return createType(typeDef, 0);
+ }
+
+
+ /**
+ * this one is specific for those cases where dimensions can be part of both the type and identifier
+ * i.e. private String[] matrix[]; //field
+ * public abstract String[] getMatrix[](); //method
+ *
+ * @param typeDef
+ * @param dimensions
+ * @return the Type
+ */
+ public Type createType(TypeDef typeDef, int dimensions) {
+ if(typeDef == null) {
+ return null;
+ }
+ return Type.createUnresolved(typeDef, dimensions, currentClass == null ? currentParent : currentClass);
+ }
+
+ private void addJavaDoc(AbstractJavaEntity entity) {
+ if (lastComment == null) return;
+
+ entity.setComment(lastComment);
+
+ Iterator tagDefIterator = lastTagSet.iterator();
+ List tagList = new ArrayList();
+ while (tagDefIterator.hasNext()) {
+ TagDef tagDef = (TagDef) tagDefIterator.next();
+ tagList.add(
+ docletTagFactory.createDocletTag(
+ tagDef.name, tagDef.text,
+ entity, tagDef.lineNumber
+ )
+ );
+ }
+ entity.setTags(tagList);
+
+ lastComment = null;
+ }
+
+ public void addMethod(MethodDef def) {
+ beginMethod();
+ endMethod(def);
+ }
+
+ public void beginMethod() {
+ currentMethod = new JavaMethod();
+ setAnnotations(currentMethod);
+ }
+
+ public void endMethod(MethodDef def) {
+ currentMethod.setParentClass(currentClass);
+ currentMethod.setLineNumber(def.lineNumber);
+
+ // basic details
+ currentMethod.setName(def.name);
+ currentMethod.setReturns(createType(def.returnType, def.dimensions));
+ currentMethod.setConstructor(def.constructor);
+
+ // typeParameters
+ if (def.typeParams != null) {
+ TypeVariable[] typeParams = new TypeVariable[def.typeParams.size()];
+ int index = 0;
+ for(Iterator iterator = def.typeParams.iterator(); iterator.hasNext();) {
+ TypeVariableDef typeVariableDef = (TypeVariableDef) iterator.next();
+ typeParams[index++] = createTypeVariable(typeVariableDef);
+ }
+ currentMethod.setTypeParameters(typeParams);
+ }
+
+ // exceptions
+ {
+ Type[] exceptions = new Type[def.exceptions.size()];
+ int index = 0;
+ for (Iterator iter = def.exceptions.iterator(); iter.hasNext();) {
+ exceptions[index++] = createType((String) iter.next(), 0);
+ }
+ currentMethod.setExceptions(exceptions);
+ }
+
+ // modifiers
+ {
+ String[] modifiers = new String[def.modifiers.size()];
+ def.modifiers.toArray(modifiers);
+ currentMethod.setModifiers(modifiers);
+ }
+
+ currentMethod.setSourceCode(def.body);
+
+ // javadoc
+ addJavaDoc(currentMethod);
+
+ currentClass.addMethod(currentMethod);
+ }
+
+ public TypeVariable createTypeVariable(TypeVariableDef typeVariableDef) {
+ if(typeVariableDef == null) {
+ return null;
+ }
+ return TypeVariable.createUnresolved(typeVariableDef, currentClass == null ? currentParent : currentClass);
+
+ }
+
+ public TypeVariable createTypeVariable(String name, List typeParams) {
+ if( name == null || name.equals( "" ) )
+ return null;
+
+ return createTypeVariable(new TypeVariableDef(name, typeParams));
+ }
+
+ public void addField(FieldDef def) {
+ JavaField currentField = new JavaField();
+ currentField.setParentClass(currentClass);
+ currentField.setLineNumber(def.lineNumber);
+
+ currentField.setName(def.name);
+ currentField.setType(createType(def.type, def.dimensions));
+
+ // modifiers
+ {
+ String[] modifiers = new String[def.modifiers.size()];
+ def.modifiers.toArray(modifiers);
+ currentField.setModifiers(modifiers);
+ }
+
+ // code body
+ currentField.setInitializationExpression(def.body);
+
+ // javadoc
+ addJavaDoc(currentField);
+
+ // annotations
+ setAnnotations( currentField );
+
+ currentClass.addField(currentField);
+ }
+
+ public void addParameter(FieldDef fieldDef) {
+ JavaParameter jParam = new JavaParameter(createType(fieldDef.type, fieldDef.dimensions), fieldDef.name, fieldDef.isVarArgs);
+ setAnnotations( jParam );
+ currentMethod.addParameter( jParam );
+ }
+
+ private void setAnnotations( final AbstractBaseJavaEntity entity ) {
+ if( !currentAnnoDefs.isEmpty() ) {
+ AnnotationVisitor visitor = new RecursiveAnnotationVisitor() {
+ public Object visitAnnotation( Annotation annotation ) {
+ annotation.setContext( entity );
+ return super.visitAnnotation( annotation );
+ }
+
+ public Object visitAnnotationFieldRef( AnnotationFieldRef fieldRef ) {
+ fieldRef.setContext( entity );
+ return super.visitAnnotationFieldRef( fieldRef );
+ }
+ };
+
+ Annotation[] annotations = new Annotation[currentAnnoDefs.size()];
+ for( ListIterator iter = currentAnnoDefs.listIterator(); iter.hasNext(); ) {
+ Annotation annotation = (Annotation) iter.next();
+ annotation.accept(visitor);
+ annotations[iter.previousIndex()] = annotation;
+ }
+
+ entity.setAnnotations( annotations );
+ currentAnnoDefs.clear();
+ }
+ }
+
+ // Don't resolve until we need it... class hasn't been defined yet.
+ public void addAnnotation( Annotation annotation ) {
+ currentAnnoDefs.add( annotation );
+ }
+
+ public JavaSource getSource() {
+ return source;
+ }
+
+}
+
diff --git a/src/java/com/thoughtworks/qdox/model/Type.java b/src/java/com/thoughtworks/qdox/model/Type.java
new file mode 100644
index 0000000..8026ffc
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/Type.java
@@ -0,0 +1,424 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.Serializable;
+
+import com.thoughtworks.qdox.JavaClassContext;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+import com.thoughtworks.qdox.parser.structs.WildcardTypeDef;
+
+public class Type implements Comparable, Serializable {
+
+ public static final Type[] EMPTY_ARRAY = new Type[0];
+ public static final Type VOID = new Type("void");
+
+ private String name;
+ private JavaClassParent context;
+ private String fullName;
+ private int dimensions;
+ private Type[] actualArgumentTypes;
+
+ public Type(String fullName, String name, int dimensions, JavaClassParent context) {
+ this.fullName = fullName;
+ this.name = name;
+ this.dimensions = dimensions;
+ this.context = context;
+ }
+
+ public Type(String fullName, TypeDef typeDef, int dimensions, JavaClassParent context) {
+ this.fullName = fullName;
+ this.name = typeDef.name;
+ this.dimensions = typeDef.dimensions + dimensions; //in some cases dimensions can be spread. Collect them here
+ if(typeDef.actualArgumentTypes != null && !typeDef.actualArgumentTypes.isEmpty()) {
+ actualArgumentTypes = new Type[typeDef.actualArgumentTypes.size()];
+ for(int index = 0; index < typeDef.actualArgumentTypes.size(); index++) {
+ actualArgumentTypes[index] = createUnresolved((TypeDef) typeDef.actualArgumentTypes.get(index), context);
+ }
+ }
+ this.context = context;
+ }
+
+
+ public Type(String fullName, int dimensions, JavaClassParent context) {
+ this(fullName, (String) null, dimensions, context);
+ }
+
+ public Type(String fullName, int dimensions) {
+ this(fullName, dimensions, null);
+ }
+
+ public Type(String fullName) {
+ this(fullName, 0);
+ }
+
+ public static Type createUnresolved(String name, int dimensions, JavaClassParent context) {
+ return new Type(null, name, dimensions, context);
+ }
+
+ public static Type createUnresolved(TypeDef typeDef, int dimensions, JavaClassParent context) {
+ return new Type(null, typeDef, dimensions, context);
+ }
+
+ public static Type createUnresolved(TypeDef typeDef, JavaClassParent context) {
+ if(typeDef instanceof WildcardTypeDef) {
+ return new WildcardType((WildcardTypeDef) typeDef, context);
+ }
+ return new Type(null, typeDef, 0, context);
+ }
+
+
+ public JavaClassParent getJavaClassParent() {
+ return context;
+ }
+
+ /**
+ *
+ * @deprecated instead use getFullyQualifiedName()
+ */
+ public String getFullQualifiedName() {
+ return getFullyQualifiedName();
+ }
+
+ /**
+ * Returns the FQN of an Object or the handler of a Type
+ * If the name of the can't be resolved based on the imports and the classes on the classpath the name will be returned
+ * InnerClasses will use the $ sign
+ *
+ * Some examples how names will be translated
+ * <pre>
+ * Object > java.lang.Object
+ * java.util.List > java.util.List
+ * ? > ?
+ * T > T
+ * anypackage.Outer.Inner > anypackage.Outer$Inner
+ * </pre>
+ *
+ * @return
+ */
+ public String getFullyQualifiedName() {
+
+ return isResolved() ? fullName : name;
+ }
+
+ /**
+ * The FQN representation of an Object for code usage
+ * This implementation ignores generics
+ *
+ * Some examples how Objects will be translated
+ * <pre>
+ * Object > java.lang.object
+ * java.util.List<T> > java.util.List
+ * ? > ?
+ * T > T
+ * anypackage.Outer.Inner > anypackage.Outer.Inner
+ * </pre>
+ *
+ * @return type representation for code usage
+ */
+ public String getValue() {
+ String fqn = getFullyQualifiedName();
+ return ( fqn == null ? "" : fqn.replaceAll( "\\$", "." ) );
+ }
+
+ /**
+ * The FQN representation of an Object for code usage
+ * This implementation ignores generics
+ *
+ * Some examples how Objects will be translated
+ * <pre>
+ * Object > java.lang.object
+ * java.util.List<T> > java.util.List
+ * ? > ?
+ * T > T
+ * anypackage.Outer.Inner > anypackage.Outer.Inner
+ * </pre>
+
+ * @since 1.8
+ * @return generic type representation for code usage
+ */
+ public String getGenericValue() {
+ StringBuffer result = new StringBuffer(getValue());
+ if(actualArgumentTypes != null && actualArgumentTypes.length > 0) {
+ result.append("<");
+ for(int index = 0;index < actualArgumentTypes.length; index++) {
+ result.append(actualArgumentTypes[index].getGenericValue());
+ if(index + 1 != actualArgumentTypes.length) {
+ result.append(",");
+ }
+ }
+ result.append(">");
+ }
+ for (int i = 0; i < dimensions; i++) result.append("[]");
+ return result.toString();
+ }
+
+ protected String getGenericValue(TypeVariable[] typeVariableList) {
+ StringBuffer result = new StringBuffer(getResolvedValue(typeVariableList));
+ if(actualArgumentTypes != null && actualArgumentTypes.length > 0) {
+ for(int index = 0;index < actualArgumentTypes.length; index++) {
+ result.append(actualArgumentTypes[index].getResolvedGenericValue(typeVariableList));
+ if(index + 1 != actualArgumentTypes.length) {
+ result.append(",");
+ }
+ }
+ }
+ return result.toString();
+ }
+
+ protected String getResolvedValue(TypeVariable[] typeParameters) {
+ String result = getValue();
+ for(int typeIndex=0;typeIndex<typeParameters.length; typeIndex++) {
+ if(typeParameters[typeIndex].getName().equals(getValue())) {
+ result = typeParameters[typeIndex].getValue();
+ break;
+ }
+ }
+ return result;
+ }
+
+ protected String getResolvedGenericValue(TypeVariable[] typeParameters) {
+ String result = getGenericValue(typeParameters);
+ for(int typeIndex=0;typeIndex<typeParameters.length; typeIndex++) {
+ if(typeParameters[typeIndex].getName().equals(getValue())) {
+ result = typeParameters[typeIndex].getGenericValue();
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Checks if the FQN of this Type is resolved
+ *
+ * @return
+ */
+ public boolean isResolved() {
+ if (fullName == null && context != null) {
+ fullName = context.resolveType(name);
+ }
+ return (fullName != null);
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(Object)
+ */
+ public int compareTo(Object o) {
+ if (!(o instanceof Type))
+ return 0;
+
+ return getValue().compareTo(((Type) o).getValue());
+ }
+
+ /**
+ * Returns true if this Type is an array
+ *
+ * @return
+ */
+ public boolean isArray() {
+ return dimensions > 0;
+ }
+
+ /**
+ * Returns the depth of this array, 0 if it's not an array
+ *
+ * @return The depth of this array
+ */
+ public int getDimensions() {
+ return dimensions;
+ }
+
+ /**
+ *
+ * @return the actualTypeArguments or null
+ */
+ public Type[] getActualTypeArguments()
+ {
+ return actualArgumentTypes;
+ }
+
+ /**
+ * Returns getValue() extended with the array information
+ *
+ * @return
+ */
+ public String toString() {
+ if (dimensions == 0) return getValue();
+ StringBuffer buff = new StringBuffer(getValue());
+ for (int i = 0; i < dimensions; i++) buff.append("[]");
+ String result = buff.toString();
+ return result;
+ }
+
+ /**
+ * Returns getGenericValue() extended with the array information
+ *
+ * <pre>
+ * Object > java.lang.Object
+ * Object[] > java.lang.Object[]
+ * List<Object> > java.lang.List<java.lang.Object>
+ * Outer.Inner > Outer.Inner
+ * Outer.Inner<Object>[][] > Outer.Inner<java.lang.Object>[][]
+ * </pre>
+ * @return
+ */
+ public String toGenericString() {
+ if (dimensions == 0) return getGenericValue();
+ StringBuffer buff = new StringBuffer(getGenericValue());
+ for (int i = 0; i < dimensions; i++) buff.append("[]");
+ String result = buff.toString();
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == null) return false;
+ Type t = (Type) obj;
+ return getValue().equals(t.getValue()) && t.getDimensions() == getDimensions();
+ }
+
+ public int hashCode() {
+ return getValue().hashCode();
+ }
+
+ public JavaClass getJavaClass() {
+ JavaClass result = null;
+
+ JavaClassParent javaClassParent = getJavaClassParent();
+ if (javaClassParent != null) {
+ result = javaClassParent.getNestedClassByName(getFullyQualifiedName());
+ if(result == null) {
+ JavaClassContext context = javaClassParent.getJavaClassContext();
+ if (context.getClassLibrary() != null) {
+ result = context.getClassByName(getFullyQualifiedName());
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean isA(Type type) {
+ if (this.equals(type)) {
+ return true;
+ } else {
+ JavaClass javaClass = getJavaClass();
+ if (javaClass != null) {
+ // ask our interfaces
+ Type[] implementz = javaClass.getImplements();
+ for (int i = 0; i < implementz.length; i++) {
+ if (implementz[i].isA(type)) {
+ return true;
+ }
+ }
+
+ // ask our superclass
+ Type supertype = javaClass.getSuperClass();
+ if (supertype != null) {
+ if (supertype.isA(type)) {
+ return true;
+ }
+ }
+ }
+ }
+ // We'we walked up the hierarchy and found nothing.
+ return false;
+ }
+
+ /**
+ * @since 1.6
+ */
+ public boolean isPrimitive() {
+ String value = getValue();
+ if (value == null || value.length() == 0 || value.indexOf('.') > -1) {
+ return false;
+ } else {
+ return "void".equals(value)
+ || "boolean".equals(value)
+ || "byte".equals(value)
+ || "char".equals(value)
+ || "short".equals(value)
+ || "int".equals(value)
+ || "long".equals(value)
+ || "float".equals(value)
+ || "double".equals(value);
+ }
+ }
+
+ /**
+ * @since 1.6
+ */
+ public boolean isVoid() {
+ return "void".equals(getValue());
+ }
+
+ /**
+ *
+ * @param superClass
+ * @return
+ * @since 1.12
+ */
+ protected int getTypeVariableIndex( JavaClass superClass ) {
+ TypeVariable[] typeVariables = superClass.getTypeParameters();
+ for(int typeIndex=0;typeIndex<typeVariables.length; typeIndex++) {
+ if(typeVariables[typeIndex].getFullyQualifiedName().equals( getFullyQualifiedName())) {
+ return typeIndex;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ *
+ * @param parentClass
+ * @return
+ * @since 1.12
+ */
+ protected Type resolve( JavaClass parentClass )
+ {
+ return resolve( parentClass, parentClass );
+ }
+
+ /**
+ *
+ * @param parentClass
+ * @param subclass
+ * @return
+ * @since 1.12
+ */
+ protected Type resolve( JavaClass parentClass, JavaClass subclass )
+ {
+ Type result = this;
+ int typeIndex = getTypeVariableIndex( parentClass );
+ if ( typeIndex >= 0 )
+ {
+ String fqn = parentClass.getFullyQualifiedName();
+ if ( subclass.getSuperClass() != null && fqn.equals( subclass.getSuperClass().getFullyQualifiedName() ) ) {
+ result = subclass.getSuperClass().getActualTypeArguments()[typeIndex];
+ }
+ else if ( subclass.getImplementedInterfaces() != null )
+ {
+ for ( int i = 0; i < subclass.getImplementedInterfaces().length; i++ )
+ {
+ if ( fqn.equals( subclass.getImplements()[i].getFullyQualifiedName() ) )
+ {
+ result = subclass.getImplements()[i].getActualTypeArguments()[typeIndex].resolve( subclass.getImplementedInterfaces()[i] );
+ break;
+ }
+ }
+ //no direct interface available, try indirect
+ }
+ }
+
+ if ( this.actualArgumentTypes != null ) {
+ result = new Type( this.fullName, this.name, this.dimensions, this.context );
+
+ result.actualArgumentTypes = new Type[this.actualArgumentTypes.length];
+ for (int i = 0; i < this.getActualTypeArguments().length; i++ )
+ {
+ result.actualArgumentTypes[i] = this.actualArgumentTypes[i].resolve( parentClass, subclass );
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/TypeVariable.java b/src/java/com/thoughtworks/qdox/model/TypeVariable.java
new file mode 100644
index 0000000..f6943a2
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/TypeVariable.java
@@ -0,0 +1,56 @@
+package com.thoughtworks.qdox.model;
+
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+import com.thoughtworks.qdox.parser.structs.TypeVariableDef;
+/**
+ *
+ *
+ * @author Robert Scholte
+ * @since 1.10
+ */
+public class TypeVariable extends Type {
+
+ public static final TypeVariable[] EMPTY_ARRAY = new TypeVariable[0];
+
+ private Type[] bounds;
+
+ public TypeVariable(String fullName, TypeVariableDef def, JavaClassParent context) {
+ super(fullName, def.name, 0, context);
+ if(def.bounds != null && !def.bounds.isEmpty()) {
+ bounds = new Type[def.bounds.size()];
+ for(int index = 0; index < def.bounds.size(); index++) {
+ bounds[index] = createUnresolved((TypeDef) def.bounds.get(index), context);
+ }
+ }
+ }
+
+ public static TypeVariable createUnresolved(TypeVariableDef def, JavaClassParent context) {
+ return new TypeVariable(null, def, context);
+ }
+
+
+ public String getValue() {
+ return (bounds == null || bounds.length == 0 ? "" : bounds[0].getValue());
+ }
+
+ public String getGenericValue() {
+ StringBuffer result = new StringBuffer("<");
+ result.append(super.getValue());
+ if(bounds != null && bounds.length > 0) {
+ result.append(" extends ");
+ for(int index = 0; index < bounds.length; index++) {
+ if(index > 0) {
+ result.append(",");
+ }
+ result.append(bounds[index].getGenericValue());
+ }
+ }
+ result.append(">");
+ return result.toString();
+ }
+
+ public String getName() {
+ return super.getValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/WildcardType.java b/src/java/com/thoughtworks/qdox/model/WildcardType.java
new file mode 100644
index 0000000..da41c1b
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/WildcardType.java
@@ -0,0 +1,38 @@
+package com.thoughtworks.qdox.model;
+
+import com.thoughtworks.qdox.parser.structs.WildcardTypeDef;
+
+/**
+ * This class supports both the 'super' and 'extends' wildcards.
+ * For <?> you must use the normal Type, because ? itself can't be generic
+ *
+ * @author Robert Scholte
+ *
+ */
+public class WildcardType extends Type {
+
+ private String wildcardExpressionType = null;
+
+ public WildcardType() {
+ super("?");
+ }
+
+
+ public WildcardType(WildcardTypeDef typeDef) {
+ this(typeDef, null);
+ }
+
+ public WildcardType(WildcardTypeDef typeDef, JavaClassParent context) {
+ super(null, typeDef, 0, context);
+ this.wildcardExpressionType = typeDef.getWildcardExpressionType();
+ }
+
+ public String getGenericValue() {
+ String result = "";
+ if(wildcardExpressionType != null) {
+ result += "? " + wildcardExpressionType+ " ";
+ }
+ result += super.getGenericValue();
+ return result;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAdd.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAdd.java
new file mode 100644
index 0000000..3dadca9
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAdd.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationAdd extends AnnotationBinaryOperator {
+
+ public AnnotationAdd( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " + " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationAdd( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " + " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAnd.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAnd.java
new file mode 100644
index 0000000..5317afe
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationAnd.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationAnd extends AnnotationBinaryOperator {
+
+ public AnnotationAnd( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " & " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationAnd( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " & " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationBinaryOperator.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationBinaryOperator.java
new file mode 100644
index 0000000..aec9b02
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationBinaryOperator.java
@@ -0,0 +1,22 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public abstract class AnnotationBinaryOperator implements AnnotationValue {
+
+ private AnnotationValue left;
+
+ private AnnotationValue right;
+
+ public AnnotationBinaryOperator( AnnotationValue left, AnnotationValue right ) {
+ this.left = left;
+ this.right = right;
+ }
+
+ public AnnotationValue getLeft() {
+ return left;
+ }
+
+ public AnnotationValue getRight() {
+ return right;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationCast.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationCast.java
new file mode 100644
index 0000000..c89b471
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationCast.java
@@ -0,0 +1,36 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import com.thoughtworks.qdox.model.Type;
+
+public class AnnotationCast implements AnnotationValue {
+
+ private final Type type;
+
+ private final AnnotationValue value;
+
+ public AnnotationCast( Type type, AnnotationValue value ) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public Type getType() {
+ return this.type;
+ }
+
+ public AnnotationValue getValue() {
+ return this.value;
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationCast( this );
+ }
+
+ public Object getParameterValue() {
+ return "(" + type.getValue() + ") " + value.getParameterValue();
+ }
+
+ public String toString() {
+ return "(" + type.getValue() + ") " + value.toString();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationConstant.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationConstant.java
new file mode 100644
index 0000000..ce4ae0b
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationConstant.java
@@ -0,0 +1,36 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import java.io.Serializable;
+
+public class AnnotationConstant implements AnnotationValue, Serializable {
+
+ private final Object value;
+
+ private final String image;
+
+ public AnnotationConstant( Object value, String image ) {
+ this.value = value;
+ this.image = image;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public String toString() {
+ return image;
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationConstant( this );
+ }
+
+ public Object getParameterValue() {
+ return image;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationDivide.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationDivide.java
new file mode 100644
index 0000000..fef7118
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationDivide.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationDivide extends AnnotationBinaryOperator {
+
+ public AnnotationDivide( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " / " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationDivide( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " / " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationEquals.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationEquals.java
new file mode 100644
index 0000000..883bfb0
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationEquals.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationEquals extends AnnotationBinaryOperator {
+
+ public AnnotationEquals( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " == " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationEquals( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " == " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationExclusiveOr.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationExclusiveOr.java
new file mode 100644
index 0000000..519efa7
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationExclusiveOr.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationExclusiveOr extends AnnotationBinaryOperator {
+
+ public AnnotationExclusiveOr( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " ^ " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationExclusiveOr( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " ^ " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationFieldRef.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationFieldRef.java
new file mode 100644
index 0000000..d4bcf14
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationFieldRef.java
@@ -0,0 +1,151 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.StringTokenizer;
+
+import com.thoughtworks.qdox.model.AbstractBaseJavaEntity;
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaClassParent;
+import com.thoughtworks.qdox.model.JavaField;
+import com.thoughtworks.qdox.model.Type;
+
+public class AnnotationFieldRef implements AnnotationValue {
+
+ String[] myArray = new String[]{"unchecked"};
+ private final int[] parts;
+
+ private final String name;
+
+ private AbstractBaseJavaEntity context;
+
+ private JavaField field;
+
+ private int fieldIndex = -1;
+
+ public AnnotationFieldRef( String name ) {
+ this.name = name;
+
+ int length = new StringTokenizer( name, "." ).countTokens();
+ this.parts = new int[length + 1];
+ this.parts[0] = -1;
+
+ for( int i = 1; i < length; ++i ) {
+ this.parts[i] = name.indexOf( '.', this.parts[i - 1] + 1 );
+ }
+
+ this.parts[length] = name.length();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getNamePrefix( int end ) {
+ return name.substring( 0, parts[end + 1] );
+ }
+
+ public String getNamePart( int index ) {
+ return name.substring( parts[index] + 1, parts[index + 1] );
+ }
+
+ public int getPartCount() {
+ return parts.length - 1;
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationFieldRef( this );
+ }
+
+ public Object getParameterValue() {
+ return getName();
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public AbstractBaseJavaEntity getContext() {
+ return this.context;
+ }
+
+ public void setContext( AbstractBaseJavaEntity context ) {
+ this.context = context;
+ }
+
+ public String getClassPart() {
+ String result = null;
+
+ if( getField() != null ) {
+ result = name.substring( 0, parts[fieldIndex] );
+ }
+
+ return result;
+ }
+
+ public String getFieldPart() {
+ String result = null;
+
+ if( getField() != null ) {
+ result = name.substring( parts[fieldIndex] + 1 );
+ }
+
+ return result;
+ }
+
+ protected JavaField resolveField( JavaClass javaClass, int start, int end ) {
+ JavaField field = null;
+
+ for( int i = start; i < end; ++i ) {
+ field = javaClass.getFieldByName( getNamePart( i ) );
+
+ if( field == null ) {
+ break;
+ }
+
+ javaClass = field.getType().getJavaClass();
+ }
+
+ return field;
+ }
+
+ public JavaField getField() {
+ if( fieldIndex < 0 ) {
+ if( context.getParentClass() != null ) {
+ JavaClass javaClass = context.getParentClass();
+ field = resolveField( javaClass, 0, parts.length -1 );
+ fieldIndex = 0;
+ }
+
+ if( field == null ) {
+ JavaClassParent classParent = context.getParentClass();
+
+ //assume context is a JavaClass itself
+ if(classParent == null) {
+ classParent = (JavaClass) context;
+ }
+
+ for( int i = 0; i < parts.length - 1; ++i ) {
+ String className = getNamePrefix( i );
+ String typeName = classParent.resolveType( className );
+
+ if( typeName != null ) {
+ Type type = Type.createUnresolved( typeName, 0, classParent );
+ JavaClass javaClass = type.getJavaClass();
+
+ if( javaClass != null ) {
+ fieldIndex = i + 1;
+ field = resolveField( javaClass, i + 1, parts.length - 1 );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return field;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterEquals.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterEquals.java
new file mode 100644
index 0000000..b1dffa0
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterEquals.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationGreaterEquals extends AnnotationBinaryOperator {
+
+ public AnnotationGreaterEquals( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " >= " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationGreaterEquals( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " >= " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterThan.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterThan.java
new file mode 100644
index 0000000..213d70f
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationGreaterThan.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationGreaterThan extends AnnotationBinaryOperator {
+
+ public AnnotationGreaterThan( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " > " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationGreaterThan( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " > " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessEquals.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessEquals.java
new file mode 100644
index 0000000..bb8fb19
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessEquals.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationLessEquals extends AnnotationBinaryOperator {
+
+ public AnnotationLessEquals( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " <= " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationLessEquals( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " <= " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessThan.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessThan.java
new file mode 100644
index 0000000..6d3fea6
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLessThan.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationLessThan extends AnnotationBinaryOperator {
+
+ public AnnotationLessThan( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " < " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationLessThan( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " < " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalAnd.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalAnd.java
new file mode 100644
index 0000000..a92b46f
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalAnd.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationLogicalAnd extends AnnotationBinaryOperator {
+
+ public AnnotationLogicalAnd( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " && " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationLogicalAnd( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " && " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalNot.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalNot.java
new file mode 100644
index 0000000..9daba66
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalNot.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationLogicalNot extends AnnotationUnaryOperator {
+
+ public AnnotationLogicalNot( AnnotationValue value ) {
+ super( value );
+ }
+
+ public String toString() {
+ return "!" + getValue().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationLogicalNot( this );
+ }
+
+ public Object getParameterValue() {
+ return "!" + getValue().toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalOr.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalOr.java
new file mode 100644
index 0000000..c2dc0b1
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationLogicalOr.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationLogicalOr extends AnnotationBinaryOperator {
+
+ public AnnotationLogicalOr( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " || " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationLogicalOr( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " || " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMinusSign.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMinusSign.java
new file mode 100644
index 0000000..641d328
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMinusSign.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationMinusSign extends AnnotationUnaryOperator {
+
+ public AnnotationMinusSign( AnnotationValue value ) {
+ super( value );
+ }
+
+ public String toString() {
+ return "-" + getValue().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationMinusSign( this );
+ }
+
+ public Object getParameterValue() {
+ return "-" + getValue().toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMultiply.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMultiply.java
new file mode 100644
index 0000000..21401f5
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationMultiply.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationMultiply extends AnnotationBinaryOperator {
+
+ public AnnotationMultiply( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " * " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationMultiply( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " * " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNot.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNot.java
new file mode 100644
index 0000000..e6294a2
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNot.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationNot extends AnnotationUnaryOperator {
+
+ public AnnotationNot( AnnotationValue value ) {
+ super( value );
+ }
+
+ public String toString() {
+ return "~" + getValue().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationNot( this );
+ }
+
+ public Object getParameterValue() {
+ return "~" + getValue().toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNotEquals.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNotEquals.java
new file mode 100644
index 0000000..2e919be
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationNotEquals.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationNotEquals extends AnnotationBinaryOperator {
+
+ public AnnotationNotEquals( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " != " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationNotEquals( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " != " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationOr.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationOr.java
new file mode 100644
index 0000000..c538982
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationOr.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationOr extends AnnotationBinaryOperator {
+
+ public AnnotationOr( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " | " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationOr( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " | " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationParenExpression.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationParenExpression.java
new file mode 100644
index 0000000..0647a92
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationParenExpression.java
@@ -0,0 +1,27 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationParenExpression implements AnnotationValue {
+
+ private AnnotationValue value;
+
+ public AnnotationParenExpression( AnnotationValue value ) {
+ this.value = value;
+ }
+
+ public AnnotationValue getValue() {
+ return value;
+ }
+
+ public String toString() {
+ return "(" + value.toString() + ")";
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationParenExpression( this );
+ }
+
+ public Object getParameterValue() {
+ return "(" + value.getParameterValue() + ")";
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationPlusSign.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationPlusSign.java
new file mode 100644
index 0000000..361b5ed
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationPlusSign.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationPlusSign extends AnnotationUnaryOperator {
+
+ public AnnotationPlusSign( AnnotationValue value ) {
+ super( value );
+ }
+
+ public String toString() {
+ return "+" + getValue().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationPlusSign( this );
+ }
+
+ public Object getParameterValue() {
+ return "+" + getValue().toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationQuery.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationQuery.java
new file mode 100644
index 0000000..ff1a8f7
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationQuery.java
@@ -0,0 +1,41 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationQuery implements AnnotationValue {
+
+ private final AnnotationValue condition;
+
+ private final AnnotationValue trueExpression;
+
+ private final AnnotationValue falseExpression;
+
+ public AnnotationQuery( AnnotationValue condition, AnnotationValue trueExpression, AnnotationValue falseExpression ) {
+ this.condition = condition;
+ this.trueExpression = trueExpression;
+ this.falseExpression = falseExpression;
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationQuery( this );
+ }
+
+ public AnnotationValue getCondition() {
+ return this.condition;
+ }
+
+ public AnnotationValue getTrueExpression() {
+ return this.trueExpression;
+ }
+
+ public AnnotationValue getFalseExpression() {
+ return this.falseExpression;
+ }
+
+ public Object getParameterValue() {
+ return condition.getParameterValue().toString() + " ? " + trueExpression.getParameterValue() + " : "
+ + falseExpression.getParameterValue();
+ }
+
+ public String toString() {
+ return condition.toString() + " ? " + trueExpression.toString() + " : " + falseExpression.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationRemainder.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationRemainder.java
new file mode 100644
index 0000000..126dfd4
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationRemainder.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationRemainder extends AnnotationBinaryOperator {
+
+ public AnnotationRemainder( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " * " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationRemainder( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " * " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftLeft.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftLeft.java
new file mode 100644
index 0000000..b057ac0
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftLeft.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationShiftLeft extends AnnotationBinaryOperator {
+
+ public AnnotationShiftLeft( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " << " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationShiftLeft( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " << " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftRight.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftRight.java
new file mode 100644
index 0000000..28bbe28
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationShiftRight.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationShiftRight extends AnnotationBinaryOperator {
+
+ public AnnotationShiftRight( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " >> " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationShiftRight( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " >> " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationSubtract.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationSubtract.java
new file mode 100644
index 0000000..2fb6dff
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationSubtract.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationSubtract extends AnnotationBinaryOperator {
+
+ public AnnotationSubtract( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " - " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationSubtract( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " - " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationTypeRef.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationTypeRef.java
new file mode 100644
index 0000000..3b5f84e
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationTypeRef.java
@@ -0,0 +1,28 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import com.thoughtworks.qdox.model.Type;
+
+public class AnnotationTypeRef implements AnnotationValue {
+
+ private Type type;
+
+ public AnnotationTypeRef( Type type ) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String toString() {
+ return type.getValue() + ".class";
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationTypeRef( this );
+ }
+
+ public Object getParameterValue() {
+ return type.getValue() + ".class";
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnaryOperator.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnaryOperator.java
new file mode 100644
index 0000000..111c526
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnaryOperator.java
@@ -0,0 +1,15 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public abstract class AnnotationUnaryOperator implements AnnotationValue {
+
+ private AnnotationValue value;
+
+ public AnnotationUnaryOperator( AnnotationValue value ) {
+ this.value = value;
+ }
+
+ public AnnotationValue getValue() {
+ return value;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnsignedShiftRight.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnsignedShiftRight.java
new file mode 100644
index 0000000..7500c31
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationUnsignedShiftRight.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.model.annotation;
+
+public class AnnotationUnsignedShiftRight extends AnnotationBinaryOperator {
+
+ public AnnotationUnsignedShiftRight( AnnotationValue left, AnnotationValue right ) {
+ super( left, right );
+ }
+
+ public String toString() {
+ return getLeft().toString() + " >>> " + getRight().toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationUnsignedShiftRight( this );
+ }
+
+ public Object getParameterValue() {
+ return getLeft().getParameterValue() + " >>> " + getRight().getParameterValue();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValue.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValue.java
new file mode 100644
index 0000000..5a50020
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValue.java
@@ -0,0 +1,27 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import com.thoughtworks.qdox.model.Annotation;
+
+/**
+ * Interface for all annotation model elements
+ *
+ * @author Jochen Kuhnle
+ */
+public interface AnnotationValue {
+
+ /**
+ * Accept a visitor for this value.
+ *
+ * @param visitor Visitor
+ * @return Visitor result
+ */
+ public Object accept( AnnotationVisitor visitor );
+
+ /**
+ * Get a parameter value for {@link Annotation#getNamedParameter(String)}.
+ *
+ * @return Parameter value
+ */
+ public Object getParameterValue();
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValueList.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValueList.java
new file mode 100644
index 0000000..f3c47df
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationValueList.java
@@ -0,0 +1,54 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+public class AnnotationValueList implements AnnotationValue {
+
+ private final List valueList;
+
+ public AnnotationValueList( List valueList ) {
+ this.valueList = valueList;
+ }
+
+ public List getValueList() {
+ return valueList;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append( "{" );
+
+ int pos = buf.length();
+
+ for( ListIterator i = valueList.listIterator(); i.hasNext(); ) {
+ buf.append( i.next().toString() );
+ buf.append( ", " );
+ }
+
+ if( buf.length() > pos ) {
+ buf.setLength( buf.length() - 2 );
+ }
+
+ buf.append( "}" );
+
+ return buf.toString();
+ }
+
+ public Object accept( AnnotationVisitor visitor ) {
+ return visitor.visitAnnotationValueList( this );
+ }
+
+ public Object getParameterValue() {
+ List list = new ArrayList();
+
+ for( ListIterator i = valueList.listIterator(); i.hasNext(); ) {
+ AnnotationValue value = (AnnotationValue) i.next();
+ list.add( value.getParameterValue() );
+ }
+
+ return list;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/AnnotationVisitor.java b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationVisitor.java
new file mode 100644
index 0000000..47cb5cc
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/AnnotationVisitor.java
@@ -0,0 +1,74 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import com.thoughtworks.qdox.model.Annotation;
+
+/**
+ * Visitor class for the annotation model elements
+ *
+ * @author Jochen Kuhnle
+ */
+public interface AnnotationVisitor {
+
+ public Object visitAnnotationAdd( AnnotationAdd add );
+
+ public Object visitAnnotationSubtract( AnnotationSubtract subtract );
+
+ public Object visitAnnotationMultiply( AnnotationMultiply multiply );
+
+ public Object visitAnnotationDivide( AnnotationDivide divide );
+
+ public Object visitAnnotationGreaterThan( AnnotationGreaterThan greaterThan );
+
+ public Object visitAnnotationLessThan( AnnotationLessThan lessThan );
+
+ public Object visitAnnotation( Annotation annotation );
+
+ public Object visitAnnotationConstant( AnnotationConstant constant );
+
+ public Object visitAnnotationParenExpression( AnnotationParenExpression expression );
+
+ public Object visitAnnotationValueList( AnnotationValueList valueList );
+
+ public Object visitAnnotationTypeRef( AnnotationTypeRef typeRef );
+
+ public Object visitAnnotationFieldRef( AnnotationFieldRef fieldRef );
+
+ public Object visitAnnotationLessEquals( AnnotationLessEquals lessEquals );
+
+ public Object visitAnnotationGreaterEquals( AnnotationGreaterEquals greaterEquals );
+
+ public Object visitAnnotationRemainder( AnnotationRemainder remainder );
+
+ public Object visitAnnotationOr( AnnotationOr or );
+
+ public Object visitAnnotationAnd( AnnotationAnd and );
+
+ public Object visitAnnotationShiftLeft( AnnotationShiftLeft left );
+
+ public Object visitAnnotationShiftRight( AnnotationShiftRight right );
+
+ public Object visitAnnotationNot( AnnotationNot not );
+
+ public Object visitAnnotationLogicalOr( AnnotationLogicalOr or );
+
+ public Object visitAnnotationLogicalAnd( AnnotationLogicalAnd and );
+
+ public Object visitAnnotationLogicalNot( AnnotationLogicalNot not );
+
+ public Object visitAnnotationMinusSign( AnnotationMinusSign sign );
+
+ public Object visitAnnotationPlusSign( AnnotationPlusSign sign );
+
+ public Object visitAnnotationUnsignedShiftRight( AnnotationUnsignedShiftRight right );
+
+ public Object visitAnnotationEquals( AnnotationEquals annotationEquals );
+
+ public Object visitAnnotationNotEquals( AnnotationNotEquals annotationNotEquals );
+
+ public Object visitAnnotationExclusiveOr( AnnotationExclusiveOr annotationExclusiveOr );
+
+ public Object visitAnnotationQuery( AnnotationQuery annotationQuery );
+
+ public Object visitAnnotationCast( AnnotationCast annotationCast );
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/EvaluatingVisitor.java b/src/java/com/thoughtworks/qdox/model/annotation/EvaluatingVisitor.java
new file mode 100644
index 0000000..a3b9450
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/EvaluatingVisitor.java
@@ -0,0 +1,737 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.ListIterator;
+
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+
+/**
+ * Visitor that evaluates annotation expressions.
+ * <p>
+ * Users of this class must override
+ * {@link EvaluatingVisitor#getFieldReferenceValue(JavaField)} to return values
+ * for referenced fields.
+ *
+ * @author Jochen Kuhnle
+ */
+public abstract class EvaluatingVisitor implements AnnotationVisitor {
+
+ public Object getValue( Annotation annotation, String property ) {
+ Object result = null;
+ AnnotationValue value = annotation.getProperty( property );
+
+ if( value != null ) {
+ result = value.accept( this );
+ }
+
+ return result;
+ }
+
+ public List getListValue( Annotation annotation, String property ) {
+ Object value = getValue( annotation, property );
+ List list = null;
+
+ if( value != null ) {
+ if( value instanceof List ) {
+ list = (List) value;
+ }
+ else {
+ list = Collections.singletonList( value );
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * Return the result type of a binary operator
+ * <p>
+ * Performs binary numeric promotion as specified in the Java Language
+ * Specification,
+ * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170983">section 5.6.1<a>
+ */
+ protected static Class resultType( Object left, Object right ) {
+ Class type = void.class;
+
+ if( left instanceof String || right instanceof String ) {
+ type = String.class;
+ }
+ else if( left instanceof Number && right instanceof Number ) {
+ if( left instanceof Double || right instanceof Double ) {
+ type = Double.class;
+ }
+ else if( left instanceof Float || right instanceof Float ) {
+ type = Float.class;
+ }
+ else if( left instanceof Long || right instanceof Long ) {
+ type = Long.class;
+ }
+ else {
+ type = Integer.class;
+ }
+ }
+
+ return type;
+ }
+
+ /**
+ * Return the numeric result type of a binary operator
+ * <p>
+ * Performs binary numeric promotion as specified in the Java Language
+ * Specification,
+ * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170983">section 5.6.1<a>
+ */
+ protected static Class numericResultType( Object left, Object right ) {
+ Class type = void.class;
+
+ if( left instanceof Number && right instanceof Number ) {
+ if( left instanceof Long || right instanceof Long ) {
+ type = Long.class;
+ }
+ else if( left instanceof Integer || right instanceof Integer ) {
+ type = Integer.class;
+ }
+ }
+
+ return type;
+ }
+
+ /**
+ * Return the result type of an unary operator
+ * <p>
+ * Performs unary numeric promotion as specified in the Java Language
+ * Specification,
+ * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170952">section 5.6.2<a>
+ */
+ protected static Class unaryNumericResultType( Object value ) {
+ Class type = void.class;
+
+ if( value instanceof Byte || value instanceof Short || value instanceof Character || value instanceof Integer ) {
+ type = Integer.class;
+ }
+ else if( value instanceof Long ) {
+ value = Long.class;
+ }
+
+ return type;
+ }
+
+ protected static Class unaryResultType( Object value ) {
+ Class type = unaryNumericResultType( value );
+
+ if( type == void.class ) {
+ if( value instanceof Float ) {
+ value = Float.class;
+ }
+ else if( value instanceof Double ) {
+ value = Double.class;
+ }
+ }
+
+ return type;
+ }
+
+ public Object visitAnnotation( Annotation annotation ) {
+ throw new UnsupportedOperationException( "Illegal annotation value '" + annotation + "'." );
+ }
+
+ public Object visitAnnotationAdd( AnnotationAdd op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ Object result;
+
+ if( type == String.class ) {
+ result = left.toString() + right.toString();
+ }
+ else if( type == Double.class ) {
+ result = new Double( ((Number) left).doubleValue() + ((Number) right).doubleValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( ((Number) left).floatValue() + ((Number) right).floatValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() + ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() + ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationConstant( AnnotationConstant constant ) {
+ return constant.getValue();
+ }
+
+ public Object visitAnnotationDivide( AnnotationDivide op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ Object result;
+
+ if( type == Double.class ) {
+ result = new Double( ((Number) left).doubleValue() / ((Number) right).doubleValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( ((Number) left).floatValue() / ((Number) right).floatValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() / ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() / ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationFieldRef( AnnotationFieldRef fieldRef ) {
+ JavaField javaField = fieldRef.getField();
+
+ if( javaField == null ) {
+ throw new IllegalArgumentException( "Cannot resolve field reference '" + fieldRef + "'." );
+ }
+
+ if( !javaField.isFinal() || !javaField.isStatic() ) {
+ throw new IllegalArgumentException( "Field reference '" + fieldRef + "' must be static and final." );
+ }
+
+ Object result = getFieldReferenceValue( javaField );
+ return result;
+ }
+
+ protected abstract Object getFieldReferenceValue( JavaField javaField );
+
+ public Object visitAnnotationGreaterThan( AnnotationGreaterThan op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() > ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() > ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() > ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() > ((Number) right).intValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationLessThan( AnnotationLessThan op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() < ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() < ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() < ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() < ((Number) right).intValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationMultiply( AnnotationMultiply op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ Object result;
+
+ if( type == Double.class ) {
+ result = new Double( ((Number) left).doubleValue() * ((Number) right).doubleValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( ((Number) left).floatValue() * ((Number) right).floatValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() * ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() * ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationParenExpression( AnnotationParenExpression parenExpression ) {
+ return parenExpression.getValue().accept( this );
+ }
+
+ public Object visitAnnotationSubtract( AnnotationSubtract op ) {
+ Object left = op.getLeft().accept( this );
+ Object right = op.getRight().accept( this );
+ Class type = resultType( left, right );
+ Object result;
+
+ if( type == Double.class ) {
+ result = new Double( ((Number) left).doubleValue() - ((Number) right).doubleValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( ((Number) left).floatValue() - ((Number) right).floatValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() - ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() - ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationTypeRef( AnnotationTypeRef typeRef ) {
+ JavaClass javaClass = typeRef.getType().getJavaClass();
+ return javaClass;
+ }
+
+ public Object visitAnnotationValueList( AnnotationValueList valueList ) {
+ List list = new ArrayList();
+
+ for( ListIterator i = valueList.getValueList().listIterator(); i.hasNext(); ) {
+ AnnotationValue value = (AnnotationValue) i.next();
+ Object v = value.accept( this );
+ list.add( v );
+ }
+
+ return list;
+ }
+
+ public Object visitAnnotationAnd( AnnotationAnd and ) {
+ Object left = and.getLeft().accept( this );
+ Object right = and.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() & ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() & ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + and + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationGreaterEquals( AnnotationGreaterEquals greaterEquals ) {
+ Object left = greaterEquals.getLeft().accept( this );
+ Object right = greaterEquals.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() >= ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() >= ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() >= ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() >= ((Number) right).intValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + greaterEquals + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationLessEquals( AnnotationLessEquals lessEquals ) {
+ Object left = lessEquals.getLeft().accept( this );
+ Object right = lessEquals.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() <= ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() <= ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() <= ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() <= ((Number) right).intValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + lessEquals + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationLogicalAnd( AnnotationLogicalAnd and ) {
+ Object left = and.getLeft().accept( this );
+ Object right = and.getRight().accept( this );
+ boolean result;
+
+ if( left instanceof Boolean && right instanceof Boolean ) {
+ result = ((Boolean) left).booleanValue() && ((Boolean) right).booleanValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + and + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationLogicalNot( AnnotationLogicalNot not ) {
+ Object value = not.getValue().accept( this );
+ boolean result;
+
+ if( value instanceof Boolean ) {
+ result = !((Boolean) value).booleanValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + not + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationLogicalOr( AnnotationLogicalOr or ) {
+ Object left = or.getLeft().accept( this );
+ Object right = or.getRight().accept( this );
+ boolean result;
+
+ if( left instanceof Boolean && right instanceof Boolean ) {
+ result = ((Boolean) left).booleanValue() || ((Boolean) right).booleanValue();
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + or + "'." );
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationMinusSign( AnnotationMinusSign sign ) {
+ Object value = sign.getValue().accept( this );
+ Class type = unaryResultType( value );
+ Object result;
+
+ if( type == Integer.class ) {
+ result = new Integer( -((Integer) value).intValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( -((Long) value).longValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( -((Float) value).floatValue() );
+ }
+ else if( type == Double.class ) {
+ result = new Double( -((Double) value).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + sign + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationNot( AnnotationNot not ) {
+ Object value = not.getValue().accept( this );
+ Object type = unaryNumericResultType( value );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ~((Long) value).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ~((Integer) value).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + not + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationOr( AnnotationOr or ) {
+ Object left = or.getLeft().accept( this );
+ Object right = or.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() | ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() | ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + or + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationPlusSign( AnnotationPlusSign sign ) {
+ Object value = sign.getValue().accept( this );
+ Object result;
+
+ if( value instanceof Number ) {
+ result = value;
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + sign + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationRemainder( AnnotationRemainder remainder ) {
+ Object left = remainder.getLeft().accept( this );
+ Object right = remainder.getRight().accept( this );
+ Class type = resultType( left, right );
+ Object result;
+
+ if( type == Double.class ) {
+ result = new Double( ((Number) left).doubleValue() % ((Number) right).doubleValue() );
+ }
+ else if( type == Float.class ) {
+ result = new Float( ((Number) left).floatValue() % ((Number) right).floatValue() );
+ }
+ else if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() % ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() % ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + remainder + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationShiftLeft( AnnotationShiftLeft shiftLeft ) {
+ Object left = shiftLeft.getLeft().accept( this );
+ Object right = shiftLeft.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() << ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() << ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + shiftLeft + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationShiftRight( AnnotationShiftRight shiftRight ) {
+ Object left = shiftRight.getLeft().accept( this );
+ Object right = shiftRight.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() >> ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() >> ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + shiftRight + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationUnsignedShiftRight( AnnotationUnsignedShiftRight shiftRight ) {
+ Object left = shiftRight.getLeft().accept( this );
+ Object right = shiftRight.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() >>> ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() >>> ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + shiftRight + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationEquals( AnnotationEquals annotationEquals ) {
+ Object left = annotationEquals.getLeft().accept( this );
+ Object right = annotationEquals.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() == ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() == ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() == ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() == ((Number) right).intValue();
+ }
+ else {
+ result = (left == right);
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationExclusiveOr( AnnotationExclusiveOr annotationExclusiveOr ) {
+ Object left = annotationExclusiveOr.getLeft().accept( this );
+ Object right = annotationExclusiveOr.getRight().accept( this );
+ Class type = numericResultType( left, right );
+ Object result;
+
+ if( type == Long.class ) {
+ result = new Long( ((Number) left).longValue() ^ ((Number) right).longValue() );
+ }
+ else if( type == Integer.class ) {
+ result = new Integer( ((Number) left).intValue() ^ ((Number) right).intValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + annotationExclusiveOr + "'." );
+ }
+
+ return result;
+ }
+
+ public Object visitAnnotationNotEquals( AnnotationNotEquals annotationNotEquals ) {
+ Object left = annotationNotEquals.getLeft().accept( this );
+ Object right = annotationNotEquals.getRight().accept( this );
+ Class type = resultType( left, right );
+ boolean result;
+
+ if( type == Double.class ) {
+ result = ((Number) left).doubleValue() != ((Number) right).doubleValue();
+ }
+ else if( type == Float.class ) {
+ result = ((Number) left).floatValue() != ((Number) right).floatValue();
+ }
+ else if( type == Long.class ) {
+ result = ((Number) left).longValue() != ((Number) right).longValue();
+ }
+ else if( type == Integer.class ) {
+ result = ((Number) left).intValue() != ((Number) right).intValue();
+ }
+ else {
+ result = (left == right);
+ }
+
+ return result ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object visitAnnotationQuery( AnnotationQuery annotationQuery ) {
+ Object value = annotationQuery.getCondition().accept( this );
+
+ if( value == null || !(value instanceof Boolean) ) {
+ throw new IllegalArgumentException( "Cannot evaluate '" + annotationQuery + "'." );
+ }
+
+ AnnotationValue expression = ((Boolean) value).booleanValue() ? annotationQuery.getTrueExpression()
+ : annotationQuery.getFalseExpression();
+
+ return expression.accept( this );
+ }
+
+ public Object visitAnnotationCast( AnnotationCast annotationCast ) {
+ Object value = annotationCast.getValue().accept( this );
+ String type = annotationCast.getType().getJavaClass().getFullyQualifiedName();
+ Object result;
+
+ if( value instanceof Number ) {
+ Number n = (Number) value;
+
+ if( type.equals( "byte" ) ) {
+ result = new Byte( n.byteValue() );
+ }
+ else if( type.equals( "char" ) ) {
+ result = new Character( (char) n.intValue() );
+ }
+ else if( type.equals( "short" ) ) {
+ result = new Short( n.shortValue() );
+ }
+ else if( type.equals( "int" ) ) {
+ result = new Integer( n.intValue() );
+ }
+ else if( type.equals( "long" ) ) {
+ result = new Long( n.longValue() );
+ }
+ else if( type.equals( "float" ) ) {
+ result = new Float( n.floatValue() );
+ }
+ else if( type.equals( "double" ) ) {
+ result = new Double( n.doubleValue() );
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + annotationCast + "'." );
+ }
+ }
+ else if( value instanceof String ) {
+ if( type.equals( "java.lang.String" ) ) {
+ result = value;
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + annotationCast + "'." );
+ }
+ }
+ else {
+ throw new IllegalArgumentException( "Cannot evaluate '" + annotationCast + "'." );
+ }
+
+ return result;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/annotation/RecursiveAnnotationVisitor.java b/src/java/com/thoughtworks/qdox/model/annotation/RecursiveAnnotationVisitor.java
new file mode 100644
index 0000000..c758e51
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/annotation/RecursiveAnnotationVisitor.java
@@ -0,0 +1,217 @@
+package com.thoughtworks.qdox.model.annotation;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+
+import com.thoughtworks.qdox.model.Annotation;
+
+public class RecursiveAnnotationVisitor implements AnnotationVisitor {
+
+ public Object visitAnnotation( Annotation annotation ) {
+ for( Iterator i = annotation.getPropertyMap().values().iterator(); i.hasNext(); ) {
+ AnnotationValue value = (AnnotationValue) i.next();
+ value.accept( this );
+ }
+
+ return null;
+ }
+
+ public Object visitAnnotationAdd( AnnotationAdd op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationConstant( AnnotationConstant constant ) {
+ return null;
+ }
+
+ public Object visitAnnotationDivide( AnnotationDivide op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationFieldRef( AnnotationFieldRef fieldRef ) {
+ return null;
+ }
+
+ public Object visitAnnotationGreaterThan( AnnotationGreaterThan op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationLessThan( AnnotationLessThan op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationMultiply( AnnotationMultiply op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationParenExpression( AnnotationParenExpression parenExpression ) {
+ parenExpression.getValue().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationSubtract( AnnotationSubtract op ) {
+ op.getLeft().accept( this );
+ op.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationTypeRef( AnnotationTypeRef typeRef ) {
+ return null;
+ }
+
+ public Object visitAnnotationValueList( AnnotationValueList valueList ) {
+ for( ListIterator i = valueList.getValueList().listIterator(); i.hasNext(); ) {
+ AnnotationValue value = (AnnotationValue) i.next();
+ value.accept( this );
+ }
+
+ return null;
+ }
+
+ public Object visitAnnotationAnd( AnnotationAnd and ) {
+ and.getLeft().accept( this );
+ and.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationGreaterEquals( AnnotationGreaterEquals greaterEquals ) {
+ greaterEquals.getLeft().accept( this );
+ greaterEquals.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationLessEquals( AnnotationLessEquals lessEquals ) {
+ lessEquals.getLeft().accept( this );
+ lessEquals.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationLogicalAnd( AnnotationLogicalAnd and ) {
+ and.getLeft().accept( this );
+ and.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationLogicalNot( AnnotationLogicalNot not ) {
+ not.getValue().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationLogicalOr( AnnotationLogicalOr or ) {
+ or.getLeft().accept( this );
+ or.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationMinusSign( AnnotationMinusSign sign ) {
+ sign.getValue().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationNot( AnnotationNot not ) {
+ not.getValue().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationOr( AnnotationOr or ) {
+ or.getLeft().accept( this );
+ or.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationPlusSign( AnnotationPlusSign sign ) {
+ sign.getValue().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationRemainder( AnnotationRemainder remainder ) {
+ remainder.getLeft().accept( this );
+ remainder.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationShiftLeft( AnnotationShiftLeft left ) {
+ left.getLeft().accept( this );
+ left.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationShiftRight( AnnotationShiftRight right ) {
+ right.getLeft().accept( this );
+ right.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationUnsignedShiftRight( AnnotationUnsignedShiftRight right ) {
+ right.getLeft().accept( this );
+ right.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationEquals( AnnotationEquals annotationEquals ) {
+ annotationEquals.getLeft().accept( this );
+ annotationEquals.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationExclusiveOr( AnnotationExclusiveOr annotationExclusiveOr ) {
+ annotationExclusiveOr.getLeft().accept( this );
+ annotationExclusiveOr.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationNotEquals( AnnotationNotEquals annotationNotEquals ) {
+ annotationNotEquals.getLeft().accept( this );
+ annotationNotEquals.getRight().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationQuery( AnnotationQuery annotationQuery ) {
+ annotationQuery.getCondition().accept( this );
+ annotationQuery.getTrueExpression().accept( this );
+ annotationQuery.getFalseExpression().accept( this );
+
+ return null;
+ }
+
+ public Object visitAnnotationCast( AnnotationCast annotationCast ) {
+ annotationCast.getValue().accept( this );
+
+ return null;
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/model/util/OrderedMap.java b/src/java/com/thoughtworks/qdox/model/util/OrderedMap.java
new file mode 100644
index 0000000..67ca32a
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/model/util/OrderedMap.java
@@ -0,0 +1,121 @@
+package com.thoughtworks.qdox.model.util;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This is a simple Map implementation backed by a List of Map.Entry objects.
+ * It has the property that iterators return entries in the order in whick
+ * they were inserted.
+ *
+ * Operations involving searching, including get() and put(), have cost linear
+ * to the size of the map. In other words, avoid this implementation if your
+ * Map might get large.
+ *
+ * If we could assume Java 1.4+, we'd just use java.util.LinkedHashMap
+ * instead of this class. But we can't.
+ *
+ * @author Mike Williams
+ */
+public class OrderedMap extends AbstractMap {
+
+ private Set _entrySet = new OrderedSet();
+
+ public Set entrySet() {
+ return _entrySet;
+ }
+
+ public Object put(Object key, Object value) {
+ Entry existingEntry = getEntryWithKey(key);
+ if (existingEntry == null) {
+ entrySet().add(new Entry(key, value));
+ return null;
+ }
+ Object previousValue = existingEntry.getValue();
+ existingEntry.setValue(value);
+ return previousValue;
+ }
+
+ private Entry getEntryWithKey(Object key) {
+ Iterator i = entrySet().iterator();
+ while (i.hasNext()) {
+ Entry e = (Entry) i.next();
+ if (eq(e.getKey(), key)) {
+ return e;
+ }
+ }
+ return null;
+ }
+
+ static class OrderedSet extends AbstractSet {
+
+ private List _elementList = new LinkedList();
+
+ public int size() {
+ return _elementList.size();
+ }
+
+ public Iterator iterator() {
+ return _elementList.iterator();
+ }
+
+ public boolean add(Object o) {
+ _elementList.add(o);
+ return true;
+ }
+
+ }
+
+ static class Entry implements Map.Entry {
+
+ Object _key;
+ Object _value;
+
+ public Entry(Object key, Object value) {
+ _key = key;
+ _value = value;
+ }
+
+ public Object getKey() {
+ return _key;
+ }
+
+ public Object getValue() {
+ return _value;
+ }
+
+ public Object setValue(Object value) {
+ Object oldValue = _value;
+ _value = value;
+ return oldValue;
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Map.Entry)) {
+ return false;
+ }
+ Map.Entry e = (Map.Entry) o;
+ return eq(_key, e.getKey()) && eq(_value, e.getValue());
+ }
+
+ public int hashCode() {
+ return ((_key == null) ? 0 : _key.hashCode()) ^
+ ((_value == null) ? 0 : _value.hashCode());
+ }
+
+ public String toString() {
+ return _key + "=" + _value;
+ }
+
+ }
+
+ private static boolean eq(Object o1, Object o2) {
+ return (o1 == null ? o2 == null : o1.equals(o2));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/util/TagParser.java b/src/java/com/thoughtworks/qdox/model/util/TagParser.java
similarity index 72%
rename from src/main/java/com/thoughtworks/qdox/model/util/TagParser.java
rename to src/java/com/thoughtworks/qdox/model/util/TagParser.java
index ef2399c..737ab78 100644
--- a/src/main/java/com/thoughtworks/qdox/model/util/TagParser.java
+++ b/src/java/com/thoughtworks/qdox/model/util/TagParser.java
@@ -1,39 +1,12 @@
package com.thoughtworks.qdox.model.util;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import java.io.IOException;
import java.io.StreamTokenizer;
import java.io.StringReader;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
-public final class TagParser {
-
- private TagParser()
- {
- // hide utility class constructor
- }
+public class TagParser {
/**
* Create a StreamTokenizer suitable for parsing the tag text.
@@ -63,8 +36,8 @@ public final class TagParser {
/**
* Extract a Map of named parameters
*/
- public static Map<String, String> parseNamedParameters(String tagValue) {
- Map<String, String> paramMap = new LinkedHashMap<String, String>();
+ public static Map parseNamedParameters(String tagValue) {
+ Map paramMap = new OrderedMap();
StreamTokenizer tokenizer = makeTokenizer(tagValue);
try {
while (tokenizer.nextToken() == StreamTokenizer.TT_WORD) {
@@ -92,7 +65,7 @@ public final class TagParser {
*/
public static String[] parseWords(String tagValue) {
StreamTokenizer tokenizer = makeTokenizer(tagValue);
- List<String> wordList = new ArrayList<String>();
+ ArrayList wordList = new ArrayList();
try {
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
if (tokenizer.sval == null) {
@@ -105,16 +78,18 @@ public final class TagParser {
e.printStackTrace();
throw new RuntimeException("error tokenizing tag");
}
- return wordList.toArray(new String[0]);
+ String[] wordArray = new String[wordList.size()];
+ wordList.toArray(wordArray);
+ return wordArray;
}
/**
* Extract an array of parameters as name or name=value representation
* @since 1.11
*/
- public static List<String> parseParameters(String tagValue) {
+ public static String[] parseParameters(String tagValue) {
StreamTokenizer tokenizer = makeTokenizer(tagValue);
- List<String> wordList = new LinkedList<String>();
+ ArrayList wordList = new ArrayList();
try {
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
StringBuilder param = new StringBuilder();
@@ -141,7 +116,9 @@ public final class TagParser {
e.printStackTrace();
throw new RuntimeException("error tokenizing tag");
}
- return wordList;
+ String[] wordArray = new String[wordList.size()];
+ wordList.toArray(wordArray);
+ return wordArray;
}
}
diff --git a/src/java/com/thoughtworks/qdox/parser/Builder.java b/src/java/com/thoughtworks/qdox/parser/Builder.java
new file mode 100644
index 0000000..44ab4f1
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/Builder.java
@@ -0,0 +1,41 @@
+package com.thoughtworks.qdox.parser;
+
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TagDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+
+public interface Builder {
+
+ void addPackage(PackageDef packageDef);
+
+ void addImport(String importName);
+
+ void addJavaDoc(String text);
+
+ void addJavaDocTag(TagDef def);
+
+ void beginClass(ClassDef def);
+
+ void endClass();
+
+ void beginMethod();
+ void endMethod(MethodDef def);
+
+ void addParameter(FieldDef def);
+
+ void addField(FieldDef def);
+
+ void addAnnotation(Annotation annotation);
+
+ /**
+ * @deprecated
+ */
+ Type createType(String name, int dimensions);
+
+ Type createType(TypeDef name);
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/Lexer.java b/src/java/com/thoughtworks/qdox/parser/Lexer.java
new file mode 100644
index 0000000..15413dd
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/Lexer.java
@@ -0,0 +1,17 @@
+package com.thoughtworks.qdox.parser;
+
+import java.io.IOException;
+
+public interface Lexer {
+
+ int lex() throws IOException;
+
+ String text();
+
+ int getLine();
+
+ int getColumn();
+
+ String getCodeBody();
+
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/ParseException.java b/src/java/com/thoughtworks/qdox/parser/ParseException.java
new file mode 100644
index 0000000..14dc4c2
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/ParseException.java
@@ -0,0 +1,33 @@
+package com.thoughtworks.qdox.parser;
+
+/**
+ * Thrown to indicate an error during parsing
+ */
+public class ParseException extends RuntimeException {
+
+ private int line;
+ private int column;
+ private String errorMessage;
+
+ public ParseException(String message, int line, int column) {
+ errorMessage = message + " @[" + line + "," + column + "] in ";
+ this.line = line;
+ this.column = column;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public void setSourceInfo(String sourceInfo) {
+ errorMessage += sourceInfo;
+ }
+
+ public String getMessage() {
+ return errorMessage;
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java b/src/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java
new file mode 100644
index 0000000..a2fca6d
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java
@@ -0,0 +1,34 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class AnnoDef extends LocatedDef
+{
+ public String name = "";
+ public Map args = new HashMap();
+ public AnnoDef tempAnno = null; // holds an annotation to construct nested values
+
+ public boolean equals(Object obj) {
+ AnnoDef annoDef = (AnnoDef) obj;
+ return annoDef.name.equals(name) && annoDef.args.equals(args);
+ }
+
+ public int hashCode() {
+ return name.hashCode() + args.hashCode();
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append('@');
+ result.append(name);
+ result.append('(');
+ if( !args.isEmpty() ) {
+ for(Iterator i = args.entrySet().iterator(); i.hasNext();) result.append( i.next() + ",");
+ result.deleteCharAt( result.length()-1 );
+ }
+ result.append(')');
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/ClassDef.java b/src/java/com/thoughtworks/qdox/parser/structs/ClassDef.java
new file mode 100644
index 0000000..f54f6d2
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/ClassDef.java
@@ -0,0 +1,52 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ClassDef extends LocatedDef {
+
+ public static final String CLASS = "class";
+ public static final String INTERFACE = "interface";
+ public static final String ENUM = "enum";
+ public static final String ANNOTATION_TYPE = "@interface";
+
+ public String name = "";
+ public Set modifiers = new HashSet();
+ public List typeParams = new ArrayList(); //<TypeVariableDef>
+ public Set extendz = new HashSet();
+ public Set implementz = new HashSet();
+ public String type = CLASS;
+
+ public boolean equals(Object obj) {
+ ClassDef classDef = (ClassDef) obj;
+ return classDef.name.equals(name)
+ && classDef.type == type
+ && classDef.typeParams.equals( typeParams )
+ && classDef.modifiers.equals(modifiers)
+ && classDef.extendz.equals(extendz)
+ && classDef.implementz.equals(implementz);
+ }
+
+ public int hashCode() {
+ return name.hashCode() + type.hashCode() + typeParams.hashCode()+
+ modifiers.hashCode() + extendz.hashCode() +
+ implementz.hashCode();
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(modifiers);
+ result.append(" ");
+ result.append(type);
+ result.append(" ");
+ result.append(name);
+ //typeParams
+ result.append(" extends ");
+ result.append(extendz);
+ result.append(" implements ");
+ result.append(implementz);
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/FieldDef.java b/src/java/com/thoughtworks/qdox/parser/structs/FieldDef.java
new file mode 100644
index 0000000..02252ed
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/FieldDef.java
@@ -0,0 +1,50 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class FieldDef extends LocatedDef {
+ public String name = "";
+ public TypeDef type;
+ public Set modifiers = new HashSet();
+ public int dimensions;
+ public boolean isVarArgs;
+ public String body = "";
+
+ public boolean equals(Object obj) {
+ FieldDef paramDef = (FieldDef) obj;
+ boolean result = paramDef.name.equals(name)
+ && paramDef.modifiers.equals(modifiers)
+ && paramDef.isVarArgs == isVarArgs;
+ if(paramDef.type == null) {
+ result &= (type == null)
+ && paramDef.dimensions == dimensions;
+ }
+ else {
+ result &= (type != null)
+ &&(paramDef.type.name.equals(type.name))
+ &&(paramDef.type.actualArgumentTypes == null ? type.actualArgumentTypes == null: paramDef.type.actualArgumentTypes.equals(type.actualArgumentTypes))
+ &&(paramDef.type.dimensions + paramDef.dimensions == dimensions + type.dimensions);
+ }
+ return result;
+ }
+
+ public int hashCode() {
+ return name.hashCode() + (type != null ? type.hashCode() : 0) +
+ dimensions + modifiers.hashCode() + (isVarArgs ? 79769989 : 0);
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(modifiers);
+ result.append(' ');
+ result.append(type);
+ for (int i = 0; i < dimensions; i++) result.append("[]");
+ result.append(' ');
+ result.append(name);
+ if(body.length() > 0){
+ result.append(" = ").append(body);
+ }
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java b/src/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java
new file mode 100644
index 0000000..d1ffd15
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java
@@ -0,0 +1,7 @@
+package com.thoughtworks.qdox.parser.structs;
+
+public class LocatedDef {
+
+ public int lineNumber;
+
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/MethodDef.java b/src/java/com/thoughtworks/qdox/parser/structs/MethodDef.java
new file mode 100644
index 0000000..d5bf05c
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/MethodDef.java
@@ -0,0 +1,66 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+public class MethodDef extends LocatedDef {
+ public String name = "";
+ public List typeParams; //<TypeVariableDef>
+ public TypeDef returnType;
+ public Set modifiers = new HashSet();
+ public List params = new ArrayList();
+ public Set exceptions = new LinkedHashSet();
+ public boolean constructor = false;
+ public int dimensions;
+ public String body;
+
+ public boolean equals(Object obj) {
+ MethodDef methodDef = (MethodDef) obj;
+ boolean result;
+ result = methodDef.name.equals(name)
+ && methodDef.modifiers.equals(modifiers)
+ && methodDef.params.equals(params)
+ && methodDef.exceptions.equals(exceptions)
+ && methodDef.constructor == constructor;
+ if(methodDef.returnType == null) {
+ result &= (returnType == null)
+ && methodDef.dimensions == dimensions;
+
+ }
+ else {
+ result &= (returnType != null)
+ &&(methodDef.returnType.name.equals(returnType.name))
+ &&(methodDef.returnType.actualArgumentTypes == null ? returnType.actualArgumentTypes == null: methodDef.returnType.actualArgumentTypes.equals(returnType.actualArgumentTypes))
+ &&(methodDef.returnType.dimensions + methodDef.dimensions == dimensions + returnType.dimensions);
+ }
+ return result;
+ }
+
+ public int hashCode() {
+ return name.hashCode() +
+ (returnType != null ? returnType.hashCode() : 0) +
+ modifiers.hashCode() + params.hashCode() +
+ params.hashCode() + exceptions.hashCode() +
+ dimensions + (constructor ? 0 : 1);
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(modifiers);
+ result.append(' ');
+ result.append((returnType != null ? returnType.toString() : ""));
+ for (int i = 0; i < dimensions; i++) result.append("[]");
+ result.append(' ');
+ result.append(name);
+ result.append('(');
+ result.append(params);
+ result.append(')');
+ result.append(" throws ");
+ result.append(exceptions);
+ result.append(body);
+ return result.toString();
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/PackageDef.java b/src/java/com/thoughtworks/qdox/parser/structs/PackageDef.java
new file mode 100644
index 0000000..de9186b
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/PackageDef.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.parser.structs;
+
+public class PackageDef extends LocatedDef {
+
+ public String name = "";
+
+ public PackageDef(String name) {
+ this.name = name;
+ }
+
+ public PackageDef(String name, int lineNumber) {
+ this.name = name;
+ this.lineNumber = lineNumber;
+ }
+
+ public boolean equals(Object obj) {
+ PackageDef packageDef = (PackageDef) obj;
+ return packageDef.name.equals(name);
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/TagDef.java b/src/java/com/thoughtworks/qdox/parser/structs/TagDef.java
new file mode 100644
index 0000000..4200ed1
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/TagDef.java
@@ -0,0 +1,40 @@
+package com.thoughtworks.qdox.parser.structs;
+
+public class TagDef extends LocatedDef {
+
+ public String name;
+ public String text;
+
+ public TagDef(String name, String text, int lineNumber) {
+ this.name = name;
+ this.text = text;
+ this.lineNumber = lineNumber;
+ }
+
+ public TagDef(String name, String text) {
+ this(name, text, -1);
+ }
+
+ public boolean equals(Object obj) {
+ TagDef tagDef = (TagDef) obj;
+ return tagDef.name.equals(name)
+ && tagDef.text.equals(text)
+ && tagDef.lineNumber == lineNumber;
+ }
+
+ public int hashCode() {
+ return name.hashCode() + text.hashCode() + lineNumber;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append('@');
+ result.append(name);
+ result.append(" => \"");
+ result.append(text);
+ result.append("\" @ line ");
+ result.append(lineNumber);
+ return result.toString();
+ }
+
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/TypeDef.java b/src/java/com/thoughtworks/qdox/parser/structs/TypeDef.java
new file mode 100644
index 0000000..9ebcce9
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/TypeDef.java
@@ -0,0 +1,31 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.List;
+
+public class TypeDef {
+
+ public String name;
+ public int dimensions;
+ public List actualArgumentTypes;
+
+ public TypeDef(String name, int dimensions) {
+ this.name = name;
+ this.dimensions = dimensions;
+ }
+
+ public TypeDef(String name) {
+ this(name, 0);
+ }
+
+ public boolean equals(Object obj) {
+ TypeDef typeDef = (TypeDef) obj;
+ return typeDef.name.equals(name)
+ && typeDef.dimensions == dimensions
+ && (typeDef.actualArgumentTypes != null ? typeDef.actualArgumentTypes.equals(actualArgumentTypes): actualArgumentTypes == null);
+ }
+
+ public int hashCode() {
+ return name.hashCode() +
+ dimensions + (actualArgumentTypes == null ? 0 : actualArgumentTypes.hashCode());
+ }
+}
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java b/src/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java
new file mode 100644
index 0000000..723614d
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java
@@ -0,0 +1,21 @@
+package com.thoughtworks.qdox.parser.structs;
+
+import java.util.List;
+
+public class TypeVariableDef {
+
+ public String name;
+ public List bounds;
+
+ public TypeVariableDef(String name) {
+ this.name = name;
+ }
+
+ public TypeVariableDef(String name, List bounds) {
+ super();
+ this.name = name;
+ this.bounds = bounds;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java b/src/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java
new file mode 100644
index 0000000..a155a66
--- /dev/null
+++ b/src/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java
@@ -0,0 +1,35 @@
+package com.thoughtworks.qdox.parser.structs;
+
+/**
+ * WildcardTypeDef must be a subclass of TypeDef, so it can be used in other classes.
+ * But here are only 2 fields interesting: typeDef and wildcardExpressionType
+ * typeDef itself can be generic, so it must be resolvable
+ * wildcardExpressionType is super or extends
+ *
+ *
+ * @author Robert Scholte
+ *
+ */
+public class WildcardTypeDef extends TypeDef {
+
+ private TypeDef typeDef;
+ private String wildcardExpressionType; //super or extends
+
+ public WildcardTypeDef() {
+ super("?");
+ }
+
+ public WildcardTypeDef(TypeDef typeDef, String wildcardExpressionType) {
+ super(typeDef.name, typeDef.dimensions);
+ this.typeDef = typeDef;
+ this.wildcardExpressionType = wildcardExpressionType;
+ }
+
+ public TypeDef getTypeDef() {
+ return typeDef;
+ }
+
+ public String getWildcardExpressionType() {
+ return wildcardExpressionType;
+ }
+}
diff --git a/src/main/java/com/thoughtworks/qdox/tools/QDoxTester.java b/src/java/com/thoughtworks/qdox/tools/QDoxTester.java
similarity index 81%
rename from src/main/java/com/thoughtworks/qdox/tools/QDoxTester.java
rename to src/java/com/thoughtworks/qdox/tools/QDoxTester.java
index 7568357..847490d 100644
--- a/src/main/java/com/thoughtworks/qdox/tools/QDoxTester.java
+++ b/src/java/com/thoughtworks/qdox/tools/QDoxTester.java
@@ -1,23 +1,10 @@
package com.thoughtworks.qdox.tools;
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.directorywalker.DirectoryScanner;
+import com.thoughtworks.qdox.directorywalker.FileVisitor;
+import com.thoughtworks.qdox.directorywalker.SuffixFilter;
+import com.thoughtworks.qdox.parser.ParseException;
import java.io.BufferedReader;
import java.io.File;
@@ -30,12 +17,6 @@ import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import com.thoughtworks.qdox.JavaProjectBuilder;
-import com.thoughtworks.qdox.directorywalker.DirectoryScanner;
-import com.thoughtworks.qdox.directorywalker.FileVisitor;
-import com.thoughtworks.qdox.directorywalker.SuffixFilter;
-import com.thoughtworks.qdox.parser.ParseException;
-
/**
* Tool for testing that QDox can parse Java source code.
*
@@ -59,13 +40,9 @@ public class QDoxTester {
public void checkZipOrJarFile(File file) throws IOException {
ZipFile zipFile = new ZipFile(file);
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ Enumeration entries = zipFile.entries();
while (entries.hasMoreElements()) {
- ZipEntry zipEntry = entries.nextElement();
- if( zipEntry.isDirectory() )
- {
- continue;
- }
+ ZipEntry zipEntry = (ZipEntry) entries.nextElement();
InputStream inputStream = zipFile.getInputStream(zipEntry);
try {
verify(file.getName() + "!" + zipEntry.getName(), inputStream);
@@ -100,8 +77,8 @@ public class QDoxTester {
private void verify(String id, InputStream inputStream) {
try {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSource(new BufferedReader(new InputStreamReader(inputStream)));
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
+ javaDocBuilder.addSource(new BufferedReader(new InputStreamReader(inputStream)));
reporter.success(id);
} catch (ParseException parseException) {
reporter.parseFailure(id, parseException.getLine(), parseException.getColumn(), parseException.getMessage());
diff --git a/src/main/java/com/thoughtworks/qdox/JavaProjectBuilder.java b/src/main/java/com/thoughtworks/qdox/JavaProjectBuilder.java
deleted file mode 100644
index 72b9ce6..0000000
--- a/src/main/java/com/thoughtworks/qdox/JavaProjectBuilder.java
+++ /dev/null
@@ -1,371 +0,0 @@
-package com.thoughtworks.qdox;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Reader;
-import java.net.URL;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import com.thoughtworks.qdox.directorywalker.DirectoryScanner;
-import com.thoughtworks.qdox.directorywalker.FileVisitor;
-import com.thoughtworks.qdox.directorywalker.SuffixFilter;
-import com.thoughtworks.qdox.library.ClassLibraryBuilder;
-import com.thoughtworks.qdox.library.ErrorHandler;
-import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/**
- * This is the improved version of the JavaDocBuilder of QDox 1.x, which has the following tasks:
- * <ul>
- * <li>Provide adders for all kind of resources, such as classloaders, java files and source directories</li>
- * <li>Provide setters to enable the debug-mode for the Lexer and Parser (which are used when parsing sourcefiles) and
- * the encoding
- * <li>Provide getter for retrieving Java Object Models from these libraries, such as JavaSources, JavaClasses and
- * JavaPackages</li>
- * <li>Provide a method to search through all the parsed JavaClasses</li>
- * <li>Provide store and load methods for the JavaProjectBuilder</li>
- * <li>Provide the option to set an ErrorHandler</li>
- * </ul>
- * By default the JavaProjectBuilder will use the {@link com.thoughtworks.qdox.library.SortedClassLibraryBuilder}, which means it doesn't matter in
- * which order you add the resources, first all sources and sourcefolders, followed by the classloaders. Another
- * implementation for the ClassLibraryBuilder is the {@link com.thoughtworks.qdox.library.OrderedClassLibraryBuilder}, which preserves the order in
- * which resources are added. By creating a new JavaProjectBuilder with your own ClassLibraryBuilder you can decide
- * which loading strategy should be used.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class JavaProjectBuilder
-{
- private final ClassLibraryBuilder classLibraryBuilder;
-
- // Constructors
-
- /**
- * Default constructor, which will use the {@link SortedClassLibraryBuilder} implementation
- * and add the default classloaders
- */
- public JavaProjectBuilder()
- {
- this.classLibraryBuilder = new SortedClassLibraryBuilder();
- classLibraryBuilder.appendDefaultClassLoaders();
- }
-
- /**
- * Custom constructor, so another resource loading strategy can be defined
- *
- * @param classLibraryBuilder custom implementation of {@link ClassLibraryBuilder}
- */
- public JavaProjectBuilder( ClassLibraryBuilder classLibraryBuilder )
- {
- this.classLibraryBuilder = classLibraryBuilder;
- }
-
- // Lexer and Parser -setters
-
- /**
- * Enable the debugmode for the Lexer
- *
- * @param debugLexer <code>true</code> to enable, <code>false</code> to disable
- * @return this javaProjectBuilder itself
- */
- public JavaProjectBuilder setDebugLexer( boolean debugLexer )
- {
- classLibraryBuilder.setDebugLexer( debugLexer );
- return this;
- }
-
- /**
- * Enable the debugmode for the Parser
- *
- * @param debugParser <code>true</code> to enable, <code>false</code> to disable
- * @return this javaProjectBuilder itself
- */
- public JavaProjectBuilder setDebugParser( boolean debugParser )
- {
- classLibraryBuilder.setDebugParser( debugParser );
- return this;
- }
-
- /**
- * Sets the encoding when using Files or URL's to parse.
- *
- * @param encoding the encoding to use for {@link java.io.File} or {@link java.net.URL}
- * @return this javaProjectBuilder itself
- */
- public JavaProjectBuilder setEncoding( String encoding )
- {
- classLibraryBuilder.setEncoding( encoding );
- return this;
- }
-
- /**
- * Sets the errorHandler which will be triggered when a parse exception occurs.
- *
- * @param errorHandler the errorHandler
- * @return this javaProjectBuilder itself
- */
- public JavaProjectBuilder setErrorHandler( ErrorHandler errorHandler )
- {
- classLibraryBuilder.setErrorHander( errorHandler );
- return this;
- }
-
- /**
- * Add a java source from a file to this JavaProjectBuilder
- *
- * @param file a java file
- * @return the {@link JavaSource} of the parsed file
- * @throws IOException if file is a directory or can't be read
- */
- public JavaSource addSource( File file )
- throws IOException
- {
- return classLibraryBuilder.addSource( file );
- }
-
- /**
- * Add a java source from a URL to this JavaProjectBuilder
- *
- * @param url the url
- * @return the {@link JavaSource} of the parsed file
- * @throws IOException if the url can't be read
- */
- public JavaSource addSource( URL url ) throws IOException
- {
- return classLibraryBuilder.addSource( url );
- }
-
- /**
- * Add a java source from a Reader to this JavaProjectBuilder
- *
- * @param reader the reader
- * @return the {@link JavaSource} of the parsed reader content
- */
- public JavaSource addSource( Reader reader )
- {
- return classLibraryBuilder.addSource( reader );
- }
-
- /**
- * Add a sourcefolder to this javaprojectbuilder, but don't parse any file. This is a lazy parser. Only if a
- * JavaClass is called it will be searched by matching the package with the folder structure and the classname with
- * the filename
- *
- * @see #addSourceTree(File)
- * @param sourceFolder the sourcefolder to add
- */
- public void addSourceFolder( File sourceFolder )
- {
- classLibraryBuilder.appendSourceFolder( sourceFolder );
- }
-
- /**
- * Add all java files of the {@code directory} recursively
- *
- * @param directory the directory from which all java files should be parsed.
- */
- public void addSourceTree( File directory )
- {
- FileVisitor visitor = new FileVisitor()
- {
- public void visitFile( File badFile )
- {
- throw new RuntimeException( "Cannot read file : " + badFile.getName() );
- }
- };
- addSourceTree( directory, visitor );
- }
-
- /**
- * Add all java files of the {@code directory} recursively
- *
- * @param directory the directory from which all java files should be parsed.
- * @param errorHandler a fileVisitor which will be triggered when an {@link IOException} occurs.
- */
- public void addSourceTree( File directory, final FileVisitor errorHandler )
- {
- DirectoryScanner scanner = new DirectoryScanner( directory );
- scanner.addFilter( new SuffixFilter( ".java" ) );
- scanner.scan( new FileVisitor()
- {
- public void visitFile( File currentFile )
- {
- try
- {
- addSource( currentFile );
- }
- catch ( IOException e )
- {
- errorHandler.visitFile( currentFile );
- }
- }
- } );
- }
-
- /**
- * Add the {@link java.lang.ClassLoader} to this JavaProjectBuilder
- *
- * @param classLoader the classloader to add
- */
- public void addClassLoader( ClassLoader classLoader )
- {
- classLibraryBuilder.appendClassLoader( classLoader );
- }
-
- // Java Object Model -getters
-
- /**
- * Try to retrieve a {@link JavaClass} by its name.
- *
- * @param name the fully qualified name of the class
- * @return the matching JavaClass, otherwise <code>null</code>
- */
- public JavaClass getClassByName( String name )
- {
- return classLibraryBuilder.getClassLibrary().getJavaClass( name );
- }
-
- /**
- * Get all the sources added. This will only contain the sources added as sourcefile, sourcetree or sourcefolder.
- *
- * @return a list of sources
- * @see #addSource(File)
- * @see #addSource(Reader)
- * @see #addSourceFolder(File)
- * @see #addSourceTree(File)
- */
- public Collection<JavaSource> getSources()
- {
- return classLibraryBuilder.getClassLibrary().getJavaSources();
- }
-
- /**
- * Retrieve all classes which were added by sources
- *
- * @return a list of javaclasses, never <code>null</code>
- * @see #addSource(File)
- * @see #addSource(Reader)
- * @see #addSourceFolder(File)
- * @see #addSourceTree(File)
- */
- public Collection<JavaClass> getClasses()
- {
- return classLibraryBuilder.getClassLibrary().getJavaClasses();
- }
-
- /**
- * Try to retrieve a {@link JavaPackage} by its name.
- *
- * @param name the package name
- * @return the matching JavaPackage, otherwise <code>null</code>
- */
- public JavaPackage getPackageByName( String name )
- {
- return classLibraryBuilder.getClassLibrary().getJavaPackage( name );
- }
-
- /**
- * Retrieve all packages which were added by sources.
- *
- * @return a list of packages, never <code>null</code>
- * @see #addSource(File)
- * @see #addSource(Reader)
- * @see #addSourceFolder(File)
- * @see #addSourceTree(File)
- */
- public Collection<JavaPackage> getPackages()
- {
- return classLibraryBuilder.getClassLibrary().getJavaPackages();
- }
-
- // Searcher
-
- public Collection<JavaClass> search( Searcher searcher )
- {
- Collection<JavaClass> result = new LinkedList<JavaClass>();
- Collection<JavaClass> classArray = classLibraryBuilder.getClassLibrary().getJavaClasses();
- for ( JavaClass cls : classArray )
- {
- if ( searcher.eval( cls ) )
- {
- result.add( cls );
- }
- }
- return result;
- }
-
- /**
- * Persist the classLibraryBuilder to a file
- *
- * @param file the file to serialize to
- * @throws IOException Any exception thrown by the underlying OutputStream
- */
- public void save( File file )
- throws IOException
- {
- FileOutputStream fos = new FileOutputStream( file );
- ObjectOutputStream out = new ObjectOutputStream( fos );
- try
- {
- out.writeObject( classLibraryBuilder );
- }
- finally
- {
- out.close();
- fos.close();
- }
- }
-
- /**
- * Note that after loading JavaDocBuilder classloaders need to be re-added.
- */
- public static JavaProjectBuilder load( File file )
- throws IOException
- {
- FileInputStream fis = new FileInputStream( file );
- ObjectInputStream in = new ObjectInputStream( fis );
- JavaProjectBuilder builder;
- try
- {
- ClassLibraryBuilder libraryBuilder = (ClassLibraryBuilder) in.readObject();
- builder = new JavaProjectBuilder( libraryBuilder );
- }
- catch ( ClassNotFoundException e )
- {
- throw new Error( "Couldn't load class : " + e.getMessage() );
- }
- finally
- {
- in.close();
- fis.close();
- }
- return builder;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/Searcher.java b/src/main/java/com/thoughtworks/qdox/Searcher.java
deleted file mode 100644
index 1537299..0000000
--- a/src/main/java/com/thoughtworks/qdox/Searcher.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.model.JavaClass;
-
-/**
- * A filter which evaluates the JavaClass and decides if it's part of the criteria.
- *
- *
- */
-public interface Searcher
-{
-
- /**
- * Evaluate the class
- *
- * @param cls the class to evaluate
- * @return <code>true</code> if this class should be part of the criteria, otherwise <code>false</code>
- */
- boolean eval( JavaClass cls );
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/builder/Builder.java b/src/main/java/com/thoughtworks/qdox/builder/Builder.java
deleted file mode 100644
index e843baa..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/Builder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.thoughtworks.qdox.builder;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.URL;
-
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.parser.expression.ExpressionDef;
-import com.thoughtworks.qdox.parser.structs.AnnoDef;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.parser.structs.FieldDef;
-import com.thoughtworks.qdox.parser.structs.InitDef;
-import com.thoughtworks.qdox.parser.structs.MethodDef;
-import com.thoughtworks.qdox.parser.structs.PackageDef;
-import com.thoughtworks.qdox.parser.structs.TagDef;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-public interface Builder
-{
- void setModelWriterFactory( ModelWriterFactory writer );
-
- void setUrl( URL url );
-
- void addPackage( PackageDef packageDef );
-
- void addImport( String importName );
-
- void addJavaDoc( String text );
- void addJavaDocTag( TagDef def );
-
- void beginClass( ClassDef def );
- void endClass();
-
- void addInitializer( InitDef def );
-
- void beginConstructor();
- void endConstructor( MethodDef def );
-
- void beginMethod();
- void endMethod( MethodDef def );
-
- void beginField( FieldDef def );
- void endField();
-
- void addParameter( FieldDef def );
-
- void addAnnotation( AnnoDef annotation );
-
- void addArgument( ExpressionDef argument );
-
- JavaSource getSource();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/builder/ModelBuilderFactory.java b/src/main/java/com/thoughtworks/qdox/builder/ModelBuilderFactory.java
deleted file mode 100644
index 1765716..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/ModelBuilderFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.builder;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-import com.thoughtworks.qdox.builder.impl.ModelBuilder;
-import com.thoughtworks.qdox.library.ClassLibrary;
-
-/**
- * The ModelBuilderFactory for constructing ModelBuilders
- *
- * @author Robert Scholte
- *
- */
-public interface ModelBuilderFactory extends Serializable
-{
- /**
- * Return a new instance of a ModelBuilder.
- * Parsers will use exactly one instance per java source file or class.
- *
- * @param library the classLibrary
- * @return a new ModelBuilder
- */
- ModelBuilder newInstance( ClassLibrary library );
-}
diff --git a/src/main/java/com/thoughtworks/qdox/builder/TypeAssembler.java b/src/main/java/com/thoughtworks/qdox/builder/TypeAssembler.java
deleted file mode 100644
index 04ec986..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/TypeAssembler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.thoughtworks.qdox.builder;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.impl.DefaultJavaParameterizedType;
-import com.thoughtworks.qdox.model.impl.DefaultJavaWildcardType;
-import com.thoughtworks.qdox.model.impl.DefaultJavaWildcardType.BoundType;
-import com.thoughtworks.qdox.model.impl.JavaClassParent;
-import com.thoughtworks.qdox.model.impl.DefaultJavaType;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-import com.thoughtworks.qdox.parser.structs.WildcardTypeDef;
-
-/**
- * An assembler to transform a {@link TypeDef} to a {@link DefaultJavaType}
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public final class TypeAssembler
-{
- private TypeAssembler()
- {
- }
-
- /**
- * this one is specific for those cases where dimensions can be part of both the type and identifier i.e. private
- * String[] matrix[]; //field public abstract String[] getMatrix[](); //method
- *
- * @param typeDef
- * @param dimensions
- * @param context
- * @return the Type
- */
- public static DefaultJavaType createUnresolved( TypeDef typeDef, int dimensions, JavaClassParent context )
- {
- DefaultJavaType result;
- if ( typeDef instanceof WildcardTypeDef )
- {
- WildcardTypeDef wildcard = (WildcardTypeDef) typeDef;
- if( wildcard.getTypeDef() != null )
- {
- JavaType type = createUnresolved( wildcard.getTypeDef(), context );
- DefaultJavaWildcardType.BoundType boundType = null;
- if( "extends".equals( wildcard.getWildcardExpressionType() ) )
- {
- boundType = BoundType.EXTENDS;
- }
- else if( "super".equals( wildcard.getWildcardExpressionType() ) )
- {
- boundType = BoundType.SUPER;
- }
- result = new DefaultJavaWildcardType( type , boundType );
- }
- else
- {
- result = new DefaultJavaWildcardType();
- }
- }
- else
- {
- DefaultJavaParameterizedType typeResult = new DefaultJavaParameterizedType( null, typeDef.getName(), typeDef.getDimensions() + dimensions, context );
- if ( typeDef.getActualArgumentTypes() != null && !typeDef.getActualArgumentTypes().isEmpty() )
- {
- List<JavaType> actualArgumentTypes = new LinkedList<JavaType>();
- for ( TypeDef actualArgType : typeDef.getActualArgumentTypes() )
- {
- actualArgumentTypes.add( TypeAssembler.createUnresolved( actualArgType, context ) );
- }
- typeResult.setActualArgumentTypes( actualArgumentTypes );
- }
- result = typeResult;
- }
- return result;
- }
-
- /**
- * @param typeDef the TypeDef
- * @param context the context
- * @return the Type
- */
- public static DefaultJavaType createUnresolved( TypeDef typeDef, JavaClassParent context )
- {
- return createUnresolved( typeDef, 0, context );
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java b/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java
deleted file mode 100644
index 32490b8..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java
+++ /dev/null
@@ -1,459 +0,0 @@
-package com.thoughtworks.qdox.builder.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import com.thoughtworks.qdox.builder.TypeAssembler;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.expression.Add;
-import com.thoughtworks.qdox.model.expression.And;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.AnnotationValueList;
-import com.thoughtworks.qdox.model.expression.Assignment;
-import com.thoughtworks.qdox.model.expression.Cast;
-import com.thoughtworks.qdox.model.expression.Constant;
-import com.thoughtworks.qdox.model.expression.Divide;
-import com.thoughtworks.qdox.model.expression.Equals;
-import com.thoughtworks.qdox.model.expression.ExclusiveOr;
-import com.thoughtworks.qdox.model.expression.Expression;
-import com.thoughtworks.qdox.model.expression.FieldRef;
-import com.thoughtworks.qdox.model.expression.GreaterEquals;
-import com.thoughtworks.qdox.model.expression.GreaterThan;
-import com.thoughtworks.qdox.model.expression.LessEquals;
-import com.thoughtworks.qdox.model.expression.LessThan;
-import com.thoughtworks.qdox.model.expression.LogicalAnd;
-import com.thoughtworks.qdox.model.expression.LogicalNot;
-import com.thoughtworks.qdox.model.expression.LogicalOr;
-import com.thoughtworks.qdox.model.expression.MinusSign;
-import com.thoughtworks.qdox.model.expression.Multiply;
-import com.thoughtworks.qdox.model.expression.Not;
-import com.thoughtworks.qdox.model.expression.NotEquals;
-import com.thoughtworks.qdox.model.expression.Or;
-import com.thoughtworks.qdox.model.expression.ParenExpression;
-import com.thoughtworks.qdox.model.expression.PlusSign;
-import com.thoughtworks.qdox.model.expression.PostDecrement;
-import com.thoughtworks.qdox.model.expression.PostIncrement;
-import com.thoughtworks.qdox.model.expression.PreDecrement;
-import com.thoughtworks.qdox.model.expression.PreIncrement;
-import com.thoughtworks.qdox.model.expression.Query;
-import com.thoughtworks.qdox.model.expression.Remainder;
-import com.thoughtworks.qdox.model.expression.ShiftLeft;
-import com.thoughtworks.qdox.model.expression.ShiftRight;
-import com.thoughtworks.qdox.model.expression.Subtract;
-import com.thoughtworks.qdox.model.expression.TypeRef;
-import com.thoughtworks.qdox.model.expression.UnsignedShiftRight;
-import com.thoughtworks.qdox.model.impl.AbstractBaseJavaEntity;
-import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
-import com.thoughtworks.qdox.parser.expression.AddDef;
-import com.thoughtworks.qdox.parser.expression.AndDef;
-import com.thoughtworks.qdox.parser.expression.AssignmentDef;
-import com.thoughtworks.qdox.parser.expression.CastDef;
-import com.thoughtworks.qdox.parser.expression.ConstantDef;
-import com.thoughtworks.qdox.parser.expression.CreatorDef;
-import com.thoughtworks.qdox.parser.expression.DivideDef;
-import com.thoughtworks.qdox.parser.expression.ElemValueDef;
-import com.thoughtworks.qdox.parser.expression.ElemValueListDef;
-import com.thoughtworks.qdox.parser.expression.ElemValueTransformer;
-import com.thoughtworks.qdox.parser.expression.EqualsDef;
-import com.thoughtworks.qdox.parser.expression.ExclusiveOrDef;
-import com.thoughtworks.qdox.parser.expression.FieldRefDef;
-import com.thoughtworks.qdox.parser.expression.GreaterEqualsDef;
-import com.thoughtworks.qdox.parser.expression.GreaterThanDef;
-import com.thoughtworks.qdox.parser.expression.LessEqualsDef;
-import com.thoughtworks.qdox.parser.expression.LessThanDef;
-import com.thoughtworks.qdox.parser.expression.LogicalAndDef;
-import com.thoughtworks.qdox.parser.expression.LogicalNotDef;
-import com.thoughtworks.qdox.parser.expression.LogicalOrDef;
-import com.thoughtworks.qdox.parser.expression.MethodInvocationDef;
-import com.thoughtworks.qdox.parser.expression.MinusSignDef;
-import com.thoughtworks.qdox.parser.expression.MultiplyDef;
-import com.thoughtworks.qdox.parser.expression.NotDef;
-import com.thoughtworks.qdox.parser.expression.NotEqualsDef;
-import com.thoughtworks.qdox.parser.expression.OrDef;
-import com.thoughtworks.qdox.parser.expression.ParenExpressionDef;
-import com.thoughtworks.qdox.parser.expression.PlusSignDef;
-import com.thoughtworks.qdox.parser.expression.PostDecrementDef;
-import com.thoughtworks.qdox.parser.expression.PostIncrementDef;
-import com.thoughtworks.qdox.parser.expression.PreDecrementDef;
-import com.thoughtworks.qdox.parser.expression.PreIncrementDef;
-import com.thoughtworks.qdox.parser.expression.QueryDef;
-import com.thoughtworks.qdox.parser.expression.RemainderDef;
-import com.thoughtworks.qdox.parser.expression.ShiftLeftDef;
-import com.thoughtworks.qdox.parser.expression.ShiftRightDef;
-import com.thoughtworks.qdox.parser.expression.SubtractDef;
-import com.thoughtworks.qdox.parser.expression.TypeRefDef;
-import com.thoughtworks.qdox.parser.expression.UnsignedShiftRightDef;
-import com.thoughtworks.qdox.parser.structs.AnnoDef;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-
-public class DefaultJavaAnnotationAssembler
- implements ElemValueTransformer<AnnotationValue>
-{
-
- private AbstractBaseJavaEntity parent;
-
- public DefaultJavaAnnotationAssembler( JavaAnnotatedElement parent )
- {
- this.parent = (AbstractBaseJavaEntity) parent;
- }
-
- public DefaultJavaAnnotation assemble( AnnoDef annoDef ) {
- DefaultJavaAnnotation annotation =
- new DefaultJavaAnnotation( createType( annoDef.getTypeDef(), 0 ), annoDef.getLineNumber() );
- for ( Map.Entry<String, ElemValueDef> annoVal : annoDef.getArgs().entrySet() )
- {
- annotation.setProperty( annoVal.getKey(), annoVal.getValue().transform( this ) );
- }
- annotation.setContext( (JavaAnnotatedElement) parent );
- return annotation;
- }
-
- public Expression assemble( ElemValueDef annoDef )
- {
- return annoDef.transform( this );
- }
-
-
- private JavaClass createType( TypeDef typeDef, int dimensions )
- {
- if ( typeDef == null )
- {
- return null;
- }
- return TypeAssembler.createUnresolved( typeDef,
- dimensions,
- parent.getParentClass() != null ? parent.getParentClass()
- : parent.getSource() );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( AnnoDef annoDef )
- {
- return assemble( annoDef);
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ElemValueListDef elemValueListDef )
- {
- List<AnnotationValue> parsedList = new LinkedList<AnnotationValue>();
- for ( ElemValueDef val : elemValueListDef.getValueList() )
- {
- parsedList.add( val.transform( this ) );
- }
- return new AnnotationValueList( parsedList );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( AddDef annotationAdd )
- {
- AnnotationValue left = annotationAdd.getLeft().transform( this );
- AnnotationValue right = annotationAdd.getRight().transform( this );
- return new Add( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( AndDef annotationAnd )
- {
- AnnotationValue left = annotationAnd.getLeft().transform( this );
- AnnotationValue right = annotationAnd.getRight().transform( this );
- return new And( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( DivideDef annotationDivide )
- {
- AnnotationValue left = annotationDivide.getLeft().transform( this );
- AnnotationValue right = annotationDivide.getRight().transform( this );
- return new Divide( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( EqualsDef annotationEquals )
- {
- AnnotationValue left = annotationEquals.getLeft().transform( this );
- AnnotationValue right = annotationEquals.getRight().transform( this );
- return new Equals( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ExclusiveOrDef annotationExclusiveOr )
- {
- AnnotationValue left = annotationExclusiveOr.getLeft().transform( this );
- AnnotationValue right = annotationExclusiveOr.getRight().transform( this );
- return new ExclusiveOr( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( GreaterEqualsDef annotationGreaterEquals )
- {
- AnnotationValue left = annotationGreaterEquals.getLeft().transform( this );
- AnnotationValue right = annotationGreaterEquals.getRight().transform( this );
- return new GreaterEquals( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( GreaterThanDef annotationGreaterThan )
- {
- AnnotationValue left = annotationGreaterThan.getLeft().transform( this );
- AnnotationValue right = annotationGreaterThan.getRight().transform( this );
- return new GreaterThan( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( LessEqualsDef annotationLessEquals )
- {
- AnnotationValue left = annotationLessEquals.getLeft().transform( this );
- AnnotationValue right = annotationLessEquals.getRight().transform( this );
- return new LessEquals( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( LessThanDef annotationLessThan )
- {
- AnnotationValue left = annotationLessThan.getLeft().transform( this );
- AnnotationValue right = annotationLessThan.getRight().transform( this );
- return new LessThan( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( LogicalAndDef annotationLogicalAnd )
- {
- AnnotationValue left = annotationLogicalAnd.getLeft().transform( this );
- AnnotationValue right = annotationLogicalAnd.getRight().transform( this );
- return new LogicalAnd( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( LogicalOrDef annotationLogicalOr )
- {
- AnnotationValue left = annotationLogicalOr.getLeft().transform( this );
- AnnotationValue right = annotationLogicalOr.getRight().transform( this );
- return new LogicalOr( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( MultiplyDef annotationMultiply )
- {
- AnnotationValue left = annotationMultiply.getLeft().transform( this );
- AnnotationValue right = annotationMultiply.getRight().transform( this );
- return new Multiply( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( NotEqualsDef annotationNotEquals )
- {
- AnnotationValue left = annotationNotEquals.getLeft().transform( this );
- AnnotationValue right = annotationNotEquals.getRight().transform( this );
- return new NotEquals( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( OrDef annotationOr )
- {
- AnnotationValue left = annotationOr.getLeft().transform( this );
- AnnotationValue right = annotationOr.getRight().transform( this );
- return new Or( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( RemainderDef annotationRemainder )
- {
- AnnotationValue left = annotationRemainder.getLeft().transform( this );
- AnnotationValue right = annotationRemainder.getRight().transform( this );
- return new Remainder( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ShiftLeftDef annotationShiftLeft )
- {
- AnnotationValue left = annotationShiftLeft.getLeft().transform( this );
- AnnotationValue right = annotationShiftLeft.getRight().transform( this );
- return new ShiftLeft( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ShiftRightDef annotationShiftRight )
- {
- AnnotationValue left = annotationShiftRight.getLeft().transform( this );
- AnnotationValue right = annotationShiftRight.getRight().transform( this );
- return new ShiftRight( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( SubtractDef annotationSubtract )
- {
- AnnotationValue left = annotationSubtract.getLeft().transform( this );
- AnnotationValue right = annotationSubtract.getRight().transform( this );
- return new Subtract( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( UnsignedShiftRightDef annotationUnsignedShiftRight )
- {
- AnnotationValue left = annotationUnsignedShiftRight.getLeft().transform( this );
- AnnotationValue right = annotationUnsignedShiftRight.getRight().transform( this );
- return new UnsignedShiftRight( left, right );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( CastDef annotationCast )
- {
- JavaType type = createType( annotationCast.getTypeDef(), annotationCast.getTypeDef().getDimensions() );
- AnnotationValue value = annotationCast.getElemDef().transform( this );
- return new Cast( type, value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ConstantDef annotationConstant )
- {
- AnnotationValue result;
- String image = annotationConstant.getValue();
- Class<?> type = annotationConstant.getType();
- if ( type == Integer.class )
- {
- result = Constant.newIntegerLiteral( image );
- }
- else if ( type == String.class )
- {
- result = Constant.newStringLiteral( image );
- }
- else if ( type == Boolean.class )
- {
- result = Constant.newBooleanLiteral( image );
- }
- else if ( type == Character.class )
- {
- result = Constant.newCharacterLiteral( image );
- }
- else if ( type == Float.class )
- {
- result = Constant.newFloatingPointLiteral( image );
- }
- else
- {
- result = null; // unknown??
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( FieldRefDef annotationFieldRef )
- {
- FieldRef result;
- String name = annotationFieldRef.getName();
- result = new FieldRef( name );
- result.setContext( (JavaAnnotatedElement) parent );
- return result;
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( LogicalNotDef annotationLogicalNot )
- {
- AnnotationValue value = annotationLogicalNot.getElemValueDef().transform( this );
- return new LogicalNot( value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( MinusSignDef annotationMinusSign )
- {
- AnnotationValue value = annotationMinusSign.getElemValueDef().transform( this );
- return new MinusSign( value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( NotDef annotationNot )
- {
- AnnotationValue value = annotationNot.getElemValueDef().transform( this );
- return new Not( value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( ParenExpressionDef annotationParenExpression )
- {
- AnnotationValue value = annotationParenExpression.getElemValueDef().transform( this );
- return new ParenExpression( value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( PlusSignDef annotationPlusSign )
- {
- AnnotationValue value = annotationPlusSign.getElemValueDef().transform( this );
- return new PlusSign( value );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( QueryDef annotationQuery )
- {
- AnnotationValue condition = annotationQuery.getCondition().transform( this );
- AnnotationValue trueExpression = annotationQuery.getTrueExpression().transform( this );
- AnnotationValue falseExpression = annotationQuery.getFalseExpression().transform( this );
- return new Query( condition, trueExpression, falseExpression );
- }
-
- /** {@inheritDoc} */
- public AnnotationValue transform( TypeRefDef annotationTypeRef )
- {
- JavaType type = createType( annotationTypeRef.getTypeDef(), annotationTypeRef.getTypeDef().getDimensions() );
- return new TypeRef( type );
- }
-
- public AnnotationValue transform( AssignmentDef assignmentDef )
- {
- Expression leftHandSide = assignmentDef.getLetfHandSide().transform( this );
- String operator = assignmentDef.getOperator();
- Expression assignmentExpression = assignmentDef.getAssignmentExpression().transform( this );
- return new Assignment( leftHandSide, operator, assignmentExpression );
- }
-
- public AnnotationValue transform( PreIncrementDef preIncrementDef )
- {
- return new PreIncrement( preIncrementDef.getElemValueDef().transform( this ) );
- }
-
- public AnnotationValue transform( PreDecrementDef preDecrementDef )
- {
- return new PreDecrement( preDecrementDef.getElemValueDef().transform( this ) );
- }
-
- public AnnotationValue transform( PostIncrementDef postIncrement )
- {
- return new PostIncrement( postIncrement.getElemValueDef().transform( this ) );
- }
-
- public AnnotationValue transform( PostDecrementDef postDecrementDef )
- {
- return new PostDecrement( postDecrementDef.getElemValueDef().transform( this ) );
- }
-
- public AnnotationValue transform( MethodInvocationDef methodInvocationDef )
- {
- return null;
- }
-
- public AnnotationValue transform( CreatorDef newCreator )
- {
- return null;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java b/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java
deleted file mode 100644
index 51d7a44..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java
+++ /dev/null
@@ -1,986 +0,0 @@
-package com.thoughtworks.qdox.builder.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.expression.Add;
-import com.thoughtworks.qdox.model.expression.And;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.AnnotationValueList;
-import com.thoughtworks.qdox.model.expression.Assignment;
-import com.thoughtworks.qdox.model.expression.Cast;
-import com.thoughtworks.qdox.model.expression.Constant;
-import com.thoughtworks.qdox.model.expression.Divide;
-import com.thoughtworks.qdox.model.expression.Equals;
-import com.thoughtworks.qdox.model.expression.ExclusiveOr;
-import com.thoughtworks.qdox.model.expression.ExpressionVisitor;
-import com.thoughtworks.qdox.model.expression.FieldRef;
-import com.thoughtworks.qdox.model.expression.GreaterEquals;
-import com.thoughtworks.qdox.model.expression.GreaterThan;
-import com.thoughtworks.qdox.model.expression.LessEquals;
-import com.thoughtworks.qdox.model.expression.LessThan;
-import com.thoughtworks.qdox.model.expression.LogicalAnd;
-import com.thoughtworks.qdox.model.expression.LogicalNot;
-import com.thoughtworks.qdox.model.expression.LogicalOr;
-import com.thoughtworks.qdox.model.expression.MethodInvocation;
-import com.thoughtworks.qdox.model.expression.MinusSign;
-import com.thoughtworks.qdox.model.expression.Multiply;
-import com.thoughtworks.qdox.model.expression.Not;
-import com.thoughtworks.qdox.model.expression.NotEquals;
-import com.thoughtworks.qdox.model.expression.Or;
-import com.thoughtworks.qdox.model.expression.ParenExpression;
-import com.thoughtworks.qdox.model.expression.PlusSign;
-import com.thoughtworks.qdox.model.expression.PostDecrement;
-import com.thoughtworks.qdox.model.expression.PostIncrement;
-import com.thoughtworks.qdox.model.expression.PreDecrement;
-import com.thoughtworks.qdox.model.expression.PreIncrement;
-import com.thoughtworks.qdox.model.expression.Query;
-import com.thoughtworks.qdox.model.expression.Remainder;
-import com.thoughtworks.qdox.model.expression.ShiftLeft;
-import com.thoughtworks.qdox.model.expression.ShiftRight;
-import com.thoughtworks.qdox.model.expression.Subtract;
-import com.thoughtworks.qdox.model.expression.TypeRef;
-import com.thoughtworks.qdox.model.expression.UnsignedShiftRight;
-
-/**
- * Visitor that evaluates annotation expressions.
- * <p>
- * Users of this class must override {@link EvaluatingVisitor#getFieldReferenceValue(JavaField)} to return values for
- * referenced fields.
- *
- * @author Jochen Kuhnle
- */
-public class EvaluatingVisitor
- implements ExpressionVisitor
-{
-
- public Object getValue( JavaAnnotation annotation, String property )
- {
- Object result = null;
- AnnotationValue value = annotation.getProperty( property );
-
- if ( value != null )
- {
- result = value.accept( this );
- }
-
- return result;
- }
-
- public List<?> getListValue( JavaAnnotation annotation, String property )
- {
- Object value = getValue( annotation, property );
- List<?> list = null;
-
- if ( value != null )
- {
- if ( value instanceof List )
- {
- list = (List<?>) value;
- }
- else
- {
- list = Collections.singletonList( value );
- }
- }
- return list;
- }
-
- /**
- * Return the result type of a binary operator
- * <p>
- * Performs binary numeric promotion as specified in the Java Language Specification,
- *
- * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170983">section
- * 5.6.1<a>
- */
- protected static Class<?> resultType( final Object left, final Object right )
- {
- Class<?> type = void.class;
-
- if ( left instanceof String || right instanceof String )
- {
- type = String.class;
- }
- else if ( left instanceof Number && right instanceof Number )
- {
- if ( left instanceof Double || right instanceof Double )
- {
- type = Double.class;
- }
- else if ( left instanceof Float || right instanceof Float )
- {
- type = Float.class;
- }
- else if ( left instanceof Long || right instanceof Long )
- {
- type = Long.class;
- }
- else
- {
- type = Integer.class;
- }
- }
-
- return type;
- }
-
- /**
- * Return the numeric result type of a binary operator
- * <p>
- * Performs binary numeric promotion as specified in the Java Language Specification,
- *
- * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170983">section
- * 5.6.1<a>
- */
- protected static Class<?> numericResultType( final Object left, final Object right )
- {
- Class<?> type = void.class;
-
- if ( left instanceof Number && right instanceof Number )
- {
- if ( left instanceof Long || right instanceof Long )
- {
- type = Long.class;
- }
- else if ( left instanceof Integer || right instanceof Integer )
- {
- type = Integer.class;
- }
- }
-
- return type;
- }
-
- /**
- * Return the result type of an unary operator
- * <p>
- * Performs unary numeric promotion as specified in the Java Language Specification,
- *
- * @see <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#170952">section
- * 5.6.2<a>
- */
- protected static Class<?> unaryNumericResultType( final Object value )
- {
- Class<?> type = void.class;
-
- if ( value instanceof Byte || value instanceof Short || value instanceof Character || value instanceof Integer )
- {
- type = Integer.class;
- }
- else if ( value instanceof Long )
- {
- type = Long.class;
- }
-
- return type;
- }
-
- protected static Class<?> unaryResultType( final Object value )
- {
- Class<?> type = unaryNumericResultType( value );
-
- if ( type == void.class )
- {
- if ( value instanceof Float )
- {
- type = Float.class;
- }
- else if ( value instanceof Double )
- {
- type = Double.class;
- }
- }
-
- return type;
- }
-
- public Object visit( JavaAnnotation annotation ) throws UnsupportedOperationException
- {
- throw new UnsupportedOperationException( "Illegal annotation value '" + annotation + "'." );
- }
-
- public Object visit( Add op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- Object result;
-
- if ( type == String.class )
- {
- result = left.toString() + right.toString();
- }
- else if ( type == Double.class )
- {
- result = Double.valueOf( ( (Number) left ).doubleValue() + ( (Number) right ).doubleValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( ( (Number) left ).floatValue() + ( (Number) right ).floatValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() + ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
-
- result = Integer.valueOf( ( (Number) left ).intValue() + ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result;
- }
-
- public Object visit( Constant constant )
- {
- return constant.getValue();
- }
-
- public Object visit( Divide op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- Object result;
-
- if ( type == Double.class )
- {
- result = Double.valueOf( ( (Number) left ).doubleValue() / ( (Number) right ).doubleValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( ( (Number) left ).floatValue() / ( (Number) right ).floatValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() / ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() / ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result;
- }
-
- public Object visit( FieldRef fieldRef )
- {
- JavaField javaField = fieldRef.getField();
-
- if ( javaField == null )
- {
- throw new IllegalArgumentException( "Cannot resolve field reference '" + fieldRef + "'." );
- }
-
- if ( !(javaField.isFinal() && javaField.isStatic() ) )
- {
- throw new IllegalArgumentException( "Field reference '" + fieldRef + "' must be static and final." );
- }
-
- return getFieldReferenceValue( javaField );
- }
-
- protected Object getFieldReferenceValue( JavaField javaField ) {
- throw new UnsupportedOperationException("getFieldReferenceValue(JavaField) has not been implemented.");
- }
-
- public Object visit( GreaterThan op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() > ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() > ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() > ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() > ( (Number) right ).intValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( LessThan op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() < ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() < ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() < ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() < ( (Number) right ).intValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( Multiply op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- Object result;
-
- if ( type == Double.class )
- {
- result = Double.valueOf( ( (Number) left ).doubleValue() * ( (Number) right ).doubleValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( ( (Number) left ).floatValue() * ( (Number) right ).floatValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() * ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() * ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result;
- }
-
- public Object visit( ParenExpression parenExpression )
- {
- return parenExpression.getValue().accept( this );
- }
-
- public Object visit( Subtract op )
- {
- Object left = op.getLeft().accept( this );
- Object right = op.getRight().accept( this );
- Class<?> type = resultType( left, right );
- Object result;
-
- if ( type == Double.class )
- {
- result = Double.valueOf( ( (Number) left ).doubleValue() - ( (Number) right ).doubleValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( ( (Number) left ).floatValue() - ( (Number) right ).floatValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() - ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() - ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + op + "'." );
- }
-
- return result;
- }
-
- public JavaType visit( TypeRef typeRef )
- {
- return typeRef.getType();
- }
-
- public List<?> visit( AnnotationValueList valueList )
- {
- List<Object> list = new LinkedList<Object>();
-
- for ( AnnotationValue value : valueList.getValueList() )
- {
- Object v = value.accept( this );
- list.add( v );
- }
-
- return list;
- }
-
- public Object visit( And and )
- {
- Object left = and.getLeft().accept( this );
- Object right = and.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() & ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() & ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + and + "'." );
- }
-
- return result;
- }
-
- public Object visit( GreaterEquals greaterEquals )
- {
- Object left = greaterEquals.getLeft().accept( this );
- Object right = greaterEquals.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() >= ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() >= ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() >= ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() >= ( (Number) right ).intValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + greaterEquals + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( LessEquals lessEquals )
- {
- Object left = lessEquals.getLeft().accept( this );
- Object right = lessEquals.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() <= ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() <= ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() <= ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() <= ( (Number) right ).intValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + lessEquals + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( LogicalAnd and )
- {
- Object left = and.getLeft().accept( this );
- Object right = and.getRight().accept( this );
- boolean result;
-
- if ( left instanceof Boolean && right instanceof Boolean )
- {
- result = ( (Boolean) left ).booleanValue() && ( (Boolean) right ).booleanValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + and + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( LogicalNot not )
- {
- Object value = not.getValue().accept( this );
- boolean result;
-
- if ( value instanceof Boolean )
- {
- result = !( (Boolean) value ).booleanValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + not + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( LogicalOr or )
- {
- Object left = or.getLeft().accept( this );
- Object right = or.getRight().accept( this );
- boolean result;
-
- if ( left instanceof Boolean && right instanceof Boolean )
- {
- result = ( (Boolean) left ).booleanValue() || ( (Boolean) right ).booleanValue();
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + or + "'." );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( MinusSign sign )
- {
- Object value = sign.getValue().accept( this );
- Class<?> type = unaryResultType( value );
- Object result;
-
- if ( type == Integer.class )
- {
- result = Integer.valueOf( -( (Integer) value ).intValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( -( (Long) value ).longValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( -( (Float) value ).floatValue() );
- }
- else if ( type == Double.class )
- {
- result = Double.valueOf( -( (Double) value ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + sign + "'." );
- }
-
- return result;
- }
-
- public Object visit( Not not )
- {
- Object value = not.getValue().accept( this );
- Object type = unaryNumericResultType( value );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ~( (Long) value ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ~( (Integer) value ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + not + "'." );
- }
-
- return result;
- }
-
- public Object visit( Or or )
- {
- Object left = or.getLeft().accept( this );
- Object right = or.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() | ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() | ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + or + "'." );
- }
-
- return result;
- }
-
- public Object visit( PlusSign sign )
- {
- Object value = sign.getValue().accept( this );
- Object result;
-
- if ( value instanceof Number )
- {
- result = value;
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + sign + "'." );
- }
-
- return result;
- }
-
- public Object visit( Remainder remainder )
- {
- Object left = remainder.getLeft().accept( this );
- Object right = remainder.getRight().accept( this );
- Class<?> type = resultType( left, right );
- Object result;
-
- if ( type == Double.class )
- {
- result = Double.valueOf( ( (Number) left ).doubleValue() % ( (Number) right ).doubleValue() );
- }
- else if ( type == Float.class )
- {
- result = Float.valueOf( ( (Number) left ).floatValue() % ( (Number) right ).floatValue() );
- }
- else if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() % ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() % ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + remainder + "'." );
- }
-
- return result;
- }
-
- public Object visit( ShiftLeft shiftLeft )
- {
- Object left = shiftLeft.getLeft().accept( this );
- Object right = shiftLeft.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() << ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() << ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + shiftLeft + "'." );
- }
-
- return result;
- }
-
- public Object visit( ShiftRight shiftRight )
- {
- Object left = shiftRight.getLeft().accept( this );
- Object right = shiftRight.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() >> ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() >> ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + shiftRight + "'." );
- }
-
- return result;
- }
-
- public Object visit( UnsignedShiftRight shiftRight )
- {
- Object left = shiftRight.getLeft().accept( this );
- Object right = shiftRight.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() >>> ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() >>> ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + shiftRight + "'." );
- }
-
- return result;
- }
-
- public Object visit( Equals annotationEquals )
- {
- Object left = annotationEquals.getLeft().accept( this );
- Object right = annotationEquals.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() == ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() == ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() == ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() == ( (Number) right ).intValue();
- }
- else
- {
- result = ( left == right );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( ExclusiveOr annotationExclusiveOr )
- {
- Object left = annotationExclusiveOr.getLeft().accept( this );
- Object right = annotationExclusiveOr.getRight().accept( this );
- Class<?> type = numericResultType( left, right );
- Object result;
-
- if ( type == Long.class )
- {
- result = Long.valueOf( ( (Number) left ).longValue() ^ ( (Number) right ).longValue() );
- }
- else if ( type == Integer.class )
- {
- result = Integer.valueOf( ( (Number) left ).intValue() ^ ( (Number) right ).intValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + annotationExclusiveOr + "'." );
- }
-
- return result;
- }
-
- public Object visit( NotEquals annotationNotEquals )
- {
- Object left = annotationNotEquals.getLeft().accept( this );
- Object right = annotationNotEquals.getRight().accept( this );
- Class<?> type = resultType( left, right );
- boolean result;
-
- if ( type == Double.class )
- {
- result = ( (Number) left ).doubleValue() != ( (Number) right ).doubleValue();
- }
- else if ( type == Float.class )
- {
- result = ( (Number) left ).floatValue() != ( (Number) right ).floatValue();
- }
- else if ( type == Long.class )
- {
- result = ( (Number) left ).longValue() != ( (Number) right ).longValue();
- }
- else if ( type == Integer.class )
- {
- result = ( (Number) left ).intValue() != ( (Number) right ).intValue();
- }
- else
- {
- result = ( left != right );
- }
-
- return result ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object visit( Query annotationQuery )
- {
- Object value = annotationQuery.getCondition().accept( this );
-
- if ( !( value instanceof Boolean ) )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + annotationQuery + "'." );
- }
-
- AnnotationValue expression =
- ( (Boolean) value ).booleanValue() ? annotationQuery.getTrueExpression()
- : annotationQuery.getFalseExpression();
-
- return expression.accept( this );
- }
-
- public Object visit( Cast annotationCast )
- {
- Object value = annotationCast.getValue().accept( this );
- JavaType type = annotationCast.getType();
- Object result;
-
- if ( type instanceof JavaClass && ( (JavaClass) type ).isPrimitive() && value instanceof Number )
- {
- Number n = (Number) value;
- String typeName = type.getFullyQualifiedName();
-
- if ( typeName.equals( "byte" ) )
- {
- result = Byte.valueOf( n.byteValue() );
- }
- else if ( typeName.equals( "char" ) )
- {
- result = Character.valueOf( (char) n.intValue() );
- }
- else if ( typeName.equals( "short" ) )
- {
- result = Short.valueOf( n.shortValue() );
- }
- else if ( typeName.equals( "int" ) )
- {
- result = Integer.valueOf( n.intValue() );
- }
- else if ( typeName.equals( "long" ) )
- {
- result = Long.valueOf( n.longValue() );
- }
- else if ( typeName.equals( "float" ) )
- {
- result = Float.valueOf( n.floatValue() );
- }
- else if ( typeName.equals( "double" ) )
- {
- result = Double.valueOf( n.doubleValue() );
- }
- else
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + annotationCast + "'." );
- }
- }
- else
- {
- try
- {
- result = Class.forName( type.getFullyQualifiedName() ).cast( value );
- }
- catch ( ClassNotFoundException e )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + annotationCast + "'." );
- }
- }
-
- return result;
- }
-
- public Object visit( PreDecrement preDecrement )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + preDecrement + "'." );
- }
-
- public Object visit( PreIncrement preIncrement )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + preIncrement + "'." );
- }
-
- public Object visit( PostDecrement postDecrement )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + postDecrement + "'." );
- }
-
- public Object visit( PostIncrement postIncrement )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + postIncrement + "'." );
- }
-
- public Object visit( Assignment assignment )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + assignment + "'." );
- }
-
- public Object visit( MethodInvocation methodInvocation )
- {
- throw new IllegalArgumentException( "Cannot evaluate '" + methodInvocation + "'." );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/builder/impl/ModelBuilder.java b/src/main/java/com/thoughtworks/qdox/builder/impl/ModelBuilder.java
deleted file mode 100644
index 7570486..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/impl/ModelBuilder.java
+++ /dev/null
@@ -1,514 +0,0 @@
-package com.thoughtworks.qdox.builder.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.builder.TypeAssembler;
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.DocletTagFactory;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaGenericDeclaration;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-import com.thoughtworks.qdox.model.expression.Expression;
-import com.thoughtworks.qdox.model.impl.AbstractBaseJavaEntity;
-import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
-import com.thoughtworks.qdox.model.impl.DefaultJavaConstructor;
-import com.thoughtworks.qdox.model.impl.DefaultJavaField;
-import com.thoughtworks.qdox.model.impl.DefaultJavaInitializer;
-import com.thoughtworks.qdox.model.impl.DefaultJavaMethod;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-import com.thoughtworks.qdox.model.impl.DefaultJavaParameter;
-import com.thoughtworks.qdox.model.impl.DefaultJavaSource;
-import com.thoughtworks.qdox.model.impl.DefaultJavaType;
-import com.thoughtworks.qdox.model.impl.DefaultJavaTypeVariable;
-import com.thoughtworks.qdox.parser.expression.ExpressionDef;
-import com.thoughtworks.qdox.parser.structs.AnnoDef;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.parser.structs.FieldDef;
-import com.thoughtworks.qdox.parser.structs.InitDef;
-import com.thoughtworks.qdox.parser.structs.MethodDef;
-import com.thoughtworks.qdox.parser.structs.PackageDef;
-import com.thoughtworks.qdox.parser.structs.TagDef;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-import com.thoughtworks.qdox.parser.structs.TypeVariableDef;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-/**
- * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
- * @author Robert Scholte
- */
-public class ModelBuilder implements Builder {
-
- private final DefaultJavaSource source;
-
- private LinkedList<DefaultJavaClass> classStack = new LinkedList<DefaultJavaClass>();
-
- private List<DefaultJavaParameter> parameterList = new LinkedList<DefaultJavaParameter>();
-
- private DefaultJavaConstructor currentConstructor;
-
- private DefaultJavaMethod currentMethod;
-
- private DefaultJavaField currentField;
-
- private List<AnnoDef> currentAnnoDefs;
-
- private List<ExpressionDef> currentArguments;
-
- private String lastComment;
-
- private List<TagDef> lastTagSet = new LinkedList<TagDef>();
-
- private DocletTagFactory docletTagFactory;
-
- private ModelWriterFactory modelWriterFactory;
-
- public ModelBuilder( ClassLibrary classLibrary, DocletTagFactory docletTagFactory )
- {
- this.docletTagFactory = docletTagFactory;
- this.source = new DefaultJavaSource( classLibrary );
- this.currentAnnoDefs = new LinkedList<AnnoDef>();
- this.currentArguments = new LinkedList<ExpressionDef>();
- }
-
- /** {@inheritDoc} */
- public void setModelWriterFactory( ModelWriterFactory modelWriterFactory )
- {
- this.modelWriterFactory = modelWriterFactory;
- source.setModelWriterFactory( modelWriterFactory );
- }
-
- /** {@inheritDoc} */
- public void addPackage( PackageDef packageDef )
- {
- DefaultJavaPackage jPackage = new DefaultJavaPackage( packageDef.getName() );
- jPackage.setClassLibrary( source.getJavaClassLibrary() );
- jPackage.setLineNumber( packageDef.getLineNumber() );
- jPackage.setModelWriterFactory( modelWriterFactory );
- addJavaDoc( jPackage );
- setAnnotations( jPackage );
- source.setPackage( jPackage );
- }
-
- /** {@inheritDoc} */
- public void addImport( String importName )
- {
- source.addImport( importName );
- }
-
- /** {@inheritDoc} */
- public void addJavaDoc( String text )
- {
- lastComment = text;
- }
-
- /** {@inheritDoc} */
- public void addJavaDocTag( TagDef tagDef )
- {
- lastTagSet.add( tagDef );
- }
-
- /** {@inheritDoc} */
- public void beginClass(ClassDef def)
- {
- DefaultJavaClass newClass = new DefaultJavaClass( source );
- newClass.setLineNumber( def.getLineNumber() );
- newClass.setModelWriterFactory( modelWriterFactory );
-
- // basic details
- newClass.setName( def.getName() );
- newClass.setInterface( ClassDef.INTERFACE.equals( def.getType() ) );
- newClass.setEnum( ClassDef.ENUM.equals( def.getType() ) );
- newClass.setAnnotation( ClassDef.ANNOTATION_TYPE.equals( def.getType() ) );
-
- // superclass
- if ( newClass.isInterface() )
- {
- newClass.setSuperClass( null );
- }
- else if ( !newClass.isEnum() )
- {
- newClass.setSuperClass( def.getExtends().size() > 0 ? createType( def.getExtends().iterator().next(), 0 )
- : null );
- }
-
- // implements
- Set<TypeDef> implementSet = newClass.isInterface() ? def.getExtends() : def.getImplements();
- List<JavaClass> implementz = new LinkedList<JavaClass>();
- for ( TypeDef implementType : implementSet )
- {
- implementz.add( createType( implementType, 0 ) );
- }
- newClass.setImplementz( implementz );
-
- // modifiers
- newClass.setModifiers( new LinkedList<String>( def.getModifiers() ) );
-
- // typeParameters
- if ( def.getTypeParameters() != null )
- {
- List<DefaultJavaTypeVariable<JavaClass>> typeParams = new LinkedList<DefaultJavaTypeVariable<JavaClass>>();
- for ( TypeVariableDef typeVariableDef : def.getTypeParameters() )
- {
- typeParams.add( createTypeVariable( typeVariableDef, (JavaClass) newClass ) );
- }
- newClass.setTypeParameters( typeParams );
- }
-
- // javadoc
- addJavaDoc( newClass );
-
-// // ignore annotation types (for now)
-// if (ClassDef.ANNOTATION_TYPE.equals(def.type)) {
-// System.out.println( currentClass.getFullyQualifiedName() );
-// return;
-// }
-
- // annotations
- setAnnotations( newClass );
-
- classStack.addFirst( bindClass( newClass ) );
- }
-
- protected DefaultJavaClass bindClass( DefaultJavaClass newClass )
- {
- if ( currentField != null )
- {
- classStack.getFirst().addClass( newClass );
- currentField.setEnumConstantClass( newClass );
- }
- else if ( !classStack.isEmpty() )
- {
- classStack.getFirst().addClass( newClass );
- newClass.setParentClass( classStack.getFirst() );
- }
- else
- {
- source.addClass( newClass );
- }
- return newClass;
- }
-
- /** {@inheritDoc} */
- public void endClass()
- {
- classStack.removeFirst();
- }
-
- /**
- * this one is specific for those cases where dimensions can be part of both the type and identifier
- * i.e. private String[] matrix[]; //field
- * public abstract String[] getMatrix[](); //method
- *
- * @param typeDef
- * @param dimensions
- * @return the Type
- */
- private DefaultJavaType createType( TypeDef typeDef, int dimensions )
- {
- if ( typeDef == null )
- {
- return null;
- }
- return TypeAssembler.createUnresolved( typeDef, dimensions,
- classStack.isEmpty() ? source : classStack.getFirst() );
- }
-
- private void addJavaDoc( AbstractBaseJavaEntity entity )
- {
- entity.setComment( lastComment );
- List<DocletTag> tagList = new LinkedList<DocletTag>();
- for ( TagDef tagDef : lastTagSet )
- {
- tagList.add( docletTagFactory.createDocletTag( tagDef.getName(), tagDef.getText(),
- (JavaAnnotatedElement) entity, tagDef.getLineNumber() ) );
- }
- entity.setTags( tagList );
-
- lastTagSet.clear();
- lastComment = null;
- }
-
- public void addInitializer( InitDef def )
- {
- DefaultJavaInitializer initializer = new DefaultJavaInitializer();
- initializer.setLineNumber( def.getLineNumber() );
-
- initializer.setBlock( def.getBlockContent() );
- initializer.setStatic( def.isStatic() );
-
- classStack.getFirst().addInitializer( initializer );
-
- }
-
- /** {@inheritDoc} */
- public void beginConstructor()
- {
- currentConstructor = new DefaultJavaConstructor();
-
- currentConstructor.setParentClass( classStack.getFirst() );
-
- currentConstructor.setModelWriterFactory( modelWriterFactory );
-
- addJavaDoc( currentConstructor );
- setAnnotations( currentConstructor );
-
- classStack.getFirst().addConstructor( currentConstructor );
- }
-
- /** {@inheritDoc} */
- public void endConstructor( MethodDef def )
- {
- currentConstructor.setLineNumber( def.getLineNumber() );
-
- // basic details
- currentConstructor.setName( def.getName() );
-
- // typeParameters
- if ( def.getTypeParams() != null )
- {
- List<JavaTypeVariable<JavaConstructor>> typeParams =
- new LinkedList<JavaTypeVariable<JavaConstructor>>();
- for ( TypeVariableDef typeVariableDef : def.getTypeParams() )
- {
- typeParams.add( createTypeVariable( typeVariableDef, (JavaConstructor) currentConstructor ) );
- }
- currentConstructor.setTypeParameters( typeParams );
- }
-
- // exceptions
- List<JavaClass> exceptions = new LinkedList<JavaClass>();
- for ( TypeDef type : def.getExceptions() )
- {
- exceptions.add( createType( type, 0 ) );
- }
- currentConstructor.setExceptions( exceptions );
-
- // modifiers
- currentConstructor.setModifiers( new LinkedList<String>( def.getModifiers() ) );
-
- if ( !parameterList.isEmpty() )
- {
- currentConstructor.setParameters( new ArrayList<JavaParameter>( parameterList ) );
- parameterList.clear();
- }
-
- currentConstructor.setSourceCode( def.getBody() );
- }
-
- /** {@inheritDoc} */
- public void beginMethod()
- {
- currentMethod = new DefaultJavaMethod();
- if ( currentField == null )
- {
- currentMethod.setParentClass( classStack.getFirst() );
- classStack.getFirst().addMethod( currentMethod );
- }
- currentMethod.setModelWriterFactory( modelWriterFactory );
-
- addJavaDoc( currentMethod );
- setAnnotations( currentMethod );
- }
-
- /** {@inheritDoc} */
- public void endMethod( MethodDef def )
- {
- currentMethod.setLineNumber( def.getLineNumber() );
-
- // basic details
- currentMethod.setName( def.getName() );
- currentMethod.setReturns( createType( def.getReturnType(), def.getDimensions() ) );
-
- // typeParameters
- if ( def.getTypeParams() != null )
- {
- List<JavaTypeVariable<JavaMethod>> typeParams =
- new LinkedList<JavaTypeVariable<JavaMethod>>();
- for ( TypeVariableDef typeVariableDef : def.getTypeParams() )
- {
- typeParams.add( createTypeVariable( typeVariableDef, (JavaMethod) currentMethod ) );
- }
- currentMethod.setTypeParameters( typeParams );
- }
-
- // exceptions
- List<JavaClass> exceptions = new LinkedList<JavaClass>();
- for ( TypeDef type : def.getExceptions() )
- {
- exceptions.add( createType( type, 0 ) );
- }
- currentMethod.setExceptions( exceptions );
-
- // modifiers
- currentMethod.setDefault( def.getModifiers().remove( "default" ) );
- currentMethod.setModifiers( new LinkedList<String>( def.getModifiers() ) );
-
- if ( !parameterList.isEmpty() )
- {
- currentMethod.setParameters( new ArrayList<JavaParameter>( parameterList ) );
- parameterList.clear();
- }
-
- currentMethod.setSourceCode( def.getBody() );
- }
-
- private <G extends JavaGenericDeclaration> DefaultJavaTypeVariable<G> createTypeVariable( TypeVariableDef typeVariableDef, G genericDeclaration)
- {
- if ( typeVariableDef == null )
- {
- return null;
- }
- DefaultJavaTypeVariable<G> result = new DefaultJavaTypeVariable<G>( typeVariableDef.getName(), genericDeclaration );
-
- if ( typeVariableDef.getBounds() != null && !typeVariableDef.getBounds().isEmpty() )
- {
- List<JavaType> bounds = new LinkedList<JavaType>();
- for ( TypeDef typeDef : typeVariableDef.getBounds() )
- {
- bounds.add( createType( typeDef, 0 ) );
- }
- result.setBounds( bounds );
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public void beginField( FieldDef def )
- {
- currentField = new DefaultJavaField();
- currentField.setParentClass( classStack.getFirst() );
- currentField.setLineNumber( def.getLineNumber() );
- currentField.setModelWriterFactory( modelWriterFactory );
-
- currentField.setName( def.getName() );
- currentField.setType( createType( def.getType(), def.getDimensions() ) );
-
- currentField.setEnumConstant( def.isEnumConstant() );
-
- // modifiers
- {
- currentField.setModifiers( new LinkedList<String>( def.getModifiers() ) );
- }
-
- // code body
- currentField.setInitializationExpression( def.getBody() );
-
- // javadoc
- addJavaDoc( currentField );
-
- // annotations
- setAnnotations( currentField );
- }
-
- /** {@inheritDoc} */
- public void endField()
- {
- if ( currentArguments != null && !currentArguments.isEmpty() )
- {
- //DefaultExpressionTransformer??
- DefaultJavaAnnotationAssembler assembler = new DefaultJavaAnnotationAssembler( currentField );
-
- List<Expression> arguments = new LinkedList<Expression>();
- for ( ExpressionDef annoDef : currentArguments )
- {
- arguments.add( assembler.assemble( annoDef ) );
- }
- currentField.setEnumConstantArguments( arguments );
- currentArguments.clear();
- }
-
- classStack.getFirst().addField(currentField);
-
- currentField = null;
- }
-
- /** {@inheritDoc} */
- public void addParameter( FieldDef fieldDef )
- {
- DefaultJavaParameter jParam =
- new DefaultJavaParameter( createType( fieldDef.getType(), fieldDef.getDimensions() ), fieldDef.getName(),
- fieldDef.isVarArgs() );
- if( currentMethod != null )
- {
- jParam.setDeclarator( currentMethod );
- }
- else
- {
- jParam.setDeclarator( currentConstructor );
- }
- jParam.setModelWriterFactory( modelWriterFactory );
- addJavaDoc( jParam );
- setAnnotations( jParam );
- parameterList.add( jParam );
- }
-
- private void setAnnotations( final AbstractBaseJavaEntity entity )
- {
- if ( !currentAnnoDefs.isEmpty() )
- {
- DefaultJavaAnnotationAssembler assembler = new DefaultJavaAnnotationAssembler( (JavaAnnotatedElement) entity );
-
- List<JavaAnnotation> annotations = new LinkedList<JavaAnnotation>();
- for ( AnnoDef annoDef : currentAnnoDefs )
- {
- annotations.add( assembler.assemble( annoDef ) );
- }
- entity.setAnnotations( annotations );
- currentAnnoDefs.clear();
- }
- }
-
- // Don't resolve until we need it... class hasn't been defined yet.
- /** {@inheritDoc} */
- public void addAnnotation( AnnoDef annotation )
- {
- currentAnnoDefs.add( annotation );
- }
-
- public void addArgument( ExpressionDef argument )
- {
- currentArguments.add( argument );
- }
-
- public JavaSource getSource()
- {
- return source;
- }
-
- public void setUrl( URL url )
- {
- source.setURL( url );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/builder/impl/package-info.java b/src/main/java/com/thoughtworks/qdox/builder/impl/package-info.java
deleted file mode 100644
index f72e71b..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/impl/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides the default implementation of the classes which transform the structs from the JavaParser to the Java model elements
- */
-package com.thoughtworks.qdox.builder.impl;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/builder/package-info.java b/src/main/java/com/thoughtworks/qdox/builder/package-info.java
deleted file mode 100644
index be07a32..0000000
--- a/src/main/java/com/thoughtworks/qdox/builder/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes which transform the structs from the JavaParser to the Java model elements
- */
-package com.thoughtworks.qdox.builder;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java b/src/main/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java
deleted file mode 100644
index a0bc3e8..0000000
--- a/src/main/java/com/thoughtworks/qdox/directorywalker/DirectoryScanner.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * A directory scanner, which can scan files based on optional filters.
- */
-public class DirectoryScanner
-{
-
- private File file;
-
- private Collection<Filter> filters = new HashSet<Filter>();
-
- /**
- *
- * @param file the directory (or file) to scan
- */
- public DirectoryScanner( File file )
- {
- this.file = file;
- }
-
- /**
- * Add a filter to this scanner.
- *
- * @param filter the filter
- */
- public void addFilter( Filter filter )
- {
- this.filters.add( filter );
- }
-
- /**
- *
- * @return a list of files matching the filters, never <code>null</code>
- */
- public List<File> scan()
- {
- final List<File> result = new LinkedList<File>();
- walk( new FileVisitor()
- {
- public void visitFile( File file )
- {
- result.add( file );
- }
- }, this.file );
- return result;
- }
-
- /**
- * Scans the directory. Every file not filtered out by a filter fill be passed to the {@code fileVisitor}
- *
- * @param fileVisitor handler for matching files.
- */
- public void scan( FileVisitor fileVisitor )
- {
- walk( fileVisitor, this.file );
- }
-
- private void walk( FileVisitor visitor, File current )
- {
- if ( current.isDirectory() )
- {
- File[] currentFiles = current.listFiles();
- for ( int i = 0; i < currentFiles.length; i++ )
- {
- walk( visitor, currentFiles[i] );
- }
- }
- else
- {
- for ( Filter filter : this.filters )
- {
- if ( !filter.filter( current ) )
- {
- return;
- }
- }
- visitor.visitFile( current );
- }
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java b/src/main/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java
deleted file mode 100644
index 64b6bf1..0000000
--- a/src/main/java/com/thoughtworks/qdox/directorywalker/FileVisitor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-/**
- * A File visitor
- */
-public interface FileVisitor
-{
-
- /**
- *
- * @param file the file to visit
- */
- void visitFile( File file );
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/directorywalker/Filter.java b/src/main/java/com/thoughtworks/qdox/directorywalker/Filter.java
deleted file mode 100644
index 29b4c02..0000000
--- a/src/main/java/com/thoughtworks/qdox/directorywalker/Filter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-public interface Filter
-{
-
- /**
- *
- * @param file the file to filter
- * @return returns <code>true</code> if the file matches the filter expression, otherwise <code>false</code>
- */
- boolean filter( File file );
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java b/src/main/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java
deleted file mode 100644
index 69b074d..0000000
--- a/src/main/java/com/thoughtworks/qdox/directorywalker/SuffixFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-/**
- *
- * A file filter based on its suffix
- *
- */
-public class SuffixFilter
- implements Filter
-{
- private String suffixFilter;
-
- /**
- *
- * @param suffixFilter the suffix which will be matched for every file, must not be <code>null</code>
- */
- public SuffixFilter( String suffixFilter )
- {
- this.suffixFilter = suffixFilter;
- }
-
- /**
- * @param file the file to filter
- * @return <code>true</code> if the file ends with the specified suffix, otherwise <code>false</code>
- */
- public boolean filter( File file )
- {
- return file.getName().endsWith( this.suffixFilter );
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/directorywalker/package-info.java b/src/main/java/com/thoughtworks/qdox/directorywalker/package-info.java
deleted file mode 100644
index 8d5fbf8..0000000
--- a/src/main/java/com/thoughtworks/qdox/directorywalker/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes to visit all files within a directory matching a certain filter
- */
-package com.thoughtworks.qdox.directorywalker;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/library/AbstractClassLibrary.java b/src/main/java/com/thoughtworks/qdox/library/AbstractClassLibrary.java
deleted file mode 100644
index f488a1f..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/AbstractClassLibrary.java
+++ /dev/null
@@ -1,354 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.builder.ModelBuilderFactory;
-import com.thoughtworks.qdox.builder.impl.ModelBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.impl.DefaultDocletTagFactory;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-/**
- * A ClassLibrary can be compared with a java classloader.
- * Its main task is to serve JavaClasses based on the Fully Qualified Name.
- * AbstractClassLibraries hold a reference a parent library, in which way they can be chained.
- * Besides that it contains a context only for this library.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public abstract class AbstractClassLibrary
- implements ClassLibrary
-{
- private AbstractClassLibrary parentClassLibrary;
-
- private ModelBuilderFactory modelBuilderFactory;
-
- private ModelWriterFactory modelWriterFactory;
-
- private JavaClassContext context = new JavaClassContext();
-
- /**
- * constructor for root ClassLibrary
- */
- public AbstractClassLibrary()
- {
- }
-
- /**
- * constructor for chained ClassLibrary
- */
- public AbstractClassLibrary( AbstractClassLibrary parent )
- {
- this.parentClassLibrary = parent;
- }
-
- /**
- * First checks if there's a JavaClass available in the private context by this name. Otherwise try to resolve it by
- * the concrete class. If there's still no JavaClass, ask the parent (if available) to resolve it.
- *
- * @param name
- * @return the JavaClass matching the name, otherwise <code>null</code>
- */
- public final JavaClass getJavaClass( String name ) {
- return getJavaClass( name, false );
- }
-
- public final JavaClass getJavaClass( String name, boolean createStub ) {
- JavaClass result = context.getClassByName( name );
- if ( result == null )
- {
- result = resolveJavaClass( name );
-
- if ( result != null )
- {
- context.add( result );
- context.add( result.getSource() );
-
- JavaPackage contextPackage = context.getPackageByName( result.getPackageName() );
- if( contextPackage == null ) {
- DefaultJavaPackage newContextPackage = new DefaultJavaPackage( result.getPackageName() );
- newContextPackage.setClassLibrary( this );
- context.add( newContextPackage );
-
- contextPackage = newContextPackage;
- }
- contextPackage.getClasses().addAll( result.getNestedClasses() );
- }
- }
- if ( result == null && parentClassLibrary != null )
- {
- result = parentClassLibrary.getJavaClass( name );
- }
- if (result == null && createStub) {
- result = createStub(name);
- }
- return result;
- }
-
- private JavaClass createStub( String name )
- {
- Builder unknownBuilder = getModelBuilder();
- unknownBuilder.beginClass( new ClassDef( name ) );
- unknownBuilder.endClass();
- JavaSource unknownSource = unknownBuilder.getSource();
- return unknownSource.getClasses().get( 0 );
- }
-
- /**
- * The implementation should check it's sources to see if it can build a JavaClass Model If not, just return null;
- * Once found it will be mapped, so there's no need to keep a reference to this object.
- *
- * @param name the fully qualified name
- * @return the resolved JavaClass, otherwise <code>null</code>
- */
- protected abstract JavaClass resolveJavaClass( String name );
-
- public Collection<JavaSource> getJavaSources()
- {
- return context.getSources();
- }
-
- /**
- *
- *
- * @param filter
- * @return JavaSources matching the filter
- */
- protected final Collection<JavaSource> getJavaSources( ClassLibraryFilter filter) {
- List<JavaSource> result = new LinkedList<JavaSource>();
- if(filter.accept(this)) {
- result.addAll( context.getSources() );
- }
- if ( parentClassLibrary != null ) {
- result.addAll( parentClassLibrary.getJavaSources( filter ) );
- }
- return Collections.unmodifiableList( result );
- }
-
- /**
- * Get all the classes of the current {@link AbstractClassLibrary}.
- * Subclasses can overwrite this method by including the following code
- * <code>
- * public List<JavaClass> getClasses()
- * {
- * return getJavaClasses( new ClassLibraryFilter()
- * {
- * public boolean accept( AbstractClassLibrary classLibrary )
- * {
- * return true;
- * }
- * });
- * }
- * </code>
- * This example would return all created {@link JavaClass } objects, including those from the classloaders.
- *
- * @return all JavaClasses of this ClassLibrary
- */
- public Collection<JavaClass> getJavaClasses()
- {
- return context.getClasses();
- }
-
- /**
- * Subclasses can call this method to gather all JavaClass object, including those from the parent.
- *
- * @param filter
- * @return JavaClasses matching the filter
- */
- protected final Collection<JavaClass> getJavaClasses( ClassLibraryFilter filter) {
- List<JavaClass> result = new LinkedList<JavaClass>();
- if(filter.accept(this)) {
- result.addAll( context.getClasses() );
- }
- if ( parentClassLibrary != null ) {
- result.addAll( parentClassLibrary.getJavaClasses( filter ) );
- }
- return Collections.unmodifiableList( result );
- }
-
- /**
- * Get all packages of the current {@link AbstractClassLibrary}.
- * Subclasses can overwrite this method by including the following code
- * <code>
- * public List<JavaPackage> getJavaPackages()
- * {
- * return getJavaPackages( new ClassLibraryFilter()
- * {
- * public boolean accept( AbstractClassLibrary classLibrary )
- * {
- * return true;
- * }
- * });
- * }
- * </code>
- * This example would return all created {@link JavaPackage } objects, including those from the classloaders.
- *
- * @return all JavaPackages of this ClassLibrary
- */
- public Collection<JavaPackage> getJavaPackages()
- {
- return context.getPackages();
- }
-
- /**
- * @param name the fully qualified name
- * @return the JavaPackage matching the name, otherwise <code>null</code>
- */
- public final JavaPackage getJavaPackage( String name ) {
- JavaPackage result = context.getPackageByName( name );
- if (result == null) {
- result = resolveJavaPackage( name );
- if (result != null) {
- context.add(result);
- }
- }
- if(result == null && parentClassLibrary != null ) {
- result = parentClassLibrary.getJavaPackage( name );
- }
- return result;
- }
-
- protected abstract JavaPackage resolveJavaPackage(String name);
-
- protected final Collection<JavaPackage> getJavaPackages( ClassLibraryFilter filter) {
- List<JavaPackage> result = new LinkedList<JavaPackage>();
- if( filter.accept( this ) ) {
- result.addAll( context.getPackages() );
- }
- if ( parentClassLibrary != null ) {
- result.addAll( parentClassLibrary.getJavaPackages( filter ) );
- }
- return Collections.unmodifiableList( result );
- }
-
- /**
- * First checks if the context already has a JavaClass with this name.
- * If not, find out if this classlibrary is able to build a model for this class
- * Otherwise ask the parent if it could build a JavaClass.
- *
- * @param name the fully qualified name
- * @return <code>true</code> if there is a reference, otherwise <code>false</code>
- */
- public boolean hasClassReference( String name )
- {
- boolean result = context.getClassByName( name ) != null;
- if ( !result ) {
- result = containsClassReference( name );
- }
- if ( !result && parentClassLibrary != null ) {
- result = parentClassLibrary.hasClassReference( name );
- }
- return result;
- }
-
- /**
- * This method is used to detect if there's a match with this classname.
- * The name could be constructed based on imports and inner class paths.
- *
- * @param name the fully qualified name of the class
- * @return true if this ClassLibrary has a reference to this class.
- */
- protected abstract boolean containsClassReference( String name );
-
- /**
- * Set the ModelBuilderFactory for this classLibrary.
- *
- * @param factory the model builder factory
- */
- public final void setModelBuilderFactory( ModelBuilderFactory factory ) {
- this.modelBuilderFactory = factory;
- }
-
- /**
- * Set the ModelWriterFactory for this class.
- *
- * @param factory the model writer factory
- */
- public final void setModelWriterFactory( ModelWriterFactory factory )
- {
- this.modelWriterFactory = factory;
- }
-
- protected final ModelWriterFactory getModelWriterFactory()
- {
- return modelWriterFactory;
- }
-
- protected final ModelBuilderFactory getModelBuilderFactory()
- {
- return modelBuilderFactory;
- }
-
- /**
- * If there's a modelBuilderFactory available, ask it for a new instance.
- * Otherwise, return a default ModelBuilder.
- * In both cases, pass this library as argument.
- *
- * @return a new instance of a ModelBuilder, never <code>null</code>
- */
- protected Builder getModelBuilder()
- {
- ModelBuilder result;
- if ( modelBuilderFactory != null )
- {
- result = modelBuilderFactory.newInstance( this );
- }
- else
- {
- result = new ModelBuilder( this, new DefaultDocletTagFactory() );
- }
- result.setModelWriterFactory( modelWriterFactory );
- return result;
- }
-
- protected Builder getModelBuilder( URL url )
- {
- Builder result = getModelBuilder();
- result.setUrl( url );
- return result;
- }
-
- /**
- * A filter to use when checking all ancestors.
- *
- * @author Robert Scholte
- */
- interface ClassLibraryFilter
- {
- /**
- *
- * @param classLibrary
- * @return
- */
- boolean accept( AbstractClassLibrary classLibrary );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/library/ClassLibrary.java b/src/main/java/com/thoughtworks/qdox/library/ClassLibrary.java
deleted file mode 100644
index f9750bb..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/ClassLibrary.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Collection;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/**
- * Main methods of a ClassLibrary, which can be used by every Model
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface ClassLibrary
- extends Serializable
-{
- /**
- * Check if this library holds a reference based on the name.
- *
- * @param name the Fully Qualified Name trying to resolve
- * @return true if the classLibrary has a reference, otherwise <code>false</code>
- */
- boolean hasClassReference( String name );
-
- /**
- * Get the JavaClass or null if it's not possible
- *
- * @param name The fully qualified name of the JavaClass
- * @return the JavaClass, otherwise <code>null</code>
- */
- JavaClass getJavaClass( String name );
-
- /**
- * Try to retrieve the JavaClass by a fully qualified name.
- * If the JavaClss doesn't exist and createStub is <code>true</code> make a stub, otherwise return <code>null</code>
- *
- * @param name the fully qualified name of the class
- * @param createStub force creation of a stub if the class can't be found
- * @return the JavaClass, might be <code>null</code> depending on the value of createStub.
- */
- JavaClass getJavaClass( String name, boolean createStub );
-
-
- /**
- * Return all JavaClasses of the current library.
- * It's up to the library to decide if also collects JavaClasses from it's ancestors
- *
- * @return all JavaClasses as a List, never <code>null</code>
- */
- Collection<JavaClass> getJavaClasses();
-
- /**
- * Return all JavaSources of the current library.
- * It's up to the library to decide if also collects JavaSources from it's ancestors
- *
- * @return all JavaSources as a List, never <code>null</code>
- */
- Collection<JavaSource> getJavaSources();
-
- /**
- * Get the JavaPackage or null if it's not possible
- *
- * @param name The fully qualified name of the JavaPackage
- * @return The package, otherwise <code>null</code>
- */
- JavaPackage getJavaPackage( String name );
-
- /**
- * Return all JavaPackages of the current library.
- * It's up to the library to decide if also collects JavaPackages from it's ancestors
- *
- * @return all JavaPackages as a List, never <code>null</code>
- */
- Collection<JavaPackage> getJavaPackages();
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/ClassLibraryBuilder.java b/src/main/java/com/thoughtworks/qdox/library/ClassLibraryBuilder.java
deleted file mode 100644
index 0f9ca8f..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/ClassLibraryBuilder.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Serializable;
-import java.net.URL;
-
-import com.thoughtworks.qdox.builder.ModelBuilderFactory;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-/**
- * This builder helps to construct a library.
- * All kinds of sourcetypes are supported and it's up to the implementation how to bind these types.
- * For instance: The {@link SortedClassLibraryBuilder} bundles all classloaders, all sourcefolders and all sources.
- * The {@link OrderedClassLibraryBuilder} on the other hand keeps track of the order in which sourcetypes are added.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface ClassLibraryBuilder extends Serializable
-{
- /**
- * Append a classloader and return itself
- *
- * @param classLoader the classloader to add
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder appendClassLoader( ClassLoader classLoader );
-
- /**
- * Add the defaultClassLoaders and return itse
- *
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder appendDefaultClassLoaders();
-
- /**
- *
- * @param sourceFolder
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder appendSourceFolder( File sourceFolder );
-
- /**
- *
- * @param stream
- * @return this ClassLibraryBuilder instance
- * @throws IOException if an IOException is thrown, e.g. unsupported encoding
- */
- ClassLibraryBuilder appendSource( InputStream stream ) throws IOException;
-
- /**
- *
- * @param reader
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder appendSource( Reader reader );
-
- /**
- *
- * @param url
- * @return this ClassLibraryBuilder instance
- * @throws IOException
- */
- ClassLibraryBuilder appendSource( URL url ) throws IOException;
-
- /**
- *
- * @param file
- * @return this ClassLibraryBuilder instance
- * @throws IOException
- */
- ClassLibraryBuilder appendSource( File file ) throws IOException;
-
- /**
- *
- * @param stream
- * @return the created JavaSource
- * @throws IOException if an IOException is thrown, e.g. unsupported encoding
- */
- JavaSource addSource( InputStream stream ) throws IOException;
-
- /**
- * Add the source content of the reader to the ClassLibrary and return the generated JavaSource
- *
- * @param reader
- * @return the created JavaSource
- */
- JavaSource addSource( Reader reader );
-
- /**
- *
- * @param url
- * @return the created JavaSource
- * @throws IOException
- */
- JavaSource addSource( URL url ) throws IOException;
-
- /**
- *
- * @param file
- * @return the created JavaSource
- * @throws IOException
- */
- JavaSource addSource( File file ) throws IOException;
-
- /**
- *
- * @param debugLexer
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setDebugLexer( boolean debugLexer );
-
- /**
- *
- * @param debugParser
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setDebugParser( boolean debugParser );
-
- /**
- *
- * @param encoding
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setEncoding( String encoding );
-
- /**
- * Define the {@link ModelBuilderFactory} which the parsers should use to construct the JavaModel Objects
- *
- * @param factory the modelBuilderFactory
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setModelBuilderFactory( ModelBuilderFactory factory );
-
- /**
- * Define the {@link ModelWriterFactory} which is used by the classes when calling for the codeBlock.
- *
- * @param factory the modelWriterFactory
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setModelWriterFactory( ModelWriterFactory factory );
-
- /**
- * Get the library based on the strategy of the implementation
- *
- * @return the constructed ClassLibrary
- */
- ClassLibrary getClassLibrary();
-
- /**
- * Can handle ParseExceptions instead of crashing.
- * Has only effect on the appendSource() methods
- *
- * @param errorHandler the errorHandler
- * @return this ClassLibraryBuilder instance
- */
- ClassLibraryBuilder setErrorHander( ErrorHandler errorHandler );
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/library/ClassLoaderLibrary.java b/src/main/java/com/thoughtworks/qdox/library/ClassLoaderLibrary.java
deleted file mode 100644
index 3f030fb..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/ClassLoaderLibrary.java
+++ /dev/null
@@ -1,232 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.builder.impl.ModelBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-import com.thoughtworks.qdox.parser.JavaLexer;
-import com.thoughtworks.qdox.parser.ParseException;
-import com.thoughtworks.qdox.parser.impl.BinaryClassParser;
-import com.thoughtworks.qdox.parser.impl.JFlexLexer;
-import com.thoughtworks.qdox.parser.impl.Parser;
-
-/**
- * <strong>Important!! Be sure to add a classloader with the bootstrap classes.</strong>
- * <p>
- * Normally you can generate your classLibrary like this:<br/>
- * <code>
- * ClassLibrary classLibrary = new ClassLibrary();
- * classLibrary.addDefaultLoader();
- * </code>
- * </p>
- * <p>
- * If you want full control over the classLoaders you might want to create your library like:<br/>
- * <code>
- * ClassLibrary classLibrary = new ClassLibrary( ClassLoader.getSystemClassLoader() )
- * </code>
- * </p>
- *
- * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
- * @author Aslak Hellesøy
- * @author Robert Scholte
- * @since 2.0
- */
-public class ClassLoaderLibrary
- extends AbstractClassLibrary
-{
- private transient List<ClassLoader> classLoaders = new LinkedList<ClassLoader>();
-
- private boolean defaultClassLoadersAdded = false;
-
- private boolean debugLexer;
-
- private boolean debugParser;
-
- private ErrorHandler errorHandler;
-
- public ClassLoaderLibrary( AbstractClassLibrary parent )
- {
- super( parent );
- }
-
- public ClassLoaderLibrary( AbstractClassLibrary parent, ClassLoader classLoader )
- {
- super( parent );
- this.classLoaders.add( classLoader );
- }
-
- public void addClassLoader( ClassLoader classLoader )
- {
- classLoaders.add( classLoader );
- }
-
- public void addDefaultLoader()
- {
- if ( !defaultClassLoadersAdded )
- {
- classLoaders.add( getClass().getClassLoader() );
- classLoaders.add( Thread.currentThread().getContextClassLoader() );
- }
- defaultClassLoadersAdded = true;
- }
-
- @Override
- protected JavaClass resolveJavaClass( final String name )
- {
- JavaClass result = null;
- for ( ClassLoader classLoader : classLoaders )
- {
- String resource = name;
- if ( resource.indexOf( '$' ) > 0 )
- {
- resource = resource.split( "$" )[0];
- }
- resource = resource.replace( '.', '/' ) + ".java";
- InputStream sourceStream = classLoader.getResourceAsStream( resource );
- if ( sourceStream != null )
- {
- Builder builder = getModelBuilder();
- JavaLexer lexer = new JFlexLexer( sourceStream );
- Parser parser = new Parser( lexer, builder );
- parser.setDebugLexer( debugLexer );
- parser.setDebugParser( debugParser );
- try
- {
- if ( parser.parse() )
- {
- result = builder.getSource().getClassByName( name );
- break;
- }
- }
- catch ( ParseException pe )
- {
- pe.setSourceInfo( resource );
- if ( errorHandler != null )
- {
- errorHandler.handle( pe );
- }
- else
- {
- throw pe;
- }
- }
- }
- if ( result == null )
- {
- try
- {
- Class<?> clazz = classLoader.loadClass( name );
- if ( clazz.getDeclaringClass() != null )
- {
- clazz = clazz.getDeclaringClass();
- }
- Builder builder = getModelBuilder();
- BinaryClassParser parser = new BinaryClassParser( clazz, builder );
- if ( parser.parse() )
- {
- result = builder.getSource().getClassByName( name );
- break;
- }
- }
- catch ( ClassNotFoundException e )
- {
- }
- }
- }
- return result;
- }
-
- @Override
- protected JavaPackage resolveJavaPackage(String name) {
- DefaultJavaPackage result = null;
- Package pckg = Package.getPackage(name);
- if(pckg != null) {
- result = new DefaultJavaPackage(name);
- result.setClassLibrary( this );
- }
- return result;
- }
-
- private void readObject( ObjectInputStream in )
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- classLoaders = new LinkedList<ClassLoader>();
- if ( defaultClassLoadersAdded )
- {
- defaultClassLoadersAdded = false;
- addDefaultLoader();
- }
- }
-
- @Override
- protected boolean containsClassReference( String name )
- {
- boolean result = false;
- for(Iterator<ClassLoader> iter = classLoaders.iterator();!result && iter.hasNext(); )
- {
- ClassLoader classLoader = (ClassLoader) iter.next();
- try
- {
- Class<?> clazz = classLoader.loadClass( name );
- result = ( clazz != null );
- }
- catch ( ClassNotFoundException e )
- {
- }
- }
- return result;
- }
-
- /**
- * Use the Lexer in debug mode
- *
- * @param debugLexer
- */
- public void setDebugLexer( boolean debugLexer )
- {
- this.debugLexer = debugLexer;
- }
-
- /**
- * Use the Parser in debug mode
- *
- * @param debugParser
- */
- public void setDebugParser( boolean debugParser )
- {
- this.debugParser = debugParser;
- }
-
- public void setErrorHandler( ErrorHandler errorHandler )
- {
- this.errorHandler = errorHandler;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/ClassNameLibrary.java b/src/main/java/com/thoughtworks/qdox/library/ClassNameLibrary.java
deleted file mode 100644
index b3a6776..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/ClassNameLibrary.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-
-/**
- * This library always resolve a className by generating an empty JavaClass Model
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class ClassNameLibrary
- extends AbstractClassLibrary
-{
-
- @Override
- protected JavaClass resolveJavaClass( String name )
- {
- Builder unknownBuilder = getModelBuilder();
- unknownBuilder.beginClass( new ClassDef( name ) );
- unknownBuilder.endClass();
- JavaSource unknownSource = unknownBuilder.getSource();
- return unknownSource.getClasses().get( 0 );
- }
-
- @Override
- protected JavaPackage resolveJavaPackage(String name) {
- return null;
- }
-
- @Override
- protected boolean containsClassReference( String name )
- {
- return false;
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/ErrorHandler.java b/src/main/java/com/thoughtworks/qdox/library/ErrorHandler.java
deleted file mode 100644
index bb6fb72..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/ErrorHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.parser.ParseException;
-
-public interface ErrorHandler {
-
- void handle(ParseException parseException);
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/library/JavaClassContext.java b/src/main/java/com/thoughtworks/qdox/library/JavaClassContext.java
deleted file mode 100644
index 6cc3563..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/JavaClassContext.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/**
- * JavaClassContext gives you a mechanism to get a {@link JavaClass}.
- * If a class couldn't be found in the cache, the class will be pulled from the classLibrary, the builder will create the corresponding JavaClass and put it in the cache.
- *
- *
- * @author Robert Scholte
- *
- */
-public class JavaClassContext implements Serializable {
-
-
- private Map<String, JavaClass> classMap = new LinkedHashMap<String, JavaClass>();
- private Map<String, JavaPackage> packageMap = new LinkedHashMap<String, JavaPackage>();
- private Set<JavaSource> sourceSet = new LinkedHashSet<JavaSource>();
-
- public JavaClassContext(){
- }
-
- /**
- * Retrieve the {@link JavaClass} based on the {@code name}.
- *
- * @param name the fully qualified name of the class
- * @return the stored JavaClass, otherwise <code>null</code>
- */
- public JavaClass getClassByName(String name)
- {
- return classMap.get( name );
- }
-
- /**
- * Remove and return the {@link JavaClass} based on the {@code name}.
- *
- * @param name the fully qualified name of the class
- * @return the removed JavaClass, otherwise <code>null</code>
- */
- public JavaClass removeClassByName(String name)
- {
- return classMap.remove( name );
- }
-
- /**
- * Return all stored JavaClasses
- *
- * @return a list of JavaClasses, never <code>null</code>
- */
- public List<JavaClass> getClasses() {
- return Collections.unmodifiableList( new LinkedList<JavaClass>(classMap.values()) );
- }
-
- /**
- * Store this {@link JavaClass} based on its fully qualified name
- *
- * @param javaClass the JavaClass to add
- */
- public void add(JavaClass javaClass) {
- classMap.put(javaClass.getFullyQualifiedName(), javaClass);
- }
-
- /**
- * Retrieve the {@link JavaPackage} based on the {@code name}.
- *
- * @param name the fully qualified name of the package
- * @return the stored JavaPackage, otherwise <code>null</code>
- */
- public JavaPackage getPackageByName( String name )
- {
- return packageMap.get( name );
- }
-
- /**
- * Remove and return the {@link JavaPackage} based on the {@code name}.
- *
- * @param name the fully qualified name of the class
- * @return the removed JavaPackage, otherwise <code>null</code>
- */
- public JavaPackage removePackageByName( String name )
- {
- return packageMap.remove( name );
- }
-
- /**
- * A null-safe implementation to store a {@link JavaPackage} in this context
- *
- * @param jPackage the JavaPackage to add
- */
- public void add( JavaPackage jPackage )
- {
- if(jPackage != null) {
- packageMap.put( jPackage.getName(), jPackage );
- }
- }
-
- /**
- * Return all stored JavaPackages
- *
- * @return a list of JavaPackages, never <code>null</code>
- */
- public List<JavaPackage> getPackages()
- {
- return Collections.unmodifiableList( new LinkedList<JavaPackage>(packageMap.values()) );
-
- }
-
- /**
- * Store a {@link JavaSource} in this context
- *
- * @param source the JavaSource to add
- */
- public void add( JavaSource source )
- {
- sourceSet.add( source );
- }
-
- /**
- * Return all stored JavaSources
- *
- * @return a list of JavaSources, never <code>null</code>
- */
- public List<JavaSource> getSources()
- {
- return Collections.unmodifiableList( new LinkedList<JavaSource>(sourceSet) );
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilder.java b/src/main/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilder.java
deleted file mode 100644
index bb16c5d..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilder.java
+++ /dev/null
@@ -1,334 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
-
-import com.thoughtworks.qdox.builder.ModelBuilderFactory;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-/**
- * This library resolves JavaClasses in the order in which class sources are added.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class OrderedClassLibraryBuilder implements ClassLibraryBuilder
-{
-
- private AbstractClassLibrary classLibrary;
-
- private boolean debugLexer;
-
- private boolean debugParser;
-
- private String encoding;
-
- private ErrorHandler errorHandler;
-
- private ModelBuilderFactory modelBuilderFactory;
-
- private ModelWriterFactory modelWriterFactory;
-
- /**
- * Default constructor which sets the root classLibrary to ClassNameLibrary.
- * This way every class will be resolved, even if it's not on the classpath.
- *
- */
- public OrderedClassLibraryBuilder()
- {
- this.classLibrary = new ClassNameLibrary();
- }
-
- /**
- * Constructor for which you can set the root ClassLibrary
- * If you set this to null, all classes should be available on the classpath.
- *
- * @param rootClassLibrary
- */
- public OrderedClassLibraryBuilder( AbstractClassLibrary rootClassLibrary )
- {
- this.classLibrary = rootClassLibrary;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#appendClassLoader(java.lang.ClassLoader)
- */
- public ClassLibraryBuilder appendClassLoader( ClassLoader classLoader )
- {
- if ( !( classLibrary instanceof ClassLoaderLibrary ) )
- {
- classLibrary = newClassLoaderLibrary( classLibrary );
- }
- ClassLoaderLibrary classLoaderLibrary = (ClassLoaderLibrary) classLibrary;
- classLoaderLibrary.addClassLoader( classLoader );
- classLoaderLibrary.setModelBuilderFactory( modelBuilderFactory );
- classLoaderLibrary.setModelWriterFactory( modelWriterFactory );
- classLoaderLibrary.setDebugLexer( debugLexer );
- classLoaderLibrary.setDebugParser( debugParser );
- classLoaderLibrary.setErrorHandler( errorHandler );
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#appendDefaultClassLoaders()
- */
- public ClassLibraryBuilder appendDefaultClassLoaders()
- {
- if ( !( classLibrary instanceof ClassLoaderLibrary ) )
- {
- classLibrary = newClassLoaderLibrary( classLibrary );
- }
- ClassLoaderLibrary classLoaderLibrary = (ClassLoaderLibrary) classLibrary;
- classLoaderLibrary.addDefaultLoader();
- classLoaderLibrary.setModelBuilderFactory( modelBuilderFactory );
- classLoaderLibrary.setModelWriterFactory( modelWriterFactory );
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSourceFolder(java.io.File)
- */
- public ClassLibraryBuilder appendSourceFolder( File sourceFolder )
- {
- if ( !( classLibrary instanceof SourceFolderLibrary ) )
- {
- classLibrary = newSourceFolderLibrary( classLibrary );
- }
- SourceFolderLibrary sourceFolderLibrary = (SourceFolderLibrary) classLibrary;
- prepareSourceLibrary( sourceFolderLibrary );
- sourceFolderLibrary.addSourceFolder( sourceFolder );
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.io.InputStream)
- */
- public ClassLibraryBuilder appendSource( InputStream stream ) throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- sourceLibrary.addSource( stream );
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.io.Reader)
- */
- public ClassLibraryBuilder appendSource( Reader reader )
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- sourceLibrary.addSource( reader );
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setDebugLexer(boolean)
- */
- public ClassLibraryBuilder setDebugLexer( boolean debugLexer )
- {
- this.debugLexer = debugLexer;
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setDebugParser(boolean)
- */
- public ClassLibraryBuilder setDebugParser( boolean debugParser )
- {
- this.debugParser = debugParser;
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setEncoding(java.lang.String)
- */
- public ClassLibraryBuilder setEncoding( String encoding )
- {
- this.encoding = encoding;
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setErrorHander(com.thoughtworks.qdox.library.ErrorHandler)
- */
- public ClassLibraryBuilder setErrorHander( ErrorHandler errorHandler )
- {
- this.errorHandler = errorHandler;
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setModelBuilderFactory(com.thoughtworks.qdox.builder.ModelBuilderFactory)
- */
- public ClassLibraryBuilder setModelBuilderFactory( ModelBuilderFactory modelBuilderFactory )
- {
- this.modelBuilderFactory = modelBuilderFactory;
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#setModelWriterFactory(com.thoughtworks.qdox.writer.ModelWriterFactory)
- */
- public ClassLibraryBuilder setModelWriterFactory( ModelWriterFactory modelWriterFactory )
- {
- this.modelWriterFactory = modelWriterFactory;
- return this;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#getClassLibrary()
- */
- public ClassLibrary getClassLibrary()
- {
- return classLibrary;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#appendSource(java.net.URL)
- */
- public ClassLibraryBuilder appendSource( URL url ) throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- sourceLibrary.addSource( url );
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#appendSource(java.io.File)
- */
- public ClassLibraryBuilder appendSource( File file )
- throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- sourceLibrary.addSource( file );
- return this;
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.io.InputStream)
- */
- public JavaSource addSource( InputStream stream ) throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- return sourceLibrary.addSource( stream );
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.io.Reader)
- */
- public JavaSource addSource( Reader reader )
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- return sourceLibrary.addSource( reader );
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.net.URL)
- */
- public JavaSource addSource( URL url ) throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- return sourceLibrary.addSource( url );
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.library.ClassLibraryBuilder#addSource(java.io.File)
- */
- public JavaSource addSource( File file )
- throws IOException
- {
- SourceLibrary sourceLibrary = getSourceLibrary();
- return sourceLibrary.addSource( file );
- }
-
- private void prepareSourceLibrary( SourceLibrary sourceLibrary ) {
- sourceLibrary.setModelBuilderFactory( modelBuilderFactory );
- sourceLibrary.setModelWriterFactory( modelWriterFactory );
- sourceLibrary.setDebugLexer( debugLexer );
- sourceLibrary.setDebugParser( debugParser );
- sourceLibrary.setEncoding( encoding );
- sourceLibrary.setErrorHandler( errorHandler );
- }
-
- protected final SourceLibrary getSourceLibrary() {
- if ( !( classLibrary instanceof SourceLibrary ) )
- {
- classLibrary = newSourceLibrary( classLibrary );
- }
- SourceLibrary sourceLibrary = (SourceLibrary) classLibrary;
- prepareSourceLibrary( sourceLibrary );
- return sourceLibrary;
- }
-
- /**
- * Ability to override the implementation of ClassLoaderLibrary
- *
- * @param parentLibrary the parent library
- * @return a new ClassLoaderLibrary instance
- * @since 2.0
- */
- protected ClassLoaderLibrary newClassLoaderLibrary( AbstractClassLibrary parentLibrary )
- {
- return new ClassLoaderLibrary( parentLibrary );
- }
-
- /**
- * Ability to override the implementation of SourceLibrary
- *
- * @param parentLibrary the parent library
- * @return a new SourceLibrary instance
- * @since 2.0
- */
- protected SourceLibrary newSourceLibrary( AbstractClassLibrary parentLibrary )
- {
- return new SourceLibrary( parentLibrary );
- }
-
- /**
- * Ability to override the implementation of SourceFolderLibrary
- *
- * @param parentLibrary the parent library
- * @return a new SourceFolderLibrary instance
- * @since 2.0
- */
- protected SourceFolderLibrary newSourceFolderLibrary( AbstractClassLibrary parentLibrary )
- {
- return new SourceFolderLibrary( parentLibrary );
- }
-
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilder.java b/src/main/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilder.java
deleted file mode 100644
index 9d3d755..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilder.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
-
-import com.thoughtworks.qdox.builder.ModelBuilderFactory;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-
-/**
- * @author Robert Scholte
- * @since 2.0
- */
-public class SortedClassLibraryBuilder
- implements ClassLibraryBuilder
-{
- private final ClassNameLibrary classNameLibrary;
-
- private final ClassLoaderLibrary classLoaderLibrary;
-
- private final SourceFolderLibrary sourceFolderLibrary;
-
- private final SourceLibrary sourceLibrary;
-
- public SortedClassLibraryBuilder()
- {
- classNameLibrary = new ClassNameLibrary();
- classLoaderLibrary = new ClassLoaderLibrary( classNameLibrary );
- sourceFolderLibrary = new SourceFolderLibrary( classLoaderLibrary );
- sourceLibrary = new SourceLibrary( sourceFolderLibrary );
- }
-
- public ClassLibraryBuilder appendClassLoader( ClassLoader classLoader )
- {
- classLoaderLibrary.addClassLoader( classLoader );
- return this;
- }
-
- public ClassLibraryBuilder appendDefaultClassLoaders()
- {
- classLoaderLibrary.addDefaultLoader();
- return this;
- }
-
- public ClassLibraryBuilder appendSourceFolder( File sourceFolder )
- {
- sourceFolderLibrary.addSourceFolder( sourceFolder );
- return this;
- }
-
- public ClassLibraryBuilder appendSource( InputStream stream ) throws IOException
- {
- sourceLibrary.addSource( stream );
- return this;
- }
-
- public ClassLibraryBuilder appendSource( Reader reader )
- {
- sourceLibrary.addSource( reader );
- return this;
- }
-
- public ClassLibraryBuilder appendSource( URL url )
- throws IOException
- {
- sourceLibrary.addSource( url );
- return this;
- }
-
- public ClassLibraryBuilder appendSource( File file )
- throws IOException
- {
- sourceLibrary.addSource( file );
- return this;
- }
-
- public ClassLibraryBuilder setDebugLexer( boolean debugLexer )
- {
- classLoaderLibrary.setDebugLexer( debugLexer );
- sourceFolderLibrary.setDebugLexer( debugLexer );
- sourceLibrary.setDebugLexer( debugLexer );
- return this;
- }
-
- public ClassLibraryBuilder setDebugParser( boolean debugParser )
- {
- classLoaderLibrary.setDebugParser( debugParser );
- sourceFolderLibrary.setDebugParser( debugParser );
- sourceLibrary.setDebugParser( debugParser );
- return this;
- }
-
- public ClassLibraryBuilder setEncoding( String encoding )
- {
- sourceFolderLibrary.setEncoding( encoding );
- sourceLibrary.setEncoding( encoding );
- return this;
- }
-
- public ClassLibraryBuilder setErrorHander( ErrorHandler errorHandler )
- {
- classLoaderLibrary.setErrorHandler( errorHandler );
- sourceFolderLibrary.setErrorHandler( errorHandler );
- sourceLibrary.setErrorHandler( errorHandler );
- return this;
- }
-
- public ClassLibraryBuilder setModelBuilderFactory( ModelBuilderFactory factory )
- {
- classNameLibrary.setModelBuilderFactory( factory );
- classLoaderLibrary.setModelBuilderFactory( factory );
- sourceFolderLibrary.setModelBuilderFactory( factory );
- sourceLibrary.setModelBuilderFactory( factory );
- return this;
- }
-
-
- public ClassLibraryBuilder setModelWriterFactory( ModelWriterFactory modelWriterFactory )
- {
- classNameLibrary.setModelWriterFactory( modelWriterFactory );
- classLoaderLibrary.setModelWriterFactory( modelWriterFactory );
- sourceFolderLibrary.setModelWriterFactory( modelWriterFactory );
- sourceLibrary.setModelWriterFactory( modelWriterFactory );
- return this;
- }
-
- public ClassLibrary getClassLibrary()
- {
- return sourceLibrary;
- }
-
- public JavaSource addSource( InputStream stream ) throws IOException
- {
- return sourceLibrary.addSource( stream );
- }
-
- public JavaSource addSource( Reader reader )
- {
- return sourceLibrary.addSource( reader );
- }
-
- public JavaSource addSource( URL url )
- throws IOException
- {
- return sourceLibrary.addSource( url );
- }
-
- public JavaSource addSource( File file )
- throws IOException
- {
- return sourceLibrary.addSource( file );
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/SourceFolderLibrary.java b/src/main/java/com/thoughtworks/qdox/library/SourceFolderLibrary.java
deleted file mode 100644
index f2d3cec..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/SourceFolderLibrary.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.net.MalformedURLException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/**
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class SourceFolderLibrary
- extends SourceLibrary
-{
- private List<File> sourceFolders = new LinkedList<File>();
-
- public SourceFolderLibrary( AbstractClassLibrary parent )
- {
- super( parent );
- }
-
- public SourceFolderLibrary( AbstractClassLibrary parent, File sourceFolder )
- {
- super( parent );
- this.sourceFolders.add( sourceFolder );
- }
-
- public void addSourceFolder( File sourceFolder )
- {
- this.sourceFolders.add( sourceFolder );
- }
-
- @Override
- protected JavaClass resolveJavaClass( String className )
- {
- JavaClass result = null;
- for ( File sourceFolder : sourceFolders )
- {
- String mainClassName = className.split( "\\$" )[0];
- File classFile = new File( sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java" );
- if ( classFile.exists() && classFile.isFile() )
- {
- try
- {
- JavaSource source = parse( new FileReader( classFile ), classFile.toURI().toURL() );
- result = source.getClassByName( className );
- }
- catch ( FileNotFoundException e )
- {
- }
- catch ( MalformedURLException e )
- {
- }
- }
- }
- return result;
- }
-
- /**
- * Loops over the sourceFolder to find a classReference.
- * It will try to map the className to a file.
- *
- */
- @Override
- protected boolean containsClassReference( String className )
- {
- boolean result = false;
- for ( Iterator<File> iterator = sourceFolders.iterator(); !result && iterator.hasNext(); )
- {
- File sourceFolder = (File) iterator.next();
- String mainClassName = className.split( "\\$" )[0];
- File classFile = new File( sourceFolder, mainClassName.replace( '.', File.separatorChar ) + ".java" );
-
- result = ( classFile.exists() && classFile.isFile() );
- }
- return result;
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/SourceLibrary.java b/src/main/java/com/thoughtworks/qdox/library/SourceLibrary.java
deleted file mode 100644
index 8869e5f..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/SourceLibrary.java
+++ /dev/null
@@ -1,404 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-import com.thoughtworks.qdox.parser.JavaLexer;
-import com.thoughtworks.qdox.parser.ParseException;
-import com.thoughtworks.qdox.parser.impl.JFlexLexer;
-import com.thoughtworks.qdox.parser.impl.Parser;
-
-/**
- * This Library will immediately parse the source and keeps its reference to a private context.
- * Once the superclass explicitly asks for an instance if will be moved to the context f the supoerclass.
- * If there's a request to get a certain JavaModel Object from a SourceLibrary, it will check all ancestor SourceLibraries as well.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class SourceLibrary
- extends AbstractClassLibrary
-{
- // parser and unused JavaSources, JavaClasses and JavaPackages
- private JavaClassContext context = new JavaClassContext();
-
- private boolean debugLexer;
-
- private boolean debugParser;
-
- private static final String DEFAULT_ENCODING = System.getProperty("file.encoding");
-
- private String encoding;
-
- private ErrorHandler errorHandler;
-
- /**
- * Create a new instance of SourceLibrary and chain it to the parent
- *
- * @param parent
- */
- public SourceLibrary( AbstractClassLibrary parent )
- {
- super( parent );
- }
-
- /**
- * Add a {@link Reader} containing java code to this library
- *
- * @param reader a {@link Reader} which should contain java code
- * @return The constructed {@link JavaSource} object of this reader
- * @throws ParseException if this content couldn't be parsed to a JavaModel
- */
- public JavaSource addSource( Reader reader )
- throws ParseException
- {
- return addSource( reader, null );
- }
-
- private JavaSource addSource( Reader reader, URL url )
- {
- JavaSource source = parse( reader, url );
- registerJavaSource(source);
- return source;
- }
-
- /**
- * Add an {@link InputStream} containing java code to this library
- *
- * @param stream an {@link InputStream} which should contain java code
- * @return The constructed {@link JavaSource} object of this stream
- * @throws ParseException if this content couldn't be parsed to a JavaModel
- */
- public JavaSource addSource( InputStream stream )
- throws ParseException, IOException
- {
- JavaSource source = parse( stream, null );
- registerJavaSource(source);
- return source;
- }
-
- /**
- * Add a {@link URL} containing java code to this library
- *
- * @param url a {@link URL} which should contain java code
- * @return The constructed {@link JavaSource} object of this url
- * @throws ParseException if this content couldn't be parsed to a JavaModel
- */
- public JavaSource addSource( URL url )
- throws ParseException, IOException
- {
- return addSource( new InputStreamReader( url.openStream(), encoding), url );
- }
-
- /**
- * Add a {@link File} containing java code to this library
- *
- * @param file a {@link File} which should contain java code
- * @return The constructed {@link JavaSource} object of this file
- * @throws ParseException
- * @throws IOException
- */
- public JavaSource addSource( File file )
- throws ParseException, IOException
- {
- JavaSource result = null;
- if ( !"package-info.java".equals( file.getName() ) )
- {
- result = parse( new FileInputStream( file ), file.toURI().toURL() );
- // if an error is handled by the errorHandler the result will be null
- if( result != null )
- {
- if( getJavaPackage( result.getPackageName() ) == null )
- {
- File packageInfo = new File(file.getParentFile(), "package-info.java");
- if( packageInfo.exists() )
- {
- JavaPackage pckg = parse( new FileInputStream( packageInfo ), packageInfo.toURI().toURL() ).getPackage();
- context.add( pckg );
- }
- }
- registerJavaSource(result);
- }
- }
- return result;
- }
-
-
-
- protected JavaSource parse( Reader reader, URL url )
- throws ParseException
- {
- try
- {
- return parse( new JFlexLexer( reader ), url );
- }
- finally
- {
- try
- {
- reader.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
-
- protected JavaSource parse( InputStream stream, URL url )
- throws ParseException, UnsupportedEncodingException
- {
- try
- {
- return parse( new JFlexLexer( new InputStreamReader( stream, getEncoding() ) ), url );
- }
- finally
- {
- try
- {
- stream.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
-
- private JavaSource parse( JavaLexer lexer, URL url )
- throws ParseException
- {
- JavaSource result = null;
- Builder builder = getModelBuilder();
- builder.setUrl( url );
- Parser parser = new Parser( lexer, builder );
- parser.setDebugLexer( debugLexer );
- parser.setDebugParser( debugParser );
- try {
- if ( parser.parse() )
- {
- result = builder.getSource();
- }
- }
- catch( ParseException pe )
- {
- if ( url != null )
- {
- pe.setSourceInfo( url.toExternalForm() );
- }
- if( errorHandler != null )
- {
- errorHandler.handle( pe );
- }
- else
- {
- throw pe;
- }
- }
- return result;
- }
-
- @Override
- protected JavaClass resolveJavaClass( String name )
- {
- // abstractLibrary only calls this when it can't find the source itself.
- // it will take over the reference
- return context.removeClassByName( name );
- }
-
- @Override
- protected JavaPackage resolveJavaPackage(String name) {
- return context.removePackageByName( name );
- }
-
- /**
- *
- * @param source the source, might be <code>null</code>
- */
- protected final void registerJavaSource( JavaSource source )
- {
- if ( source != null )
- {
- context.add( source );
- registerJavaPackage( source.getPackage() );
- for ( JavaClass cls : source.getClasses() )
- {
- registerJavaClass( cls );
- }
- }
- }
-
- private void registerJavaPackage( JavaPackage pckg )
- {
- String pckgName = ( pckg == null || pckg.getName() == null ? "" : pckg.getName() );
- if( getJavaPackage( pckgName ) == null )
- {
- DefaultJavaPackage packageInfo = new DefaultJavaPackage( pckgName );
- packageInfo.setClassLibrary( this );
- context.add( packageInfo );
- }
- }
-
- private void registerJavaClass(JavaClass cls) {
- if (cls != null) {
- context.add( cls );
- getJavaPackage( cls.getPackageName() ).getClasses().add( cls );
- }
- for( JavaClass innerCls : cls.getNestedClasses()) {
- registerJavaClass( innerCls );
- }
- }
-
- /**
- * Use the Lexer in debug mode
- *
- * @param debugLexer
- */
- public final void setDebugLexer( boolean debugLexer )
- {
- this.debugLexer = debugLexer;
- }
-
- public final boolean isDebugLexer()
- {
- return debugLexer;
- }
-
- /**
- * Use the Parser in debug mode
- *
- * @param debugParser
- */
- public final void setDebugParser( boolean debugParser )
- {
- this.debugParser = debugParser;
- }
-
- public final boolean isDebugParser()
- {
- return debugParser;
- }
-
- /**
- * Sets the encoding to use when parsing a URL or InputStreamReader
- *
- * @param encoding
- */
- public final void setEncoding( String encoding )
- {
- this.encoding = encoding;
- }
-
- public final String getEncoding()
- {
- return encoding == null ? DEFAULT_ENCODING : encoding;
- }
-
- public final void setErrorHandler( ErrorHandler errorHandler )
- {
- this.errorHandler = errorHandler;
- }
-
- public final ErrorHandler getErrorHandler()
- {
- return errorHandler;
- }
-
- /**
- * Get all classes, including those from parent SourceLibraries
- */
- @Override
- public Collection<JavaClass> getJavaClasses()
- {
- List<JavaClass> result = new LinkedList<JavaClass>();
- List<JavaClass> unusedClasses = context.getClasses();
- Collection<JavaClass> usedClasses = getJavaClasses( new ClassLibraryFilter()
- {
- public boolean accept( AbstractClassLibrary classLibrary )
- {
- return (classLibrary instanceof SourceLibrary);
- }
- });
- result.addAll( usedClasses );
- result.addAll( unusedClasses );
- return Collections.unmodifiableList( result );
- }
-
- /**
- * Get all packages, including those from parent SourceLibraries
- */
- @Override
- public Collection<JavaPackage> getJavaPackages()
- {
- List<JavaPackage> result = new LinkedList<JavaPackage>();
- List<JavaPackage> unusedPackages = context.getPackages();
- Collection<JavaPackage> usedPackages = getJavaPackages( new ClassLibraryFilter()
- {
- public boolean accept( AbstractClassLibrary classLibrary )
- {
- return (classLibrary instanceof SourceLibrary);
- }
- });
- result.addAll( usedPackages );
- result.addAll( unusedPackages );
- return Collections.unmodifiableList( result );
- }
-
- /**
- * Get all sources, including those from parent SourceLibraries
- */
- @Override
- public Collection<JavaSource> getJavaSources()
- {
- List<JavaSource> result = new LinkedList<JavaSource>();
- List<JavaSource> unusedSources = context.getSources();
- Collection<JavaSource> usedSources = getJavaSources( new ClassLibraryFilter()
- {
- public boolean accept( AbstractClassLibrary classLibrary )
- {
- return (classLibrary instanceof SourceLibrary);
- }
- });
- result.addAll( usedSources );
- result.addAll( unusedSources );
- return Collections.unmodifiableList( result );
- }
-
- @Override
- protected boolean containsClassReference( String name )
- {
- return context.getClassByName( name ) != null;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/library/package-info.java b/src/main/java/com/thoughtworks/qdox/library/package-info.java
deleted file mode 100644
index 7369975..0000000
--- a/src/main/java/com/thoughtworks/qdox/library/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Provides classes to construct a classloader-like structure of libraries
- *
- * There are two types of ClassLibraryBuilders:
- * <ul>
- * <li><code>SortedClassLibraryBuilder</code>, which bundles the libraries by type</li>
- * <li><code>OrderedClassLibraryBuilder</code>, which respects the order of added libraries</li>
- * </ul>
- *
- * There are four types of ClassLibraries:
- * <ul>
- * <li><code>ClassLoaderLibrary</code>, which uses the classpath to search for sources or binaries</li>
- * <li><code>SourceLibrary</code>, which uses a specific sourcefile</li>
- * <li><code>SourceFolderLibrary</code>, which tries to locate sourcefiles by translating the package to folders</li>
- * <li><code>ClassNameLibrary</code>, which generates an anonymous class, as if it would exist</li>
- * </ul>
- *
- */
-package com.thoughtworks.qdox.library;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/BeanProperty.java b/src/main/java/com/thoughtworks/qdox/model/BeanProperty.java
deleted file mode 100644
index 7f54c5f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/BeanProperty.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Aslak Hellesøy
- * @version $Revision$
- */
-public interface BeanProperty
-{
-
- /**
- * The name of the bean, which is based on the name of the mutator or accessor, not on the field.
- *
- * @return the name of the bean
- */
- String getName();
-
- /**
- * The type of the bean, either used as argument type of the mutator or return type of the accessor.
- *
- * @return the type of the bean
- */
- JavaType getType();
-
- /**
- * This can return both the <code>isProperty</code> if the property is of type {@link Boolean} or
- * <code>getProperty</code> for any other type of {@link Object}.
- *
- * @return the getter, otherwise <code>null</code>
- */
- JavaMethod getAccessor();
-
- /**
- * The setter-method of the bean.
- *
- * @return the setter, otherwise <code>null</code>
- */
- JavaMethod getMutator();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/DocletTag.java b/src/main/java/com/thoughtworks/qdox/model/DocletTag.java
deleted file mode 100644
index e658c97..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/DocletTag.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Joe Walnes
- * @author Aslak Hellesøy
- * @version $Revision$
- */
-public interface DocletTag
- extends Serializable
-{
-
- /**
- * The name of the doclet tag.
- *
- * @return the tag name
- */
- String getName();
-
- /**
- * The full value of the doclet tag.
- *
- * @return the full tag-value
- */
- String getValue();
-
- /**
- *
- *
- * @return a list of whitespace-separated tag parameters
- */
- List<String> getParameters();
-
- /**
- * @param key name of a named-parameter
- * @return the matching value, otherwise <code>null</code>
- */
- String getNamedParameter( String key );
-
- /**
- * @return a Map containing all the named-parameters, never <code>null</code>
- */
- Map<String, String> getNamedParameterMap();
-
- /**
- * The line number of the source where this tag occurred.
- *
- * @return the line number where the tag occurred, otherwise <code>-1</code>
- */
- int getLineNumber();
-
- /**
- * The element to which this tag applies.
- *
- * @return the annotated element, should never be <code>null</code>
- * @since 1.4
- */
- JavaAnnotatedElement getContext();
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/DocletTagFactory.java b/src/main/java/com/thoughtworks/qdox/model/DocletTagFactory.java
deleted file mode 100644
index e3d61ac..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/DocletTagFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * @author Aslak Hellesøy
- * @version $Revision$
- */
-public interface DocletTagFactory extends Serializable {
-
- /**
- * @since 1.5
- */
- DocletTag createDocletTag(
- String tag, String text,
- JavaAnnotatedElement context, int lineNumber
- );
-
- DocletTag createDocletTag(String tag, String text);
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaAnnotatedElement.java b/src/main/java/com/thoughtworks/qdox/model/JavaAnnotatedElement.java
deleted file mode 100644
index 191b1ed..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaAnnotatedElement.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-/**
- * <p>
- * Equivalent of {@link java.lang.reflect.AnnotatedElement}, providing the most important methods.
- * Where the original AnnotatedElement uses an Array, the JavaAnnotatedElement is using a {@link List}.
- * </p>
- * <p>
- * Where you can use Annotations, you can also use JavaDoc. For that reason all JavaDoc methods have been added to this interface.
- * </p>
- *
- * @author Robert Scholte
- * @since 2.0
- *
- */
-public interface JavaAnnotatedElement
-{
- // Methods from AnnotatedElement
-
- /**
- *
- * Equivalent of {@link java.lang.reflect.AnnotatedElement#getAnnotations()}
- *
- * @return a list of Annotations, never <code>null</code>
- */
- List<JavaAnnotation> getAnnotations();
-
- // JavaDoc specific methods
-
- /**
- * Retrieve the javadoc comment of this annotated element.
- * This is the part between /** and the */, but without the doclet tags
- *
- * @return the comment, otherwise <code>null</code>
- */
- String getComment();
-
- /**
- * Retrieve all defined doclet tags.
- *
- * @return a list of DocletTags, never <code>null</code>
- */
- List<DocletTag> getTags();
-
- /**
- * Retrieve all doclettags with a specific name.
- *
- * @param name the name of the doclet tag
- * @return a list of doclettags, never <code>null</code>
- */
- List<DocletTag> getTagsByName( String name );
-
- /**
- * Retrieve the doclettag by the specified name.
- * If there are more than one tags, only return the first one.
- *
- * @param name the name of the doclettag trying to retrieve
- * @return the first doclettag matching the name, otherwise <code>null</code>
- */
- DocletTag getTagByName( String name );
-
- /**
- * Convenience method for <code>getTagByName(String).getNamedParameter(String)</code>
- * that also checks for null tag.
- *
- * @param tagName the tag name
- * @param parameterName the parameter name
- * @return the value of the matching parameter, otherwise <code>null</code>
- * @since 1.3
- */
- String getNamedParameter(String tagName, String parameterName);
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaAnnotation.java b/src/main/java/com/thoughtworks/qdox/model/JavaAnnotation.java
deleted file mode 100644
index ace40b2..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaAnnotation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Map;
-
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-
-public interface JavaAnnotation {
-
- /**
- * @return the annotation type
- */
- JavaClass getType();
-
- Map<String, AnnotationValue> getPropertyMap();
-
- AnnotationValue getProperty(String name);
-
- Map<String, Object> getNamedParameterMap();
-
- Object getNamedParameter(String key);
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaClass.java b/src/main/java/com/thoughtworks/qdox/model/JavaClass.java
deleted file mode 100644
index e21fe53..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaClass.java
+++ /dev/null
@@ -1,517 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.impl.JavaClassParent;
-
-/**
- * Equivalent of {@link java.lang.Class}, providing the most important methods.
- * Where the original Class is using an Array, this model is using a List.
- *
- * @author Robert Scholte
- */
-public interface JavaClass extends JavaModel, JavaType, JavaClassParent, JavaAnnotatedElement, JavaGenericDeclaration
-{
-
- // deprecated methods
- // will be removed with QDox-2.0
-
- /**
- * @deprecated the JavaClass should have the same methods
- */
- JavaType asType();
-
- /**
- * @deprecated Use {@link #getNestedClasses()} instead.
- */
- List<JavaClass> getClasses();
-
- /**
- * @deprecated use {@link #getNestedClassByName(String)} instead
- */
- JavaClass getInnerClassByName(String name);
-
- /**
- * @deprecated use {@link #getNestedClasses()} instead
- */
- List<JavaClass> getInnerClasses();
-
- /**
- * @deprecated use {@link #getParentSource()} or {@link #getDeclaringClass()}
- */
- JavaClassParent getParent();
-
- /**
- * @deprecated use {@link #resolveCanonicalName(String)} or {@link #resolveFullyQualifiedName(String)} instead
- */
- String resolveType( String name );
-
- /**
- * (API description of {@link java.lang.Class#isInterface()})
- * <p>
- * Determines if the specified <code>Class</code> object represents an interface type.
- * </p>
- *
- * @return <code>true</code> if this object represents an interface, otherwise <code>false</code>
- */
- boolean isInterface();
-
- /**
- * (API description of {@link java.lang.Class#isEnum()})
- * <p>
- * Returns <code>true</code> if and only if this class was declared as an enum in the source code.
- * </p>
- *
- * @return <code>true</code> if this object represents an enum, otherwise <code>false</code>
-
- */
- boolean isEnum();
-
- /**
- * (API description of {@link java.lang.Class#isAnnotation()})
- * <p>Returns true if this <code>Class</code> object represents an annotation type.
- * Note that if this method returns true, {@link #isInterface()} would also return true, as all annotation types are also interfaces.
- * </p>
- *
- * @return <code>true</code> if this object represents an annotation, otherwise <code>false</code>
- * @since 2.0
- */
- boolean isAnnotation();
-
- JavaClass getDeclaringClass();
-
- JavaType getSuperClass();
-
- /**
- * Shorthand for getSuperClass().getJavaClass() with null checking.
- */
- JavaClass getSuperJavaClass();
-
- List<JavaType> getImplements();
-
- /**
- * @since 1.3
- */
- List<JavaClass> getImplementedInterfaces();
-
- /**
- * Equivalent of {@link java.lang.Class#getInterfaces()}
- * Determines the interfaces implemented by the class or interface represented by this object. *
- *
- * @return a list of interfaces, never <code>null</code>
- * @since 2.0
- */
- List<JavaClass> getInterfaces();
-
- String getCodeBlock();
-
- JavaSource getParentSource();
-
- /**
- * Equivalent of {@link java.lang.Class#getPackage()}
- * @return
- */
- JavaPackage getPackage();
-
- /**
- * If this class has a package, the packagename will be returned.
- * Otherwise an empty String.
- *
- * @return the name of the package, otherwise an empty String
- */
- String getPackageName();
-
- /**
- * @since 1.3
- * @return <code>true</code> if this class is an inner class, otherwise <code>false</code>
- */
- boolean isInner();
-
- /**
- * The name can be both absolute (including the package) or relative (matching a subclass or an import).
- *
- * Tries to return the fully qualified name based on the name.
- * The name tries to match the following:
- * <ul>
- * <li>primitives or void</li>
- * <li>java.lang.*</li>
- * <li>inner classes</li>
- * <li>explicit imports</li>
- * <li>implicit imports</li>
- * </ul>
- *
- * @param name the name to resolve
- * @return the resolved canonical name, otherwise <code>null</code>
- * @since 2.0
- */
- String resolveCanonicalName( String name );
-
- /**
- * The name can be both absolute (including the package) or relative (matching a subclass or an import).
- *
- * Tries to return the fully qualified name based on the name.
- * The name tries to match the following:
- * <ul>
- * <li>primitives or void</li>
- * <li>java.lang.*</li>
- * <li>inner classes</li>
- * <li>explicit imports</li>
- * <li>implicit imports</li>
- * </ul>
- *
- * @param name the name to resolve
- * @return the resolved fully qualified name, otherwise <code>null</code>
- * @since 2.0
- */
- String resolveFullyQualifiedName( String name );
-
- /**
- * If this class has a package, it will return the package name, followed by a "."(dot).
- * Otherwise it will return an empty String
- *
- * @return the package name plus a dot if there's a package, otherwise an empty String
- */
- String getClassNamePrefix();
-
- /**
- * Equivalent of {@link java.lang.Class#getMethods()}
- *
- * @return the methods declared or overridden in this class
- */
- List<JavaMethod> getMethods();
-
- /**
- * Equivalent of {@link java.lang.Class#getConstructors()}
- *
- * @return the list of constructors
- * @since 2.0
- */
- List<JavaConstructor> getConstructors();
-
-
- /**
- *
- * @param parameterTypes the parameter types of the constructor, can be <code>null</code>
- * @return the matching constructor, otherwise <code>null</code>
- * @since 2.0
- */
- JavaConstructor getConstructor(List<JavaType> parameterTypes);
-
- /**
- *
- * @param parameterTypes the parameter types of the constructor, can be <code>null</code>
- * @param varArg define is the constructor has varArgs
- * @return the matching constructor, otherwise <code>null</code>
- * @since 2.0
- */
- JavaConstructor getConstructor(List<JavaType> parameterTypes, boolean varArg);
-
-
- /**
- * @since 1.3
- */
- List<JavaMethod> getMethods( boolean superclasses );
-
- /**
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null</code>.
- * @return the matching method, otherwise <code>null</code>
- */
- JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes );
-
- /**
- * This should be the signature for getMethodBySignature.
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null<code>
- * @param varArgs define if the method has varArgs
- * @return the matching method, otherwise <code>null</code>
- */
- JavaMethod getMethod( String name, List<JavaType> parameterTypes, boolean varArgs );
-
- /**
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null</code>
- * @param superclasses to define if superclasses should be included as well
- * @return the matching method, otherwise <code>null</code>
- */
- JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses );
-
- /**
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null<code>
- * @param superclasses
- * @param varArg define if the method has varArgs
- * @return the matching method, otherwise <code>null</code>
- */
- JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg );
-
- /**
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null<code>
- * @param superclasses to define if superclasses should be included as well
- * @return the matching methods, otherwise <code>null</code>
- */
- List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses );
-
- /**
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null<code>
- * @param superclasses to define if superclasses should be included as well
- * @param varArg define if the method has varArgs
- * @return the matching methods, otherwise <code>null</code>
- */
- List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses,
- boolean varArg );
-
- /**
- * Equivalent of {@link java.lang.Class#getFields()}
- *
- * @return a list of fiels, never <code>null</code>
- */
- List<JavaField> getFields();
-
- /**
- * Equivalent of {@link java.lang.Class#getField(String)}, where this method can resolve every field
- *
- * @param name
- * @return
- */
- JavaField getFieldByName( String name );
-
- /**
- * Based on {@link java.lang.Class#getEnumConstants()}.
- *
- *
- * @return a List of enum constants if this class is an <code>enum</code>, otherwise <code>null</code>
- */
- List<JavaField> getEnumConstants();
-
- /**
- *
- *
- * @return the enumConstant matching the {@code name}, otherwise <code>null</code>
- */
- JavaField getEnumConstantByName( String name );
-
- /**
- * Equivalent of {@link Class#getDeclaredClasses()}
- *
- * @return a list of declared classes, never <code>null</code>
- * @since 1.3
- */
- List<JavaClass> getNestedClasses();
-
- JavaClass getNestedClassByName( String name );
-
- /**
- * @since 1.3
- */
- boolean isA( String fullyQualifiedName );
-
- /**
- * @param javaClass
- * @since 1.3
- */
- boolean isA( JavaClass javaClass );
-
- /**
- *
- * @return the number of dimensions, at least 0
- * @since 2.0
- */
- int getDimensions();
-
- /**
- *
- * @return <code>true</code> if this JavaClass is an array, otherwise <code>false</code>
- * @since 2.0
- */
- boolean isArray();
-
- /**
- *
- * @return <code>true</code> if this JavaClass is a void, otherwise <code>false</code>
- * @since 2.0 (was part of Type since 1.6)
- */
- boolean isVoid();
-
- /**
- * Equivalent of {@link Class#getComponentType()}
- * If this type is an array, return its component type
- *
- * @return the type of array if it's one, otherwise <code>null</code>
- */
- JavaClass getComponentType();
-
- /**
- * Gets bean properties without looking in superclasses or interfaces.
- *
- * @since 1.3
- */
- List<BeanProperty> getBeanProperties();
-
- /**
- *
- * @param superclasses to define if superclasses should be included as well
- * @since 1.3
- */
- List<BeanProperty> getBeanProperties( boolean superclasses );
-
- /**
- * Gets bean property without looking in superclasses or interfaces.
- *
- * @param propertyName the name of the property
- * @since 1.3
- */
- BeanProperty getBeanProperty( String propertyName );
-
- /**
- * @param propertyName the name of the property
- * @param superclasses to define if superclasses should be included as well
- *
- * @since 1.3
- */
- BeanProperty getBeanProperty( String propertyName, boolean superclasses );
-
- /**
- * Equivalent of {@link Class#getClasses()}
- * Gets the known derived classes. That is, subclasses or implementing classes.
- */
- List<JavaClass> getDerivedClasses();
-
- List<DocletTag> getTagsByName( String name, boolean superclasses );
-
- ClassLibrary getJavaClassLibrary();
-
- /**
- * A list if {@link JavaInitializer}, either static or instance initializers.
- *
- * @return a List of initializers
- */
- List<JavaInitializer> getInitializers();
-
- /**
- * Equivalent of {@link java.lang.Class#getName()}.
- *
- * @return the fully qualified name of the class
- */
- String getName();
-
- /**
- * Equivalent of {@link Class#getModifiers()}
- *
- * <strong>This does not follow the java-api</strong>
- * The Class.getModifiers() returns an <code>int</code>, which should be decoded with the {@link java.lang.reflect.Modifier}.
- * This method will return a list of strings representing the modifiers.
- * If this member was extracted from a source, it will keep its order.
- * Otherwise if will be in the preferred order of the java-api.
- *
- * @return all modifiers is this member
- */
- List<String> getModifiers();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isPublic(int)})
- * <p>
- * Return <code>true</code> if the class includes the public modifier, <code>false</code> otherwise.
- * <p>
- *
- * @return <code>true</code> if class has the public modifier, otherwise <code>false</code>
- */
- boolean isPublic();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isProtected(int)})
- * <p>
- * Return <code>true</code> if the class includes the protected modifier, <code>false</code> otherwise.
- * </p>
- *
- * @return <code>true</code> if class has the protected modifier, otherwise <code>false</code>
- */
- boolean isProtected();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isPrivate(int)})
- * <p>
- * Return <code>true</code> if the class includes the private modifier, <code>false</code> otherwise.
- * </p>
- *
- * @return <code>true</code> if class has the private modifier, otherwise <code>false</code>
- */
- boolean isPrivate();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isFinal(int)})
- * <p>
- * Return <code>true</code> if the class includes the final modifier, <code>false</code> otherwise.
- * </p>
- *
- * @return <code>true</code> if class has the final modifier, otherwise <code>false</code>
- */
- boolean isFinal();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isStatic(int)})
- * <p>
- * Return <code>true</code> if the class includes the static modifier, <code>false</code> otherwise.
- * </p>
- *
- * @return <code>true</code> if class the static modifier, otherwise <code>false</code>
- */
- boolean isStatic();
-
- /**
- * (API description of {@link java.lang.reflect.Modifier#isAbstract(int)})
- *
- * Return <code>true</code> if the class includes the abstract modifier, <code>false</code> otherwise.
- *
- * @return <code>true</code> if class has the abstract modifier, otherwise <code>false</code>
- */
- boolean isAbstract();
-
- /**
- * Equivalent of {@link java.lang.Class#isPrimitive()}
- *
- * @return <code>true</code> if this class represents a primitive, otherwise <code>false</code>
- */
- boolean isPrimitive();
-
- /**
- * (API description of {@link java.lang.Class#toString()})
- *
- * Converts the object to a string.
- * The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by <code>getName</code>.
- * If this <code>Class</code> object represents a primitive type, this method returns the name of the primitive type.
- * If this <code>Class</code> object represents void this method returns "void".
- *
- * @return a string representation of this class object.
- */
- @Override
- String toString();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java b/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java
deleted file mode 100644
index b8406d3..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaConstructor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Modeled equivalent of {@link java.lang.reflect.Constructor}, providing the most important methods.
- * Where the original Constructor is using an Array, this model is using a {@link List}.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface JavaConstructor
- extends JavaModel, JavaAnnotatedElement, JavaGenericDeclaration, JavaMember, ParameterDeclarator, Serializable
-{
- // Methods from Constructor
-
- /**
- * Equivalent of {@link java.lang.reflect.Constructor#getParameterTypes()}, where a JavaParameter also contains the original name if available.
- *
- * @return a list of JavaParameters, never <code>null</code>
- */
- List<JavaParameter> getParameters();
-
- /**
- *
- * @param name the name of the parameter
- * @return the {@link JavaParameter} matching the name, otherwise <code>null</code>
- */
- JavaParameter getParameterByName( String name );
-
- /**
- * Equivalent of {@link java.lang.reflect.Constructor#getParameterTypes()}
- *
- * @return a list of JavaParameters, never <code>null</code>
- */
- List<JavaType> getParameterTypes();
-
- /**
- * Equivalent of {@link java.lang.reflect.Constructor#getExceptionTypes()}
- *
- * @return a list of Exceptions, never <code>null</code>
- */
- List<JavaClass> getExceptions();
-
- List<JavaType> getExceptionTypes();
-
- /**
- * Equivalent of {@link java.lang.reflect.Constructor#isVarArgs()}
- *
- * @return <code>true</code> if the final parameter is a varArg, otherwise <code>false</code>
- */
- boolean isVarArgs();
-
- // Extra source methods
-
- /**
- * Retrieve the code between the brackets
- *
- * @return the source code
- */
- String getSourceCode();
-
- /**
- * Retrieve the complete codeblock of the constructor, including the sourcecode.
- *
- * @return the code block
- */
- String getCodeBlock();
-
- // Utility methods
-
- /**
- * Returns <code>true</code> if this constructor matches the parameterTypes, assuming it's a non-varArg constructor.
- *
- * @param parameterTypes
- * @return <code>true</code> if signature matches, otherwise <code>false</code>
- */
- boolean signatureMatches( List<JavaType> parameterTypes );
-
- /**
- * Returns <code>true</code> if this constructor matches the parameterTypes and matches the varArg argument.
- *
- * @param parameterTypes
- * @param varArgs
- * @return <code>true</code> if signature matches, otherwise <code>false</code>
- */
- boolean signatureMatches( List<JavaType> parameterTypes, boolean varArgs );
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaField.java b/src/main/java/com/thoughtworks/qdox/model/JavaField.java
deleted file mode 100644
index ff23a05..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaField.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.model.expression.Expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Modeled equivalent of {@link java.lang.reflect.Field}, providing the most important methods.
- * Where the original Field is using an Array, this model is using a {@link java.util.List}.
- *
- */
-public interface JavaField extends JavaAnnotatedElement, JavaMember, JavaModel
-{
- // Methods of Field
-
- /**
- * Equivalent of {@link java.lang.reflect.Field#getType()}
- *
- * @return the type of this field, should never be <code>null</code>.
- */
- JavaClass getType();
-
- // Source methods
-
- /**
- * The in-code representation of this field.
- *
- * @return the complete representation of this field
- */
- String getCodeBlock();
-
- @Deprecated
- String getDeclarationSignature( boolean withModifiers );
-
- @Deprecated
- String getCallSignature();
-
- /**
- * Get the original expression used to initialize the field.
- *
- * @return initialization as string.
- */
- String getInitializationExpression();
-
- /**
- * Equivalent of {@link java.lang.reflect.Field#isEnumConstant()}
- *
- * @return <code>true</code> if this field is an enum constant, otherwise <code>false</code>
- * @since 2.0
- */
- boolean isEnumConstant();
-
- /**
- *
- * @return the classBody of the enum constant
- * @since 2.0
- */
- JavaClass getEnumConstantClass();
-
- /**
- *
- *
- * @return the arguments of the enum constant
- * @since 2.0
- */
- List<Expression> getEnumConstantArguments();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java b/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java
deleted file mode 100644
index 6a0c612..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaGenericDeclaration.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-/**
- * Equivalent of {@link java.lang.reflect.GenericDeclaration}.
- * Where the original GenericDeclaration uses an Array, the JavaGenericDeclaration is using a {@link List}.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface JavaGenericDeclaration
-{
- /**
- * Equivalent of {@link java.lang.reflect.GenericDeclaration#getTypeParameters()}
- *
- * @return a list of typeParameters, never <code>null</code>
- */
- <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters();
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaInitializer.java b/src/main/java/com/thoughtworks/qdox/model/JavaInitializer.java
deleted file mode 100644
index cb37fb7..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaInitializer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import java.io.Serializable;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * A {@link JavaClass} can have contain one of the following initializers:
- * <ul>
- * <li>A static initializer declared in a class is executed when the class is initialized</li>
- * <li>An instance initializer declared in a class is executed when an instance of the class is created</li>
- * </ul>
- *
- * In code this would look like:
- * <pre>
- * public class Example {
- *
- * static {
- * // static initializer
- * }
- *
- * {
- * // instance initializer
- * }
- *
- * }
- * </pre>
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface JavaInitializer extends Serializable
-{
- boolean isStatic();
-
- String getBlockContent();
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaMember.java b/src/main/java/com/thoughtworks/qdox/model/JavaMember.java
deleted file mode 100644
index 386a957..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaMember.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-/**
- * JavaModel representation of a {@link java.lang.reflect.Member} including related methods of {@link java.lang.reflect.Modifier}
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface JavaMember
-{
- /**
- * Equivalent of {@link java.lang.reflect.Member#getModifiers()}
- *
- * <strong>This does not follow the java-api</strong>
- * With the Member-class, getModifiers returns an <code>int</code>, which should be decoded with the Modifier.
- * If this member was extracted from a source, it will keep its order.
- * Otherwise if will be in the preferred order of the java-api.
- *
- * @return all modifiers is this member
- */
- List<String> getModifiers();
-
- /**
- * Equivalent of {@link java.lang.reflect.Member#getDeclaringClass()}
- *
- * @return the declaring class
- */
- JavaClass getDeclaringClass();
-
- /**
- * Equivalent of {@link java.lang.reflect.Member#getName()}
- *
- * @return the name of this member
- */
- String getName();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isAbstract(int)}
- *
- * @return <code>true</code> if this member is <code>abstract</code>, otherwise <code>false</code>
- */
- boolean isAbstract();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isFinal(int)}
- *
- * @return <code>true</code> is this member is <code>final</code>, otherwise <code>false</code>
- */
- boolean isFinal();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isNative(int)}
- *
- * @return <code>true</code> if this member is <code>native</code>, otherwise <code>false</code>
- */
- boolean isNative();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isPrivate(int)}
- *
- * @return <code>true</code> if this member is <code>private</code>, otherwise <code>false</code>
- */
- boolean isPrivate();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isProtected(int)}
- *
- * @return <code>true</code> if this member is <code>protected</code>; otherwise <code>false</code>
- */
- boolean isProtected();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isPublic(int)}
- *
- * @return <code>true</code> if this member is <code>public</code>, otherwise <code>false</code>
- */
- boolean isPublic();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isStatic(int)}
- *
- * @return <code>true</code> if this member is <code>static</code>, otherwise <code>false</code>
- */
- boolean isStatic();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isStrict(int)}
- *
- * @return <code>true</code> if this member is <code>strictfp</code>, otherwise <code>false</code>
- */
- boolean isStrictfp();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isSynchronized(int)}
- *
- * @return <code>true</code> if this member is <code>synchronized</code>, otherwise <code>false</code>
- */
- boolean isSynchronized();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isTransient(int)}
- *
- * @return <code>true</code> if this member is <code>transient</code>, otherwise <code>false</code>
- */
- boolean isTransient();
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isVolatile(int)}
- *
- * @return <code>true</code> if this member is <code>volatile</code>, otherwise <code>false</code>
- */
- boolean isVolatile();
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java b/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java
deleted file mode 100644
index d859198..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaMethod.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public interface JavaMethod extends JavaAnnotatedElement, JavaMember, JavaModel, JavaGenericDeclaration, ParameterDeclarator
-{
-
- // deprecated methods
- // will be removed with QDox-2.0
-
- /**
- * Equivalent of java.lang.reflect.Method.getGenericReturnType()
- *
- * @return the generic return type
- * @since 1.12
- * @deprecated use {@link #getReturnType()} instead, this one holds generic information
- */
- JavaClass getGenericReturnType();
-
- /**
- * @deprecated use {@link #getDeclaringClass()} instead
- */
- JavaClass getParentClass();
-
- /**
- *
- * @return the return type
- */
- JavaClass getReturns();
-
- List<JavaParameter> getParameters();
-
- JavaParameter getParameterByName( String name );
-
- List<JavaClass> getExceptions();
-
- List<JavaType> getExceptionTypes();
-
- /**
- * Equivalent of {@link java.lang.reflect.Method#isVarArgs()}
- *
- * @return <code>true</code> if this method was declared to take a variable number of arguments,
- * otherwise <code>false</code>
- */
- boolean isVarArgs();
-
- /**
- * @since 1.3
- */
- String getDeclarationSignature( boolean withModifiers );
-
- /**
- * @since 1.3
- */
- String getCallSignature();
-
- /**
- * This method is NOT varArg aware.
- *
- * @param name the name of the method
- * @param parameterTypes the parameter types of the method, can be <code>null</code>
- * @return <code>true</code> if this method matches the signature, otherwise <code>false</code>
- */
- boolean signatureMatches( String name, List<JavaType> parameterTypes );
-
- /**
- * @param name the name of the method
- * @param parameterTypes the parameter types, can be <code>null</code>
- * @param varArg <code>true</code> is signature should match a varArg-method, otherwise <code>false</code>
- * @return <code>true</code> if this method matches the signature, otherwise <code>false</code>
- */
- boolean signatureMatches( String name, List<JavaType> parameterTypes, boolean varArg );
-
- /**
- * Returns <code>true</code> if this method follows the bean convention of being an accessor.
- *
- * <pre>
- * public String getName(); // true
- * public boolean isValid() // true
- * public String getName( String def ); // false, it has a parameter
- * public String gettingUp(); // false, 'get' is not followed by an uppercase character
- * public boolean isolate(); // false, 'is' is not followed by an uppercase character
- * public static String getName(); // false, it is static
- * </pre>
- *
- * @return <code>true</code> if this method is a Java Bean accessor, otherwise <code>false</code>
- * @since 1.3
- */
- boolean isPropertyAccessor();
-
- /**
- * Returns <code>true</code> if this method follows the bean convention of being an mutator.
- *
- * <pre>
- * public void setName(String name); // true
- * public void setUp(); // false, it has no parameter
- * public void settingUp(String def); // false, 'set' is not followed by an uppercase character
- * public static void setName(String name); // false, it is static
- * </pre>
- *
- * @return <code>true</code> if this method is a Java Bean mutator, otherwise <code>false</code>
- * @since 1.3
- */
- boolean isPropertyMutator();
-
- /**
- * @return the type of the property this method represents, or <code>null</code> if this method
- * is not a property mutator or property accessor.
- * @since 1.3
- */
- JavaType getPropertyType();
-
- /**
- * @return the name of the property this method represents, or <code>null</code> if this method
- * is not a property mutator or property accessor.
- * @since 1.3
- */
- String getPropertyName();
-
- List<DocletTag> getTagsByName( String name, boolean inherited );
-
- /**
- * Get the original source code of the body of this method.
- *
- * @return Code as string.
- */
- String getSourceCode();
-
- /**
- * Equivalent of java.lang.reflect.Method.getReturnType()
- *
- * @return the return type
- * @since 1.12
- */
- JavaType getReturnType();
-
- /**
- * If a class inherits this method from a generic class or interface, you can use this method to get the resolved return type
- *
- * @param resolve define if generic should be resolved
- * @return the return type
- * @since 1.12
- */
- JavaType getReturnType( boolean resolve );
-
- /**
- *
- * @return the parameter types
- * @since 1.12
- */
- List<JavaType> getParameterTypes();
-
- /**
- * If a class inherits this method from a generic class or interface, you can use this method to get the resolved parameter types
- *
- * @param resolve
- * @return the parameter types
- * @since 1.12
- */
- List<JavaType> getParameterTypes( boolean resolve );
-
- DocletTag getTagByName( String string, boolean b );
-
- /**
- * Equivalent {@link java.lang.reflect.Method#isDefault()}
- *
- * @return {@code true} if this is a default method of an interface, otherwise {@code false}
- * @since 2.0
- */
- boolean isDefault();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaModel.java b/src/main/java/com/thoughtworks/qdox/model/JavaModel.java
deleted file mode 100644
index 4b0ffd1..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaModel.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-public interface JavaModel extends Serializable
-{
- /**
- *
- * @return the codeblock
- */
- String getCodeBlock();
-
- /**
- * The compilation unit, which includes the imports, the public and anonymous classes
- *
- * @return the {@link JavaSource} of this element
- */
- JavaSource getSource();
-
- /**
- * The line number where this element started
- *
- * @return the line number of this element
- */
- int getLineNumber();
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaModelUtils.java b/src/main/java/com/thoughtworks/qdox/model/JavaModelUtils.java
deleted file mode 100644
index 3772564..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaModelUtils.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public final class JavaModelUtils
-{
-
- private JavaModelUtils()
- {
- // hide constructor for utility class
- }
-
- /**
- * <p>
- * Try to resolve the class by the {@code name}, either relative from {@code cls}
- * as the fully qualified name.
- * </p>
- * <strong>Note:</strong>the name must match the {@code cls} itself or one of its nested classes.
- *
- * @param cls
- * @param name
- * @return the matching class, otherwise <code>null</code>
- * @see JavaClass#getJavaClassLibrary()
- */
- public static JavaClass getClassByName( JavaClass cls, String name )
- {
- JavaClass result = null;
- if ( cls.getFullyQualifiedName().equals( name ) )
- {
- result = cls;
- }
- else if ( cls.getName().equals( name ) )
- {
- result = cls;
- }
- else
- {
- for ( JavaClass innerCls : cls.getClasses() )
- {
- result = getClassByName( innerCls, name );
- if ( result != null )
- {
- break;
- }
- }
- }
- return result;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaPackage.java b/src/main/java/com/thoughtworks/qdox/model/JavaPackage.java
deleted file mode 100644
index 1053a71..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaPackage.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-
-public interface JavaPackage extends JavaModel, JavaAnnotatedElement
-{
-
- /**
- * Returns all the classes found for the package.
- *
- * @return all the classes found for the package, never <code>null</code>
- */
- Collection<JavaClass> getClasses();
-
- /**
- * Try to get any class of this package by name.
- * The name can be both the fully qualified name or just the name of the class.
- *
- * @param name the (fully qualified) name of the class
- * @return the matching class, otherwise <code>null</code>
- * @since 2.0
- */
- JavaClass getClassByName( String name );
-
- /**
- * The parent of this package
- *
- * For instance: the package of <code>java.lang.reflect</code> is <code>java.lang</code>
- *
- * @return the parent package, otherwise <code>null</code>
- */
- JavaPackage getParentPackage();
-
- /**
- * For instance: one of the children of <code>java.lang</code> would be <code>java.lang.reflect</code>
- *
- * @return all the children of this package , never <code>null</code>
- */
- Collection<JavaPackage> getSubPackages();
-
- /**
- * Equivalent of {@link Package#getName()}
- *
- * @return the name, should never be <code>null</code>
- */
- String getName();
-
- /**
- * The {@link ClassLibrary} of this package.
- *
- * @return the classLibrary, should never be <code>null</code>
- */
- ClassLibrary getJavaClassLibrary();
-
- /**
- * Equivalent of {@link Package#toString()}
- *
- * @return the string representation of the package.
- */
- String toString();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java b/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java
deleted file mode 100644
index f80c912..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaParameter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * JavaParameter is an extended version of JavaClass and doesn't exist in the java api.
- *
- * @author Robert Scholte
- *
- */
-public interface JavaParameter extends JavaAnnotatedElement, JavaType
-{
-
- /**
- *
- * @return the name of the parameter
- */
- String getName();
-
- /**
- *
- * @return the type of this parameter
- */
- JavaType getType();
-
- JavaClass getJavaClass();
-
- /**
- * Returns the declaring method or constructor of this parameter
- *
- * @return the declaring method or constructor
- */
- ParameterDeclarator getDeclarator();
-
- /**
- * The declaring class of the declaring method of this parameter.
- *
- * @return the declaring class of the declaring method
- */
- JavaClass getParentClass();
-
- /**
- * Is this a Java 5 var args type specified using three dots. e.g. <code>void doStuff(Object... thing)</code>
- *
- * @since 1.6
- */
- boolean isVarArgs();
-
- /**
- *
- * @return the value of the type, never <code>null</code>
- */
- String getValue();
-
- /**
- *
- * @return the FQN of the type, never <code>null</code>
- */
- String getFullyQualifiedName();
-
- /**
- * @return the canonical name of the type, never <code>null</code>
- * @since 2.0
- */
- String getCanonicalName();
-
- /**
- * @return the resolved value of the type
- * @since 1.10
- */
- String getResolvedValue();
-
- /**
- *
- * @return the resolved generic value of the type, never <code>null</code>
- * @since 2.0
- */
- String getResolvedGenericValue();
-
- /**
- *
- * @return the resolved FQN, never <code>null</code>
- * @since 2.0
- */
- String getResolvedFullyQualifiedName();
-
- /**
- *
- * @return the resolved generic FQN, never <code>null</code>
- * @since 2.0
- */
- String getResolvedGenericFullyQualifiedName();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaParameterizedType.java b/src/main/java/com/thoughtworks/qdox/model/JavaParameterizedType.java
deleted file mode 100644
index eee9c85..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaParameterizedType.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-/**
- * Equivalent of {@link java.lang.reflect.ParameterizedType}.
- *
- * @since 2.0
- * @author Robert Scholte
- */
-public interface JavaParameterizedType extends JavaType
-{
- List<JavaType> getActualTypeArguments();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaSource.java b/src/main/java/com/thoughtworks/qdox/model/JavaSource.java
deleted file mode 100644
index 141e25f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaSource.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.URL;
-import java.util.List;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.impl.JavaClassParent;
-
-/**
- * The root of every JavaModel, even for those based on binary classes.
- *
- * @author Robert Scholte
- */
-public interface JavaSource extends JavaClassParent
-{
-
- /**
- * @since 1.4
- */
- URL getURL();
-
- /**
- * The package of this source or <code>null</code>
- *
- * @return the package
- */
- JavaPackage getPackage();
-
- /**
- * Retrieve all the import
- *
- * @return the imports, never <code>null</code>
- */
- List<String> getImports();
-
- /**
- * A List with all direct classes of this source, never <code>null</code>
- *
- * @return a list of JavaClasses, never <code>null</code>
- */
- List<JavaClass> getClasses();
-
- /**
- * Complete code representation of this source
- *
- * @return the code block of this source
- */
- String getCodeBlock();
-
- /**
- * @deprecated use {@link #resolveCanonicalName(String)} or {@link #resolveFullyQualifiedName(String)} instead
- */
- String resolveType( String typeName );
-
- /**
- * @param name the simple name or canonical name of a class
- * @return the resolved canonical name, otherwise <code>null</code>
- */
- String resolveCanonicalName( String name );
-
- /**
- * @param name the simple name or canonical name of a class
- * @return the resolved fully qualified name, otherwise <code>null</code>
- */
- String resolveFullyQualifiedName( String name );
-
- /**
- * If there's a package, return the packageName, followed by a dot, otherwise an empty String
- *
- * @return the class name prefix, otherwise an empty String
- */
- String getClassNamePrefix();
-
- /**
- * Try to get the JavaClass child based on its name relative to the package.
- * This doesn't try to resolve it by recursion.
- *
- * @return the resolved JavaClass, otherwise <code>null</code>
- */
- JavaClass getNestedClassByName( String name );
-
- /**
- * Try to get any class of this source by name.
- * The name can be both the fully qualified name or just the name of the class.
- *
- * @param name the (fully qualified) name of the class
- * @return the matching class, otherwise <code>null</code>
- * @since 2.0
- */
- JavaClass getClassByName( String name );
-
- ClassLibrary getJavaClassLibrary();
-
- /**
- * Returns the name of the package or an empty String if there's no package
- *
- * @return the package name, otherwise an empty String
- */
- String getPackageName();
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaType.java b/src/main/java/com/thoughtworks/qdox/model/JavaType.java
deleted file mode 100644
index d85b4e2..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaType.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Equivalent of {@link java.lang.reflect.Type}.
- *
- */
-public interface JavaType
-{
- JavaType VOID = new JavaType()
- {
- private final String value = "void";
-
- public String getCanonicalName()
- {
- return value;
- }
-
- public String getGenericCanonicalName()
- {
- return value;
- }
-
- public String getFullyQualifiedName()
- {
- return value;
- }
-
- public String getGenericFullyQualifiedName()
- {
- return value;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public String getGenericValue()
- {
- return value;
- }
-
- public String toGenericString()
- {
- return value;
- }
- };
-
- /**
- * Equivalent of (@link {@link java.lang.Class#getCanonicalName()}.
- *
- * @return the canonical name of this class
- */
- String getCanonicalName();
-
- /**
- * The canonical name with generic information.
- *
- * @return the generic canonical name
- */
- String getGenericCanonicalName();
-
- /**
- * Returns the FQN of an Object or the handler of a Type.
- * If the name of the can't be resolved based on the imports and the classes on the classpath the name will be returned.
- * InnerClasses will use the $ sign.
- * If the type is an array, the brackets will be included. The get only the name, use {@link #getComponentType()}.
- *
- * Some examples how names will be translated
- * <pre>
- * Object > java.lang.Object
- * java.util.List > java.util.List
- * ? > ?
- * T > T
- * anypackage.Outer.Inner > anypackage.Outer$Inner
- * String[][] > java.lang.String[][]
- * </pre>
- *
- * @return the fully qualified name, never <code>null</code>
- * @see #getComponentType()
- */
- String getFullyQualifiedName();
-
- /**
- * The fully qualified nate with generic information.
- *
- * @return the generic fully qualified name
- */
- String getGenericFullyQualifiedName();
-
- /**
- * If there's a reference to this class, use the value used in the code. Otherwise return the simple name.
- * When including all imports, you should be safe to use this method.
- * This won't return generics, so it's java1.4 safe.
- *
- * Examples:
- * <pre>
- * private String fieldA; // getValue() will return "String"
- * private java.lang.String fieldA; // getValue() will return "java.lang.String"
- * private List<String> aList; // getValue() will return "List"
- * </pre>
- *
- * @return the name of the class as used in the source
- */
- String getValue();
-
- /**
- * A java5+ representation of the class.
- * When including all imports, you should be safe to use this method.
- *
- * Examples:
- * <pre>
- * private String fieldA; // getValue() will return "String"
- * private java.lang.String fieldA; // getValue() will return "java.lang.String"
- * private List<String> aList; // getValue() will return "List<String>"
- * </pre>
- * @return the generic name of the class as used in the source
- */
- String getGenericValue();
-
- @Deprecated
- String toGenericString();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java b/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java
deleted file mode 100644
index 36553ae..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaTypeVariable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public interface JavaTypeVariable<D extends JavaGenericDeclaration> extends JavaType
-{
- D getGenericDeclaration();
-
- String getName();
-
- List<JavaType> getBounds();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/JavaWildcardType.java b/src/main/java/com/thoughtworks/qdox/model/JavaWildcardType.java
deleted file mode 100644
index 917540c..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/JavaWildcardType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Equivalent of {@link java.lang.reflect.WildcardType}
- */
-public interface JavaWildcardType extends JavaType
-{
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/ParameterDeclarator.java b/src/main/java/com/thoughtworks/qdox/model/ParameterDeclarator.java
deleted file mode 100644
index 01b4d66..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/ParameterDeclarator.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-/**
- * Can either be a Method or a Constructor
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface ParameterDeclarator extends JavaGenericDeclaration
-{
- JavaClass getParentClass();
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Add.java b/src/main/java/com/thoughtworks/qdox/model/expression/Add.java
deleted file mode 100644
index 89905fb..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Add.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Add
- extends BinaryOperator
-{
-
- public Add( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " + " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " + " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/And.java b/src/main/java/com/thoughtworks/qdox/model/expression/And.java
deleted file mode 100644
index 281cd11..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/And.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class And
- extends BinaryOperator
-{
-
- public And( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " & " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " & " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValue.java b/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValue.java
deleted file mode 100644
index 21f301f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValue.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Interface for all annotation model elements
- *
- * @author Jochen Kuhnle
- */
-public interface AnnotationValue
- extends Expression
-{
-
- /**
- * Accept a visitor for this value.
- *
- * @param visitor Visitor
- * @return Visitor result
- */
- Object accept( ExpressionVisitor visitor );
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValueList.java b/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValueList.java
deleted file mode 100644
index 94ab843..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/AnnotationValueList.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-public class AnnotationValueList
- implements AnnotationValue
-{
-
- private final List<AnnotationValue> valueList;
-
- public AnnotationValueList( List<AnnotationValue> valueList )
- {
- this.valueList = valueList;
- }
-
- public List<AnnotationValue> getValueList()
- {
- return valueList;
- }
-
- public String toString()
- {
- StringBuilder buf = new StringBuilder();
-
- buf.append( '{' );
-
- for ( Iterator<AnnotationValue> i = valueList.iterator(); i.hasNext(); )
- {
- buf.append( i.next().toString() );
-
- if ( i.hasNext() )
- {
- buf.append( ", " );
- }
- }
-
- buf.append( '}' );
-
- return buf.toString();
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.model.expression.AnnotationValue#accept(com.thoughtworks.qdox.model.expression.
- * AnnotationVisitor)
- */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /*
- * (non-Javadoc)
- * @see com.thoughtworks.qdox.model.expression.AnnotationValue#getParameterValue()
- */
- public List<Object> getParameterValue()
- {
- List<Object> list = new LinkedList<Object>();
-
- for ( AnnotationValue value : valueList )
- {
- list.add( value.getParameterValue() );
- }
-
- return list;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Assignment.java b/src/main/java/com/thoughtworks/qdox/model/expression/Assignment.java
deleted file mode 100644
index 5bc7f58..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Assignment.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Assignment
- implements AnnotationValue
-{
- private Expression leftHandSide;
-
- private String operator;
-
- private Expression assignmentExpression;
-
- public Assignment( Expression leftHandSide, String operator, Expression assignmentExpression )
- {
- this.leftHandSide = leftHandSide;
- this.operator = operator;
- this.assignmentExpression = assignmentExpression;
- }
-
- /** {@inheritDoc} */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public Object getParameterValue()
- {
- return leftHandSide.getParameterValue() + " " + operator + ' ' + assignmentExpression.getParameterValue();
- }
-
- @Override
- public String toString()
- {
- return leftHandSide.toString() + ' ' + operator + ' ' + assignmentExpression.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/BinaryOperator.java b/src/main/java/com/thoughtworks/qdox/model/expression/BinaryOperator.java
deleted file mode 100644
index 970e154..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/BinaryOperator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class BinaryOperator
- implements AnnotationValue
-{
-
- private AnnotationValue left;
-
- private AnnotationValue right;
-
- public BinaryOperator( AnnotationValue left, AnnotationValue right )
- {
- this.left = left;
- this.right = right;
- }
-
- public AnnotationValue getLeft()
- {
- return left;
- }
-
- public AnnotationValue getRight()
- {
- return right;
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Cast.java b/src/main/java/com/thoughtworks/qdox/model/expression/Cast.java
deleted file mode 100644
index ae70c27..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Cast.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import com.thoughtworks.qdox.model.JavaType;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Cast
- implements AnnotationValue
-{
-
- private final JavaType type;
-
- private final AnnotationValue value;
-
- public Cast( JavaType type, AnnotationValue value )
- {
- this.type = type;
- this.value = value;
- }
-
- public JavaType getType()
- {
- return this.type;
- }
-
- public AnnotationValue getValue()
- {
- return this.value;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "(" + type.getCanonicalName() + ") " + value.getParameterValue();
- }
-
- public String toString()
- {
- return "(" + type.toString() + ") " + value.toString();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Constant.java b/src/main/java/com/thoughtworks/qdox/model/expression/Constant.java
deleted file mode 100644
index c31ee80..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Constant.java
+++ /dev/null
@@ -1,327 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import java.util.regex.Pattern;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class Constant
- implements AnnotationValue
-{
-
- private final String image;
-
- private Constant( String image )
- {
- this.image = image;
- }
-
- public abstract Object getValue();
-
- public static Constant newBooleanLiteral( final String value )
- {
- return new Constant( value )
- {
-
- @Override
- public Object getValue()
- {
- return toBoolean( value );
- }
- };
- }
-
- public static Constant newCharacterLiteral( final String value )
- {
- return new Constant( value )
- {
- @Override
- public Object getValue()
- {
- return toChar( value );
- }
- };
- }
-
- public static Constant newFloatingPointLiteral( final String value )
- {
- return new Constant( value )
- {
- @Override
- public Object getValue()
- {
- return toFloatingPointLiteral( value );
- }
- };
- }
-
- public static Constant newIntegerLiteral( final String value )
- {
- return new Constant( value )
- {
- @Override
- public Object getValue()
- {
- return toIntegerLiteral( value );
- }
- };
- }
-
- public static Constant newStringLiteral( final String value )
- {
- return new Constant( value )
- {
- @Override
- public Object getValue()
- {
- return toString( value );
- }
- };
- }
-
- public String getImage()
- {
- return image;
- }
-
- public String toString()
- {
- return image;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return image;
- }
-
- protected static String convertString( String str )
- {
- StringBuilder buf = new StringBuilder();
- boolean escaped = false;
- int unicode = 0;
- int value = 0;
- int octal = 0;
- boolean consumed = false;
-
- for ( int i = 0; i < str.length(); ++i )
- {
- char ch = str.charAt( i );
-
- if ( octal > 0 )
- {
- if ( value >= '0' && value <= '7' )
- {
- value = ( value << 3 ) | Character.digit( ch, 8 );
- --octal;
- consumed = true;
- }
- else
- {
- octal = 0;
- }
-
- if ( octal == 0 )
- {
- buf.append( (char) value );
- value = 0;
- }
- }
-
- if ( !consumed )
- {
- if ( unicode > 0 )
- {
- value = ( value << 4 ) | Character.digit( ch, 16 );
-
- --unicode;
-
- if ( unicode == 0 )
- {
- buf.append( (char) value );
- value = 0;
- }
- }
- else if ( escaped )
- {
- if ( ch == 'u' || ch == 'U' )
- {
- unicode = 4;
- }
- else if ( ch >= '0' && ch <= '7' )
- {
- octal = ( ch > '3' ) ? 1 : 2;
- value = Character.digit( ch, 8 );
- }
- else
- {
- switch ( ch )
- {
- case 'b':
- buf.append( '\b' );
- break;
-
- case 'f':
- buf.append( '\f' );
- break;
-
- case 'n':
- buf.append( '\n' );
- break;
-
- case 'r':
- buf.append( '\r' );
- break;
-
- case 't':
- buf.append( '\t' );
- break;
-
- case '\'':
- buf.append( '\'' );
- break;
-
- case '\"':
- buf.append( '\"' );
- break;
-
- case '\\':
- buf.append( '\\' );
- break;
-
- default:
- // yyerror( "Illegal escape character '" + ch + "'" );
- }
- }
-
- escaped = false;
- }
- else if ( ch == '\\' )
- {
- escaped = true;
- }
- else
- {
- buf.append( ch );
- }
- }
- }
-
- return buf.toString();
- }
-
- protected static Boolean toBoolean( String value )
- {
- return Boolean.valueOf( value );
- }
-
- protected static Number toIntegerLiteral( String value )
- {
- String literal = value.replaceAll( "_", "" );
-
- Number result;
- int radix = 10; // default
- int offset = 0;
-
- if ( Pattern.compile( "^0[xX]" ).matcher( literal ).find() )
- {
- radix = 16;
- offset = 2;
- }
- else if ( Pattern.compile( "^0[bB]" ).matcher( literal ).find() )
- {
- radix = 2;
- offset = 2;
- }
- else if ( Pattern.compile( "^0[0-7]" ).matcher( literal ).find() )
- {
- radix = 8;
- offset = 1;
- }
- if ( Pattern.compile( "[lL]$" ).matcher( literal ).find() )
- {
- result = Long.valueOf( literal.substring( offset, literal.length() - 1 ), radix );
- }
- else
- {
- result = Integer.valueOf( literal.substring( offset ), radix );
- }
-
- return result;
- }
-
- protected static Number toFloatingPointLiteral( String value )
- {
- String literal = value.replaceAll( "_", "" );
-
- Number result;
-
- if ( Pattern.compile( "[dD]$" ).matcher( literal ).find() )
- {
- result = Double.valueOf( literal.substring( 0, literal.length() - 1 ) );
- }
- else if ( Pattern.compile( "[fF]$" ).matcher( literal ).find() )
- {
- result = Float.valueOf( literal.substring( 0, literal.length() - 1 ) );
- }
- else
- {
- result = Float.valueOf( literal );
- }
-
- return result;
- }
-
- /**
- * Convert a character literal into a character.
- */
- protected static Character toChar( String value )
- {
- if ( !value.startsWith( "'" ) && !value.endsWith( "'" ) )
- {
- throw new IllegalArgumentException( "Character must be single quoted." );
- }
-
- String literal = convertString( value.substring( 1, value.length() - 1 ) );
-
- if ( literal.length() != 1 )
- {
- throw new IllegalArgumentException( "Only one character allowed in character constants." );
- }
-
- return Character.valueOf( literal.charAt( 0 ) );
- }
-
- /**
- * Convert a string literal into a string.
- */
- protected static String toString( String value )
- {
- if ( value.length() < 2 && !value.startsWith( "\"" ) && !value.endsWith( "\"" ) )
- {
- throw new IllegalArgumentException( "String must be double quoted." );
- }
-
- return convertString( value.substring( 1, value.length() - 1 ) );
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Divide.java b/src/main/java/com/thoughtworks/qdox/model/expression/Divide.java
deleted file mode 100644
index f2465e5..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Divide.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Divide
- extends BinaryOperator
-{
-
- public Divide( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " / " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " / " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Equals.java b/src/main/java/com/thoughtworks/qdox/model/expression/Equals.java
deleted file mode 100644
index 42c02bc..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Equals.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Equals
- extends BinaryOperator
-{
-
- public Equals( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " == " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " == " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/ExclusiveOr.java b/src/main/java/com/thoughtworks/qdox/model/expression/ExclusiveOr.java
deleted file mode 100644
index 7009435..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/ExclusiveOr.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ExclusiveOr
- extends BinaryOperator
-{
-
- public ExclusiveOr( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " ^ " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " ^ " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Expression.java b/src/main/java/com/thoughtworks/qdox/model/expression/Expression.java
deleted file mode 100644
index c7d3935..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Expression.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public interface Expression
-{
- /**
- * Get a parameter value for {@link JavaAnnotation#getNamedParameter(String)}.
- *
- * @return Parameter value
- */
- Object getParameterValue();
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java b/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java
deleted file mode 100644
index 1c9bad1..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.model.JavaAnnotation;
-
-/**
- * Visitor class for the annotation model elements
- *
- * @author Jochen Kuhnle
- */
-public interface ExpressionVisitor
-{
-
- Object visit( Add add );
-
- Object visit( Subtract subtract );
-
- Object visit( Multiply multiply );
-
- Object visit( Divide divide );
-
- Object visit( GreaterThan greaterThan );
-
- Object visit( LessThan lessThan );
-
- Object visit( JavaAnnotation annotation );
-
- Object visit( Constant constant );
-
- Object visit( ParenExpression expression );
-
- Object visit( AnnotationValueList valueList );
-
- Object visit( TypeRef typeRef );
-
- Object visit( FieldRef fieldRef );
-
- Object visit( LessEquals lessEquals );
-
- Object visit( GreaterEquals greaterEquals );
-
- Object visit( Remainder remainder );
-
- Object visit( Or or );
-
- Object visit( And and );
-
- Object visit( ShiftLeft left );
-
- Object visit( ShiftRight right );
-
- Object visit( Not not );
-
- Object visit( LogicalOr or );
-
- Object visit( LogicalAnd and );
-
- Object visit( LogicalNot not );
-
- Object visit( MinusSign sign );
-
- Object visit( PlusSign sign );
-
- Object visit( UnsignedShiftRight right );
-
- Object visit( Equals annotationEquals );
-
- Object visit( NotEquals annotationNotEquals );
-
- Object visit( ExclusiveOr annotationExclusiveOr );
-
- Object visit( Query annotationQuery );
-
- Object visit( Cast annotationCast );
-
- Object visit( PreDecrement preDecrement );
-
- Object visit( PreIncrement preIncrement );
-
- Object visit( PostDecrement postDecrement );
-
- Object visit( PostIncrement postIncrement );
-
- Object visit( Assignment assignment );
-
- Object visit( MethodInvocation methodInvocation );
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java b/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java
deleted file mode 100644
index d53e320..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java
+++ /dev/null
@@ -1,222 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.StringTokenizer;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaMember;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameter;
-
-public class FieldRef
- implements AnnotationValue
-{
- private final int[] parts;
-
- private final String name;
-
- private JavaAnnotatedElement context;
-
- private JavaField field;
-
- private int fieldIndex = -1;
-
- /**
- * @param name the field name, not <code>null</code>
- */
- public FieldRef( String name )
- {
- this.name = name;
-
- int length = new StringTokenizer( name, "." ).countTokens();
- this.parts = new int[length + 1];
- this.parts[0] = -1;
-
- for ( int i = 1; i < length; ++i )
- {
- this.parts[i] = name.indexOf( '.', this.parts[i - 1] + 1 );
- }
-
- this.parts[length] = name.length();
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getNamePrefix( int end )
- {
- return name.substring( 0, parts[end + 1] );
- }
-
- public String getNamePart( int index )
- {
- return name.substring( parts[index] + 1, parts[index + 1] );
- }
-
- public int getPartCount()
- {
- return parts.length - 1;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public String getParameterValue()
- {
- return getName();
- }
-
- public String toString()
- {
- return getName();
- }
-
- public void setContext( JavaAnnotatedElement context )
- {
- this.context = context;
- }
-
- public String getClassPart()
- {
- String result = null;
-
- if ( getField() != null )
- {
- result = name.substring( 0, parts[fieldIndex] );
- }
-
- return result;
- }
-
- public String getFieldPart()
- {
- String result = null;
-
- if ( getField() != null )
- {
- result = name.substring( parts[fieldIndex] + 1 );
- }
-
- return result;
- }
-
- protected JavaField resolveField( JavaClass javaClass, int start, int end )
- {
- JavaField field = null;
-
- for ( int i = start; i < end; ++i )
- {
- field = javaClass.getFieldByName( getNamePart( i ) );
-
- if ( field == null )
- {
- break;
- }
- }
-
- return field;
- }
-
- public JavaField getField()
- {
- if ( fieldIndex < 0 )
- {
- JavaClass declaringClass = getDeclaringClass();
- if ( declaringClass != null )
- {
- field = resolveField( declaringClass, 0, parts.length - 1 );
- fieldIndex = 0;
- }
-
- if ( field == null )
- {
- ClassLibrary classLibrary = getClassLibrary();
- if ( classLibrary != null )
- {
- for ( int i = 0; i < parts.length - 1; ++i )
- {
- String className = getNamePrefix( i );
-
- if ( classLibrary.hasClassReference( className ) )
- {
- JavaClass javaClass = classLibrary.getJavaClass( className );
- fieldIndex = i + 1;
- field = resolveField( javaClass, i + 1, parts.length - 1 );
- break;
- }
- }
- }
- }
- }
- return field;
- }
-
- private JavaClass getDeclaringClass()
- {
- JavaClass result = null;
- if ( context instanceof JavaMember )
- {
- result = ( (JavaMember) context ).getDeclaringClass();
- }
- else if ( context instanceof JavaClass )
- {
- result = ( (JavaClass) context ).getDeclaringClass();
- }
- else if ( context instanceof JavaParameter )
- {
- result = ( (JavaParameter) context ).getParentClass();
- }
- // else if ( context instanceof JavaPackage )
- // {
- // }
- return result;
- }
-
- private ClassLibrary getClassLibrary()
- {
- ClassLibrary result = null;
- if ( context instanceof JavaPackage )
- {
- result = ( (JavaPackage) context ).getJavaClassLibrary();
- }
- else if ( context instanceof JavaClass )
- {
- result = ( (JavaClass) context ).getJavaClassLibrary();
- }
- else
- {
- JavaClass declaringClass = getDeclaringClass();
- if ( declaringClass != null )
- {
- result = declaringClass.getJavaClassLibrary();
- }
- }
- return result;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/GreaterEquals.java b/src/main/java/com/thoughtworks/qdox/model/expression/GreaterEquals.java
deleted file mode 100644
index 9ca982b..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/GreaterEquals.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class GreaterEquals
- extends BinaryOperator
-{
-
- public GreaterEquals( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " >= " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " >= " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/GreaterThan.java b/src/main/java/com/thoughtworks/qdox/model/expression/GreaterThan.java
deleted file mode 100644
index ae8f57b..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/GreaterThan.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class GreaterThan
- extends BinaryOperator
-{
-
- public GreaterThan( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " > " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " > " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/LessEquals.java b/src/main/java/com/thoughtworks/qdox/model/expression/LessEquals.java
deleted file mode 100644
index 3255d60..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/LessEquals.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LessEquals
- extends BinaryOperator
-{
-
- public LessEquals( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " <= " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " <= " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/LessThan.java b/src/main/java/com/thoughtworks/qdox/model/expression/LessThan.java
deleted file mode 100644
index 62d7a3a..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/LessThan.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LessThan
- extends BinaryOperator
-{
-
- public LessThan( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " < " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " < " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalAnd.java b/src/main/java/com/thoughtworks/qdox/model/expression/LogicalAnd.java
deleted file mode 100644
index 5e4acb7..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalAnd.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalAnd
- extends BinaryOperator
-{
-
- public LogicalAnd( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " && " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " && " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalNot.java b/src/main/java/com/thoughtworks/qdox/model/expression/LogicalNot.java
deleted file mode 100644
index 7233e16..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalNot.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalNot
- extends UnaryOperator
-{
-
- public LogicalNot( AnnotationValue value )
- {
- super( value );
- }
-
- public String toString()
- {
- return "!" + getValue().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "!" + getValue().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalOr.java b/src/main/java/com/thoughtworks/qdox/model/expression/LogicalOr.java
deleted file mode 100644
index b5585cd..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/LogicalOr.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalOr
- extends BinaryOperator
-{
-
- public LogicalOr( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " || " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " || " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/MethodInvocation.java b/src/main/java/com/thoughtworks/qdox/model/expression/MethodInvocation.java
deleted file mode 100644
index 2f9e747..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/MethodInvocation.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public class MethodInvocation
- implements AnnotationValue
-{
- private String methodName;
-
- private List<AnnotationValue> arguments;
-
- public MethodInvocation( String methodName, List<AnnotationValue> arguments )
- {
- this.methodName = methodName;
- this.arguments = arguments;
- }
-
- public Object getParameterValue()
- {
- return null;
- }
-
- public String getMethodName()
- {
- return methodName;
- }
-
- public List<AnnotationValue> getArguments()
- {
- return arguments;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/MinusSign.java b/src/main/java/com/thoughtworks/qdox/model/expression/MinusSign.java
deleted file mode 100644
index 2350994..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/MinusSign.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class MinusSign
- extends UnaryOperator
-{
-
- public MinusSign( AnnotationValue value )
- {
- super( value );
- }
-
- public String toString()
- {
- return "-" + getValue().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "-" + getValue().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Multiply.java b/src/main/java/com/thoughtworks/qdox/model/expression/Multiply.java
deleted file mode 100644
index 2eb4073..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Multiply.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Multiply
- extends BinaryOperator
-{
-
- public Multiply( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " * " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " * " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Not.java b/src/main/java/com/thoughtworks/qdox/model/expression/Not.java
deleted file mode 100644
index 9c2ba74..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Not.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Not
- extends UnaryOperator
-{
-
- public Not( AnnotationValue value )
- {
- super( value );
- }
-
- public String toString()
- {
- return "~" + getValue().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "~" + getValue().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/NotEquals.java b/src/main/java/com/thoughtworks/qdox/model/expression/NotEquals.java
deleted file mode 100644
index 7c3df44..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/NotEquals.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class NotEquals
- extends BinaryOperator
-{
-
- public NotEquals( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " != " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " != " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Or.java b/src/main/java/com/thoughtworks/qdox/model/expression/Or.java
deleted file mode 100644
index 1c7cffc..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Or.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Or
- extends BinaryOperator
-{
-
- public Or( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " | " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " | " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/ParenExpression.java b/src/main/java/com/thoughtworks/qdox/model/expression/ParenExpression.java
deleted file mode 100644
index 62fc77b..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/ParenExpression.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ParenExpression
- implements AnnotationValue
-{
-
- private AnnotationValue value;
-
- public ParenExpression( AnnotationValue value )
- {
- this.value = value;
- }
-
- public AnnotationValue getValue()
- {
- return value;
- }
-
- public String toString()
- {
- return "(" + value.toString() + ")";
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "(" + value.getParameterValue() + ")";
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/PlusSign.java b/src/main/java/com/thoughtworks/qdox/model/expression/PlusSign.java
deleted file mode 100644
index 5d4134d..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/PlusSign.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PlusSign
- extends UnaryOperator
-{
-
- public PlusSign( AnnotationValue value )
- {
- super( value );
- }
-
- public String toString()
- {
- return "+" + getValue().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return "+" + getValue().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/PostDecrement.java b/src/main/java/com/thoughtworks/qdox/model/expression/PostDecrement.java
deleted file mode 100644
index 01f4464..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/PostDecrement.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PostDecrement
- extends UnaryOperator
-{
- public PostDecrement( AnnotationValue value )
- {
- super( value );
- }
-
- /** {@inheritDoc} */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public String getParameterValue()
- {
- return getValue().getParameterValue() + "--";
- }
-
- @Override
- public String toString()
- {
- return getValue().toString() + "--";
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/PostIncrement.java b/src/main/java/com/thoughtworks/qdox/model/expression/PostIncrement.java
deleted file mode 100644
index 524054b..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/PostIncrement.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PostIncrement
- extends UnaryOperator
-{
- public PostIncrement( AnnotationValue value )
- {
- super( value );
- }
-
- /** {@inheritDoc} */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public String getParameterValue()
- {
- return getValue().getParameterValue() + "++";
- }
-
- @Override
- public String toString()
- {
- return getValue().toString() + "++";
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/PreDecrement.java b/src/main/java/com/thoughtworks/qdox/model/expression/PreDecrement.java
deleted file mode 100644
index 04ab678..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/PreDecrement.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PreDecrement
- extends UnaryOperator
-{
- public PreDecrement( AnnotationValue value )
- {
- super( value );
- }
-
- /** {@inheritDoc} */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public String getParameterValue()
- {
- return "--" + getValue().getParameterValue();
- }
-
- @Override
- public String toString()
- {
- return "--" + getValue().toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/PreIncrement.java b/src/main/java/com/thoughtworks/qdox/model/expression/PreIncrement.java
deleted file mode 100644
index 3d24e51..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/PreIncrement.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PreIncrement
- extends UnaryOperator
-{
- public PreIncrement( AnnotationValue value )
- {
- super( value );
- }
-
- /** {@inheritDoc} */
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public String getParameterValue()
- {
- return "++" + getValue().getParameterValue();
- }
-
- @Override
- public String toString()
- {
- return "++" + getValue().toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Query.java b/src/main/java/com/thoughtworks/qdox/model/expression/Query.java
deleted file mode 100644
index 48d9c05..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Query.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Query
- implements AnnotationValue
-{
-
- private final AnnotationValue condition;
-
- private final AnnotationValue trueExpression;
-
- private final AnnotationValue falseExpression;
-
- public Query( AnnotationValue condition, AnnotationValue trueExpression, AnnotationValue falseExpression )
- {
- this.condition = condition;
- this.trueExpression = trueExpression;
- this.falseExpression = falseExpression;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public AnnotationValue getCondition()
- {
- return this.condition;
- }
-
- public AnnotationValue getTrueExpression()
- {
- return this.trueExpression;
- }
-
- public AnnotationValue getFalseExpression()
- {
- return this.falseExpression;
- }
-
- public String getParameterValue()
- {
- return condition.getParameterValue().toString() + " ? " + trueExpression.getParameterValue() + " : "
- + falseExpression.getParameterValue();
- }
-
- public String toString()
- {
- return condition.toString() + " ? " + trueExpression.toString() + " : " + falseExpression.toString();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Remainder.java b/src/main/java/com/thoughtworks/qdox/model/expression/Remainder.java
deleted file mode 100644
index fd76b50..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Remainder.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Remainder
- extends BinaryOperator
-{
-
- public Remainder( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " * " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " * " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/ShiftLeft.java b/src/main/java/com/thoughtworks/qdox/model/expression/ShiftLeft.java
deleted file mode 100644
index a6f1007..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/ShiftLeft.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ShiftLeft
- extends BinaryOperator
-{
-
- public ShiftLeft( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " << " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " << " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/ShiftRight.java b/src/main/java/com/thoughtworks/qdox/model/expression/ShiftRight.java
deleted file mode 100644
index f2dbb1c..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/ShiftRight.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ShiftRight
- extends BinaryOperator
-{
-
- public ShiftRight( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " >> " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " >> " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/Subtract.java b/src/main/java/com/thoughtworks/qdox/model/expression/Subtract.java
deleted file mode 100644
index 47f3185..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/Subtract.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class Subtract
- extends BinaryOperator
-{
-
- public Subtract( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " - " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " - " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/TypeRef.java b/src/main/java/com/thoughtworks/qdox/model/expression/TypeRef.java
deleted file mode 100644
index 382e45f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/TypeRef.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.model.JavaType;
-
-public class TypeRef
- implements AnnotationValue
-{
-
- private JavaType type;
-
- public TypeRef( JavaType type )
- {
- this.type = type;
- }
-
- public JavaType getType()
- {
- return type;
- }
-
- public String toString()
- {
- return type.getValue() + ".class";
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return type.getValue() + ".class";
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/UnaryOperator.java b/src/main/java/com/thoughtworks/qdox/model/expression/UnaryOperator.java
deleted file mode 100644
index 32e3802..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/UnaryOperator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class UnaryOperator
- implements AnnotationValue
-{
-
- private AnnotationValue value;
-
- public UnaryOperator( AnnotationValue value )
- {
- this.value = value;
- }
-
- public AnnotationValue getValue()
- {
- return value;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRight.java b/src/main/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRight.java
deleted file mode 100644
index 69215cf..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRight.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class UnsignedShiftRight
- extends BinaryOperator
-{
-
- public UnsignedShiftRight( AnnotationValue left, AnnotationValue right )
- {
- super( left, right );
- }
-
- public String toString()
- {
- return getLeft().toString() + " >>> " + getRight().toString();
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- public String getParameterValue()
- {
- return getLeft().getParameterValue() + " >>> " + getRight().getParameterValue();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/expression/package-info.java b/src/main/java/com/thoughtworks/qdox/model/expression/package-info.java
deleted file mode 100644
index d55648a..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/expression/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes reflecting the Java expressions.
- */
-package com.thoughtworks.qdox.model.expression;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseJavaEntity.java b/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseJavaEntity.java
deleted file mode 100644
index 7548752..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseJavaEntity.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-
-public abstract class AbstractBaseJavaEntity extends AbstractJavaModel implements Serializable {
-
- private List<JavaAnnotation> annotations = Collections.emptyList();
- private String comment;
- private List<DocletTag> tags = Collections.emptyList();
-
- public AbstractBaseJavaEntity()
- {
- super();
- }
-
- public List<JavaAnnotation> getAnnotations()
- {
- return annotations;
- }
-
- public void setAnnotations( List<JavaAnnotation> annotations )
- {
- this.annotations = annotations;
- }
-
- /**
- * Not every entity has a parentClass, but AnnotationFieldRef requires access to it.
- * When used with JavaClass, don't confuse this with getSuperClass()
- *
- * @return the surrounding class
- */
- public JavaClass getParentClass()
- {
- return null;
- }
-
- public String getComment()
- {
- return comment;
- }
-
- public void setComment( String comment )
- {
- this.comment = comment;
- }
-
- public List<DocletTag> getTags()
- {
- return tags;
- }
-
- public List<DocletTag> getTagsByName( String name )
- {
- List<DocletTag> specifiedTags = new LinkedList<DocletTag>();
- for ( DocletTag docletTag : tags )
- {
- if ( docletTag.getName().equals( name ) )
- {
- specifiedTags.add( docletTag );
- }
- }
- return specifiedTags;
- }
-
- public DocletTag getTagByName( String name )
- {
- for ( DocletTag docletTag : tags )
- {
- if ( docletTag.getName().equals( name ) )
- {
- return docletTag;
- }
- }
- return null;
- }
-
- /**
- * Convenience method for <code>getTagByName(String).getNamedParameter(String)</code> that also checks for null tag.
- *
- * @param tagName the name of the docletTag
- * @param parameterName the name of the parameter
- * @since 1.3
- */
- public String getNamedParameter( String tagName, String parameterName )
- {
- DocletTag tag = getTagByName( tagName );
- return ( tag != null ? tag.getNamedParameter( parameterName ) : null );
- }
-
- public void setTags( List<DocletTag> tagList )
- {
- this.tags = tagList;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseMethod.java b/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseMethod.java
deleted file mode 100644
index 88610c4..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractBaseMethod.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-
-/**
- * The BaseMethod contains all methods used by both JavaMethod and JavaConstructor
- *
- * @author Robert Scholte
- *
- */
-public abstract class AbstractBaseMethod
- extends AbstractInheritableJavaEntity
-{
-
- private List<JavaParameter> parameters = Collections.emptyList();
- private List<JavaClass> exceptions = Collections.emptyList();
- private boolean varArgs;
- private String sourceCode;
-
- public List<JavaParameter> getParameters()
- {
- return parameters;
- }
-
- public JavaParameter getParameterByName( String name )
- {
- for (JavaParameter parameter : getParameters()) {
- if (parameter.getName().equals(name)) {
- return parameter;
- }
- }
- return null;
- }
-
- public List<JavaClass> getExceptions()
- {
- return new LinkedList<JavaClass>( exceptions );
- }
-
- public List<JavaType> getExceptionTypes()
- {
- return new LinkedList<JavaType>( exceptions );
- }
-
- public boolean isVarArgs()
- {
- return varArgs;
- }
-
- public JavaClass getDeclaringClass()
- {
- return getParentClass();
- }
-
- public void setParameters( List<JavaParameter> javaParameters )
- {
- parameters = javaParameters;
- this.varArgs = javaParameters.get( javaParameters.size() -1 ).isVarArgs();
- }
-
- public void setExceptions( List<JavaClass> exceptions )
- {
- this.exceptions = exceptions;
- }
-
- protected boolean signatureMatches( List<JavaType> parameterTypes, boolean varArgs )
- {
- List<JavaType> parameterTypeList;
- if( parameterTypes == null) {
- parameterTypeList = Collections.emptyList();
- }
- else {
- parameterTypeList = parameterTypes;
- }
-
- if (parameterTypeList.size() != this.getParameters().size())
- {
- return false;
- }
-
- for (int i = 0; i < getParameters().size(); i++)
- {
- if (!getParameters().get(i).getType().equals(parameterTypes.get(i))) {
- return false;
- }
- }
- return (this.varArgs == varArgs);
- }
-
- public boolean isPublic()
- {
- return super.isPublic() || (getParentClass() != null ? getParentClass().isInterface() : false);
- }
-
- public List<DocletTag> getTagsByName( String name, boolean inherited )
- {
- JavaClass cls = getParentClass();
- List<JavaType> types = new LinkedList<JavaType>();
- for (JavaParameter parameter : getParameters()) {
- types.add(parameter.getType());
- }
- List<JavaMethod> methods = cls.getMethodsBySignature(getName(), types, true);
-
- List<DocletTag> result = new LinkedList<DocletTag>();
- for (JavaMethod method : methods) {
- List<DocletTag> tags = method.getTagsByName(name);
- for (DocletTag tag : tags) {
- if(!result.contains(tag)) {
- result.add(tag);
- }
- }
- }
- return result;
- }
-
- public List<JavaType> getParameterTypes()
- {
- return getParameterTypes( false );
- }
-
- /** {@inheritDoc} */
- public List<JavaType> getParameterTypes( boolean resolve )
- {
- List<JavaType> result = new LinkedList<JavaType>();
- for ( JavaParameter parameter : this.getParameters() )
- {
- result.add( parameter.getType() );
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public String getSourceCode()
- {
- return sourceCode;
- }
-
- public void setSourceCode( String sourceCode )
- {
- this.sourceCode = sourceCode;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractInheritableJavaEntity.java b/src/main/java/com/thoughtworks/qdox/model/impl/AbstractInheritableJavaEntity.java
deleted file mode 100644
index 39b0a49..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractInheritableJavaEntity.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-import com.thoughtworks.qdox.model.DocletTag;
-
-/**
- * @author Aslak Hellesøy
- * @version $Revision$
- */
-public abstract class AbstractInheritableJavaEntity extends AbstractJavaEntity {
-
- public DocletTag getTagByName(String name, boolean inherited) {
- List<DocletTag> tags = getTagsByName(name, inherited);
- return tags.size() > 0 ? tags.get(0) : null;
- }
-
- public abstract List<DocletTag> getTagsByName(String name, boolean inherited);
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntity.java b/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntity.java
deleted file mode 100644
index da215b4..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntity.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaModel;
-
-public abstract class AbstractJavaEntity extends AbstractBaseJavaEntity implements JavaModel {
-
- private List<String> modifiers = Collections.emptyList();
- private JavaClass parentCls;
- private String name;
-
- /**
- * Return list of modifiers as Strings.
- * (public, private, protected, final, abstract, static)
- * @return a list of modifiers, never <code>null</code>
- */
- public List<String> getModifiers() {
- return modifiers;
- }
-
- public void setModifiers(List<String> modifiers) {
- this.modifiers = modifiers;
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isAbstract(int)}
- *
- * @return <code>true</code> if entity is abstract, otherwise <code>false</code>
- */
- public boolean isAbstract() {
- return isModifierPresent("abstract");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isPublic(int)}
- *
- * @return <code>true</code> if entity is public, otherwise <code>false</code>
- */
- public boolean isPublic() {
- return isModifierPresent("public");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isPrivate(int)}
- *
- * @return <code>true</code> if entity is private, otherwise <code>false</code>
- */
- public boolean isPrivate() {
- return isModifierPresent("private");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isProtected(int)}
- *
- * @return <code>true</code> if entity is protected, otherwise <code>false</code>
- */
- public boolean isProtected() {
- return isModifierPresent("protected");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isStatic(int)}
- *
- * @return <code>true</code> if entity is static, otherwise <code>false</code>
- */
- public boolean isStatic() {
- return isModifierPresent("static");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isFinal(int)}
- *
- * @return <code>true</code> if entity is final, otherwise <code>false</code>
- */
- public boolean isFinal() {
- return isModifierPresent("final");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isSynchronized(int)}
- *
- * @return <code>true</code> if entity is sunchronized, otherwise <code>false</code>
- */
- public boolean isSynchronized() {
- return isModifierPresent("synchronized");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isTransient(int)}
- *
- * @return <code>true</code> if entity is transient, otherwise <code>false</code>
- */
- public boolean isTransient() {
- return isModifierPresent("transient");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isVolatile(int)}
- *
- * @return <code>true</code> if entity is volatile, otherwise <code>false</code>
- * @since 1.4
- */
- public boolean isVolatile() {
- return isModifierPresent("volatile");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isNative(int)}
- *
- * @return <code>true</code> if entity is native, otherwise <code>false</code>
- * @since 1.4
- */
- public boolean isNative() {
- return isModifierPresent("native");
- }
-
- /**
- * Equivalent of {@link java.lang.reflect.Modifier#isStrict(int)}
- *
- * @return <code>true</code> if entity is strictfp, otherwise <code>false</code>
- * @since 1.4
- */
- public boolean isStrictfp() {
- return isModifierPresent("strictfp");
- }
-
- /**
- * Returns <code>true</code> if one of the modifiers matches the {@code modifier}
- *
- * @param modifier the modifier
- * @return <code>true</code> if the modifier is present, otherwise <code>false</code>
- */
- private boolean isModifierPresent(String modifier) {
- return modifiers.contains(modifier);
- }
-
- public void setParentClass( JavaClass parentClass )
- {
- this.parentCls = parentClass;
- }
-
- public JavaClass getParentClass()
- {
- return parentCls;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaModel.java b/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaModel.java
deleted file mode 100644
index 3861b02..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/AbstractJavaModel.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.model.JavaModel;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.writer.ModelWriter;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-import com.thoughtworks.qdox.writer.impl.DefaultModelWriter;
-
-/**
- * Every element of a class, including the class itself is a javaModel.
- * While being constructed by a ModelBuilder, they all <strong>must</strong> have a reference to the same source.
- * If a ModelWriterFactory is set, it <strong>must</strong> be the same for every element of this source, otherwise the defaultModelWriter is used.
- *
- * @author Robert Scholte
- *
- */
-public abstract class AbstractJavaModel implements JavaModel {
-
- private ModelWriterFactory modelWriterFactory;
- private JavaSource source;
-
- private int lineNumber = -1;
-
- public AbstractJavaModel() {
- super();
- }
-
- public int getLineNumber() {
- return lineNumber;
- }
-
- public void setLineNumber(int lineNumber) {
- this.lineNumber = lineNumber;
- }
-
- public JavaSource getSource() {
- return source;
- }
-
- public void setSource(JavaSource source) {
- this.source = source;
- }
-
- /**
- *
- * @param modelWriterFactory
- * @since 2.0
- */
- public void setModelWriterFactory( ModelWriterFactory modelWriterFactory )
- {
- this.modelWriterFactory = modelWriterFactory;
- }
-
- /* (non-Javadoc)
- * @see com.thoughtworks.qdox.model.JavaSource#getModelWriter()
- */
- public ModelWriter getModelWriter()
- {
- ModelWriter result;
- if (modelWriterFactory != null) {
- result = modelWriterFactory.newInstance();
- }
- else {
- result = new DefaultModelWriter();
- }
- return result;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultBeanProperty.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultBeanProperty.java
deleted file mode 100644
index 5ee3abc..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultBeanProperty.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.model.BeanProperty;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaType;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class DefaultBeanProperty
- implements BeanProperty
-{
-
- private final String name;
-
- private JavaMethod accessor;
-
- private JavaMethod mutator;
-
- private JavaType type;
-
- public DefaultBeanProperty( String name )
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- public String getName()
- {
- return name;
- }
-
- public void setType( JavaType type )
- {
- this.type = type;
- }
-
- /** {@inheritDoc} */
- public JavaType getType()
- {
- return type;
- }
-
- /** {@inheritDoc} */
- public JavaMethod getAccessor()
- {
- return accessor;
- }
-
- public void setAccessor( JavaMethod accessor )
- {
- this.accessor = accessor;
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMutator()
- {
- return mutator;
- }
-
- public void setMutator( JavaMethod mutator )
- {
- this.mutator = mutator;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTag.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTag.java
deleted file mode 100644
index c3fee1e..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTag.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-import java.util.Map;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.util.TagParser;
-
-public class DefaultDocletTag
- implements DocletTag
-{
-
- private final String name;
-
- private final String value;
-
- private final int lineNumber;
-
- private List<String> parameters;
-
- private Map<String, String> namedParameters;
-
- private JavaAnnotatedElement context;
-
- public DefaultDocletTag( String name, String value, JavaAnnotatedElement context, int lineNumber )
- {
- this.name = name;
- this.value = value;
- this.context = context;
- this.lineNumber = lineNumber;
- }
-
- public DefaultDocletTag( String name, String value )
- {
- this( name, value, null, 0 );
- }
-
- /** {@inheritDoc} */
- public String getName()
- {
- return name;
- }
-
- /** {@inheritDoc} */
- public String getValue()
- {
- return value;
- }
-
- /** {@inheritDoc} */
- public List<String> getParameters()
- {
- if ( parameters == null )
- {
- parameters = TagParser.parseParameters( value );
- }
- return parameters;
- }
-
- /** {@inheritDoc} */
- public Map<String, String> getNamedParameterMap()
- {
- if ( namedParameters == null )
- {
- namedParameters = TagParser.parseNamedParameters( value );
- }
- return namedParameters;
- }
-
- /** {@inheritDoc} */
- public String getNamedParameter( String key )
- {
- return (String) getNamedParameterMap().get( key );
- }
-
- /** {@inheritDoc} */
- public final JavaAnnotatedElement getContext()
- {
- return context;
- }
-
- /** {@inheritDoc} */
- public int getLineNumber()
- {
- return lineNumber;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagFactory.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagFactory.java
deleted file mode 100644
index 8416fa4..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.DocletTagFactory;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Aslak Hellesøy
- * @version $Revision$
- */
-public class DefaultDocletTagFactory implements DocletTagFactory {
-
- public DocletTag createDocletTag(
- String tag, String text,
- JavaAnnotatedElement context, int lineNumber
- ) {
- return new DefaultDocletTag(tag, text, context, lineNumber);
- }
-
- public DocletTag createDocletTag(String tag, String text) {
- return createDocletTag(tag, text, null, 0);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java
deleted file mode 100644
index 4927f18..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaAnnotation.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.ExpressionVisitor;
-
-/**
- * @author Eric Redmond
- */
-public class DefaultJavaAnnotation
- implements AnnotationValue, Serializable, JavaAnnotation
-{
- private final JavaClass type;
-
- private final int lineNumber;
-
- /**
- * Annotation properties as AnnotationValues
- * <p>
- * This map contains the parsed AnnotationValue for each property and allows access to the full parse tree,
- * including typerefs and expressions.
- */
- private final Map<String, AnnotationValue> properties = new LinkedHashMap<String, AnnotationValue>();
-
- /**
- * Annotation properties as Parameters
- */
- private final Map<String, Object> namedParameters = new LinkedHashMap<String, Object>();
-
- private JavaAnnotatedElement context;
-
- public DefaultJavaAnnotation( JavaClass type, JavaAnnotatedElement context, Map<String, Object> namedParameters,
- int lineNumber )
- {
- this.type = type;
- this.context = context;
- this.lineNumber = lineNumber;
-
- if ( properties != null )
- {
- for ( Entry<String, AnnotationValue> entry : properties.entrySet() )
- {
- String name = entry.getKey();
- AnnotationValue value = entry.getValue();
-
- setProperty( name, value );
- }
- }
- }
-
- public DefaultJavaAnnotation( JavaClass type, int line )
- {
- this( type, null, null, line );
- }
-
- public final void setProperty( String name, AnnotationValue value )
- {
- properties.put( name, value );
- namedParameters.put( name, value.getParameterValue() );
- }
-
- /** {@inheritDoc} */
- public JavaClass getType()
- {
- return type;
- }
-
- /** {@inheritDoc} */
- public Object getNamedParameter( String key )
- {
- return namedParameters.get( key );
- }
-
- /** {@inheritDoc} */
- public Map<String, Object> getNamedParameterMap()
- {
- return namedParameters;
- }
-
- /** {@inheritDoc} */
- public final JavaAnnotatedElement getContext()
- {
- return context;
- }
-
- /** {@inheritDoc} */
- public int getLineNumber()
- {
- return lineNumber;
- }
-
- public Object accept( ExpressionVisitor visitor )
- {
- return visitor.visit( this );
- }
-
- /** {@inheritDoc} */
- public DefaultJavaAnnotation getParameterValue()
- {
- return this;
- }
-
- /** {@inheritDoc} */
- public Map<String, AnnotationValue> getPropertyMap()
- {
- return properties;
- }
-
- /** {@inheritDoc} */
- public AnnotationValue getProperty( String name )
- {
- return properties.get( name );
- }
-
- public void setContext( JavaAnnotatedElement context )
- {
- this.context = context;
- }
-
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- result.append( '@' );
- result.append( type.getFullyQualifiedName() );
- result.append( '(' );
- if ( !namedParameters.isEmpty() )
- {
- for ( Iterator<Entry<String, Object>> i = namedParameters.entrySet().iterator(); i.hasNext(); )
- {
- result.append( i.next() );
- if ( i.hasNext() )
- {
- result.append( ',' );
- }
- }
- }
- result.append( ')' );
- return result.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java
deleted file mode 100644
index bfac09d..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaClass.java
+++ /dev/null
@@ -1,931 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.BeanProperty;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaInitializer;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-
-/**
- * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
- * @author Aslak Hellesøy
- */
-public class DefaultJavaClass
- extends AbstractInheritableJavaEntity
- implements JavaClass
-{
-
- private List<JavaConstructor> constructors = new LinkedList<JavaConstructor>();
-
- private List<JavaMethod> methods = new LinkedList<JavaMethod>();
-
- private List<JavaField> fields = new LinkedList<JavaField>();
-
- private List<JavaClass> classes = new LinkedList<JavaClass>();
-
- private boolean anInterface;
-
- private boolean anEnum;
-
- private boolean anAnnotation;
-
- private JavaType superClass;
-
- private List<JavaClass> implementz = new LinkedList<JavaClass>();
-
- private List<JavaInitializer> initializers = new LinkedList<JavaInitializer>();
-
- private List<DefaultJavaTypeVariable<JavaClass>> typeParameters =
- new LinkedList<DefaultJavaTypeVariable<JavaClass>>();
-
- // sourceless class can use this property
- private JavaPackage javaPackage;
-
- protected DefaultJavaClass()
- {
- }
-
- public DefaultJavaClass( String name )
- {
- setName( name );
- }
-
- public DefaultJavaClass( JavaSource source )
- {
- setSource( source );
- }
-
- /** {@inheritDoc} */
- public boolean isInterface()
- {
- return anInterface;
- }
-
- /** {@inheritDoc} */
- public boolean isPrimitive()
- {
- final String name = getName();
- return "void".equals( name ) || "boolean".equals( name ) || "byte".equals( name ) || "char".equals( name )
- || "short".equals( name ) || "int".equals( name ) || "long".equals( name ) || "float".equals( name )
- || "double".equals( name );
- }
-
- /** {@inheritDoc} */
- public boolean isVoid()
- {
- return "void".equals( getName() );
- }
-
- /** {@inheritDoc} */
- public boolean isEnum()
- {
- return anEnum;
- }
-
- /** {@inheritDoc} */
- public boolean isAnnotation()
- {
- return anAnnotation;
- }
-
- /** {@inheritDoc} */
- public boolean isArray()
- {
- return false;
- }
-
- /** {@inheritDoc} */
- public JavaClass getComponentType()
- {
- return null;
- }
-
- /** {@inheritDoc} */
- public int getDimensions()
- {
- return 0;
- }
-
- /** {@inheritDoc} */
- public JavaType getSuperClass()
- {
- JavaType result = null;
- JavaClass OBJECT_JAVACLASS = getJavaClassLibrary().getJavaClass( "java.lang.Object" );
- JavaClass ENUM_JAVACLASS = getJavaClassLibrary().getJavaClass( "java.lang.Enum" );
-
- boolean iAmJavaLangObject = OBJECT_JAVACLASS.equals( this );
-
- if ( anEnum )
- {
- result = ENUM_JAVACLASS;
- }
- else if ( !anInterface && !anAnnotation && ( superClass == null ) && !iAmJavaLangObject )
- {
- result = OBJECT_JAVACLASS;
- }
- else
- {
- result = superClass;
- }
- return result;
- }
-
- /**
- * Shorthand for getSuperClass().getJavaClass() with null checking.
- */
- public JavaClass getSuperJavaClass()
- {
- JavaClass result = null;
- JavaType superType = getSuperClass();
- if ( superType instanceof JavaClass )
- {
- result = ( JavaClass ) superType;
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public List<JavaType> getImplements()
- {
- return new LinkedList<JavaType>( implementz );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getImplementedInterfaces()
- {
- return new LinkedList<JavaClass>( implementz );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getInterfaces()
- {
- return new LinkedList<JavaClass>( implementz );
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return getModelWriter().writeClass( this ).toString();
- }
-
- public void setInterface( boolean anInterface )
- {
- this.anInterface = anInterface;
- }
-
- public void setEnum( boolean anEnum )
- {
- this.anEnum = anEnum;
- }
-
- public void setAnnotation( boolean anAnnotation )
- {
- this.anAnnotation = anAnnotation;
- }
-
- public void addConstructor( JavaConstructor constructor )
- {
- constructors.add( constructor );
- }
-
- public void addMethod( JavaMethod meth )
- {
- methods.add( meth );
- }
-
- public void setSuperClass( JavaType type )
- {
- if ( anEnum )
- {
- throw new IllegalArgumentException( "enums cannot extend other classes" );
- }
- superClass = type;
- }
-
- public void setImplementz( List<JavaClass> implementz )
- {
- this.implementz = implementz;
- }
-
- /** {@inheritDoc} */
- public List<DefaultJavaTypeVariable<JavaClass>> getTypeParameters()
- {
- return typeParameters;
- }
-
- public void setTypeParameters( List<DefaultJavaTypeVariable<JavaClass>> typeParameters )
- {
- this.typeParameters = typeParameters;
- }
-
- public void addField( JavaField javaField )
- {
- fields.add( javaField );
- }
-
- /**
- * Only used when constructing the model by hand / without source
- *
- * @param javaPackage
- */
- public void setJavaPackage( JavaPackage javaPackage )
- {
- this.javaPackage = javaPackage;
- }
-
- /** {@inheritDoc} */
- public JavaSource getParentSource()
- {
- return ( getParentClass() != null ? getParentClass().getParentSource() : super.getSource() );
- }
-
- /** {@inheritDoc} */
- public JavaSource getSource()
- {
- return getParentSource();
- }
-
- /** {@inheritDoc} */
- public JavaPackage getPackage()
- {
- return getParentSource() != null ? getParentSource().getPackage() : javaPackage;
- }
-
- /** {@inheritDoc} */
- public JavaClassParent getParent()
- {
- JavaClassParent result = getParentClass();
- if ( result == null )
- {
- result = getParentSource();
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public String getPackageName()
- {
- JavaPackage pckg = getPackage();
- return ( pckg != null && pckg.getName() != null ) ? pckg.getName() : "";
- }
-
- /** {@inheritDoc} */
- public String getFullyQualifiedName()
- {
- return ( getParentClass() != null ? ( getParentClass().getClassNamePrefix() )
- : getPackage() != null ? ( getPackage().getName() + "." ) : "" )
- + getName();
- }
-
- /** {@inheritDoc} */
- public String getGenericFullyQualifiedName()
- {
- return getFullyQualifiedName();
- }
-
- /** {@inheritDoc} */
- public String getCanonicalName()
- {
- return getFullyQualifiedName().replace( '$', '.' );
- }
-
- /** {@inheritDoc} */
- public String getGenericCanonicalName()
- {
- return getCanonicalName();
- }
-
- /** {@inheritDoc} */
- public String getValue()
- {
- return getCanonicalName().substring( getSource().getClassNamePrefix().length() );
- }
-
- /** {@inheritDoc} */
- public String getGenericValue()
- {
- return getValue();
- }
-
- /** {@inheritDoc} */
- public boolean isInner()
- {
- return getParentClass() != null;
- }
-
- /** {@inheritDoc} */
- public String resolveType( String typeName )
- {
- String result;
- JavaClass resolvedClass = getNestedClassByName( typeName );
- if ( resolvedClass != null )
- {
- result = resolvedClass.getFullyQualifiedName();
- }
- else
- {
- result = getParent().resolveType( typeName );
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public String resolveCanonicalName( String name )
- {
- // Maybe it's an inner class?
- for ( JavaClass innerClass : getNestedClasses() )
- {
- if ( innerClass.getName().equals( name ) )
- {
- return innerClass.getName();
- }
- }
- return getParent().resolveCanonicalName( name );
- }
-
- /** {@inheritDoc} */
- public String resolveFullyQualifiedName( String name )
- {
- // Maybe it's an inner class?
- for ( JavaClass innerClass : getNestedClasses() )
- {
- if ( innerClass.getName().equals( name ) )
- {
- return innerClass.getFullyQualifiedName();
- }
- }
- return getParent().resolveFullyQualifiedName( name );
- }
-
- /** {@inheritDoc} */
- public String getClassNamePrefix()
- {
- return getFullyQualifiedName() + "$";
- }
-
- /** {@inheritDoc} */
- public JavaType asType()
- {
- return this;
- }
-
- /** {@inheritDoc} */
- public List<JavaInitializer> getInitializers()
- {
- return initializers;
- }
-
- /** {@inheritDoc} */
- public List<JavaConstructor> getConstructors()
- {
- return constructors;
- }
-
- /** {@inheritDoc} */
- public JavaConstructor getConstructor( List<JavaType> parameterTypes )
- {
- return getConstructor( parameterTypes, false );
- }
-
- /** {@inheritDoc} */
- public JavaConstructor getConstructor( List<JavaType> parameterTypes, boolean varArgs )
- {
- for ( JavaConstructor constructor : getConstructors() )
- {
- if ( constructor.signatureMatches( parameterTypes, varArgs ) )
- {
- return constructor;
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethods()
- {
- return methods;
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethods( boolean superclasses )
- {
- if ( superclasses )
- {
- return new LinkedList<JavaMethod>( getMethodsFromSuperclassAndInterfaces( this, this ).values() );
- }
- else
- {
- return getMethods();
- }
- }
-
- private static Map<String, JavaMethod> getMethodsFromSuperclassAndInterfaces( JavaClass rootClass,
- JavaClass callingClazz )
- {
-
- Map<String, JavaMethod> result = new LinkedHashMap<String, JavaMethod>();
-
- for ( JavaMethod method : callingClazz.getMethods() )
- {
- if ( !method.isPrivate() )
- {
- String signature = method.getDeclarationSignature( false );
-
- result.put( signature, method );
- }
- }
-
- JavaClass superclass = callingClazz.getSuperJavaClass();
- if ( superclass != null )
- {
- Map<String, JavaMethod> superClassMethods =
- getMethodsFromSuperclassAndInterfaces( callingClazz, superclass );
- for ( Map.Entry<String, JavaMethod> methodEntry : superClassMethods.entrySet() )
- {
- if ( !result.containsKey( methodEntry.getKey() ) )
- {
- JavaMethod method;
- if ( superclass.equals( rootClass ) )
- {
- method = methodEntry.getValue();
- }
- else
- {
- method = new JavaMethodDelegate( callingClazz, methodEntry.getValue() );
- }
- result.put( methodEntry.getKey(), method );
- }
- }
-
- }
-
- for ( JavaClass clazz : callingClazz.getImplementedInterfaces() )
- {
- Map<String, JavaMethod> interfaceMethods = getMethodsFromSuperclassAndInterfaces( callingClazz, clazz );
- for ( Map.Entry<String, JavaMethod> methodEntry : interfaceMethods.entrySet() )
- {
- if ( !result.containsKey( methodEntry.getKey() ) )
- {
- JavaMethod method;
- if ( clazz.equals( rootClass ) )
- {
- method = methodEntry.getValue();
- }
- else
- {
- method = new JavaMethodDelegate( callingClazz, methodEntry.getValue() );
- }
- result.put( methodEntry.getKey(), method );
- }
- }
-
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes )
- {
- return getMethod( name, parameterTypes, false );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethod( String name, List<JavaType> parameterTypes, boolean varArgs )
- {
- for ( JavaMethod method : getMethods() )
- {
- if ( method.signatureMatches( name, parameterTypes, varArgs ) )
- {
- return method;
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses )
- {
- return getMethodBySignature( name, parameterTypes, superclasses, false );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses,
- boolean varArg )
- {
-
- List<JavaMethod> result = getMethodsBySignature( name, parameterTypes, superclasses, varArg );
-
- return ( result.size() > 0 ) ? result.get( 0 ) : null;
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses )
- {
- return getMethodsBySignature( name, parameterTypes, superclasses, false );
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses,
- boolean varArg )
- {
- List<JavaMethod> result = new LinkedList<JavaMethod>();
-
- JavaMethod methodInThisClass = getMethod( name, parameterTypes, varArg );
-
- if ( methodInThisClass != null )
- {
- result.add( methodInThisClass );
- }
-
- if ( superclasses )
- {
- JavaClass superclass = getSuperJavaClass();
-
- if ( superclass != null )
- {
- JavaMethod method = superclass.getMethodBySignature( name, parameterTypes, true, varArg );
-
- // todo: ideally we should check on package privacy too. oh well.
- if ( ( method != null ) && !method.isPrivate() )
- {
- result.add( new JavaMethodDelegate( this, method ) );
- }
- }
-
- for ( JavaClass clazz : getImplementedInterfaces() )
- {
- JavaMethod method = clazz.getMethodBySignature( name, parameterTypes, true, varArg );
- if ( method != null )
- {
- result.add( new JavaMethodDelegate( this, method ) );
- }
- }
- }
-
- return result;
- }
-
- /** {@inheritDoc} */
- public List<JavaField> getFields()
- {
- return fields;
- }
-
- /** {@inheritDoc} */
- public JavaField getFieldByName( String name )
- {
- for ( JavaField field : getFields() )
- {
- if ( field.getName().equals( name ) )
- {
- return field;
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public List<JavaField> getEnumConstants()
- {
- List<JavaField> result = isEnum() ? new LinkedList<JavaField>() : null;
- if ( isEnum() )
- {
- for ( JavaField field : getFields() )
- {
- if ( field.isEnumConstant() )
- {
- result.add( field );
- }
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public JavaField getEnumConstantByName( String name )
- {
- JavaField field = getFieldByName( name );
- return field.isEnumConstant() ? field : null;
- }
-
- public void addInitializer( JavaInitializer initializer )
- {
- initializers.add( initializer );
- }
-
- public void addClass( JavaClass cls )
- {
- classes.add( cls );
- }
-
- /**
- * @deprecated Use {@link #getNestedClasses()} instead.
- */
- public List<JavaClass> getClasses()
- {
- return getNestedClasses();
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getNestedClasses()
- {
- return classes;
- }
-
- /** {@inheritDoc} */
- public JavaClass getInnerClassByName( String name )
- {
- return getNestedClassByName( name );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getInnerClasses()
- {
- return getNestedClasses();
- }
-
- /** {@inheritDoc} */
- public JavaClass getNestedClassByName( String name )
- {
- int separatorIndex = name.indexOf( '.' );
- String directInnerClassName = ( separatorIndex > 0 ? name.substring( 0, separatorIndex ) : name );
- for ( JavaClass jClass : getNestedClasses() )
- {
- if ( jClass.getName().equals( directInnerClassName ) )
- {
- if ( separatorIndex > 0 )
- {
- return jClass.getNestedClassByName( name.substring( separatorIndex + 1 ) );
- }
- else
- {
- return jClass;
- }
- }
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public boolean isA( String fullClassName )
- {
- if ( fullClassName == null )
- {
- return false;
- }
- if ( fullClassName.equals( getFullyQualifiedName() ) )
- {
- return true;
- }
- for ( JavaClass implementz : getImplementedInterfaces() )
- {
- if ( implementz.isA( fullClassName ) )
- {
- return true;
- }
- }
- JavaClass superClass = getSuperJavaClass();
- if ( superClass != null )
- {
- return superClass.isA( fullClassName );
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isA( JavaClass javaClass )
- {
- if ( this == javaClass )
- {
- return true;
- }
- else if ( this.equals( javaClass ) )
- {
- return true;
- }
- else if ( javaClass != null )
- {
- // ask our interfaces
- for ( JavaClass intrfc : getImplementedInterfaces() )
- {
- if ( intrfc.isA( javaClass ) )
- {
- return true;
- }
- }
- // ask our superclass
- JavaClass superClass = getSuperJavaClass();
- if ( superClass != null )
- {
- return superClass.isA( javaClass );
- }
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public List<BeanProperty> getBeanProperties()
- {
- return getBeanProperties( false );
- }
-
- /** {@inheritDoc} */
- public List<BeanProperty> getBeanProperties( boolean superclasses )
- {
- Map<String, BeanProperty> beanPropertyMap = getBeanPropertyMap( superclasses );
- Collection<BeanProperty> beanPropertyCollection = beanPropertyMap.values();
-
- return new LinkedList<BeanProperty>( beanPropertyCollection );
- }
-
- private Map<String, BeanProperty> getBeanPropertyMap( boolean superclasses )
- {
- List<JavaMethod> superMethods = getMethods( superclasses );
- Map<String, DefaultBeanProperty> beanPropertyMap = new LinkedHashMap<String, DefaultBeanProperty>();
-
- // loop over the methods.
- for ( JavaMethod superMethod : superMethods )
- {
- if ( superMethod.isPropertyAccessor() )
- {
- String propertyName = superMethod.getPropertyName();
- DefaultBeanProperty beanProperty = getOrCreateProperty( beanPropertyMap, propertyName );
-
- beanProperty.setAccessor( superMethod );
- beanProperty.setType( superMethod.getPropertyType() );
- }
- else if ( superMethod.isPropertyMutator() )
- {
- String propertyName = superMethod.getPropertyName();
- DefaultBeanProperty beanProperty = getOrCreateProperty( beanPropertyMap, propertyName );
-
- beanProperty.setMutator( superMethod );
- beanProperty.setType( superMethod.getPropertyType() );
- }
- }
- return new LinkedHashMap<String, BeanProperty>( beanPropertyMap );
- }
-
- private DefaultBeanProperty getOrCreateProperty( Map<String, DefaultBeanProperty> beanPropertyMap,
- String propertyName )
- {
- DefaultBeanProperty result = beanPropertyMap.get( propertyName );
-
- if ( result == null )
- {
- result = new DefaultBeanProperty( propertyName );
- beanPropertyMap.put( propertyName, result );
- }
-
- return result;
- }
-
- /** {@inheritDoc} */
- public BeanProperty getBeanProperty( String propertyName )
- {
- return getBeanProperty( propertyName, false );
- }
-
- /** {@inheritDoc} */
- public BeanProperty getBeanProperty( String propertyName, boolean superclasses )
- {
- return getBeanPropertyMap( superclasses ).get( propertyName );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getDerivedClasses()
- {
- List<JavaClass> result = new LinkedList<JavaClass>();
- for ( JavaClass clazz : getSource().getJavaClassLibrary().getJavaClasses() )
- {
- if ( clazz.isA( this ) && !( clazz == this ) )
- {
- result.add( clazz );
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public JavaClass getDeclaringClass()
- {
- return getParentClass();
- }
-
- /** {@inheritDoc} */
- public List<DocletTag> getTagsByName( String name, boolean superclasses )
- {
- return getTagsRecursive( this, name, superclasses );
- }
-
- private List<DocletTag> getTagsRecursive( JavaClass javaClass, String name, boolean superclasses )
- {
- Set<DocletTag> result = new LinkedHashSet<DocletTag>();
- result.addAll( javaClass.getTagsByName( name ) );
- if ( superclasses )
- {
- JavaClass superclass = javaClass.getSuperJavaClass();
-
- if ( superclass != null )
- {
- result.addAll( getTagsRecursive( superclass, name, superclasses ) );
- }
-
- for ( JavaClass intrfc : javaClass.getImplementedInterfaces() )
- {
- if ( intrfc != null )
- {
- result.addAll( getTagsRecursive( intrfc, name, superclasses ) );
- }
- }
- }
- return new LinkedList<DocletTag>( result );
- }
-
- /**
- * @see java.lang.Class#toString()
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- if ( isPrimitive() )
- {
- sb.append( getName() );
- }
- else
- {
- sb.append( isInterface() ? "interface" : "class" );
- sb.append( " " );
- sb.append( getFullyQualifiedName() );
- }
- return sb.toString();
- }
-
- public String toGenericString()
- {
- return toString();
- }
-
- @Override
- public int hashCode()
- {
- return 2 + getFullyQualifiedName().hashCode();
- }
-
- // ideally this shouldn't be required, but we must as long as Types can be created without classLibrary
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaClass ) )
- {
- return false;
- }
- JavaClass clazz = (JavaClass) obj;
- return this.getFullyQualifiedName().equals( clazz.getFullyQualifiedName() );
- }
-
- /** {@inheritDoc} */
- public ClassLibrary getJavaClassLibrary()
- {
- return getSource().getJavaClassLibrary();
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructor.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructor.java
deleted file mode 100644
index 94486e5..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructor.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-
-/**
- *
- * @author Robert
- * @since 2.0
- */
-public class DefaultJavaConstructor
- extends AbstractBaseMethod implements JavaConstructor
-{
-
- private List<JavaTypeVariable<JavaConstructor>> typeParameters = Collections.emptyList();
-
- public void setTypeParameters( List<JavaTypeVariable<JavaConstructor>> typeParameters )
- {
- this.typeParameters = typeParameters;
- }
-
- /** {@inheritDoc} */
- public List<JavaTypeVariable<JavaConstructor>> getTypeParameters()
- {
- return typeParameters;
- }
-
- public boolean signatureMatches( List<JavaType> parameterTypes )
- {
- return signatureMatches( parameterTypes, false );
- }
-
- public boolean signatureMatches( List<JavaType> parameterTypes, boolean varArgs )
- {
- return super.signatureMatches( parameterTypes, varArgs );
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return getModelWriter().writeConstructor( this ).toString();
- }
-
- @Override
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- if ( isPrivate() )
- {
- result.append( "private " );
- }
- else if ( isProtected() )
- {
- result.append( "protected " );
- }
- else if ( isPublic() )
- {
- result.append( "public " );
- }
- if ( getParentClass() != null )
- {
- result.append( getParentClass().getFullyQualifiedName() );
- }
- result.append( "(" );
- for ( Iterator<JavaParameter> paramIter = getParameters().iterator(); paramIter.hasNext();)
- {
- String typeValue = DefaultJavaType.getResolvedValue( paramIter.next().getType(), getTypeParameters() );
- result.append( typeValue );
- if ( paramIter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ")" );
- if ( getExceptions().size() > 0 )
- {
- result.append( " throws " );
- for ( Iterator<JavaClass> excIter = getExceptions().iterator(); excIter.hasNext(); )
- {
- result.append( excIter.next().getValue() );
- if ( excIter.hasNext() )
- {
- result.append( "," );
- }
- }
- }
- return result.toString();
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = 3 + getName().hashCode();
- hashCode *= 31 + getParameters().hashCode();
- return hashCode;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaConstructor ) )
- {
- return false;
- }
-
- JavaConstructor c = (JavaConstructor) obj;
-
- if ( c.getDeclaringClass() != null ? !c.getDeclaringClass().equals( this.getDeclaringClass() ) : this.getDeclaringClass() != null )
- {
- return false;
- }
-
- if ( !c.getName().equals( getName() ) )
- {
- return false;
- }
-
- List<JavaParameter> myParams = getParameters();
- List<JavaParameter> otherParams = c.getParameters();
- if ( otherParams.size() != myParams.size() )
- {
- return false;
- }
- for ( int i = 0; i < myParams.size(); i++ )
- {
- if ( !otherParams.get( i ).equals( myParams.get( i ) ) )
- {
- return false;
- }
- }
- return this.isVarArgs() == c.isVarArgs();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaField.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaField.java
deleted file mode 100644
index a84aea5..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaField.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.expression.Expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class DefaultJavaField
- extends AbstractJavaEntity
- implements JavaField
-{
-
- private JavaClass type;
-
- private String initializationExpression;
-
- private boolean enumConstant;
-
- private JavaClass enumConstantClass;
-
- private List<Expression> enumConstantArguments;
-
- public DefaultJavaField()
- {
- }
-
- public DefaultJavaField( String name )
- {
- setName( name );
- }
-
- public DefaultJavaField( JavaClass type, String name )
- {
- this( name );
- this.type = type;
- }
-
- /** {@inheritDoc} */
- public JavaClass getDeclaringClass()
- {
- return getParentClass();
- }
-
- /** {@inheritDoc} */
- public JavaClass getType()
- {
- return type;
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return getModelWriter().writeField( this ).toString();
- }
-
- public void setType( JavaClass type )
- {
- this.type = type;
- }
-
- /** {@inheritDoc} */
- public String getDeclarationSignature( boolean withModifiers )
- {
- StringBuilder result = new StringBuilder();
- if ( withModifiers )
- {
- for ( String modifier : getModifiers() )
- {
- result.append( modifier );
- result.append( ' ' );
- }
- }
- result.append( type.getCanonicalName() );
- result.append( ' ' );
- result.append( getName() );
- return result.toString();
- }
-
- /** {@inheritDoc} */
- public String getCallSignature()
- {
- return getName();
- }
-
- /** {@inheritDoc} */
- public String getInitializationExpression()
- {
- return initializationExpression;
- }
-
- public void setInitializationExpression( String initializationExpression )
- {
- this.initializationExpression = initializationExpression;
- }
-
- /** {@inheritDoc} */
- public boolean isEnumConstant()
- {
- return enumConstant;
- }
-
- public void setEnumConstant( boolean enumConstant )
- {
- this.enumConstant = enumConstant;
- }
-
- /** {@inheritDoc} */
- public List<Expression> getEnumConstantArguments()
- {
- return enumConstantArguments;
- }
-
- public void setEnumConstantArguments( List<Expression> enumConstantArguments )
- {
- this.enumConstantArguments = enumConstantArguments;
- }
-
- /** {@inheritDoc} */
- public JavaClass getEnumConstantClass()
- {
- return enumConstantClass;
- }
-
- public void setEnumConstantClass( JavaClass enumConstantClass )
- {
- this.enumConstantClass = enumConstantClass;
- }
-
- /**
- * @see java.lang.reflect.Field#toString()
- */
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- if ( isPrivate() )
- {
- result.append( "private " );
- }
- else if ( isProtected() )
- {
- result.append( "protected " );
- }
- else if ( isPublic() )
- {
- result.append( "public " );
- }
- if ( isStatic() )
- {
- result.append( "static " );
- }
- if ( isFinal() )
- {
- result.append( "final " );
- }
- if ( isTransient() )
- {
- result.append( "transient " );
- }
- if ( isVolatile() )
- {
- result.append( "volatile " );
- }
- result.append( type.getValue() ).append( ' ' );
- result.append( getDeclaringClass().getFullyQualifiedName() ).append( '.' ).append( getName() );
- return result.toString();
- }
-
- /**
- * Compares this Field against the specified object. Returns <code>true</code> if the objects are the same. Two
- * Field objects are the same if they were declared by the same class and have the same name and type.
- */
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaField ) )
- {
- return false;
- }
- JavaField fld = (JavaField) obj;
- if ( fld.getDeclaringClass().equals( this.getDeclaringClass() ) )
- {
- return false;
- }
- if ( fld.isEnumConstant() == this.isEnumConstant() )
- {
- return false;
- }
- // Don't see any reason to compare the Type. Otherwise it's already invalid
- return fld.getName().equals( this.getName() );
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = 5;
- if ( getDeclaringClass() != null )
- {
- hashCode *= 31 + getDeclaringClass().hashCode();
- }
- if ( getName() != null )
- {
- hashCode *= 37 + getName().hashCode();
- }
- return hashCode;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaInitializer.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaInitializer.java
deleted file mode 100644
index 818c18f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaInitializer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.model.JavaInitializer;
-
-/**
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class DefaultJavaInitializer extends AbstractJavaModel implements JavaInitializer
-{
- private boolean staticInitializer;
-
- private String blockContent;
-
- public boolean isStatic()
- {
- return staticInitializer;
- }
-
- public void setStatic( boolean staticInitializer )
- {
- this.staticInitializer = staticInitializer;
- }
-
- public String getBlockContent()
- {
- return blockContent;
- }
-
- public void setBlock( String codeBlock )
- {
- this.blockContent = codeBlock;
- }
-
- public String getCodeBlock()
- {
- return getModelWriter().writeInitializer( this ).toString();
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethod.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethod.java
deleted file mode 100644
index 378b85e..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethod.java
+++ /dev/null
@@ -1,432 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.beans.Introspector;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-
-public class DefaultJavaMethod extends AbstractBaseMethod implements JavaMethod {
-
- private boolean defaultMethod;
- private JavaClass returns = DefaultJavaType.VOID;
- private List<JavaTypeVariable<JavaMethod>> typeParameters = Collections.emptyList();
-
- /**
- * The default constructor
- */
- public DefaultJavaMethod() {
- }
-
- /**
- * Create new method without parameters and return type
- *
- * @param name the name of the method
- */
- public DefaultJavaMethod(String name) {
- setName(name);
- }
-
- /**
- * Create a new method without parameters
- *
- * @param returns the return type
- * @param name the name of this method
- */
- public DefaultJavaMethod(JavaClass returns, String name) {
- this.returns = returns;
- setName(name);
- }
-
- /** {@inheritDoc} */
- public boolean isDefault()
- {
- return defaultMethod;
- }
-
- public void setDefault( boolean defaultMethod )
- {
- this.defaultMethod = defaultMethod;
- }
-
- /** {@inheritDoc} */
- public JavaClass getReturns() {
- return returns;
- }
-
- public void setTypeParameters( List<JavaTypeVariable<JavaMethod>> typeParameters )
- {
- this.typeParameters = typeParameters;
- }
-
- /** {@inheritDoc} */
- public List<JavaTypeVariable<JavaMethod>> getTypeParameters()
- {
- return typeParameters;
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return getModelWriter().writeMethod( this ).toString();
- }
-
- /**
- * @since 1.3
- */
- private String getSignature( boolean withModifiers, boolean isDeclaration )
- {
- StringBuilder result = new StringBuilder();
- if ( withModifiers )
- {
- for ( String modifier : getModifiers() )
- {
- // check for public, protected and private
- if ( modifier.startsWith( "p" ) )
- {
- result.append( modifier ).append( ' ' );
- }
- }
- for ( String modifier : getModifiers() )
- {
- // check for public, protected and private
- if ( !modifier.startsWith( "p" ) )
- {
- result.append( modifier ).append( ' ' );
- }
- }
- }
-
- if ( isDeclaration )
- {
- result.append( returns.getCanonicalName() );
- result.append( ' ' );
- }
-
- result.append( getName() );
- result.append( '(' );
- for ( ListIterator<JavaParameter> iter = getParameters().listIterator(); iter.hasNext(); )
- {
- JavaParameter parameter = iter.next();
- if ( isDeclaration )
- {
- result.append( parameter.getType().getCanonicalName() );
- if ( parameter.isVarArgs() )
- {
- result.append( "..." );
- }
- result.append( ' ' );
- }
- result.append( parameter.getName() );
- if ( iter.hasNext() )
- {
- result.append( ", " );
- }
- }
- result.append( ')' );
- if ( isDeclaration && !getExceptions().isEmpty() )
- {
- result.append( " throws " );
- for ( Iterator<JavaClass> excIter = getExceptions().iterator(); excIter.hasNext(); )
- {
- result.append( excIter.next().getCanonicalName() );
- if ( excIter.hasNext() )
- {
- result.append( ", " );
- }
- }
- }
- return result.toString();
- }
-
-
- /** {@inheritDoc} */
- public String getDeclarationSignature( boolean withModifiers )
- {
- return getSignature(withModifiers, true);
- }
-
- /** {@inheritDoc} */
- public String getCallSignature()
- {
- return getSignature(false, false);
- }
-
- /**
- * Define the return type of this method
- *
- * @param returns the return type
- */
- public void setReturns(JavaClass returns)
- {
- this.returns = returns;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaMethod ) )
- {
- return false;
- }
-
- JavaMethod other = (JavaMethod) obj;
- if ( other.getDeclaringClass() != null ? !other.getDeclaringClass().equals( this.getDeclaringClass() ) : this.getDeclaringClass() != null )
- {
- return false;
- }
-
- //use 'this' from here to make it better readable
- if ( other.getName() != null ? !other.getName().equals( this.getName() ) : this.getName() != null )
- {
- return false;
- }
-
- if ( other.getReturnType() != null ? !other.getReturnType().equals( this.getReturns() ) : this.getReturns() != null )
- {
- return false;
- }
-
- List<JavaParameter> thisParams = this.getParameters();
- List<JavaParameter> otherParams = other.getParameters();
- if ( otherParams.size() != thisParams.size() )
- {
- return false;
- }
- for ( int i = 0; i < thisParams.size(); i++ )
- {
- if ( !otherParams.get( i ).equals( thisParams.get( i ) ) )
- {
- return false;
- }
- }
-
- return this.isVarArgs() == other.isVarArgs();
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = 7;
- if ( getDeclaringClass() != null )
- {
- hashCode *= 31 + getDeclaringClass().hashCode();
- }
- if ( getName() != null )
- {
- hashCode *= 37 + getName().hashCode();
- }
- hashCode *= 41 + getParameters().hashCode();
- if ( returns != null )
- {
- hashCode *= 43 + returns.hashCode();
- }
- return hashCode;
- }
-
- /** {@inheritDoc} */
- public boolean isPropertyAccessor()
- {
- if ( isStatic() )
- {
- return false;
- }
- if ( getParameters().size() != 0 )
- {
- return false;
- }
- if ( getName().startsWith( "is" ) )
- {
- return ( getName().length() > 2 && Character.isUpperCase( getName().charAt( 2 ) ) );
- }
- if ( getName().startsWith( "get" ) )
- {
- return ( getName().length() > 3 && Character.isUpperCase( getName().charAt( 3 ) ) );
- }
- return false;
- }
-
- /** {@inheritDoc} */
- public boolean isPropertyMutator()
- {
- if ( isStatic() )
- {
- return false;
- }
- if ( getParameters().size() != 1 )
- {
- return false;
- }
-
- if ( getName().startsWith( "set" ) )
- {
- return ( getName().length() > 3 && Character.isUpperCase( getName().charAt( 3 ) ) );
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- public JavaType getPropertyType()
- {
- if ( isPropertyAccessor() )
- {
- return getReturns();
- }
- if ( isPropertyMutator() )
- {
- return getParameters().get(0).getType();
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public String getPropertyName()
- {
- int start = -1;
- if ( getName().startsWith( "get" ) || getName().startsWith( "set" ) )
- {
- start = 3;
- }
- else if ( getName().startsWith( "is" ) )
- {
- start = 2;
- }
- else
- {
- return null;
- }
- return Introspector.decapitalize( getName().substring( start ) );
- }
-
- /** {@inheritDoc} */
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- if ( isPrivate() )
- {
- result.append( "private " );
- }
- else if ( isProtected() )
- {
- result.append( "protected " );
- }
- else if ( isPublic() )
- {
- result.append( "public " );
- }
- if ( isAbstract() )
- {
- result.append( "abstract " );
- }
- if ( isStatic() )
- {
- result.append( "static " );
- }
- if ( isFinal() )
- {
- result.append( "final " );
- }
- if ( isSynchronized() )
- {
- result.append( "synchronized " );
- }
- if ( isNative() )
- {
- result.append( "native " );
- }
- result.append( getReturns().getFullyQualifiedName() ).append( ' ' );
- if ( getParentClass() != null )
- {
- result.append( getParentClass().getFullyQualifiedName() );
- result.append( "." );
- }
- result.append( getName() );
- result.append( "(" );
- for ( int paramIndex = 0; paramIndex < getParameters().size(); paramIndex++ )
- {
- if ( paramIndex > 0 )
- {
- result.append( "," );
- }
- JavaType originalType = getParameters().get( paramIndex ).getType();
- JavaTypeVariable<?> typeVariable = DefaultJavaType.resolve( originalType, getTypeParameters() );
- result.append( typeVariable == null ? originalType.getFullyQualifiedName() : typeVariable.getBounds().get( 0 ).getFullyQualifiedName() );
- }
- result.append( ")" );
- if ( getExceptions().size() > 0 )
- {
- result.append( " throws " );
- for ( Iterator<JavaClass> excIter = getExceptions().iterator(); excIter.hasNext(); )
- {
- result.append( excIter.next().getFullyQualifiedName() );
- if ( excIter.hasNext() )
- {
- result.append( "," );
- }
- }
- }
- return result.toString();
- }
-
- /** {@inheritDoc} */
- public JavaClass getGenericReturnType()
- {
- return returns;
- }
-
- /** {@inheritDoc} */
- public JavaType getReturnType()
- {
- return getReturnType( false );
- }
-
- /** {@inheritDoc} */
- public JavaType getReturnType( boolean resolve )
- {
- return returns;
- }
-
- public boolean signatureMatches( String name, List<JavaType> parameterTypes )
- {
- return signatureMatches( name, parameterTypes, false );
- }
-
- public boolean signatureMatches( String name, List<JavaType> parameterTypes, boolean varArg )
- {
- if ( !name.equals( this.getName() ) )
- {
- return false;
- }
- return signatureMatches( parameterTypes, varArg );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackage.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackage.java
deleted file mode 100644
index 2301914..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackage.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaModelUtils;
-import com.thoughtworks.qdox.model.JavaPackage;
-
-/**
- * The default implementation of {@link JavaPackage}, representing a {@link Package}.
- *
- * @since 1.9
- */
-public class DefaultJavaPackage extends AbstractBaseJavaEntity implements JavaPackage {
-
- private ClassLibrary classLibrary;
- private String name;
- private List<JavaClass> classes = new LinkedList<JavaClass>();
-
- /**
- *
- * @param name the name of the package, should never be <code>null</code>
- */
- public DefaultJavaPackage(String name) {
- this.name= name;
- }
-
- /** {@inheritDoc} */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock() {
- return getModelWriter().writePackage(this).toString();
- }
-
- public void setClassLibrary( ClassLibrary classLibrary )
- {
- this.classLibrary = classLibrary;
- }
-
- /** {@inheritDoc} */
- public ClassLibrary getJavaClassLibrary()
- {
- return classLibrary;
- }
-
- public void addClass(JavaClass clazz) {
- classes.add(clazz);
- }
-
- /** {@inheritDoc} */
- public Collection<JavaClass> getClasses() {
- //avoid infinitive recursion
- if (this == classLibrary.getJavaPackage( name )) {
- return classes;
- }
- else {
- return classLibrary.getJavaPackage( name ).getClasses();
- }
- }
-
- /** {@inheritDoc} */
- public JavaClass getClassByName(String name)
- {
- JavaClass result = null;
-
- for ( JavaClass candidateCls : classes )
- {
- result = JavaModelUtils.getClassByName( candidateCls, name );
- if ( result != null )
- {
- result = candidateCls;
- break;
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public JavaPackage getParentPackage()
- {
- String parentName = name.substring( 0, name.lastIndexOf( '.' ) );
- return classLibrary.getJavaPackage( parentName );
- }
-
- /** {@inheritDoc} */
- public List<JavaPackage> getSubPackages() {
- String expected = name + ".";
- Collection<JavaPackage> jPackages = classLibrary.getJavaPackages();
- List<JavaPackage> retList = new LinkedList<JavaPackage>();
- for (JavaPackage jPackage : jPackages) {
- String pName = jPackage.getName();
- if (pName.startsWith(expected) && !(pName.substring(expected.length()).indexOf(".") > -1)) {
- retList.add(classLibrary.getJavaPackage( pName ));
- }
- }
- return retList;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- {
- return true;
- }
- if ( !( o instanceof JavaPackage ) )
- {
- return false;
- }
-
- JavaPackage that = (JavaPackage) o;
-
- return ( name.equals( that.getName() ) );
- }
-
- @Override
- public int hashCode() {
- return 11 + name.hashCode();
- }
-
- @Override
- public String toString() {
- return "package " + name;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameter.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameter.java
deleted file mode 100644
index 896131f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameter.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.ParameterDeclarator;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-public class DefaultJavaParameter extends AbstractBaseJavaEntity implements JavaParameter
-{
-
- private String name;
- private JavaClass type;
- private ParameterDeclarator declarator;
- private boolean varArgs;
-
- public DefaultJavaParameter( JavaClass type, String name )
- {
- this( type, name, false );
- }
-
- public DefaultJavaParameter( JavaClass type, String name, boolean varArgs )
- {
- this.name = name;
- this.type = type;
- this.varArgs = varArgs;
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return getModelWriter().writeParameter( this ).toString();
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- public String getName()
- {
- return name;
- }
-
- /** {@inheritDoc} */
- public JavaType getType()
- {
- return type;
- }
-
- /** {@inheritDoc} */
- public JavaClass getJavaClass()
- {
- return type;
- }
-
- /** {@inheritDoc} */
- public ParameterDeclarator getDeclarator()
- {
- return declarator;
- }
-
- public void setDeclarator( ParameterDeclarator declarator )
- {
- this.declarator = declarator;
- }
-
- /** {@inheritDoc} */
- public JavaClass getParentClass()
- {
- return getDeclarator().getParentClass();
- }
-
- /** {@inheritDoc} */
- public boolean isVarArgs() {
- return varArgs;
- }
-
- /** {@inheritDoc} */
- public String getFullyQualifiedName()
- {
- return type.getFullyQualifiedName();
- }
-
- /** {@inheritDoc} */
- public String getCanonicalName()
- {
- return type.getCanonicalName();
- }
-
- /** {@inheritDoc} */
- public String getValue()
- {
- return type.getValue();
- }
-
- /** {@inheritDoc} */
- public String getGenericCanonicalName()
- {
- return type.getGenericCanonicalName();
- }
-
- /** {@inheritDoc} */
- public String getGenericFullyQualifiedName()
- {
- return type.getGenericFullyQualifiedName();
- }
-
- /** {@inheritDoc} */
- public String getResolvedValue()
- {
- return DefaultJavaType.getResolvedValue( type, getDeclarator().getTypeParameters() );
- }
-
- /** {@inheritDoc} */
- public String getResolvedFullyQualifiedName()
- {
- return DefaultJavaType.getResolvedFullyQualifiedName( type, getDeclarator().getTypeParameters() );
- }
-
- /** {@inheritDoc} */
- public String getResolvedGenericValue()
- {
- return DefaultJavaType.getResolvedGenericValue( type, getDeclarator().getTypeParameters() );
- }
-
- /** {@inheritDoc} */
- public String getResolvedGenericFullyQualifiedName()
- {
- return DefaultJavaType.getResolvedGenericFullyQualifiedName( type, getDeclarator().getTypeParameters() );
- }
-
- @Override
- public int hashCode()
- {
- return 13 + ( isVarArgs() ? 1 : 0 ) + getType().hashCode();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaParameter ) )
- {
- return false;
- }
- JavaParameter p = (JavaParameter) obj;
- // name should not be used in equality check.
- return getType().equals( p.getType() ) && isVarArgs() == p.isVarArgs();
- }
-
- @Override
- public String toString()
- {
- return getResolvedValue() + " "+ name;
- }
-
- /** {@inheritDoc} */
- public String getGenericValue()
- {
- return type.getGenericValue();
- }
-
- /** {@inheritDoc} */
- public String toGenericString()
- {
- return type.toGenericString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterizedType.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterizedType.java
deleted file mode 100644
index 855a8e1..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterizedType.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaParameterizedType;
-import com.thoughtworks.qdox.model.JavaType;
-
-public class DefaultJavaParameterizedType extends DefaultJavaType implements JavaParameterizedType
-{
- private List<JavaType> actualArgumentTypes = Collections.emptyList();
-
-
- public DefaultJavaParameterizedType( String fullName, int dimensions, JavaClassParent context )
- {
- super( fullName, dimensions, context );
- }
-
- public DefaultJavaParameterizedType( String fullName, int dimensions )
- {
- super( fullName, dimensions );
- }
-
- public DefaultJavaParameterizedType( String name, JavaClassParent context )
- {
- super( name, context );
- }
-
- public DefaultJavaParameterizedType( String fullName, String name, int dimensions, JavaClassParent context )
- {
- super( fullName, name, dimensions, context );
- }
-
- public DefaultJavaParameterizedType( String fullName )
- {
- super( fullName );
- }
-
- /**
- *
- * @return the actualTypeArguments or null
- */
- public List<JavaType> getActualTypeArguments()
- {
- return actualArgumentTypes;
- }
-
- public void setActualArgumentTypes( List<JavaType> actualArgumentTypes )
- {
- this.actualArgumentTypes = actualArgumentTypes;
- }
-
- /**
- * The FQN representation of an Object for code usage
- * This implementation ignores generics
- *
- * Some examples how Objects will be translated
- * <pre>
- * Object > java.lang.object
- * java.util.List<T> > java.util.List
- * ? > ?
- * T > T
- * anypackage.Outer.Inner > anypackage.Outer.Inner
- * </pre>
-
- * @since 1.8
- * @return generic type representation for code usage
- */
- public String getGenericValue()
- {
- StringBuilder result = new StringBuilder( getValue() );
- if ( !actualArgumentTypes.isEmpty() )
- {
- result.append( "<" );
- for ( Iterator<JavaType> iter = actualArgumentTypes.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericValue() );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ">" );
- }
- for ( int i = 0; i < getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-
- public String getGenericCanonicalName()
- {
- StringBuilder result = new StringBuilder( getCanonicalName() );
- if ( !actualArgumentTypes.isEmpty() )
- {
- result.append( "<" );
- for ( Iterator<JavaType> iter = actualArgumentTypes.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericCanonicalName() );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ">" );
- }
- for ( int i = 0; i < getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-
- public String getGenericFullyQualifiedName()
- {
- StringBuilder result = new StringBuilder( isResolved() ? fullName : name );
- if ( !actualArgumentTypes.isEmpty() )
- {
- result.append( "<" );
- for ( Iterator<JavaType> iter = actualArgumentTypes.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericFullyQualifiedName() );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ">" );
- }
- for ( int i = 0; i < getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaSource.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaSource.java
deleted file mode 100644
index f66a31a..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaSource.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaModelUtils;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.writer.ModelWriter;
-import com.thoughtworks.qdox.writer.ModelWriterFactory;
-import com.thoughtworks.qdox.writer.impl.DefaultModelWriter;
-
-public class DefaultJavaSource implements JavaSource, Serializable {
-
- private static final Set<String> PRIMITIVE_TYPES = new HashSet<String>();
-
- static {
- PRIMITIVE_TYPES.add("boolean");
- PRIMITIVE_TYPES.add("byte");
- PRIMITIVE_TYPES.add("char");
- PRIMITIVE_TYPES.add("double");
- PRIMITIVE_TYPES.add("float");
- PRIMITIVE_TYPES.add("int");
- PRIMITIVE_TYPES.add("long");
- PRIMITIVE_TYPES.add("short");
- PRIMITIVE_TYPES.add("void");
- }
-
- private final ClassLibrary classLibrary;
- private ModelWriterFactory modelWriterFactory;
-
- private JavaPackage pkg;
- private List<String> imports = new LinkedList<String>();
- private List<JavaClass> classes = new LinkedList<JavaClass>();
- private Map<String, String> resolvedTypeCache = new HashMap<String, String>();
- private URL url;
-
- /**
- * Default constructor for the Default JavaSource
- *
- * @param classLibrary the classLibrary, should not be <code>null</code>
- */
- public DefaultJavaSource( ClassLibrary classLibrary )
- {
- this.classLibrary = classLibrary;
- }
-
- /**
- * @since 1.4
- */
- public void setURL(URL url) {
- this.url = url;
- }
-
- /** {@inheritDoc} */
- public URL getURL() {
- return url;
- }
-
- /** {@inheritDoc} */
- public JavaPackage getPackage() {
- return pkg;
- }
-
- public void setPackage(JavaPackage pkg) {
- this.pkg = pkg;
- }
-
- public void addImport(String imp) {
- imports.add(imp);
- }
-
- /** {@inheritDoc} */
- public List<String> getImports() {
- return imports;
- }
-
- public void addClass(JavaClass cls) {
- classes.add(cls);
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getClasses() {
- return Collections.unmodifiableList( classes );
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock() {
- return getModelWriter().writeSource( this ).toString();
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return getCodeBlock();
- }
-
- /** {@inheritDoc} */
- public String resolveType( String typeName )
- {
- return resolveFullyQualifiedName( typeName );
- }
-
- /** {@inheritDoc} */
- public String resolveFullyQualifiedName( String name )
- {
- String result = resolvedTypeCache.get( name );
- if ( result == null )
- {
- result = resolveTypeInternal( name );
- if ( result != null )
- {
- resolvedTypeCache.put( name, result );
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public String resolveCanonicalName( String name )
- {
- String className = resolveFullyQualifiedName( name );
- String result = null;
- if ( className != null )
- {
- result = className.replace( '$', '.' );
- }
- return result;
- }
-
- /**
- * Resolves a type name
- * <p>
- * Follows the <a href="http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.1">
- * Java Language Specification, Version 3.0</a>.
- * <p>
- * Current resolution order is:
- * <ol>
- * <li>Single-Type-Import Declaration</li>
- * <li>Type-Import-on-Demand Declaration</li>
- * <li>Automatic Imports</li>
- * </ol>
- *
- * @param typeName the name to resolve
- * @return the resolved type name, otherwise <code>null</code>
- */
- private String resolveTypeInternal( String typeName )
- {
- String resolvedName = null;
-
- lookup:
- {
- // primitive types
- if ( PRIMITIVE_TYPES.contains( typeName ) )
- {
- resolvedName = typeName;
- break lookup;
- }
-
- String outerName = typeName;
- String nestedName = typeName.replace( '.', '$' );
- int dotpos = typeName.indexOf( '.' );
-
- if ( dotpos >= 0 )
- {
- outerName = typeName.substring( 0, dotpos );
- }
-
- // Check single-type-import with fully qualified name
- resolvedName = resolveImportedType( typeName, nestedName, true );
-
- if ( resolvedName != null )
- {
- break lookup;
- }
-
- // Check single-type-import with outer name
- resolvedName = resolveImportedType( outerName, nestedName, false );
-
- if ( resolvedName != null )
- {
- break lookup;
- }
-
- // check for class in the same package
- if ( getPackage() != null )
- {
- resolvedName = resolveFullyQualifiedType( getPackageName() + '.' + typeName );
-
- if ( resolvedName != null )
- {
- break lookup;
- }
- }
-
- // check for a class globally
- resolvedName = resolveFullyQualifiedType( typeName );
-
- if ( resolvedName != null )
- {
- break lookup;
- }
-
- // check for a class in the same package
- resolvedName = resolveFromLibrary( getClassNamePrefix() + nestedName );
- if ( resolvedName != null )
- {
- break lookup;
- }
-
- // try java.lang.*
- resolvedName = resolveFromLibrary( "java.lang." + nestedName );
- if ( resolvedName != null )
- {
- break lookup;
- }
-
- // Check type-import-on-demand
- resolvedName = resolveImportedType( "*", nestedName, false );
-
- if ( resolvedName != null )
- {
- break lookup;
- }
- }
-
- return resolvedName;
- }
-
- private String resolveImportedType( String importSpec, String typeName, boolean fullMatch )
- {
- String resolvedName = null;
- String dotSuffix = "." + importSpec;
-
- for ( String imprt : getImports() )
- {
- // static imports can refer to inner classes
- if ( imprt.startsWith( "static " ) )
- {
- imprt = imprt.substring( 7 );
- }
- if ( imprt.equals( importSpec ) || ( !fullMatch && imprt.endsWith( dotSuffix ) ) )
- {
- String candidateName = imprt.substring( 0, imprt.length() - importSpec.length() ) + typeName;
- resolvedName = resolveFullyQualifiedType( candidateName );
- if ( resolvedName == null && !"*".equals( importSpec ) )
- {
- resolvedName = candidateName;
- }
- if ( resolvedName != null )
- {
- break;
- }
- }
- }
-
- return resolvedName;
- }
-
- private String resolveFromLibrary(String typeName) {
- return classLibrary.hasClassReference( typeName ) ? typeName : null;
- }
-
- private String resolveFullyQualifiedType(String typeName) {
- int indexOfLastDot = typeName.lastIndexOf('.');
-
- if (indexOfLastDot >= 0) {
- String root = typeName.substring(0,indexOfLastDot);
- String leaf = typeName.substring(indexOfLastDot+1);
- String resolvedTypeName = resolveFullyQualifiedType(root + '$' + leaf);
-
- if(resolvedTypeName != null) {
- return resolvedTypeName;
- }
- }
-
- if( classLibrary.hasClassReference( typeName ))
- {
- return typeName;
- }
- return null;
- }
-
- /** {@inheritDoc} */
- public String getClassNamePrefix() {
- return ( pkg == null ? "" : pkg.getName() + '.' );
- }
-
- public JavaSource getParentSource() {
- return this;
- }
-
- /** {@inheritDoc} */
- public JavaClass getNestedClassByName(String name) {
- JavaClass result = null;
-
- for (JavaClass candidateCls : classes) {
- if (candidateCls.getName().equals(name)) {
- result = candidateCls;
- break;
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public JavaClass getClassByName(String name)
- {
- JavaClass result = null;
-
- for ( JavaClass candidateCls : classes )
- {
- result = JavaModelUtils.getClassByName( candidateCls, name );
- if ( result != null )
- {
- break;
- }
- }
- return result;
- }
-
- /** {@inheritDoc} */
- public ClassLibrary getJavaClassLibrary()
- {
- return classLibrary;
- }
-
- /** {@inheritDoc} */
- public String getPackageName()
- {
- return ( pkg == null ? "" : pkg.getName() );
- }
-
- /**
- *
- * @param modelWriterFactory
- * @since 2.0
- */
- public void setModelWriterFactory( ModelWriterFactory modelWriterFactory )
- {
- this.modelWriterFactory = modelWriterFactory;
- }
-
- private ModelWriter getModelWriter()
- {
- ModelWriter result;
- if ( modelWriterFactory != null )
- {
- result = modelWriterFactory.newInstance();
- }
- else
- {
- result = new DefaultModelWriter();
- }
- return result;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaType.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaType.java
deleted file mode 100644
index 4ecd782..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaType.java
+++ /dev/null
@@ -1,978 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.BeanProperty;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaGenericDeclaration;
-import com.thoughtworks.qdox.model.JavaInitializer;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameterizedType;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-
-public class DefaultJavaType implements JavaClass, JavaType, Serializable {
-
- public static final DefaultJavaType VOID = new DefaultJavaType("void");
-
- protected final String name;
- private JavaClassParent context;
- protected String fullName;
- private int dimensions;
-
- public DefaultJavaType( String name, JavaClassParent context )
- {
- this.name = name;
- this.context = context;
- }
-
- public DefaultJavaType(String fullName, String name, int dimensions, JavaClassParent context) {
- this.fullName = fullName;
- this.name = name;
- this.dimensions = dimensions;
- this.context = context;
- }
-
- public DefaultJavaType(String fullName, int dimensions, JavaClassParent context) {
- this(fullName, (String) null, dimensions, context);
- }
-
- public DefaultJavaType(String fullName, int dimensions) {
- this(fullName, dimensions, null);
- }
-
- /**
- * Should only be used by primitives, since they don't have a classloader.
- *
- * @param fullName the name of the primitive
- */
- public DefaultJavaType( String fullName )
- {
- this( fullName, 0 );
- }
-
- public static DefaultJavaType createUnresolved(String name, int dimensions, JavaClassParent context) {
- return new DefaultJavaType(null, name, dimensions, context);
- }
-
- /** {@inheritDoc} */
- public String getFullyQualifiedName() {
- StringBuilder result = new StringBuilder( isResolved() ? fullName : name );
- for (int i = 0; i < dimensions; i++)
- {
- result.append("[]");
- }
- return result.toString();
- }
-
- /**
- * Equivalent of {@link Class#getComponentType()}
- * If this type is an array, return its component type
- *
- * @return the type of array if it's one, otherwise <code>null</code>
- */
- public JavaClass getComponentType() {
- return isArray() ? resolveRealClass() : null;
- }
-
- /** {@inheritDoc}*/
- public String getValue() {
- return ( name != null ? name : getFullyQualifiedName().replaceAll( "\\$", "." ) );
- }
-
- /**
- * The FQN representation of an Object for code usage
- * This implementation ignores generics
- *
- * Some examples how Objects will be translated
- * <pre>
- * Object > java.lang.object
- * java.util.List<T> > java.util.List
- * ? > ?
- * T > T
- * anypackage.Outer.Inner > anypackage.Outer.Inner
- * </pre>
-
- * @since 1.8
- * @return generic type representation for code usage
- */
- public String getGenericValue()
- {
- StringBuilder result = new StringBuilder( getValue() );
- for ( int i = 0; i < dimensions; i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-
- protected static <D extends JavaGenericDeclaration> String getGenericValue( JavaType base, List<JavaTypeVariable<D>> typeVariableList )
- {
- StringBuilder result = new StringBuilder( getResolvedValue( base, typeVariableList ) );
- for ( Iterator<JavaType> iter = getActualTypeArguments( base ).iterator(); iter.hasNext(); )
- {
- result.append( DefaultJavaType.resolve( base, typeVariableList ) );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- return result.toString();
- }
-
- private static List<JavaType> getActualTypeArguments( JavaType base )
- {
- List<JavaType> result;
- if ( base instanceof JavaParameterizedType )
- {
- result = ( (JavaParameterizedType) base ).getActualTypeArguments();
- }
- else
- {
- result = Collections.emptyList();
- }
- return result;
- }
-
- protected static <D extends JavaGenericDeclaration> String getResolvedValue( JavaType base, List<JavaTypeVariable<D>> typeParameters )
- {
- String result = base.getValue();
- for ( JavaTypeVariable<?> typeParameter : typeParameters )
- {
- if ( typeParameter.getName().equals( base.getValue() ) )
- {
- result = typeParameter.getBounds().get( 0 ).getValue();
- break;
- }
- }
- return result;
- }
-
- protected static <D extends JavaGenericDeclaration> JavaTypeVariable<D> resolve( JavaType base, List<JavaTypeVariable<D>> typeParameters )
- {
- JavaTypeVariable<D> result = null;
- // String result = getGenericValue(typeParameters);
- for ( JavaTypeVariable<D> typeParameter : typeParameters )
- {
- if ( typeParameter.getName().equals( base.getValue() ) )
- {
- result = typeParameter;
- break;
- }
- }
- return result;
- }
-
- protected boolean isResolved()
- {
- if ( fullName == null && context != null )
- {
- fullName = context.resolveType( name );
- }
- return ( fullName != null );
- }
-
- /**
- * Returns true if this Type is an array
- *
- * @return true if this type is an array, otherwise <code>null</code>
- */
- public boolean isArray() {
- return dimensions > 0;
- }
-
- /**
- * Returns the depth of this array, 0 if it's not an array
- *
- * @return The depth of this array, at least <code>0</code>
- */
- public int getDimensions() {
- return dimensions;
- }
-
- /**
- * Equivalent of {@link Class#toString()}.
- * Converts the object to a string.
- *
- * @return a string representation of this type.
- * @see Class#toString()
- */
- public String toString()
- {
- return getFullyQualifiedName();
- }
-
- /**
- * Returns getGenericValue() extended with the array information
- *
- * <pre>
- * Object > java.lang.Object
- * Object[] > java.lang.Object[]
- * List<Object> > java.lang.List<java.lang.Object>
- * Outer.Inner > Outer$Inner
- * Outer.Inner<Object>[][] > Outer$Inner<java.lang.Object>[][]
- * </pre>
- * @return a generic string representation of this type.
- */
- public String toGenericString() {
- return getGenericFullyQualifiedName();
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( !( obj instanceof JavaType ) )
- {
- return false;
- }
- JavaType t = (JavaType) obj;
- return getFullyQualifiedName().equals( t.getFullyQualifiedName() );
- }
-
- @Override
- public int hashCode() {
- return getFullyQualifiedName().hashCode();
- }
-
- private JavaClass resolveRealClass()
- {
- JavaClass result;
- String qualifiedName = isResolved() ? fullName : name;
- if ( isPrimitive( qualifiedName ) )
- {
- result = new DefaultJavaClass( qualifiedName );
- }
- else
- {
- result = getJavaClassParent().getNestedClassByName( qualifiedName );
- if ( result == null )
- {
- result = getJavaClassLibrary().getJavaClass( qualifiedName, true );
- }
- }
-
- return result;
- }
-
- /**
- *
- * @return this
- * @deprecated Type already has the JavaClass interface
- */
- public JavaClass getJavaClass()
- {
- return this;
- }
-
- /**
- * @since 1.3
- */
- public boolean isA( JavaType type )
- {
- if ( this == type )
- {
- return true;
- }
- else
- {
- return this.isA( type );
- }
- }
-
- /**
- * @since 1.6
- */
- public boolean isPrimitive() {
- return isPrimitive( getValue() );
- }
-
- private static boolean isPrimitive( String value )
- {
- return "void".equals(value)
- || "boolean".equals(value)
- || "byte".equals(value)
- || "char".equals(value)
- || "short".equals(value)
- || "int".equals(value)
- || "long".equals(value)
- || "float".equals(value)
- || "double".equals(value);
-
- }
-
- /**
- * @since 1.6
- */
- public boolean isVoid() {
- return "void".equals(getValue());
- }
-
-// String superSource = "public abstract class Test<T> {\n" +
-// " private T me;\n" +
-// " public Test(T me) {\n" +
-// " this.me = me;\n" +
-// " }\n" +
-// " public T getValue() {\n" +
-// " return me;\n" +
-// " }\n" +
-// " }";
-//String subSource = "public class StringTest extends Test<String> {\n" +
-// " public StringTest(String s) {\n" +
-// " super(s);\n" +
-// " }\n" +
-// " }";
-
- /**
- * Consider the following example
- *
- * <pre>
- * public abstract class AbstractClass<T>
- * {
- * private T value;
- *
- * public AbstractClass( T value ) { this.value = value; }
- *
- * public T getValue() { return value; }
- * }
- *
- * public class ConcreteClass extends AbstractClass<String>
- * {
- * public ConcreteClass( String s ) { super( s ); }
- * }
- * </pre>
- * <p>
- * We want to know the resolved returnType when calling <code>ConcreteClass.getValue()</code>.
- * The expected type is String.
- * </p>
- *
- * <ul>
- * <li>{@code this} would be T</li>
- * <li>{@code declaringClass} would be AbstractClass, since that's where T is used</li>
- * <li>{@code callingClass} would be ConcreteClass</li>
- * </ul>
- *
- * @param declaringClass
- * @param callingClass
- * @return
- */
- protected static JavaType resolve( JavaType base, JavaClass declaringClass, JavaClass callingClass )
- {
- JavaType result = base;
-
- String concreteClassName;
- if ( base instanceof JavaClass )
- {
- JavaClass baseClass = (JavaClass) base;
- concreteClassName = ( baseClass.isArray() ? baseClass.getComponentType().getFullyQualifiedName() : baseClass.getFullyQualifiedName() );
- }
- else
- {
- concreteClassName = base.getFullyQualifiedName();
- }
-
- int typeIndex = getTypeVariableIndex( declaringClass, concreteClassName );
-
- if ( typeIndex >= 0 )
- {
- String fqn = declaringClass.getFullyQualifiedName();
- if ( callingClass.getSuperClass() != null
- && fqn.equals( callingClass.getSuperClass().getFullyQualifiedName() ) )
- {
- result = getActualTypeArguments( callingClass.getSuperClass() ).get( typeIndex );
- }
- else
- {
- for ( JavaClass implement : callingClass.getInterfaces() )
- {
- if ( fqn.equals( implement.getFullyQualifiedName() ) )
- {
- JavaType actualType = getActualTypeArguments( implement ).get( typeIndex );
- JavaType resolvedType = new DefaultJavaType( actualType.getFullyQualifiedName(), actualType.getValue(), getDimensions( base ), implement.getParent() );
- result = resolve( resolvedType , implement, implement );
- break;
- }
- else
- {
- // no direct interface available, try indirect
- result = resolve( base, implement, callingClass );
- }
- }
- }
- }
-
- List<JavaType> actualTypeArguments = getActualTypeArguments(base);
- if ( !actualTypeArguments.isEmpty() )
- {
- String value = base.getValue();
- if( value.indexOf( '[' ) > 0 )
- {
- value = value.substring( 0, value.indexOf( '[' ) );
- }
- DefaultJavaParameterizedType typeResult =
- new DefaultJavaParameterizedType( concreteClassName, value, getDimensions( base ),
- ((DefaultJavaType)base).getJavaClassParent() );
-
- List<JavaType> actualTypes = new LinkedList<JavaType>();
- for ( JavaType actualArgType : actualTypeArguments )
- {
- actualTypes.add( resolve( actualArgType, declaringClass, callingClass ) );
- }
- typeResult.setActualArgumentTypes( actualTypes );
- result = typeResult;
- }
- return result;
- }
-
- private static int getDimensions( JavaType type )
- {
- return type instanceof JavaClass ? ( (JavaClass) type ).getDimensions() : 0;
- }
-
- private static JavaClass getDeclaringClass( JavaType type )
- {
- return type instanceof JavaClass ? ( (JavaClass) type ).getDeclaringClass() : null;
- }
-
- private static int getTypeVariableIndex( JavaClass declaringClass, String fqn )
- {
- int typeIndex = -1;
- for ( JavaTypeVariable<?> typeVariable : declaringClass.getTypeParameters() )
- {
- typeIndex++;
- if ( typeVariable.getFullyQualifiedName().equals( fqn ) )
- {
- return typeIndex;
- }
- }
- return -1;
- }
-
- /** {@inheritDoc} */
- public String getGenericFullyQualifiedName()
- {
- StringBuilder result = new StringBuilder( isResolved() ? fullName : name );
- for ( int i = 0; i < dimensions; i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-
- /** {@inheritDoc} */
- public String getGenericCanonicalName()
- {
- StringBuilder result = new StringBuilder( getCanonicalName() );
- for ( int i = 0; i < dimensions; i++ )
- {
- result.append( "[]" );
- }
- return result.toString();
- }
-
- protected static <D extends JavaGenericDeclaration> String getResolvedGenericValue( JavaType base, List<JavaTypeVariable<D>> typeParameters )
- {
- StringBuilder result = new StringBuilder();
- JavaTypeVariable<?> variable = resolve( base, typeParameters );
- result.append( variable == null ? base.getValue() : variable.getBounds().get(0).getValue() );
- List<JavaType> actualTypeArguments = getActualTypeArguments( base );
- if ( !actualTypeArguments.isEmpty() )
- {
- result.append( "<" );
- for ( Iterator<JavaType> iter = actualTypeArguments.iterator(); iter.hasNext(); )
- {
- result.append( getGenericValue( iter.next(), typeParameters) );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ">" );
- }
- if( base instanceof JavaClass )
- {
- for ( int i = 0; i < ( (JavaClass) base ).getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- }
- return result.toString();
- }
-
- protected static <D extends JavaGenericDeclaration> String getResolvedGenericFullyQualifiedName( JavaType base, List<JavaTypeVariable<D>> typeParameters )
- {
- StringBuilder result = new StringBuilder();
- JavaTypeVariable<D> variable = resolve( base, typeParameters );
- result.append( variable == null ? base.getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() );
- List<JavaType> actualTypeArguments = getActualTypeArguments( base );
- if ( !actualTypeArguments.isEmpty() )
- {
- result.append( "<" );
- for ( Iterator<JavaType> iter = actualTypeArguments.iterator(); iter.hasNext(); )
- {
- result.append( getResolvedFullyQualifiedName( iter.next(), typeParameters) );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- result.append( ">" );
- }
- if ( base instanceof JavaClass )
- {
- for ( int i = 0; i < ( (JavaClass) base ).getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- }
- return result.toString();
- }
-
- protected static <D extends JavaGenericDeclaration> String getResolvedFullyQualifiedName( JavaType base, List<JavaTypeVariable<D>> typeParameters )
- {
- JavaTypeVariable<D> variable = resolve( base, typeParameters );
- return (variable == null ? base.getFullyQualifiedName() : variable.getBounds().get(0).getFullyQualifiedName() );
- }
-
- //Delegating methods
-
- /** {@inheritDoc} */
- public JavaSource getSource()
- {
- return resolveRealClass().getSource();
- }
-
- /** {@inheritDoc} */
- public int getLineNumber()
- {
- return resolveRealClass().getLineNumber();
- }
-
- /** {@inheritDoc} */
- public boolean isInterface()
- {
- return resolveRealClass().isInterface();
- }
-
- /** {@inheritDoc} */
- public List<JavaAnnotation> getAnnotations()
- {
- return resolveRealClass().getAnnotations();
- }
-
- /** {@inheritDoc} */
- public boolean isEnum()
- {
- return resolveRealClass().isEnum();
- }
-
- /** {@inheritDoc} */
- public String getComment()
- {
- return resolveRealClass().getComment();
- }
-
- /** {@inheritDoc} */
- public List<DocletTag> getTags()
- {
- return resolveRealClass().getTags();
- }
-
- /** {@inheritDoc} */
- public boolean isAnnotation()
- {
- return resolveRealClass().isAnnotation();
- }
-
- /** {@inheritDoc} */
- public List<DocletTag> getTagsByName( String name )
- {
- return resolveRealClass().getTagsByName( name );
- }
-
- /** {@inheritDoc} */
- public DocletTag getTagByName( String name )
- {
- return resolveRealClass().getTagByName( name );
- }
-
- /** {@inheritDoc} */
- public JavaType getSuperClass()
- {
- return resolveRealClass().getSuperClass();
- }
-
- /** {@inheritDoc} */
- public JavaClass getSuperJavaClass()
- {
- return resolveRealClass().getSuperJavaClass();
- }
-
- /** {@inheritDoc} */
- public List<JavaType> getImplements()
- {
- return resolveRealClass().getImplements();
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getImplementedInterfaces()
- {
- return resolveRealClass().getImplementedInterfaces();
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getInterfaces()
- {
- return resolveRealClass().getImplementedInterfaces();
- }
-
- /** {@inheritDoc} */
- public String getNamedParameter( String tagName, String parameterName )
- {
- return resolveRealClass().getNamedParameter( tagName, parameterName );
- }
-
- /** {@inheritDoc} */
- public String getCodeBlock()
- {
- return resolveRealClass().getCodeBlock();
- }
-
- /** {@inheritDoc} */
- public <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters()
- {
- return resolveRealClass().getTypeParameters();
- }
-
- /** {@inheritDoc} */
- public JavaSource getParentSource()
- {
- return resolveRealClass().getParentSource();
- }
-
- /** {@inheritDoc} */
- public JavaPackage getPackage()
- {
- return resolveRealClass().getPackage();
- }
-
- /** {@inheritDoc} */
- public String getPackageName()
- {
- return resolveRealClass().getPackageName();
- }
-
- /** {@inheritDoc} */
- public boolean isInner()
- {
- return resolveRealClass().isInner();
- }
-
- /** {@inheritDoc} */
- public String resolveCanonicalName( String name )
- {
- return resolveRealClass().resolveCanonicalName( name );
- }
-
- /** {@inheritDoc} */
- public String resolveFullyQualifiedName( String name )
- {
- return resolveRealClass().resolveFullyQualifiedName( name );
- }
-
- /** {@inheritDoc} */
- public String getClassNamePrefix()
- {
- return resolveRealClass().getClassNamePrefix();
- }
-
- /** {@inheritDoc} */
- public List<JavaInitializer> getInitializers()
- {
- return resolveRealClass().getInitializers();
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethods()
- {
- return resolveRealClass().getMethods();
- }
-
- /** {@inheritDoc} */
- public List<JavaConstructor> getConstructors()
- {
- return resolveRealClass().getConstructors();
- }
-
- /** {@inheritDoc} */
- public JavaConstructor getConstructor( List<JavaType> parameterTypes )
- {
- return resolveRealClass().getConstructor( parameterTypes );
- }
-
- /** {@inheritDoc} */
- public JavaConstructor getConstructor( List<JavaType> parameterTypes, boolean varArg )
- {
- return resolveRealClass().getConstructor( parameterTypes, varArg );
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethods( boolean superclasses )
- {
- return resolveRealClass().getMethods( superclasses );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes )
- {
- return resolveRealClass().getMethodBySignature( name, parameterTypes );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethod( String name, List<JavaType> parameterTypes, boolean varArgs )
- {
- return resolveRealClass().getMethod( name, parameterTypes, varArgs );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses )
- {
- return resolveRealClass().getMethodBySignature( name, parameterTypes, superclasses );
- }
-
- /** {@inheritDoc} */
- public JavaMethod getMethodBySignature( String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg )
- {
- return resolveRealClass().getMethodBySignature( name, parameterTypes, superclasses, varArg );
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses )
- {
- return resolveRealClass().getMethodsBySignature( name, parameterTypes, superclasses );
- }
-
- /** {@inheritDoc} */
- public List<JavaMethod> getMethodsBySignature( String name, List<JavaType> parameterTypes, boolean superclasses,
- boolean varArg )
- {
- return resolveRealClass().getMethodsBySignature( name, parameterTypes, superclasses, varArg );
- }
-
- /** {@inheritDoc} */
- public List<JavaField> getFields()
- {
- return resolveRealClass().getFields();
- }
-
- /** {@inheritDoc} */
- public JavaField getFieldByName( String name )
- {
- return resolveRealClass().getFieldByName( name );
- }
-
- /** {@inheritDoc} */
- public List<JavaField> getEnumConstants()
- {
- return resolveRealClass().getEnumConstants();
- }
-
- /** {@inheritDoc} */
- public JavaField getEnumConstantByName( String name )
- {
- return resolveRealClass().getEnumConstantByName( name );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getNestedClasses()
- {
- return resolveRealClass().getNestedClasses();
- }
-
- /** {@inheritDoc} */
- public JavaClass getNestedClassByName( String name )
- {
- return resolveRealClass().getNestedClassByName( name );
- }
-
- /** {@inheritDoc} */
- public boolean isA( String fullClassName )
- {
- return resolveRealClass().isA( fullClassName );
- }
-
- /** {@inheritDoc} */
- public boolean isA( JavaClass javaClass )
- {
- return resolveRealClass().isA( javaClass );
- }
-
- /** {@inheritDoc} */
- public List<BeanProperty> getBeanProperties()
- {
- return resolveRealClass().getBeanProperties();
- }
-
- /** {@inheritDoc} */
- public List<BeanProperty> getBeanProperties( boolean superclasses )
- {
- return resolveRealClass().getBeanProperties( superclasses );
- }
-
- /** {@inheritDoc} */
- public BeanProperty getBeanProperty( String propertyName )
- {
- return resolveRealClass().getBeanProperty( propertyName );
- }
-
- /** {@inheritDoc} */
- public BeanProperty getBeanProperty( String propertyName, boolean superclasses )
- {
- return resolveRealClass().getBeanProperty( propertyName, superclasses );
- }
-
- /** {@inheritDoc} */
- public List<JavaClass> getDerivedClasses()
- {
- return resolveRealClass().getDerivedClasses();
- }
-
- /** {@inheritDoc} */
- public List<DocletTag> getTagsByName( String name, boolean superclasses )
- {
- return resolveRealClass().getTagsByName( name, superclasses );
- }
-
- /** {@inheritDoc} */
- public ClassLibrary getJavaClassLibrary()
- {
- return context.getJavaClassLibrary();
- }
-
- /** {@inheritDoc} */
- public String getName()
- {
- return resolveRealClass().getName();
- }
-
- /** {@inheritDoc} */
- public String getCanonicalName()
- {
- return resolveRealClass().getCanonicalName();
- }
-
- /** {@inheritDoc} */
- public List<String> getModifiers()
- {
- return resolveRealClass().getModifiers();
- }
-
- /** {@inheritDoc} */
- public boolean isPublic()
- {
- return resolveRealClass().isPublic();
- }
-
- /** {@inheritDoc} */
- public boolean isProtected()
- {
- return resolveRealClass().isProtected();
- }
-
- /** {@inheritDoc} */
- public boolean isPrivate()
- {
- return resolveRealClass().isPrivate();
- }
-
- /** {@inheritDoc} */
- public boolean isFinal()
- {
- return resolveRealClass().isFinal();
- }
-
- /** {@inheritDoc} */
- public boolean isStatic()
- {
- return resolveRealClass().isStatic();
- }
-
- /** {@inheritDoc} */
- public boolean isAbstract()
- {
- return resolveRealClass().isAbstract();
- }
-
- /** {@inheritDoc} */
- public JavaClass getDeclaringClass()
- {
- return resolveRealClass().getDeclaringClass();
- }
-
- // deprecated
- public JavaType asType() {
- return resolveRealClass().asType();
- }
-
- public List<JavaClass> getClasses()
- {
- return resolveRealClass().getClasses();
- }
-
- public JavaClass getInnerClassByName( String name )
- {
- return resolveRealClass().getInnerClassByName( name );
- }
-
- public List<JavaClass> getInnerClasses()
- {
- return resolveRealClass().getInnerClasses();
- }
-
- public JavaClassParent getParent()
- {
- return context;
- }
-
- public String resolveType( String name )
- {
- return resolveRealClass().resolveType( name );
- }
-
- public JavaClassParent getJavaClassParent() {
- return context;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java
deleted file mode 100644
index e7dcc3f..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeVariable.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaGenericDeclaration;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-
-/**
- * Equivalent of {@link java.lang.reflect.TypeVariable}
- *
- * @author Robert Scholte
- * @since 1.10
- */
-public class DefaultJavaTypeVariable<D extends JavaGenericDeclaration>
- extends DefaultJavaType implements JavaTypeVariable<D>
-{
- private List<JavaType> bounds;
-
- private D genericDeclaration;
-
- public DefaultJavaTypeVariable( String name, D genericDeclaration )
- {
- super( name, getContext( genericDeclaration ) );
- this.genericDeclaration = genericDeclaration;
- }
-
- private static JavaClass getContext( JavaGenericDeclaration genericDeclaration )
- {
- JavaClass result;
- if ( genericDeclaration instanceof JavaClass )
- {
- result = (JavaClass) genericDeclaration;
- }
- else if ( genericDeclaration instanceof JavaMethod )
- {
- result = ( (JavaMethod) genericDeclaration ).getDeclaringClass();
- }
- else if ( genericDeclaration instanceof JavaConstructor )
- {
- result = ( (JavaConstructor) genericDeclaration ).getDeclaringClass();
- }
- else
- {
- throw new IllegalArgumentException( "Unknown JavaGenericDeclaration implementation" );
- }
- return result;
- }
-
- /**
- * @return the bounds
- */
- public List<JavaType> getBounds()
- {
- return bounds;
- }
-
- /**
- * @param bounds the bounds to set
- */
- public void setBounds( List<JavaType> bounds )
- {
- this.bounds = bounds;
- }
-
- public D getGenericDeclaration()
- {
- return genericDeclaration;
- }
-
- @Override
- public String getFullyQualifiedName()
- {
- return getValue();
- }
-
- @Override
- public String getGenericFullyQualifiedName()
- {
- StringBuilder result = new StringBuilder();
- result.append( '<' );
- result.append( super.getFullyQualifiedName() );
- if ( bounds != null && !bounds.isEmpty() )
- {
- result.append( " extends " );
- for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericFullyQualifiedName() );
- if ( iter.hasNext() )
- {
- result.append( " & " );
- }
- }
- }
- result.append( '>' );
- return result.toString();
- }
-
- @Override
- public String getCanonicalName()
- {
- return super.getValue();
- }
-
- @Override
- public String getGenericCanonicalName()
- {
- StringBuilder result = new StringBuilder();
- result.append( '<' );
- result.append( super.getGenericCanonicalName() );
- if ( bounds != null && !bounds.isEmpty() )
- {
- result.append( " extends " );
- for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericCanonicalName() );
- if ( iter.hasNext() )
- {
- result.append( " & " );
- }
- }
- }
- result.append( '>' );
- return result.toString();
- }
-
- @Override
- public String getGenericValue()
- {
- StringBuilder result = new StringBuilder( getValue() );
- if ( bounds != null && !bounds.isEmpty() )
- {
- result.append( " extends " );
- for ( Iterator<JavaType> iter = bounds.iterator(); iter.hasNext(); )
- {
- result.append( iter.next().getGenericValue() );
- if ( iter.hasNext() )
- {
- result.append( "," );
- }
- }
- }
- return result.toString();
- }
-
- @Override
- public String getName()
- {
- return getValue();
- }
-
- public String getResolvedValue()
- {
- return bounds.get( 0 ).getValue();
- }
-
- public String getResolvedFullyQualifiedName()
- {
- return bounds.get( 0 ).getFullyQualifiedName();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaWildcardType.java b/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaWildcardType.java
deleted file mode 100644
index 9123871..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/DefaultJavaWildcardType.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.Collections;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaWildcardType;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Equivalent of {@link java.lang.reflect.WildcardType}
- * This class supports both the 'super' and 'extends' wildcards. For <?> you must use the normal Type, because ?
- * itself can't be generic
- *
- * @author Robert Scholte
- */
-public class DefaultJavaWildcardType extends DefaultJavaType
- implements JavaWildcardType
-{
- public static enum BoundType { EXTENDS, SUPER }
-
- private BoundType boundType;
-
- private List<JavaType> bounds;
-
- public DefaultJavaWildcardType()
- {
- super( "?" );
- bounds = Collections.emptyList();
- }
-
- public DefaultJavaWildcardType( JavaType type, BoundType boundType )
- {
- this();
- bounds = Collections.singletonList( type );
- this.boundType = boundType;
- }
-
- public String getFullyQualifiedName()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getFullyQualifiedName() );
- }
- return builder.toString();
- }
-
- public String getGenericValue()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getGenericValue() );
- }
- return builder.toString();
- }
-
- public String getGenericFullyQualifiedName()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getGenericFullyQualifiedName() );
- }
- return builder.toString();
- }
-
- public String getCanonicalName()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getCanonicalName() );
- }
- return builder.toString();
- }
-
- public String getGenericCanonicalName()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getGenericCanonicalName() );
- }
- return builder.toString();
- }
-
- public String getValue()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.getValue() );
- }
- return builder.toString();
-
- }
-
- public String toGenericString()
- {
- StringBuilder builder = getPreparedStringBuilder();
- for( JavaType type : bounds )
- {
- builder.append( type.toGenericString() );
- }
- return builder.toString();
- }
-
- private StringBuilder getPreparedStringBuilder()
- {
- StringBuilder builder = new StringBuilder( "?" );
- if( BoundType.EXTENDS.equals( boundType ) )
- {
- builder.append( " extends " );
- }
- else if( BoundType.SUPER.equals( boundType ) )
- {
- builder.append( " super " );
- }
- return builder;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/JavaClassParent.java b/src/main/java/com/thoughtworks/qdox/model/impl/JavaClassParent.java
deleted file mode 100644
index b719c24..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/JavaClassParent.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * @deprecated this interface will be hidden for the model interfaces
- */
-public interface JavaClassParent {
-
- /**
- * Resolve a type-name within the context of this source or class.
- * @param typeName name of a type
- * @return the fully-qualified name of the type, or null if it cannot
- * be resolved
- */
- String resolveType(String typeName);
-
- String resolveCanonicalName(String typeName);
-
- String resolveFullyQualifiedName(String typeName);
-
- JavaSource getParentSource();
-
- JavaClass getNestedClassByName(String name);
-
- ClassLibrary getJavaClassLibrary();
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/model/impl/package-info.java b/src/main/java/com/thoughtworks/qdox/model/impl/package-info.java
deleted file mode 100644
index cfe3272..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/impl/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Provides the default implementation of the classes reflecting the Java model elements.
- * These classes are often richer then their <code>java.reflect</code> equivalent.
- */
-package com.thoughtworks.qdox.model.impl;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/package-info.java b/src/main/java/com/thoughtworks/qdox/model/package-info.java
deleted file mode 100644
index 1e0275b..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Provides classes reflecting the Java model elements.
- * These classes are often richer then their <code>java.reflect</code> equivalent.
- */
-package com.thoughtworks.qdox.model;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/model/util/package-info.java b/src/main/java/com/thoughtworks/qdox/model/util/package-info.java
deleted file mode 100644
index 4766111..0000000
--- a/src/main/java/com/thoughtworks/qdox/model/util/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides utility classes supporting the construction of the models
- */
-package com.thoughtworks.qdox.model.util;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/package-info.java b/src/main/java/com/thoughtworks/qdox/package-info.java
deleted file mode 100644
index 09549df..0000000
--- a/src/main/java/com/thoughtworks/qdox/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes to start constructing a java project
- */
-package com.thoughtworks.qdox;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/CommentHandler.java b/src/main/java/com/thoughtworks/qdox/parser/CommentHandler.java
deleted file mode 100644
index 357b4f9..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/CommentHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * JavaDoc is not part of the Java Language Specification, it should be treated as a special type of comment. This means
- * it can appear almost everywhere, although there are only a few places where JavaDoc has effect. When the parser has
- * finished a comment, it will trigger the commentHandler by calling the onComment-method.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface CommentHandler
-{
- /**
- * Called if the parser hits a comment
- *
- * @param comment the comment
- * @param line the line number
- * @param column the column number
- */
- void onComment( String comment, int line, int column );
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/CommentScanner.java b/src/main/java/com/thoughtworks/qdox/parser/CommentScanner.java
deleted file mode 100644
index bf1ebe9..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/CommentScanner.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Classes implementing this interface can trigger the handler for every time it has parsed a comment.
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface CommentScanner
-{
- /**
- * Register this handler as a comment-listener.
- * If scanner hits a comment, all handlers will be triggered.
- *
- * @param handler the commentHandler to add to the CommentScanner
- */
- void addCommentHandler( CommentHandler handler );
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/JavaLexer.java b/src/main/java/com/thoughtworks/qdox/parser/JavaLexer.java
deleted file mode 100644
index 943d550..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/JavaLexer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * The Lexer-interface for Java sources
- *
- * @since 2.0
- */
-public interface JavaLexer extends Lexer, CommentScanner
-{
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/Lexer.java b/src/main/java/com/thoughtworks/qdox/parser/Lexer.java
deleted file mode 100644
index 67565a0..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/Lexer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-public interface Lexer {
-
- int lex() throws IOException;
-
- String text();
-
- int getLine();
-
- int getColumn();
-
- String getCodeBody();
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/ParseException.java b/src/main/java/com/thoughtworks/qdox/parser/ParseException.java
deleted file mode 100644
index 927fe7c..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/ParseException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Thrown to indicate an error during parsing
- */
-public class ParseException
- extends RuntimeException
-{
-
- /**
- * The line where the ParserException occurred
- */
- private int line = -1;
-
- /**
- * The column where the ParserException occurred
- */
- private int column = -1;
-
- /**
- * The sourceInfo of where the exception occurred
- */
- private String sourceInfo;
-
- /**
- * Default constructor for the ParseException
- *
- * @param message the message
- * @param line the line number
- * @param column the column number
- */
- public ParseException( String message, int line, int column )
- {
- super( message );
- this.line = line;
- this.column = column;
- }
-
- public int getLine()
- {
- return line;
- }
-
- public int getColumn()
- {
- return column;
- }
-
- public void setSourceInfo( String sourceInfo )
- {
- this.sourceInfo = sourceInfo;
- }
-
- @Override
- public String getMessage()
- {
- StringBuilder buffer = new StringBuilder( super.getMessage() );
- if ( line >= 0 )
- {
- buffer.append( " @[" ).append( line );
-
- if ( column >= 0 )
- {
- buffer.append( ',' ).append( column );
- }
- buffer.append( ']' );
- }
- if ( sourceInfo != null )
- {
- buffer.append( " in " ).append( sourceInfo );
- }
- return buffer.toString();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/AddDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/AddDef.java
deleted file mode 100644
index 19499f7..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/AddDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class AddDef extends BinaryOperatorDef {
-
- public AddDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/AndDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/AndDef.java
deleted file mode 100644
index 88f4f9d..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/AndDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class AndDef extends BinaryOperatorDef {
-
- public AndDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/AssignmentDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/AssignmentDef.java
deleted file mode 100644
index dd82036..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/AssignmentDef.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class AssignmentDef extends ExpressionDef
-{
-
- private ElemValueDef letfHandSide;
- private String operator;
- private ElemValueDef assignmentExpression;
-
- public AssignmentDef( ElemValueDef letfHandSide, String operator, ElemValueDef assignmentExpression )
- {
- this.letfHandSide = letfHandSide;
- this.operator = operator;
- this.assignmentExpression = assignmentExpression;
- }
-
- public ElemValueDef getLetfHandSide()
- {
- return letfHandSide;
- }
-
- public String getOperator()
- {
- return operator;
- }
-
- public ElemValueDef getAssignmentExpression()
- {
- return assignmentExpression;
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform(this);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/BinaryOperatorDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/BinaryOperatorDef.java
deleted file mode 100644
index 9142897..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/BinaryOperatorDef.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class BinaryOperatorDef extends ExpressionDef {
-
- private final ElemValueDef lhs;
- private final ElemValueDef rhs;
-
- public BinaryOperatorDef(ElemValueDef lhs, ElemValueDef rhs) {
- this.lhs = lhs;
- this.rhs = rhs;
- }
-
- /**
- * @return the lhs
- */
- public ElemValueDef getLeft()
- {
- return lhs;
- }
-
- /**
- * @return the rhs
- */
- public ElemValueDef getRight()
- {
- return rhs;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/CastDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/CastDef.java
deleted file mode 100644
index 7cfb7a4..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/CastDef.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class CastDef extends ExpressionDef
-{
-
- private final TypeDef typeDef;
-
- private final ElemValueDef elemDef;
-
- public CastDef( TypeDef type, ElemValueDef value )
- {
- this.typeDef = type;
- this.elemDef = value;
- }
-
- public TypeDef getTypeDef()
- {
- return typeDef;
- }
-
- public ElemValueDef getElemDef()
- {
- return elemDef;
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ConstantDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ConstantDef.java
deleted file mode 100644
index 0852577..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ConstantDef.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-public class ConstantDef extends ExpressionDef {
-
- private final String value;
- private Class<?> type;
-
- public ConstantDef( String value, Class<?> type ) {
- this.value = value;
- this.type = type;
- }
-
- public Class<?> getType()
- {
- return type;
- }
-
- public String getValue() {
- return value;
- }
-
- public String toString() {
- return value;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/CreatorDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/CreatorDef.java
deleted file mode 100644
index f0b8eb2..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/CreatorDef.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-import java.util.List;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class CreatorDef extends ExpressionDef
-{
- private List<?> typeArguments;
-
- private String createdName;
-
- private List<ExpressionDef> arguments;
-
- private String classBody;
-
- public List<?> getTypeArguments()
- {
- return typeArguments;
- }
-
- public void setTypeArguments( List<?> typeArguments )
- {
- this.typeArguments = typeArguments;
- }
-
- public String getCreatedName()
- {
- return createdName;
- }
-
- public void setCreatedName( String createdName )
- {
- this.createdName = createdName;
- }
-
- public List<ExpressionDef> getArguments()
- {
- return arguments;
- }
-
- public void setArguments( List<ExpressionDef> arguments )
- {
- this.arguments = arguments;
- }
-
- public String getClassBody()
- {
- return classBody;
- }
-
- public void setClassBody( String classBody )
- {
- this.classBody = classBody;
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/DivideDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/DivideDef.java
deleted file mode 100644
index f1521d1..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/DivideDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class DivideDef extends BinaryOperatorDef {
-
- public DivideDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueDef.java
deleted file mode 100644
index b62a4b1..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueDef.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-public interface ElemValueDef {
-
- <U> U transform(ElemValueTransformer<U> transformer);
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueListDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueListDef.java
deleted file mode 100644
index 06bd353..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueListDef.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-import java.util.List;
-
-
-public class ElemValueListDef implements ElemValueDef{
-
- private List<ElemValueDef> valueList;
-
- public ElemValueListDef(List<ElemValueDef> annoValueList) {
- this.valueList = annoValueList;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
- /**
- * @return the valueList
- */
- public List<ElemValueDef> getValueList()
- {
- return valueList;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java
deleted file mode 100644
index d4b0034..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.parser.structs.AnnoDef;
-
-public interface ElemValueTransformer<U>
-{
- U transform( AnnoDef annoDef );
-
- U transform( AddDef annotationAdd );
-
- U transform( AndDef annotationAnd );
-
- U transform( DivideDef annotationDivide );
-
- U transform( EqualsDef annotationEquals );
-
- U transform( ExclusiveOrDef annotationExclusiveOr );
-
- U transform( GreaterEqualsDef annotationGreaterEquals );
-
- U transform( GreaterThanDef annotationGreaterThan );
-
- U transform( LessEqualsDef annotationLessEquals );
-
- U transform( LessThanDef annotationLessThan );
-
- U transform( LogicalAndDef annotationLogicalAnd );
-
- U transform( LogicalOrDef annotationLogicalOr );
-
- U transform( MultiplyDef annotationMultiply );
-
- U transform( NotEqualsDef annotationNotEquals );
-
- U transform( OrDef annotationOr );
-
- U transform( RemainderDef annotationRemainder );
-
- U transform( ShiftLeftDef annotationShiftLeft );
-
- U transform( ShiftRightDef annotationShiftRight );
-
- U transform( SubtractDef annotationSubtract );
-
- U transform( UnsignedShiftRightDef annotationUnsignedShiftRight );
-
- U transform( CastDef annotationCast );
-
- U transform( ConstantDef annotationConstant );
-
- U transform( FieldRefDef annotationFieldRef );
-
- U transform( LogicalNotDef annotationLogicalNot );
-
- U transform( MinusSignDef annotationMinusSign );
-
- U transform( NotDef annotationNot );
-
- U transform( ParenExpressionDef annotationParenExpression );
-
- U transform( PlusSignDef annotationPlusSign );
-
- U transform( QueryDef annotationQuery );
-
- U transform( TypeRefDef annotationTypeRef );
-
- U transform( ElemValueListDef elemValueListDef );
-
- U transform( AssignmentDef assignmentDef );
-
- U transform( PostIncrementDef postIncrement );
-
- U transform( PostDecrementDef postDecrementDef );
-
- U transform( PreDecrementDef preDecrementDef );
-
- U transform( PreIncrementDef preIncrementDef );
-
- U transform( MethodInvocationDef methodInvocationDef );
-
- U transform( CreatorDef newCreator );
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/EqualsDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/EqualsDef.java
deleted file mode 100644
index 854abf2..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/EqualsDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class EqualsDef extends BinaryOperatorDef {
-
- public EqualsDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ExclusiveOrDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ExclusiveOrDef.java
deleted file mode 100644
index 71b5ad7..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ExclusiveOrDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ExclusiveOrDef extends BinaryOperatorDef {
-
- public ExclusiveOrDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ExpressionDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ExpressionDef.java
deleted file mode 100644
index 5d433e8..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ExpressionDef.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class ExpressionDef implements ElemValueDef
-{
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/FieldRefDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/FieldRefDef.java
deleted file mode 100644
index 11c722e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/FieldRefDef.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-public class FieldRefDef extends ExpressionDef {
-
- private final String name;
-
- public FieldRefDef( String name ) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterEqualsDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterEqualsDef.java
deleted file mode 100644
index b2a35a2..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterEqualsDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class GreaterEqualsDef extends BinaryOperatorDef {
-
- public GreaterEqualsDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterThanDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterThanDef.java
deleted file mode 100644
index f756672..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/GreaterThanDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class GreaterThanDef extends BinaryOperatorDef {
-
- public GreaterThanDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/LessEqualsDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/LessEqualsDef.java
deleted file mode 100644
index efa3c5e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/LessEqualsDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LessEqualsDef extends BinaryOperatorDef {
-
- public LessEqualsDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/LessThanDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/LessThanDef.java
deleted file mode 100644
index 154e428..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/LessThanDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LessThanDef extends BinaryOperatorDef {
-
- public LessThanDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalAndDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalAndDef.java
deleted file mode 100644
index 250f259..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalAndDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalAndDef extends BinaryOperatorDef {
-
- public LogicalAndDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalNotDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalNotDef.java
deleted file mode 100644
index ff1d5ff..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalNotDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalNotDef extends UnaryOperatorDef {
-
- public LogicalNotDef(ElemValueDef value) {
- super(value);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalOrDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalOrDef.java
deleted file mode 100644
index 7ef0330..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/LogicalOrDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LogicalOrDef extends BinaryOperatorDef {
-
- public LogicalOrDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/MethodInvocationDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/MethodInvocationDef.java
deleted file mode 100644
index e73047a..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/MethodInvocationDef.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public class MethodInvocationDef extends ExpressionDef
-{
- private String methodName;
-
- private List<ExpressionDef> arguments;
-
- public MethodInvocationDef( String methodName, List<ExpressionDef> arguments )
- {
- this.methodName = methodName;
- this.arguments = arguments;
- }
-
- public String getMethodName()
- {
- return methodName;
- }
-
- public List<ExpressionDef> getArguments()
- {
- return arguments;
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/MinusSignDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/MinusSignDef.java
deleted file mode 100644
index ae3e95b..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/MinusSignDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class MinusSignDef extends UnaryOperatorDef {
-
- public MinusSignDef(ElemValueDef value) {
- super(value);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/MultiplyDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/MultiplyDef.java
deleted file mode 100644
index f3cecde..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/MultiplyDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class MultiplyDef extends BinaryOperatorDef {
-
- public MultiplyDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/NotDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/NotDef.java
deleted file mode 100644
index 9cc9a4e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/NotDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class NotDef extends UnaryOperatorDef {
-
- public NotDef(ElemValueDef value) {
- super(value);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/NotEqualsDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/NotEqualsDef.java
deleted file mode 100644
index 35cbc11..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/NotEqualsDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class NotEqualsDef extends BinaryOperatorDef {
-
- public NotEqualsDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/OrDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/OrDef.java
deleted file mode 100644
index 0021322..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/OrDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class OrDef extends BinaryOperatorDef {
-
- public OrDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ParenExpressionDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ParenExpressionDef.java
deleted file mode 100644
index 161ff30..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ParenExpressionDef.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ParenExpressionDef extends ExpressionDef {
-
- private final ElemValueDef elemValueDef;
-
- public ParenExpressionDef(ElemValueDef value) {
- this.elemValueDef = value;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
- /**
- * @return the elemValueDef
- */
- public ElemValueDef getElemValueDef()
- {
- return elemValueDef;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/PlusSignDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/PlusSignDef.java
deleted file mode 100644
index 8579565..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/PlusSignDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PlusSignDef extends UnaryOperatorDef {
-
- public PlusSignDef(ElemValueDef value) {
- super(value);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/PostDecrementDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/PostDecrementDef.java
deleted file mode 100644
index e8bda02..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/PostDecrementDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PostDecrementDef extends UnaryOperatorDef
-{
- public PostDecrementDef( ElemValueDef elemValueDef )
- {
- super( elemValueDef );
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/PostIncrementDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/PostIncrementDef.java
deleted file mode 100644
index 3599d02..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/PostIncrementDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PostIncrementDef extends UnaryOperatorDef
-{
- public PostIncrementDef( ElemValueDef elemValueDef )
- {
- super( elemValueDef );
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/PreDecrementDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/PreDecrementDef.java
deleted file mode 100644
index 2d3ca66..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/PreDecrementDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PreDecrementDef extends UnaryOperatorDef
-{
- public PreDecrementDef( ElemValueDef elemValueDef )
- {
- super( elemValueDef );
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/PreIncrementDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/PreIncrementDef.java
deleted file mode 100644
index e109509..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/PreIncrementDef.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PreIncrementDef extends UnaryOperatorDef
-{
- public PreIncrementDef( ElemValueDef elemValueDef )
- {
- super( elemValueDef );
- }
-
- public <U> U transform( ElemValueTransformer<U> transformer )
- {
- return transformer.transform( this );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/QueryDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/QueryDef.java
deleted file mode 100644
index 1a9e4ce..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/QueryDef.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class QueryDef extends ExpressionDef {
-
- private final ElemValueDef cond;
- private final ElemValueDef trueExpr;
- private final ElemValueDef falseExpr;
-
- public QueryDef(ElemValueDef cond, ElemValueDef trueExpr,
- ElemValueDef falseExpr) {
- this.cond = cond;
- this.trueExpr = trueExpr;
- this.falseExpr = falseExpr;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
-
- /**
- * @return the cond
- */
- public ElemValueDef getCondition()
- {
- return cond;
- }
-
- /**
- * @return the trueExpr
- */
- public ElemValueDef getTrueExpression()
- {
- return trueExpr;
- }
-
- /**
- * @return the falseExpr
- */
- public ElemValueDef getFalseExpression()
- {
- return falseExpr;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/RemainderDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/RemainderDef.java
deleted file mode 100644
index 431d3e3..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/RemainderDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class RemainderDef extends BinaryOperatorDef {
-
- public RemainderDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftLeftDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftLeftDef.java
deleted file mode 100644
index 03d8f2f..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftLeftDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ShiftLeftDef extends BinaryOperatorDef {
-
- public ShiftLeftDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftRightDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftRightDef.java
deleted file mode 100644
index f83ab72..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/ShiftRightDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class ShiftRightDef extends BinaryOperatorDef {
-
- public ShiftRightDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/SubtractDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/SubtractDef.java
deleted file mode 100644
index 35b5800..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/SubtractDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class SubtractDef extends BinaryOperatorDef {
-
- public SubtractDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/TypeRefDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/TypeRefDef.java
deleted file mode 100644
index e3e4877..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/TypeRefDef.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-
-public class TypeRefDef extends ExpressionDef {
-
- private TypeDef typeDef;
-
- public TypeRefDef(TypeDef typeDef) {
- this.typeDef = typeDef;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
- public TypeDef getTypeDef()
- {
- return typeDef;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/UnaryOperatorDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/UnaryOperatorDef.java
deleted file mode 100644
index e79b0c7..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/UnaryOperatorDef.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public abstract class UnaryOperatorDef extends ExpressionDef {
-
- private final ElemValueDef elemValueDef;
-
- public UnaryOperatorDef(ElemValueDef elemValueDef) {
- this.elemValueDef = elemValueDef;
- }
-
- /**
- * @return the elemValueDef
- */
- public ElemValueDef getElemValueDef()
- {
- return elemValueDef;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/UnsignedShiftRightDef.java b/src/main/java/com/thoughtworks/qdox/parser/expression/UnsignedShiftRightDef.java
deleted file mode 100644
index c9a3a86..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/UnsignedShiftRightDef.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.thoughtworks.qdox.parser.expression;
-
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class UnsignedShiftRightDef extends BinaryOperatorDef {
-
- public UnsignedShiftRightDef(ElemValueDef lhs, ElemValueDef rhs) {
- super(lhs, rhs);
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/expression/package-info.java b/src/main/java/com/thoughtworks/qdox/parser/expression/package-info.java
deleted file mode 100644
index 5651945..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/expression/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes which make it possible to resolve expression values
- */
-package com.thoughtworks.qdox.parser.expression;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/impl/BinaryClassParser.java b/src/main/java/com/thoughtworks/qdox/parser/impl/BinaryClassParser.java
deleted file mode 100644
index f78b31e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/impl/BinaryClassParser.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package com.thoughtworks.qdox.parser.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.parser.structs.FieldDef;
-import com.thoughtworks.qdox.parser.structs.MethodDef;
-import com.thoughtworks.qdox.parser.structs.PackageDef;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-
-public class BinaryClassParser
-{
- private Class<?> declaringClazz;
-
- private Builder binaryBuilder;
-
- public BinaryClassParser( Class<?> declaringClazz, Builder modelBuilder )
- {
- this.declaringClazz = declaringClazz;
- this.binaryBuilder = modelBuilder;
- }
-
- public boolean parse()
- {
- try
- {
- String name = declaringClazz.getName();
-
- // Set the package name and class name
- String packageName = getPackageName( name );
- binaryBuilder.addPackage( new PackageDef( packageName ) );
-
- addClass( declaringClazz );
-
- return true;
- }
- catch ( NoClassDefFoundError e )
- {
- return false;
- }
- }
-
- private void addClass( Class<?> clazz )
- {
- ClassDef classDef = new ClassDef( clazz.getSimpleName() );
-
- // Set the extended class and interfaces.
- Class<?>[] interfaces = clazz.getInterfaces();
- if ( clazz.isInterface() )
- {
- // It's an interface
- classDef.setType( ClassDef.INTERFACE );
- for ( int i = 0; i < interfaces.length; i++ )
- {
- Class<?> anInterface = interfaces[i];
- classDef.getExtends().add( new TypeDef( anInterface.getName() ) );
- }
- }
- else
- {
- // It's a class
- for ( int i = 0; i < interfaces.length; i++ )
- {
- Class<?> anInterface = interfaces[i];
- classDef.getImplements().add( new TypeDef( anInterface.getName() ) );
- }
- Class<?> superclass = clazz.getSuperclass();
- if ( superclass != null )
- {
- classDef.getExtends().add( new TypeDef( superclass.getName() ) );
- }
- }
-
- addModifiers( classDef.getModifiers(), clazz.getModifiers() );
-
- binaryBuilder.beginClass( classDef );
-
- // add the constructors
- //
- // This also adds the default constructor if any which is different
- // to the source code as that does not create a default constructor
- // if no constructor exists.
- Constructor<?>[] constructors = clazz.getDeclaredConstructors();
- for ( int i = 0; i < constructors.length; i++ )
- {
- binaryBuilder.beginConstructor();
- MethodDef methodDef = createMethodDef( constructors[i] );
- binaryBuilder.endConstructor( methodDef );
- }
-
- // add the methods
- Method[] methods = clazz.getDeclaredMethods();
- for ( int i = 0; i < methods.length; i++ )
- {
- binaryBuilder.beginMethod();
- MethodDef methodDef = createMethodDef( methods[i] );
- binaryBuilder.endMethod( methodDef );
- }
-
- Field[] fields = clazz.getDeclaredFields();
- for ( int i = 0; i < fields.length; i++ )
- {
- addField( fields[i] );
- }
-
- Class<?>[] classes = clazz.getDeclaredClasses();
- for ( int i = 0; i < classes.length; i++ )
- {
- addClass( classes[i] );
- }
-
-
- binaryBuilder.endClass();
- }
-
- private static void addModifiers( Set<String> set, int modifier )
- {
- String modifierString = Modifier.toString( modifier );
- for ( StringTokenizer stringTokenizer = new StringTokenizer( modifierString ); stringTokenizer.hasMoreTokens(); )
- {
- set.add( stringTokenizer.nextToken() );
- }
- }
-
- private void addField( Field field )
- {
- FieldDef fieldDef = new FieldDef( field.getName() );
- Class<?> fieldType = field.getType();
- fieldDef.setType( getTypeDef( fieldType ) );
- fieldDef.setDimensions( getDimension( fieldType ) );
- fieldDef.setEnumConstant( field.isEnumConstant() );
- addModifiers( fieldDef.getModifiers(), field.getModifiers() );
- binaryBuilder.beginField( fieldDef );
- binaryBuilder.endField();
- }
-
- private MethodDef createMethodDef( Member member )
- {
- MethodDef methodDef = new MethodDef();
- // The name of constructors are qualified. Need to strip it.
- // This will work for regular methods too, since -1 + 1 = 0
- int lastDot = member.getName().lastIndexOf( '.' );
- methodDef.setName( member.getName().substring( lastDot + 1 ) );
-
- addModifiers( methodDef.getModifiers(), member.getModifiers() );
- Class<?>[] exceptions;
- Class<?>[] parameterTypes;
- if ( member instanceof Method )
- {
- methodDef.setConstructor( false );
-
- // For some stupid reason, these methods are not defined in Member,
- // but in both Method and Construcotr.
- exceptions = ( (Method) member ).getExceptionTypes();
- parameterTypes = ( (Method) member ).getParameterTypes();
-
- Class<?> returnType = ( (Method) member ).getReturnType();
- methodDef.setReturnType( getTypeDef( returnType ) );
- methodDef.setDimensions( getDimension( returnType ) );
-
- }
- else
- {
- methodDef.setConstructor( true );
-
- exceptions = ( (Constructor<?>) member ).getExceptionTypes();
- parameterTypes = ( (Constructor<?>) member ).getParameterTypes();
- }
- for ( int j = 0; j < exceptions.length; j++ )
- {
- Class<?> exception = exceptions[j];
- methodDef.getExceptions().add( getTypeDef( exception ) );
- }
- for ( int j = 0; j < parameterTypes.length; j++ )
- {
- FieldDef param = new FieldDef( "p" + j );
- Class<?> parameterType = parameterTypes[j];
- param.setType( getTypeDef( parameterType ) );
- param.setDimensions( getDimension( parameterType ) );
- binaryBuilder.addParameter( param );
- }
- return methodDef;
- }
-
- private static int getDimension( Class<?> c )
- {
- return c.getName().lastIndexOf( '[' ) + 1;
- }
-
- private static String getTypeName( Class<?> c )
- {
- return c.getComponentType() != null ? c.getComponentType().getName() : c.getName();
- }
-
- private static TypeDef getTypeDef( Class<?> c )
- {
- return new TypeDef( getTypeName( c ) );
- }
-
- private String getPackageName( String fullClassName )
- {
- int lastDot = fullClassName.lastIndexOf( '.' );
- return lastDot == -1 ? "" : fullClassName.substring( 0, lastDot );
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/impl/package-info.java b/src/main/java/com/thoughtworks/qdox/parser/impl/package-info.java
deleted file mode 100644
index ace7aa4..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/impl/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides the implementations of the Lexers and Parsers
- */
-package com.thoughtworks.qdox.parser.impl;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/package-info.java b/src/main/java/com/thoughtworks/qdox/parser/package-info.java
deleted file mode 100644
index 54394ad..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides interfaces and exceptions for both Lexers and Parsers
- */
-package com.thoughtworks.qdox.parser;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java
deleted file mode 100644
index 6e9593f..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/AnnoDef.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import com.thoughtworks.qdox.parser.expression.ElemValueTransformer;
-import com.thoughtworks.qdox.parser.expression.ElemValueDef;
-
-public class AnnoDef extends LocatedDef implements ElemValueDef
-{
- private TypeDef typeDef;
- private final Map<String, ElemValueDef> args = new LinkedHashMap<String, ElemValueDef>();
-
- public AnnoDef( TypeDef typeDef )
- {
- this.typeDef = typeDef;
- }
-
- public AnnoDef getValue() {
- return this;
- }
-
- public <U> U transform(ElemValueTransformer<U> transformer) {
- return transformer.transform(this);
- }
-
- public TypeDef getTypeDef()
- {
- return typeDef;
- }
-
- public Map<String, ElemValueDef> getArgs()
- {
- return args;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/ClassDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/ClassDef.java
deleted file mode 100644
index 423f888..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/ClassDef.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-public class ClassDef extends LocatedDef {
-
- public static final String CLASS = "class";
- public static final String INTERFACE = "interface";
- public static final String ENUM = "enum";
- public static final String ANNOTATION_TYPE = "@interface";
-
- private String name = "";
- private Set<String> modifiers = new LinkedHashSet<String>();
- private List<TypeVariableDef> typeParams = new LinkedList<TypeVariableDef>();
- private Set<TypeDef> extendz = new LinkedHashSet<TypeDef>();
- private Set<TypeDef> implementz = new LinkedHashSet<TypeDef>();
- private String type = CLASS;
-
- public ClassDef()
- {
- }
-
- public ClassDef( String name )
- {
- this.name = name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName( String name )
- {
- this.name = name;
- }
-
- /**
- * @return the name
- */
- public String getName()
- {
- return name;
- }
-
- @Override
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- result.append( getModifiers() );
- result.append( ' ' );
- result.append( getType() );
- result.append( ' ' );
- result.append( getName() );
- // typeParams
- result.append( " extends " );
- result.append( getExtends() );
- result.append( " implements " );
- result.append( getImplements() );
- return result.toString();
- }
-
- public void setModifiers( Set<String> modifiers )
- {
- this.modifiers = modifiers;
- }
-
- public Set<String> getModifiers()
- {
- return modifiers;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setImplements( Set<TypeDef> implementz )
- {
- this.implementz = implementz;
- }
-
- public Set<TypeDef> getImplements()
- {
- return implementz;
- }
-
- public void setExtends( Set<TypeDef> extendz )
- {
- this.extendz = extendz;
- }
-
- public Set<TypeDef> getExtends()
- {
- return extendz;
- }
-
- public void setTypeParameters( List<TypeVariableDef> typeParams )
- {
- this.typeParams = typeParams;
- }
-
- public List<TypeVariableDef> getTypeParameters()
- {
- return typeParams;
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/FieldDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/FieldDef.java
deleted file mode 100644
index 0a1a70a..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/FieldDef.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * Used for both fields and parameters
- */
-public class FieldDef
- extends LocatedDef
-{
-
- private String name;
-
- private TypeDef type;
-
- private Set<String> modifiers = new LinkedHashSet<String>();
-
- private int dimensions;
-
- private boolean isVarArgs;
-
- private boolean isEnumConstant;
-
- private String body;
-
- public FieldDef()
- {
- }
-
- public FieldDef( String name )
- {
- this.name = name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName( String name )
- {
- this.name = name;
- }
-
- /**
- * @return the name
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * @param type the type to set
- */
- public void setType( TypeDef type )
- {
- this.type = type;
- }
-
- /**
- * @return the type
- */
- public TypeDef getType()
- {
- return type;
- }
-
- /**
- * @param dimensions the dimensions to set
- */
- public void setDimensions( int dimensions )
- {
- this.dimensions = dimensions;
- }
-
- /**
- * @return the dimensions
- */
- public int getDimensions()
- {
- return dimensions;
- }
-
- /**
- * @param isVarArgs the isVarArgs to set
- */
- public void setVarArgs( boolean isVarArgs )
- {
- this.isVarArgs = isVarArgs;
- }
-
- /**
- * @return the isVarArgs
- */
- public boolean isVarArgs()
- {
- return isVarArgs;
- }
-
- /**
- * @param body the body to set
- */
- public void setBody( String body )
- {
- this.body = body;
- }
-
- /**
- * @return the body
- */
- public String getBody()
- {
- return body;
- }
-
- /**
- * @param modifiers the modifiers to set
- */
- public void setModifiers( Set<String> modifiers )
- {
- this.modifiers = modifiers;
- }
-
- /**
- * @return the modifiers
- */
- public Set<String> getModifiers()
- {
- return modifiers;
- }
-
- /**
- * @return <code>true</code> if this field is an enum constant, otherwise <code>false</code>
- */
- public boolean isEnumConstant()
- {
- return isEnumConstant;
- }
-
- /**
- * @param isEnumConstant value to specify if this field is an enum constant or not
- */
- public void setEnumConstant( boolean isEnumConstant )
- {
- this.isEnumConstant = isEnumConstant;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/InitDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/InitDef.java
deleted file mode 100644
index 21f690e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/InitDef.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public class InitDef extends LocatedDef
-{
-
- private boolean staticInitializer;
-
- private String blockContent;
-
- public InitDef()
- {
- }
-
- public InitDef( String blockContent, boolean staticInitializer )
- {
- this.staticInitializer = staticInitializer;
- this.blockContent = blockContent;
- }
-
- public boolean isStatic()
- {
- return staticInitializer;
- }
-
- public void setStatic( boolean staticInitializer )
- {
- this.staticInitializer = staticInitializer;
- }
-
- public String getBlockContent()
- {
- return blockContent;
- }
-
- public void setBlockContent( String block )
- {
- this.blockContent = block;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java
deleted file mode 100644
index 047d54e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/LocatedDef.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class LocatedDef {
-
- private int lineNumber;
- private int columnNumber;
-
- public void setLineNumber( int lineNumber )
- {
- this.lineNumber = lineNumber;
- }
- public int getLineNumber()
- {
- return lineNumber;
- }
- public void setColumnNumber( int columnNumber )
- {
- this.columnNumber = columnNumber;
- }
- public int getColumnNumber()
- {
- return columnNumber;
- }
-
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/MethodDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/MethodDef.java
deleted file mode 100644
index fe71df8..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/MethodDef.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-public class MethodDef extends LocatedDef {
-
- private String name = "";
- private List<TypeVariableDef> typeParams;
- private TypeDef returnType;
- private Set<String> modifiers = new LinkedHashSet<String>();
- private Set<TypeDef> exceptions = new LinkedHashSet<TypeDef>();
- private boolean constructor = false;
- private int dimensions;
- private String body;
-
- @Override
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- result.append( getModifiers() );
- result.append( ' ' );
- result.append( ( getReturnType() != null ? getReturnType().toString() : "" ) );
- for ( int i = 0; i < getDimensions(); i++ )
- {
- result.append( "[]" );
- }
- result.append( ' ' );
- result.append( getName() );
- result.append( '(' );
- result.append( getTypeParams() );
- result.append( ')' );
- result.append( " throws " );
- result.append( getExceptions() );
- result.append( getBody() );
- return result.toString();
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setReturnType(TypeDef returnType) {
- this.returnType = returnType;
- }
-
- public TypeDef getReturnType() {
- return returnType;
- }
-
- public void setModifiers(Set<String> modifiers) {
- this.modifiers = modifiers;
- }
-
- public Set<String> getModifiers() {
- return modifiers;
- }
-
- public void setConstructor(boolean constructor) {
- this.constructor = constructor;
- }
-
- public boolean isConstructor() {
- return constructor;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setDimensions(int dimensions) {
- this.dimensions = dimensions;
- }
-
- public int getDimensions() {
- return dimensions;
- }
-
- public void setExceptions(Set<TypeDef> exceptions) {
- this.exceptions = exceptions;
- }
-
- public Set<TypeDef> getExceptions() {
- return exceptions;
- }
-
- public void setTypeParams( List<TypeVariableDef> typeParams )
- {
- this.typeParams = typeParams;
- }
-
- public List<TypeVariableDef> getTypeParams()
- {
- return typeParams;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/PackageDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/PackageDef.java
deleted file mode 100644
index 9cbadf8..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/PackageDef.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class PackageDef extends LocatedDef {
-
- private String name;
-
- public PackageDef(String name) {
- this.name = name;
- }
-
- public PackageDef(String name, int lineNumber) {
- this.name = name;
- this.setLineNumber( lineNumber );
- }
-
- /**
- * @return the name
- */
- public String getName()
- {
- return name;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/TagDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/TagDef.java
deleted file mode 100644
index 5d58fc2..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/TagDef.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class TagDef
- extends LocatedDef
-{
-
- private String name;
- private String text;
-
- public TagDef( String name, String text, int lineNumber )
- {
- this.name = name;
- this.text = text;
- this.setLineNumber( lineNumber );
- }
-
- public TagDef( String name, String text )
- {
- this( name, text, -1 );
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getText()
- {
- return text;
- }
-
- @Override
- public String toString()
- {
- StringBuilder result = new StringBuilder();
- result.append( '@' );
- result.append( name );
- result.append( " => \"" );
- result.append( text );
- result.append( "\" @ line " );
- result.append( getLineNumber() );
- return result.toString();
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/TypeDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/TypeDef.java
deleted file mode 100644
index 38d8222..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/TypeDef.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public class TypeDef {
-
- private String name;
- private int dimensions;
- private List<TypeDef> actualArgumentTypes;
-
- public TypeDef(String name, int dimensions) {
- this.name = name;
- this.dimensions = dimensions;
- }
-
- public TypeDef(String name) {
- this(name, 0);
- }
-
- public String getName()
- {
- return name;
- }
-
- public int getDimensions()
- {
- return dimensions;
- }
-
- public void setDimensions( int dimensions )
- {
- this.dimensions = dimensions;
- }
-
- @Override
- public boolean equals(Object obj) {
- TypeDef typeDef = (TypeDef) obj;
- return typeDef.name.equals(name)
- && typeDef.dimensions == dimensions
- && (typeDef.getActualArgumentTypes() != null ? typeDef.getActualArgumentTypes().equals(getActualArgumentTypes()): getActualArgumentTypes() == null);
- }
-
- @Override
- public int hashCode() {
- return name.hashCode() +
- dimensions + (getActualArgumentTypes() == null ? 0 : getActualArgumentTypes().hashCode());
- }
-
- /**
- * @param actualArgumentTypes the actualArgumentTypes to set
- */
- public void setActualArgumentTypes( List<TypeDef> actualArgumentTypes )
- {
- this.actualArgumentTypes = actualArgumentTypes;
- }
-
- /**
- * @return the actualArgumentTypes
- */
- public List<TypeDef> getActualArgumentTypes()
- {
- return actualArgumentTypes;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java
deleted file mode 100644
index e03d923..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/TypeVariableDef.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-public class TypeVariableDef {
-
- private String name;
- private List<TypeDef> bounds;
-
- public TypeVariableDef(String name) {
- this.name = name;
- }
-
- public TypeVariableDef(String name, List<TypeDef> bounds) {
- super();
- this.name = name;
- this.bounds = bounds;
- }
-
- public void setBounds( List<TypeDef> bounds )
- {
- this.bounds = bounds;
- }
-
- public String getName()
- {
- return name;
- }
-
- public List<TypeDef> getBounds()
- {
- return bounds;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java b/src/main/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java
deleted file mode 100644
index 5d6afb8..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/WildcardTypeDef.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.thoughtworks.qdox.parser.structs;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * WildcardTypeDef must be a subclass of TypeDef, so it can be used in other classes.
- * But here are only 2 fields interesting: typeDef and wildcardExpressionType
- * typeDef itself can be generic, so it must be resolvable
- * wildcardExpressionType is super or extends
- *
- *
- * @author Robert Scholte
- *
- */
-public class WildcardTypeDef extends TypeDef {
-
- private TypeDef typeDef;
- private String wildcardExpressionType; //super or extends
-
- public WildcardTypeDef() {
- super("?");
- }
-
- public WildcardTypeDef(TypeDef typeDef, String wildcardExpressionType) {
- super( typeDef.getName(), typeDef.getDimensions() );
- this.typeDef = typeDef;
- this.wildcardExpressionType = wildcardExpressionType;
- }
-
- public TypeDef getTypeDef() {
- return typeDef;
- }
-
- public String getWildcardExpressionType() {
- return wildcardExpressionType;
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/parser/structs/package-info.java b/src/main/java/com/thoughtworks/qdox/parser/structs/package-info.java
deleted file mode 100644
index 328a52e..0000000
--- a/src/main/java/com/thoughtworks/qdox/parser/structs/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Provides simple models to be constructed by the parser.
- * With these objects the ModeLbuilder constructs a complete Java Model
- */
-package com.thoughtworks.qdox.parser.structs;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/tools/package-info.java b/src/main/java/com/thoughtworks/qdox/tools/package-info.java
deleted file mode 100644
index f02351c..0000000
--- a/src/main/java/com/thoughtworks/qdox/tools/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- *
- */
-package com.thoughtworks.qdox.tools;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/writer/ModelWriter.java b/src/main/java/com/thoughtworks/qdox/writer/ModelWriter.java
deleted file mode 100644
index 7480264..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/ModelWriter.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package com.thoughtworks.qdox.writer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaInitializer;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-
-/**
- * Interface for a custom ModelWriter.
- *
- * QDox doesn't keep any formatting information of the original source file (if it's there).
- * With a ModelWriter you can specify the way elements look if you write them to any output.
- *
- *
- * @author Robert Scholte
- * @since 2.0
- */
-public interface ModelWriter
-{
- /**
- * Write the complete source file
- *
- * A standard source writer should write:
- * <ul>
- * <li>the package</li>
- * <li>the imports</li>
- * <li>the classes</li>
- * </ul>
- *
- * @param src the source
- * @return itself
- */
- ModelWriter writeSource( JavaSource src );
-
- /**
- * Write the java package
- *
- * A standard package writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the package signature</li>
- * </ul>
- *
- * @param pkg the package
- * @return itself
- */
- ModelWriter writePackage( JavaPackage pkg );
-
- /**
- * Write the java class
- *
- * A standard class writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the class signature, containing:
- * <ul>
- * <li>the fields</li>
- * <li>the constructors</li>
- * <li>the methods</li>
- * </ul>
- * </li>
- * </ul>
- *
- * @param cls the class
- * @return itself
- */
- ModelWriter writeClass( JavaClass cls );
-
- /**
- * Write the java field
- *
- * A standard field writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the field signature</li>
- * </ul>
- *
- * @param fld the field
- * @return itself
- */
- ModelWriter writeField( JavaField fld );
-
- /**
- * Write the java annotation
- *
- * A standard annotation writer should write:
- * <ul>
- * <li>the annotation signature</li>
- * </ul>
- *
- * @param ann the annotation
- * @return itself
- */
- ModelWriter writeAnnotation( JavaAnnotation ann );
-
- /**
- * Write the java method
- *
- * A standard method writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the method signature, containing:
- * <ul>
- * <li>the parameters</li>
- * </ul>
- * </li>
- * </ul>
- *
- * @param mth the method
- * @return itself
- */
- ModelWriter writeMethod( JavaMethod mth );
-
- /**
- * Write the java parameter
- *
- * A standard parameter writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the parameter signature</li>
- * </ul>
- *
- * @param prm the parameter
- * @return itself
- */
- ModelWriter writeParameter( JavaParameter prm );
-
- /**
- * Write the java constructor.
- *
- * A standard constructor writer should write:
- * <ul>
- * <li>the javadoc</li>
- * <li>the annotations</li>
- * <li>the constructor signature, containing:
- * <ul>
- * <li>the parameters</li>
- * </ul>
- * </li>
- * </ul>
- *
- * @param cns the constructor
- * @return itself
- */
- ModelWriter writeConstructor( JavaConstructor cns );
-
- /**
- * Write the initializer.
- *
- * @param init the initializer
- * @return itself
- */
- ModelWriter writeInitializer( JavaInitializer init );
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/writer/ModelWriterFactory.java b/src/main/java/com/thoughtworks/qdox/writer/ModelWriterFactory.java
deleted file mode 100644
index c4d5912..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/ModelWriterFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.thoughtworks.qdox.writer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Factory for constructing a new {@link ModelWriter}
- */
-public interface ModelWriterFactory
-{
- /**
- * When called, a new instance must be returned.
- *
- * @return a new ModelWriter
- */
- ModelWriter newInstance();
-}
diff --git a/src/main/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriter.java b/src/main/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriter.java
deleted file mode 100644
index 0fbc1f9..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriter.java
+++ /dev/null
@@ -1,476 +0,0 @@
-package com.thoughtworks.qdox.writer.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaInitializer;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.Expression;
-import com.thoughtworks.qdox.writer.ModelWriter;
-
-public class DefaultModelWriter
- implements ModelWriter
-{
- private IndentBuffer buffer = new IndentBuffer();
-
- /**
- * All information is written to this buffer.
- * When extending this class you should write to this buffer
- *
- * @return the buffer
- */
- protected final IndentBuffer getBuffer()
- {
- return buffer;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeSource( JavaSource source )
- {
- // package statement
- writePackage( source.getPackage() );
-
- // import statement
- for ( String imprt : source.getImports() )
- {
- buffer.write( "import " );
- buffer.write( imprt );
- buffer.write( ';' );
- buffer.newline();
- }
- if ( source.getImports().size() > 0 )
- {
- buffer.newline();
- }
-
- // classes
- for ( ListIterator<JavaClass> iter = source.getClasses().listIterator(); iter.hasNext(); )
- {
- JavaClass cls = iter.next();
- writeClass( cls );
- if ( iter.hasNext() )
- {
- buffer.newline();
- }
- }
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writePackage( JavaPackage pckg )
- {
- if ( pckg != null )
- {
- commentHeader( pckg );
- buffer.write( "package " );
- buffer.write( pckg.getName() );
- buffer.write( ';' );
- buffer.newline();
- buffer.newline();
- }
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeClass( JavaClass cls )
- {
- commentHeader( cls );
-
- writeAccessibilityModifier( cls.getModifiers() );
- writeNonAccessibilityModifiers( cls.getModifiers() );
-
- buffer.write( cls.isEnum() ? "enum " : cls.isInterface() ? "interface " : cls.isAnnotation() ? "@interface "
- : "class " );
- buffer.write( cls.getName() );
-
- // subclass
- if ( cls.getSuperClass() != null )
- {
- String className = cls.getSuperClass().getFullyQualifiedName();
- if ( !"java.lang.Object".equals( className ) && !"java.lang.Enum".equals( className ) )
- {
- buffer.write( " extends " );
- buffer.write( cls.getSuperClass().getGenericCanonicalName() );
- }
- }
-
- // implements
- if ( cls.getImplements().size() > 0 )
- {
- buffer.write( cls.isInterface() ? " extends " : " implements " );
-
- for ( ListIterator<JavaType> iter = cls.getImplements().listIterator(); iter.hasNext(); )
- {
- buffer.write( iter.next().getGenericCanonicalName() );
- if ( iter.hasNext() )
- {
- buffer.write( ", " );
- }
- }
- }
-
- return writeClassBody( cls );
- }
-
- private ModelWriter writeClassBody( JavaClass cls )
- {
- buffer.write( " {" );
- buffer.newline();
- buffer.indent();
-
- // fields
- for ( JavaField javaField : cls.getFields() )
- {
- buffer.newline();
- writeField( javaField );
- }
-
- // constructors
- for ( JavaConstructor javaConstructor : cls.getConstructors() )
- {
- buffer.newline();
- writeConstructor( javaConstructor );
- }
-
- // methods
- for ( JavaMethod javaMethod : cls.getMethods() )
- {
- buffer.newline();
- writeMethod( javaMethod );
- }
-
- // inner-classes
- for ( JavaClass innerCls : cls.getNestedClasses() )
- {
- buffer.newline();
- writeClass( innerCls );
- }
-
- buffer.deindent();
- buffer.newline();
- buffer.write( '}' );
- buffer.newline();
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeInitializer( JavaInitializer init )
- {
- if ( init.isStatic() )
- {
- buffer.write( "static " );
- }
- buffer.write( '{' );
- buffer.newline();
- buffer.indent();
-
- buffer.write( init.getBlockContent() );
-
- buffer.deindent();
- buffer.newline();
- buffer.write( '}' );
- buffer.newline();
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeField( JavaField field )
- {
- commentHeader( field );
-
- writeAllModifiers( field.getModifiers() );
- if ( !field.isEnumConstant() )
- {
- buffer.write( field.getType().getGenericCanonicalName() );
- buffer.write( ' ' );
- }
- buffer.write( field.getName() );
-
- if ( field.isEnumConstant() )
- {
- if ( field.getEnumConstantArguments() != null && !field.getEnumConstantArguments().isEmpty() )
- {
- buffer.write( "( " );
- for( Iterator<Expression> iter = field.getEnumConstantArguments().listIterator(); iter.hasNext(); )
- {
- buffer.write( iter.next().getParameterValue().toString() );
- if( iter.hasNext() )
- {
- buffer.write( ", " );
- }
- }
- buffer.write( " )" );
- }
- if ( field.getEnumConstantClass() != null )
- {
- writeClassBody( field.getEnumConstantClass() );
- }
- }
- else
- {
- if ( field.getInitializationExpression() != null && field.getInitializationExpression().length() > 0 )
- {
- {
- buffer.write( " = " );
- }
- buffer.write( field.getInitializationExpression() );
- }
- }
- buffer.write( ';' );
- buffer.newline();
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeConstructor( JavaConstructor constructor )
- {
- commentHeader( constructor );
- writeAllModifiers( constructor.getModifiers() );
-
- buffer.write( constructor.getName() );
- buffer.write( '(' );
- for ( ListIterator<JavaParameter> iter = constructor.getParameters().listIterator(); iter.hasNext(); )
- {
- writeParameter( iter.next() );
- if ( iter.hasNext() )
- {
- buffer.write( ", " );
- }
- }
- buffer.write( ')' );
-
- if ( constructor.getExceptions().size() > 0 )
- {
- buffer.write( " throws " );
- for ( Iterator<JavaClass> excIter = constructor.getExceptions().iterator(); excIter.hasNext(); )
- {
- buffer.write( excIter.next().getGenericCanonicalName() );
- if ( excIter.hasNext() )
- {
- buffer.write( ", " );
- }
- }
- }
-
- buffer.write( " {" );
- buffer.newline();
- if ( constructor.getSourceCode() != null )
- {
- buffer.write( constructor.getSourceCode() );
- }
- buffer.write( '}' );
- buffer.newline();
-
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeMethod( JavaMethod method )
- {
- commentHeader( method );
- writeAccessibilityModifier( method.getModifiers() );
- writeNonAccessibilityModifiers( method.getModifiers() );
- buffer.write( method.getReturnType().getGenericCanonicalName() );
- buffer.write( ' ' );
- buffer.write( method.getName() );
- buffer.write( '(' );
- for ( ListIterator<JavaParameter> iter = method.getParameters().listIterator(); iter.hasNext(); )
- {
- writeParameter( iter.next() );
- if ( iter.hasNext() )
- {
- buffer.write( ", " );
- }
-
- }
- buffer.write( ')' );
- if ( method.getExceptions().size() > 0 )
- {
- buffer.write( " throws " );
- for ( Iterator<JavaClass> excIter = method.getExceptions().iterator(); excIter.hasNext(); )
- {
- buffer.write( excIter.next().getGenericCanonicalName() );
- if ( excIter.hasNext() )
- {
- buffer.write( ", " );
- }
- }
- }
- if ( method.getSourceCode() != null && method.getSourceCode().length() > 0 )
- {
- buffer.write( " {" );
- buffer.newline();
- buffer.write( method.getSourceCode() );
- buffer.write( '}' );
- buffer.newline();
- }
- else
- {
- buffer.write( ';' );
- buffer.newline();
- }
- return this;
- }
-
- private void writeNonAccessibilityModifiers( List<String> modifiers )
- {
- for ( String modifier : modifiers )
- {
- if ( !modifier.startsWith( "p" ) )
- {
- buffer.write( modifier );
- buffer.write( ' ' );
- }
- }
- }
-
- private void writeAccessibilityModifier( List<String> modifiers )
- {
- for ( String modifier : modifiers )
- {
- if ( modifier.startsWith( "p" ) )
- {
- buffer.write( modifier );
- buffer.write( ' ' );
- }
- }
- }
-
- private void writeAllModifiers( List<String> modifiers )
- {
- for ( String modifier : modifiers )
- {
- buffer.write( modifier );
- buffer.write( ' ' );
- }
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeAnnotation( JavaAnnotation annotation )
- {
- buffer.write( '@' );
- buffer.write( annotation.getType().getGenericCanonicalName() );
- if ( !annotation.getPropertyMap().isEmpty() )
- {
- buffer.indent();
- buffer.write( '(' );
- Iterator<Map.Entry<String, AnnotationValue>> iterator = annotation.getPropertyMap().entrySet().iterator();
- while ( iterator.hasNext() )
- {
- Map.Entry<String, AnnotationValue> entry = iterator.next();
- buffer.write( entry.getKey() );
- buffer.write( '=' );
- buffer.write( entry.getValue().toString() );
- if ( iterator.hasNext() )
- {
- buffer.write( ',' );
- buffer.newline();
- }
- }
- buffer.write( ')' );
- buffer.deindent();
- }
- buffer.newline();
- return this;
- }
-
- /** {@inheritDoc} */
- public ModelWriter writeParameter( JavaParameter parameter )
- {
- commentHeader( parameter );
- buffer.write( parameter.getGenericCanonicalName() );
- if ( parameter.isVarArgs() )
- {
- buffer.write( "..." );
- }
- buffer.write( ' ' );
- buffer.write( parameter.getName() );
- return this;
- }
-
- protected void commentHeader( JavaAnnotatedElement entity )
- {
- if ( entity.getComment() != null || ( entity.getTags().size() > 0 ) )
- {
- buffer.write( "/**" );
- buffer.newline();
-
- if ( entity.getComment() != null && entity.getComment().length() > 0 )
- {
- buffer.write( " * " );
-
- buffer.write( entity.getComment().replaceAll( "\n", "\n * " ) );
-
- buffer.newline();
- }
-
- if ( entity.getTags().size() > 0 )
- {
- if ( entity.getComment() != null && entity.getComment().length() > 0 )
- {
- buffer.write( " *" );
- buffer.newline();
- }
- for ( DocletTag docletTag : entity.getTags() )
- {
- buffer.write( " * @" );
- buffer.write( docletTag.getName() );
- if ( docletTag.getValue().length() > 0 )
- {
- buffer.write( ' ' );
- buffer.write( docletTag.getValue() );
- }
- buffer.newline();
- }
- }
-
- buffer.write( " */" );
- buffer.newline();
- }
- if ( entity.getAnnotations() != null )
- {
- for ( JavaAnnotation annotation : entity.getAnnotations() )
- {
- writeAnnotation( annotation );
- }
- }
- }
-
- @Override
- public String toString()
- {
- return buffer.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/writer/impl/IndentBuffer.java b/src/main/java/com/thoughtworks/qdox/writer/impl/IndentBuffer.java
deleted file mode 100644
index 71d6573..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/impl/IndentBuffer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.thoughtworks.qdox.writer.impl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-public class IndentBuffer
-{
-
- private String eol = "\n";
- private String indentation = "\t";
- private StringBuffer buffer = new StringBuffer();
-
- private int depth = 0;
-
- private boolean newLine;
-
- public void setEol( String eol )
- {
- this.eol = eol;
- }
-
- public void setIndentation( String indentation )
- {
- this.indentation = indentation;
- }
-
- public void write( String s )
- {
- checkNewLine();
- buffer.append( s );
- }
-
- public void write( char s )
- {
- checkNewLine();
- buffer.append( s );
- }
-
- public void newline()
- {
- buffer.append( eol );
- newLine = true;
- }
-
- public void indent()
- {
- depth++;
- }
-
- public void deindent()
- {
- depth--;
- }
-
- public String toString()
- {
- return buffer.toString();
- }
-
- private void checkNewLine()
- {
- if ( newLine )
- {
- for ( int i = 0; i < depth; i++ )
- {
- buffer.append( indentation );
- }
- newLine = false;
- }
- }
-}
diff --git a/src/main/java/com/thoughtworks/qdox/writer/impl/package-info.java b/src/main/java/com/thoughtworks/qdox/writer/impl/package-info.java
deleted file mode 100644
index de96e7a..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/impl/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides the default implementation of classes to write Java model elements in any style.
- */
-package com.thoughtworks.qdox.writer.impl;
\ No newline at end of file
diff --git a/src/main/java/com/thoughtworks/qdox/writer/package-info.java b/src/main/java/com/thoughtworks/qdox/writer/package-info.java
deleted file mode 100644
index 1ad65db..0000000
--- a/src/main/java/com/thoughtworks/qdox/writer/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes to write Java model elements in any style
- */
-package com.thoughtworks.qdox.writer;
\ No newline at end of file
diff --git a/src/site/apt/migrationplan.apt.vm b/src/site/apt/migrationplan.apt.vm
deleted file mode 100644
index 5adf06e..0000000
--- a/src/site/apt/migrationplan.apt.vm
+++ /dev/null
@@ -1,70 +0,0 @@
-Migrating to QDox 2.0
-
- QDox 2.0 is *<<not>>* 100% backwards compatible with previous versions.
- We've decided to move from java1.4 to java5, since support for java1.4 has ended ages ago.
- Nowadays most applications are moving to java5 and so should QDox.
-
- Here are the required steps to take to move to QDox 2.x
-
- * Replace <<com.thoughtworks.qdox.JavaDocBuilder>> with <<com.thoughtworks.qdox.JavaDocBuilder>>
-
- * Refactor every javamodel array to generic <<List>> or <<Collection>> objects, for example: <<JavaClass[]>> will become <<List\<JavaClass\>>>
-
- * Redefined getValue(). This would normally return the FQN, but now it'll return the value as used in the code(when available).
-
- * Redefined getFullyQualifiedName(). This used to return the classname, but according to the specs it should also return the array dimensions.
- To get the classname, use <<getComponentType()>>.
-
- []
-
- Below is a table which maps the non-abstract classes to the refactored or suggested interface or class. The classes which are not mentioned have been removed or are implementations which should be called by their interfaces.
-
-*------------------------------------------------------*-----------------------------------------------------------------------*
-|| QDox-1.x || QDox-2.x |
-*------------------------------------------------------+-----------------------------------------------------------------------+
-| c.t.q.JavaDocBuilder\ | c.t.q.JavaProjectBuilder\ |
-| <c.t.q.JavaDocBuilder.ErrorHandler>\ | <c.t.q.library.ErrorHandler>\ |
-*------------------------------------------------------+-----------------------------------------------------------------------+
-| c.t.q.model.Annotation\ | <c.t.q.model.JavaAnnotation>\ |
-| c.t.q.model.ClassLibrary\ | <c.t.q.library.ClassLibrary> and <c.t.q.library.ClassLibraryBuilder>\ |
-| <c.t.q.model.Member>\ | <c.t.q.model.JavaMember>\ |
-| c.t.q.model.ModelBuilder\ | <c.t.q.model.Builder> and c.t.q.builder.impl.ModelBuilder\ |
-| c.t.q.model.Type\ | <c.t.q.model.JavaType>\ |
-| c.t.q.model.TypeVariable\ | <c.t.q.model.JavaTypeVariable>\ |
-| c.t.q.model.WildcardType\ | <c.t.q.model.JavaWildcardType>\ |
-*------------------------------------------------------+-----------------------------------------------------------------------+
-| c.t.q.model.annotation.AnnotationAdd\ | c.t.q.model.expression.Add\ |
-| c.t.q.model.annotation.AnnotationAnd\ | c.t.q.model.expression.And\ |
-| c.t.q.model.annotation.AnnotationBinaryOperator\ | c.t.q.model.expression.BinaryOperator\ |
-| c.t.q.model.annotation.AnnotationCast\ | c.t.q.model.expression.Cast\ |
-| c.t.q.model.annotation.AnnotationConstant\ | c.t.q.model.expression.Constant\ |
-| c.t.q.model.annotation.AnnotationDivide\ | c.t.q.model.expression.Divide\ |
-| c.t.q.model.annotation.AnnotationEquals\ | c.t.q.model.expression.Equals\ |
-| c.t.q.model.annotation.AnnotationExclusiveOr\ | c.t.q.model.expression.ExclusiveOr\ |
-| c.t.q.model.annotation.AnnotationFieldRef\ | c.t.q.model.expression.FieldRef\ |
-| c.t.q.model.annotation.AnnotationGreaterEquals\ | c.t.q.model.expression.GreaterEquals\ |
-| c.t.q.model.annotation.AnnotationGreaterThan\ | c.t.q.model.expression.GreaterThan\ |
-| c.t.q.model.annotation.AnnotationLessEquals\ | c.t.q.model.expression.LessEquals\ |
-| c.t.q.model.annotation.AnnotationLessThan\ | c.t.q.model.expression.LessThan\ |
-| c.t.q.model.annotation.AnnotationLogicalAnd\ | c.t.q.model.expression.LogicalAnd\ |
-| c.t.q.model.annotation.AnnotationLogicalNot\ | c.t.q.model.expression.LogicalNot\ |
-| c.t.q.model.annotation.AnnotationLogicalOr\ | c.t.q.model.expression.LogicalOr\ |
-| c.t.q.model.annotation.AnnotationMinusSign\ | c.t.q.model.expression.MinusSign\ |
-| c.t.q.model.annotation.AnnotationMultiply\ | c.t.q.model.expression.Multiply\ |
-| c.t.q.model.annotation.AnnotationNot\ | c.t.q.model.expression.Not\ |
-| c.t.q.model.annotation.AnnotationNotEquals\ | c.t.q.model.expression.NotEquals\ |
-| c.t.q.model.annotation.AnnotationOr\ | c.t.q.model.expression.Or\ |
-| c.t.q.model.annotation.AnnotationParenExpression\ | c.t.q.model.expression.ParenExpression\ |
-| c.t.q.model.annotation.AnnotationPlusSign\ | c.t.q.model.expression.PlusSign\ |
-| c.t.q.model.annotation.AnnotationQuery\ | c.t.q.model.expression.Query\ |
-| c.t.q.model.annotation.AnnotationRemainder\ | c.t.q.model.expression.Remainder\ |
-| c.t.q.model.annotation.AnnotationShiftLeft\ | c.t.q.model.expression.ShiftLeft\ |
-| c.t.q.model.annotation.AnnotationShiftRight\ | c.t.q.model.expression.ShiftRight\ |
-| c.t.q.model.annotation.AnnotationSubtract\ | c.t.q.model.expression.Subtract\ |
-| c.t.q.model.annotation.AnnotationTypeRef\ | c.t.q.model.expression.TypeRef\ |
-| c.t.q.model.annotation.AnnotationUnaryOperator\ | c.t.q.model.expression.UnaryOperator\ |
-| c.t.q.model.annotation.AnnotationUnsignedShiftRight\ | c.t.q.model.expression.UnsignedShiftRight\ |
-| c.t.q.model.annotation.AnnotationValueList\ | c.t.q.model.expression.AnnotationValueList\ |
-| c.t.q.model.annotation.EvaluatingVisitor\ | c.t.q.model.expression.ExpressionVisitor\ |
-| c.t.q.model.annotation.RecursiveAnnotationVisitor\ | <c.t.q.parser.expression.TransformerDef\<U\>>\ |
-*------------------------------------------------------+-----------------------------------------------------------------------+
diff --git a/src/site/content/changes.html b/src/site/content/changes.html
new file mode 100644
index 0000000..b3cdec2
--- /dev/null
+++ b/src/site/content/changes.html
@@ -0,0 +1,15 @@
+<html>
+ <head>
+ <title>Jira Change History</title>
+ </head>
+ <body>
+
+ <p>Full details can be found in Jira's
+ <a href="http://jira.codehaus.org/browse/QDOX?report=com.atlassian.jira.plugin.system.project:roadmap-panel">Roadmap</a> and
+ <a href="http://jira.codehaus.org/browse/QDOX?report=com.atlassian.jira.plugin.system.project:changelog-panel">Change Log</a>.
+ </p>
+
+ <p>
+
+ </body>
+</html>
diff --git a/src/site/content/download.html b/src/site/content/download.html
new file mode 100644
index 0000000..832810b
--- /dev/null
+++ b/src/site/content/download.html
@@ -0,0 +1,21 @@
+<html>
+ <head>
+ <title>Download</title>
+ </head>
+ <body>
+ <p>
+ Latest stable release - QDox ${project.rel.org.thoughtworks.qdox:qdox}:
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}.jar">binary jar</a> |
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-sources.jar">sources jar</a> |
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-javadoc.jar">javadoc jar</a> |
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.tar.bz2">project tar.bz2</a> |
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.tar.gz">project tar.gz</a> |
+ <a href="http://repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.zip">project zip</a>
+ </p>
+ <p>
+ The latest snapshot - QDox ${project.dev.org.thoughtworks.qdox:qdox}:
+ <a href="http://snapshots.repository.codehaus.org/com/thoughtworks/qdox/qdox/${project.dev.org.thoughtworks.qdox:qdox}">snapshots directory</a>.
+ </p>
+ </body>
+
+</html>
diff --git a/src/site/content/faq.html b/src/site/content/faq.html
new file mode 100644
index 0000000..097b55b
--- /dev/null
+++ b/src/site/content/faq.html
@@ -0,0 +1,49 @@
+<html>
+ <head>
+ <title>Frequently Asked Questions</title>
+ </head>
+ <body>
+
+ <ul style="list-style-type:decimal;">
+ <li><a href="#Where_is_the_array_information_stored">Where is the array information stored?</a></li>
+ <li><a href="#What_s_the_object_type_of_an_interface">What's the objecttype of an interface?</a></li>
+ <li><a href="#Can_I_have_full_control_over_the_classloader">Can I have full control over the classloader?</a></li>
+ </ul>
+
+ <a name="Where_is_the_array_information_stored"></a><h2>Where is the array information stored?</h2>
+ <p>The <code><a href="apidocs/com/thoughtworks/qdox/model/Type.html">Type</a></code> class stores array information
+ in it. If the array is multidimensional, the dimension depth can be accessed.</p>
+
+ <a name="What_s_the_object_type_of_an_interface"></a><h2>What's the object type of an interface?</h2>
+
+ <p>The <code><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html">JavaClass</a></code> method is used to
+ represent both classes and interfaces.
+ The <code><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isInterface()">isInterface()</a></code>
+ method allows you to distinguish between the two.</p>
+
+ <p>When using a class, the <a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getSuperClass()">getSuperClass()</a>
+ return which class is extended. If this has not been defined in the input source code, <code>java.lang.Object</code> is
+ returned. When using an interface, this method ALWAYS returns null.</p>
+
+ <p>When using a class, the <a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getImplements()">getImplements()</a>
+ returns an array of the interfaces implemented by the class. If none are implemented, an empty array is returned. When
+ using an interface, this returns an array of interfaces the current interface EXTENDS.
+ </p>
+
+ <a name="Can_I_have_full_control_over_the_classloader"></a><h2>Can I have full control over the classloader?</h2>
+ <p>
+ I some cases QDox is used to generate classes for another project with it's own dependencies. This could result in class-collission.
+ By default the JavadocBuilder will contain the classloader(s) of the current project, but by defining your own classLibrary you can have the required control.
+
+ <code><pre>
+ /* new ClassLibrary() will give you an empty classLoader
+ * Big chance you want at least the system classloader.
+ */
+ ClassLibrary classLibrary = new ClassLibrary( ClassLoader.getSystemClassLoader() );
+ JavaDocBuilder builder = new JavaDocBuilder(classLibrary);
+
+ </pre></code>
+ </p>
+ </body>
+
+</html>
diff --git a/src/site/xhtml/index.xhtml b/src/site/content/index.html
similarity index 100%
rename from src/site/xhtml/index.xhtml
rename to src/site/content/index.html
diff --git a/src/site/xhtml/license.xhtml b/src/site/content/license.html
similarity index 100%
rename from src/site/xhtml/license.xhtml
rename to src/site/content/license.html
diff --git a/src/site/xhtml/model.xhtml b/src/site/content/model.html
similarity index 63%
rename from src/site/xhtml/model.xhtml
rename to src/site/content/model.html
index cd33d64..c50563e 100644
--- a/src/site/xhtml/model.xhtml
+++ b/src/site/content/model.html
@@ -4,13 +4,13 @@
</head>
<body>
- <p>After the source code has been <a href="usage.html">parsed</a>, the content of the files can be navigated using a simple to use and intuitive object model.</p>
+ <p>After the source code has been <a href="usage.html">parsed</a>, the content of the files can be navigated using a simple to use and intuitive object model.</p>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html">JavaSource</a></h2>
- <p>Represents a complete .java file. This contains a collection of classes.</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html">JavaSource</a></h2>
+ <p>Represents a complete .java file. This contains a collection of classes.</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
package com.blah.foo;
import java.awt.*;
@@ -29,16 +29,18 @@
<h3>Example Code</h3>
<div class="Source Java"><pre>
- JavaProjectBuilder builder = new JavaProjectBuilder();
- JavaSource src = builder.addSource(myReader);
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(myReader);
+
+ JavaSource src = builder.getSources[](0);
JavaPackage pkg = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getPackage()">getPackage</a>();
- List<String> imports = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getImports()">getImports</a>(); // {"java.awt.*",
+ String[] imports = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getImports()">getImports</a>(); // {"java.awt.*",
// "java.util.List"}
- JavaClass class1 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>().get(0);
- JavaClass class2 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>().get(1);
- JavaClass interface1 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>().get(2);
+ JavaClass class1 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>()[0];
+ JavaClass class2 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>()[1];
+ JavaClass interface1 = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getClasses()">getClasses</a>()[2];
</pre></div>
<h2><a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html">JavaPackage</a></h2>
<p>Represents the package of the class.</p>
@@ -50,27 +52,29 @@
public class BarClass {
...
}
- </pre></div>
+ </pre></div>
- <h3>Example Code</h3>
- <div class="Source Java"><pre>
- JavaProjectBuilder builder = new JavaProjectBuilder();
- JavaSource src = builder.addSource(myReader);
+ <h3>Example Code</h3>
+ <div class="Source Java"><pre>
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(myReader);
+
+ JavaSource src = builder.getSources[](0);
JavaPackage pkg = src.<a href="apidocs/com/thoughtworks/qdox/model/JavaSource.html#getPackage()">getPackage</a>();
- Collection<JavaClass> classes = pkg.<a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html#getClasses()">getClasses</a>(); // BarClass
+ JavaClass[] classes = pkg.<a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html#getClasses()">getClasses</a>()[0]; // BarClass
String name = pkg.<a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html#getName()">getName</a>(); // "com.blah.foo"
String toString = pkg.<a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html#toString()">toString</a>(); // "package com.blah.foo" conform javaAPI
JavaPackage parent = pkg.<a href="apidocs/com/thoughtworks/qdox/model/JavaPackage.html#getParentPackage()">getParentPackage</a>(); //
- </pre></div>
+ </pre></div>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html">JavaClass</a></h2>
- <p>Represents a class or interface. This contains doclet tags, fields and methods. Information about the class
- definition is available, such as which classes are extended, which interfaces implemented and modifiers.</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html">JavaClass</a></h2>
+ <p>Represents a class or interface. This contains doclet tags, fields and methods. Information about the class
+ definition is available, such as which classes are extended, which interfaces implemented and modifiers.</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
package com.blah.foo;
import java.io.*;
@@ -88,27 +92,26 @@
private int getNumber() { ... }
}
- </pre></div>
+ </pre></div>
- <h3>Example Code</h3>
- <div class="Source Java"><pre>
- JavaProjectBuilder builder = new JavaProjectBuilder();
+ <h3>Example Code</h3>
+ <div class="Source Java"><pre>
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(myReader);
JavaClass cls = builder.getClassByName("com.blah.foo.MyClass");
String pkg = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getPackage()">getPackage</a>(); // "com.blah.foo"
String name = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getName()">getName</a>(); // "MyClass"
- String fullName = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getCanonicalName()">getCanonicalName</a>(); // "com.blah.foo.MyClass";
- String canonicalName = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getFullyQualifiedName()">getFullyQualifiedName</a>(); // "com.blah.foo.MyClass";
+ String fullName = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getFullyQualifiedName()">getFullyQualifiedName</a>(); // "com.blah.foo.MyClass";
boolean isInterface = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isInterface()">isInterface</a>(); // false
boolean isPublic = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isPublic()">isPublic</a>(); // true
boolean isAbstract = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isAbstract()">isAbstract</a>(); // true
boolean isFinal = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isFinal()">isFinal</a>(); // false
- JavaType superClass = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getSuperClass()">getSuperClass</a>(); // "com.base.SubClass";
- List<JavaType> imps = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getImplements()">getImplements</a>(); // {"java.io.Serializable",
+ Type superClass = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getSuperClass()">getSuperClass</a>(); // "com.base.SubClass";
+ Type[] imps = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getImplements()">getImplements</a>(); // {"java.io.Serializable",
// "com.custom.CustomInterface"}
String author = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getTagsByName(java.lang.String)">getTagsByName</a>("author").getValue(); // "joe"
@@ -118,13 +121,14 @@
JavaMethod getNumber = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getMethods()">getMethods</a>()[1];
JavaSource javaSource = cls.<a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getParentSource()">getParentSource</a>();
- </pre></div>
+ </pre></div>
+ </p>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaField.html">JavaField</a></h2>
- <p>Represents a field in a class. This has doclet tags, a name and a type.</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaField.html">JavaField</a></h2>
+ <p>Represents a field in a class. This has doclet tags, a name and a type.</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
import java.util.Date;
public class MyClass {
@@ -142,28 +146,28 @@
<div class="Source Java"><pre>
JavaField e = cls.getFields()[0];
- JavaType eType = e.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>(); // "java.lang.String";
+ Type eType = e.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>(); // "java.lang.String";
String eName = e.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getName()">getName</a>(); // "email";
DocletTag eTag = e.<a href="apidocs/com/thoughtworks/qdox/model/AbstractJavaEntity.html#getTagByName(java.lang.String)">getTagsByName</a>("magic"); // @magic
- boolean eArray = e.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // false;
+ boolean eArray = e.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // false;
JavaField d = cls.getFields()[1];
- JavaType dType = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>(); // "java.util.Date";
+ Type dType = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>(); // "java.util.Date";
String dName = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getName()">getName</a>(); // "dates";
DocletTag dTag = d.<a href="apidocs/com/thoughtworks/qdox/model/AbstractJavaEntity.html#getTagByName(java.lang.String)">getTagsByName</a>("magic"); // null
- boolean dArray = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // true;
- int dDimensions= d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 2;
+ boolean dArray = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // true;
+ int dDimensions= d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 2;
boolean dStatic= d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#isStatic()">isStatic</a>(); // true;
JavaClass javaClass = d.<a href="apidocs/com/thoughtworks/qdox/model/JavaField.html#getParentClass()">getParentClass</a>();
</pre></div>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html">JavaMethod</a></h2>
- <p>Represents a method in a class. This has doclet tags, a name, return type, parameters and exceptions.</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html">JavaMethod</a></h2>
+ <p>Represents a method in a class. This has doclet tags, a name, return type, parameters and exceptions.</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
import java.util.Date;
import java.io.*;
@@ -179,36 +183,36 @@
}
}
- </pre></div>
+ </pre></div>
- <h3>Example Code</h3>
- <div class="Source Java"><pre>
+ <h3>Example Code</h3>
+ <div class="Source Java"><pre>
JavaMethod m = cls.getMethods()[0];
String mName = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getName()">getName</a>(); // "doStuff";
- JavaType mReturns = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getReturns()">getReturns</a>(); // "java.util.Date";
- boolean mArray = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getReturns()">getReturns</a>().<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // true
+ Type mReturns = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getReturns()">getReturns</a>(); // "java.util.Date";
+ boolean mArray = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getReturns()">getReturns</a>().<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // true
boolean mStatic = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#isStatic()">isStatic</a>(); // true
boolean mPublic = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#isPublic()">isPublic</a>(); // true
String doc = m.getTagByName("returns").getValue();
// "Lots of dates"
- List<JavaType> exceptions = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getExceptions()">getExceptions</a>();
+ Type[] exceptions = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getExceptions()">getExceptions</a>();
// {"java.lang.RuntimeException", "java.io.IOException"}
JavaParameter numberParam = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getParameters()">getParameters</a>()[0];
JavaParameter stuffParam = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getParameters()">getParameters</a>()[1];
JavaClass javaClass = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getParentClass()">getParentClass</a>();
- </pre></div>
+ </pre></div>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html">JavaParameter</a></h2>
- <p>Represents a parameter passed to a method. This has a name and a type.</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html">JavaParameter</a></h2>
+ <p>Represents a parameter passed to a method. This has a name and a type.</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
public class MyClass {
public void stuff(int n, Object[] objects) {
@@ -216,32 +220,29 @@
}
}
- </pre></div>
-
- <h3>Example Code</h3>
- <div class="Source Java"><pre>
+ </pre></div>
+ <h3>Example Code</h3>
+ <div class="Source Java"><pre>
JavaMethod m = cls.getMethods()[0];
JavaParameter n = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getParameters()">getParameters</a>()[0];
String nName = n.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getName()">getName</a>(); // "n"
- JavaType nType = n.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>(); // "int";
+ Type nType = n.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>(); // "int";
JavaParameter o = m.<a href="apidocs/com/thoughtworks/qdox/model/JavaMethod.html#getParameters()">getParameters</a>()[1];
String oName = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getName()">getName</a>(); // "objects"
- JavaType oType = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>(); // "java.lang.Object";
- boolean oArray = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // true
+ Type oType = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>(); // "java.lang.Object";
+ boolean oArray = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getType()">getType</a>().<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // true
JavaMethod javaMethod = o.<a href="apidocs/com/thoughtworks/qdox/model/JavaParameter.html#getParentMethod()">getParentMethod</a>();
- </pre></div>
+ </pre></div>
- <h2><a href="apidocs/com/thoughtworks/qdox/model/JavaType.html">JavaType</a></h2>
- <p>Represents a specific instance of a class used by another class (such as return value, superclass, etc).
- The value represents the name of the class. Array dimensions are also available. Since 1.8 it's also possible to get the generic value of the Type</p>
+ <h2><a href="apidocs/com/thoughtworks/qdox/model/Type.html">Type</a></h2>
+ <p>Represents a specific instance of a class used by another class (such as return value, superclass, etc).
+ The value represents the name of the class. Array dimensions are also available. Since 1.8 it's also possible to get the generic value of the Type</p>
- <h3>Example Input</h3>
- <div class="Source Java"><pre>
- <![CDATA[
-
+ <h3>Example Input</h3>
+ <div class="Source Java"><pre>
import java.util.*;
public class MyClass {
@@ -252,38 +253,37 @@
}
}
- ]]>
- </pre></div>
+ </pre></div>
- <h3>Example Code</h3>
- <div class="Source Java"><pre>
+ <h3>Example Code</h3>
+ <div class="Source Java"><pre>
JavaMethod m = cls.getMethods()[0];
- JavaType returns = m.getReturns();
+ Type returns = m.getReturns();
returns.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getValue()">getValue</a>(); // "void"
- returns.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // false
- returns.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 0
-
- JavaType n = m.getParameters()[0].getType();
- n.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getValue()">getValue</a>(); // "int"
- n.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // false
- n.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 0
-
- JavaType objects = m.getParameters()[1].getType();
- objects.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getValue()">getValue</a>(); // "java.lang.Object"
- objects.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // true
- objects.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 1
-
- JavaType dates = m.getParameters()[2].getType();
- dates.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getValue()">getValue</a>(); // "java.util.Date"
- dates.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // true
- dates.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 2
-
- JavaType stringList = m.getParameters()[3].getType();
- stringList.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getValue()">getValue</a>(); // "java.util.List"
- stringList.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getGenericValue()">getGenericValue</a>(); // <![CDATA["java.util.List<java.lang.String>"]]>
- stringList.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#isArray()">isArray</a>(); // false
- stringList.<a href="apidocs/com/thoughtworks/qdox/model/JavaType.html#getDimensions()">getDimensions</a>(); // 0
+ returns.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // false
+ returns.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 0
+
+ Type n = m.getParameters()[0].getType();
+ n.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getValue()">getValue</a>(); // "int"
+ n.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // false
+ n.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 0
+
+ Type objects = m.getParameters()[1].getType();
+ objects.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getValue()">getValue</a>(); // "java.lang.Object"
+ objects.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // true
+ objects.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 1
+
+ Type dates = m.getParameters()[2].getType();
+ dates.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getValue()">getValue</a>(); // "java.util.Date"
+ dates.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // true
+ dates.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 2
+
+ Type stringList = m.getParameters()[3].getType();
+ stringList.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getValue()">getValue</a>(); // "java.util.List"
+ stringList.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getGenericValue()">getGenericValue</a>(); // "java.util.List<java.lang.String>"
+ stringList.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#isArray()">isArray</a>(); // false
+ stringList.<a href="apidocs/com/thoughtworks/qdox/model/Type.html#getDimensions()">getDimensions</a>(); // 0
</pre></div>
<h2><a href="apidocs/com/thoughtworks/qdox/model/DocletTag.html">DocletTag</a></h2>
diff --git a/src/site/xhtml/upgrade.xhtml b/src/site/content/upgrade.html
similarity index 99%
rename from src/site/xhtml/upgrade.xhtml
rename to src/site/content/upgrade.html
index 5d48c3a..7c5bbc1 100644
--- a/src/site/xhtml/upgrade.xhtml
+++ b/src/site/content/upgrade.html
@@ -21,7 +21,7 @@
Some methods require extra attention, because there's not an exact match. Watch out for differences between Type and JavaClass.
<table>
<tr><th>Java API</th><th>QDOX</th></tr>
- <tr class="b"><td>((java.lang.Method) aMethod).getReturnsType().toString()</td><td>((com.thoughtworks.qdox.model.JavaMethod) aMethod).getReturns().toString()</td></tr>
+ <tr class="b"><td>((java.lang.Method) aMethod).getReturnsType().toString()</td><td>((com.thoughtworks.qdox.model.JavaMethod) aMethod).getReturns().toString()</td>
</table>
</p>
<p>com.thoughtworks.qdox.model.Type.getValue() will return the typeName for usage in the code. The new method com.thoughtworks.qdox.model.Type.getFullQualifiedName() will return the FQN as defined by the java specs.
diff --git a/src/site/xhtml/usage.xhtml b/src/site/content/usage.html
similarity index 64%
rename from src/site/xhtml/usage.xhtml
rename to src/site/content/usage.html
index 3af403d..713261d 100644
--- a/src/site/xhtml/usage.xhtml
+++ b/src/site/content/usage.html
@@ -6,21 +6,21 @@
<h2>Entry Point</h2>
- <p><code><a href="apidocs/com/thoughtworks/qdox/JavaProjectBuilder.html">JavaProjectBuilder</a></code> is the entry point to
+ <p><code><a href="apidocs/com/thoughtworks/qdox/JavaDocBuilder.html">JavaDocBuilder</a></code> is the entry point to
QDox. It is responsible for parsing source code, resolving imports and storing
the data.</p>
<p>To create it, all you need to do is call the default constructor.</p>
<div class="Source Java"><pre>
-JavaProjectBuilder builder = new JavaProjectBuilder();
+JavaDocBuilder builder = new JavaDocBuilder();
</pre></div>
<h2>Reading Source Files</h2>
<p>Java source code can then be added to the
- <code><a href="apidocs/com/thoughtworks/qdox/JavaProjectBuilder.html">JavaProjectBuilder</a></code>.
+ <code><a href="apidocs/com/thoughtworks/qdox/JavaDocBuilder.html">JavaDocBuilder</a></code>.
Source can either be read one file at a time (using a java.io.Reader) or an entire source tree
can be added recursively.</p>
@@ -38,7 +38,7 @@ builder.addSourceTree(new File("mysrcdir"));
<h2>Resolving Class Names</h2>
<p>In order to resolve classes that have been imported using a wildcard (e.g. <code>import java.util.*;</code>), the
- <code><a href="apidocs/com/thoughtworks/qdox/library/ClassLibrary.html">ClassLibrary</a></code>
+ <code><a href="apidocs/com/thoughtworks/qdox/model/ClassLibrary.html">ClassLibrary</a></code>
must be aware of other classes used in the project.</p>
<p>ClassLibrary has 4 ways to resolve classes:</p>
@@ -50,25 +50,28 @@ builder.addSourceTree(new File("mysrcdir"));
<li>By looking at additional ClassLoaders specified at runtime.</li>
</ul></p>
- <p>All sources and sourcetrees added to the JavaProjectBuilder will be parsed. This is often much more than required.
- To increase efficiency use the ClassLibrary to add sourcefolders. Consider these files as lazy parsed sources.</p>
+ <p>All sources and sourcetrees added to the JavaDocBuilder will be parsed. This is often much more than required.
+ To increase efficiency use the ClassLibrary to add sourcefolders. Consider these files as lazy parsed sources.
- <p>The current classpath is automatically set by JavaProjectBuilder. In most cases this shall be sufficient, however in some
+ <p>The current classpath is automaticly set by JavaDocBuilder. In most cases this shall be sufficient, however in some
situations you may want resolve the full classes in external libraries.</p>
+ <p>To resolve classes from different ClassLoaders (e.g. 3rd party Jar files), the
+ <code>addClassLoader()</code> method must be called on the ClassLibrary.</p>
+
<div class="Source Java"><pre>
// Get the ClassLibrary
-JavaProjectBuilder builder = new JavaProjectBuilder();
+ClassLibrary lib = builder.getClassLibrary();
// Add a sourcefolder;
-builder.addSourceFolder( new File( "src/main/java" ) );
-builder.addSourceFolder( new File( "target/generated-sources/foobar" ) );
+lib.addSourceFolder( new File( "src/main/java" ) );
+lib.addSourceFolder( new File( "target/generated-sources/foobar" ) );
// Add a custom ClassLoader
-builder.addClassLoader( myCustomClassLoader );
+lib.addClassLoader( myCustomClassLoader );
// Ant example : add the <classpath> element's contents
-builder.addClassLoader( new AntClassLoader( getProject(), classpath ) );
+lib.addClassLoader( new AntClassLoader( getProject(), classpath ) );
</pre></div>
<p>It is important that additional ClassLoaders are added before any source files are parsed.</p>
diff --git a/src/site/content/website.xml b/src/site/content/website.xml
new file mode 100644
index 0000000..d1d5230
--- /dev/null
+++ b/src/site/content/website.xml
@@ -0,0 +1,34 @@
+<sitemap>
+ <section>
+ <name>Software</name>
+ <page>index.html</page>
+ <page>faq.html</page>
+ </section>
+ <section>
+ <name>Evaluating QDox</name>
+ <page>download.html</page>
+ <page>upgrade.html</page>
+ <page>whouses.html</page>
+ </section>
+ <section>
+ <name>Project Information</name>
+ <page>dependencies.html</page>
+ <page>issue-tracking.html</page>
+ <page>mail-lists.html</page>
+ <page>license.html</page>
+ <page>project-summary.html</page>
+ <page>team-list.html</page>
+ <page>source-repository.html</page>
+ </section>
+ <section>
+ <name>Project Reports</name>
+ <page>changes-report.html</page>
+ <page>changes.html</page>
+ <link title="JavaDoc">apidocs/index.html</link>
+ </section>
+ <section>
+ <name>Using QDox</name>
+ <page>usage.html</page>
+ <page>model.html</page>
+ </section>
+</sitemap>
diff --git a/src/site/xhtml/whouses.xhtml b/src/site/content/whouses.html
similarity index 99%
rename from src/site/xhtml/whouses.xhtml
rename to src/site/content/whouses.html
index 353dbe4..19fb6a3 100644
--- a/src/site/xhtml/whouses.xhtml
+++ b/src/site/content/whouses.html
@@ -84,7 +84,7 @@
The Javadoc Plugin uses the Javadoc tool to generate javadocs for the specified project.
</td>
<td>
- When developers write code, they could forget to create (or update) the Javadoc comments. The <fix> and <test-fix>
+ When developers write code, they could forget to create (or update) the Javadoc comments. The <fix> and <test-fix>
goals are interactive goals to fix the actual Javadoc comments.
</td>
</tr>
diff --git a/src/site/fml/faq.fml b/src/site/fml/faq.fml
deleted file mode 100644
index d20a362..0000000
--- a/src/site/fml/faq.fml
+++ /dev/null
@@ -1,60 +0,0 @@
-<faqs xmlns="http://maven.apache.org/FML/1.0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/FML/1.0.1 http://maven.apache.org/xsd/fml-1.0.1.xsd"
- title="Frequently Asked Questions">
-
- <part id="general">
- <title>General</title>
- <faq id="Whats_the_object_type_of_an_interface">
- <question>What's the objecttype of an interface?</question>
- <answer>
- <p>The <code><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html">JavaClass</a></code> method is used to
- represent both classes and interfaces.
- The <code><a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#isInterface()">isInterface()</a></code>
- method allows you to distinguish between the two.</p>
-
- <p>When using a class, the <a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getSuperClass()">getSuperClass()</a>
- return which class is extended. If this has not been defined in the input source code, <code>java.lang.Object</code> is
- returned. When using an interface, this method ALWAYS returns null.</p>
-
- <p>When using a class, the <a href="apidocs/com/thoughtworks/qdox/model/JavaClass.html#getImplements()">getImplements()</a>
- returns an array of the interfaces implemented by the class. If none are implemented, an empty array is returned. When
- using an interface, this returns an array of interfaces the current interface EXTENDS.
- </p>
- </answer>
- </faq>
-
- <faq id="Can_I_have_full_control_over_the_classloader">
- <question>Can I have full control over the classloader?</question>
- <answer>
- <p>
- I some cases QDox is used to generate classes for another project with it's own dependencies. This could result in class-collision.
- By default the JavadocBuilder will contain the classloader(s) of the current project, but by defining your own classLibrary you can have the required control.
-
- <source>
- /* new ClassLibrary() will give you an empty classLoader
- * Big chance you want at least the system classloader.
- */
- ClassLibraryBuilder libraryBuilder = new SortedClassLibraryBuilder(); //or OrderedClassLibraryBuilder()
- libraryBuilder.addClassLoader( ClassLoader.getSystemClassLoader() );
- JavaProjectBuilder builder = new JavaProjectBuilder( libraryBuilder );
- </source>
- </p>
- </answer>
- </faq>
-
- <faq id="ArrayIndexOutOfBoundsException_500">
- <question>I'm getting an ArrayIndexOutOfBoundsException: 500. What to do?</question>
- <answer>
- <p>During the parsing of java files the Parser needs to remember states, which are kept in a stack.
- Due to recursive calls the stack can become very large.
- By default the size of this this stack is 500 and it can only be set during <em>compile-time</em> of QDox.
- Normally 500 per sourcefile will do, but in very, very rare cases this might be too little.
- The only way to increase this number is by rebuilding it.
- Download the <a href="./download.html">sources</a> and build it like <code>mvn install -Dqdox.javaparser.stack=750</code> if you want to change it to 750.
- </p>
- </answer>
- </faq>
- </part>
-
-</faqs>
\ No newline at end of file
diff --git a/src/site/resources/images/blue2white.jpg b/src/site/resources/blue2white.jpg
similarity index 100%
rename from src/site/resources/images/blue2white.jpg
rename to src/site/resources/blue2white.jpg
diff --git a/src/site/resources/images/breadcrumbs.jpg b/src/site/resources/breadcrumbs.jpg
similarity index 100%
rename from src/site/resources/images/breadcrumbs.jpg
rename to src/site/resources/breadcrumbs.jpg
diff --git a/src/site/resources/images/arrow_blue_collapsed.png b/src/site/resources/images/arrow_blue_collapsed.png
deleted file mode 100644
index dccb763..0000000
Binary files a/src/site/resources/images/arrow_blue_collapsed.png and /dev/null differ
diff --git a/src/site/resources/images/arrow_blue_expanded.png b/src/site/resources/images/arrow_blue_expanded.png
deleted file mode 100644
index d9be07c..0000000
Binary files a/src/site/resources/images/arrow_blue_expanded.png and /dev/null differ
diff --git a/src/site/resources/images/logo.gif b/src/site/resources/logo.gif
similarity index 100%
rename from src/site/resources/images/logo.gif
rename to src/site/resources/logo.gif
diff --git a/src/site/resources/css/style.css b/src/site/resources/style.css
similarity index 85%
rename from src/site/resources/css/style.css
rename to src/site/resources/style.css
index e54b600..723ccb8 100644
--- a/src/site/resources/css/style.css
+++ b/src/site/resources/style.css
@@ -1,435 +1,417 @@
-/*---------------------------------------------------------------------------
- * Two- and three-column layout
- */
-
-#banner {
- margin 5px;
-}
-
-#left {
- position: absolute;
- z-index: 2;
- left: 8px;
- width: 184px;
- top: 125px;
- bottom: 8px;
- margin: 0px;
- padding: 0px;
-}
-
-#right {
- position: absolute;
- z-index: 1;
- right: 8px;
- width: 184px;
- top: 125px;
- bottom: 8px;
- margin: 0px;
- padding: 0px;
-}
-
-.Content3Column {
- position: absolute;
- top: 125px;
- bottom: 8px;
- left: 208px;
- right: 216px;
-}
-
-.Content2Column {
- position: absolute;
- top: 125px;
- bottom: 8px;
- left: 208px;
- right: 16px;
-}
-
-#center {
- z-index: 3;
- margin: 0px;
- border: none;
- padding-bottom: 8px;
-}
-
-/*---------------------------------------------------------------------------
- * Bradcrumbs
- */
-.xleft, #bannerLeft img {
- float:left;
-}
-.xright, #bannerRight {
- float:right;
-}
-div.clear {
- clear:both;
- visibility:hidden;
-}
-#breadcrumbs {
- background-image:url(../images/breadcrumbs.jpg);
- height:13px;
- padding:5px 10px 14px 20px;
-}
-#breadcrumbs {
- font-size:x-small;
- margin:0;
-}
-
-/*---------------------------------------------------------------------------
- * Default element styles
- */
-
-body {
- padding: 0px;
- margin: 0px;
- border: 0px;
-
- font-family: helvetica, arial, sans-serif;
- font-size: 12px;
-
- background-color: white;
- color: black;
-}
-
-h1, h2, h3, h4, h5, h6 {
- margin: 0px;
- border: 0px;
- padding: 0px;
- font-weight: normal;
-}
-
-a:link { color: #9cf; }
-a:active { color: red; }
-a:hover { color: red; }
-a:visited { color: black; }
-
-iframe {
- width:100%;
- height: 800px;
- border: 0px;
-}
-
-img {
- border: 0px;
- padding: 0px;
- margin: 0px;
-}
-
-p {
- border: 0px;
- padding: 0px;
- margin: 0px;
- margin-bottom: 10px;
-}
-
-blockquote {
- margin-bottom: 10px;
-}
-
-table {
- width:100%;
- padding-bottom: 6px;
-}
-td {
- font-size: 12px;
- padding: 2px;
-}
-
-th {
- font-size: 12px;
- font-weight: bold;
- white-space: nowrap;
- padding: 2px;
-}
-
-th.Row {
- text-align: left;
- vertical-align: top;
-}
-
-ul, ol {
- border: 0px;
- padding: 0px;
- margin-top: 0px;
- margin-bottom: 12px;
- margin-left: 20px;
-}
-tr.a {
- background-color: #7EB2E4;
-}
-tr.b {
- background-color: #BDD7F0;
-}
-
-
-/*---------------------------------------------------------------------------
- * Page banner
- */
-
-#banner {
- margin: 5px;
- border: 0px;
- padding: 0px;
- background-color: white;
- color: #06c;
- vertical-align: bottom;
-}
-
-#banner a { text-decoration: none; }
-#banner a:visited { color: #9cf; }
-#banner a:hover { color: red; }
-#banner a:active { color: red; }
-
-#versions {
- position: absolute;
- width: auto;
- right: 0px;
- top: 0px;
- margin: 8px;
- font-weight: normal;
-}
-
-/*---------------------------------------------------------------------------
- * Page content
- */
-
-#content {
- margin: 0px;
- background-color: white;
- color: black;
- height: 100%;
-}
-
-#content h1 {
- width: 100%;
- font-size: 18px;
- background-color: #06c;
- color: white;
- padding: 2px;
- padding-left: 6px;
- margin-top: 24px;
- margin-bottom: 12px;
-}
-
-#content .FirstChild { /* IE doesn't understand first-child pseudoelement */
- margin-top: 0px;
-}
-
-#content a { text-decoration: underline; }
-#content a:link { color: #06c; }
-#content a:visited { color: #06c; }
-#content a:active { color: red; }
-#content a:hover { color: red; }
-
-#content h2 {
- margin-top: 24px;
- border-top: 1px solid #99CCFF;
- margin-bottom: 16px;
- font-size: 15px;
- font-weight: bold;
- background: transparent url(../images/blue2white.jpg) repeat-y;
- padding: 2px;
-}
-#content h3 {
- padding-left: 13px;
- border-bottom: 1px solid #99CCFF;
-}
-
-#content li {
- margin-bottom: 6px;
-}
-
-#content th {
- background-color: #3E8BD9;
-}
-
-.Source pre {
- padding: 4px;
- font-family: courier new, monospace;
- font-size: 11px;
- border: 1px dashed #06c;
- background-color: #eeeeee;
- color: black;
-}
-
-.Source:before {
- margin: 0px;
- padding: 0px;
- border: 0px;
- font-size: inherit;
- line-spacing: 100%;
-}
-
-.highlight {
- background-color: #cff;
- border: 1px dotted #06c;
- padding: 5px;
-}
-
-/* The following are for images, but can also apply to div's containing images. */
-
-#content .Float {
- float: right;
- margin-left: 8px;
- margin-right: 0px;
- margin-top: 8px;
- margin-bottom: 8px;
-}
-
-#content .Diagram {
- display: block;
- margin-left: auto;
- margin-right: auto;
- margin-top: 8px;
- margin-bottom: 8px;
-}
-
-
-#content .Inline {
- display: inline;
-}
-
-ul.referenceSummary {
- list-style: none;
- font-family: monospace;
- display: inline-table;
-}
-
-.RuleOfThumb {
- font-weight: bold;
-}
-
-/*---------------------------------------------------------------------------
- * Side panels
- */
-
-.SidePanel {
- background-color: white;
- padding: 0px;
- font-size: 12px;
-}
-
-.SidePanel h5 { /* menugroup-headers */
- margin: 0px;
- border: 0px;
- padding: 4px;
- color: #06c;
- font-size: 12px;
- font-weight: bold;
- background: url(../images/white2blue.jpg);
-}
-
-
-.SidePanel a { text-decoration: none; }
-.SidePanel a:link { color: #06c; }
-.SidePanel a:visited { color: #06c; }
-.SidePanel a:active { color: red; }
-.SidePanel a:hover { color: red; }
-
-/*---------------------------------------------------------------------------
- * Menus
- */
-
-.MenuGroup {
- border-top: 2px solid #06c;
-
- margin-bottom: 8px;
- background: white;
-
- color: #06c;
-}
-
-.MenuGroup ul {
- margin: 0px;
- padding-left: 20px;
- list-style-type: none;
-}
-
-.MenuGroup ul ul {
- padding-left: 0px;
-}
-
-.MenuGroup li {
- padding: 2px;
- list-style-position: outside;
-}
-
-.MenuGroup .currentLink {
- color: #06c;
-}
-
-.MenuGroup li.collapsed {
- list-style-image: url(../images/arrow_blue_collapsed.png);
-}
-
-.MenuGroup li.expanded {
- list-style-image: url(../images/arrow_blue_expanded.png);
-}
-.MenuGroup li.expanded ul {
- margin-left: 5px;
-}
-.MenuGroup li.none {
- list-style-image: none;
-}
-
-/*---------------------------------------------------------------------------
- * News panel
- */
-
-.NewsGroup {
- border-left: 1px solid #06c;
- border-top: 1px solid #06c;
- border-bottom: 1px solid white; /* IE workaround */
- margin-bottom: 8px;
-
- color: #06c;
-}
-
-.NewsItem {
- margin: 4px;
-}
-
-.NewsDate {
- font-weight: bold;
- margin: 0px;
- padding: 0px;
-}
-
-.NewsText {
- padding: 0px;
- margin: 0px;
- margin-bottom: 8px;
-}
-
-.NewsText a { text-decoration: underline; }
-.NewsText a:link { color: #06c; }
-.NewsText a:visited { color: #06c; }
-.NewsText a:active { color: red; }
-.NewsText a:hover { color: red; }
-
-.NewsMore {
- font-size: smaller;
- margin: 4px;
- margin-top: 8px;
- text-align: left;
-}
-
-.NewsGroup td {
- font-size: 12px;
-}
-
-/*---------------------------------------------------------------------------
- * Document meta-information
- */
-
-.Meta {
- margin-top: 64px;
- font-size: smaller;
- color: #C0C0C0;
- text-align: right;
-}
-
-.Meta a { text-decoration: underline; }
-.Meta a:link { color: #C0C0C0; }
-.Meta a:visited { color: #C0C0C0; }
-.Meta a:active { color: red; }
+/*---------------------------------------------------------------------------
+ * Two- and three-column layout
+ */
+
+#banner {
+ margin 5px;
+}
+
+#left {
+ position: absolute;
+ z-index: 2;
+ left: 8px;
+ width: 184px;
+ top: 125px;
+ bottom: 8px;
+ margin: 0px;
+ padding: 0px;
+}
+
+#right {
+ position: absolute;
+ z-index: 1;
+ right: 8px;
+ width: 184px;
+ top: 125px;
+ bottom: 8px;
+ margin: 0px;
+ padding: 0px;
+}
+
+.Content3Column {
+ position: absolute;
+ top: 125px;
+ bottom: 8px;
+ left: 208px;
+ right: 216px;
+}
+
+.Content2Column {
+ position: absolute;
+ top: 125px;
+ bottom: 8px;
+ left: 208px;
+ right: 16px;
+}
+
+#center {
+ z-index: 3;
+ margin: 0px;
+ border: none;
+ padding-bottom: 8px;
+}
+
+/*---------------------------------------------------------------------------
+ * Bradcrumbs
+ */
+.xleft, #bannerLeft img {
+ float:left;
+}
+.xright, #bannerRight {
+ float:right;
+}
+div.clear {
+ clear:both;
+ visibility:hidden;
+}
+#breadcrumbs {
+ background-image:url(breadcrumbs.jpg);
+ height:13px;
+ padding:5px 10px 14px 20px;
+}
+#breadcrumbs {
+ font-size:x-small;
+ margin:0;
+}
+
+/*---------------------------------------------------------------------------
+ * Default element styles
+ */
+
+body {
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+
+ font-family: helvetica, arial, sans-serif;
+ font-size: 12px;
+
+ background-color: white;
+ color: black;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ font-weight: normal;
+}
+
+a:link { color: #9cf; }
+a:active { color: red; }
+a:hover { color: red; }
+a:visited { color: black; }
+
+iframe {
+ width:100%;
+ height: 800px;
+ border: 0px;
+}
+
+img {
+ border: 0px;
+ padding: 0px;
+ margin: 0px;
+}
+
+p {
+ border: 0px;
+ padding: 0px;
+ margin: 0px;
+ margin-bottom: 10px;
+}
+
+blockquote {
+ margin-bottom: 10px;
+}
+
+table {
+ width:100%;
+ padding-bottom: 6px;
+}
+td {
+ font-size: 12px;
+ padding: 2px;
+}
+
+th {
+ font-size: 12px;
+ font-weight: bold;
+ white-space: nowrap;
+ padding: 2px;
+}
+
+th.Row {
+ text-align: left;
+ vertical-align: top;
+}
+
+ul, ol {
+ border: 0px;
+ padding: 0px;
+ margin-top: 0px;
+ margin-bottom: 12px;
+ margin-left: 20px;
+}
+tr.a {
+ background-color: #7EB2E4;
+}
+tr.b {
+ background-color: #BDD7F0;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Page banner
+ */
+
+#banner {
+ margin: 5px;
+ border: 0px;
+ padding: 0px;
+ background-color: white;
+ color: #06c;
+ vertical-align: bottom;
+}
+
+#banner a { text-decoration: none; }
+#banner a:visited { color: #9cf; }
+#banner a:hover { color: red; }
+#banner a:active { color: red; }
+
+#versions {
+ position: absolute;
+ width: auto;
+ right: 0px;
+ top: 0px;
+ margin: 8px;
+ font-weight: normal;
+}
+
+/*---------------------------------------------------------------------------
+ * Page content
+ */
+
+#content {
+ margin: 0px;
+ background-color: white;
+ color: black;
+ height: 100%;
+}
+
+#content h1 {
+ width: 100%;
+ font-size: 18px;
+ background-color: #06c;
+ color: white;
+ padding: 2px;
+ padding-left: 6px;
+ margin-top: 24px;
+ margin-bottom: 12px;
+}
+
+#content .FirstChild { /* IE doesn't understand first-child pseudoelement */
+ margin-top: 0px;
+}
+
+#content a { text-decoration: underline; }
+#content a:link { color: #06c; }
+#content a:visited { color: #06c; }
+#content a:active { color: red; }
+#content a:hover { color: red; }
+
+#content h2 {
+ margin-top: 24px;
+ border-top: 1px solid #99CCFF;
+ margin-bottom: 16px;
+ font-size: 15px;
+ font-weight: bold;
+ background: transparent url(blue2white.jpg) repeat-y;
+ padding: 2px;
+}
+#content h3 {
+ padding-left: 13px;
+ border-bottom: 1px solid #99CCFF;
+}
+
+#content li {
+ margin-bottom: 6px;
+}
+
+#content th {
+ background-color: #3E8BD9;
+}
+
+.Source pre {
+ padding: 4px;
+ font-family: courier new, monospace;
+ font-size: 11px;
+ border: 1px dashed #06c;
+ background-color: #eeeeee;
+ color: black;
+}
+
+.Source:before {
+ margin: 0px;
+ padding: 0px;
+ border: 0px;
+ font-size: inherit;
+ line-spacing: 100%;
+}
+
+.highlight {
+ background-color: #cff;
+ border: 1px dotted #06c;
+ padding: 5px;
+}
+
+/* The following are for images, but can also apply to div's containing images. */
+
+#content .Float {
+ float: right;
+ margin-left: 8px;
+ margin-right: 0px;
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+#content .Diagram {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+
+#content .Inline {
+ display: inline;
+}
+
+ul.referenceSummary {
+ list-style: none;
+ font-family: monospace;
+ display: inline-table;
+}
+
+.RuleOfThumb {
+ font-weight: bold;
+}
+
+/*---------------------------------------------------------------------------
+ * Side panels
+ */
+
+.SidePanel {
+ background-color: white;
+ padding: 0px;
+ font-size: 11px;
+}
+
+.SidePanel h1 {
+ margin: 0px;
+ border: 0px;
+ padding: 4px;
+ color: #06c;
+ font-size: 12px;
+ font-weight: bold;
+ background: url(white2blue.jpg);
+}
+
+
+.SidePanel a { text-decoration: none; }
+.SidePanel a:link { color: #06c; }
+.SidePanel a:visited { color: #06c; }
+.SidePanel a:active { color: red; }
+.SidePanel a:hover { color: red; }
+
+/*---------------------------------------------------------------------------
+ * Menus
+ */
+
+.MenuGroup {
+ border-top: 2px solid #06c;
+
+ margin-bottom: 8px;
+ background: white;
+
+ color: #06c;
+}
+
+.MenuGroup ul {
+ margin: 0px;
+ padding-left: 4px;
+ list-style-type: none;
+}
+
+.MenuGroup li {
+ padding: 2px;
+}
+
+.MenuGroup .currentLink {
+ color: #06c;
+}
+
+
+/*---------------------------------------------------------------------------
+ * News panel
+ */
+
+.NewsGroup {
+ border-left: 1px solid #06c;
+ border-top: 1px solid #06c;
+ border-bottom: 1px solid white; /* IE workaround */
+ margin-bottom: 8px;
+
+ color: #06c;
+}
+
+.NewsItem {
+ margin: 4px;
+}
+
+.NewsDate {
+ font-weight: bold;
+ margin: 0px;
+ padding: 0px;
+}
+
+.NewsText {
+ padding: 0px;
+ margin: 0px;
+ margin-bottom: 8px;
+}
+
+.NewsText a { text-decoration: underline; }
+.NewsText a:link { color: #06c; }
+.NewsText a:visited { color: #06c; }
+.NewsText a:active { color: red; }
+.NewsText a:hover { color: red; }
+
+.NewsMore {
+ font-size: smaller;
+ margin: 4px;
+ margin-top: 8px;
+ text-align: left;
+}
+
+.NewsGroup td {
+ font-size: 12px;
+}
+
+/*---------------------------------------------------------------------------
+ * Document meta-information
+ */
+
+.Meta {
+ margin-top: 64px;
+ font-size: smaller;
+ color: #C0C0C0;
+ text-align: right;
+}
+
+.Meta a { text-decoration: underline; }
+.Meta a:link { color: #C0C0C0; }
+.Meta a:visited { color: #C0C0C0; }
+.Meta a:active { color: red; }
.Meta a:hover { color: red; }
\ No newline at end of file
diff --git a/src/site/resources/images/tekton_logo.png b/src/site/resources/tekton_logo.png
similarity index 100%
rename from src/site/resources/images/tekton_logo.png
rename to src/site/resources/tekton_logo.png
diff --git a/src/site/resources/images/white2blue.jpg b/src/site/resources/white2blue.jpg
similarity index 100%
rename from src/site/resources/images/white2blue.jpg
rename to src/site/resources/white2blue.jpg
diff --git a/src/site/site.xml b/src/site/site.xml
deleted file mode 100644
index 143963e..0000000
--- a/src/site/site.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"
- name="QDox">
- <bannerLeft>
- <name>Codehaus QDox</name>
- <src>./images/tekton_logo.png</src>
- <href>http://qdox.codehaus.org/index.html</href>
- </bannerLeft>
- <publishDate position="right"/>
- <version position="right"/>
- <body>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="Frequently asked questions" href="faq.html"/>
- </menu>
- <menu name="Evaluating QDox">
- <item name="Download" href="download.html"/>
- <item name="Upgrading" href="upgrade.html"/>
- <item name="Who is using QDox" href="whouses.html"/>
- </menu>
- <menu name="Using QDox">
- <item name="Usage" href="usage.html"/>
- <item name="Model" href="model.html"/>
- </menu>
- <menu ref="reports"/>
- </body>
-</project>
diff --git a/src/site/templates/site-template.vm b/src/site/templates/site-template.vm
new file mode 100644
index 0000000..ef84bba
--- /dev/null
+++ b/src/site/templates/site-template.vm
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>#if($title.startsWith('QDox - ')) $title.substring(6) #else $title #end</title>
+ <style type="text/css" media="all">
+ @import url("$relativePath/css/maven-base.css");
+ @import url("$relativePath/css/maven-theme.css");
+ @import url("$relativePath/css/site.css");
+ </style>
+ </head>
+ <body>
+ $bodyContent
+ </body>
+</html>
+
diff --git a/src/site/templates/site.vm b/src/site/templates/site.vm
deleted file mode 100644
index 0c7bfbc..0000000
--- a/src/site/templates/site.vm
+++ /dev/null
@@ -1,369 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-#macro ( link $href $name )
- #if ( ( $href.toLowerCase().startsWith("http") || $href.toLowerCase().startsWith("https") ) )
- <a href="$href" class="externalLink">$name</a>
- #else
- <a href="$href">$name</a>
- #end
-#end
-
-#macro ( banner $banner $id )
- <!-- banner $banner -->
- #if ( $banner )
- #if( $banner.href )
- <a href="${banner.href}" id="$id" #if( $banner.alt ) title="$banner.alt" #end >
- #else
- <div id="$id">
- #end
-
- #if( $banner.src )
- #set ( $src = $banner.src )
- #if ( ! ( $src.toLowerCase().startsWith("http") || $src.toLowerCase().startsWith("https") ) )
- #set ( $src = $PathTool.calculateLink( $src, $relativePath ) )
- #set ( $src = $src.replaceAll( "\\", "/" ) )
- #end
- #if ( $banner.alt )
- #set ( $alt = $banner.alt )
- #else
- #set ( $alt = $banner.name )
- #end
- <img src="${src}" alt="${alt}" />
- #else
- $banner.name
- #end
-
- #if( $banner.href )
- </a>
- #else
- </div>
- #end
- #end
-#end
-
-#macro ( links $links )
- #set ( $counter = 0 )
- #foreach( $item in $links )
- #set ( $counter = $counter + 1 )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) )
- #link( $currentItemHref $item.name )
- #if ( $links.size() > $counter )
- |
- #end
- #end
-#end
-
-#macro ( breadcrumbs $breadcrumbs )
- #set ( $counter = 0 )
- #foreach( $item in $breadcrumbs )
- #set ( $counter = $counter + 1 )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) )
-
- #if ( $currentItemHref == $alignedFileName || $currentItemHref == "" )
- $item.name
- #else
- #link( $currentItemHref $item.name )
- #end
- #if ( $breadcrumbs.size() > $counter )
- >
- #end
- #end
-#end
-
-#macro ( displayTree $display $item )
- #if ( $item && $item.items && $item.items.size() > 0 )
- #foreach( $subitem in $item.items )
- #set ( $subitemHref = $PathTool.calculateLink( $subitem.href, $relativePath ) )
- #set ( $subitemHref = $subitemHref.replaceAll( "\\", "/" ) )
- #set ( $display = false )
- #if ( $alignedFileName == $subitemHref )
- #set ( $display = true )
- #end
-
- #displayTree( $display $subitem )
- #end
- #end
-#end
-
-#macro ( menuItem $item )
- #set ( $collapse = "none" )
- #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) )
-
- #if ( $item && $item.items && $item.items.size() > 0 )
- #if ( $item.collapse == false )
- #set ( $collapse = "expanded" )
- #else
- ## By default collapsed
- #set ( $collapse = "collapsed" )
- #end
-
- #set ( $display = false )
- #displayTree( $display $item )
-
- #if ( $alignedFileName == $currentItemHref || $display )
- #set ( $collapse = "expanded" )
- #end
- #end
- <li class="$collapse">
- #if ( $item.img )
- #if ( ! ( $item.img.toLowerCase().startsWith("http") || $item.img.toLowerCase().startsWith("https") ) )
- #set ( $src = $PathTool.calculateLink( $item.img, $relativePath ) )
- #set ( $src = $src.replaceAll( "\\", "/" ) )
- <img src="$src"/>
- #else
- <img src="$item.img" align="absbottom" style="border-width: 0"/>
- #end
- #end
- #if ( $alignedFileName == $currentItemHref )
- <strong>$item.name</strong>
- #else
- #link( $currentItemHref $item.name )
- #end
- #if ( $item && $item.items && $item.items.size() > 0 )
- #if ( $collapse == "expanded" )
- <ul>
- #foreach( $subitem in $item.items )
- #menuItem( $subitem )
- #end
- </ul>
- #end
- #end
- </li>
-#end
-
-#macro ( mainMenu $menus )
- #foreach( $menu in $menus )
- <div class="MenuGroup">
- #if ( $menu.name )
- <h5>$menu.name</h5>
- #end
- #if ( $menu.items && $menu.items.size() > 0 )
- <ul>
- #foreach( $item in $menu.items )
- #menuItem( $item )
- #end
- </ul>
- #end
- </div>
- #end
-#end
-
-#macro ( copyright )
- #if ( $project )
- #set ( $currentYear = ${currentDate.year} + 1900 )
-
- #if ( ${project.inceptionYear} && ( ${project.inceptionYear} != ${currentYear.toString()} ) )
- ${project.inceptionYear}-${currentYear}
- #else
- ${currentYear}
- #end
-
- #if ( ${project.organization} && ${project.organization.name} )
- ${project.organization.name}
- #end
- #end
-#end
-
-#macro ( publishDate $position $publishDate $version )
- #if ( $publishDate && $publishDate.format )
- #set ( $format = $publishDate.format )
- #else
- #set ( $format = "yyyy-MM-dd" )
- #end
-
- $dateFormat.applyPattern( $format )
-
- #set ( $dateToday = $dateFormat.format( $currentDate ) )
-
- #if ( $publishDate && $publishDate.position )
- #set ( $datePosition = $publishDate.position )
- #else
- #set ( $datePosition = "left" )
- #end
-
- #if ( $version )
- #if ( $version.position )
- #set ( $versionPosition = $version.position )
- #else
- #set ( $versionPosition = "left" )
- #end
- #else
- #set ( $version = "" )
- #set ( $versionPosition = "left" )
- #end
-
- #set ( $breadcrumbs = $decoration.body.breadcrumbs )
- #set ( $links = $decoration.body.links )
-
- #if ( $datePosition.equalsIgnoreCase( "right" ) && $links && $links.size() > 0 )
- #set ( $prefix = " |" )
- #else
- #set ( $prefix = "" )
- #end
-
- #if ( $datePosition.equalsIgnoreCase( $position ) )
- #if ( ( $datePosition.equalsIgnoreCase( "right" ) ) || ( $datePosition.equalsIgnoreCase( "bottom" ) ) )
- $prefix $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- #end
- #elseif ( ( $datePosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $datePosition.equalsIgnoreCase( "navigation-top" ) ) )
- <div id="lastPublished">
- $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- #end
- </div>
- #elseif ( $datePosition.equalsIgnoreCase("left") )
- <div class="xleft">
- $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday
- #if ( $versionPosition.equalsIgnoreCase( $position ) )
- | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- #end
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- | #breadcrumbs( $breadcrumbs )
- #end
- </div>
- #end
- #elseif ( $versionPosition.equalsIgnoreCase( $position ) )
- #if ( ( $versionPosition.equalsIgnoreCase( "right" ) ) || ( $versionPosition.equalsIgnoreCase( "bottom" ) ) )
- $prefix $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- #elseif ( ( $versionPosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $versionPosition.equalsIgnoreCase( "navigation-top" ) ) )
- <div id="lastPublished">
- $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- </div>
- #elseif ( $versionPosition.equalsIgnoreCase("left") )
- <div class="xleft">
- $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- | #breadcrumbs( $breadcrumbs )
- #end
- </div>
- #end
- #elseif ( $position.equalsIgnoreCase( "left" ) )
- #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
- <div class="xleft">
- #breadcrumbs( $breadcrumbs )
- </div>
- #end
- #end
-#end
-
-#macro ( poweredByLogo $poweredBy )
- #if( $poweredBy )
- #foreach ($item in $poweredBy)
- #if( $item.href )
- #set ( $href = $PathTool.calculateLink( $item.href, $relativePath ) )
- #set ( $href = $href.replaceAll( "\\", "/" ) )
- #else
- #set ( $href="http://maven.apache.org/" )
- #end
-
- #if( $item.name )
- #set ( $name = $item.name )
- #else
- #set ( $name = $i18n.getString( "site-renderer", $locale, "template.builtby" ) )
- #set ( $name = "${name} Maven" )
- #end
-
- #if( $item.img )
- #set ( $img = $item.img )
- #else
- #set ( $img = "images/logos/maven-feather.png" )
- #end
-
- <a href="$href" title="$name" class="poweredBy">
- #set ( $img = $PathTool.calculateLink( $img, $relativePath ) )
- #set ( $img = $img.replaceAll( "\\", "/" ) )
- <img class="poweredBy"
- alt="$name"
- src="$img"
- width="90"
- height="30"
- />
- </a>
- #end
- #if( $poweredBy.isEmpty() )
- <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" class="poweredBy">
- <img class="poweredBy"
- alt="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven"
- src="$relativePath/images/logos/maven-feather.png"
- width="90"
- height="30"
- border="1" />
- </a>
- #end
- #else
- <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven" class="poweredBy">
- <img class="poweredBy"
- alt="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven"
- src="$relativePath/images/logos/maven-feather.png"
- width="90"
- height="30"
- border="1"
- />
- </a>
- #end
-#end
-
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>$title</title>
- <style type="text/css" media="all">
- @import url("$relativePath/css/style.css");
- </style>
- #foreach( $author in $authors )
- <meta name="author" content="$author" />
- #end
- <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
- #if ( $decoration.body.head )
- #foreach( $item in $decoration.body.head.getChildren() )
- ## Workaround for DOXIA-150 due to a non-desired behaviour in p-u
- ## @see org.codehaus.plexus.util.xml.Xpp3Dom#toString()
- ## @see org.codehaus.plexus.util.xml.Xpp3Dom#toUnescapedString()
- #set ( $documentHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" )
- #set ( $documentHeader = $documentHeader.replaceAll( "\\", "" ) )
- #if ( $item.name == "script" )
- $StringUtils.replace( $item.toUnescapedString(), $documentHeader, "" )
- #else
- $StringUtils.replace( $item.toString(), $documentHeader, "" )
- #end
- #end
- #end
- </head>
- <body>
- <div id="breadcrumbs">
- #publishDate( "left" $decoration.publishDate $decoration.version )
- <div class="xright">#links( $decoration.body.links )#publishDate( "right" $decoration.publishDate $decoration.version )</div>
- <div class="clear">
- <hr/>
- </div>
- </div>
- <div id="banner">
- #banner( $decoration.bannerLeft "bannerLeft" )
- #banner( $decoration.bannerRight "bannerRight" )
- <div class="clear">
- <hr/>
- </div>
- </div>
-
- <div id="center" class="Content2Column"> <!-- Content3Column for index -->
- <div id="content">
- <h1 class="FirstChild">${title}</h1>
- ${bodyContent}<br/>
- </div>
- </div>
-
- <div class="SidePanel" id="left">
- #mainMenu( $decoration.body.menus )
- <div style="padding: 25px 57px 5px;">
- <script type="text/javascript" src="http://www.ohloh.net/p/10367/widgets/project_users.js?style=blue"></script>
- </div>
- </div>
-
- </body>
-</html>
-
diff --git a/src/site/templates/skin.html b/src/site/templates/skin.html
new file mode 100644
index 0000000..9acdaa3
--- /dev/null
+++ b/src/site/templates/skin.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>QDox - ${title}</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ ${head}
+ </head>
+ <body>
+
+ <div id="breadcrumbs">
+ <div class="xleft"></div>
+ <div class="xright">Last Published: ${timestamp} | Version: ${project.version}</div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="banner">
+ <a href="index.html"><img id="logo" src="tekton_logo.png" alt="QDox"/></a>
+ </div>
+
+
+ <div id="center" class="Content2Column"> <!-- Content3Column for index -->
+ <div id="content">
+ <h1 class="FirstChild">${title}</h1>
+
+ ${body}
+
+ <br/>
+
+ </div>
+ </div>
+
+ <div class="SidePanel" id="left">
+ <#list sitemap.sections as section>
+ <div class="MenuGroup">
+ <h1>${section.name}</h1>
+ <ul>
+ <#list section.entries as otherPage>
+ <#if otherPage = page>
+ <li class="currentLink">${otherPage.title}</li>
+ <#else>
+ <li><a href="${otherPage.href}">${otherPage.title}</a></li>
+ </#if>
+ </#list>
+ </ul>
+ </div>
+ </#list>
+ <div style="padding: 25px 57px 5px;">
+ <script type="text/javascript" src="http://www.ohloh.net/p/10367/widgets/project_users.js?style=blue"></script>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/src/site/xhtml/download.xhtml b/src/site/xhtml/download.xhtml
deleted file mode 100644
index aa6ae7d..0000000
--- a/src/site/xhtml/download.xhtml
+++ /dev/null
@@ -1,30 +0,0 @@
-<html>
- <head>
- <title>Download</title>
- </head>
- <body>
- <p>QDox is available at the Maven Central. To include the most recent of QDox in your pom, include the following dependency:
- <pre>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>${project.artifactId}</artifactId>
- <version>${project.version}</version>
- </dependency>
- </pre>
- </p>
- <p>
- Latest stable release - QDox ${project.rel.org.thoughtworks.qdox:qdox}:
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}.jar">binary jar</a> |
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-sources.jar">sources jar</a> |
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-javadoc.jar">javadoc jar</a> |
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.tar.bz2">project tar.bz2</a> |
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.tar.gz">project tar.gz</a> |
- <a href="http://nexus.codehaus.org/content/repositories/releases/com/thoughtworks/qdox/qdox/${project.rel.org.thoughtworks.qdox:qdox}/qdox-${project.rel.org.thoughtworks.qdox:qdox}-project.zip">project zip</a>
- </p>
- <p>
- Snapshot deployments:
- <a href="https://nexus.codehaus.org/content/repositories/snapshots/com/thoughtworks/qdox/qdox/">snapshots directory</a>.
- </p>
- </body>
-
-</html>
diff --git a/src/site/xhtml/migration.xhtml b/src/site/xhtml/migration.xhtml
deleted file mode 100644
index 78a36e1..0000000
--- a/src/site/xhtml/migration.xhtml
+++ /dev/null
@@ -1,34 +0,0 @@
-<html>
-<head/>
-<body>
-<h1>Migrating to QDox 2.0</h1>
-
-<h3>Farewell JavaDocBuilder, hello JavaProjectBuilder</h3>
-
-<h3>Farewell OrderedMap, hello LinkedHashMap</h3>
-<p>
-Before JDK1.3 there was no implementation available which could hold the order in which entries were added to a Map.
-With JDK1.4 the LinkedHashMap was introduced.
-We've decided to make use of this class which also means projects using QDox need at least JDK1.4.
-If you want QDox to <strong>parse</strong> code with an older JDK version, you'll have to configure the ClassLoaderLibrary feeding it with the required classloaders.
-</p>
-
-<h3>Farewell JavaClass, hello JavaClass</h3>
-Looks like nothing has changed, but we've decided to change all models to interfaces and give them a default implementation.
-This way we can hide all methods which the ModelBuilder needs to build the model and you'll only see those methods which are interesting for you.
-This also means that the default implementations looks much more like plain old Java Objects, its binding logic has been moved to the ModelBuilder.
-
-<h3>Farewell AbstractQDoxTask for Ant</h3>
-We've decided to remove this Abstract AntTask. It doesn't belong in the core of QDox, but it's an prepared Ant Task to use QDox.
-Although we'd defined this dependency as optional, it kind of spoiled the pom.xml.
-
-<h3>Farewell APITestCase for JUnit3</h3>
-
-
-<h2>Summary</h2>
-<ul>
- <li>Use the JavaProjectBuilder instead of the JavaDocBuilder</li>
- <li>QDox requires at least JDK1.4</li>
-</ul>
-</body>
-</html>
\ No newline at end of file
diff --git a/src/test/resources/qdox-140/X.jav b/src/test-resources/qdox-140/X.jav
similarity index 100%
rename from src/test/resources/qdox-140/X.jav
rename to src/test-resources/qdox-140/X.jav
diff --git a/src/test/resources/readme.txt b/src/test-resources/readme.txt
similarity index 100%
rename from src/test/resources/readme.txt
rename to src/test-resources/readme.txt
diff --git a/src/test/com/thoughtworks/qdox/AnnotationsModelTest.java b/src/test/com/thoughtworks/qdox/AnnotationsModelTest.java
new file mode 100644
index 0000000..fb31448
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/AnnotationsModelTest.java
@@ -0,0 +1,331 @@
+package com.thoughtworks.qdox;
+
+import java.io.StringReader;
+import java.util.ListIterator;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaPackage;
+import com.thoughtworks.qdox.model.annotation.AnnotationAdd;
+import com.thoughtworks.qdox.model.annotation.AnnotationConstant;
+import com.thoughtworks.qdox.model.annotation.AnnotationFieldRef;
+import com.thoughtworks.qdox.model.annotation.AnnotationTypeRef;
+import com.thoughtworks.qdox.model.annotation.AnnotationValue;
+import com.thoughtworks.qdox.model.annotation.AnnotationValueList;
+import com.thoughtworks.qdox.model.annotation.EvaluatingVisitor;
+
+public class AnnotationsModelTest extends TestCase {
+
+ private JavaDocBuilder builder;
+
+ private EvaluatingVisitor evaluatingVisitor = new EvaluatingVisitor() {
+ protected Object getFieldReferenceValue( JavaField javaField ) {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ builder = new JavaDocBuilder();
+ builder.setDebugLexer( true );
+ builder.setDebugParser( true );
+ }
+
+ protected Annotation checkClassAnnotation( String source ) {
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+
+ return annotation;
+ }
+
+ public void testMarkerAnnotation() {
+ checkClassAnnotation( "@Annotation\nclass Foo {}" );
+ }
+
+ public void testEmptyAnnotation() {
+ checkClassAnnotation( "@Annotation()\nclass Foo {}" );
+ }
+
+ public void testAnnotationAnnotation() {
+ checkClassAnnotation( "@Annotation(@NestedAnnotation)\nclass Foo {}" );
+ }
+
+ public void testConstAnnotation() {
+ checkClassAnnotation( "@Annotation(1)\nclass Foo {}" );
+ }
+
+ public void testAnnotationConstants() {
+ String source = "@Annotation( f = 1.0, d = 1.0d, i = 1, ix = 0x1, l = 1L, lx = 0x1L, c = 'c', s = \"string\" )\nclass Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 8, annotation.getNamedParameterMap().size() );
+
+ AnnotationConstant f = (AnnotationConstant) annotation.getProperty( "f" );
+ assertEquals( "f", new Float( 1 ), f.getValue() );
+
+ AnnotationConstant d = (AnnotationConstant) annotation.getProperty( "d" );
+ assertEquals( "d", new Double( 1 ), d.getValue() );
+
+ AnnotationConstant i = (AnnotationConstant) annotation.getProperty( "i" );
+ assertEquals( "i", new Integer( 1 ), i.getValue() );
+
+ AnnotationConstant ix = (AnnotationConstant) annotation.getProperty( "ix" );
+ assertEquals( "ix", new Integer( 1 ), ix.getValue() );
+
+ AnnotationConstant l = (AnnotationConstant) annotation.getProperty( "l" );
+ assertEquals( "l", new Long( 1 ), l.getValue() );
+
+ AnnotationConstant lx = (AnnotationConstant) annotation.getProperty( "lx" );
+ assertEquals( "lx", new Long( 1 ), lx.getValue() );
+
+ AnnotationConstant c = (AnnotationConstant) annotation.getProperty( "c" );
+ assertEquals( "c", new Character( 'c' ), c.getValue() );
+
+ AnnotationConstant s = (AnnotationConstant) annotation.getProperty( "s" );
+ assertEquals( "s", "string", s.getValue() );
+ }
+
+ public void testAnnotationConstantsControlChars() {
+ String source = "@Annotation( s1 = \"a\\nb\", s2 = \"a\\nb\", s3 = \"a\\rb\", s4 = \"a\\tb\", s5 = \"a\\u0009b\" ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 5, annotation.getPropertyMap().size() );
+
+ AnnotationConstant s1 = (AnnotationConstant) annotation.getProperty( "s1" );
+ assertEquals( "s1", "a\nb", s1.getValue() );
+
+ AnnotationConstant s2 = (AnnotationConstant) annotation.getProperty( "s2" );
+ assertEquals( "s2", "a\nb", s2.getValue() );
+
+ AnnotationConstant s3 = (AnnotationConstant) annotation.getProperty( "s3" );
+ assertEquals( "s3", "a\rb", s3.getValue() );
+
+ AnnotationConstant s4 = (AnnotationConstant) annotation.getProperty( "s4" );
+ assertEquals( "s4", "a\tb", s4.getValue() );
+
+ AnnotationConstant s5 = (AnnotationConstant) annotation.getProperty( "s5" );
+ assertEquals( "s5", "a\u0009b", s5.getValue() );
+ }
+
+ public void testNestedAnnotation() {
+ String source = "@Annotation( { @Inner(1), @Inner(2) } ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ AnnotationValueList list = (AnnotationValueList) annotation.getProperty( "value" );
+ assertEquals( "Inner Annotations", 2, list.getValueList().size() );
+
+ for( ListIterator i = list.getValueList().listIterator(); i.hasNext(); ) {
+ Annotation inner = (Annotation) i.next();
+ assertEquals( "Inner " + i.previousIndex(), "Inner", inner.getType().getValue() );
+ }
+ }
+
+ public void testExpressionAnnotation1() {
+ String source = "@Annotation( 1 + 1 ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ AnnotationAdd add = (AnnotationAdd) annotation.getProperty( "value" );
+ assertEquals( "Left", new Integer( 1 ), ((AnnotationConstant) add.getLeft()).getValue() );
+ assertEquals( "Right", new Integer( 1 ), ((AnnotationConstant) add.getRight()).getValue() );
+ }
+
+ public void testExpressionAnnotation2() {
+ String source = "@Annotation( \"value = \" + 1 ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ AnnotationAdd add = (AnnotationAdd) annotation.getProperty( "value" );
+ assertEquals( "Left", "value = ", ((AnnotationConstant) add.getLeft()).getValue() );
+ assertEquals( "Right", new Integer( 1 ), ((AnnotationConstant) add.getRight()).getValue() );
+ }
+
+ public void testFieldRefAnnotation() {
+ String source = "@Annotation( java.lang.Math.E ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ AnnotationFieldRef value = (AnnotationFieldRef) annotation.getProperty( "value" );
+ assertEquals( "type", "double", value.getField().getType().getValue() );
+ assertEquals( "class part", "java.lang.Math", value.getClassPart() );
+ assertEquals( "field part", "E", value.getFieldPart() );
+ }
+
+ public void testPrimitiveClassAnnotation() {
+ String source = "@Annotation( int.class ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ Object value = annotation.getProperty( "value" );
+ AnnotationTypeRef ref = (AnnotationTypeRef) value;
+ assertEquals( "value", "int", ref.getType().getValue() );
+ }
+
+ public void testClassAnnotation() {
+ String source = "@Annotation( java.util.Set.class ) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ Object value = annotation.getProperty( "value" );
+ AnnotationTypeRef ref = (AnnotationTypeRef) value;
+ assertEquals( "value", "java.util.Set", ref.getType().getValue() );
+ }
+
+ protected void assertAnnotationValue( Object expected ) {
+ JavaClass clazz = builder.getClassByName( "Foo" );
+ assertEquals( "Annotations", 1, clazz.getAnnotations().length );
+ Annotation annotation = clazz.getAnnotations()[0];
+ assertEquals( "Annotation name", "Annotation", annotation.getType().getJavaClass().getFullyQualifiedName() );
+ assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
+
+ AnnotationValue value = annotation.getProperty( "value" );
+ Object v = value.accept( evaluatingVisitor );
+ assertEquals( "Value", expected, v );
+ }
+
+ protected void assertAnnotationExpression( String expression, Object expected ) {
+ String source = "@Annotation(\n" + expression + "\n) class Foo {}";
+ builder.addSource( new StringReader( source ) );
+ assertAnnotationValue( expected );
+ }
+
+ public void testPrecedence() {
+ assertAnnotationExpression( "2 + 2 * 5", new Integer( 12 ) );
+ assertAnnotationExpression( "2 * 5 + 2", new Integer( 12 ) );
+ }
+
+ public void testLogicalExpression() {
+ assertAnnotationExpression( "true && false", Boolean.FALSE );
+ assertAnnotationExpression( "true || false", Boolean.TRUE );
+ assertAnnotationExpression( "!true", Boolean.FALSE );
+ }
+
+ public void testBitExpression() {
+ assertAnnotationExpression( "1 & 3", new Integer( 1 & 3 ) );
+ assertAnnotationExpression( "1 | 3", new Integer( 1 | 3 ) );
+ assertAnnotationExpression( "1 ^ 3", new Integer( 1 ^ 3 ) );
+ assertAnnotationExpression( "~1", new Integer( ~1 ) );
+ }
+
+ public void testSignExpression() {
+ assertAnnotationExpression( "+1", new Integer( 1 ) );
+ assertAnnotationExpression( "-1", new Integer( -1 ) );
+ assertAnnotationExpression( "--1", new Integer( 1 ) );
+ }
+
+ public void testAddSubMultDivExpression() {
+ assertAnnotationExpression( "8 / 3", new Integer( 8 / 3 ) );
+ assertAnnotationExpression( "8 * 3", new Integer( 8 * 3 ) );
+ assertAnnotationExpression( "8 + 3", new Integer( 8 + 3 ) );
+ assertAnnotationExpression( "8 - 3", new Integer( 8 - 3 ) );
+ assertAnnotationExpression( "8 % 3", new Integer( 8 % 3 ) );
+ assertAnnotationExpression( "\"a\" + \"b\"", "a" + "b" );
+ }
+
+ public void testShiftExpression() {
+ assertAnnotationExpression( "8 << 2", new Integer( 8 << 2 ) );
+ assertAnnotationExpression( "8 >> 2", new Integer( 8 >> 2 ) );
+ assertAnnotationExpression( "-1 >> 2", new Integer( -1 >> 2 ) );
+ assertAnnotationExpression( "-1 >>> 2", new Integer( -1 >>> 2 ) );
+ }
+
+ public void testLiteral() {
+ assertAnnotationExpression( "1", new Integer( 1 ) );
+ assertAnnotationExpression( "1l", new Long( 1 ) );
+ assertAnnotationExpression( "1.0", new Float( 1 ) );
+ assertAnnotationExpression( "1.0d", new Double( 1 ) );
+ }
+
+ public void testParenExpression() {
+ assertAnnotationExpression( "2 + (2 * 5)", new Integer( 12 ) );
+ assertAnnotationExpression( "(2 + 2) * 5", new Integer( 20 ) );
+ }
+
+ public void testCompareExpression() {
+ assertAnnotationExpression( "1 < 2", Boolean.TRUE );
+ assertAnnotationExpression( "1 > 2", Boolean.FALSE );
+ assertAnnotationExpression( "1 <= 2", Boolean.TRUE );
+ assertAnnotationExpression( "1 >= 2", Boolean.FALSE );
+ assertAnnotationExpression( "1 == 2", Boolean.FALSE );
+ assertAnnotationExpression( "1 != 2", Boolean.TRUE );
+ }
+
+ public void testQueryExpression() {
+ assertAnnotationExpression( "1 < 2 ? 0 : 3", new Integer( 0 ) );
+ assertAnnotationExpression( "1 > 2 ? 0 : 3", new Integer( 3 ) );
+ }
+
+ public void testCastExpression() {
+ assertAnnotationExpression( "(short)1", new Short( (short) 1 ) );
+ assertAnnotationExpression( "(long)(short)1", new Long( 1 ) );
+ assertAnnotationExpression( "(int)((short)1 + (long)3)", new Integer( 4 ) );
+ }
+
+ //from Qdox-98
+ public void testPackageWithAnnotation() throws Exception {
+ String source = "@javax.xml.bind.annotation.XmlSchema(namespace = \"http://docs.oasis-open.org/wsn/br-2\")\n" +
+ "package org.oasis_open.docs.wsn.br_2;\n" +
+ "public class Foo {}";
+ builder.addSource(new StringReader(source));
+ JavaPackage jPackage = builder.getClasses()[0].getPackage();
+ assertEquals("org.oasis_open.docs.wsn.br_2", jPackage.getName());
+ assertEquals("javax.xml.bind.annotation.XmlSchema", jPackage.getAnnotations()[0].getType().getValue());
+ assertEquals(2, jPackage.getLineNumber());
+
+
+ }
+
+ // http://jira.codehaus.org/browse/QDOX-135
+ public void testAnnotationInMethodParamList() {
+ String source = ""
+ + "class Foo {\n"
+ // + " @X()\n" - does not affect test.
+ + " public String xyz(@Y(1) int blah) {\n"
+ + " }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass clazz = builder.getClassByName("Foo");
+ JavaMethod mth = clazz.getMethods()[0];
+ assertEquals("Foo", clazz.getName());
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/AnnotationsTest.java b/src/test/com/thoughtworks/qdox/AnnotationsTest.java
new file mode 100644
index 0000000..06b272a
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/AnnotationsTest.java
@@ -0,0 +1,267 @@
+package com.thoughtworks.qdox;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.annotation.AnnotationFieldRef;
+
+public class AnnotationsTest extends TestCase {
+
+ private JavaDocBuilder builder;
+ public AnnotationsTest()
+ {
+ builder = new JavaDocBuilder();
+ //builder.setDebugLexer( true );
+ //builder.setDebugParser( true );
+ }
+
+ public void testShouldIgnoreSimpleClassAnnotation() {
+ String source = ""
+ + "@Fnord\n"
+ + "public interface Foo extends Bar {}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+ public void testShouldIgnoreSimpleMethodAnnotation() {
+ String source = ""
+ + "public class X {\n"
+ + " @Fnord public void snort() {}\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass fooClass = builder.getClassByName("X");
+ assertEquals("X", fooClass.getName());
+ assertEquals(1, fooClass.getMethods().length);
+ assertEquals("snort", fooClass.getMethods()[0].getName());
+ }
+
+ public void testShouldIgnoreMethodParameterAnnotation() {
+ String source = ""
+ + "public class X {\n"
+ + " String field = new String( \"hey\" );\n"
+ + " public void setX(@name String x) {}\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass fooClass = builder.getClassByName("X");
+ assertEquals("X", fooClass.getName());
+ assertEquals(1, fooClass.getMethods().length);
+ assertEquals("setX", fooClass.getMethods()[0].getName());
+ }
+
+ public void testShouldIgnoreComplexClassAnnotations() {
+ String source = ""
+ + "@Fnord(pi = 3.14, e = m*c*c)\n"
+ + "public interface Foo extends Bar {\n"
+ + " @Fnord(pi = 3.14, e = m*c*c)\n"
+ + " void doStuff() { }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+ public void testShouldIgnoreSingleMemberClassAnnotations() {
+ String source = ""
+ + "@Fnord(\"xyz\")\n"
+ + "@Blat(Math.MAXINT)\n"
+ + "public interface Foo extends Bar {\n"
+ + " @Fnord(\"xyz\")\n"
+ + " @Blat(Math.MAXINT)\n"
+ + " void doStuff() { }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+ public void testShouldIgnoreArrayValuedSingleMemberClassAnnotations() {
+ String source = "" /** @hey=\"yo\" someval = \"yep\" */
+ + "@ Endorsers({(\"Children\"), \"Unscrupulous dentists\"})\n"
+ + "public class Lollipop {\n"
+ + " @Cheese( hey=@ano({\"Edam\", \"Gruyere\", 2}), t=5.5f, c=4)\n"
+ + " void doStuff() { }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ assertNotNull(builder.getClassByName("Lollipop"));
+ }
+
+ public void testShouldIgnoreComplexSingleMemberClassAnnotations() {
+ String source = ""
+ + "@Author(@Name(first = \"Joe\", last = true))\n" // I won't take it personally! ;) -joe
+ + "public class BitTwiddle {\n"
+ + " @Author(@Name(first = \'c\', last = 2.5e3f))\n"
+ + " void doStuff() { }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ assertNotNull(builder.getClassByName("BitTwiddle"));
+ assertNotNull( builder.getClassByName("BitTwiddle").getAnnotations()[0].getNamedParameter("value") );
+ assertEquals( "Author", builder.getClassByName("BitTwiddle")
+ .getMethodBySignature("doStuff", new Type[] {})
+ .getAnnotations()[0].getType().getValue() );
+ }
+
+ public void testShouldIgnoreAnnotationDeclaration() {
+ String source = "package org.jabba;\n"
+ + "@MyAnno\n"
+ + "public @interface Note {\n"
+ + " String text;\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals(1, builder.getClasses().length);
+ }
+
+ public void testShouldIgnoreAnnotationWithClassType() {
+ String source = ""
+ + "@Fnord(String.class)\n"
+ + "public interface Foo extends Bar {}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+
+ // from QDOX-97
+ public void testShouldIgnoreAttributeAnnotation() {
+ String source = ""
+ + "public interface Foo {\n"
+ + " String echo(@WebParam java.lang.String msg);\n"
+ + "}\n";
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+ // from QDOX-101
+ public void testShouldNotChokeOnDoubleAttributeAnnotationAndGenerics() {
+ String source = ""
+ + "public class Person {\n" +
+ " @XmlJavaTypeAdapter(CollapsedStringAdapter.class)\n" +
+ " @XmlID\n" +
+ " protected String name;\n" +
+ " public List<String> getAddress() {\n" +
+ " return address;\n" +
+ " }" +
+ "}\n";
+ builder.addSource(new StringReader(source));
+ assertEquals("Person", builder.getClassByName("Person").getName());
+ }
+
+ // from QDOX-108
+ public void testFQNAnnotations() {
+ String source = ""
+ + "@com.mycompany.Fnord(a=1)\n"
+ + "public interface Foo extends Bar {}\n";
+
+ builder.addSource(new StringReader(source));
+ assertEquals("Foo", builder.getClassByName("Foo").getName());
+ }
+
+ // from QDOX-113
+ public void testAnnotationWithParameter() throws Exception {
+ String source="public class Foo{\n" +
+ "@Editor(FileEditor.class)\n" +
+ "public void setFile(File file) { this.file = file; }" +
+ "}";
+ builder.addSource(new StringReader(source));
+ }
+
+ //from QDOX-128
+ public void testQuotedStringAnnotation() throws Exception {
+ String source = "@Anno(run = \"1.0\")"+
+ "public interface Foo {}";
+ builder.addSource(new StringReader(source));
+ assertEquals("\"1.0\"", builder.getClassByName("Foo").getAnnotations()[0].getProperty("run").getParameterValue());
+ }
+
+ // from QDOX-135
+ public void testAnnotationInMethodParamList() {
+ String source = ""
+ + "class Foo {\n"
+ + " @X()\n"
+ + " public String xyz(@Y(1) int blah) {\n"
+ + " }\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass clazz = builder.getClassByName("Foo");
+ JavaMethod mth = clazz.getMethods()[0];
+ assertEquals("Foo", clazz.getName());
+ assertEquals("X", mth.getAnnotations()[0].getType().getJavaClass().getName());
+ }
+
+ // from QDOX-142
+ public void testEmptyParameterListAnnotation() throws Exception {
+ String source = "@MyAnnotation()\n" +
+ "public class MyClass {}";
+ builder.addSource(new StringReader(source));
+ assertEquals("MyAnnotation", builder.getClasses()[0].getAnnotations()[0].getType().getValue());
+ }
+
+ public void testMethodAnnotationBeforeComment() throws Exception {
+ String source = "class Foo {\n" +
+ "@Override\n" +
+ "/**\n" +
+ " * " +
+ " */" +
+ " public boolean isPostback() { return true;}\n" +
+ "}";
+ builder.addSource(new StringReader(source));
+ assertEquals("java.lang.Override", builder.getClasses()[0].getMethods()[0].getAnnotations()[0].getType().getValue());
+ }
+
+ public void testEnumsWithAnnotations() throws Exception {
+ String source="class Foo {\n" +
+ " public enum BasicType {\n" +
+ " @XmlEnumValue(\"text\")\n" +
+ " TEXT(\"text\"),\n" +
+ "" +
+ " @XmlEnumValue(\"value\")\n" +
+ " VALUE(\"value\") }\n" +
+ "}";
+ builder.addSource(new StringReader(source));
+ }
+
+ public void testParameterAnnotations() throws Exception {
+ String source = "class Foo {\n" +
+ " @NativeAccessible\n" +
+ " static void get_tmp_dir( String targetfilename, @ParamInfo( direction = ParamInfo.Direction.OUT ) byte[] tmpDirOutput ) throws IOException {}\n" +
+ "}";
+ builder.addSource( new StringReader( source ) );
+ JavaMethod jMethod = builder.getClasses()[0].getMethods()[0];
+ assertEquals( "NativeAccessible", jMethod.getAnnotations()[0].getType().getValue() );
+ Annotation annotation = jMethod.getParameters()[1].getAnnotations()[0];
+ assertEquals( "ParamInfo", annotation.getType().getValue() );
+ assertEquals( "ParamInfo.Direction.OUT", annotation.getProperty( "direction" ).getParameterValue() );
+ }
+
+ public void testFieldRefAnnotation() throws Exception {
+ String source = "public class Foo {\n" +
+ " final String s = \"unchecked\";\n" +
+ " @SuppressWarnings( s )\n" +
+ " public void testNothing() { }\n " +
+ "}";
+ builder.addSource( new StringReader( source ) );
+ JavaMethod method = builder.getClasses()[0].getMethods()[0];
+ AnnotationFieldRef suppressWarnings = (AnnotationFieldRef) method.getAnnotations()[0].getProperty( "value" );
+ assertEquals( builder.getClasses()[0].getFields()[0], suppressWarnings.getField());
+ }
+
+ public void testDoubleEscapedString() throws Exception {
+ JavaDocBuilder builder = new JavaDocBuilder();
+ String source = "public class Foo {\n" +
+ "@SuppressWarnings({\"abc\\\\d\"})\n" +
+ "private void bar() { } }";
+ builder.addSource( new StringReader(source) );
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/ClassResolutionTest.java b/src/test/com/thoughtworks/qdox/ClassResolutionTest.java
new file mode 100644
index 0000000..8c27b69
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/ClassResolutionTest.java
@@ -0,0 +1,96 @@
+package com.thoughtworks.qdox;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.Type;
+
+public class ClassResolutionTest extends TestCase {
+
+ public void testNestedClassesResolvedAcrossPackageBoundaries() {
+
+ // input sources
+ String source1 = ""
+ + "package package1;"
+ + "public class Class1 {"
+ + " public static final class NestedClass {}"
+ + "}";
+
+ String source2 = ""
+ + "package package2;"
+ + "import package1.Class1;"
+ + "public class Class2 {"
+ + " public void doStuff(Class1.NestedClass arg) {}"
+ + "}";
+
+ // parse
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(new StringReader(source1));
+ builder.addSource(new StringReader(source2));
+
+ // find the parameter
+ JavaClass class2 = builder.getClassByName("package2.Class2");
+ JavaMethod method = class2.getMethods()[0];
+ JavaParameter parameter = method.getParameters()[0];
+ Type type = parameter.getType();
+
+ // verify
+ assertEquals("Should include fully qualified name", "package1.Class1$NestedClass", type.getFullyQualifiedName());
+ }
+
+ public void testSurvivesStaticImports() {
+
+ // input sources
+ String source = ""
+ + "package package2;"
+ + "import static package1.Class1.VALUE;"
+ + "public class Class2 {"
+ + " public void doStuff(String arg) {}"
+ + "}";
+
+ // parse
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(new StringReader(source));
+
+ // find the parameter
+ JavaClass class2 = builder.getClassByName("package2.Class2");
+ assertNotNull(class2);
+ }
+
+ public void testAnonymousClass() {
+ JavaDocBuilder builder = new JavaDocBuilder();
+
+ String source = ""
+ + "public class AnimatedAlgorithm {\n"
+ + " private SelectionListener mySelectionListener = new SelectionListenerAdapter() {\n"
+ + " public void selectionEvent() {\n"
+ + " for (int i = 0; i < recalcers.size(); i++) {\n"
+ + " int something = 5;"
+ + " }\n"
+ + " }\n"
+ + " };\n"
+ + "}";
+
+ builder.addSource(new StringReader(source));
+ }
+
+ //from QDOX-86
+ public void testInnerClassInMethod() throws Exception {
+ JavaDocBuilder builder = new JavaDocBuilder();
+ String source = "package some.pack;\n" +
+ "class Test {\n" +
+ "void some(Inner.Inner2 a) {}\n" +
+ "static interface Inner {\n" +
+ "static interface Inner2 { }\n" +
+ "}\n" +
+ "}";
+ builder.addSource(new StringReader(source));
+ JavaMethod method = builder.getClassByName("some.pack.Test").getMethods()[0];
+ JavaParameter parameter = method.getParameters()[0];
+ assertEquals("some.pack.Test$Inner$Inner2", parameter.getType().getJavaClass().getFullyQualifiedName());
+ }
+}
diff --git a/src/test/java/com/thoughtworks/qdox/EnumsModelTest.java b/src/test/com/thoughtworks/qdox/EnumsModelTest.java
similarity index 75%
rename from src/test/java/com/thoughtworks/qdox/EnumsModelTest.java
rename to src/test/com/thoughtworks/qdox/EnumsModelTest.java
index bebc148..9f160cb 100644
--- a/src/test/java/com/thoughtworks/qdox/EnumsModelTest.java
+++ b/src/test/com/thoughtworks/qdox/EnumsModelTest.java
@@ -1,10 +1,9 @@
package com.thoughtworks.qdox;
-import java.io.StringReader;
-import java.util.List;
-
import junit.framework.TestCase;
+import java.io.StringReader;
+
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaField;
@@ -20,7 +19,7 @@ public class EnumsModelTest extends TestCase {
+ "public enum Enum1 {}\n"
+ "enum Enum2 {;}\n";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass enum1 = javaDocBuilder.getClassByName("Enum1");
@@ -38,7 +37,7 @@ public class EnumsModelTest extends TestCase {
+ " int someField; "
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("X");
@@ -50,28 +49,28 @@ public class EnumsModelTest extends TestCase {
//---
- List<JavaField> fields1 = enum1.getFields();
+ JavaField fields1[] = enum1.getFields();
// printFields( fields1 );
- assertEquals(2, fields1.size());
+ assertEquals(2, fields1.length);
- JavaField enum1a = fields1.get(0);
+ JavaField enum1a = fields1[0];
assertNull( enum1a.getComment() );
- assertEquals( 1, enum1a.getModifiers().size() );
- assertEquals( "public", enum1a.getModifiers().get(0) );
- assertEquals( 0, enum1a.getAnnotations().size() );
+ assertEquals( 1, enum1a.getModifiers().length );
+ assertEquals( "public", enum1a.getModifiers()[0] );
+ assertEquals( 0, enum1a.getAnnotations().length );
assertEquals( "Enum1", enum1a.getType().toString() );
assertEquals( "a", enum1a.getName() );
//---
- List<JavaField> fields2 = enum2.getFields();
+ JavaField fields2[] = enum2.getFields();
// printFields( fields2 );
- assertEquals(2, fields2.size());
+ assertEquals(2, fields2.length);
- JavaField enum2d = fields2.get(1);
+ JavaField enum2d = fields2[1];
assertNotNull( enum2d.getComment() );
- assertEquals( 0, enum2d.getModifiers().size() );
- assertEquals( 0, enum2d.getAnnotations().size() );
+ assertEquals( 0, enum2d.getModifiers().length );
+ assertEquals( 0, enum2d.getAnnotations().length );
assertEquals( "X$Enum2", enum2d.getType().getFullyQualifiedName() );
assertEquals( "d", enum2d.getName() );
@@ -82,7 +81,7 @@ public class EnumsModelTest extends TestCase {
String source = ""
+ "public enum Enum1 implements java.io.Serializable { a, b }";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("Enum1");
@@ -90,11 +89,15 @@ public class EnumsModelTest extends TestCase {
assertTrue(cls.isA("java.io.Serializable"));
}
+/*
+ //
+ // Annotations on enums are not supported as of QDox 1.7 (2008-11-12)
+ //
public void testAddEnumWithAnnotationToModel() {
String source = ""
+ "public enum Enum1 implements java.io.Serializable { a, @Deprecated b }";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("Enum1");
@@ -103,21 +106,22 @@ public class EnumsModelTest extends TestCase {
//---
- List<JavaField> fields = cls.getFields();
+ JavaField fields[] = cls.getFields();
// printFields( fields );
- assertEquals(2, fields.size());
+ assertEquals(2, fields.length);
- JavaField enum1b = fields.get(1);
+ JavaField enum1b = fields[1];
assertNull( enum1b.getComment() );
- assertEquals( 1, enum1b.getModifiers().size() );
- assertEquals( "public", enum1b.getModifiers().get(0) );
- assertEquals( 1, enum1b.getAnnotations().size() );
- assertEquals( "@java.lang.Deprecated()", enum1b.getAnnotations().get(0).toString() );
+ assertEquals( 1, enum1b.getModifiers().length );
+ assertEquals( "public", enum1b.getModifiers()[0] );
+ assertEquals( 1, enum1b.getAnnotations().length );
+ assertEquals( "@java.lang.Deprecated()", enum1b.getAnnotations()[0].toString() );
assertEquals( "Enum1", enum1b.getType().toString() );
assertEquals( "b", enum1b.getName() );
//---
}
+*/
public void testAddEnumWithFieldAndConstructorsToModel() {
@@ -135,7 +139,7 @@ public class EnumsModelTest extends TestCase {
+ " }\n"
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("X$EnumWithConstructors");
@@ -144,22 +148,22 @@ public class EnumsModelTest extends TestCase {
//---
- List<JavaField> fields = cls.getFields();
+ JavaField fields[] = cls.getFields();
// printFields( fields );
- assertEquals(3, fields.size()); // includes c, d, and someField
+ assertEquals(3, fields.length); // includes c, d, and someField
- JavaField enum1c = fields.get(0);
+ JavaField enum1c = fields[0];
assertNull( enum1c.getComment() );
- assertEquals( 0, enum1c.getModifiers().size() );
- assertEquals( 0, enum1c.getAnnotations().size() );
+ assertEquals( 0, enum1c.getModifiers().length );
+ assertEquals( 0, enum1c.getAnnotations().length );
assertEquals( "X$EnumWithConstructors", enum1c.getType().getFullyQualifiedName() );
assertEquals( "c", enum1c.getName() );
//---
- JavaField enum1d = fields.get(1);
+ JavaField enum1d = fields[1];
assertNull( enum1d.getComment() );
- assertEquals( 0, enum1d.getModifiers().size() );
+ assertEquals( 0, enum1d.getModifiers().length );
assertEquals( "X$EnumWithConstructors", enum1d.getType().getFullyQualifiedName() );
assertEquals( "d", enum1d.getName() );
@@ -176,7 +180,7 @@ public class EnumsModelTest extends TestCase {
+ " public abstract void speak();\n"
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("Animal");
@@ -193,7 +197,7 @@ public class EnumsModelTest extends TestCase {
"@MyAnno\n" +
"TEST;\n" +
"}\n";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
}
diff --git a/src/test/java/com/thoughtworks/qdox/EnumsTest.java b/src/test/com/thoughtworks/qdox/EnumsTest.java
similarity index 66%
rename from src/test/java/com/thoughtworks/qdox/EnumsTest.java
rename to src/test/com/thoughtworks/qdox/EnumsTest.java
index b1e1eee..1fb539a 100644
--- a/src/test/java/com/thoughtworks/qdox/EnumsTest.java
+++ b/src/test/com/thoughtworks/qdox/EnumsTest.java
@@ -1,25 +1,26 @@
package com.thoughtworks.qdox;
-import java.io.StringReader;
-
import junit.framework.TestCase;
+import java.io.StringReader;
+
import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.parser.Lexer;
+import com.thoughtworks.qdox.parser.impl.JFlexLexer;
public class EnumsTest extends TestCase {
public void testAddEmptyEnumsToModel() {
+
String source = ""
+ "public enum Enum1 {}\n"
- + "enum Enum2 {;}\n"
- + "private enum Enum3 {,}";
+ + "enum Enum2 {;}\n";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
assertTrue(javaDocBuilder.getClassByName("Enum1").isEnum());
assertTrue(javaDocBuilder.getClassByName("Enum2").isEnum());
- assertTrue(javaDocBuilder.getClassByName("Enum3").isEnum());
}
public void testAddSimpleEnumsToModel() {
@@ -31,7 +32,7 @@ public class EnumsTest extends TestCase {
+ " int someField; "
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("X");
@@ -44,7 +45,7 @@ public class EnumsTest extends TestCase {
String source = ""
+ "public enum Enum1 implements java.io.Serializable { a, b }";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("Enum1");
@@ -56,7 +57,7 @@ public class EnumsTest extends TestCase {
String source = ""
+ "public enum Enum1 implements java.io.Serializable { a, @Deprecated b }";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("Enum1");
@@ -80,17 +81,12 @@ public class EnumsTest extends TestCase {
+ " }\n"
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
JavaClass cls = javaDocBuilder.getClassByName("X$EnumWithConstructors");
assertTrue(cls.isEnum());
- assertEquals( 3, cls.getFields().size() );
- assertEquals( 2, cls.getConstructors().size() );
assertEquals("int", cls.getFieldByName("someField").getType().getValue()); // sanity check
- assertTrue( "c should be recognized as a enumConstant", cls.getFieldByName( "c" ).isEnumConstant() );
- assertTrue( "d should be recognized as a enumConstant", cls.getFieldByName( "d" ).isEnumConstant() );
- assertFalse( cls.getFieldByName( "someField" ).isEnumConstant() );
}
public void testAddEnumsWithMethodsToModel() throws Exception {
@@ -103,7 +99,7 @@ public class EnumsTest extends TestCase {
+ " public abstract void speak();\n"
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
assertTrue(javaDocBuilder.getClassByName("Animal").isEnum());
@@ -119,7 +115,7 @@ public class EnumsTest extends TestCase {
+ "\n"
+ "}";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
assertTrue(javaDocBuilder.getClassByName("AccountType").isEnum());
@@ -130,7 +126,7 @@ public class EnumsTest extends TestCase {
String source = ""
+ "public enum Foo { BAR }\n";
- JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
javaDocBuilder.addSource(new StringReader(source));
assertTrue(javaDocBuilder.getClassByName("Foo").isEnum());
@@ -147,7 +143,7 @@ public class EnumsTest extends TestCase {
"static class AnnotationContainer" +
"{ @ValueHintEnum(values = TestValueSet.class) String hint; }" +
"}";
- new JavaProjectBuilder().addSource(new StringReader(source));
+ new JavaDocBuilder().addSource(new StringReader(source));
}
public void testEnumAfterClass() throws Exception {
@@ -160,7 +156,7 @@ public class EnumsTest extends TestCase {
"public enum TestValueSet" +
"{ VALUE_1 }" +
"}";
- new JavaProjectBuilder().addSource(new StringReader(source));
+ new JavaDocBuilder().addSource(new StringReader(source));
}
//for QDOX-153
@@ -173,45 +169,6 @@ public class EnumsTest extends TestCase {
" public FacesCompositeELResolver(final Scope scope) {}\n" +
"}";
- new JavaProjectBuilder().addSource(new StringReader(source));
+ new JavaDocBuilder().addSource(new StringReader(source));
}
-
- // QDOX-240
- public void testObjectCreation()
- {
- String source="package simpleenum;\r\n" +
- "import java.util.Date;\r\n" +
- "public enum MinimalEnumExampleConstructor\r\n" +
- "{\r\n" +
- " D_CONSTRUCTOR(new Date()); // FAILS to be parsed\r\n" +
- " private final Date date;\r\n" +
- " private MinimalEnumExampleConstructor(final Date date)\r\n" +
- " {\r\n" +
- " this.date = date;\r\n" +
- " }\r\n" +
- "}";
- new JavaProjectBuilder().addSource(new StringReader(source));
- }
-
- // QDOX-240
- public void testMethodInvocation()
- {
- String source="package simpleenum;\r\n" +
- "import java.util.Date;\r\n" +
- "public enum MinimalEnumExampleMethod\r\n" +
- "{\r\n" +
- " D_METHOD(create()); // FAILS to be parsed\r\n" +
- " private final Date date;\r\n" +
- " private MinimalEnumExampleMethod(final Date date)\r\n" +
- " {\r\n" +
- " this.date = date;\r\n" +
- " }\r\n" +
- " public static Date create()\r\n" +
- " {\r\n" +
- " return new Date();\r\n" +
- " }\r\n" +
- "}";
- new JavaProjectBuilder().addSource(new StringReader(source));
- }
-
}
diff --git a/src/test/com/thoughtworks/qdox/FieldsTest.java b/src/test/com/thoughtworks/qdox/FieldsTest.java
new file mode 100644
index 0000000..a8f25de
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/FieldsTest.java
@@ -0,0 +1,61 @@
+/**
+ * $Id: FieldsTest.java 16 2008-02-20 17:57:08Z louis $
+ */
+
+package com.thoughtworks.qdox;
+
+import junit.framework.TestCase;
+import com.thoughtworks.qdox.model.*;
+
+import java.io.StringReader;
+
+public class FieldsTest extends TestCase
+{
+ private JavaDocBuilder builder = new JavaDocBuilder();
+
+ public void testAssignmentViaBitShift() {
+ String source = ""
+ + "public class X {\n"
+ + " Object b = new Object();\n"
+ + " int a = 1 << 30;\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass fooClass = builder.getClassByName("X");
+ assertEquals("X", fooClass.getName());
+ assertEquals("a", fooClass.getFieldByName("a").getName());
+ assertEquals("1 << 30", fooClass.getFieldByName("a").getInitializationExpression().trim());
+ }
+
+ // from QDOX-114
+ public void testNewArrayWithBitShift() {
+ String source = ""
+ + "public class X {\n"
+ + " int a[] = new int[1 << 16];\n"
+ + "}\n";
+
+ builder.addSource(new StringReader(source));
+ JavaClass fooClass = builder.getClassByName("X");
+ assertEquals("X", fooClass.getName());
+ assertEquals("a", fooClass.getFieldByName("a").getName());
+ assertEquals("new int[1 << 16]", fooClass.getFieldByName("a").getInitializationExpression().trim());
+ }
+
+ //from QDOX-127
+ //fails because returned value is " null"
+ //which is already better then mentioned in the issue
+ public void testCommentBeforeInitialization() throws Exception {
+ String source = "public class X{\n" +
+ "// Attributes\n" +
+ "\n" +
+ "/**" +
+ "* Some decription" +
+ "*/" +
+ "private String uDI = null;\n" +
+ "}";
+
+ builder.addSource(new StringReader(source));
+ JavaField field = builder.getClasses()[0].getFields()[0];
+ assertEquals("null", field.getInitializationExpression());
+ }
+}
diff --git a/src/test/java/com/thoughtworks/qdox/GenericsTest.java b/src/test/com/thoughtworks/qdox/GenericsTest.java
similarity index 85%
rename from src/test/java/com/thoughtworks/qdox/GenericsTest.java
rename to src/test/com/thoughtworks/qdox/GenericsTest.java
index e252279..b9ec874 100644
--- a/src/test/java/com/thoughtworks/qdox/GenericsTest.java
+++ b/src/test/com/thoughtworks/qdox/GenericsTest.java
@@ -1,18 +1,12 @@
package com.thoughtworks.qdox;
-import static org.mockito.Mockito.*;
-
-import java.io.StringReader;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaField;
import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameterizedType;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaWildcardType;
+
+import junit.framework.TestCase;
+
+import java.io.StringReader;
/**
* @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
@@ -21,7 +15,7 @@ import com.thoughtworks.qdox.model.JavaWildcardType;
*/
public class GenericsTest extends TestCase {
- private JavaProjectBuilder builder = new JavaProjectBuilder();
+ private JavaDocBuilder builder = new JavaDocBuilder();
public void testShouldUnderstandSingleGenericClassDeclarations() {
String source = "" +
@@ -285,7 +279,6 @@ public class GenericsTest extends TestCase {
assertEquals( "java.lang.String", method.getReturnType( true ).getFullyQualifiedName() );
}
- //GWT-186
public void testMethodReturnTypeImplements() throws Exception {
String source1="public interface GenericDao<TEntity, TKey> {\n" +
"public List<TEntity> getAll();\n" +
@@ -316,22 +309,14 @@ public class GenericsTest extends TestCase {
method = builder.getClassByName( "SubjectDao" ).getMethodBySignature( "getAll", null, true );
assertEquals( "List<Subject>", method.getReturnType( true ).getGenericValue() );
method = builder.getClassByName( "SubjectDao" ).getMethodBySignature( "asMap", null, true );
- assertEquals( "Map<java.lang.Long,Subject>", method.getReturnType( true ).getGenericFullyQualifiedName() );
- assertEquals( "Map<Long,Subject>", method.getReturnType( true ).getGenericValue() );
+ assertEquals( "Map<java.lang.Long,Subject>", method.getReturnType( true ).getGenericValue() );
method = builder.getClassByName( "SubjectService" ).getMethodBySignature( "getRandom", null, true );
assertEquals( "Subject", method.getReturnType( true ).getGenericValue() );
method = builder.getClassByName( "SubjectService" ).getMethodBySignature( "getAll", null, true );
assertEquals( "List<Subject>", method.getReturnType( true ).getGenericValue() );
method = builder.getClassByName( "SubjectService" ).getMethodBySignature( "asMap", null, true );
- assertEquals( "Map<java.lang.Long,Subject>", method.getReturnType( true ).getGenericFullyQualifiedName() );
- assertEquals( "Map<Long,Subject>", method.getReturnType( true ).getGenericValue() );
-
- JavaType tEntity = mock( JavaType.class );
- when( tEntity.getFullyQualifiedName() ).thenReturn( "TEntity[]" );
- method = builder.getClassByName( "SubjectDao" ).getMethodBySignature( "persist", Collections.singletonList( tEntity ), true );
- assertNotNull( method );
- assertEquals( "Subject[]", method.getParameterTypes( true ).get( 0 ).getGenericFullyQualifiedName() );
+ assertEquals( "Map<java.lang.Long,Subject>", method.getReturnType( true ).getGenericValue() );
}
//for QDOX-210
@@ -350,39 +335,19 @@ public class GenericsTest extends TestCase {
"}";
String source3="public interface SubjectService extends RemoteService, SubjectDao {\r\n" +
"}";
- String source4="public interface RemoteService {}";
builder.addSource( new StringReader( source1 ) );
builder.addSource( new StringReader( source2 ) );
builder.addSource( new StringReader( source3 ) );
- builder.addSource( new StringReader( source4 ) );
JavaClass clazz = builder.getClassByName( "SubjectService" );
- JavaMethod method = clazz.getMethods( true ).get(0);
+ JavaMethod method = clazz.getMethods( true )[0];
assertEquals( "getAll", method.getName() );
- assertEquals( "java.util.List<Subject>", method.getReturnType( true ).getGenericFullyQualifiedName() );
- assertEquals( "List<Subject>", method.getReturnType( true ).getGenericValue() );
- method = clazz.getMethods( true ).get(2);
+ assertEquals( "java.util.List<Subject>", method.getReturnType( true ).getGenericValue() );
+ method = clazz.getMethods( true )[2];
assertEquals( "findById", method.getName() );
- assertEquals( "java.lang.Long", method.getParameterTypes( true ).get(0).getGenericFullyQualifiedName() );
- assertEquals( "Long", method.getParameterTypes( true ).get(0).getGenericValue() );
+ assertEquals( "java.lang.Long", method.getParameterTypes( true )[0].getGenericValue() );
}
- // for QDOX-239
- public void testFieldWithWildcardType()
- {
- StringBuilder b = new StringBuilder("package test;\n");
- b.append("import java.util.ArrayList;\n");
- b.append("import java.util.Map;\n");
- b.append("public class TestClass<E>{\n");
- b.append("public ArrayList<? extends Map<String, E>> list;\n}");
- builder.addSource(new StringReader(b.toString()));
- JavaClass javaClass = builder.getClassByName( "test.TestClass" );
- JavaField field = javaClass.getFields().get( 0 );
- assertTrue( field.getType() instanceof JavaParameterizedType );
- JavaParameterizedType paramType = (JavaParameterizedType) field.getType();
- assertTrue( paramType.getActualTypeArguments().get( 0 ) instanceof JavaWildcardType);
- JavaWildcardType wildcardType = (JavaWildcardType) paramType.getActualTypeArguments().get( 0 );
- assertEquals("? extends java.util.Map<java.lang.String,E>", wildcardType.getGenericFullyQualifiedName() );
- }
+
}
diff --git a/src/test/com/thoughtworks/qdox/JSR14Test.java b/src/test/com/thoughtworks/qdox/JSR14Test.java
new file mode 100644
index 0000000..4b348c1
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/JSR14Test.java
@@ -0,0 +1,405 @@
+package com.thoughtworks.qdox;
+
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaField;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.Type;
+/**
+ * QDOX-54 Support for retrieval of generic type information (JSR 14)
+ *
+ * Some core-classes have been changed, but most interfaces are kept the same.
+ * Most important is the method Type.getGenericValue(), which does exactly what it says.
+ * The WildcardType is added as a subclass of Type. This way we can easily define these types of Types
+ *
+ *
+ * @author Robert Scholte
+ *
+ */
+public class JSR14Test extends TestCase {
+
+ private JavaDocBuilder builder = new JavaDocBuilder();
+
+ public void testSimpleSingleParameterizedTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.List<String> getList();");
+ assertEquals("java.util.List<java.lang.String>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testSimpleWildcardTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.List<?> getList();");
+ assertEquals("java.util.List<?>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testSimpleExtendsWildcardTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.List<? extends Number> getList();");
+ assertEquals("java.util.List<? extends java.lang.Number>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testSimpleSuperWildcardTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.List<? super Integer> getList();");
+ assertEquals("java.util.List<? super java.lang.Integer>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testSimpleMultiParameterizedTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.Map<String, Object> getMap();");
+ assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testComplexSingleParameterizedTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.List<java.util.Set<String>> getList();");
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaMethod.getReturns().getGenericValue());
+ }
+
+ public void testComplexMultiParameterizedTypeMethod() throws Exception {
+ JavaMethod javaMethod = buildMethod("java.util.Map<String, java.util.Iterator<Number>> getMap();");
+ assertEquals("java.util.Map<java.lang.String,java.util.Iterator<java.lang.Number>>", javaMethod.getReturns().getGenericValue());
+ }
+
+ private JavaMethod buildMethod(String methodSource) {
+ String source = "interface Something { " + methodSource + " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
+ return javaMethod;
+ }
+
+ public void testSimpleSingleParameterizedTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<String> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<java.lang.String>", javaField.getType().getGenericValue());
+ }
+
+ public void testSimpleMultiParameterizedTypeField() {
+ String source = "public class Something { " +
+ "public java.util.Map<String, Object> aMap;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aMap");
+ assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaField.getType().getGenericValue());
+ }
+
+ public void testSimpleWildcardTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<?> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<?>", javaField.getType().getGenericValue());
+ }
+
+ public void testSimpleExtendsWildcardTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<? extends Number> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<? extends java.lang.Number>", javaField.getType().getGenericValue());
+ }
+
+ public void testSimpleSuperWildcardTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<? super Integer> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<? super java.lang.Integer>", javaField.getType().getGenericValue());
+ }
+
+ public void testComplexSingleParameterizedTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<java.util.Set<String>> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaField.getType().getGenericValue());
+ }
+
+ public void testComplexMultiParameterizedTypeField() throws Exception {
+ String source = "public class Something { " +
+ "public java.util.List<java.util.Set<String>> aList;" +
+ " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFieldByName("aList");
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaField.getType().getGenericValue());
+ }
+
+ public void testSimpleSingleParameterizedTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setList(java.util.List<String> aList);");
+ assertEquals("java.util.List<java.lang.String>", javaMethod.getParameterByName("aList").getType().getGenericValue());
+ }
+
+ public void testSimpleWildcardTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setList(java.util.List<?> aList);");
+ assertEquals("java.util.List<?>", javaMethod.getParameterByName("aList").getType().getGenericValue());
+ }
+
+ public void testSimpleExtendsWildcardTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setList(java.util.List<? extends Number> aList);");
+ assertEquals("java.util.List<? extends java.lang.Number>", javaMethod.getParameterByName("aList").getType().getGenericValue());
+ }
+
+ public void testSimpleSuperWildcardTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setList(java.util.List<? super Integer> aList);");
+ assertEquals("java.util.List<? super java.lang.Integer>", javaMethod.getParameterByName("aList").getType().getGenericValue());
+ }
+
+ public void testSimpleMultiParameterizedTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setMap(java.util.Map<String, Object> aMap);");
+ assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaMethod.getParameterByName("aMap").getType().getGenericValue());
+ }
+
+ public void testComplexSingleParameterizedTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setList(java.util.List<java.util.Set<String>> aList);");
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaMethod.getParameterByName("aList").getType().getGenericValue());
+ }
+
+ public void testComplexMultiParameterizedTypeParameter() throws Exception {
+ JavaMethod javaMethod = buildMethod("void setMap(java.util.Map<String, java.util.Iterator<Number>> aMap);");
+ assertEquals("java.util.Map<java.lang.String,java.util.Iterator<java.lang.Number>>", javaMethod.getParameterByName("aMap").getType().getGenericValue());
+ }
+
+ public void testSimpleSingleParameterizedTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<String> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<java.lang.String>", superClass.getGenericValue());
+ }
+
+ public void testSimpleMultiParameterizedTypeClassExtends() {
+ String source = "public class Something extends java.util.Map<String, Object> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.Map<java.lang.String,java.lang.Object>", superClass.getGenericValue());
+ }
+
+ public void testSimpleWildcardTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<?>{}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<?>", superClass.getGenericValue());
+ }
+
+ public void testSimpleExtendsWildcardTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<? extends Number> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<? extends java.lang.Number>", superClass.getGenericValue());
+ }
+
+ public void testSimpleSuperWildcardTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<? super Integer> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<? super java.lang.Integer>", superClass.getGenericValue());
+ }
+
+ public void testComplexSingleParameterizedTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<java.util.Set<String>> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", superClass.getGenericValue());
+ }
+
+ public void testComplexMultiParameterizedTypeClassExtends() throws Exception {
+ String source = "public class Something extends java.util.List<java.util.Set<String>> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type superClass = javaClass.getSuperClass();
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", superClass.getGenericValue());
+ }
+
+ public void testSimpleSingleParameterizedTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<String> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<java.lang.String>", implementsClass.getGenericValue());
+ }
+
+ public void testSimpleMultiParameterizedTypeClassImplements() {
+ String source = "public class Something implements java.util.Map<String, Object> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.Map<java.lang.String,java.lang.Object>", implementsClass.getGenericValue());
+ }
+
+ public void testSimpleWildcardTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<?>{}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<?>", implementsClass.getGenericValue());
+ }
+
+ public void testSimpleExtendsWildcardTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<? extends Number> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<? extends java.lang.Number>", implementsClass.getGenericValue());
+ }
+
+ public void testSimpleSuperWildcardTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<? super Integer> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<? super java.lang.Integer>", implementsClass.getGenericValue());
+ }
+
+ public void testComplexSingleParameterizedTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<java.util.Set<String>> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", implementsClass.getGenericValue());
+ }
+
+ public void testComplexMultiParameterizedTypeClassImplements() throws Exception {
+ String source = "public class Something implements java.util.List<java.util.Set<String>> {}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ Type implementsClass = javaClass.getImplements()[0];
+ assertEquals("java.util.List<java.util.Set<java.lang.String>>", implementsClass.getGenericValue());
+ }
+
+ public void testSimpleTypeVariable() throws Exception {
+ String source = "public class Something {\n" +
+ " public <T extends StringBuffer> void doStuff(T param) {}\n" +
+ "}";
+
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaMethod javaMethod = javaSource.getClasses()[0].getMethods()[0];
+ assertEquals(1, javaMethod.getTypeParameters().length);
+ assertEquals("java.lang.StringBuffer", javaMethod.getTypeParameters()[0].getValue());
+ assertEquals("<T extends java.lang.StringBuffer>", javaMethod.getTypeParameters()[0].getGenericValue());
+
+ }
+
+ public void testComplexTypeVariable() throws Exception {
+ String source = "class Collections {\n" +
+ "public static <T, S extends T> void copy(List<T> dest, List<S> src){}\n" +
+ "}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaMethod javaMethod = javaSource.getClasses()[0].getMethods()[0];
+ assertEquals("T", javaMethod.getTypeParameters()[0].getName());
+ assertEquals("S", javaMethod.getTypeParameters()[1].getName());
+ assertEquals("T", javaMethod.getTypeParameters()[1].getValue());
+ }
+
+ public void testComplexTypeVariableMultipleBounds() throws Exception {
+ String source = "class Collections\n" +
+ "public static <T extends Object & Comparable<? super T>>\n" +
+ "T max(Collection<? extends T> coll) {\n" +
+ "return null;}\n";
+
+ }
+
+ //for qdox-150
+ // second assert is based on java's Method.toString()
+ // http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#toString()
+ // 3rd and 4th are resolved Types, based on <T extends StringBuffer> in method
+ public void testGenericMethodDeclarationSingleParameter() throws Exception {
+ String source = "package com.thoughtworks.qdox;" +
+ "import java.util.*;\n" +
+ "public class TestQDOX150 {\n" +
+ " public <T extends StringBuffer> List<StringBuffer> myMethod( T request ) throws Exception {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
+ JavaParameter paramType = javaMethod.getParameters()[0];
+ Type returnType = javaMethod.getReturns();
+ assertEquals("myMethod(request)", javaMethod.getCallSignature());
+ assertEquals("public java.util.List com.thoughtworks.qdox.TestQDOX150.myMethod(java.lang.StringBuffer) throws java.lang.Exception", javaMethod.toString());
+ assertEquals("java.lang.StringBuffer", paramType.getResolvedValue());
+ assertEquals("<T extends java.lang.StringBuffer>", paramType.getResolvedGenericValue());
+ assertEquals("java.util.List", returnType.getValue());
+ assertEquals("java.util.List<java.lang.StringBuffer>", returnType.getGenericValue());
+ }
+
+ public void testGenericMethodDeclarationMultipleParameters() throws Exception {
+ String source = "package com.thoughtworks.qdox;" +
+ "import java.util.*;\n" +
+ "public class TestQDOX150 {\n" +
+ " public <T extends StringBuffer> List<StringBuffer> myMethod( T request, List<T> list ) throws Exception {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
+ JavaParameter paramType = javaMethod.getParameters()[1];
+ assertEquals("myMethod(request, list)", javaMethod.getCallSignature());
+ assertEquals("public java.util.List com.thoughtworks.qdox.TestQDOX150.myMethod(java.lang.StringBuffer,java.util.List) throws java.lang.Exception", javaMethod.toString());
+ assertEquals("java.util.List", paramType.getResolvedValue());
+ assertEquals("java.util.List<T extends java.lang.StringBuffer>", paramType.getResolvedGenericValue());
+ }
+
+ //for QDOX-167
+ public void testGenericTypedMethodCall() throws Exception {
+ String source = "import java.util.*;\n" +
+ "\n" +
+ "public class MyClass\n" +
+ "{\n" +
+ "\n" +
+ " private static final Map<String, String> map1 = Collections.<String, String>emptyMap();\n" +
+ "\n" +
+ " private static final Map<?, ?> map2 = Collections. <String, String> emptyMap();\n" +
+ "\n" +
+ "}";
+ builder.addSource(new StringReader(source));
+ }
+
+ // For QDox-205
+ public void testClassTypeParameters() throws Exception {
+ String source1 = "class GenericControllerImpl<T, K, D extends GenericDAO<T, K>>\n" +
+ " implements GenericController<T, K>\n {}";
+ String source2 = "class GroupControllerImpl extends\n" +
+ " GenericControllerImpl<Group, Long, GroupDAO>\n {}";
+ String source3 = "interface GenericController<T, K> {}";
+ builder.addSource(new StringReader(source1));
+ builder.addSource(new StringReader(source2));
+ builder.addSource(new StringReader(source3));
+ JavaClass genericControllerImpl = builder.getSources()[0].getClasses()[0];
+ assertEquals( 3, genericControllerImpl.getTypeParameters().length );
+ JavaClass groupControllerImpl = builder.getSources()[1].getClasses()[0];
+ assertEquals( 0, groupControllerImpl.getTypeParameters().length );
+ JavaClass genericController = builder.getSources()[2].getClasses()[0];
+ assertEquals( 2, genericController.getTypeParameters().length );
+ }
+
+ // For QDOX-206
+ public void testGenericsAndArrays() throws Exception {
+ JavaMethod method = buildMethod( "public Map<String[], Object[]> test(Map<String[], Object[]> input);" );
+ assertEquals("Map<java.lang.String[],java.lang.Object[]>", method.getReturns().toGenericString());
+ assertEquals("Map<java.lang.String[],java.lang.Object[]>", method.getParameters()[0].getType().toGenericString());
+ }
+}
diff --git a/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java b/src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java
similarity index 53%
rename from src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
rename to src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java
index 5ab3adc..207bbc9 100644
--- a/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
+++ b/src/test/com/thoughtworks/qdox/JavaDocBuilderTest.java
@@ -1,65 +1,36 @@
+
package com.thoughtworks.qdox;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.lang.reflect.Method;
-import java.lang.reflect.TypeVariable;
-import java.net.URL;
-import java.util.ArrayList;
+import com.thoughtworks.qdox.model.*;
+import com.thoughtworks.qdox.model.util.SerializationUtils;
+import com.thoughtworks.qdox.parser.ParseException;
+import com.thoughtworks.qdox.testdata.PropertyClass;
+
+import java.io.*;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.HashSet;
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.library.ClassLibraryBuilder;
-import com.thoughtworks.qdox.library.ErrorHandler;
-import com.thoughtworks.qdox.library.OrderedClassLibraryBuilder;
-import com.thoughtworks.qdox.model.BeanProperty;
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaGenericDeclaration;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaParameterizedType;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-import com.thoughtworks.qdox.model.util.SerializationUtils;
-import com.thoughtworks.qdox.parser.ParseException;
-import com.thoughtworks.qdox.testdata.PropertyClass;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
-public class JavaProjectBuilderTest extends TestCase
-{
+/**
+ * @author <a href="mailto:joew at thoughtworks.com">Joe Walnes</a>
+ * @author Aslak Hellesøy
+ */
+public class JavaDocBuilderTest extends MockObjectTestCase {
+
+ private JavaDocBuilder builder;
- private JavaProjectBuilder builder;
-
protected void setUp() throws Exception {
super.setUp();
- builder = new JavaProjectBuilder();
- createFile("target/test-source/com/blah/Another.java", "com.blah", "Another");
- createFile("target/test-source/com/blah/Ignore.notjava", "com.blah", "Ignore");
+ builder = new JavaDocBuilder();
createFile("target/test-source/com/blah/Thing.java", "com.blah", "Thing");
+ createFile("target/test-source/com/blah/Another.java", "com.blah", "Another");
createFile("target/test-source/com/blah/subpackage/Cheese.java", "com.blah.subpackage", "Cheese");
+ createFile("target/test-source/com/blah/Ignore.notjava", "com.blah", "Ignore");
}
protected void tearDown() throws Exception {
@@ -68,17 +39,16 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testParsingMultipleJavaFiles() {
- JavaSource source1 = builder.addSource(new StringReader(createTestClassList()));
- JavaSource source2 = builder.addSource(new StringReader(createTestClass()));
- Collection<JavaSource> sources = builder.getSources();
- assertEquals(2, sources.size());
+ builder.addSource(new StringReader(createTestClassList()));
+ builder.addSource(new StringReader(createTestClass()));
+ JavaSource[] sources = builder.getSources();
+ assertEquals(2, sources.length);
- JavaClass testClassList = source1.getClasses().get(0);
+ JavaClass testClassList = sources[0].getClasses()[0];
assertEquals("TestClassList", testClassList.getName());
- assertEquals("TestClass", testClassList.getSuperClass().getValue());
- assertEquals("com.thoughtworks.util.TestClass", testClassList.getSuperClass().getFullyQualifiedName());
+ assertEquals("com.thoughtworks.util.TestClass", testClassList.getSuperClass().getValue());
- JavaClass testClass = source2.getClasses().get(0);
+ JavaClass testClass = sources[1].getClasses()[0];
assertEquals("TestClass", testClass.getName());
JavaClass testClassListByName = builder.getClassByName("com.thoughtworks.qdox.TestClassList");
@@ -110,53 +80,57 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testParseWithInnerClass() {
- JavaSource source = builder.addSource(new StringReader(createOuter()));
- Collection<JavaSource> sources = builder.getSources();
- assertEquals(1, sources.size());
+ builder.addSource(new StringReader(createOuter()));
+ JavaSource[] sources = builder.getSources();
+ assertEquals(1, sources.length);
- JavaClass outer = source.getClasses().get(0);
+ JavaClass outer = sources[0].getClasses()[0];
assertEquals("Outer", outer.getName());
assertEquals("foo.bar.Outer", outer.getFullyQualifiedName());
- assertEquals(1, outer.getFields().size());
- assertEquals("int", outer.getFields().get(0).getType().getValue());
+ assertEquals(1, outer.getFields().length);
+ assertEquals("int", outer.getFields()[0].getType().getValue());
- assertEquals(1, outer.getMethods().size());
- assertEquals("outerMethod", outer.getMethods().get(0).getName());
+ assertEquals(1, outer.getMethods().length);
+ assertEquals("outerMethod", outer.getMethods()[0].getName());
- assertEquals(1, outer.getNestedClasses().size());
- JavaClass inner = outer.getNestedClasses().get(0);
+ assertEquals(1, outer.getNestedClasses().length);
+ JavaClass inner = outer.getNestedClasses()[0];
assertEquals("Inner", inner.getName());
assertEquals("foo.bar.Outer$Inner", inner.getFullyQualifiedName());
- assertEquals(1, inner.getMethods().size());
- assertEquals("innerMethod", inner.getMethods().get(0).getName());
+ assertEquals(1, inner.getMethods().length);
+ assertEquals("innerMethod", inner.getMethods()[0].getName());
}
public void testGetClasses() {
builder.addSource(new StringReader(createOuter()));
- Collection<JavaClass> classes = builder.getClasses();
- assertEquals(2, classes.size());
+ JavaClass[] classes = builder.getClasses();
+ assertEquals(2, classes.length);
}
public void testGetPackagesShowsOnePackageAndTwoClasses() {
builder.addSourceTree(new File("target/test-source"));
- Collection<JavaPackage> packages = builder.getPackages();
- assertEquals(2, packages.size());
- JavaPackage comBlah = builder.getPackageByName( "com.blah" );
- JavaPackage comBlahSubpackage = builder.getPackageByName( "com.blah.subpackage" );
+ JavaPackage[] packages = builder.getPackages();
+ assertEquals(2, packages.length);
+ JavaPackage comBlahSubpackage = packages[0];
assertEquals("com.blah.subpackage", comBlahSubpackage.getName());
- assertEquals(1, comBlahSubpackage.getClasses().size());
- assertNotNull("Cheese", comBlahSubpackage.getClassByName( "Cheese" ) );
- assertEquals(2, comBlah.getClasses().size());
- assertNotNull( comBlah.getClassByName( "Another" ));
- assertNotNull( comBlah.getClassByName( "Thing" ));
+ JavaPackage comBlah = packages[1];
+ assertEquals("com.blah", comBlah.getName());
+ JavaClass[] classes = comBlahSubpackage.getClasses();
+ assertEquals(1, classes.length);
+ assertEquals("Cheese", classes[0].getName());
+ classes = comBlah.getClasses();
+ assertEquals(2, classes.length);
+ assertEquals("Another", classes[0].getName());
+ assertEquals("Thing", classes[1].getName());
assertEquals(comBlah, comBlahSubpackage.getParentPackage());
assertNull(comBlah.getParentPackage());
- Collection<JavaPackage> comBlahSubpackages = comBlah.getSubPackages();
- assertEquals(1, comBlahSubpackages.size());
- assertEquals(comBlahSubpackage, comBlahSubpackages.iterator().next());
- assertEquals(0, comBlahSubpackage.getSubPackages().size());
+ JavaPackage[] comBlahSubpackages = comBlah.getSubPackages();
+ assertEquals(1, comBlahSubpackages.length);
+ assertEquals(comBlahSubpackage, comBlahSubpackages[0]);
+ JavaPackage[] comBlahSubpackageSubpackages = comBlahSubpackage.getSubPackages();
+ assertEquals(0, comBlahSubpackageSubpackages.length);
}
private String createOuter() {
@@ -181,37 +155,26 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testRecordFile() throws Exception {
- JavaSource source = builder.addSource(new File("target/test-source/com/blah/Thing.java"));
+ builder.addSource(new File("target/test-source/com/blah/Thing.java"));
- Collection<JavaSource> sources = builder.getSources();
- assertEquals(1, sources.size());
+ JavaSource[] sources = builder.getSources();
+ assertEquals(1, sources.length);
assertEquals(new File("target/test-source/com/blah/Thing.java").toURL(),
- source.getURL());
+ sources[0].getURL());
}
- public void testSearcher()
- throws Exception
- {
- builder.addSourceTree( new File( "target/test-source" ) );
+ public void testSearcher() throws Exception {
+ builder.addSourceTree(new File("target/test-source"));
- Collection<JavaClass> results = builder.search( new Searcher()
- {
- public boolean eval( JavaClass cls )
- {
- return cls.getPackage().getName().equals( "com.blah" );
+ List results = builder.search(new Searcher() {
+ public boolean eval(JavaClass cls) {
+ return cls.getPackage().getName().equals("com.blah");
}
- } );
-
- assertEquals( 2, results.size() );
+ });
- List<String> classNames = new ArrayList<String>();
- for ( JavaClass cls : results )
- {
- classNames.add( cls.getName() );
- }
- Collections.sort( classNames );
- assertEquals( "Another", classNames.get( 0 ) );
- assertEquals( "Thing", classNames.get( 1 ) );
+ assertEquals(2, results.size());
+ assertEquals("Another", ((JavaClass) results.get(0)).getName());
+ assertEquals("Thing", ((JavaClass) results.get(1)).getName());
}
private void createFile(String fileName, String packageName, String className) throws Exception {
@@ -246,38 +209,27 @@ public class JavaProjectBuilderTest extends TestCase
+ "class X extends List {}";
builder.addSource(new StringReader(in));
JavaClass cls = builder.getClassByName("x.X");
- assertEquals("List", cls.getSuperClass().getValue());
- assertEquals("java.util.List", cls.getSuperClass().getFullyQualifiedName());
+ assertEquals("java.util.List", cls.getSuperClass().getValue());
}
public void testAddMoreClassLoaders() throws Exception {
- builder = new JavaProjectBuilder(new OrderedClassLibraryBuilder(null));
- builder.addClassLoader(new ClassLoader() {
- public Class loadClass(String name) throws ClassNotFoundException {
- if("com.thoughtworks.qdox.Spoon".equals(name)) {
- return Spoon.class; //Located inside com.thoughtworks.qdox.TestClasses.java
- }
- else {
- throw new ClassNotFoundException(name);
- }
+
+ builder.getClassLibrary().addClassLoader(new ClassLoader() {
+ public Class loadClass(String name) {
+ return name.equals("com.thoughtworks.Spoon") ? this.getClass() : null;
}
});
- builder.addClassLoader(new ClassLoader() {
- public Class loadClass(String name) throws ClassNotFoundException {
- if("com.thoughtworks.qdox.Fork".equals(name)) {
- return Fork.class; //Located inside com.thoughtworks.qdox.TestClasses.java
- }
- else {
- throw new ClassNotFoundException(name);
- }
+ builder.getClassLibrary().addClassLoader(new ClassLoader() {
+ public Class loadClass(String name) {
+ return name.equals("com.thoughtworks.Fork") ? this.getClass() : null;
}
});
String in = ""
+ "package x;"
+ "import java.util.*;"
- + "import com.thoughtworks.qdox.*;"
+ + "import com.thoughtworks.*;"
+ "class X {"
+ " Spoon a();"
+ " Fork b();"
@@ -285,15 +237,11 @@ public class JavaProjectBuilderTest extends TestCase
+ "}";
builder.addSource(new StringReader(in));
- // be sure no default classloaders have been added
- assertNull(builder.getClassByName(Knife.class.getName()));
JavaClass cls = builder.getClassByName("x.X");
- assertEquals("Spoon", cls.getMethods().get(0).getReturns().getValue());
- assertEquals("com.thoughtworks.qdox.Spoon", cls.getMethods().get(0).getReturns().getFullyQualifiedName());
- assertEquals("Fork", cls.getMethods().get(1).getReturns().getValue());
- assertEquals("com.thoughtworks.qdox.Fork", cls.getMethods().get(1).getReturns().getFullyQualifiedName());
+ assertEquals("com.thoughtworks.Spoon", cls.getMethods()[0].getReturns().getValue());
+ assertEquals("com.thoughtworks.Fork", cls.getMethods()[1].getReturns().getValue());
// unresolved
- assertEquals("Cabbage", cls.getMethods().get(2).getReturns().getValue());
+ assertEquals("Cabbage", cls.getMethods()[2].getReturns().getValue());
}
@@ -305,7 +253,7 @@ public class JavaProjectBuilderTest extends TestCase
+ "class Bar {"
+ "}";
builder.addSource(new StringReader(in));
- assertEquals(2, builder.getClasses().size());
+ assertEquals(2, builder.getClasses().length);
assertNotNull(builder.getClassByName("oldfashioned.Ping"));
assertNotNull(builder.getClassByName("oldfashioned.Bar"));
}
@@ -321,13 +269,15 @@ public class JavaProjectBuilderTest extends TestCase
builder.addSource(new StringReader(in));
JavaClass cls = builder.getClassByName("x.X");
- JavaType returnType = cls.getMethods().get(0).getReturns();
- JavaClass returnClass = builder.getClassByName(returnType.getFullyQualifiedName());
+ Type returnType = cls.getMethods()[0].getReturns();
+ JavaClass returnClass = builder.getClassByName(returnType.getValue());
assertEquals("java.util.ArrayList", returnClass.getFullyQualifiedName());
+ Type[] returnImplementz = returnClass.getImplements();
boolean foundList = false;
- for (JavaType type : returnClass.getImplements()) {
+ for (int i = 0; i < returnImplementz.length; i++) {
+ Type type = returnImplementz[i];
if (type.getValue().equals("java.util.List")) {
foundList = true;
}
@@ -338,7 +288,7 @@ public class JavaProjectBuilderTest extends TestCase
JavaClass list = builder.getClassByName("java.util.List");
assertTrue(list.isInterface());
assertNull(list.getSuperJavaClass());
- assertEquals("java.util.Collection", list.getImplements().get(0).getValue());
+ assertEquals("java.util.Collection", list.getImplements()[0].getValue());
}
public void testSuperclassOfObjectIsNull() throws Exception {
@@ -409,7 +359,7 @@ public class JavaProjectBuilderTest extends TestCase
public void testClassesCanBeAddedLater() throws Exception {
testClassCanBeTestedForNonexistantClasses();
- assertEquals(1, builder.getClasses().size());
+ assertEquals(1, builder.getClasses().length);
JavaClass sausage = builder.getClassByName("food.Sausage");
assertFalse(sausage.isA("global.Stuff"));
@@ -418,7 +368,7 @@ public class JavaProjectBuilderTest extends TestCase
+ "class Meat extends global.Stuff {"
+ "}";
builder.addSource(new StringReader(in));
- assertEquals(2, builder.getClasses().size());
+ assertEquals(2, builder.getClasses().length);
assertTrue(sausage.isA("global.Stuff"));
}
@@ -461,10 +411,10 @@ public class JavaProjectBuilderTest extends TestCase
JavaClass abstractList = builder.getClassByName("AbstractList");
JavaClass arrayList = builder.getClassByName("ArrayList");
- List<JavaClass> derivedClassesOfCollection = collection.getDerivedClasses();
- List<JavaClass> derivedClassesOfList = list.getDerivedClasses();
- List<JavaClass> derivedClassesOfAbstractList = abstractList.getDerivedClasses();
- List<JavaClass> derivedClassesOfArrayList = arrayList.getDerivedClasses();
+ List derivedClassesOfCollection = Arrays.asList(collection.getDerivedClasses());
+ List derivedClassesOfList = Arrays.asList(list.getDerivedClasses());
+ List derivedClassesOfAbstractList = Arrays.asList(abstractList.getDerivedClasses());
+ List derivedClassesOfArrayList = Arrays.asList(arrayList.getDerivedClasses());
assertEquals(3, derivedClassesOfCollection.size());
assertEquals(2, derivedClassesOfList.size());
@@ -473,23 +423,25 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testSourcePropertyClass() throws IOException {
- builder.addSource(new File("src/test/java/com/thoughtworks/qdox/testdata/PropertyClass.java"));
+ builder.addSource(new File("src/test/com/thoughtworks/qdox/testdata/PropertyClass.java"));
+ // Handy way to assert that behaviour for source and binary classes is the same.
+ testPropertyClass();
+ }
+ public void testPropertyClass() {
JavaClass propertyClass = builder.getClassByName("com.thoughtworks.qdox.testdata.PropertyClass");
- assertEquals(1, propertyClass.getBeanProperties().size());
+ assertEquals(1, propertyClass.getBeanProperties().length);
// test ctor, methods and fields
- assertEquals(6, propertyClass.getMethods().size());
- assertEquals(2, propertyClass.getConstructors().size());
+ JavaMethod[] methods = propertyClass.getMethods();
+ assertEquals(8, methods.length);
- JavaConstructor ctor = propertyClass.getConstructor(null);
- JavaConstructor ctor2 = propertyClass.getConstructor(Collections.singletonList((JavaType) propertyClass));
+ JavaMethod ctor = propertyClass.getMethodBySignature("PropertyClass", null);
+ JavaMethod ctor2 = propertyClass.getMethodBySignature("PropertyClass", new Type[] {propertyClass.asType()});
JavaMethod getFoo = propertyClass.getMethodBySignature("getFoo", null);
JavaMethod isBar = propertyClass.getMethodBySignature("isBar", null);
JavaMethod get = propertyClass.getMethodBySignature("get", null);
- JavaType intType = mock( JavaType.class );
- when( intType.getFullyQualifiedName() ).thenReturn( "int" );
- JavaMethod set = propertyClass.getMethodBySignature( "set", Collections.singletonList( (JavaType) intType ) );
+ JavaMethod set = propertyClass.getMethodBySignature("set", new Type[]{new Type("int")});
JavaMethod protectedMethod = propertyClass.getMethodBySignature("protectedMethod", null);
JavaMethod privateMethod = propertyClass.getMethodBySignature("privateMethod", null);
@@ -505,6 +457,15 @@ public class JavaProjectBuilderTest extends TestCase
assertNotNull(privateMethod);
assertNull(shouldntBeInherited);
+ assertTrue(ctor.isConstructor());
+ assertTrue(ctor2.isConstructor());
+ assertFalse(getFoo.isConstructor());
+ assertFalse(isBar.isConstructor());
+ assertFalse(get.isConstructor());
+ assertFalse(set.isConstructor());
+ assertFalse(protectedMethod.isConstructor());
+ assertFalse(privateMethod.isConstructor());
+
assertTrue(getFoo.isStatic());
assertFalse(isBar.isStatic());
assertFalse(get.isStatic());
@@ -519,15 +480,18 @@ public class JavaProjectBuilderTest extends TestCase
assertTrue(protectedMethod.isProtected());
assertTrue(privateMethod.isPrivate());
- List<JavaField> fields = propertyClass.getFields();
- assertEquals(3, fields.size());
+ JavaField[] fields = propertyClass.getFields();
+ assertEquals(3, fields.length);
}
public void testSourceDefaultCtor() throws Exception {
- builder.addSource(new File("src/test/resources/com/thoughtworks/qdox/testdata/DefaultCtor.java"));
+ builder.addSource(new File("src/test/com/thoughtworks/qdox/testdata/DefaultCtor.java"));
JavaClass javaClass = builder.getClassByName("com.thoughtworks.qdox.testdata.DefaultCtor");
JavaMethod ctor = javaClass.getMethodBySignature("DefaultCtor", null);
+
+ // Differs from binary as currently no way to identify default
+ // constructor in binary class.
assertNull(ctor);
}
@@ -535,53 +499,32 @@ public class JavaProjectBuilderTest extends TestCase
JavaClass javaClass = builder.getClassByName("com.thoughtworks.qdox.testdata.DefaultCtor");
JavaMethod ctor = javaClass.getMethodBySignature("DefaultCtor", null);
- assertNull(ctor);
+
+ // Differs from source as currently no way to identify default
+ // constructor in binary class.
+ assertNotNull(ctor);
}
- /*
- * The JavaDocBuilder has to be serializable, With JavaProjectBuilder, we only need to serialize the ClassLibraryBuilder
- */
public void testSerializable() throws Exception {
-
- JavaSource source = builder.addSource(new StringReader("package test; public class X{}"));
- assertEquals("X", source.getClasses().get(0).getName());
- try {
- SerializationUtils.serializedCopy(builder);
+ builder.addSource(new StringReader("package test; public class X{}"));
+ assertEquals("X", builder.getSources()[0].getClasses()[0].getName());
- fail("JavaProjectBuilder should not serializable");
- }
- catch(RuntimeException ex) {
- if ( !(ex.getCause() instanceof NotSerializableException)) {
- fail("Unexpected RuntimeException caught: " + ex.getMessage());
- }
- }
- }
+ JavaDocBuilder newBuilder = (JavaDocBuilder) SerializationUtils.serializedCopy(builder);
- public void testSaveAndRestore() throws Exception {
- File file = new File("target/test-source/cache.obj");
- builder.addSourceTree(new File("target/test-source"));
- builder.save(file);
+ assertEquals("X", newBuilder.getSources()[0].getClasses()[0].getName());
- JavaProjectBuilder newBuilder = JavaProjectBuilder.load(file);
- assertNotNull(newBuilder.getClassByName("com.blah.subpackage.Cheese"));
-
- newBuilder.addSource(new StringReader("package x; import java.util.*; class Z extends List{}"));
- assertEquals("List", newBuilder.getClassByName("x.Z").getSuperClass().getValue());
- assertEquals("java.util.List", newBuilder.getClassByName("x.Z").getSuperClass().getFullyQualifiedName());
}
-
- public void testSaveAndRestoreWithoutDefaultClassloaders() throws Exception {
- builder = new JavaProjectBuilder( new OrderedClassLibraryBuilder() );
+
+ public void testSaveAndRestore() throws Exception {
File file = new File("target/test-source/cache.obj");
builder.addSourceTree(new File("target/test-source"));
builder.save(file);
- JavaProjectBuilder newBuilder = JavaProjectBuilder.load(file);
+ JavaDocBuilder newBuilder = JavaDocBuilder.load(file);
assertNotNull(newBuilder.getClassByName("com.blah.subpackage.Cheese"));
newBuilder.addSource(new StringReader("package x; import java.util.*; class Z extends List{}"));
- //Here it's just List, since there we didn't use the defaultClassLoaders
- assertEquals("List", newBuilder.getClassByName("x.Z").getSuperClass().getValue());
+ assertEquals("java.util.List", newBuilder.getClassByName("x.Z").getSuperClass().getValue());
}
@@ -657,7 +600,7 @@ public class JavaProjectBuilderTest extends TestCase
JavaField iField = fooClass.getFieldByName("i");
assertEquals(5, iField.getLineNumber());
JavaMethod getIMethod =
- fooClass.getMethodBySignature("getI", Collections.EMPTY_LIST);
+ fooClass.getMethodBySignature("getI", Type.EMPTY_ARRAY);
assertEquals(6, getIMethod.getLineNumber());
}
@@ -673,12 +616,12 @@ public class JavaProjectBuilderTest extends TestCase
"";
builder.addSource(new StringReader(source));
JavaClass outer = builder.getClassByName("foo.Outer");
- JavaClass inner = outer.getNestedClasses().get(0);
+ JavaClass inner = outer.getNestedClasses()[0];
assertEquals("foo.Outer$Inner", inner.getFullyQualifiedName());
JavaField field1 = outer.getFieldByName("field1");
- JavaClass type = field1.getType();
- assertEquals("foo.Outer$Inner", type.getFullyQualifiedName());
+ Type type = field1.getType();
+ assertEquals("foo.Outer$Inner", type.getJavaClass().getFullyQualifiedName());
}
public void testJiraQdox16() {
@@ -728,7 +671,7 @@ public class JavaProjectBuilderTest extends TestCase
builder.addSource(new StringReader(source));
JavaClass x = builder.getClassByName("x");
- JavaMethod m = x.getMethods().get(0);
+ JavaMethod m = x.getMethods()[0];
DocletTag foo = m.getTagByName("y");
assertEquals("z", foo.getValue());
}
@@ -753,16 +696,16 @@ public class JavaProjectBuilderTest extends TestCase
builder.addSource(new StringReader(Y));
JavaClass y = builder.getClassByName("Y");
- List<DocletTag> c = y.getTagsByName("c", true);
- assertEquals(2, c.size());
- assertEquals("y", c.get(0).getValue());
- assertEquals("x", c.get(1).getValue());
+ DocletTag[] c = y.getTagsByName("c", true);
+ assertEquals(2, c.length);
+ assertEquals("y", c[0].getValue());
+ assertEquals("x", c[1].getValue());
JavaMethod i = y.getMethodBySignature("i", null);
- List<DocletTag> m = i.getTagsByName("m", true);
- assertEquals(2, m.size());
- assertEquals("y", m.get(0).getValue());
- assertEquals("x", m.get(1).getValue());
+ DocletTag[] m = i.getTagsByName("m", true);
+ assertEquals(2, m.length);
+ assertEquals("y", m[0].getValue());
+ assertEquals("x", m[1].getValue());
DocletTag s = i.getTagByName("s", true);
assertEquals("f", s.getValue());
@@ -777,6 +720,7 @@ public class JavaProjectBuilderTest extends TestCase
+ " **/"
+ "public class AClassName {\n"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass aClass =
builder.getClassByName("com.acme.thing.AClassName");
@@ -788,15 +732,16 @@ public class JavaProjectBuilderTest extends TestCase
+ "public class A {\n"
+ " int i,j=2,k[];"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass a = builder.getClassByName("A");
- assertEquals(3, a.getFields().size());
- assertEquals("i", a.getFields().get(0).getName());
- assertEquals("int", a.getFields().get(0).getType().toString());
- assertEquals("j", a.getFields().get(1).getName());
- assertEquals("int", a.getFields().get(1).getType().toString());
- assertEquals("k", a.getFields().get(2).getName());
- assertEquals("int[]", a.getFields().get(2).getType().toString());
+ assertEquals(3, a.getFields().length);
+ assertEquals("i", a.getFields()[0].getName());
+ assertEquals("int", a.getFields()[0].getType().toString());
+ assertEquals("j", a.getFields()[1].getName());
+ assertEquals("int", a.getFields()[1].getType().toString());
+ assertEquals("k", a.getFields()[2].getName());
+ assertEquals("int[]", a.getFields()[2].getType().toString());
}
public void testJiraQdox40() {
@@ -806,10 +751,11 @@ public class JavaProjectBuilderTest extends TestCase
+ " class WrappedInternalContextAdapter implements InternalContextAdapter {"
+ " }"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass clazz = builder.getClassByName("foo.bar.Outer");
- assertEquals(1, clazz.getNestedClasses().size());
+ assertEquals(1, clazz.getNestedClasses().length);
}
public void testParseErrorLocationShouldBeAvailable() {
@@ -828,12 +774,13 @@ public class JavaProjectBuilderTest extends TestCase
public void testJiraQdox35() {
String sourceCode = "package pack; public class Foo extends Bar implements Zap {}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass clazz = builder.getClassByName("pack.Foo");
- assertEquals(1, clazz.getImplementedInterfaces().size());
+ assertEquals(1, clazz.getImplementedInterfaces().length);
// Ideally the fully qualified names should be the pack.Zap and pack.Bar,
// but this will do for now to fix the NPE bug.
- assertEquals("Zap", clazz.getImplementedInterfaces().get(0).getFullyQualifiedName());
+ assertEquals("Zap", clazz.getImplementedInterfaces()[0].getFullyQualifiedName());
assertEquals("Bar", clazz.getSuperJavaClass().getFullyQualifiedName());
}
@@ -854,7 +801,8 @@ public class JavaProjectBuilderTest extends TestCase
" * fish=\"poisson\"\r" +
" */\n" +
" class MultiLine{}";
- JavaClass multiline = builder.addSource(new StringReader(sourceCode)).getClasses().get(0);
+ JavaDocBuilder builder = new JavaDocBuilder();
+ JavaClass multiline = builder.addSource(new StringReader(sourceCode)).getClasses()[0];
DocletTag frenchEnglish = multiline.getTagByName("french.english");
Set expected = new HashSet();
@@ -868,7 +816,7 @@ public class JavaProjectBuilderTest extends TestCase
"class Y implements SomeInterface { }")
);
- Collection<JavaClass> results = builder.search(new Searcher() {
+ List results = builder.search(new Searcher() {
public boolean eval(JavaClass javaClass) {
return javaClass.isA("SomeInterface");
}
@@ -900,7 +848,7 @@ public class JavaProjectBuilderTest extends TestCase
builder.getClassByName("p1.A").getNestedClassByName("Inner");
JavaField innerField =
builder.getClassByName("p2.B").getFieldByName("innerField");
- assertEquals(innerClass, innerField.getType() );
+ assertEquals(innerClass.asType(), innerField.getType());
assertEquals("p1.A$Inner", innerField.getType().getFullyQualifiedName());
}
@@ -910,6 +858,7 @@ public class JavaProjectBuilderTest extends TestCase
+ "public class C {"
+ " boolean flag = (X < Y);"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
}
@@ -920,8 +869,9 @@ public class JavaProjectBuilderTest extends TestCase
+ " @AnotherAnnotation\n"
+ " public void aMethod() {}\n"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaMethod javaMethod = javaSource.getClasses().get(0).getMethods().get(0);
+ JavaMethod javaMethod = javaSource.getClasses()[0].getMethods()[0];
assertEquals("aMethod", javaMethod.getName());
}
@@ -932,12 +882,14 @@ public class JavaProjectBuilderTest extends TestCase
+ "public class C {"
+ " public void aMethod() {}\n"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
assertEquals("C", javaClass.getName());
}
public void testMethodBody() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String sourceCode = "" +
"public class X {\n" +
" public void doStuff() {\n" +
@@ -946,8 +898,8 @@ public class JavaProjectBuilderTest extends TestCase
" } // not this \n" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
String expected = "" +
" System.out.println(\"hi\"); // comment\n" +
" Foo<X> x = new Cheese().get()[4]; /*x*/";
@@ -955,6 +907,7 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testMethodBodyWithConfusingCurlies() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String sourceCode = "" +
"public class X {\n" +
" public void doStuff() {\n" +
@@ -963,8 +916,8 @@ public class JavaProjectBuilderTest extends TestCase
" } // not this \n" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
String expected = "" +
" System.out.println(\"}}} \\\"\"); // }\n" +
" Foo<X> x = new Cheese().get()[4]; /*}}*/ /etc\n";
@@ -972,6 +925,7 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testMethodBodyWithPrecedingStaticBlock() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String sourceCode = "" +
"public class X {\n" +
" static {\n" +
@@ -983,8 +937,8 @@ public class JavaProjectBuilderTest extends TestCase
" } // not this \n" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
String expected = "" +
" System.out.println(\"hi\"); // comment\n" +
" Foo<X> x = new Cheese().get()[4]; /*x*/";
@@ -992,14 +946,15 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testFieldDefinition() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String sourceCode = "" +
"public class X {\n" +
" int x = new FlubberFactory<Y>(\"}\"){}.doCheese(spam/*c*/)\n" +
" [9] /*comment*/ //more\n; /*somethingelse*/" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFields().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaField javaField = javaClass.getFields()[0];
String expected = "" +
"new FlubberFactory<Y>(\"}\"){}.doCheese(spam/*c*/)\n" +
" [9] /*comment*/ //more";
@@ -1011,15 +966,17 @@ public class JavaProjectBuilderTest extends TestCase
"public class Thing {\n" +
" long[] bad = {1,2,3};\n" + // as opposed to bad = new long[] {1,2,3}.
"}";
+ JavaDocBuilder builder = new JavaDocBuilder();
JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaField field = javaSource.getClasses().get(0).getFieldByName("bad");
+ JavaField field = javaSource.getClasses()[0].getFieldByName("bad");
assertEquals("{1,2,3}", field.getInitializationExpression().trim());
}
public void testDefaultsToThrowingExceptionWhenNotParseable() throws Exception {
createFile("target/test-source/com/blah/Bad.java", "com.blah", "@%! BAD {}}}}");
+ JavaDocBuilder builder = new JavaDocBuilder();
try {
builder.addSourceTree(new File("target/test-source"));
fail("Expected exception");
@@ -1031,60 +988,53 @@ public class JavaProjectBuilderTest extends TestCase
public void testContinuesProcessingAfterBadFileIfCustomHandlerPermits() throws Exception {
createFile("target/test-source/com/blah/Bad.java", "com.blah", "@%! BAD {}}}}");
- ErrorHandler mockErrorHandler = mock(ErrorHandler.class);
+ Mock mockErrorHandler = mock(JavaDocBuilder.ErrorHandler.class);
+ // Expectation
+ mockErrorHandler.expects(once())
+ .method("handle")
+ .with(isA(ParseException.class));
- builder.setErrorHandler( mockErrorHandler );
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.setErrorHandler((JavaDocBuilder.ErrorHandler) mockErrorHandler.proxy());
builder.addSourceTree(new File("target/test-source"));
assertNotNull(builder.getClassByName("com.blah.Thing"));
-
- verify( mockErrorHandler ).handle( any( ParseException.class ) );
}
public void testBinaryClassFieldModifiers() {
+ JavaDocBuilder builder = new JavaDocBuilder();
JavaClass javaClass = builder.getClassByName(PropertyClass.class.getName());
assertEquals("Class", PropertyClass.class.getName(), javaClass.getFullyQualifiedName());
JavaField javaField = javaClass.getFieldByName("aField");
assertNotNull("Field", javaField);
- Set<String> modifiers = new HashSet<String>(javaField.getModifiers());
- assertEquals("Modifier count", 2, javaField.getModifiers().size());
+ Set modifiers = new HashSet(Arrays.asList(javaField.getModifiers()));
+ assertEquals("Modifier count", 2, javaField.getModifiers().length);
assertTrue("Static", modifiers.contains("static"));
assertTrue("Public", modifiers.contains("public"));
}
public void testMultipleFieldsWithJavaDoc() throws Exception {
- String sourceCode = "class Thing {\n" +
- " /** some doc */\n" +
- " int a = 1,\n" +
- " /** more doc */\n" +
- " b = 2,\n" +
- " /** etc */\n" +
- " c = 3; }";
- JavaClass javaClass = builder.addSource(new StringReader(sourceCode)).getClasses().get(0);
- JavaField fieldA = javaClass.getFieldByName("a");
- assertEquals("some doc", fieldA.getComment());
- JavaField fieldB = javaClass.getFields().get(1);
- assertEquals("more doc", fieldB.getComment());
- JavaField fieldC = javaClass.getFields().get(2);
- assertEquals("etc", fieldC.getComment());
- }
-
- public void testValueRemainsIntact() throws Exception {
- String in = ""
- + "package x;\n"
- + "/**\n"
- + " * @tag aa count(*) bbb * ccc dd=e f='g' i = \"xx\"\n"
- + " */\n"
- + "class X {}";
-
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSource(new StringReader(in));
- DocletTag tag = builder.getClassByName("x.X").getTagByName("tag");
-
- assertEquals("aa count(*) bbb * ccc dd=e f='g' i = \"xx\"", tag.getValue());
+ String sourceCode = "class Thing {\n" +
+ " /** some doc */\n" +
+ " int a = 1,\n" +
+ " /** more doc */\n" +
+ " b = 2,\n" +
+ " /** etc */\n" +
+ " c = 3; }";
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(new StringReader(sourceCode));
+ JavaClass javaClass = builder.getClasses()[0];
+ JavaField fieldA = javaClass.getFieldByName("a");
+ assertEquals("some doc", fieldA.getComment());
+ JavaField fieldB = javaClass.getFields()[1];
+ assertEquals("more doc", fieldB.getComment());
+ JavaField fieldC = javaClass.getFields()[2];
+ assertEquals("etc", fieldC.getComment());
}
+
public void testJiraQdox117() throws Exception {
+ JavaDocBuilder builder = new JavaDocBuilder();
String sourceCode = "" +
"public class foo {\n" +
"{ dosomething(); }\n" +
@@ -1092,40 +1042,22 @@ public class JavaProjectBuilderTest extends TestCase
"public void myTest() {}\n" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(sourceCode));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
- assertEquals("\"test blah blah\"", javaMethod.getAnnotations().get(0).getNamedParameter("description").toString());
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
+ assertEquals("\"test blah blah\"", javaMethod.getAnnotations()[0].getNamedParameter("description").toString());
}
- public void testJiraQdox131() throws Exception {
- String sourceCode = "package com.acme.qdox;\n" +
- "\n" +
- "public class QDoxBugClass {\n" +
- " final public static String C1 = \"C1\", C2 = \"C2\";\n" +
- " final public static String[] ALL = { C1, C2 }; \n" +
- " /*\n" +
- " Comment\n" +
- " */\n" +
- " public void method() {\n" +
- " System.out.println(\"This will contain the comment\");\n" +
- " }\n" +
- "}\n" +
- "";
- builder.addSource(new StringReader(sourceCode));
- JavaClass aClass = builder.getClassByName("com.acme.qdox.QDoxBugClass");
- assertEquals("\n System.out.println(\"This will contain the comment\");\n ",
- aClass.getMethods().get(0).getSourceCode());
- }
-
public void testJiraQdox134() throws Exception {
String sourceCode = "/**\n" +
- "*\n" +
- "@myTag name=TestClass attrs=Something1,Something2,Something3\n" +
- "*/\n" +
- "public class TestClassImpl {\r\n" +
- "}";
- JavaClass jClass = builder.addSource(new StringReader(sourceCode)).getClasses().get(0);
- assertEquals( Arrays.asList( new String[] {"name=TestClass","attrs=Something1,Something2,Something3"}), jClass.getTags().get(0).getParameters());
+ "*\n" +
+ "@myTag name=TestClass attrs=Something1,Something2,Something3\n" +
+ "*/\n" +
+ "public class TestClassImpl {\r\n" +
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(new StringReader(sourceCode));
+ JavaClass jClass = builder.getClasses()[0];
+ assertEquals( Arrays.toString( new String[] {"name=TestClass","attrs=Something1,Something2,Something3"}), Arrays.toString(jClass.getTags()[0].getParameters()));
//assertTrue( Arrays.equals( new String[] {"name=TestClass","attrs=Something1,Something2,Something3"}, jClass.getTags()[0].getParameters() ));
}
@@ -1141,6 +1073,7 @@ public class JavaProjectBuilderTest extends TestCase
+ " **/\n"
+ "public class AClassName {\n"
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder();
builder.addSource(new StringReader(sourceCode));
JavaClass aClass = builder.getClassByName("com.acme.thing.AClassName");
assertEquals("This class does something.\n"
@@ -1150,20 +1083,19 @@ public class JavaProjectBuilderTest extends TestCase
//for qdox-152
public void testExtendedClass() throws Exception {
- String source = "import javax.faces.component.UIOutput;" +
- "public abstract class AbstractSayHello extends UIOutput {\n" +
- "}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- assertEquals("UIOutput", javaClass.getSuperClass().getValue());
- assertEquals("javax.faces.component.UIOutput", javaClass.getSuperClass().getFullyQualifiedName());
+ String source = "import javax.faces.component.UIOutput;" +
+ "public abstract class AbstractSayHello extends UIOutput {\n" +
+ "}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ assertEquals(javaClass.getSuperClass().getValue(), "javax.faces.component.UIOutput");
}
//for QDox-154
public void testImplicitJavadocCommentOrder() throws Exception {
String source = "" +
- "public class Foo {\n" +
- " /**\n" +
+ "public class Foo {\n" +
+ " /**\n" +
" * A Javadoc sample.\n" +
" *\n" +
" * @return The size.\n" +
@@ -1184,42 +1116,42 @@ public class JavaProjectBuilderTest extends TestCase
" }\n" +
"}";
JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod method1 = javaClass.getMethods().get(0);
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod method1 = javaClass.getMethods()[0];
assertEquals( "A Javadoc sample.", method1.getComment());
assertEquals( "The size.", method1.getTagByName( "return" ).getValue());
- JavaMethod method2 = javaClass.getMethods().get(1);
+ JavaMethod method2 = javaClass.getMethods()[1];
assertEquals( "The size.\n\nA Javadoc sample.", method2.getTagByName( "return" ).getValue());
}
//for qdox-155
public void testCharField() throws Exception {
- String source = "public class Foo {\n" +
- "public static final char SEPARATOR = ',';" +
- "}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
+ String source = "public class Foo {\n" +
+ "public static final char SEPARATOR = ',';" +
+ "}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
assertEquals(javaClass.getFieldByName( "SEPARATOR" ).getInitializationExpression(), "','");
}
//for qdox-157
public void testCommentBetweenFields() throws Exception {
- String source = "public class Foo {\n" +
- "public static final String TEST1 = \"test1\";\n" +
- "// TODO: blabla\n" +
- "public static final String TEST2 = \"test2\";\n" +
- "}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
+ String source = "public class Foo {\n" +
+ "public static final String TEST1 = \"test1\";\n" +
+ "// TODO: blabla\n" +
+ "public static final String TEST2 = \"test2\";\n" +
+ "}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
assertEquals(javaClass.getFieldByName( "TEST2" ).getInitializationExpression(), "\"test2\"");
}
public void testAnnotationWithComment() throws Exception {
- String source = "@OneToMany(cascade = {/* CascadeType.PERSIST */}, fetch = FetchType.LAZY)\n" +
- "public class Foo{}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- assertNotNull(javaClass.getAnnotations().get(0).getNamedParameter("cascade"));
+ String source = "@OneToMany(cascade = {/* CascadeType.PERSIST */}, fetch = FetchType.LAZY)\n" +
+ "public class Foo{}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ assertNotNull(javaClass.getAnnotations()[0].getNamedParameter("cascade"));
}
/**
@@ -1227,25 +1159,26 @@ public class JavaProjectBuilderTest extends TestCase
* @throws Exception
*/
public void testJavadocWithoutStartingAsterisks() throws Exception {
- String source = " /**\n" +
- " Some text\n" +
- "more text\n" +
- "\t and even more\n" +
- " \n" +
- " @throws Exception\n" +
- "@deprecated" +
- " */\n" +
- "public class Foo{}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- assertEquals("Some text\nmore text\nand even more", javaClass.getComment());
- assertEquals("throws", javaClass.getTags().get(0).getName());
- assertEquals("Exception", javaClass.getTags().get(0).getValue());
- assertEquals("deprecated", javaClass.getTags().get(1).getName());
+ String source = " /**\n" +
+ " Some text\n" +
+ "more text\n" +
+ "\t and even more\n" +
+ " \n" +
+ " @throws Exception\n" +
+ "@deprecated" +
+ " */\n" +
+ "public class Foo{}";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ assertEquals("Some text\nmore text\nand even more", javaClass.getComment());
+ assertEquals("throws", javaClass.getTags()[0].getName());
+ assertEquals("Exception", javaClass.getTags()[0].getValue());
+ assertEquals("deprecated", javaClass.getTags()[1].getName());
}
// for QDOX-189
public void testFinalAnnotationParam() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String source = "public final class WSEndpointReference {\n" +
" public void writeTo(final @NotNull String localName, @NotNull XMLStreamWriter w) throws XMLStreamException {\n" +
" }\n" +
@@ -1255,6 +1188,7 @@ public class JavaProjectBuilderTest extends TestCase
// for QDOX-190
public void testTwoCommentsBeforeEnumValue() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String source =
"public enum Source {\n" +
" /** comment 1 */ \n" +
@@ -1262,11 +1196,12 @@ public class JavaProjectBuilderTest extends TestCase
" JDK1_2(\"1.2\");\n" +
"}\n";
JavaSource src = builder.addSource(new StringReader(source));
- assertEquals( "comment 2", src.getClasses().get(0).getFieldByName( "JDK1_2" ).getComment() );
+ assertEquals( "comment 2", src.getClasses()[0].getFieldByName( "JDK1_2" ).getComment() );
}
//for QDOX-191
public void testLeftShift() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String source =
"private static class Flags {\n" +
" static final Flags LEFT_JUSTIFY = new Flags(1 << 0);\n" +
@@ -1275,6 +1210,7 @@ public class JavaProjectBuilderTest extends TestCase
}
public void testGenericConstructor() {
+ JavaDocBuilder builder = new JavaDocBuilder();
String source =
"public class MXBeanSupport {\n" +
" public <T> MXBeanSupport(T resource, Class<T> mxbeanInterface)\n" +
@@ -1288,383 +1224,80 @@ public class JavaProjectBuilderTest extends TestCase
public void testSharedPackageJavaClasses() {
String source1 = "@javax.xml.bind.annotation.XmlSchema(namespace = \"http://docs.oasis-open.org/wsn/br-2\")\n" +
"package com.foo;\n" +
- "public class Bar1 {}";
+ "public class Bar1 {}";
String source2 = "package com.foo;\n" +
"public class Bar2{}";
JavaSource javaSource1 = builder.addSource(new StringReader(source1));
JavaSource javaSource2 = builder.addSource(new StringReader(source2));
JavaPackage jPackage = builder.getPackageByName("com.foo");
- assertEquals( 2, jPackage.getClasses().size() );
- assertEquals( 2, javaSource1.getPackage().getClasses().size() );
- assertEquals( 2, javaSource2.getPackage().getClasses().size() );
+ assertEquals( 2, jPackage.getClasses().length );
+ assertEquals( 2, javaSource1.getPackage().getClasses().length );
+ assertEquals( 2, javaSource2.getPackage().getClasses().length );
assertNotSame( javaSource1.getPackage(), javaSource2.getPackage() );
- assertEquals( 1, javaSource1.getPackage().getAnnotations().size() );
- assertEquals( 0, javaSource2.getPackage().getAnnotations().size() );
+ assertEquals( 1, javaSource1.getPackage().getAnnotations().length );
+ assertEquals( 0, javaSource2.getPackage().getAnnotations().length );
assertEquals( 2, javaSource1.getPackage().getLineNumber() );
assertEquals( 1, javaSource2.getPackage().getLineNumber() );
}
public void testSourceFolder() throws Exception {
- builder.addSourceFolder( new File("target/test-source") );
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.getClassLibrary().addSourceFolder( new File("target/test-source") );
String source = "package com.foo;\n" +
- "import com.blah.*;\n" +
- "public abstract class Me {\n" +
- " public abstract Thing getThing(); " +
- "}";
+ "import com.blah.*;\n" +
+ "public abstract class Me {\n" +
+ " public abstract Thing getThing(); " +
+ "}";
builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.addSource( new StringReader( source ) ).getClasses().get(0);
- JavaClass thing = clazz.getMethods().get(0).getReturns();
+ JavaClass clazz = builder.addSource( new StringReader( source ) ).getClasses()[0];
+ JavaClass thing = clazz.getMethods()[0].getReturns().getJavaClass();
assertEquals("com.blah.Thing", thing.getFullyQualifiedName());
assertNotNull(thing.getSource());
}
// for QDOX-208
public void testMethodLineNumber() throws Exception {
+ JavaDocBuilder builder = new JavaDocBuilder();
String source = "package com.foo;\n" +
- "public class Bar {\n" +
- " public void method1() \n" +
- " {}\n" +
- "\n" +
- " /**\n" +
- " * Method with javadoc\n" +
- " */\n" +
- " public void method1() { \n" +
- " }\n" +
- "}";
- JavaClass clazz = builder.addSource( new StringReader( source ) ).getClasses().get(0);
- assertEquals( 3, clazz.getMethods().get(0).getLineNumber() );
- assertEquals( 9, clazz.getMethods().get(1).getLineNumber() );
+ "public class Bar {\n" +
+ " public void method1() \n" +
+ " {}\n" +
+ "\n" +
+ " /**\n" +
+ " * Method with javadoc\n" +
+ " */\n" +
+ " public void method1() { \n" +
+ " }\n" +
+ "}";
+ builder.addSource( new StringReader( source ) );
+ JavaClass clazz = builder.getClasses()[0];
+ assertEquals( 3, clazz.getMethods()[0].getLineNumber() );
+ assertEquals( 9, clazz.getMethods()[1].getLineNumber() );
}
// for QDOX-209
public void testAnnotationMap() throws Exception{
+ JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
String source = "import javax.persistence.JoinColumn;\n" +
- "public class Instruction {\n" +
- " private static final int something = 40;\n" +
- " //-----------------------------------------------------------------------\r\n" +
- " @JoinColumn(name=\"test\",bla=\"hi\")\n" +
- " int testfield;\r\n" +
- "}";
- builder.addSource(new StringReader( source ));
- JavaClass classByName = builder.getClassByName("Instruction");
+ "public class Instruction {\n" +
+ " private static final int something = 40;\n" +
+ " //-----------------------------------------------------------------------\r\n" +
+ " @JoinColumn(name=\"test\",bla=\"hi\")\n" +
+ " int testfield;\r\n" +
+ "}";
+ javaDocBuilder.addSource(new StringReader( source ));
+ JavaClass classByName = javaDocBuilder.getClassByName("Instruction");
JavaField fieldByName = classByName.getFieldByName("testfield");
- List<JavaAnnotation> annotations = fieldByName.getAnnotations();
+ Annotation[] annotations = fieldByName.getAnnotations();
// Now we do have the annotation "JoinColumn" in annotations[0]
- Map propertyMap = annotations.get(0).getNamedParameterMap();
+ Map propertyMap = annotations[0].getNamedParameterMap();
// This one works
assertEquals("\"hi\"", propertyMap.get("bla"));
String string = (String) propertyMap.get("name");
// This one does not work
assertEquals("\"test\"", string);
}
-
-
- public void testEnumConstantArguments() throws Exception
- {
- String source = "public enum AssignmentOperators {" +
- " EQ ( a = b )," +
- " TMSEQ ( a *= b )," +
- " DVDEQ ( a /= b )," +
- " MODEQ ( a %= b )," +
- " PLEQ ( a += b )," +
- " MNEQ ( a -= b )," +
- " LT2EQ ( a <<= b )," +
- " GT2EQ ( a >>= b )," +
- " GT3EQ ( a >>>= b )," +
- " ANDEQ ( a &= b )," +
- " XOREQ ( a ^= b )," +
- " OREQ ( a |= b )" +
- " }";
- JavaClass cls = builder.addSource(new StringReader( source )).getClassByName( "AssignmentOperators" );
- JavaField xoreq = cls.getFieldByName( "XOREQ" );
- assertEquals( 1, xoreq.getEnumConstantArguments().size() );
- assertEquals( "a ^= b", xoreq.getEnumConstantArguments().get(0).getParameterValue() );
- }
-
- public void testIncrementAndDecrement() throws Exception
- {
- String source = "public enum Expression {" +
- " POSTINC ( a++ )," +
- " POSTDEC ( a-- )," +
- " PREINC ( ++a )," +
- " PREDEC ( --a )" +
- " }";
- JavaClass cls = builder.addSource(new StringReader( source )).getClassByName( "Expression" );
- JavaField postInc = cls.getFieldByName( "POSTINC" );
- assertEquals( 1, postInc.getEnumConstantArguments().size() );
- assertEquals( "a++", postInc.getEnumConstantArguments().get( 0 ).getParameterValue() );
- }
-
- // for QDOX-230
- public void testInterfaceAnnotations() throws Exception {
- String source = "@RemoteServiceRelativePath(\"greetings\")\r\n" +
- "public interface GreetingService extends RemoteService {\r\n" +
- " String greetServer(String name) throws IllegalArgumentException;\r\n" +
- "}";
- builder.addSource(new StringReader( source ));
- JavaClass cls = builder.getClassByName( "GreetingService" );
- assertEquals( 1, cls.getAnnotations().size() );
- }
-
- // for QDOX-243
- public void testReadsGenericsInGenericType()
- {
- final String sourceCode =
- ""
- + "package foo;\n"
- + "public static class DummyOne {\n"
- + " public static java.util.list<java.util.Map<? extends java.util.Set<Long>, String>> crazyType() { return null; }\n"
- + "}\n";
-
- builder.addSource( new java.io.StringReader( sourceCode ) );
- JavaClass qDoxClass = builder.getClassByName( "foo.DummyOne" );
- JavaMethod qDoxMethod = qDoxClass.getMethodBySignature( "crazyType", null );
-
- JavaParameterizedType returnType = (JavaParameterizedType) qDoxMethod.getReturnType();
- assertEquals( "java.util.Map<? extends java.util.Set<java.lang.Long>,java.lang.String>",
- returnType.getActualTypeArguments().get( 0 ).getGenericFullyQualifiedName() );
- assertEquals( "java.util.Map<? extends java.util.Set<java.lang.Long>,java.lang.String>",
- returnType.getActualTypeArguments().get( 0 ).getGenericCanonicalName() );
- }
-
- // for QDOX-244
- public void testReadsGenericTypeParameters()
- {
- final String sourceCode =
- "" + "package foo;\n" + "public static class DummyOne {\n"
- + " public static <T extends Number & Iterable<Integer>> T genericTypeParam(T x) { return null; }\n"
- + "}\n";
-
- builder.addSource( new java.io.StringReader( sourceCode ) );
- JavaClass qDoxClass = builder.getClassByName( "foo.DummyOne" );
- JavaMethod qDoxMethod = qDoxClass.getMethods().get(0);
-
- JavaTypeVariable<JavaGenericDeclaration> result = qDoxMethod.getTypeParameters().get( 0 );
- assertEquals( "<T extends java.lang.Number & java.lang.Iterable<java.lang.Integer>>", result.getGenericFullyQualifiedName() );
- assertEquals( "<T extends java.lang.Number & java.lang.Iterable<java.lang.Integer>>", result.getGenericCanonicalName() );
- }
-
- // for QDOX-245
- public void
- testReadsGenerifiedParameterTypes() {
- final String sourceCode = "" +
- "package foo;\n" +
- "public static class DummyOne {\n" +
- " public static String withGenerifiedParam(java.util.Collection<? extends Comparable<String>> things) { return null; }\n" +
- "}\n";
-
- builder.addSource(new java.io.StringReader(sourceCode));
- JavaClass qDoxClass = builder.getClassByName("foo.DummyOne");
- JavaMethod qDoxMethod = qDoxClass.getMethods().get(0);
-
- JavaType result = qDoxMethod.getParameterTypes(true).get( 0 );
- assertEquals("java.util.Collection<? extends java.lang.Comparable<java.lang.String>>", result.getGenericFullyQualifiedName());
- assertEquals("java.util.Collection<? extends java.lang.Comparable<java.lang.String>>", result.getGenericCanonicalName());
- }
-
- // for QDOX-253
- public void testConstructorHasAnnotation()
- throws Exception
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- String source =
- "public class Foo { private String apiPath; public Foo(@Value(\"${api.path}\") String apiPath) {this.apiPath = apiPath}}";
- JavaClass qDoxClass = builder.addSource( new StringReader( source ) ).getClassByName( "Foo" );
- assertEquals( 1, qDoxClass.getConstructors().size() );
- JavaConstructor qDoxConstructor = qDoxClass.getConstructors().get( 0 );
- assertEquals( 1, qDoxConstructor.getParameters().size() );
- JavaParameter qDoxParameter = qDoxConstructor.getParameters().get( 0 );
- assertEquals( "apiPath", qDoxParameter.getName() );
- assertEquals( qDoxConstructor, qDoxParameter.getDeclarator() );
- }
-
- // for QDOX-255
- public void testPackageAnnotation()
- {
- String source = "@Anot\r\n" +
- "package net.jcs.jboilerdowntest;\r\n" +
- "import net.jcs.annotation.Anot;";
-
- JavaProjectBuilder builder = new JavaProjectBuilder();
- JavaPackage pckg = builder.addSource( new StringReader( source) ).getPackage();
- assertEquals( "net.jcs.jboilerdowntest", pckg.getName() );
- assertEquals( 1, pckg.getAnnotations().size() );
- }
-
- public void testCanonicalName()
- throws Exception
- {
- String source =
- "package com.foo;\b" + "public class Outer {\n" + "public class Inner {\n" + "public class Core {}\n"
- + "}\n" + "}\n";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- assertEquals( "com.foo.Outer", cls.getFullyQualifiedName() );
- assertEquals( "com.foo.Outer", cls.getCanonicalName() );
- cls = cls.getNestedClassByName( "Inner" );
- assertEquals( "com.foo.Outer$Inner", cls.getFullyQualifiedName() );
- assertEquals( "com.foo.Outer.Inner", cls.getCanonicalName() );
- cls = cls.getNestedClassByName( "Core" );
- assertEquals( "com.foo.Outer$Inner$Core", cls.getFullyQualifiedName() );
- assertEquals( "com.foo.Outer.Inner.Core", cls.getCanonicalName() );
- }
-
- public void testEnumConstantMethods() {
- String source = "public enum MethodLocationOfEnumMethod\n" +
- "{\n" +
- " A()\n" +
- " {\n" +
- " @Override\n" +
- " private void method()\n" +
- " {\n" +
- " };\n" +
- " };\n" +
- " public abstract void method();\n" +
- " private void test()\n" +
- " {\n" +
- " };\n" +
- " \n" +
- " String name = \"x\";" +
- "}";
- builder.addSource( new StringReader( source ) );
- JavaClass cls = builder.getClassByName( "MethodLocationOfEnumMethod" );
- assertEquals( 2, cls.getMethods().size() );
- assertEquals( "method", cls.getMethods().get( 0 ).getName() );
- assertEquals( true, cls.getMethods().get( 0 ).isAbstract() );
- assertEquals( "test", cls.getMethods().get( 1 ).getName() );
- }
-
- // QDOX-240
- public void testComplexEnum() throws Exception
- {
- String source = "import java.util.HashMap;\r\n" +
- "\r\n" +
- "public enum MyEnum {\r\n" +
- " MAP(new HashMap<String, Object>()); // Parser throws java.util.EmptyStackException\r\n" +
- " \r\n" +
- " public final Object defaultValue;\r\n" +
- " \r\n" +
- " private MyEnum(Object defaultValue) {\r\n" +
- " this.defaultValue = defaultValue;\r\n" +
- " }\r\n" +
- "}";
- builder.addSource( new StringReader( source ) );
- }
-
-
-
- public void testSetDebugLexer()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- boolean debugLexer = true;
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaProjectBuilder projectBuilder = builder.setDebugLexer( debugLexer );
-
- verify( classLibraryBuilder ).setDebugLexer( debugLexer );
- assertSame( builder, projectBuilder );
- }
-
- public void testSetDebugParser()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- boolean debugParser = true;
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaProjectBuilder projectBuilder = builder.setDebugParser( debugParser );
-
- verify( classLibraryBuilder ).setDebugParser( debugParser );
- assertSame( builder, projectBuilder );
- }
- public void testSetEncoding()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- String encoding = "UTF-8";
+}
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaProjectBuilder projectBuilder = builder.setEncoding( encoding );
-
- verify( classLibraryBuilder ).setEncoding( same( encoding ) );
- assertSame( builder, projectBuilder );
- }
-
- public void testSetErrorHandler()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- ErrorHandler errorHandler = mock( ErrorHandler.class );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaProjectBuilder projectBuilder = builder.setErrorHandler( errorHandler );
-
- verify( classLibraryBuilder ).setErrorHander( same( errorHandler ) );
- assertSame( builder, projectBuilder );
- }
-
- public void testAddClassLoader()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- ClassLoader classLoader = mock( ClassLoader.class );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- builder.addClassLoader( classLoader );
-
- verify( classLibraryBuilder ).appendClassLoader( same( classLoader ) );
- }
-
- public void testAddFileSource() throws Exception
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- File file = mock( File.class );
- JavaSource source = mock( JavaSource.class );
-
- when( classLibraryBuilder.addSource( file ) ).thenReturn( source );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaSource addedSource = builder.addSource( file );
-
- verify( classLibraryBuilder ).addSource( same( file ) );
- assertSame( addedSource, source );
- }
-
- public void testAddReaderSource() throws Exception
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- Reader reader = mock( Reader.class );
- JavaSource source = mock( JavaSource.class );
-
- when( classLibraryBuilder.addSource( reader ) ).thenReturn( source );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaSource addedSource = builder.addSource( reader );
-
- verify( classLibraryBuilder ).addSource( same( reader ) );
- assertSame( addedSource, source );
- }
-
- public void testAddURLSource() throws Exception
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- URL url = new URL( "http://localhost" );
- JavaSource source = mock( JavaSource.class );
-
- when( classLibraryBuilder.addSource( url ) ).thenReturn( source );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- JavaSource addedSource = builder.addSource( url );
-
- verify( classLibraryBuilder ).addSource( same( url ) );
- assertSame( addedSource, source );
- }
-
- public void testAddSourceFolder()
- {
- ClassLibraryBuilder classLibraryBuilder = mock( ClassLibraryBuilder.class );
- File file = mock( File.class );
-
- builder = new JavaProjectBuilder( classLibraryBuilder );
- builder.addSourceFolder( file );
-
- verify( classLibraryBuilder ).appendSourceFolder( same( file ) );
- }
-}
\ No newline at end of file
diff --git a/src/test/com/thoughtworks/qdox/MethodsTest.java b/src/test/com/thoughtworks/qdox/MethodsTest.java
new file mode 100644
index 0000000..5cc654f
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/MethodsTest.java
@@ -0,0 +1,51 @@
+package com.thoughtworks.qdox;
+
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.JavaParameter;
+import junit.framework.TestCase;
+
+import java.io.StringReader;
+
+public class MethodsTest extends TestCase {
+
+ private JavaDocBuilder builder = new JavaDocBuilder();
+
+ public void testSupportsJava5VarArgsParameter() {
+ JavaMethod javaMethod = buildMethod("void doStuff(AThing param1, BThing... param2);");
+
+ JavaParameter standardParam = javaMethod.getParameterByName("param1");
+ JavaParameter varArgsParam = javaMethod.getParameterByName("param2");
+
+ assertFalse("param1 should NOT be var args", standardParam.isVarArgs());
+ assertTrue("param2 should be var args", varArgsParam.isVarArgs());
+ }
+
+ public void testVarArgsParametersAreAlsoArrays() {
+ JavaMethod javaMethod = buildMethod("void doStuff(AThing param1, BThing[] param2, CThing... param3);");
+
+ Type standardType = javaMethod.getParameterByName("param1").getType();
+ Type arrayType = javaMethod.getParameterByName("param2").getType();
+ Type varArgsType = javaMethod.getParameterByName("param3").getType();
+
+ assertFalse("param1 should NOT be array", standardType.isArray());
+ assertTrue("param2 should be array", arrayType.isArray());
+ assertFalse("param3 should NOT be array", varArgsType.isArray());
+ }
+
+ public void testVarArgsIncludedInToString() {
+ JavaMethod javaMethod = buildMethod("void doStuff(AThing param1, BThing... param2);");
+
+ assertEquals("void doStuff(AThing param1, BThing... param2);\n", javaMethod.getCodeBlock());
+ }
+
+ private JavaMethod buildMethod(String methodSource) {
+ String source = "interface Something { " + methodSource + " }";
+ JavaSource javaSource = builder.addSource(new StringReader(source));
+ JavaClass javaClass = javaSource.getClasses()[0];
+ JavaMethod javaMethod = javaClass.getMethods()[0];
+ return javaMethod;
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/TestQDoxBug131.java b/src/test/com/thoughtworks/qdox/TestQDoxBug131.java
new file mode 100644
index 0000000..607e287
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/TestQDoxBug131.java
@@ -0,0 +1,30 @@
+package com.thoughtworks.qdox;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.model.JavaClass;
+
+public class TestQDoxBug131 extends TestCase {
+ public void testname() throws Exception {
+ String sourceCode = "package com.acme.qdox;\n" +
+ "\n" +
+ "public class QDoxBugClass {\n" +
+ " final public static String C1 = \"C1\", C2 = \"C2\";\n" +
+ " final public static String[] ALL = { C1, C2 }; \n" +
+ " /*\n" +
+ " Comment\n" +
+ " */\n" +
+ " public void method() {\n" +
+ " System.out.println(\"This will contain the comment\");\n" +
+ " }\n" +
+ "}\n" +
+ "";
+ JavaDocBuilder builder = new JavaDocBuilder();
+ builder.addSource(new StringReader(sourceCode));
+ JavaClass aClass = builder.getClassByName("com.acme.qdox.QDoxBugClass");
+ assertEquals("\n System.out.println(\"This will contain the comment\");\n ",
+ aClass.getMethods()[0].getSourceCode());
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/ant/AbstractQdoxTaskTest.java b/src/test/com/thoughtworks/qdox/ant/AbstractQdoxTaskTest.java
new file mode 100644
index 0000000..8648bf2
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/ant/AbstractQdoxTaskTest.java
@@ -0,0 +1,128 @@
+package com.thoughtworks.qdox.ant;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.FileSet;
+import com.thoughtworks.qdox.model.*;
+
+// Not really abstract, but a test of the abstract.
+
+public class AbstractQdoxTaskTest extends TestCase {
+
+ public AbstractQdoxTaskTest(String name) {
+ super(name);
+ }
+
+ public void testBasic() throws Exception {
+ OveriddenAbstractQdoxTask task = new OveriddenAbstractQdoxTask();
+ task.addFileset(new OveriddenFileSet("src/java", new String[]{"com/thoughtworks/qdox/directorywalker/SuffixFilter.java"}));
+ task.execute();
+
+ JavaClass hopefullySuffixFilter = ((JavaClass) task.allClasses.get(0));
+
+ assertNotNull("Expected a JavaClass", task.allClasses.get(0));
+ assertEquals("SuffixFilter", hopefullySuffixFilter.getName());
+ assertEquals("com.thoughtworks.qdox.directorywalker.SuffixFilter", task.classes);
+ }
+
+ public void testPluggableTagFactory() {
+ OwnTagFactoryUsingQdoxTask task = new OwnTagFactoryUsingQdoxTask();
+ task.execute();
+ }
+
+ private class OwnTagFactoryUsingQdoxTask extends AbstractQdoxTask {
+
+ public OwnTagFactoryUsingQdoxTask() {
+ addFileset(new OveriddenFileSet("src/test", new String[]{"com/thoughtworks/qdox/testdata/PropertyClass.java"}));
+ }
+
+ protected DocletTagFactory createDocletTagFactory() {
+ // Tag factory that returns tags with "aslak." prefixed to their "original" name.
+ // Not useful at all, only to test that we can actually plug in any tag factory.
+ return new DocletTagFactory() {
+ public DocletTag createDocletTag(String tag, String text, AbstractBaseJavaEntity context, int lineNumber) {
+ return new DefaultDocletTag("aslak." + tag, text);
+ }
+ public DocletTag createDocletTag(String tag, String text) {
+ fail();
+ return null;
+ }
+ };
+ }
+
+ public void execute() {
+ super.execute();
+
+ JavaClass hopefullyPropertyClass = (JavaClass) allClasses.get(0);
+ DocletTag hopefullyAslakDotFoo = hopefullyPropertyClass.getTagByName("aslak.foo");
+ assertNotNull(hopefullyAslakDotFoo);
+ assertEquals("zap", hopefullyAslakDotFoo.getNamedParameter("bar"));
+ }
+ }
+
+ public void testNoFileSets() {
+ OveriddenAbstractQdoxTask task = new OveriddenAbstractQdoxTask();
+ try {
+ task.execute();
+ fail("Expected an empty list of classes");
+ } catch (BuildException e) {
+ // expected
+ }
+ }
+
+ private class OveriddenAbstractQdoxTask extends AbstractQdoxTask {
+ public String classes = "";
+
+ public void execute() {
+ super.execute();
+
+ for (int i = 0; i < allClasses.size(); i++) {
+ JavaClass javaClass = (JavaClass) allClasses.get(i);
+ classes = classes + javaClass.getFullyQualifiedName();
+ // Interested in seeing output? Uncomment this.
+ // System.out.println("Class:" + javaClass.getName());
+ }
+ }
+ }
+
+ private class OveriddenFileSet extends FileSet {
+ private OveridenDirectoryScanner overidenDirectoryScanner;
+ private String dir;
+
+ public OveriddenFileSet(String dir, String[] includedFiles) {
+ this.dir = dir;
+ overidenDirectoryScanner = new OveridenDirectoryScanner(includedFiles);
+ }
+
+ public File getDir(Project project) {
+ return getUnderJUnitFile(dir);
+ }
+
+ public DirectoryScanner getDirectoryScanner(Project project) {
+ return overidenDirectoryScanner;
+ }
+ }
+
+ public static File getUnderJUnitFile(String filename) {
+ File result = new File("../" + filename);
+ if (result.exists()) return result;
+ return new File(filename);
+ }
+
+ private class OveridenDirectoryScanner extends DirectoryScanner {
+ private String[] includedFiles;
+
+ public OveridenDirectoryScanner(String[] includedFiles) {
+ this.includedFiles = includedFiles;
+ }
+
+ public String[] getIncludedFiles() {
+ return includedFiles;
+ }
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java b/src/test/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java
new file mode 100644
index 0000000..8d42a0d
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java
@@ -0,0 +1,136 @@
+package com.thoughtworks.qdox.directorywalker;
+
+import java.io.File;
+
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+public class DirectoryScannerTest extends MockObjectTestCase {
+
+ class MockFile extends File {
+ boolean isDirectory;
+ File[] children;
+
+ public MockFile(String pathname) {
+ super(pathname);
+ this.isDirectory = false;
+ }
+
+ public MockFile(String pathname, boolean isDirectory) {
+ super(pathname);
+ this.isDirectory = isDirectory;
+ }
+
+ public boolean isDirectory() {
+ return this.isDirectory;
+ }
+
+ public File[] listFiles() {
+ return children;
+ }
+ }
+
+ public DirectoryScannerTest(String s) {
+ super(s);
+ }
+
+ public void testSingleDirectory() {
+ MockFile rootDir = new MockFile("root", true);
+ rootDir.children = new File[]{new MockFile("blah.txt"), new MockFile("foo.txt"), new MockFile("pig.java")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ File[] files = scanner.scan();
+ assertEquals(3, files.length);
+ assertEquals("blah.txt", files[0].getName());
+ assertEquals("foo.txt", files[1].getName());
+ assertEquals("pig.java", files[2].getName());
+ }
+
+ public void testDirectoryWithSubdir() {
+ MockFile rootDir = new MockFile("root", true);
+ MockFile subDir = new MockFile("subdir", true);
+ subDir.children = new File[]{new MockFile("child1.txt"), new MockFile("child2.txt")};
+ rootDir.children = new File[]{subDir, new MockFile("foo.txt"), new MockFile("pig.java")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ File[] files = scanner.scan();
+ assertEquals(4, files.length);
+ assertEquals("child1.txt", files[0].getName());
+ assertEquals("child2.txt", files[1].getName());
+ assertEquals("foo.txt", files[2].getName());
+ assertEquals("pig.java", files[3].getName());
+ }
+
+ public void testDirectoryWithSubdirWithSubdir() {
+ MockFile rootDir = new MockFile("root", true);
+ MockFile subDir1 = new MockFile("subdir", true);
+ MockFile subDir2 = new MockFile("subdir2", true);
+ subDir2.children = new File[]{new MockFile("grandChild1.txt")};
+ subDir1.children = new File[]{subDir2, new MockFile("child1.txt"), new MockFile("child2.txt")};
+ rootDir.children = new File[]{subDir1, new MockFile("foo.txt"), new MockFile("pig.java")};
+
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ File[] files = scanner.scan();
+ assertEquals(5, files.length);
+ assertEquals("grandChild1.txt", files[0].getName());
+ assertEquals("child1.txt", files[1].getName());
+ assertEquals("child2.txt", files[2].getName());
+ assertEquals("foo.txt", files[3].getName());
+ assertEquals("pig.java", files[4].getName());
+ }
+
+ public void testSuffixFilter() {
+ MockFile rootDir = new MockFile("root", true);
+ rootDir.children = new File[]{new MockFile("blah.txt"), new MockFile("foo.java"), new MockFile("pig.java")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ scanner.addFilter(new SuffixFilter(".java"));
+ File[] files = scanner.scan();
+ assertEquals(2, files.length);
+ assertEquals("foo.java", files[0].getName());
+ assertEquals("pig.java", files[1].getName());
+ }
+
+ public void testFilterCallback() {
+ MockFile rootDir = new MockFile("root", true);
+ rootDir.children = new File[]{new MockFile("blah.txt"), new MockFile("foo.java"), new MockFile("pig.java")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ Filter mockFilter = new Filter() {
+ public boolean filter(File file) {
+ return file.getName().equals("foo.java");
+ }
+ };
+ scanner.addFilter(mockFilter);
+ File[] files = scanner.scan();
+ assertEquals(1, files.length);
+ assertEquals("foo.java", files[0].getName());
+ }
+
+ public void testMultipleFilters() {
+ MockFile rootDir = new MockFile("root", true);
+ rootDir.children = new File[]{new MockFile("blah.txt"), new MockFile("foo.java"),
+ new MockFile("pig.java"), new MockFile("foo.txt")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ scanner.addFilter(new SuffixFilter(".java"));
+ scanner.addFilter(new Filter() {
+ public boolean filter(File file) {
+ return file.getName().startsWith("foo");
+ }
+ });
+ File[] files = scanner.scan();
+ assertEquals(1, files.length);
+ assertEquals("foo.java", files[0].getName());
+ }
+
+ public void testFileVisitor() {
+ MockFile rootDir = new MockFile("root", true);
+ rootDir.children = new File[]{new MockFile("blah.txt"), new MockFile("foo.txt"), new MockFile("pig.java")};
+ DirectoryScanner scanner = new DirectoryScanner(rootDir);
+ Mock mockFileVisitor = new Mock(FileVisitor.class);
+ mockFileVisitor.expects(once()).method("visitFile").with(same(rootDir.children[0]));
+ mockFileVisitor.expects(once()).method("visitFile").with(same(rootDir.children[1]));
+ mockFileVisitor.expects(once()).method("visitFile").with(same(rootDir.children[2]));
+
+ scanner.scan((FileVisitor) mockFileVisitor.proxy());
+
+ mockFileVisitor.verify();
+
+ }
+}
diff --git a/src/test/java/com/thoughtworks/qdox/model/AbstractDocletTagTest.java b/src/test/com/thoughtworks/qdox/model/AbstractDocletTagTest.java
similarity index 72%
rename from src/test/java/com/thoughtworks/qdox/model/AbstractDocletTagTest.java
rename to src/test/com/thoughtworks/qdox/model/AbstractDocletTagTest.java
index ba8ca8b..eef5a29 100644
--- a/src/test/java/com/thoughtworks/qdox/model/AbstractDocletTagTest.java
+++ b/src/test/com/thoughtworks/qdox/model/AbstractDocletTagTest.java
@@ -1,8 +1,10 @@
package com.thoughtworks.qdox.model;
-import java.util.Map;
-
import junit.framework.TestCase;
+import com.thoughtworks.qdox.JavaDocBuilder;
+
+import java.io.StringReader;
+import java.util.Map;
public abstract class AbstractDocletTagTest extends TestCase {
@@ -16,13 +18,28 @@ public abstract class AbstractDocletTagTest extends TestCase {
return getDocletTagFactory().createDocletTag(tag, text);
}
+ public void testValueRemainsIntact() throws Exception {
+ String in = ""
+ + "package x;\n"
+ + "/**\n"
+ + " * @tag aa count(*) bbb * ccc dd=e f='g' i = \"xx\"\n"
+ + " */\n"
+ + "class X {}";
+
+ JavaDocBuilder builder = new JavaDocBuilder(getDocletTagFactory());
+ builder.addSource(new StringReader(in));
+ DocletTag tag = builder.getClassByName("x.X").getTagByName("tag");
+
+ assertEquals("aa count(*) bbb * ccc dd=e f='g' i = \"xx\"", tag.getValue());
+ }
+
public void testIndexedParameter() throws Exception {
DocletTag tag = createDocletTag("x", "one two three four");
- assertEquals("one", tag.getParameters().get(0));
- assertEquals("two", tag.getParameters().get(1));
- assertEquals("three", tag.getParameters().get(2));
- assertEquals("four", tag.getParameters().get(3));
- assertEquals(4, tag.getParameters().size());
+ assertEquals("one", tag.getParameters()[0]);
+ assertEquals("two", tag.getParameters()[1]);
+ assertEquals("three", tag.getParameters()[2]);
+ assertEquals("four", tag.getParameters()[3]);
+ assertEquals(4, tag.getParameters().length);
}
public void testNamedParameter() throws Exception {
@@ -69,9 +86,9 @@ public abstract class AbstractDocletTagTest extends TestCase {
public void testJiraQdox28() {
DocletTag tag = createDocletTag("key", "quote'ed");
- assertEquals("quote", tag.getParameters().get(0));
- assertEquals(2, tag.getParameters().size());
- assertEquals("ed", tag.getParameters().get(1));
+ assertEquals("quote", tag.getParameters()[0]);
+ assertEquals(2, tag.getParameters().length);
+ assertEquals("ed", tag.getParameters()[1]);
}
public void testJiraQdox45() {
diff --git a/src/test/com/thoughtworks/qdox/model/AbstractJavaEntityTest.java b/src/test/com/thoughtworks/qdox/model/AbstractJavaEntityTest.java
new file mode 100644
index 0000000..438ecce
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/AbstractJavaEntityTest.java
@@ -0,0 +1,244 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+import java.util.List;
+import java.util.LinkedList;
+
+public class AbstractJavaEntityTest extends TestCase {
+
+ public AbstractJavaEntityTest(String s) {
+ super(s);
+ }
+
+ public void testGetTagsByNameMethod() throws Exception {
+ AbstractJavaEntity entity = new JavaField();
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", "is good"));
+ tags.add(new DefaultDocletTag("monkey", "is funny"));
+ tags.add(new DefaultDocletTag("horse", "not so much"));
+ entity.setTags(tags);
+
+ assertEquals(2, entity.getTagsByName("monkey").length);
+ assertEquals(1, entity.getTagsByName("horse").length);
+ assertEquals(0, entity.getTagsByName("non existent tag").length);
+ }
+
+ public void testGetSingleTagByName() throws Exception {
+
+ AbstractJavaEntity entity = new JavaField();
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", "is good"));
+ tags.add(new DefaultDocletTag("monkey", "is funny"));
+ tags.add(new DefaultDocletTag("horse", "not so much"));
+ entity.setTags(tags);
+
+ assertEquals("is good", entity.getTagByName("monkey").getValue());
+ assertEquals("not so much", entity.getTagByName("horse").getValue());
+ assertNull(entity.getTagByName("cow"));
+
+ }
+
+ public void testCommentToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ entity.setComment("Hello");
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testMultilineCommentToString() {
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ entity.setComment("Hello\nWorld");
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " * World\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+
+ }
+
+ public void testNoCommentToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+
+ // expectation
+ String expected = "";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testCommentWithTagToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ entity.setComment("Hello");
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", "is in the tree"));
+ entity.setTags(tags);
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " *\n"
+ + " * @monkey is in the tree\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testCommentWithMultipleTagsToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ entity.setComment("Hello");
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", "is in the tree"));
+ tags.add(new DefaultDocletTag("see", "the doctor"));
+ entity.setTags(tags);
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " *\n"
+ + " * @monkey is in the tree\n"
+ + " * @see the doctor\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testTagButNoCommentToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", "is in the tree"));
+ entity.setTags(tags);
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * @monkey is in the tree\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testTagWithNoValueToString() {
+ // setup
+ AbstractJavaEntity entity = new JavaField();
+ IndentBuffer buffer = new IndentBuffer();
+ List tags = new LinkedList();
+ tags.add(new DefaultDocletTag("monkey", ""));
+ entity.setTags(tags);
+
+ // expectation
+ String expected = ""
+ + "/**\n"
+ + " * @monkey\n"
+ + " */\n";
+
+ // run
+ entity.commentHeader(buffer);
+
+ // verify
+ assertEquals(expected, buffer.toString());
+ }
+
+ public void testPublicModifer() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"public"});
+ assertTrue(entity.isPublic());
+ }
+
+ public void testPrivateModifer() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"private"});
+ assertTrue(entity.isPrivate());
+ }
+
+ public void testAbstractModifer() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"public", "abstract"});
+ assertTrue(entity.isAbstract());
+ assertTrue(!entity.isPrivate());
+ }
+
+ public void testProtectedModifer() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"protected", "abstract", "synchronized", "transient"});
+ assertTrue(entity.isProtected());
+ assertTrue(entity.isSynchronized());
+ assertTrue(entity.isTransient());
+ }
+
+ public void testStaticModifer() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"public", "static", "final"});
+ assertTrue(entity.isStatic());
+ assertTrue(entity.isFinal());
+ }
+
+ public void testQDOX30() {
+ AbstractJavaEntity entity = new JavaField();
+ entity.setModifiers(new String[]{"native", "volatile", "strictfp"});
+ assertTrue(entity.isNative());
+ assertTrue(entity.isVolatile());
+ assertTrue(entity.isStrictfp());
+ }
+
+ public void testGetTagsReturnsEmptyArrayInsteadOfNull() throws Exception {
+ AbstractJavaEntity entity = new JavaField();
+ assertEquals(0, entity.getTags().length);
+ }
+
+ public void testGetSource() {
+ JavaSource source = new JavaSource();
+ JavaClass clazz = new JavaClass();
+ source.addClass(clazz);
+ JavaField field = new JavaField();
+ clazz.addField(field);
+ assertEquals(source, field.getSource());
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/model/ClassLibraryTest.java b/src/test/com/thoughtworks/qdox/model/ClassLibraryTest.java
new file mode 100644
index 0000000..9aa1cd5
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/ClassLibraryTest.java
@@ -0,0 +1,70 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+import java.util.Collection;
+
+public class ClassLibraryTest extends TestCase {
+
+ public ClassLibraryTest(String s) {
+ super(s);
+ }
+
+ public JavaClass getClassByName(String name) {
+ JavaClass clazz = new JavaClass();
+ clazz.setName("MyClass");
+ return clazz;
+ }
+
+ public JavaClass[] getClasses() {
+ return new JavaClass[0];
+ }
+
+ public void testAdd() throws Exception {
+ ClassLibrary c = new ClassLibrary();
+ c.add("com.blah.Ping");
+ c.add("com.moo.Poo");
+ assertTrue(c.contains("com.blah.Ping"));
+ assertTrue(c.contains("com.moo.Poo"));
+ assertTrue(!c.contains("com.not.You"));
+ }
+
+ public void testListAll() throws Exception {
+ ClassLibrary c = new ClassLibrary();
+ c.add("com.blah.Ping");
+ c.add("com.thing.Ping");
+ c.add("com.x.Goat");
+ c.add("com.y.Goat");
+
+ Collection all = c.all();
+ assertTrue(all.contains("com.blah.Ping"));
+ assertTrue(all.contains("com.thing.Ping"));
+ assertTrue(all.contains("com.x.Goat"));
+ assertTrue(all.contains("com.y.Goat"));
+
+ assertTrue(!all.contains("com.not.True"));
+ assertEquals(4, all.size());
+ }
+
+ public void testNoClassLoaders() throws Exception {
+ ClassLibrary c = new ClassLibrary();
+ assertTrue(!c.contains("java.lang.String"));
+ }
+
+ public void testWithClassLoader() throws Exception {
+ ClassLibrary c = new ClassLibrary();
+ c.addClassLoader(getClass().getClassLoader());
+ assertTrue(c.contains("java.lang.String"));
+ assertTrue(c.contains("java.util.Collection"));
+ assertTrue(!c.contains("java.util.GoatCrusher"));
+ }
+
+ public void testDefaultClassLoader() throws Exception {
+ ClassLibrary c = new ClassLibrary();
+ c.addDefaultLoader();
+ assertTrue(c.contains("java.lang.String"));
+ assertTrue(c.contains("java.util.Collection"));
+ assertTrue(c.contains("java.util.Map$Entry"));
+ assertTrue(!c.contains("java.util.GoatCrusher"));
+ }
+}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagTest.java b/src/test/com/thoughtworks/qdox/model/DefaultDocletTagTest.java
similarity index 84%
rename from src/test/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagTest.java
rename to src/test/com/thoughtworks/qdox/model/DefaultDocletTagTest.java
index 90d1d38..9669a36 100644
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultDocletTagTest.java
+++ b/src/test/com/thoughtworks/qdox/model/DefaultDocletTagTest.java
@@ -1,10 +1,7 @@
-package com.thoughtworks.qdox.model.impl;
+package com.thoughtworks.qdox.model;
-import java.util.Map;
-
-import com.thoughtworks.qdox.model.AbstractDocletTagTest;
-import com.thoughtworks.qdox.model.DocletTagFactory;
import com.thoughtworks.qdox.model.util.SerializationUtils;
+import java.util.Map;
/**
*
diff --git a/src/test/java/com/thoughtworks/qdox/writer/impl/IndentBufferTest.java b/src/test/com/thoughtworks/qdox/model/IndentBufferTest.java
similarity index 77%
rename from src/test/java/com/thoughtworks/qdox/writer/impl/IndentBufferTest.java
rename to src/test/com/thoughtworks/qdox/model/IndentBufferTest.java
index aa09900..2fdc383 100644
--- a/src/test/java/com/thoughtworks/qdox/writer/impl/IndentBufferTest.java
+++ b/src/test/com/thoughtworks/qdox/model/IndentBufferTest.java
@@ -1,22 +1,20 @@
-package com.thoughtworks.qdox.writer.impl;
+package com.thoughtworks.qdox.model;
-import static org.junit.Assert.assertEquals;
+import junit.framework.TestCase;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.writer.impl.IndentBuffer;
-
-public class IndentBufferTest {
+public class IndentBufferTest extends TestCase {
private IndentBuffer buffer;
- @Before
- public void setUp() throws Exception {
+ public IndentBufferTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
buffer = new IndentBuffer();
}
- @Test
public void testNoIndentation() throws Exception {
buffer.write("A string");
buffer.newline();
@@ -29,7 +27,6 @@ public class IndentBufferTest {
assertEquals(expected, buffer.toString());
}
- @Test
public void testIndentation() throws Exception {
buffer.write("Line1");
buffer.newline();
diff --git a/src/test/com/thoughtworks/qdox/model/JavaClassTest.java b/src/test/com/thoughtworks/qdox/model/JavaClassTest.java
new file mode 100644
index 0000000..fc96403
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaClassTest.java
@@ -0,0 +1,639 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+import java.util.HashMap;
+
+public class JavaClassTest extends TestCase {
+
+ private JavaClass cls;
+ private JavaSource src;
+
+ public JavaClassTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ src = new JavaSource();
+ cls = new JavaClass();
+ src.addClass(cls);
+ }
+
+ public void testGetCodeBlockSimpleClass() throws Exception {
+ cls.setName("MyClass");
+ String expected = ""
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockSimpleInterface() throws Exception {
+ cls.setName("MyClass");
+ cls.setInterface(true);
+ String expected = ""
+ + "interface MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockSimpleEnum() throws Exception {
+ cls.setName("MyEnum");
+ cls.setEnum(true);
+ String expected = ""
+ + "enum MyEnum {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ public void testGetCodeBlockInterfaceExtends() throws Exception {
+ cls.setName("MyClass");
+ cls.setImplementz(type(new String[]{"SomeInterface"}));
+ cls.setInterface(true);
+ String expected = ""
+ + "interface MyClass extends SomeInterface {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockInterfaceExtendsTwo() throws Exception {
+ cls.setName("MyClass");
+ cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface"}));
+ cls.setInterface(true);
+ String expected = ""
+ + "interface MyClass extends SomeInterface, AnotherInterface {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockInterfaceExtendsThree() throws Exception {
+ cls.setName("MyClass");
+ cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface", "Thingy"}));
+ cls.setInterface(true);
+ String expected = ""
+ + "interface MyClass extends SomeInterface, AnotherInterface, Thingy {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassImplementsAndExtends() throws Exception {
+ cls.setName("MyClass");
+ cls.setImplementz(type(new String[]{"SomeInterface", "AnotherInterface", "Xx"}));
+ cls.setSuperClass(new Type("SubMarine"));
+ String expected = ""
+ + "class MyClass extends SubMarine implements SomeInterface, AnotherInterface, Xx {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+
+ cls.setModifiers(new String[]{"abstract", "protected"});
+ expected = ""
+ + "protected abstract class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithOneMethod() throws Exception {
+ cls.setName("MyClass");
+ JavaMethod mth = new JavaMethod();
+ mth.setName("doStuff");
+ mth.setReturns(new Type("void"));
+ cls.addMethod(mth);
+ String expected = ""
+ + "class MyClass {\n"
+ + "\n"
+ + "\tvoid doStuff();\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithThreeMethods() throws Exception {
+ cls.setName("MyClass");
+
+ {
+ JavaMethod mth = new JavaMethod();
+ mth.setName("doStuff");
+ mth.setReturns(new Type("void"));
+ cls.addMethod(mth);
+ }
+
+ {
+ JavaMethod mth = new JavaMethod();
+ mth.setName("somethingElse");
+ mth.setReturns(new Type("Goose"));
+ cls.addMethod(mth);
+ }
+
+ {
+ JavaMethod mth = new JavaMethod();
+ mth.setName("eat");
+ mth.setReturns(new Type("void"));
+ cls.addMethod(mth);
+ }
+
+ String expected = ""
+ + "class MyClass {\n"
+ + "\n"
+ + "\tvoid doStuff();\n"
+ + "\n"
+ + "\tGoose somethingElse();\n"
+ + "\n"
+ + "\tvoid eat();\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithTwoFields() throws Exception {
+ cls.setName("MyClass");
+
+ {
+ JavaField fld = new JavaField();
+ fld.setName("count");
+ fld.setType(new Type("int"));
+ cls.addField(fld);
+ }
+
+ {
+ JavaField fld = new JavaField();
+ fld.setName("thing");
+ fld.setType(new Type("String"));
+ fld.setModifiers(new String[]{"public"});
+ cls.addField(fld);
+ }
+
+ String expected = ""
+ + "class MyClass {\n"
+ + "\n"
+ + "\tint count;\n"
+ + "\n"
+ + "\tpublic String thing;\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithInnerClass() throws Exception {
+ cls.setName("Outer");
+ JavaClass innerClass = new JavaClass();
+ innerClass.setName("Inner");
+ cls.addClass(innerClass);
+
+ String expected = ""
+ + "class Outer {\n"
+ + "\n"
+ + "\tclass Inner {\n"
+ + "\n"
+ + "\t}\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithInnerEnum() throws Exception {
+ cls.setName("Outer");
+ JavaClass innerEnum = new JavaClass();
+ innerEnum.setEnum(true);
+ innerEnum.setName("Inner");
+ cls.addClass(innerEnum);
+
+ String expected = ""
+ + "class Outer {\n"
+ + "\n"
+ + "\tenum Inner {\n"
+ + "\n"
+ + "\t}\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockEnumWithInnerClass() throws Exception {
+ cls.setName("Outer");
+ cls.setEnum(true);
+ JavaClass innerClass = new JavaClass();
+ innerClass.setName("Inner");
+ cls.addClass(innerClass);
+
+ String expected = ""
+ + "enum Outer {\n"
+ + "\n"
+ + "\tclass Inner {\n"
+ + "\n"
+ + "\t}\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+
+ public void testGetCodeBlockClassWithComment() throws Exception {
+ cls.setName("MyClass");
+ cls.setComment("Hello World");
+
+ String expected = ""
+ + "/**\n"
+ + " * Hello World\n"
+ + " */\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testGetCodeBlockClassWithIndentedCommentsForFieldAndMethod() throws Exception {
+ cls.setName("MyClass");
+ cls.setComment("Hello World");
+
+ JavaMethod mth = new JavaMethod();
+ mth.setReturns(new Type("String"));
+ mth.setName("thingy");
+ mth.setComment("Hello Method");
+ cls.addMethod(mth);
+
+ JavaField fld = new JavaField();
+ fld.setType(new Type("String"));
+ fld.setName("thing");
+ fld.setComment("Hello Field");
+ cls.addField(fld);
+
+ String expected = ""
+ + "/**\n"
+ + " * Hello World\n"
+ + " */\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "\t/**\n"
+ + "\t * Hello Field\n"
+ + "\t */\n"
+ + "\tString thing;\n"
+ + "\n"
+ + "\t/**\n"
+ + "\t * Hello Method\n"
+ + "\t */\n"
+ + "\tString thingy();\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, cls.getCodeBlock());
+ }
+
+ public void testIsPublic() {
+ cls.setName("MyClass");
+ assertTrue(!cls.isPublic());
+
+ cls.setModifiers(new String[]{"public"});
+ assertTrue(cls.isPublic());
+ }
+
+ public void testQualifiedType() throws Exception {
+ src.setPackage(new JavaPackage("com.thoughtworks.qdox", new HashMap()));
+
+ cls.setName("MyClass");
+
+ assertEquals("MyClass", cls.getName());
+ assertEquals("com.thoughtworks.qdox", cls.getPackage().getName());
+ assertEquals("com.thoughtworks.qdox", cls.getPackageName());
+ assertEquals("com.thoughtworks.qdox.MyClass",
+ cls.getFullyQualifiedName());
+ assertTrue(cls.asType().isResolved());
+ assertEquals("com.thoughtworks.qdox.MyClass", cls.asType().getValue());
+ }
+
+ public void testGetClassNamePrefix() {
+ src.setPackage(new JavaPackage("foo.bar", new HashMap()));
+ cls.setName("Stanley");
+ assertEquals("foo.bar.Stanley$", cls.getClassNamePrefix());
+ }
+
+ public void testInnerClass() throws Exception {
+ src.setPackage(new JavaPackage("foo.bar", new HashMap()));
+
+ JavaClass outer = new JavaClass();
+ outer.setName("Outer");
+ src.addClass(outer);
+
+ JavaClass inner = new JavaClass();
+ inner.setName("Inner");
+ outer.addClass(inner);
+
+ assertEquals("Inner", inner.getName());
+ assertEquals("foo.bar", inner.getPackage().getName());
+ assertEquals("foo.bar", inner.getPackageName());
+ assertEquals("foo.bar.Outer$Inner",
+ inner.getFullyQualifiedName());
+ }
+
+ public void testDefaultPackageClass() {
+ src.setPackage(null);
+ cls.setName("DefaultPackageClass");
+
+ assertEquals("", src.getClasses()[0].getPackageName());
+ assertEquals("DefaultPackageClass", src.getClasses()[0].getFullyQualifiedName());
+ }
+
+ public void testDefaultClassSuperclass() throws Exception {
+ cls.setName("MyClass");
+ assertEquals("java.lang.Object", cls.getSuperClass().getValue());
+ cls.setSuperClass(new Type("x.X"));
+ assertEquals("x.X", cls.getSuperClass().getValue());
+ }
+
+ public void testDefaultInterfaceSuperclass() throws Exception {
+ cls.setName("MyInterface");
+ cls.setInterface(true);
+ assertNull(cls.getSuperClass());
+ cls.setSuperClass(new Type("x.X"));
+ assertEquals("x.X", cls.getSuperClass().getValue());
+ }
+
+ public void testEnumSuperclass() throws Exception {
+ cls.setName("MyEnum");
+ cls.setEnum(true);
+ assertEquals("java.lang.Enum", cls.getSuperClass().getValue());
+ }
+
+ public void testEnumCannotExtendAnythingElse() throws Exception {
+ cls.setName("MyEnum");
+ cls.setEnum(true);
+ try {
+ cls.setSuperClass(new Type("x.X"));
+ fail("expected an exception");
+ } catch (IllegalArgumentException e) {
+ assertEquals("enums cannot extend other classes", e.getMessage());
+ }
+ }
+
+ public void testCanGetFieldByName() throws Exception {
+ JavaField fredField = new JavaField();
+ fredField.setName("fred");
+ fredField.setType(new Type("int"));
+ cls.addField(fredField);
+
+ assertEquals(fredField, cls.getFieldByName("fred"));
+ assertEquals(null, cls.getFieldByName("barney"));
+ }
+
+ public void testCanGetMethodBySignature() {
+ JavaMethod method = new JavaMethod();
+ method.setReturns(new Type("void"));
+ method.setName("doStuff");
+ method.addParameter( new JavaParameter(new Type("int"), "x") );
+ method.addParameter( new JavaParameter(new Type("double"), "y") );
+ cls.addMethod(method);
+
+ Type[] correctTypes = type(new String[]{"int", "double"});
+ assertSame(
+ method,
+ cls.getMethodBySignature("doStuff", correctTypes)
+ );
+ assertEquals(
+ null,
+ cls.getMethodBySignature("doStuff", new Type[0])
+ );
+ assertEquals(
+ null,
+ cls.getMethodBySignature("sitIdlyBy", correctTypes)
+ );
+ }
+
+ public void testCanGetInnerClassByName() throws Exception {
+ JavaClass innerClass = new JavaClass();
+ innerClass.setName("Inner");
+ cls.addClass(innerClass);
+
+ assertEquals(innerClass, cls.getNestedClassByName("Inner"));
+ assertEquals(null, cls.getNestedClassByName("Bogus"));
+ }
+
+ public void testResolveTypeDefaultsToParentScope() throws Exception {
+ cls.setName("X");
+ assertEquals("int", cls.resolveType("int"));
+ }
+
+ public void testResolveTypeInnerClass() throws Exception {
+ src.setPackage(new JavaPackage("p", new HashMap()));
+ cls.setName("X");
+ JavaClass innerClass = new JavaClass();
+ innerClass.setName("DogFood");
+ cls.addClass(innerClass);
+ assertEquals("p.X$DogFood", cls.resolveType("DogFood"));
+ assertEquals(null, cls.resolveType("Food"));
+ }
+
+ public void testGetBeanPropertiesReturnsEmptyForEmptyClass() throws Exception {
+ assertEquals(0, cls.getBeanProperties().length);
+ }
+
+ public void testGetBeanPropertiesFindsSimpleProperties() throws Exception {
+ JavaMethod setFooMethod = new JavaMethod("setFoo");
+ setFooMethod.addParameter(new JavaParameter(new Type("int"), "foo"));
+ cls.addMethod(setFooMethod);
+
+ JavaMethod getFooMethod = new JavaMethod(new Type("int"), "getFoo");
+ cls.addMethod(getFooMethod);
+
+ assertEquals(1, cls.getBeanProperties().length);
+ BeanProperty fooProp = cls.getBeanProperties()[0];
+ assertEquals("foo", fooProp.getName());
+ assertEquals(new Type("int"), fooProp.getType());
+ assertEquals(getFooMethod, fooProp.getAccessor());
+ assertEquals(setFooMethod, fooProp.getMutator());
+ }
+
+ public void testToStringClass() {
+ cls.setName("com.MyClass");
+ assertEquals("class com.MyClass", cls.toString());
+ }
+
+ public void testInnerClassToString() throws Exception {
+ JavaPackage jPackage = new JavaPackage("com.thoughtworks.qdox.model");
+ JavaClass jOuterClass = new JavaClass("OuterClass");
+ jPackage.addClass(jOuterClass);
+ JavaClass jInnerClass = new JavaClass("InnerClass");
+ jOuterClass.addClass(jInnerClass);
+ assertEquals("class com.thoughtworks.qdox.model.OuterClass$InnerClass", jInnerClass.toString());
+ }
+
+ public void testInnerClassType() {
+ JavaPackage jPackage = new JavaPackage("com.thoughtworks.qdox.model");
+ JavaClass jOuterClass = new JavaClass("OuterClass");
+ jPackage.addClass(jOuterClass);
+ JavaClass jInnerClass = new JavaClass("InnerClass");
+ jOuterClass.addClass(jInnerClass);
+ assertEquals("com.thoughtworks.qdox.model.OuterClass.InnerClass", jInnerClass.asType().getValue());
+ }
+
+ public void testInnerInterfaceToString() {
+ JavaPackage jPackage = new JavaPackage("com.thoughtworks.qdox.model");
+ JavaClass jOuterClass = new JavaClass("OuterClass");
+ jPackage.addClass(jOuterClass);
+ JavaClass jInnerInterface = new JavaClass("InnerInterface");
+ jInnerInterface.setInterface(true);
+ jOuterClass.addClass(jInnerInterface);
+ assertEquals("interface com.thoughtworks.qdox.model.OuterClass$InnerInterface", jInnerInterface.toString());
+ }
+
+ public void testToStringInterface() {
+ cls.setName("com.MyClass");
+ cls.setInterface(true);
+ assertEquals("interface com.MyClass", cls.toString());
+ }
+
+ public void testToStringVoid() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(Type.VOID, "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("void", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringBoolean() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("boolean"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("boolean", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringInt() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("int"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("int", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringLong() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("long"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("long", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringFloat() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("float"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("float", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringDouble() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("double"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("double", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringChar() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("char"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("char", javaMethod.getReturns().toString());
+ }
+
+ public void testToStringByte() {
+ cls.setName("com.MyClass");
+ cls.addMethod(new JavaMethod(new Type("byte"), "doSomething"));
+ JavaMethod javaMethod = cls.getMethods()[0];
+ assertEquals("byte", javaMethod.getReturns().toString());
+ }
+
+ /**
+ * @codehaus.jira QDOX-59
+ */
+ public void testBeanPropertiesAreReturnedInOrderDeclared() {
+ cls.addMethod(new JavaMethod(new Type("int"), "getFoo"));
+ cls.addMethod(new JavaMethod(new Type("int"), "getBar"));
+ cls.addMethod(new JavaMethod(new Type("String"), "getMcFnord"));
+
+ BeanProperty[] properties = cls.getBeanProperties();
+ assertEquals(3, properties.length);
+ assertEquals("foo", properties[0].getName());
+ assertEquals("bar", properties[1].getName());
+ assertEquals("mcFnord", properties[2].getName());
+ }
+
+ private Type[] type(String[] typeNames) {
+ Type[] result = new Type[typeNames.length];
+ for (int i = 0; i < typeNames.length; i++) {
+ result[i] = new Type(typeNames[i]);
+ }
+ return result;
+ }
+
+
+ // QDOX-201
+ public void testGetVarArgMethodSignature() {
+ JavaMethod simpleMethod = new JavaMethod( "doSomething" );
+ simpleMethod.addParameter( new JavaParameter( new Type("String"), "param", false ) );
+ JavaMethod varArgMethod = new JavaMethod( "doSomething" );
+ varArgMethod.addParameter( new JavaParameter( new Type("String"), "param", true ) );
+
+ cls.addMethod( simpleMethod );
+ cls.addMethod( varArgMethod );
+
+ assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")} ) );
+ assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, false ) );
+ assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, true ) );
+ assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, false, false ) );
+ assertEquals( varArgMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, false, true ) );
+ assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, true, false ) );
+ assertEquals( varArgMethod, cls.getMethodBySignature( "doSomething", new Type[] {new Type("String")}, true, true ) );
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java b/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java
new file mode 100644
index 0000000..3400f23
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaFieldTest.java
@@ -0,0 +1,105 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+public class JavaFieldTest extends TestCase {
+
+ public JavaFieldTest(String s) {
+ super(s);
+ }
+
+ public void testGetCodeBlock() throws Exception {
+ JavaField fld = new JavaField();
+ fld.setName("count");
+ fld.setType(new Type("int"));
+ assertEquals("int count;\n", fld.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ public void testGetCodeBlockWithComment() throws Exception {
+ JavaField fld = new JavaField();
+ fld.setName("count");
+ fld.setType(new Type("int"));
+ fld.setComment("Hello");
+ String expected = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " */\n"
+ + "int count;\n";
+ assertEquals(expected, fld.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ public void testShouldReturnFieldNameForCallSignature() throws Exception {
+ JavaField fld = new JavaField();
+ fld.setName("count");
+ fld.setType(new Type("int"));
+ fld.setModifiers(new String[]{"public", "final"});
+ assertEquals("count", fld.getCallSignature());
+ }
+
+ public void testShouldReturnProperDeclarationSignatureWithModifiers() 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", fld.getDeclarationSignature(true));
+ }
+
+ public void testShouldReturnProperDeclarationSignatureWithoutModifiers() throws Exception {
+ JavaField fld = new JavaField();
+ fld.setName("count");
+ fld.setType(new Type("int"));
+ fld.setModifiers(new String[]{"public", "final"});
+ assertEquals("int count", fld.getDeclarationSignature(false));
+ }
+
+ public void testToStringThreadMIN_PRIORITY() throws Exception {
+ JavaClass cls = new JavaClass("java.lang.Thread");
+ JavaField fld = new JavaField(new Type("int"), "MIN_PRIORITY");
+ fld.setModifiers(new String[] {"final", "static", "public"});
+ cls.addField(fld);
+ assertEquals("public static final int java.lang.Thread.MIN_PRIORITY", fld.toString());
+ }
+
+ public void testToStringFieldDescriptorFd() throws Exception {
+ JavaPackage pckg = new JavaPackage("java.io");
+ JavaClass cls = new JavaClass("FileDescriptor");
+ pckg.addClass(cls);
+ JavaField fld = new JavaField(new Type("int"), "fd");
+ fld.setModifiers(new String[]{"private"});
+ cls.addField(fld);
+ assertEquals("private int java.io.FileDescriptor.fd", fld.toString());
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java b/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java
new file mode 100644
index 0000000..be5a912
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaMethodTest.java
@@ -0,0 +1,397 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+public class JavaMethodTest extends TestCase {
+
+ private JavaMethod mth;
+ private JavaSource source;
+ private JavaClass clazz;
+
+ public JavaMethodTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ source = new JavaSource();
+ clazz = new JavaClass();
+ source.addClass(clazz);
+ mth = new JavaMethod();
+ clazz.addMethod(mth);
+ }
+
+ public void testDeclarationSignatureWithModifiers() {
+ createSignatureTestMethod();
+ String signature = mth.getDeclarationSignature(true);
+ assertEquals("protected final void blah(int count, MyThing t) throws FishException, FruitException", signature);
+ }
+
+ public void testDeclarationSignatureWithoutModifiers() {
+ createSignatureTestMethod();
+ String signature = mth.getDeclarationSignature(false);
+ assertEquals("void blah(int count, MyThing t) throws FishException, FruitException", signature);
+ }
+
+ public void testCallSignature() {
+ createSignatureTestMethod();
+ String signature = mth.getCallSignature();
+ assertEquals("blah(count, t)", signature);
+ }
+
+ private void createSignatureTestMethod() {
+ mth.setName("blah");
+ mth.setModifiers(new String[]{"protected", "final"});
+ mth.setReturns(new Type("void"));
+ mth.setExceptions(new Type[] {
+ new Type("FishException"),
+ new Type("FruitException"),
+ });
+ mth.addParameter(new JavaParameter(new Type("int"), "count"));
+ mth.addParameter(new JavaParameter(new Type("MyThing"), "t"));
+ }
+
+// public void testSignatureWithVarArgs() throws Exception {
+// mth.setName( "method" );
+// mth.addParameter( new JavaParameter(new Type("java.lang.String"), "param", true) );
+// assertEquals( mth, clazz.getMethodBySignature( "method", new Type[] { new Type("java.lang.String", true)} ) );
+// }
+
+ public void testGetCodeBlockSimple() throws Exception {
+ mth.setName("doSomething");
+ mth.setReturns(new Type("java.lang.String"));
+ assertEquals("java.lang.String doSomething();\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockOneParam() throws Exception {
+ mth.setName("blah");
+ mth.setReturns(new Type("void"));
+ mth.addParameter(new JavaParameter(new Type("String"), "thingy"));
+ assertEquals("void blah(String thingy);\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockTwoParams() throws Exception {
+ mth.setName("blah");
+ mth.setReturns(new Type("void"));
+ mth.addParameter(new JavaParameter(new Type("int"), "count"));
+ mth.addParameter(new JavaParameter(new Type("MyThing"), "t"));
+ assertEquals("void blah(int count, MyThing t);\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockThreeParams() throws Exception {
+ mth.setName("blah");
+ mth.setReturns(new Type("void"));
+ mth.addParameter(new JavaParameter(new Type("int"), "count"));
+ mth.addParameter(new JavaParameter(new Type("MyThing"), "t"));
+ mth.addParameter(new JavaParameter(new Type("java.lang.Meat"), "beef"));
+ assertEquals("void blah(int count, MyThing t, java.lang.Meat beef);\n", mth.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ 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.getCodeBlock());
+ }
+
+ public void testGetCodeBlockConstructor() throws Exception {
+ mth.setName("Blah");
+ mth.setModifiers(new String[]{"public"});
+ mth.setConstructor(true);
+ assertEquals("public Blah();\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockWithComment() throws Exception {
+ mth.setName("blah");
+ mth.setReturns(new Type("void"));
+ mth.setComment("Hello");
+ String expect = ""
+ + "/**\n"
+ + " * Hello\n"
+ + " */\n"
+ + "void blah();\n";
+ assertEquals(expect, mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlock1dArray() throws Exception {
+ mth.setName("doSomething");
+ mth.setReturns(new Type("java.lang.String", 1));
+ assertEquals("java.lang.String[] doSomething();\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlock2dArray() throws Exception {
+ mth.setName("doSomething");
+ mth.setReturns(new Type("java.lang.String", 2));
+ assertEquals("java.lang.String[][] doSomething();\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockParamArray() throws Exception {
+ mth.setName("blah");
+ mth.setReturns(new Type("void"));
+ mth.addParameter(new JavaParameter(new Type("int", 2), "count"));
+ mth.addParameter(new JavaParameter(new Type("MyThing", 1), "t"));
+ assertEquals("void blah(int[][] count, MyThing[] t);\n", mth.getCodeBlock());
+ }
+
+ public void testGetCodeBlockWithBody() throws Exception {
+ mth.setName("doStuff");
+ mth.setReturns(new Type("java.lang.String"));
+ mth.setSourceCode(" int x = 2;\n return STUFF;\n");
+
+ assertEquals("" +
+ "java.lang.String doStuff() {\n" +
+ " int x = 2;\n" +
+ " return STUFF;\n" +
+ "}\n",
+ mth.getCodeBlock());
+ }
+
+ public void testEquals() throws Exception {
+ mth.setName("thing");
+ mth.setReturns(new Type("void"));
+
+ JavaMethod m2 = new JavaMethod();
+ m2.setName("thing");
+ m2.setReturns(new Type("void"));
+
+ JavaMethod m3 = new JavaMethod();
+ m3.setName("thingy");
+ m3.setReturns(new Type("void"));
+
+ JavaMethod m4 = new JavaMethod();
+ m4.setName("thing");
+ m4.setReturns(new Type("int"));
+
+ JavaMethod m5 = new JavaMethod();
+ JavaMethod m6 = new JavaMethod();
+
+ JavaMethod m7 = new JavaMethod();
+ m7.setReturns( new Type("int") );
+
+ JavaMethod c1 = new JavaMethod();
+ c1.setName("thing");
+ c1.setConstructor(true);
+
+ JavaMethod c2 = new JavaMethod();
+ c2.setName("Thong");
+ c2.setConstructor(true);
+
+ JavaMethod c3 = new JavaMethod();
+ c3.setName("Thong");
+ c3.setConstructor(true);
+
+ assertEquals(mth, m2);
+ assertEquals(m2, mth);
+ assertNotEquals(mth, m3);
+ assertNotEquals(mth, m4);
+ assertNotEquals(m4, c1);
+ assertNotEquals(c1, c2);
+ assertEquals(c2, c3);
+ assertFalse(mth.equals(null));
+ assertNotEquals( m4, m5 );
+ assertNotEquals( m5, m4 );
+ assertEquals( m5, m6 );
+ assertNotEquals( m5, m7 );
+ }
+
+ public void testEqualsWithParameters() throws Exception {
+ mth.setName("thing");
+ mth.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ mth.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ mth.addParameter(new JavaParameter(new Type("X", 3), ""));
+ mth.setReturns(new Type("void"));
+
+ JavaMethod m2 = new JavaMethod();
+ m2.setName("thing");
+ m2.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m2.addParameter(new JavaParameter(new Type("java.lang.String", 2), "anotherName"));
+ m2.addParameter(new JavaParameter(new Type("X", 3), "blah"));
+ m2.setReturns(new Type("void"));
+
+ JavaMethod m3 = new JavaMethod();
+ m3.setName("thing");
+ m3.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m3.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ m3.setReturns(new Type("void"));
+
+ JavaMethod m4 = new JavaMethod();
+ m4.setName("thing");
+ m4.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m4.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ m4.addParameter(new JavaParameter(new Type("TTTTTTTT", 3), "blah")); //name
+ m4.setReturns(new Type("void"));
+
+ JavaMethod m5 = new JavaMethod();
+ m5.setName("thing");
+ m5.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m5.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ m5.addParameter(new JavaParameter(new Type("X", 9), "blah")); // dimension
+ m5.setReturns(new Type("void"));
+
+ assertEquals(mth, m2);
+ assertEquals(m2, mth);
+ assertNotEquals(mth, m3);
+ assertNotEquals(mth, m4);
+ assertNotEquals(mth, m5);
+ }
+
+ public void testHashCode() throws Exception {
+ mth.setName("thing");
+ mth.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ mth.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ mth.addParameter(new JavaParameter(new Type("X", 3), ""));
+ mth.setReturns(new Type("void"));
+
+ JavaMethod m2 = new JavaMethod();
+ m2.setName("thing");
+ m2.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m2.addParameter(new JavaParameter(new Type("java.lang.String", 2), "anotherName"));
+ m2.addParameter(new JavaParameter(new Type("X", 3), "blah"));
+ m2.setReturns(new Type("void"));
+
+ JavaMethod m3 = new JavaMethod();
+ m3.setName("thing");
+ m3.addParameter(new JavaParameter(new Type("int", 1), "blah"));
+ m3.addParameter(new JavaParameter(new Type("java.lang.String", 2), "thing"));
+ m3.setReturns(new Type("void"));
+
+ JavaMethod c1 = new JavaMethod();
+ c1.setName("Thong");
+ c1.setConstructor(true);
+
+ JavaMethod c2 = new JavaMethod();
+ c2.setName("Thong");
+ c2.setConstructor(true);
+
+ assertEquals(mth.hashCode(), m2.hashCode());
+ assertTrue(mth.hashCode() != m3.hashCode());
+ assertEquals(c1.hashCode(), c2.hashCode());
+ }
+
+ public void testSignatureMatches() throws Exception {
+ mth.setName("thing");
+ mth.addParameter(new JavaParameter(new Type("int"), "x"));
+ mth.addParameter(new JavaParameter(new Type("long", 2), "y"));
+ mth.setReturns(new Type("void"));
+
+ Type[] correctTypes = new Type[]{
+ new Type("int"),
+ new Type("long", 2)
+ };
+
+ Type[] wrongTypes1 = new Type[]{
+ new Type("int", 2),
+ new Type("long")
+ };
+
+ Type[] wrongTypes2 = new Type[]{
+ new Type("int"),
+ new Type("long", 2),
+ new Type("double")
+ };
+
+ assertTrue(mth.signatureMatches("thing", correctTypes));
+ assertFalse(mth.signatureMatches("xxx", correctTypes));
+ assertFalse(mth.signatureMatches("thing", wrongTypes1));
+ assertFalse(mth.signatureMatches("thing", wrongTypes2));
+ }
+
+ public void testVarArgSignatureMatches() throws Exception {
+ mth.setName("thing");
+ mth.addParameter(new JavaParameter(new Type("int"), "x"));
+ mth.addParameter(new JavaParameter(new Type("long", 2), "y", true));
+ mth.setReturns(new Type("void"));
+
+ Type[] correctTypes = new Type[]{
+ new Type("int"),
+ new Type("long", 2)
+ };
+
+ Type[] wrongTypes1 = new Type[]{
+ new Type("int", 2),
+ new Type("long")
+ };
+
+ Type[] wrongTypes2 = new Type[]{
+ new Type("int"),
+ new Type("long", 2),
+ new Type("double")
+ };
+
+ assertTrue(mth.signatureMatches("thing", correctTypes, true));
+ assertFalse(mth.signatureMatches("thing", correctTypes, false));
+ assertFalse(mth.signatureMatches("xxx", correctTypes, true));
+ assertFalse(mth.signatureMatches("thing", wrongTypes1, true));
+ assertFalse(mth.signatureMatches("thing", wrongTypes2, true));
+ }
+
+ public void testParentClass() throws Exception {
+ assertSame(clazz, mth.getParentClass());
+ }
+
+ public void testCanGetParameterByName() throws Exception {
+ JavaParameter paramX = new JavaParameter(new Type("int"), "x");
+ mth.addParameter(paramX);
+ mth.addParameter(new JavaParameter(new Type("string"), "y"));
+
+ assertEquals(paramX, mth.getParameterByName("x"));
+ assertEquals(null, mth.getParameterByName("z"));
+ }
+
+ public void testToString() throws Exception {
+ JavaClass cls = new JavaClass("java.lang.Object");
+ JavaMethod mthd = new JavaMethod(new Type("boolean"),"equals");
+ cls.addMethod(mthd);
+ mthd.setModifiers(new String[]{"public"});
+ mthd.addParameter(new JavaParameter(new Type("java.lang.Object"), null));
+ assertEquals("public boolean java.lang.Object.equals(java.lang.Object)", mthd.toString());
+ }
+
+ public void testConstructorToString() throws Exception {
+ JavaClass cls = new JavaClass("a.b.Executor");
+ JavaMethod constructor = new JavaMethod(null,"Executor");
+ constructor.setConstructor( true );
+ cls.addMethod(constructor);
+ assertEquals("a.b.Executor()", constructor.toString());
+ }
+
+ public void testConstructorReturnType() throws Exception {
+ JavaMethod constructor = new JavaMethod(null,"Executor");
+ constructor.setConstructor( true );
+ assertEquals(null, constructor.getReturnType());
+ }
+
+ public void testConstructorParameterTypes() throws Exception {
+ JavaClass cls = new JavaClass("a.b.Executor");
+ JavaMethod constructor = new JavaMethod(null,"Executor");
+ constructor.addParameter( new JavaParameter( new Type("a.b.C"), "param" ) );
+ constructor.setConstructor( true );
+ cls.addMethod(constructor);
+ assertEquals("a.b.C", constructor.getParameterTypes()[0].toString());
+ }
+
+ private void assertNotEquals(Object o1, Object o2) {
+ assertTrue(o1.toString() + " should not equals " + o2.toString(), !o1.equals(o2));
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/model/JavaPackageTest.java b/src/test/com/thoughtworks/qdox/model/JavaPackageTest.java
new file mode 100644
index 0000000..73af706
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaPackageTest.java
@@ -0,0 +1,11 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+public class JavaPackageTest extends TestCase {
+
+ public void testToStringJavaLang() throws Exception {
+ JavaPackage pckg = new JavaPackage("java.lang");
+ assertEquals("package java.lang", pckg.toString());
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/model/JavaParameterTest.java b/src/test/com/thoughtworks/qdox/model/JavaParameterTest.java
new file mode 100644
index 0000000..378f745
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaParameterTest.java
@@ -0,0 +1,20 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+public class JavaParameterTest extends TestCase {
+
+ public JavaParameterTest(String s) {
+ super(s);
+ }
+
+ public void testParentMethod() throws Exception {
+ JavaParameter p = new JavaParameter(new Type("x"), "x");
+ assertNull(p.getParentMethod());
+
+ JavaMethod m = new JavaMethod();
+ m.addParameter(p);
+ assertSame(m, p.getParentMethod());
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/model/JavaSourceTest.java b/src/test/com/thoughtworks/qdox/model/JavaSourceTest.java
new file mode 100644
index 0000000..13f9807
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/JavaSourceTest.java
@@ -0,0 +1,219 @@
+package com.thoughtworks.qdox.model;
+
+import junit.framework.TestCase;
+
+import java.util.HashMap;
+
+public class JavaSourceTest extends TestCase {
+
+ private JavaSource source;
+
+ public JavaSourceTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ source = new JavaSource();
+ source.setClassLibrary(new ClassLibrary());
+ }
+
+ public void testToStringOneClass() throws Exception {
+ JavaClass cls = new JavaClass();
+ cls.setName("MyClass");
+ source.addClass(cls);
+ String expected = ""
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testToStringMultipleClass() throws Exception {
+ JavaClass cls1 = new JavaClass();
+ cls1.setName("MyClass1");
+ source.addClass(cls1);
+ JavaClass cls2 = new JavaClass();
+ cls2.setName("MyClass2");
+ source.addClass(cls2);
+ JavaClass cls3 = new JavaClass();
+ cls3.setName("MyClass3");
+ source.addClass(cls3);
+
+ String expected = ""
+ + "class MyClass1 {\n"
+ + "\n"
+ + "}\n"
+ + "\n"
+ + "class MyClass2 {\n"
+ + "\n"
+ + "}\n"
+ + "\n"
+ + "class MyClass3 {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testToStringPackage() throws Exception {
+ JavaClass cls = new JavaClass();
+ cls.setName("MyClass");
+ source.addClass(cls);
+ source.setPackage(new JavaPackage("com.thing", new HashMap()));
+ String expected = ""
+ + "package com.thing;\n"
+ + "\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testToStringImport() throws Exception {
+ JavaClass cls = new JavaClass();
+ cls.setName("MyClass");
+ source.addClass(cls);
+ source.addImport("java.util.*");
+ String expected = ""
+ + "import java.util.*;\n"
+ + "\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testToStringMultipleImports() throws Exception {
+ JavaClass cls = new JavaClass();
+ cls.setName("MyClass");
+ source.addClass(cls);
+ source.addImport("java.util.*");
+ source.addImport("com.blah.Thing");
+ source.addImport("xxx");
+ String expected = ""
+ + "import java.util.*;\n"
+ + "import com.blah.Thing;\n"
+ + "import xxx;\n"
+ + "\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testToStringImportAndPackage() throws Exception {
+ JavaClass cls = new JavaClass();
+ cls.setName("MyClass");
+ source.addClass(cls);
+ source.addImport("java.util.*");
+ source.setPackage(new JavaPackage("com.moo", new HashMap()));
+ String expected = ""
+ + "package com.moo;\n"
+ + "\n"
+ + "import java.util.*;\n"
+ + "\n"
+ + "class MyClass {\n"
+ + "\n"
+ + "}\n";
+ assertEquals(expected, source.toString());
+ }
+
+ public void testGetClassNamePrefix() {
+ assertEquals("", source.getClassNamePrefix());
+ source.setPackage(new JavaPackage("foo.bar", new HashMap()));
+ assertEquals("foo.bar.", source.getClassNamePrefix());
+ }
+
+ public void testResolveJavaPrimitive() throws Exception {
+ source.addImport("bogus.int");
+ source.addImport("bogus.double");
+ String[] primitives = new String[]{
+ "boolean", "byte", "char", "double",
+ "float", "int", "long", "short", "void"
+ };
+ for (int i = 0; i < primitives.length; i++) {
+ assertEquals(primitives[i], source.resolveType(primitives[i]));
+ }
+ }
+
+ public void testDontResolveMissingClasses() throws Exception {
+ assertEquals(null, source.resolveType("not.Found"));
+ }
+
+ public void testResolveFullyQualifiedName() throws Exception {
+ source.getClassLibrary().add("open.Bar");
+ assertEquals("open.Bar", source.resolveType("open.Bar"));
+ }
+
+ public void testResolveFullyQualifiedImport() throws Exception {
+ source.addImport("foo.Bar");
+ source.getClassLibrary().add("foo.Bar");
+ assertEquals("foo.Bar", source.resolveType("Bar"));
+ }
+
+ public void testResolveChooseFirstMatchingImport() throws Exception {
+ source.addImport("bogus.package.MyType");
+ source.addImport("com.thoughtworks.qdox.model.Type");
+ source.addImport("another.package.Type");
+ source.getClassLibrary().add("bogus.package.MyType");
+ source.getClassLibrary().add("com.thoughtworks.qdox.model.Type");
+ source.getClassLibrary().add("another.package.Type");
+ assertEquals("com.thoughtworks.qdox.model.Type", source.resolveType("Type"));
+ }
+
+ public void testResolveSamePackage() throws Exception {
+ source.setPackage(new JavaPackage("foo", new HashMap()));
+ source.getClassLibrary().add("foo.Bar");
+ assertEquals("foo.Bar", source.resolveType("Bar"));
+ }
+
+ public void testResolveFullyQualifiedTrumpsSamePackage() throws Exception {
+ source.setPackage(new JavaPackage("foo", new HashMap()));
+ source.getClassLibrary().add("foo.Bar");
+ source.getClassLibrary().add("open.Bar");
+ assertEquals("open.Bar", source.resolveType("open.Bar"));
+ }
+
+ public void testResolveFullyQualifiedTrumpsWildCard() throws Exception {
+ source.addImport("bar.Bar");
+ source.addImport("foo.Bar");
+ source.getClassLibrary().add("foo.*");
+ source.getClassLibrary().add("bar.Bar");
+ assertEquals("bar.Bar", source.resolveType("Bar"));
+ }
+
+ public void testResolveWildcard() throws Exception {
+ source.getClassLibrary().add("foo.Bar");
+ source.addImport("foo.*");
+ assertEquals("foo.Bar", source.resolveType("Bar"));
+ }
+
+ public void testResolveJavaLangClass() throws Exception {
+ source.getClassLibrary().add("java.lang.System");
+ assertEquals("java.lang.System", source.resolveType("System"));
+ }
+
+ public void testResolveSamePackageTrumpsWildcard() throws Exception {
+ source.addImport("com.thoughtworks.qdox.model.Type");
+ source.addImport("foo.*");
+ source.getClassLibrary().add("com.thoughtworks.qdox.model.Type");
+ source.getClassLibrary().add("foo.Type");
+ assertEquals("com.thoughtworks.qdox.model.Type", source.resolveType("Type"));
+ }
+
+ public void testResolveFullyQualifiedInnerClass() throws Exception {
+ source.setPackage(new JavaPackage("foo", new HashMap()));
+ source.getClassLibrary().add("foo.Bar$Fnord");
+ assertEquals("foo.Bar$Fnord", source.resolveType("foo.Bar.Fnord"));
+ }
+
+ public void testResolvePartiallySpecifiedInnerClass() throws Exception {
+ source.setPackage(new JavaPackage("foo", new HashMap()));
+ source.addImport("java.util.*");
+ source.getClassLibrary().add("foo.Bar$Fnord");
+ source.getClassLibrary().addDefaultLoader();
+ assertEquals("foo.Bar$Fnord", source.resolveType("Bar.Fnord"));
+ assertEquals("java.util.Map$Entry", source.resolveType("Map.Entry"));
+ }
+
+}
diff --git a/src/test/com/thoughtworks/qdox/model/ModelBuilderTest.java b/src/test/com/thoughtworks/qdox/model/ModelBuilderTest.java
new file mode 100644
index 0000000..180f2a6
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/ModelBuilderTest.java
@@ -0,0 +1,816 @@
+package com.thoughtworks.qdox.model;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TagDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+
+public class ModelBuilderTest extends TestCase {
+
+ private ModelBuilder builder;
+
+ public ModelBuilderTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ builder = new ModelBuilder();
+ }
+
+ public void testNumberOfClassesGrows() throws Exception {
+ assertEquals(0, builder.getSource().getClasses().length);
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+ assertEquals(1, builder.getSource().getClasses().length);
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+ assertEquals(2, builder.getSource().getClasses().length);
+ }
+
+ public void testSimpleClass() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.name = "Thingy";
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.name = "ThingyThing";
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("Thingy", source.getClasses()[0].getName());
+ assertEquals("ThingyThing", source.getClasses()[1].getName());
+ assertEquals(source, source.getClasses()[0].getParentSource());
+ }
+
+ public void testInterface() throws Exception {
+ ClassDef cls = new ClassDef();
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.type = ClassDef.INTERFACE;
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(false, source.getClasses()[0].isInterface());
+ assertEquals(true, source.getClasses()[1].isInterface());
+ }
+
+ public void testEnum() throws Exception {
+ ClassDef cls = new ClassDef();
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.type = ClassDef.ENUM;
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(false, source.getClasses()[0].isEnum());
+ assertEquals(true, source.getClasses()[1].isEnum());
+ }
+
+ public void testAnnotationType() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.type = ClassDef.ANNOTATION_TYPE;
+ builder.beginClass(cls);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(1, source.getClasses().length);
+ }
+
+ public void testClassExtends() throws Exception {
+ ClassDef cls = new ClassDef();
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.extendz.add(new TypeDef("Another"));
+ builder.beginClass(cls2);
+ builder.endClass();
+ builder.addImport("com.thoughtworks.*");
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("java.lang.Object", source.getClasses()[0].getSuperClass().getValue());
+ assertEquals("Another", source.getClasses()[1].getSuperClass().getValue());
+
+ assertEquals(0, source.getClasses()[0].getImplements().length);
+ assertEquals(0, source.getClasses()[1].getImplements().length);
+
+ //Add another class and see if Another gets resolved
+ builder.addPackage(new PackageDef("com.thoughtworks"));
+ ClassDef anotherCls = new ClassDef();
+ anotherCls.name = "Another";
+ builder.beginClass(anotherCls);
+ builder.endClass();
+
+ assertEquals("com.thoughtworks.Another", source.getClasses()[1].getSuperClass().getValue());
+ }
+
+ public void testInterfaceExtends() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.type = ClassDef.INTERFACE;
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.type = ClassDef.INTERFACE;
+ cls2.extendz.add(new TypeDef("Another"));
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(0, source.getClasses()[0].getImplements().length);
+ assertEquals(1, source.getClasses()[1].getImplements().length);
+ assertEquals("Another", source.getClasses()[1].getImplements()[0].getValue());
+
+ assertNull(source.getClasses()[0].getSuperClass());
+ assertNull(source.getClasses()[1].getSuperClass());
+ }
+
+ public void testInterfaceExtendsMultiple() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.type = ClassDef.INTERFACE;
+ cls.extendz.add(new TypeDef("Another"));
+ cls.extendz.add(new TypeDef("java.io.Serializable"));
+ cls.extendz.add(new TypeDef("BottleOpener"));
+ builder.beginClass(cls);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ // sorted
+ Arrays.sort(source.getClasses()[0].getImplements());
+ assertEquals(3, source.getClasses()[0].getImplements().length);
+ assertEquals("Another", source.getClasses()[0].getImplements()[0].getValue());
+ assertEquals("BottleOpener", source.getClasses()[0].getImplements()[1].getValue());
+ assertEquals("java.io.Serializable", source.getClasses()[0].getImplements()[2].getValue());
+
+ assertNull(source.getClasses()[0].getSuperClass());
+ }
+
+ public void testClassImplements() throws Exception {
+ ClassDef cls = new ClassDef();
+ builder.beginClass(cls);
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.implementz.add(new TypeDef("SomeInterface"));
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(0, source.getClasses()[0].getImplements().length);
+ assertEquals(1, source.getClasses()[1].getImplements().length);
+
+ assertEquals("SomeInterface", source.getClasses()[1].getImplements()[0].getValue());
+
+ assertEquals("java.lang.Object", source.getClasses()[0].getSuperClass().getValue());
+ assertEquals("java.lang.Object", source.getClasses()[1].getSuperClass().getValue());
+ }
+
+ public void testClassImplementsMultiple() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.implementz.add(new TypeDef("SomeInterface"));
+ cls.implementz.add(new TypeDef("XX"));
+ builder.beginClass(cls);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(2, source.getClasses()[0].getImplements().length);
+
+ Arrays.sort(source.getClasses()[0].getImplements());
+ assertEquals("SomeInterface", source.getClasses()[0].getImplements()[0].getValue());
+ assertEquals("XX", source.getClasses()[0].getImplements()[1].getValue());
+ }
+
+ public void testClassExtendsAndImplements() throws Exception {
+ ClassDef cls = new ClassDef();
+ cls.extendz.add(new TypeDef("SubClass"));
+ cls.implementz.add(new TypeDef("SomeInterface"));
+ cls.implementz.add(new TypeDef("XX"));
+ builder.beginClass(cls);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(2, source.getClasses()[0].getImplements().length);
+
+ Arrays.sort(source.getClasses()[0].getImplements());
+ assertEquals("SomeInterface", source.getClasses()[0].getImplements()[0].getValue());
+ assertEquals("XX", source.getClasses()[0].getImplements()[1].getValue());
+
+ assertEquals("SubClass", source.getClasses()[0].getSuperClass().getValue());
+ }
+
+ public void testClassModifiers() throws Exception {
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ ClassDef cls2 = new ClassDef();
+ cls2.modifiers.add("public");
+ cls2.modifiers.add("final");
+ builder.beginClass(cls2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals(0, source.getClasses()[0].getModifiers().length);
+ assertEquals(2, source.getClasses()[1].getModifiers().length);
+
+ // sorted
+ String[] modifiers = source.getClasses()[1].getModifiers();
+ Arrays.sort(modifiers);
+ assertEquals("final", modifiers[0]);
+ assertEquals("public", modifiers[1]);
+ }
+
+ public void testAddMethodsToCorrectClass() throws Exception {
+ builder.beginClass(new ClassDef());
+ builder.addMethod(new MethodDef());
+ builder.endClass();
+
+ builder.beginClass(new ClassDef());
+ builder.addMethod(new MethodDef());
+ builder.addMethod(new MethodDef());
+ builder.addMethod(new MethodDef());
+ builder.endClass();
+
+ builder.beginClass(new ClassDef());
+ builder.addMethod(new MethodDef());
+ builder.addMethod(new MethodDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ assertEquals(1, source.getClasses()[0].getMethods().length);
+ assertEquals(3, source.getClasses()[1].getMethods().length);
+ assertEquals(2, source.getClasses()[2].getMethods().length);
+ }
+
+ public void testInnerClass() throws Exception {
+ builder.addPackage(new PackageDef("xyz"));
+
+ ClassDef outerDef = new ClassDef();
+ outerDef.name = "Outer";
+ builder.beginClass(outerDef);
+
+ ClassDef innerDef = new ClassDef();
+ innerDef.name = "Inner";
+ builder.beginClass(innerDef);
+
+ MethodDef fooDef = new MethodDef();
+ fooDef.name = "foo";
+ builder.addMethod(fooDef);
+ builder.endClass();
+
+ MethodDef barDef = new MethodDef();
+ barDef.name = "bar";
+ builder.addMethod(barDef);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ assertEquals(1, source.getClasses().length);
+ JavaClass outerClass = source.getClasses()[0];
+ assertEquals("xyz.Outer", outerClass.getFullyQualifiedName());
+ assertEquals(1, outerClass.getMethods().length);
+ assertEquals("bar", outerClass.getMethods()[0].getName());
+ assertEquals(1, outerClass.getNestedClasses().length);
+ JavaClass innerClass = outerClass.getNestedClasses()[0];
+ assertEquals("xyz.Outer$Inner", innerClass.getFullyQualifiedName());
+ assertEquals(1, innerClass.getMethods().length);
+ assertEquals("foo", innerClass.getMethods()[0].getName());
+ }
+
+ public void testSimpleMethod() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod doSomething = source.getClasses()[0].getMethods()[0];
+ assertEquals("doSomething", doSomething.getName());
+ assertEquals("void", doSomething.getReturns().getValue());
+ JavaSource parentSource = doSomething.getReturns().getJavaClassParent().getParentSource();
+ assertSame(source, parentSource);
+ assertEquals(0, doSomething.getModifiers().length);
+ assertEquals(0, doSomething.getParameters().length);
+ assertEquals(0, doSomething.getExceptions().length);
+ }
+
+ public void testMethodNoArray() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.dimensions = 0;
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(0, result.getReturns().getDimensions());
+ }
+
+ public void testMethod1dArray() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.dimensions = 1;
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(1, result.getReturns().getDimensions());
+ }
+
+ public void testMethod2dArray() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.dimensions = 2;
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(2, result.getReturns().getDimensions());
+ }
+
+ public void testMethodParameters() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+
+ builder.addMethod(mth);
+
+ FieldDef f1 = new FieldDef();
+ f1.name = "count";
+ f1.type = new TypeDef("int");
+ f1.modifiers.add("final");
+ builder.addParameter( f1 );
+
+ FieldDef f2 = new FieldDef();
+ f2.name = "name";
+ f2.type = new TypeDef("String");
+ builder.addParameter( f2 );
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(2, result.getParameters().length);
+ assertEquals("count", result.getParameters()[0].getName());
+ assertEquals("int", result.getParameters()[0].getType().getValue());
+ assertEquals("name", result.getParameters()[1].getName());
+ assertEquals("String", result.getParameters()[1].getType().getValue());
+ }
+
+ public void testMethodParametersWithArrays() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+ builder.addMethod(mth);
+
+ FieldDef f1 = new FieldDef();
+ f1.name = "count";
+ f1.type = new TypeDef("int");
+ f1.modifiers.add("final");
+ f1.dimensions = 1;
+ builder.addParameter( f1 );
+
+
+ FieldDef f2 = new FieldDef();
+ f2.name = "name";
+ f2.type = new TypeDef("String");
+ f2.dimensions = 2;
+ builder.addParameter( f2 );
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(1, result.getParameters()[0].getType().getDimensions());
+ assertEquals(2, result.getParameters()[1].getType().getDimensions());
+ }
+
+ public void testMethodExceptions() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+
+ mth.exceptions.add("RuntimeException");
+ mth.exceptions.add("java.io.IOException");
+
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(2, result.getExceptions().length);
+ // sorted
+ Arrays.sort(result.getExceptions());
+ assertEquals("RuntimeException", result.getExceptions()[0].getValue());
+ assertEquals("java.io.IOException", result.getExceptions()[1].getValue());
+ }
+
+ public void testMethodModifiers() throws Exception {
+ builder.beginClass(new ClassDef());
+ MethodDef mth = new MethodDef();
+
+ mth.modifiers.add("public");
+ mth.modifiers.add("final");
+ mth.modifiers.add("synchronized");
+
+ builder.addMethod(mth);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ JavaMethod result = source.getClasses()[0].getMethods()[0];
+ assertEquals(3, result.getModifiers().length);
+ // sorted
+ String[] modifiers = result.getModifiers();
+ Arrays.sort(modifiers);
+ assertEquals("final", modifiers[0]);
+ assertEquals("public", modifiers[1]);
+ assertEquals("synchronized", modifiers[2]);
+ }
+
+ public void testSimpleField() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ builder.addField(fld);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaField result = source.getClasses()[0].getFields()[0];
+ assertNotNull(result);
+ assertEquals("count", result.getName());
+ assertEquals("int", result.getType().getValue());
+
+ }
+
+ public void testFieldWithModifiers() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ FieldDef fld = new FieldDef();
+ fld.modifiers.add("blah");
+ fld.modifiers.add("blah2");
+ builder.addField(fld);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaField result = source.getClasses()[0].getFields()[0];
+ assertNotNull(result);
+ assertNotNull(result.getModifiers());
+ Arrays.sort(result.getModifiers());
+ assertEquals("blah2", result.getModifiers()[0]);
+ assertEquals("blah", result.getModifiers()[1]);
+ }
+
+ public void testFieldNoArray() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 0;
+ builder.addField(fld);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaField result = source.getClasses()[0].getFields()[0];
+ assertEquals(0, result.getType().getDimensions());
+
+ }
+
+ public void testField1dArray() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 1;
+ builder.addField(fld);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaField result = source.getClasses()[0].getFields()[0];
+ assertEquals(1, result.getType().getDimensions());
+
+ }
+
+ public void testField2dArray() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 2;
+ builder.addField(fld);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaField result = source.getClasses()[0].getFields()[0];
+ assertEquals(2, result.getType().getDimensions());
+ }
+
+ public void testSimpleConstructor() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ builder.addMethod(mth);
+
+ MethodDef mth2 = new MethodDef();
+ mth2.name = "method";
+ mth2.returnType = new TypeDef("void");
+ builder.addMethod(mth2);
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ JavaMethod result1 = source.getClasses()[0].getMethods()[0];
+ JavaMethod result2 = source.getClasses()[0].getMethods()[1];
+
+ assertTrue(result1.isConstructor());
+ assertNull(result1.getReturns());
+ assertTrue(!result2.isConstructor());
+ assertNotNull(result2.getReturns());
+ }
+
+ public void testJavaDocOnClass() throws Exception {
+ builder.addJavaDoc("Hello");
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ assertEquals("Hello", source.getClasses()[0].getComment());
+ }
+
+ public void testJavaDocSpiradiclyOnManyClasses() throws Exception {
+
+ builder.addJavaDoc("Hello");
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ builder.addJavaDoc("World");
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("Hello", source.getClasses()[0].getComment());
+ assertNull(source.getClasses()[1].getComment());
+ assertEquals("World", source.getClasses()[2].getComment());
+ }
+
+ public void testJavaDocOnMethod() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ builder.addJavaDoc("Hello");
+ builder.addMethod(new MethodDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertNull(source.getClasses()[0].getComment());
+ assertEquals("Hello", source.getClasses()[0].getMethods()[0].getComment());
+ }
+
+ public void testJavaDocOnField() throws Exception {
+ builder.beginClass(new ClassDef());
+
+ builder.addJavaDoc("Hello");
+ builder.addField(new FieldDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertNull(source.getClasses()[0].getComment());
+ assertEquals("Hello", source.getClasses()[0].getFields()[0].getComment());
+ }
+
+ public void testJavaDocOnMethodsAndFields() throws Exception {
+ builder.addJavaDoc("Thing");
+ builder.beginClass(new ClassDef());
+
+ builder.addField(new FieldDef());// f0
+
+ builder.addJavaDoc("Hello");
+ builder.addMethod(new MethodDef());//m0
+
+ builder.addJavaDoc("Hello field");
+ builder.addField(new FieldDef());//f1
+
+ builder.addMethod(new MethodDef());//m1
+
+ builder.addJavaDoc("World");
+ builder.addMethod(new MethodDef());//m2
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("Thing", source.getClasses()[0].getComment());
+ assertNull(source.getClasses()[0].getFields()[0].getComment());
+ assertEquals("Hello field", source.getClasses()[0].getFields()[1].getComment());
+ assertEquals("Hello", source.getClasses()[0].getMethods()[0].getComment());
+ assertNull(source.getClasses()[0].getMethods()[1].getComment());
+ assertEquals("World", source.getClasses()[0].getMethods()[2].getComment());
+ }
+
+ public void testDocletTag() throws Exception {
+ builder.addJavaDoc("Hello");
+ builder.addJavaDocTag(new TagDef("cheese", "is good"));
+ builder.beginClass(new ClassDef());
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("Hello", source.getClasses()[0].getComment());
+ assertEquals(1, source.getClasses()[0].getTags().length);
+ assertEquals("cheese", source.getClasses()[0].getTags()[0].getName());
+ assertEquals("is good", source.getClasses()[0].getTags()[0].getValue());
+ }
+
+ public void testDocletTagWithNoComment() throws Exception {
+ builder.addJavaDoc(""); // parser will always call this method to signify start of javadoc
+ builder.addJavaDocTag(new TagDef("cheese", "is good"));
+ builder.beginClass(new ClassDef());
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("", source.getClasses()[0].getComment());
+ assertEquals(1, source.getClasses()[0].getTags().length);
+ assertEquals("cheese", source.getClasses()[0].getTags()[0].getName());
+ assertEquals("is good", source.getClasses()[0].getTags()[0].getValue());
+ }
+
+ public void testMultipleDocletTags() throws Exception {
+ builder.addJavaDoc("Hello");
+ builder.addJavaDocTag(new TagDef("cheese", "is good"));
+ builder.addJavaDocTag(new TagDef("food", "is great"));
+ builder.addJavaDocTag(new TagDef("chairs", "are boring"));
+ builder.beginClass(new ClassDef());
+
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("Hello", source.getClasses()[0].getComment());
+ assertEquals(3, source.getClasses()[0].getTags().length);
+ assertEquals("cheese", source.getClasses()[0].getTags()[0].getName());
+ assertEquals("is good", source.getClasses()[0].getTags()[0].getValue());
+ assertEquals("food", source.getClasses()[0].getTags()[1].getName());
+ assertEquals("is great", source.getClasses()[0].getTags()[1].getValue());
+ assertEquals("chairs", source.getClasses()[0].getTags()[2].getName());
+ assertEquals("are boring", source.getClasses()[0].getTags()[2].getValue());
+ }
+
+ public void testDocletTagsOnMethodsAndFields() throws Exception {
+ builder.addJavaDoc("");
+ builder.addJavaDocTag(new TagDef("cheese", "is good"));
+ builder.beginClass(new ClassDef());
+
+ builder.addJavaDoc("");
+ builder.addJavaDocTag(new TagDef("food", "is great"));
+ builder.addMethod(new MethodDef());
+
+ builder.addJavaDoc("");
+ builder.addJavaDocTag(new TagDef("chairs", "are boring"));
+ builder.addField(new FieldDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+
+ assertEquals("cheese", source.getClasses()[0].getTags()[0].getName());
+ assertEquals("is good", source.getClasses()[0].getTags()[0].getValue());
+ assertEquals("food", source.getClasses()[0].getMethods()[0].getTags()[0].getName());
+ assertEquals("is great", source.getClasses()[0].getMethods()[0].getTags()[0].getValue());
+ assertEquals("chairs", source.getClasses()[0].getFields()[0].getTags()[0].getName());
+ assertEquals("are boring", source.getClasses()[0].getFields()[0].getTags()[0].getValue());
+ }
+
+ public void testRetrieveJavaSource() throws Exception {
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+
+ JavaSource source = builder.getSource();
+ assertNotNull(source);
+ }
+
+ public void testJavaSourceClassCount() throws Exception {
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+ builder.beginClass(new ClassDef());
+ builder.endClass();
+ JavaSource result = builder.getSource();
+ assertEquals(3, result.getClasses().length);
+ }
+
+ public void testJavaSourceNoPackage() throws Exception {
+ JavaSource result = builder.getSource();
+ assertNull(result.getPackage());
+ }
+
+ public void testJavaSourceWithPackage() throws Exception {
+ builder.addPackage(new PackageDef("com.blah.thing"));
+ JavaSource result = builder.getSource();
+ assertEquals("com.blah.thing", result.getPackage().getName());
+ }
+
+ public void testJavaSourceNoImports() throws Exception {
+ JavaSource result = builder.getSource();
+ assertEquals(0, result.getImports().length);
+ }
+
+ public void testJavaSourceOneImport() throws Exception {
+ builder.addImport("com.blah.Thing");
+ JavaSource result = builder.getSource();
+ assertEquals(1, result.getImports().length);
+ assertEquals("com.blah.Thing", result.getImports()[0]);
+ }
+
+ public void testJavaSourceMultipleImports() throws Exception {
+ builder.addImport("com.blah.Thing");
+ builder.addImport("java.util.List");
+ builder.addImport("org.apache.*");
+ JavaSource result = builder.getSource();
+ assertEquals(3, result.getImports().length);
+ assertEquals("com.blah.Thing", result.getImports()[0]);
+ assertEquals("java.util.List", result.getImports()[1]);
+ assertEquals("org.apache.*", result.getImports()[2]);
+ }
+
+ public void testModelHashCodes() {
+
+ ClassDef classDef = new ClassDef();
+ classDef.name = "hello";
+ assertTrue(classDef.hashCode() > 0);
+
+ MethodDef methodDef = new MethodDef();
+ methodDef.name = "hello";
+ assertTrue(methodDef.hashCode() > 0);
+
+ FieldDef fieldDef = new FieldDef();
+ fieldDef.name = "hello";
+ assertTrue(fieldDef.hashCode() > 0);
+
+ JavaParameter javaParameter = new JavaParameter(new Type("q"), "w");
+ assertTrue(javaParameter.hashCode() > 0);
+
+ }
+
+
+ public void testType() {
+
+ Type type1 = new Type("fred", 1);
+ Type type2 = new Type("fred", 1);
+ Type type3 = new Type("wilma", 2);
+ assertTrue(type1.compareTo(type2) == 0);
+ assertFalse(type1.compareTo(type3) == 0);
+ assertTrue(type1.compareTo("barney") == 0);
+ }
+
+
+}
diff --git a/src/test/com/thoughtworks/qdox/model/TypeTest.java b/src/test/com/thoughtworks/qdox/model/TypeTest.java
new file mode 100644
index 0000000..8ae1d29
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/TypeTest.java
@@ -0,0 +1,86 @@
+package com.thoughtworks.qdox.model;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.qdox.JavaClassContext;
+import com.thoughtworks.qdox.JavaDocBuilder;
+
+public class TypeTest extends TestCase {
+
+ public TypeTest(String s) {
+ super(s);
+ }
+
+ public void testResolving() throws Exception {
+ ClassLibrary classLib = new ClassLibrary();
+ JavaSource src = new JavaSource();
+ src.setClassLibrary(classLib);
+ src.addImport("foo.*");
+ Type type = Type.createUnresolved("Bar", 0, src);
+ assertEquals(false, type.isResolved());
+ classLib.add("foo.Bar");
+ assertEquals(true, type.isResolved());
+ assertEquals("foo.Bar", type.getValue());
+ }
+
+ public void testArrayType() throws Exception {
+ Type type = new Type("int", 1);
+ assertTrue(type.isArray());
+ }
+
+ public void testToString() throws Exception {
+ assertEquals("int", new Type("int").toString());
+ assertEquals("int[]", new Type("int", 1).toString());
+ assertEquals("long[][][]", new Type("long", 3).toString());
+ }
+
+ public void testEquals() throws Exception {
+ assertEquals(new Type("string"),
+ new Type("string"));
+ assertNotEquals(new Type("string"),
+ new Type("int"));
+ assertNotEquals(new Type("long", 1),
+ new Type("long"));
+ assertNotEquals(new Type("long"),
+ new Type("long", 2));
+ assertFalse(new Type("int").equals(null));
+ }
+
+ public void testTypeHasJavaClass() {
+ JavaSource javaSource = new JavaSource(new JavaClassContext(new JavaDocBuilder()));
+ javaSource.setClassLibrary(new ClassLibrary());
+ Type type = new Type("java.util.HashSet", 0, javaSource);
+ JavaClass clazz = type.getJavaClass();
+ JavaClass superClass = clazz.getSuperJavaClass();
+ assertEquals("java.util.AbstractSet", superClass.getFullyQualifiedName());
+ }
+
+ public void testIsPrimitive() throws Exception {
+ ClassLibrary classLibrary = new ClassLibrary( ClassLoader.getSystemClassLoader() );
+ JavaDocBuilder builder = new JavaDocBuilder(classLibrary);
+
+ JavaClass javaClass = builder.getClassByName("java.lang.Object");
+ assertEquals(true, javaClass.getMethodBySignature("notify", null).getReturns().isPrimitive());
+
+ }
+
+ public void testInnerClassToString() {
+ ClassLibrary classLibrary = new ClassLibrary( ClassLoader.getSystemClassLoader() );
+
+ String source = "public class Outer {\n" +
+ " private Inner ia;" +
+ " public class Inner { }" +
+ "}";
+ JavaDocBuilder builder = new JavaDocBuilder(classLibrary);
+ builder.addSource( new StringReader( source ) );
+ assertEquals("Outer.Inner", builder.getClassByName( "Outer" ).getFieldByName( "ia" ).getType().toString());
+ assertEquals("Outer.Inner", builder.getClassByName( "Outer" ).getFieldByName( "ia" ).getType().toGenericString());
+ }
+
+ private void assertNotEquals(Object o1, Object o2) {
+ assertTrue(o2.toString() + " should not equal " + o1.toString(),
+ !o2.equals(o1));
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/model/util/OrderedMapTest.java b/src/test/com/thoughtworks/qdox/model/util/OrderedMapTest.java
new file mode 100644
index 0000000..ccdbc5d
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/model/util/OrderedMapTest.java
@@ -0,0 +1,54 @@
+package com.thoughtworks.qdox.model.util;
+
+import java.util.Iterator;
+import junit.framework.TestCase;
+
+public class OrderedMapTest extends TestCase {
+
+ OrderedMap orderedMap = new OrderedMap();
+
+ public void testEmptyMap() {
+ assertEquals(0, orderedMap.size());
+ assertEquals(0, orderedMap.entrySet().size());
+ assertEquals(false, orderedMap.entrySet().iterator().hasNext());
+ }
+
+ public void testAddOneEntry() {
+ orderedMap.put("foo", "bar");
+ assertEquals(1, orderedMap.size());
+ assertEquals(1, orderedMap.entrySet().size());
+ assertEquals(true, orderedMap.entrySet().iterator().hasNext());
+ assertEquals("bar", orderedMap.get("foo"));
+ assertTrue(orderedMap.keySet().contains("foo"));
+ assertTrue(orderedMap.values().contains("bar"));
+ }
+
+ public void testAddTwoEntries() {
+ orderedMap.put("foo", "bar");
+ orderedMap.put("bork", "flarg");
+ assertEquals(2, orderedMap.size());
+ assertEquals(2, orderedMap.entrySet().size());
+ assertEquals("bar", orderedMap.get("foo"));
+ assertEquals("flarg", orderedMap.get("bork"));
+ }
+
+ public void testEntryIsReplacedWhenKeysCollide() {
+ orderedMap.put("tweedle", "dum");
+ assertEquals("dum",orderedMap.put("tweedle", "dee"));
+ assertEquals("dee", orderedMap.get("tweedle"));
+ assertEquals(1, orderedMap.size());
+ }
+
+ public void testEntriesAreReturnedInOrderAdded() {
+ orderedMap.put("juan", "x");
+ orderedMap.put("twoo", "x");
+ orderedMap.put("juan", "x");
+ orderedMap.put("free", "x");
+ Iterator keyIterator = orderedMap.keySet().iterator();
+ assertEquals("juan", keyIterator.next());
+ assertEquals("twoo", keyIterator.next());
+ assertEquals("free", keyIterator.next());
+ assertEquals(false, keyIterator.hasNext());
+ }
+
+}
diff --git a/src/test/java/com/thoughtworks/qdox/model/util/SerializationUtils.java b/src/test/com/thoughtworks/qdox/model/util/SerializationUtils.java
similarity index 93%
rename from src/test/java/com/thoughtworks/qdox/model/util/SerializationUtils.java
rename to src/test/com/thoughtworks/qdox/model/util/SerializationUtils.java
index 9500030..1970247 100644
--- a/src/test/java/com/thoughtworks/qdox/model/util/SerializationUtils.java
+++ b/src/test/com/thoughtworks/qdox/model/util/SerializationUtils.java
@@ -16,7 +16,8 @@ public class SerializationUtils {
oos.close();
return buffer.toByteArray();
} catch (IOException e) {
- throw new RuntimeException("error writing to byte-array!", e);
+ e.printStackTrace();
+ throw new RuntimeException("error writing to byte-array!");
}
}
@@ -27,7 +28,8 @@ public class SerializationUtils {
ObjectInputStream ois = new ObjectInputStream(input);
return ois.readObject();
} catch (IOException e) {
- throw new RuntimeException("error reading from byte-array!", e);
+ e.printStackTrace();
+ throw new RuntimeException("error reading from byte-array!");
}
}
diff --git a/src/test/java/com/thoughtworks/qdox/model/util/TagParserTest.java b/src/test/com/thoughtworks/qdox/model/util/TagParserTest.java
similarity index 85%
rename from src/test/java/com/thoughtworks/qdox/model/util/TagParserTest.java
rename to src/test/com/thoughtworks/qdox/model/util/TagParserTest.java
index 8be4af5..1cc9783 100644
--- a/src/test/java/com/thoughtworks/qdox/model/util/TagParserTest.java
+++ b/src/test/com/thoughtworks/qdox/model/util/TagParserTest.java
@@ -16,7 +16,7 @@ public class TagParserTest extends TestCase {
//---( Parse into named parameters )---
public void testEmptyInputContainsNoNamedParameters() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("");
+ Map paramMap = TagParser.parseNamedParameters("");
assertNotNull(paramMap);
assertTrue(paramMap.isEmpty());
}
@@ -48,14 +48,14 @@ public class TagParserTest extends TestCase {
}
public void testCanParseSimpleNamedParameters() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x=foo");
+ Map paramMap = TagParser.parseNamedParameters("x=foo");
assertNotNull(paramMap);
assertEquals(1, paramMap.size());
assertEquals("foo", paramMap.get("x"));
}
public void testCanParseMultipleNamedParameters() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x=foo y=bar");
+ Map paramMap = TagParser.parseNamedParameters("x=foo y=bar");
assertNotNull(paramMap);
assertEquals(2, paramMap.size());
assertEquals("foo", paramMap.get("x"));
@@ -63,11 +63,11 @@ public class TagParserTest extends TestCase {
}
public void testNamedParametersAreReturnedInOrderDeclared() {
- Map<String, String> paramMap = TagParser.parseNamedParameters(
+ Map paramMap = TagParser.parseNamedParameters(
"x=foo y=bar a=orses b=oney"
);
assertEquals(4, paramMap.size());
- Iterator<String> keyIterator = paramMap.keySet().iterator();
+ Iterator keyIterator = paramMap.keySet().iterator();
assertEquals("x", keyIterator.next());
assertEquals("y", keyIterator.next());
assertEquals("a", keyIterator.next());
@@ -75,7 +75,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParameterValuesCanBeSingleQuoted() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x='foo' y='bar fly'");
+ Map paramMap = TagParser.parseNamedParameters("x='foo' y='bar fly'");
assertNotNull(paramMap);
assertEquals(2, paramMap.size());
assertEquals("foo", paramMap.get("x"));
@@ -83,7 +83,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParameterValuesCanBeDoubleQuoted() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x=\"'foo'\" y=\"bar fly\"");
+ Map paramMap = TagParser.parseNamedParameters("x=\"'foo'\" y=\"bar fly\"");
assertNotNull(paramMap);
assertEquals(2, paramMap.size());
assertEquals("'foo'", paramMap.get("x"));
@@ -91,7 +91,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParametersCanHaveSpacesAroundEquals() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x = foo y = 'bar'");
+ Map paramMap = TagParser.parseNamedParameters("x = foo y = 'bar'");
assertNotNull(paramMap);
assertEquals(2, paramMap.size());
assertEquals("foo", paramMap.get("x"));
@@ -99,7 +99,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParameterNamesCanContainHypensEtc() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x.a = '1' x-b = '2' x_c = '3'");
+ Map paramMap = TagParser.parseNamedParameters("x.a = '1' x-b = '2' x_c = '3'");
assertNotNull(paramMap);
assertEquals(3, paramMap.size());
assertEquals("1", paramMap.get("x.a"));
@@ -108,7 +108,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParameterValuesCanBeNumeric() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x=1 y=2");
+ Map paramMap = TagParser.parseNamedParameters("x=1 y=2");
assertNotNull(paramMap);
assertEquals(2, paramMap.size());
assertEquals("1", paramMap.get("x"));
@@ -116,7 +116,7 @@ public class TagParserTest extends TestCase {
}
public void testNamedParameterValuesCanSpanLinesIfBackslashIsUsed() {
- Map<String, String> paramMap = TagParser.parseNamedParameters("x='multiline\\\nvalue'");
+ Map paramMap = TagParser.parseNamedParameters("x='multiline\\\nvalue'");
assertNotNull(paramMap);
assertEquals(1, paramMap.size());
assertEquals("multiline\nvalue", paramMap.get("x"));
diff --git a/src/test/java/com/thoughtworks/qdox/parser/LexerTest.java b/src/test/com/thoughtworks/qdox/parser/LexerTest.java
similarity index 72%
rename from src/test/java/com/thoughtworks/qdox/parser/LexerTest.java
rename to src/test/com/thoughtworks/qdox/parser/LexerTest.java
index c69f75b..d541dbc 100644
--- a/src/test/java/com/thoughtworks/qdox/parser/LexerTest.java
+++ b/src/test/com/thoughtworks/qdox/parser/LexerTest.java
@@ -1,22 +1,23 @@
package com.thoughtworks.qdox.parser;
+import junit.framework.TestCase;
+
+import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import com.thoughtworks.qdox.parser.impl.JFlexLexer;
import com.thoughtworks.qdox.parser.impl.Parser;
public class LexerTest extends TestCase {
- private static Map<Integer, String> tokens;
+ private static Map tokens;
static {
- tokens = new HashMap<Integer, String>();
+ tokens = new HashMap();
Field[] tokenFlds = Parser.class.getDeclaredFields();
for (int i = 0; i < tokenFlds.length; i++) {
Field f = tokenFlds[i];
@@ -59,7 +60,7 @@ public class LexerTest extends TestCase {
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.CLASS, lexer);
- assertLex(Parser.IDENTIFIER, "X", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.STATIC, lexer);
assertLex(Parser.CODEBLOCK, lexer);
@@ -108,7 +109,7 @@ public class LexerTest extends TestCase {
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.CLASS, lexer);
- assertLex(Parser.IDENTIFIER, "X", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.IDENTIFIER, "int", lexer);
@@ -127,7 +128,7 @@ public class LexerTest extends TestCase {
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.CLASS, lexer);
- assertLex(Parser.IDENTIFIER, "X", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.IDENTIFIER, "int", lexer);
@@ -154,7 +155,7 @@ public class LexerTest extends TestCase {
}
public void testUnicodeInFile() throws Exception {
- Lexer lexer = new JFlexLexer( getClass().getResourceAsStream( "/com/thoughtworks/qdox/testdata/Unicode.java" ) );
+ Lexer lexer = new JFlexLexer(new FileReader("src/test/com/thoughtworks/qdox/testdata/Unicode.java"));
assertLex(Parser.PACKAGE, lexer);
assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.DOT, lexer);
@@ -301,6 +302,167 @@ public class LexerTest extends TestCase {
assertLex(0, lexer);
}
+ public void testDocletTags() throws Exception {
+ String in = ""
+ + "/**\n"
+ + " * @hello world\n"
+ + " * @a b c d\n"
+ + " * @bye\n"
+ + " * @bye:bye\n"
+ + " */";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCLINE, "\n",lexer);
+ assertLex(Parser.JAVADOCTAG, "@hello", lexer);
+ assertLex(Parser.JAVADOCLINE, "world\n", lexer);
+
+ assertLex(Parser.JAVADOCTAG, "@a", lexer);
+ assertLex(Parser.JAVADOCLINE, "b c d\n", lexer);
+
+ assertLex(Parser.JAVADOCTAG, "@bye", lexer);
+ assertLex(Parser.JAVADOCLINE, "\n",lexer);
+
+ assertLex(Parser.JAVADOCTAG, "@bye:bye", lexer);
+ assertLex(Parser.JAVADOCLINE, "\n",lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testOneLinerDocComment() throws Exception {
+ String in = "/** @hello world */";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCTAG, "@hello", lexer);
+ assertLex(Parser.JAVADOCLINE, "world", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testCompressedDocComment() throws Exception {
+ String in = "/**@foo bar*/";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCTAG, "@foo", lexer);
+ assertLex(Parser.JAVADOCLINE, "bar", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testDeepJavadocTag() throws Exception {
+ String in = " /** * *** * @m x \n" +
+ "*/";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCLINE, "* *** * @m x \n", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testDocCommentContainingAtSymbols() throws Exception {
+ String in = ""
+ + "/**\n"
+ + " * joe at truemesh.com\n"
+ + " * {@link here}.\n"
+ + " * me @home\n"
+ + " * geeks @ play\n"
+ + " */";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCLINE, "\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "joe at truemesh.com\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "{@link here}.\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "me @home\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "geeks @ play\n", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testDocCommentContainingStars() throws Exception {
+ String in = ""
+ + "/**\n"
+ + " * 5 * 4\n"
+ + " * SELECT COUNT(*)\n"
+ + " * **stars**everywhere** \n"
+ + " */";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCLINE, "\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "5 * 4\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "SELECT COUNT(*)\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "**stars**everywhere** \n", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testExtraStarsAreIgnoredAtStartAndEnd() throws Exception {
+ String in = ""
+ + "/*****\n"
+ + " * blah\n"
+ + " *****/";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+ assertLex(Parser.JAVADOCLINE, "\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "blah\n", lexer);
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testExtraStarsCompressed() throws Exception {
+ String in = ""
+ + "/***blah***/public";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+ assertLex(Parser.JAVADOCLINE, "blah", lexer);
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(Parser.PUBLIC, lexer);
+ assertLex(0, lexer);
+ }
+
+ public void testIgnoreStarPrefix() throws Exception {
+ String in = ""
+ + "/**\n"
+ + " * simple\n"
+ + "\t * indented\n"
+ + " *nospace\n"
+ + " *** multistar\n"
+ + " *\n"
+ + " */";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+
+ assertLex(Parser.JAVADOCLINE, "\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "simple\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "indented\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "nospace\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "multistar\n", lexer);
+ assertLex(Parser.JAVADOCLINE, "\n", lexer);
+
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
+ // QDOX-200
+ public void testCompactJavaDocTag() throws Exception {
+ String in = "/** @foo*/";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.JAVADOCSTART, lexer);
+ assertLex(Parser.JAVADOCTAG, "@foo", lexer);
+ assertLex(Parser.JAVADOCEND, lexer);
+ assertLex(0, lexer);
+ }
+
public void testArrayTokens() throws Exception {
String in = "String[] []o[]";
Lexer lexer = new JFlexLexer(new StringReader(in));
@@ -399,13 +561,13 @@ public class LexerTest extends TestCase {
assertLex(Parser.IDENTIFIER, "month", lexer);
assertLex(Parser.EQUALS, lexer);
assertLex(Parser.STRING_LITERAL, "\"", lexer);
- assertEquals("\"Jan\"", lexer.getCodeBody());
+ // TODO the above should be ...
+ // assertLex(Parser.STRING_LITERAL, "Jan", lexer);
assertLex(Parser.PARENCLOSE, lexer);
assertLex(Parser.AT, "@", lexer);
assertLex(Parser.IDENTIFIER, "Note", lexer);
assertLex(Parser.PARENOPEN, lexer);
assertLex(Parser.STRING_LITERAL, lexer);
- assertEquals( "\"Just ignore me\"", lexer.getCodeBody() );
assertLex(Parser.PARENCLOSE, lexer);
assertLex(Parser.PUBLIC, lexer);
assertLex(Parser.CLASS, lexer);
@@ -439,45 +601,18 @@ public class LexerTest extends TestCase {
assertLex(Parser.BRACECLOSE, lexer);
assertLex(0, lexer);
}
-
- public void testAnnotationElementValueArrayInitializer() throws Exception {
- String in = "@Endorsers({\"Children\", \"Unscrupulous dentists\"})\n" +
- "public class Lollipop { }";
-
- Lexer lexer = new JFlexLexer(new StringReader(in));
- assertLex(Parser.AT, "@", lexer);
- assertLex(Parser.IDENTIFIER, "Endorsers", lexer);
- assertLex(Parser.PARENOPEN, "(", lexer);
- assertLex(Parser.BRACEOPEN, "{", lexer);
- assertLex(Parser.STRING_LITERAL, "\"", lexer);
- assertEquals( "\"Children\"", lexer.getCodeBody() );
- assertLex(Parser.COMMA, ",", lexer);
- assertLex(Parser.STRING_LITERAL, "\"", lexer);
- assertEquals( "\"Unscrupulous dentists\"", lexer.getCodeBody() );
- assertLex(Parser.BRACECLOSE, "}", lexer);
- assertLex(Parser.PARENCLOSE, ")", lexer);
- assertLex(Parser.PUBLIC, "public", lexer);
- assertLex(Parser.CLASS, "class", lexer);
- assertLex(Parser.IDENTIFIER, "Lollipop", lexer);
- assertLex(Parser.BRACEOPEN, "{", lexer);
- assertLex(Parser.BRACECLOSE, "}", lexer);
- assertLex(0, lexer);
- }
public void testEnumConstructor() throws Exception {
String in = "enum Foo { a(\"hello\"); int someField; }";
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.ENUM, lexer);
- assertLex(Parser.IDENTIFIER, "Foo", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
- assertLex(Parser.IDENTIFIER, "a", lexer);
- assertLex(Parser.PARENOPEN, lexer);
- assertLex(Parser.STRING_LITERAL, "\"", lexer);
- assertEquals( "\"hello\"", lexer.getCodeBody() );
- assertLex(Parser.PARENCLOSE, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.PARENBLOCK, lexer);
assertLex(Parser.SEMI, lexer);
- assertLex(Parser.IDENTIFIER, "int", lexer);
- assertLex(Parser.IDENTIFIER, "someField", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.SEMI, lexer);
assertLex(Parser.BRACECLOSE, lexer);
}
@@ -489,21 +624,11 @@ public class LexerTest extends TestCase {
+ "}";
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.ENUM, lexer);
- assertLex(Parser.IDENTIFIER, "Animal", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
- assertLex(Parser.IDENTIFIER, "DUCK", lexer);
- //assertLex(Parser.CODEBLOCK, lexer);
- assertLex( Parser.BRACEOPEN, lexer );
- assertLex(Parser.PUBLIC, lexer);
- assertLex(Parser.IDENTIFIER, "void", lexer);
- assertLex( Parser.IDENTIFIER, "speak", lexer );
- assertLex( Parser.PARENOPEN, lexer );
- assertLex( Parser.PARENCLOSE, lexer );
- assertLex( Parser.CODEBLOCK, lexer );
- assertLex( Parser.BRACECLOSE, lexer );
-
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.CODEBLOCK, lexer);
assertLex(Parser.BRACECLOSE, lexer);
- assertLex( 0, lexer );
}
private void assertSingleLex(String in, short expectedLex) throws Exception {
@@ -533,7 +658,7 @@ public class LexerTest extends TestCase {
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.INTERFACE, lexer);
- assertLex(Parser.IDENTIFIER, "X", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.IDENTIFIER, "void", lexer);
assertLex(Parser.IDENTIFIER, "paramWithNonAsciis\\u00E4\\u00F6\\u00FC\\u00DF", lexer);
@@ -550,19 +675,17 @@ public class LexerTest extends TestCase {
"@MyFunction.MyInterface( prefix1 = \"abc\", prefix2 = \"abc\" )";
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.AT, lexer);
- assertLex(Parser.IDENTIFIER, "MyFunction", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.DOT, lexer);
- assertLex(Parser.IDENTIFIER, "MyInterface", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.PARENOPEN, lexer);
- assertLex(Parser.IDENTIFIER, "prefix1", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.EQUALS, lexer);
assertLex(Parser.STRING_LITERAL, lexer);
- assertEquals( "\"abc\"", lexer.getCodeBody() );
assertLex(Parser.COMMA, lexer);
- assertLex(Parser.IDENTIFIER, "prefix2", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.EQUALS, lexer);
assertLex(Parser.STRING_LITERAL, lexer);
- assertEquals( "\"abc\"", lexer.getCodeBody() );
assertLex(Parser.PARENCLOSE, lexer);
}
@@ -570,30 +693,27 @@ public class LexerTest extends TestCase {
String in = "@Override\n public boolean isReadOnly(final ELContext context)";
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.AT, lexer);
- assertLex(Parser.IDENTIFIER, "Override", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.PUBLIC, lexer);
- assertLex(Parser.IDENTIFIER, "boolean", lexer);
- assertLex(Parser.IDENTIFIER, "isReadOnly", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.PARENOPEN, lexer);
assertLex(Parser.FINAL, lexer);
- assertLex(Parser.IDENTIFIER, "ELContext", lexer);
- assertLex(Parser.IDENTIFIER, "context", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.PARENCLOSE, lexer);
}
- public void testMultipleRowAnnotation()
- throws Exception
- {
- String in = "@JSFComponent\n (name = \"h:inputHidden\")";
- Lexer lexer = new JFlexLexer( new StringReader( in ) );
- assertLex( Parser.AT, lexer );
- assertLex( Parser.IDENTIFIER, "JSFComponent", lexer );
- assertLex( Parser.PARENOPEN, lexer );
- assertLex( Parser.IDENTIFIER, "name", lexer );
- assertLex( Parser.EQUALS, lexer );
- assertLex( Parser.STRING_LITERAL, lexer );
- assertEquals( "\"h:inputHidden\"", lexer.getCodeBody() );
- assertLex( Parser.PARENCLOSE, lexer );
+ public void testMultipleRowAnnotation() throws Exception {
+ String in = "@JSFComponent\n (name = \"h:inputHidden\")";
+ Lexer lexer = new JFlexLexer(new StringReader(in));
+ assertLex(Parser.AT, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.PARENOPEN, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.EQUALS, lexer);
+ assertLex(Parser.STRING_LITERAL, lexer);
+ assertLex(Parser.PARENCLOSE, lexer);
}
public void testEnumWithAnnotations() throws Exception {
@@ -604,39 +724,19 @@ public class LexerTest extends TestCase {
"}";
Lexer lexer = new JFlexLexer(new StringReader(in));
assertLex(Parser.CLASS, lexer);
- assertLex(Parser.IDENTIFIER, "Foo", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.PUBLIC, lexer);
assertLex(Parser.ENUM, lexer);
- assertLex(Parser.IDENTIFIER, "BasicType", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.BRACEOPEN, lexer);
assertLex(Parser.AT, lexer);
- assertLex(Parser.IDENTIFIER, "XmlEnumValue", lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
assertLex(Parser.PARENOPEN, lexer);
assertLex(Parser.STRING_LITERAL, lexer);
- assertEquals( "\"text\"", lexer.getCodeBody() );
assertLex(Parser.PARENCLOSE, lexer);
- assertLex(Parser.IDENTIFIER, "VALUE", lexer);
- assertLex(Parser.PARENOPEN, lexer);
- assertLex(Parser.STRING_LITERAL, lexer);
- assertEquals( "\"value\"", lexer.getCodeBody() );
- assertLex(Parser.PARENCLOSE, lexer);
+ assertLex(Parser.IDENTIFIER, lexer);
+ assertLex(Parser.PARENBLOCK, lexer);
assertLex(Parser.SEMI, lexer);
}
-
- // QDOX-242
- public void testDoubleValueAnnotation()
- throws Exception
- {
- String in = "@Rule( delta = 0.005 )";
- Lexer lexer = new JFlexLexer( new StringReader( in ) );
- assertLex( Parser.AT, lexer );
- assertLex( Parser.IDENTIFIER, "Rule", lexer );
- assertLex( Parser.PARENOPEN, lexer );
- assertLex( Parser.IDENTIFIER, "delta", lexer );
- assertLex( Parser.EQUALS, lexer );
- assertLex( Parser.FLOAT_LITERAL, "0.005", lexer );
- assertLex( Parser.PARENCLOSE, lexer );
- assertLex( 0, lexer );
- }
}
diff --git a/src/test/com/thoughtworks/qdox/parser/MockBuilder.java b/src/test/com/thoughtworks/qdox/parser/MockBuilder.java
new file mode 100644
index 0000000..2bf0fae
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/parser/MockBuilder.java
@@ -0,0 +1,183 @@
+package com.thoughtworks.qdox.parser;
+
+import org.jmock.expectation.ExpectationCounter;
+import org.jmock.expectation.ExpectationList;
+
+import com.thoughtworks.qdox.model.Annotation;
+import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TagDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+
+class MockBuilder implements Builder {
+ private ExpectationCounter myAddPackageCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddPackageCalls");
+ private ExpectationList myAddPackageParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addPackage() : java.lang.String packageName");
+ private ExpectationCounter myAddImportCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddImportCalls");
+ private ExpectationList myAddImportParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addImport() : java.lang.String importName");
+ private ExpectationCounter myAddJavaDocCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddJavaDocCalls");
+ private ExpectationList myAddJavaDocParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addJavaDoc() : java.lang.String text");
+ private ExpectationCounter myAddJavaDocTagCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddJavaDocTagCalls");
+ private ExpectationList myAddJavaDocTagParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addJavaDocTag() : java.lang.String tag");
+ private ExpectationList myAddJavaDocTagParameter1Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addJavaDocTag() : java.lang.String text");
+ private ExpectationCounter myBeginClassCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder BeginClassCalls");
+ private ExpectationList myBeginClassParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.beginClass() : com.thoughtworks.qdox.parser.structs.ClassDef def");
+ private ExpectationCounter myEndClassCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder EndClassCalls");
+ private ExpectationCounter myBeginMethodCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder BeginMethodCalls");
+ private ExpectationCounter myEndMethodCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder EndMethodCalls");
+ private ExpectationList myEndMethodParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.endMethod() : com.thoughtworks.qdox.parser.structs.MethodDef def");
+ private ExpectationCounter myAddFieldCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddFieldCalls");
+ private ExpectationList myAddFieldParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addField() : com.thoughtworks.qdox.parser.structs.FieldDef def");
+ private ExpectationCounter myAddParameterCalls = new ExpectationCounter("com.thoughtworks.qdox.parser.Builder AddParameterCalls");
+ private ExpectationList myAddParameter0Values = new ExpectationList("com.thoughtworks.qdox.parser.Builder.addParameter() : com.thoughtworks.qdox.parser.structs.FieldDef def");
+
+
+ public void setExpectedAddPackageCalls(int calls) {
+ myAddPackageCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddPackageValues(PackageDef arg0) {
+ myAddPackageParameter0Values.addExpected(arg0);
+ }
+
+ public void addPackage(PackageDef arg0) {
+ myAddPackageCalls.inc();
+ myAddPackageParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedAddImportCalls(int calls) {
+ myAddImportCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddImportValues(String arg0) {
+ myAddImportParameter0Values.addExpected(arg0);
+ }
+
+ public void addImport(String arg0) {
+ myAddImportCalls.inc();
+ myAddImportParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedAddJavaDocCalls(int calls) {
+ myAddJavaDocCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddJavaDocValues(String arg0) {
+ myAddJavaDocParameter0Values.addExpected(arg0);
+ }
+
+ public void addJavaDoc(String arg0) {
+ myAddJavaDocCalls.inc();
+ myAddJavaDocParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedAddJavaDocTagCalls(int calls) {
+ myAddJavaDocTagCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddJavaDocTagValues(TagDef arg0) {
+ myAddJavaDocTagParameter0Values.addExpected(arg0);
+ }
+
+ public void addJavaDocTag(TagDef arg0) {
+ myAddJavaDocTagCalls.inc();
+ myAddJavaDocTagParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedBeginClassCalls(int calls) {
+ myBeginClassCalls.setExpected(calls);
+ }
+
+ public void addExpectedBeginClassValues(ClassDef arg0) {
+ myBeginClassParameter0Values.addExpected(arg0);
+ }
+
+ public void beginClass(ClassDef arg0) {
+ myBeginClassCalls.inc();
+ myBeginClassParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedEndClassCalls(int calls) {
+ myEndClassCalls.setExpected(calls);
+ }
+
+ public void endClass() {
+ myEndClassCalls.inc();
+ }
+
+ public void beginMethod() {
+ myBeginMethodCalls.inc();
+ }
+ public void setExpectedEndMethodCalls(int calls) {
+ myEndMethodCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddMethodValues(MethodDef arg0) {
+ myEndMethodParameter0Values.addExpected(arg0);
+ }
+
+ public void endMethod(MethodDef arg0) {
+ myEndMethodCalls.inc();
+ myEndMethodParameter0Values.addActual(arg0);
+ }
+
+ public void setExpectedAddFieldCalls(int calls) {
+ myAddFieldCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddFieldValues(FieldDef arg0) {
+ myAddFieldParameter0Values.addExpected(arg0);
+ }
+
+ public void addField(FieldDef arg0) {
+ myAddFieldCalls.inc();
+ myAddFieldParameter0Values.addActual(arg0);
+ }
+
+ public void addAnnotation( Annotation annotation ) {
+ // Empty
+ }
+
+ public void verify() {
+ myAddPackageCalls.verify();
+ myAddPackageParameter0Values.verify();
+ myAddImportCalls.verify();
+ myAddImportParameter0Values.verify();
+ myAddJavaDocCalls.verify();
+ myAddJavaDocParameter0Values.verify();
+ myAddJavaDocTagCalls.verify();
+ myAddJavaDocTagParameter0Values.verify();
+ myAddJavaDocTagParameter1Values.verify();
+ myBeginClassCalls.verify();
+ myBeginClassParameter0Values.verify();
+ myEndClassCalls.verify();
+ myBeginMethodCalls.verify();
+ myEndMethodCalls.verify();
+ myEndMethodParameter0Values.verify();
+ myAddFieldCalls.verify();
+ myAddFieldParameter0Values.verify();
+ }
+
+ public Type createType( String name, int dimensions ) {
+ return null;
+ }
+
+ public Type createType(TypeDef name) {
+ return null;
+ }
+
+ public void setExpectedAddParameterCalls(int calls) {
+ myAddParameterCalls.setExpected(calls);
+ }
+
+ public void addExpectedAddParameterValues(FieldDef arg0) {
+ myAddParameter0Values.addExpected(arg0);
+ }
+
+ public void addParameter(FieldDef arg0) {
+ myAddParameterCalls.inc();
+ myAddParameter0Values.addActual(arg0);
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/parser/MockLexer.java b/src/test/com/thoughtworks/qdox/parser/MockLexer.java
new file mode 100644
index 0000000..722146f
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/parser/MockLexer.java
@@ -0,0 +1,38 @@
+package com.thoughtworks.qdox.parser;
+
+import org.jmock.expectation.ReturnObjectList;
+
+class MockLexer implements Lexer {
+
+ private ReturnObjectList textReturn = new ReturnObjectList("text");
+ private ReturnObjectList lexReturn = new ReturnObjectList("lex");
+
+ public void setupText(String value) {
+ textReturn.addObjectToReturn(value);
+ }
+
+ public void setupLex(int value) {
+ lexReturn.addObjectToReturn(value);
+ }
+
+ public int lex() {
+ return ((Integer) lexReturn.nextReturnObject()).intValue();
+ }
+
+ public String text() {
+ return (String) textReturn.nextReturnObject();
+ }
+
+ public int getLine() {
+ return -1;
+ }
+
+ public int getColumn() {
+ return -1;
+ }
+
+
+ public String getCodeBody() {
+ return "";
+ }
+}
diff --git a/src/test/com/thoughtworks/qdox/parser/ParserTest.java b/src/test/com/thoughtworks/qdox/parser/ParserTest.java
new file mode 100644
index 0000000..732cf02
--- /dev/null
+++ b/src/test/com/thoughtworks/qdox/parser/ParserTest.java
@@ -0,0 +1,2586 @@
+package com.thoughtworks.qdox.parser;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+import com.thoughtworks.qdox.parser.impl.Parser;
+import com.thoughtworks.qdox.parser.structs.FieldDef;
+import com.thoughtworks.qdox.parser.structs.ClassDef;
+import com.thoughtworks.qdox.parser.structs.MethodDef;
+import com.thoughtworks.qdox.parser.structs.PackageDef;
+import com.thoughtworks.qdox.parser.structs.TagDef;
+import com.thoughtworks.qdox.parser.structs.TypeDef;
+import com.thoughtworks.qdox.parser.structs.WildcardTypeDef;
+
+public class ParserTest extends TestCase {
+
+ private MockLexer lexer;
+ private MockBuilder builder;
+
+ public ParserTest(String s) {
+ super(s);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ lexer = new MockLexer();
+ builder = new MockBuilder();
+ }
+
+ public void testPackageWithOneWord() throws Exception {
+
+ // setup values
+ setupLex(Parser.PACKAGE);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddPackageValues(new PackageDef("mypackage"));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testPackageWithMultipleWords() throws Exception {
+
+ // setup values
+ setupLex(Parser.PACKAGE);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "thingy");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddPackageValues(new PackageDef("com.blah.thingy.x"));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportWithOneWord() throws Exception {
+
+ // setup values
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddImportValues("mypackage");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportWithMultipleWords() throws Exception {
+
+ // setup values
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "thingy");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddImportValues("com.blah.thingy.x");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportWithOneWordAndStar() throws Exception {
+
+ // setup values
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.DOT);
+ setupLex(Parser.STAR);
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddImportValues("mypackage.*");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportWithMultipleWordsAndStar() throws Exception {
+
+ // setup values
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "thingy");
+ setupLex(Parser.DOT);
+ setupLex(Parser.STAR);
+ setupLex(Parser.SEMI);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddImportValues("com.blah.thingy.*");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportStaticWithOneWord()
+ throws Exception
+ {
+
+ // setup values
+ setupLex( Parser.IMPORT );
+ setupLex( Parser.STATIC );
+ setupLex( Parser.IDENTIFIER, "mypackage" );
+ setupLex( Parser.SEMI );
+ setupLex( 0 );
+
+ // expectations
+ builder.addExpectedAddImportValues( "static mypackage" );
+
+ // execute
+ Parser parser = new Parser( lexer, builder );
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportStaticWithMultipleWords()
+ throws Exception
+ {
+
+ // setup values
+ setupLex( Parser.IMPORT );
+ setupLex( Parser.STATIC );
+ setupLex( Parser.IDENTIFIER, "com" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.IDENTIFIER, "blah" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.IDENTIFIER, "Thingy" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.IDENTIFIER, "x" );
+ setupLex( Parser.SEMI );
+ setupLex( 0 );
+
+ // expectations
+ builder.addExpectedAddImportValues( "static com.blah.Thingy.x" );
+
+ // execute
+ Parser parser = new Parser( lexer, builder );
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportStaticWithOneWordAndStar()
+ throws Exception
+ {
+
+ // setup values
+ setupLex( Parser.IMPORT );
+ setupLex( Parser.STATIC );
+ setupLex( Parser.IDENTIFIER, "MyClass" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.STAR );
+ setupLex( Parser.SEMI );
+ setupLex( 0 );
+
+ // expectations
+ builder.addExpectedAddImportValues( "static MyClass.*" );
+
+ // execute
+ Parser parser = new Parser( lexer, builder );
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testImportStaticWithMultipleWordsAndStar()
+ throws Exception
+ {
+
+ // setup values
+ setupLex( Parser.IMPORT );
+ setupLex( Parser.STATIC );
+ setupLex( Parser.IDENTIFIER, "com" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.IDENTIFIER, "blah" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.IDENTIFIER, "Thingy" );
+ setupLex( Parser.DOT );
+ setupLex( Parser.STAR );
+ setupLex( Parser.SEMI );
+ setupLex( 0 );
+
+ // expectations
+ builder.addExpectedAddImportValues( "static com.blah.Thingy.*" );
+
+ // execute
+ Parser parser = new Parser( lexer, builder );
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testOneLineJavaDoc() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "This is great!");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("This is great!");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testOneJavaDocTag() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCTAG, "@This");
+ setupLex(Parser.JAVADOCLINE, "is great!");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocTagValues(new TagDef("This", "is great!"));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testOneJavaDocTagWithNoValue() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCTAG, "@eatme");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocTagValues(new TagDef("eatme", ""));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testOneMultiLineJavaDocTag() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCTAG, "@This");
+ setupLex(Parser.JAVADOCLINE, "is great! Mmmkay.");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("");
+ builder.addExpectedAddJavaDocTagValues(
+ new TagDef("This", "is great! Mmmkay.")
+ );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testMultipleJavaDocTags() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCTAG, "@This");
+ setupLex(Parser.JAVADOCLINE, "is great!");
+ setupLex(Parser.JAVADOCTAG, "@mock");
+ setupLex(Parser.JAVADOCLINE, "generate");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("");
+ builder.addExpectedAddJavaDocTagValues(new TagDef("This", "is great!"));
+ builder.addExpectedAddJavaDocTagValues(new TagDef("mock", "generate"));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testJavaDocTextAndMultipleJavaDocTags() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "Welcome! Here is my class.");
+ setupLex(Parser.JAVADOCTAG, "@This");
+ setupLex(Parser.JAVADOCLINE, "is great!");
+ setupLex(Parser.JAVADOCTAG, "@mock");
+ setupLex(Parser.JAVADOCLINE, "generate");
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("Welcome! Here is my class.");
+ builder.addExpectedAddJavaDocTagValues(new TagDef("This", "is great!"));
+ builder.addExpectedAddJavaDocTagValues(new TagDef("mock", "generate"));
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testJavaDocEmpty() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("");
+ builder.setExpectedAddJavaDocTagCalls(0);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testJavaDocOnlyContainsNewLines() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCEND);
+ setupLex(0);
+
+ // expectations
+ builder.addExpectedAddJavaDocValues("");
+ builder.setExpectedAddJavaDocTagCalls(0);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyVanillaClass() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyVanillaInterface() throws Exception {
+
+ // setup values
+ setupLex(Parser.INTERFACE);
+ setupLex(Parser.IDENTIFIER, "MyInterface");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyInterface";
+ cls.type = ClassDef.INTERFACE;
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyVanillaEnum() throws Exception {
+
+ // setup values
+ setupLex(Parser.ENUM);
+ setupLex(Parser.IDENTIFIER, "MyEnum");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyEnum";
+ cls.type = ClassDef.ENUM;
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassExtendsAnotherClass() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MySubClass");
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "MyBaseClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MySubClass";
+ cls.extendz.add(new TypeDef("com.blah.MyBaseClass"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyInterfaceExtendsMultipleInterfaces() throws Exception {
+
+ // setup values
+ setupLex(Parser.INTERFACE);
+ setupLex(Parser.IDENTIFIER, "MyInterface");
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "AnotherInterface");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "Serializable");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyInterface";
+ cls.type = ClassDef.INTERFACE;
+ cls.extendz.add(new TypeDef("com.blah.AnotherInterface"));
+ cls.extendz.add(new TypeDef("Serializable"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassImplementsOneInterface() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.IMPLEMENTS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "AnInterface");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.implementz.add(new TypeDef("com.blah.AnInterface"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassImplementsMultipleInterfaces() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.IMPLEMENTS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "AnInterface");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "io");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "Serializable");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "Eatable");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.implementz.add(new TypeDef("com.blah.AnInterface"));
+ cls.implementz.add(new TypeDef("java.io.Serializable"));
+ cls.implementz.add(new TypeDef("Eatable"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassExtendsOneClassAndImplementsOneInterface() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "BaseClass");
+ setupLex(Parser.IMPLEMENTS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "AnInterface");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.extendz.add(new TypeDef("mypackage.BaseClass"));
+ cls.implementz.add(new TypeDef("com.blah.AnInterface"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassExtendsOneClassAndImplementsMultipleInterface() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "BaseClass");
+ setupLex(Parser.IMPLEMENTS);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "AnInterface");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "io");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "Serializable");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "Eatable");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.extendz.add(new TypeDef("mypackage.BaseClass"));
+ cls.implementz.add(new TypeDef("com.blah.AnInterface"));
+ cls.implementz.add(new TypeDef("java.io.Serializable"));
+ cls.implementz.add(new TypeDef("Eatable"));
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassWithPublicFinalModifiers() throws Exception {
+
+ // setup values
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.FINAL);
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.modifiers.add("public");
+ cls.modifiers.add("final");
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testEmptyClassWithAllModifiers() throws Exception {
+
+ // setup values
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.PROTECTED);
+ setupLex(Parser.PRIVATE);
+ setupLex(Parser.FINAL);
+ setupLex(Parser.ABSTRACT);
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.modifiers.add("public");
+ cls.modifiers.add("protected");
+ cls.modifiers.add("private");
+ cls.modifiers.add("final");
+ cls.modifiers.add("abstract");
+ builder.addExpectedBeginClassValues(cls);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testMultipleClassesInSingleFile() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "Class1");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "Class2");
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "SubClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(Parser.INTERFACE);
+ setupLex(Parser.IDENTIFIER, "Intf1");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ ClassDef cls1 = new ClassDef();
+ cls1.name = "Class1";
+ cls1.type = ClassDef.CLASS;
+ builder.addExpectedBeginClassValues(cls1);
+
+ ClassDef cls2 = new ClassDef();
+ cls2.name = "Class2";
+ cls2.type = ClassDef.CLASS;
+ cls2.modifiers.add("public");
+ cls2.extendz.add(new TypeDef("SubClass"));
+ builder.addExpectedBeginClassValues(cls2);
+
+ ClassDef cls3 = new ClassDef();
+ cls3.name = "Intf1";
+ cls3.type = ClassDef.INTERFACE;
+ builder.addExpectedBeginClassValues(cls3);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testSemiColonBetweenClass() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "Class1");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(Parser.SEMI); // ;
+
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "Class2");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+ setupLex(Parser.SEMI); // ;
+
+ setupLex(0);
+
+ // expectations
+ ClassDef cls1 = new ClassDef();
+ cls1.name = "Class1";
+ cls1.type = ClassDef.CLASS;
+ builder.addExpectedBeginClassValues(cls1);
+
+ ClassDef cls2 = new ClassDef();
+ cls2.name = "Class2";
+ cls2.type = ClassDef.CLASS;
+ builder.addExpectedBeginClassValues(cls2);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testJavaDocAppearingAllOverThePlace() throws Exception {
+
+ // setup values
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc1");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc2");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.PACKAGE);
+ setupLex(Parser.IDENTIFIER, "mypackage");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc3");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc4");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "anotherpackage");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "Something");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc5");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc6");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.IMPORT);
+ setupLex(Parser.IDENTIFIER, "elsewhere");
+ setupLex(Parser.DOT);
+ setupLex(Parser.STAR);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc7");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc8");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc9");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(Parser.JAVADOCSTART);
+ setupLex(Parser.JAVADOCLINE, "javadoc10");
+ setupLex(Parser.JAVADOCEND);
+
+ setupLex(0);
+
+ // expectations
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ cls.modifiers.add("public");
+ builder.addExpectedBeginClassValues(cls);
+ builder.addExpectedAddJavaDocValues("javadoc1");
+ builder.addExpectedAddJavaDocValues("javadoc2");
+ builder.addExpectedAddJavaDocValues("javadoc3");
+ builder.addExpectedAddJavaDocValues("javadoc4");
+ builder.addExpectedAddJavaDocValues("javadoc5");
+ builder.addExpectedAddJavaDocValues("javadoc6");
+ builder.addExpectedAddJavaDocValues("javadoc7");
+ builder.addExpectedAddJavaDocValues("javadoc8");
+ builder.addExpectedAddJavaDocValues("javadoc9");
+ builder.addExpectedAddJavaDocValues("javadoc10");
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+
+ }
+
+ public void testSimpleVoidMethod() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testSimpleVoidMethodWithNoCode() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testSimpleMethodReturningSomething() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "Something");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("Something");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testSimpleMethodReturningSomethingFullyQualified() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "Something");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("com.blah.Something");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testSimpleMethodWithAllModifiers() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.PROTECTED);
+ setupLex(Parser.PRIVATE);
+ setupLex(Parser.ABSTRACT);
+ setupLex(Parser.STATIC);
+ setupLex(Parser.FINAL);
+ setupLex(Parser.NATIVE);
+ setupLex(Parser.SYNCHRONIZED);
+ setupLex(Parser.VOLATILE);
+ setupLex(Parser.IDENTIFIER, "com");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "blah");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "Something");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("com.blah.Something");
+ mth.modifiers.add("public");
+ mth.modifiers.add("protected");
+ mth.modifiers.add("private");
+ mth.modifiers.add("abstract");
+ mth.modifiers.add("static");
+ mth.modifiers.add("final");
+ mth.modifiers.add("native");
+ mth.modifiers.add("synchronized");
+ mth.modifiers.add("volatile");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithOneArg() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "numberOfTimes");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "numberOfTimes";
+ p1.type = new TypeDef("int");
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithOneFullyQualifiedArg() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "lang");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "numberOfTimes");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "numberOfTimes";
+ p1.type = new TypeDef("java.lang.String");
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithTwoArgs() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "numberOfTimes");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "name");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "numberOfTimes";
+ p1.type = new TypeDef("int");
+ FieldDef p2 = new FieldDef();
+ p2.name = "name";
+ p2.type = new TypeDef("String");
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+ builder.addExpectedAddParameterValues( p2 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithThreeArgs() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "numberOfTimes");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "name");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "boolean");
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "numberOfTimes";
+ p1.type = new TypeDef("int");
+ FieldDef p2 = new FieldDef();
+ p2.name = "name";
+ p2.type = new TypeDef("String");
+ FieldDef p3 = new FieldDef();
+ p3.name = "x";
+ p3.type = new TypeDef("boolean");
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+ builder.addExpectedAddParameterValues( p2 );
+ builder.addExpectedAddParameterValues( p3 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithOneArgThatHasModifier() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.FINAL);
+ setupLex(Parser.VOLATILE);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "numberOfTimes");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "numberOfTimes";
+ p1.type = new TypeDef("int");
+ p1.modifiers.add("final");
+ p1.modifiers.add("volatile");
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodThrowingOneException() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.exceptions.add("IOException");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodThrowingTwoExceptions() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "MyException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.exceptions.add("IOException");
+ mth.exceptions.add("MyException");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodThrowingThreeExceptions() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "MyException");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "AnotherException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.exceptions.add("IOException");
+ mth.exceptions.add("MyException");
+ mth.exceptions.add("AnotherException");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodThrowingOneFullyQualifiedException() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "io");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.exceptions.add("java.io.IOException");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodThrowingTwoFullyQualifiedException() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doSomething");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "io");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "lang");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "RuntimeException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doSomething";
+ mth.returnType = new TypeDef("void");
+ mth.exceptions.add("java.io.IOException");
+ mth.exceptions.add("java.lang.RuntimeException");
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testDefaultConstructor() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testPublicConstructorWithParam() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ mth.modifiers.add("public");
+ FieldDef p1 = new FieldDef();
+ p1.name = "count";
+ p1.type = new TypeDef("int");
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testConstructorWithMultipleParams() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "lang");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "thingy");
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ mth.modifiers.add("public");
+ FieldDef p1 = new FieldDef();
+ p1.name = "count";
+ p1.type = new TypeDef("int");
+ FieldDef p2 = new FieldDef();
+ p2.name = "thingy";
+ p2.type = new TypeDef("java.lang.String");
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+ builder.addExpectedAddParameterValues( p2 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testConstructorWithException() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "SomeException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ mth.exceptions.add("SomeException");
+
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testConstructorWithMultipleException() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.THROWS);
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "io");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "IOException");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "SomeException");
+ setupLex(Parser.CODEBLOCK);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "MyClass";
+ mth.constructor = true;
+ mth.exceptions.add("SomeException");
+ mth.exceptions.add("java.io.IOException");
+
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testField() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldFullyQualified() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "java");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "lang");
+ setupLex(Parser.DOT);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("java.lang.String");
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldWithModifiers() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.PUBLIC);
+ setupLex(Parser.PROTECTED);
+ setupLex(Parser.PRIVATE);
+ setupLex(Parser.STATIC);
+ setupLex(Parser.FINAL);
+ setupLex(Parser.TRANSIENT);
+ setupLex(Parser.STRICTFP);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.modifiers.add("public");
+ fld.modifiers.add("protected");
+ fld.modifiers.add("private");
+ fld.modifiers.add("static");
+ fld.modifiers.add("final");
+ fld.modifiers.add("transient");
+ fld.modifiers.add("strictfp");
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldWithMultipleDefinitionsOnOneLine() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.IDENTIFIER, "thing");
+ setupLex(Parser.COMMA);
+ setupLex(Parser.IDENTIFIER, "another");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld1 = new FieldDef();
+ fld1.name = "thing";
+ fld1.type = new TypeDef("String");
+ builder.addExpectedAddFieldValues(fld1);
+ FieldDef fld2 = new FieldDef();
+ fld2.name = "another";
+ fld2.type = new TypeDef("String");
+ builder.addExpectedAddFieldValues(fld2);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldWithSimpleGenericType() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "List");
+ setupLex(Parser.LESSTHAN);
+ setupLex(Parser.IDENTIFIER, "String");
+ setupLex(Parser.GREATERTHAN);
+
+ setupLex(Parser.IDENTIFIER, "l");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "l";
+ fld.type = new TypeDef("List");
+ fld.type.actualArgumentTypes = new ArrayList();
+ fld.type.actualArgumentTypes.add(new TypeDef("String"));
+
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldWithWildcardGenericType() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "List");
+ setupLex(Parser.LESSTHAN);
+ setupLex(Parser.QUERY);
+ setupLex(Parser.EXTENDS);
+ setupLex(Parser.IDENTIFIER, "A");
+ setupLex(Parser.GREATERTHAN);
+
+ setupLex(Parser.IDENTIFIER, "l");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "l";
+ fld.type = new TypeDef("List");
+ fld.type.actualArgumentTypes = new ArrayList();
+ fld.type.actualArgumentTypes.add(new WildcardTypeDef(new TypeDef("A"), "extends"));
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testStaticBlock() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.STATIC);
+ setupLex(Parser.CODEBLOCK);
+
+ // a random method afterwards
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doStuff");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expect no the method, and it shouldn't be static.
+ MethodDef method = new MethodDef();
+ method.name = "doStuff";
+ method.returnType = new TypeDef("void");
+ builder.addExpectedAddMethodValues(method);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testInnerClass() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "InnerCls");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "AnotherClass");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.BRACECLOSE);
+
+ setupLex(0);
+
+ // expectations
+ builder.setExpectedBeginClassCalls(3);
+ ClassDef cls = new ClassDef();
+ cls.name = "MyClass";
+ builder.addExpectedBeginClassValues(cls);
+ ClassDef cls2 = new ClassDef();
+ cls2.name = "InnerCls";
+ builder.addExpectedBeginClassValues(cls2);
+ ClassDef cls3 = new ClassDef();
+ cls3.name = "AnotherClass";
+ builder.addExpectedBeginClassValues(cls3);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testRogueSemiColon() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "MyClass");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldNotArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 0;
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldArrayOnType() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 1;
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testField2dArrayOnType() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 2;
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldArrayOnName() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 1;
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testField3dArrayOnTypeAndName() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 3;
+
+ builder.addExpectedAddFieldValues(fld);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testFieldArrayThenAnotherNonArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count2");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ FieldDef fld = new FieldDef();
+ fld.name = "count";
+ fld.type = new TypeDef("int");
+ fld.dimensions = 1;
+
+ FieldDef fld2 = new FieldDef();
+ fld2.name = "count2";
+ fld2.type = new TypeDef("int");
+ fld2.dimensions = 0;
+
+ builder.addExpectedAddFieldValues(fld);
+ builder.addExpectedAddFieldValues(fld2);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodNoArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 0;
+
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 1;
+
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithArrayDefinedAtEnd() throws Exception {
+
+ // It is legal in Java to define a method like this:
+ // String doStuff()[] {
+ // ... which is equivalent to:
+ // String[] doStuff() {
+ // This is done in some places in the JDK.
+
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 1;
+
+ builder.addExpectedAddMethodValues(mth);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodReturningArrayWithParamNoArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "p1");
+
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 1;
+ FieldDef p1 = new FieldDef();
+ p1.name = "p1";
+ p1.type = new TypeDef("int");
+ p1.dimensions = 0;
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodReturningNoArrayWithParamArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "p1");
+
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 0;
+ FieldDef p1 = new FieldDef();
+ p1.name = "p1";
+ p1.type = new TypeDef("int");
+ p1.dimensions = 1;
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodReturningArrayWithParam2dArray() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "count");
+ setupLex(Parser.PARENOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.SQUAREOPEN);
+ setupLex(Parser.SQUARECLOSE);
+ setupLex(Parser.IDENTIFIER, "p1");
+
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "count";
+ mth.returnType = new TypeDef("int");
+ mth.dimensions = 1;
+ FieldDef p1 = new FieldDef();
+ p1.name = "p1";
+ p1.type = new TypeDef("int");
+ p1.dimensions = 2;
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues( p1 );
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testMethodWithVarArgsParameter() throws Exception {
+
+ // setup values
+ setupLex(Parser.CLASS);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "void");
+ setupLex(Parser.IDENTIFIER, "doStuff");
+ setupLex(Parser.PARENOPEN);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.DOTDOTDOT);
+ setupLex(Parser.IDENTIFIER, "stuff");
+
+ setupLex(Parser.PARENCLOSE);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // expectations
+ MethodDef mth = new MethodDef();
+ mth.name = "doStuff";
+ mth.returnType = new TypeDef("void");
+ FieldDef p1 = new FieldDef();
+ p1.name = "stuff";
+ p1.type = new TypeDef("int");
+ p1.dimensions = 0;
+ p1.isVarArgs = true;
+
+ builder.addExpectedAddMethodValues(mth);
+ builder.addExpectedAddParameterValues(p1);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testEnumWithConstructors() throws Exception {
+ setupLex(Parser.ENUM);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "a");
+ setupLex(Parser.PARENBLOCK);
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.IDENTIFIER, "int");
+ setupLex(Parser.IDENTIFIER, "someField");
+ setupLex(Parser.SEMI);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ public void testEnumEndingWithExtraComma() throws Exception {
+ setupLex(Parser.ENUM);
+ setupLex(Parser.IDENTIFIER, "x");
+ setupLex(Parser.BRACEOPEN);
+
+ setupLex(Parser.IDENTIFIER, "a");
+ setupLex(Parser.COMMA);
+
+ setupLex(Parser.BRACECLOSE);
+ setupLex(0);
+
+ // execute
+ Parser parser = new Parser(lexer, builder);
+ parser.parse();
+
+ // verify
+ builder.verify();
+ }
+
+ private void setupLex(int token, String value) {
+ lexer.setupLex(token);
+ lexer.setupText(value);
+ }
+
+ private void setupLex(int token) {
+ setupLex(token, null);
+ }
+
+}
diff --git a/src/test/resources/com/thoughtworks/qdox/testdata/DefaultCtor.java b/src/test/com/thoughtworks/qdox/testdata/DefaultCtor.java
similarity index 100%
rename from src/test/resources/com/thoughtworks/qdox/testdata/DefaultCtor.java
rename to src/test/com/thoughtworks/qdox/testdata/DefaultCtor.java
diff --git a/src/test/java/com/thoughtworks/qdox/testdata/PropertyClass.java b/src/test/com/thoughtworks/qdox/testdata/PropertyClass.java
similarity index 100%
rename from src/test/java/com/thoughtworks/qdox/testdata/PropertyClass.java
rename to src/test/com/thoughtworks/qdox/testdata/PropertyClass.java
diff --git a/src/test/resources/com/thoughtworks/qdox/testdata/Unicode.java b/src/test/com/thoughtworks/qdox/testdata/Unicode.java
similarity index 100%
rename from src/test/resources/com/thoughtworks/qdox/testdata/Unicode.java
rename to src/test/com/thoughtworks/qdox/testdata/Unicode.java
diff --git a/src/test/java/com/thoughtworks/qdox/traversal/TraversalTest.java b/src/test/com/thoughtworks/qdox/traversal/TraversalTest.java
similarity index 54%
rename from src/test/java/com/thoughtworks/qdox/traversal/TraversalTest.java
rename to src/test/com/thoughtworks/qdox/traversal/TraversalTest.java
index 9f4d351..458cb79 100644
--- a/src/test/java/com/thoughtworks/qdox/traversal/TraversalTest.java
+++ b/src/test/com/thoughtworks/qdox/traversal/TraversalTest.java
@@ -2,30 +2,31 @@ package com.thoughtworks.qdox.traversal;
import junit.framework.TestCase;
-import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.impl.AbstractBaseMethod;
-import com.thoughtworks.qdox.model.impl.DefaultJavaMethod;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.AbstractInheritableJavaEntity;
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.ant.AbstractQdoxTaskTest;
public class TraversalTest extends TestCase {
- private JavaProjectBuilder builder;
+ private JavaDocBuilder builder;
public TraversalTest(String name) {
super(name);
}
protected void setUp() throws Exception {
- builder = new JavaProjectBuilder();
- //by default current classloader is already added, so QDox-classes can be found
+ builder = new JavaDocBuilder();
+ builder.addSourceTree(AbstractQdoxTaskTest.getUnderJUnitFile("src/java"));
}
public void testParentClassTraversal() throws Exception {
- JavaClass javaClass = builder.getClassByName(DefaultJavaMethod.class.getName());
+ JavaClass javaClass = builder.getClassByName(JavaMethod.class.getName());
JavaClass parentClass = javaClass.getSuperJavaClass();
assertNotNull("Parent class not found", parentClass);
assertEquals("Parent class traversal has returned the wrong parent",
- AbstractBaseMethod.class.getName(),
+ AbstractInheritableJavaEntity.class.getName(),
parentClass.getFullyQualifiedName());
}
diff --git a/src/test/java/com/thoughtworks/qdox/AnnotationExpressionTest.java b/src/test/java/com/thoughtworks/qdox/AnnotationExpressionTest.java
deleted file mode 100644
index a0f9b00..0000000
--- a/src/test/java/com/thoughtworks/qdox/AnnotationExpressionTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.thoughtworks.qdox;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.StringReader;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import com.thoughtworks.qdox.builder.impl.EvaluatingVisitor;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.parser.ParseException;
-
- at RunWith( Parameterized.class )
-public class AnnotationExpressionTest
-{
-
- private JavaProjectBuilder builder;
-
- private String expression;
-
- private Object parsedResult;
-
- public AnnotationExpressionTest( String expression, Object parsedResult )
- {
- this.expression = expression;
- this.parsedResult = parsedResult;
- }
-
- @Before
- public void setUp()
- throws Exception
- {
- builder = new JavaProjectBuilder();
- }
-
- @Parameters
- public static Collection<?> createParameters()
- {
- return Arrays.asList( new Object[][] {
- // testPrecedence
- { "2 + 2 * 5", new Integer( 12 ) },
- { "2 * 5 + 2", new Integer( 12 ) },
- { "2+2*5", new Integer( 12 ) },
- { "2*5+2", new Integer( 12 ) },
-
- // testLogicalExpression
- { "true && false", Boolean.FALSE },
- { "true || false", Boolean.TRUE },
- { "!true", Boolean.FALSE },
-
- // testBitExpression
- { "1 & 3", new Integer( 1 & 3 ) },
- { "1 | 3", new Integer( 1 | 3 ) },
- { "1 ^ 3", new Integer( 1 ^ 3 ) },
- { "~1", new Integer( ~1 ) },
-
- // testSignExpression
- { "+1", new Integer( 1 ) },
- { "-1", new Integer( -1 ) },
- //{ "--1", new Integer( --1 ) },
-
- // testAddSubMultDivExpression
- { "8 / 3", new Integer( 8 / 3 ) },
- { "8 * 3", new Integer( 8 * 3 ) },
- { "8 + 3", new Integer( 8 + 3 ) },
- { "8 - 3", new Integer( 8 - 3 ) },
- { "8 % 3", new Integer( 8 % 3 ) },
- { "\"a\" + \"b\"", "a" + "b" },
-
- // testShiftExpression
- { "8 << 2", new Integer( 8 << 2 ) },
- { "8 >> 2", new Integer( 8 >> 2 ) },
- { "-1 >> 2", new Integer( -1 >> 2 ) },
- { "-1 >>> 2", new Integer( -1 >>> 2 ) },
-
- // testLiteral
- { "1", new Integer( 1 ) },
- { "1l", new Long( 1 ) },
- { "1.0", new Float( 1 ) },
- { "1.0d", new Double( 1 ) },
-
- // testParenExpression
- { "2 + (2 * 5)", new Integer( 12 ) },
- { "(2 + 2) * 5", new Integer( 20 ) },
-
- // testCompareExpression
- { "1 < 2", Boolean.TRUE },
- { "1 > 2", Boolean.FALSE },
- { "1 <= 2", Boolean.TRUE },
- { "1 >= 2", Boolean.FALSE },
- { "1 == 2", Boolean.FALSE },
- { "1 != 2", Boolean.TRUE },
-
- // testQueryExpression
- { "1 < 2 ? 0 : 3", new Integer( 0 ) },
- { "1 > 2 ? 0 : 3", new Integer( 3 ) },
-
- // testCastExpression
- { "(short)1", new Short( (short) 1 ) },
- { "(long)(short)1", new Long( 1 ) },
- { "(int)((short)1 + (long)3)", new Integer( 4 ) },
-
- // test Array-valued single-element annotation
- { "{\"Children\", \"Unscrupulous dentists\"}",
- Arrays.asList( new String[] { "Children", "Unscrupulous dentists" } ) },
-
- // test Array-valued annotation ending with a comma
- { "{\"deprecated\", }", Arrays.asList( new String[] { "deprecated" } ) },
-
- // Binary Literals (added to JDK7)
- { "(byte)0b00100001", Byte.parseByte( "100001", 2 ) },
- { "(short)0b0110000101000101", Short.parseShort( "0110000101000101", 2 ) },
- { "0b101", Integer.parseInt( "101", 2 ) },
- { "0B101", Integer.parseInt( "101", 2 ) },
- { "0b00010000101000101101000010100010110100001010001011010000101000101L",
- Long.parseLong( "00010000101000101101000010100010110100001010001011010000101000101", 2 ) },
-
- // Underscores in Numeric Literals (added to JDK7)
- { "1234_5678", Integer.parseInt( "12345678" ) },
- { "1234_5678_9012_3456L", Long.valueOf( "1234567890123456" ) },
- { "0xFF_EC_DE_5EL", Long.valueOf( "FFECDE5E", 16 ) },
- { "0x7fff_ffff_ffff_ffffL", Long.valueOf( "7fffffffffffffff", 16 ) },
- { "(byte) 0b0010_0101 ", Byte.parseByte( "00100101", 2 ) }, { "5_______2", Integer.parseInt( "52" ) },
- { "0x5_2", Integer.parseInt( "52", 16 ) }, { "0_52", Integer.parseInt( "52", 8 ) },
- { "05_2", Integer.parseInt( "52", 8 ) }, } );
- }
-
- @Test
- public void testExpression()
- {
- assertAnnotationExpression( expression, parsedResult );
- }
-
- protected void assertAnnotationExpression( String expression, Object expected )
- {
- String source = "@Annotation(\n" + expression + "\n) class Foo {}";
- try
- {
- builder.addSource( new StringReader( source ) );
- assertAnnotationValue( expected );
- }
- catch ( ParseException pe )
- {
- fail( pe.getMessage() + "Failed to parse '" + source + "'" );
- }
- }
-
- protected void assertAnnotationValue( Object expected )
- {
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- AnnotationValue value = annotation.getProperty( "value" );
- Object v = value.accept( new EvaluatingVisitor() );
- assertEquals( "Value", expected, v );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java b/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java
deleted file mode 100644
index 130a459..0000000
--- a/src/test/java/com/thoughtworks/qdox/AnnotationsModelTest.java
+++ /dev/null
@@ -1,252 +0,0 @@
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.expression.Add;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.AnnotationValueList;
-import com.thoughtworks.qdox.model.expression.Constant;
-import com.thoughtworks.qdox.model.expression.FieldRef;
-import com.thoughtworks.qdox.model.expression.TypeRef;
-
-public class AnnotationsModelTest
- extends TestCase
-{
-
- private JavaProjectBuilder builder;
-
- protected void setUp()
- throws Exception
- {
- builder = new JavaProjectBuilder();
- //builder.setDebugLexer( true );
- //builder.setDebugParser( true );
- }
-
- protected JavaAnnotation checkClassAnnotation( String source )
- {
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- return annotation;
- }
-
- public void testMarkerAnnotation()
- {
- checkClassAnnotation( "@Annotation\nclass Foo {}" );
- }
-
- public void testEmptyAnnotation()
- {
- checkClassAnnotation( "@Annotation()\nclass Foo {}" );
- }
-
- public void testAnnotationAnnotation()
- {
- checkClassAnnotation( "@Annotation(@NestedAnnotation)\nclass Foo {}" );
- }
-
- public void testConstAnnotation()
- {
- checkClassAnnotation( "@Annotation(1)\nclass Foo {}" );
- }
-
- public void testAnnotationConstants()
- {
- String source =
- "@Annotation( f = 1.0, d = 1.0d, i = 1, ix = 0x1, l = 1L, lx = 0x1L, c = 'c', s = \"string\" )\nclass Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 8, annotation.getNamedParameterMap().size() );
-
- Constant f = (Constant) annotation.getProperty( "f" );
- assertEquals( "f", new Float( 1 ), f.getValue() );
-
- Constant d = (Constant) annotation.getProperty( "d" );
- assertEquals( "d", new Double( 1 ), d.getValue() );
-
- Constant i = (Constant) annotation.getProperty( "i" );
- assertEquals( "i", new Integer( 1 ), i.getValue() );
-
- Constant ix = (Constant) annotation.getProperty( "ix" );
- assertEquals( "ix", new Integer( 1 ), ix.getValue() );
-
- Constant l = (Constant) annotation.getProperty( "l" );
- assertEquals( "l", new Long( 1 ), l.getValue() );
-
- Constant lx = (Constant) annotation.getProperty( "lx" );
- assertEquals( "lx", new Long( 1 ), lx.getValue() );
-
- Constant c = (Constant) annotation.getProperty( "c" );
- assertEquals( "c", new Character( 'c' ), c.getValue() );
-
- Constant s = (Constant) annotation.getProperty( "s" );
- assertEquals( "s", "string", s.getValue() );
- }
-
- public void testAnnotationConstantsControlChars()
- {
- String source =
- "@Annotation( s1 = \"a\\nb\", s2 = \"a\\nb\", s3 = \"a\\rb\", s4 = \"a\\tb\", s5 = \"a\\u0009b\" ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 5, annotation.getPropertyMap().size() );
-
- Constant s1 = (Constant) annotation.getProperty( "s1" );
- assertEquals( "s1", "a\nb", s1.getValue() );
-
- Constant s2 = (Constant) annotation.getProperty( "s2" );
- assertEquals( "s2", "a\nb", s2.getValue() );
-
- Constant s3 = (Constant) annotation.getProperty( "s3" );
- assertEquals( "s3", "a\rb", s3.getValue() );
-
- Constant s4 = (Constant) annotation.getProperty( "s4" );
- assertEquals( "s4", "a\tb", s4.getValue() );
-
- Constant s5 = (Constant) annotation.getProperty( "s5" );
- assertEquals( "s5", "a\u0009b", s5.getValue() );
- }
-
- public void testNestedAnnotation()
- {
- String source = "@Annotation( { @Inner(1), @Inner(2) } ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- AnnotationValueList list = (AnnotationValueList) annotation.getProperty( "value" );
- assertEquals( "Inner Annotations", 2, list.getValueList().size() );
-
- for ( ListIterator<AnnotationValue> i = list.getValueList().listIterator(); i.hasNext(); )
- {
- JavaAnnotation inner = (JavaAnnotation) i.next();
- assertEquals( "Inner " + i.previousIndex(), "Inner", inner.getType().getValue() );
- }
- }
-
- public void testExpressionAnnotation1()
- {
- String source = "@Annotation( 1 + 1 ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- Add add = (Add) annotation.getProperty( "value" );
- assertEquals( "Left", new Integer( 1 ), ( (Constant) add.getLeft() ).getValue() );
- assertEquals( "Right", new Integer( 1 ), ( (Constant) add.getRight() ).getValue() );
- }
-
- public void testExpressionAnnotation2()
- {
- String source = "@Annotation( \"value = \" + 1 ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- Add add = (Add) annotation.getProperty( "value" );
- assertEquals( "Left", "value = ", ( (Constant) add.getLeft() ).getValue() );
- assertEquals( "Right", new Integer( 1 ), ( (Constant) add.getRight() ).getValue() );
- }
-
- public void testFieldRefAnnotation()
- {
- String source = "@Annotation( java.lang.Math.E ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- FieldRef value = (FieldRef) annotation.getProperty( "value" );
- assertEquals( "type", "double", value.getField().getType().getValue() );
- assertEquals( "class part", "java.lang.Math", value.getClassPart() );
- assertEquals( "field part", "E", value.getFieldPart() );
- }
-
- public void testPrimitiveClassAnnotation()
- {
- String source = "@Annotation( int.class ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- Object value = annotation.getProperty( "value" );
- TypeRef ref = (TypeRef) value;
- assertEquals( "value", "int", ref.getType().getValue() );
- }
-
- public void testClassAnnotation()
- {
- String source = "@Annotation( java.util.Set.class ) class Foo {}";
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Annotations", 1, clazz.getAnnotations().size() );
- JavaAnnotation annotation = clazz.getAnnotations().get( 0 );
- assertEquals( "Annotation name", "Annotation", annotation.getType().getFullyQualifiedName() );
- assertEquals( "Properties", 1, annotation.getPropertyMap().size() );
-
- Object value = annotation.getProperty( "value" );
- TypeRef ref = (TypeRef) value;
- assertEquals( "value", "java.util.Set", ref.getType().getValue() );
- }
-
- // from Qdox-98
- public void testPackageWithAnnotation()
- throws Exception
- {
- String source =
- "@javax.xml.bind.annotation.XmlSchema(namespace = \"http://docs.oasis-open.org/wsn/br-2\")\n"
- + "package org.oasis_open.docs.wsn.br_2;\n" + "public class Foo {}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- JavaPackage jPackage = cls.getPackage();
- assertEquals( "org.oasis_open.docs.wsn.br_2", jPackage.getName() );
- assertEquals( "javax.xml.bind.annotation.XmlSchema", jPackage.getAnnotations().get( 0 ).getType().getValue() );
- assertEquals( 2, jPackage.getLineNumber() );
-
- }
-
- // http://jira.codehaus.org/browse/QDOX-135
- public void testAnnotationInMethodParamList()
- {
- String source = "" + "class Foo {\n"
- // + " @X()\n" - does not affect test.
- + " public String xyz(@Y(1) int blah) {\n" + " }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- assertEquals( "Foo", clazz.getName() );
- JavaMethod mth = clazz.getMethods().get( 0 );
- JavaAnnotation paramAnn = mth.getParameterByName( "blah" ).getAnnotations().get( 0 );
- assertEquals( "@Y(value=1)", paramAnn.toString() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java b/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
deleted file mode 100644
index 3427880..0000000
--- a/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.expression.FieldRef;
-
-public class AnnotationsTest
- extends TestCase
-{
-
- private JavaProjectBuilder builder;
-
- public AnnotationsTest()
- {
- builder = new JavaProjectBuilder();
- // builder.setDebugLexer( true );
- // builder.setDebugParser( true );
- }
-
- public void testShouldIgnoreSimpleClassAnnotation()
- {
- String source = "" + "@Fnord\n" + "public interface Foo extends Bar {}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- public void testShouldIgnoreSimpleMethodAnnotation()
- {
- String source = "" + "public class X {\n" + " @Fnord public void snort() {}\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- JavaClass fooClass = builder.getClassByName( "X" );
- assertEquals( "X", fooClass.getName() );
- assertEquals( 1, fooClass.getMethods().size() );
- assertEquals( "snort", fooClass.getMethods().get( 0 ).getName() );
- }
-
- public void testShouldIgnoreMethodParameterAnnotation()
- {
- String source =
- "" + "public class X {\n" + " String field = new String( \"hey\" );\n"
- + " public void setX(@name String x) {}\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- JavaClass fooClass = builder.getClassByName( "X" );
- assertEquals( "X", fooClass.getName() );
- assertEquals( 1, fooClass.getMethods().size() );
- assertEquals( "setX", fooClass.getMethods().get( 0 ).getName() );
- }
-
- public void testShouldIgnoreComplexClassAnnotations()
- {
- String source =
- "" + "@Fnord(pi = 3.14, e = m*c*c)\n" + "public interface Foo extends Bar {\n"
- + " @Fnord(pi = 3.14, e = m*c*c)\n" + " void doStuff() { }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- public void testShouldIgnoreSingleMemberClassAnnotations()
- {
- String source =
- "" + "@Fnord(\"xyz\")\n" + "@Blat(Math.MAXINT)\n" + "public interface Foo extends Bar {\n"
- + " @Fnord(\"xyz\")\n" + " @Blat(Math.MAXINT)\n" + " void doStuff() { }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- public void testShouldIgnoreArrayValuedSingleMemberClassAnnotations()
- {
- String source =
- "/** @hey=\"yo\" someval = \"yep\" */"
- + "@ Endorsers({(\"Children\"), \"Unscrupulous dentists\"})\n" + "public class Lollipop {\n"
- + " @Cheese( hey=@ano({\"Edam\", \"Gruyere\", 2}), t=5.5f, c=4)\n" + " void doStuff() { }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- assertNotNull( builder.getClassByName( "Lollipop" ) );
- }
-
- public void testShouldIgnoreComplexSingleMemberClassAnnotations()
- {
- String source =
- ""
- + "@Author(@Name(first = \"Joe\", last = true))\n" // I won't take it personally! ;) -joe
- + "public class BitTwiddle {\n" + " @Author(@Name(first = \'c\', last = 2.5e3f))\n"
- + " void doStuff() { }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- assertNotNull( builder.getClassByName( "BitTwiddle" ) );
- assertNotNull( builder.getClassByName( "BitTwiddle" ).getAnnotations().get( 0 ).getNamedParameter( "value" ) );
- assertEquals( "Author",
- builder.getClassByName( "BitTwiddle" ).getMethodBySignature( "doStuff", Collections.EMPTY_LIST ).getAnnotations().get( 0 ).getType().getValue() );
- }
-
- public void testShouldIgnoreAnnotationDeclaration()
- {
- String source =
- "package org.jabba;\n" + "@MyAnno\n" + "public @interface Note {\n" + " String text;\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( 1, builder.getClasses().size() );
- }
-
- public void testShouldIgnoreAnnotationWithClassType()
- {
- String source = "" + "@Fnord(String.class)\n" + "public interface Foo extends Bar {}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- // from QDOX-97
- public void testShouldIgnoreAttributeAnnotation()
- {
- String source = "" + "public interface Foo {\n" + " String echo(@WebParam java.lang.String msg);\n" + "}\n";
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- // from QDOX-101
- public void testShouldNotChokeOnDoubleAttributeAnnotationAndGenerics()
- {
- String source =
- "" + "public class Person {\n" + " @XmlJavaTypeAdapter(CollapsedStringAdapter.class)\n" + " @XmlID\n"
- + " protected String name;\n" + " public List<String> getAddress() {\n"
- + " return address;\n" + " }" + "}\n";
- builder.addSource( new StringReader( source ) );
- assertEquals( "Person", builder.getClassByName( "Person" ).getName() );
- }
-
- // from QDOX-108
- public void testFQNAnnotations()
- {
- String source = "" + "@com.mycompany.Fnord(a=1)\n" + "public interface Foo extends Bar {}\n";
-
- builder.addSource( new StringReader( source ) );
- assertEquals( "Foo", builder.getClassByName( "Foo" ).getName() );
- }
-
- // from QDOX-113
- public void testAnnotationWithParameter()
- throws Exception
- {
- String source =
- "public class Foo{\n" + "@Editor(FileEditor.class)\n"
- + "public void setFile(File file) { this.file = file; }" + "}";
- builder.addSource( new StringReader( source ) );
- }
-
- // from QDOX-128
- public void testQuotedStringAnnotation()
- throws Exception
- {
- String source = "@Anno(run = \"1.0\")" + "public interface Foo {}";
- builder.addSource( new StringReader( source ) );
- assertEquals( "\"1.0\"",
- builder.getClassByName( "Foo" ).getAnnotations().get( 0 ).getProperty( "run" ).getParameterValue() );
- }
-
- // from QDOX-135
- public void testAnnotationInMethodParamList()
- {
- String source =
- "" + "class Foo {\n" + " @X()\n" + " public String xyz(@Y(1) int blah) {\n" + " }\n" + "}\n";
-
- builder.addSource( new StringReader( source ) );
- JavaClass clazz = builder.getClassByName( "Foo" );
- JavaMethod mth = clazz.getMethods().get( 0 );
- assertEquals( "Foo", clazz.getName() );
- assertEquals( "X", mth.getAnnotations().get( 0 ).getType().getName() );
- }
-
- // from QDOX-142
- public void testEmptyParameterListAnnotation()
- throws Exception
- {
- String source = "@MyAnnotation()\n" + "public class MyClass {}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- assertEquals( "MyAnnotation", cls.getAnnotations().get( 0 ).getType().getValue() );
- }
-
- public void testMethodAnnotationBeforeComment()
- throws Exception
- {
- String source =
- "class Foo {\n" + "@Override\n" + "/**\n" + " * " + " */"
- + " public boolean isPostback() { return true;}\n" + "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- assertEquals( "Override", cls.getMethods().get( 0 ).getAnnotations().get( 0 ).getType().getValue() );
- assertEquals( "java.lang.Override",
- cls.getMethods().get( 0 ).getAnnotations().get( 0 ).getType().getFullyQualifiedName() );
- }
-
- public void testEnumsWithAnnotations()
- throws Exception
- {
- String source =
- "class Foo {\n" + " public enum BasicType {\n" + " @XmlEnumValue(\"text\")\n" + " TEXT(\"text\"),\n" + ""
- + " @XmlEnumValue(\"value\")\n" + " VALUE(\"value\") }\n" + "}";
- builder.addSource( new StringReader( source ) );
- }
-
- public void testParameterAnnotations()
- throws Exception
- {
- String source =
- "class Foo {\n"
- + " @NativeAccessible\n"
- + " static void get_tmp_dir( String targetfilename, @ParamInfo( direction = ParamInfo.Direction.OUT ) byte[] tmpDirOutput ) throws IOException {}\n"
- + "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- JavaMethod jMethod = cls.getMethods().get( 0 );
- assertEquals( "NativeAccessible", jMethod.getAnnotations().get( 0 ).getType().getValue() );
- JavaAnnotation annotation = jMethod.getParameters().get( 1 ).getAnnotations().get( 0 );
- assertEquals( "ParamInfo", annotation.getType().getValue() );
- assertEquals( "ParamInfo.Direction.OUT", annotation.getProperty( "direction" ).getParameterValue() );
- }
-
- public void testFieldRefAnnotation()
- throws Exception
- {
- String source =
- "public class Foo {\n" + " final String s = \"unchecked\";\n" + " @SuppressWarnings( s )\n"
- + " public void testNothing() { }\n " + "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get( 0 );
- JavaMethod method = cls.getMethods().get( 0 );
- FieldRef suppressWarnings = (FieldRef) method.getAnnotations().get( 0 ).getProperty( "value" );
- assertEquals( cls.getFields().get( 0 ), suppressWarnings.getField() );
- }
-
- public void testDoubleEscapedString()
- throws Exception
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- String source = "public class Foo {\n" + "@SuppressWarnings({\"abc\\\\d\"})\n" + "private void bar() { } }";
- builder.addSource( new StringReader( source ) );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/ClassResolutionTest.java b/src/test/java/com/thoughtworks/qdox/ClassResolutionTest.java
deleted file mode 100644
index 606c624..0000000
--- a/src/test/java/com/thoughtworks/qdox/ClassResolutionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-
-public class ClassResolutionTest
- extends TestCase
-{
-
- public void testNestedClassesResolvedAcrossPackageBoundaries()
- {
-
- // input sources
- String source1 =
- "" + "package package1;" + "public class Class1 {" + " public static final class NestedClass {}" + "}";
-
- String source2 =
- "" + "package package2;" + "import package1.Class1;" + "public class Class2 {"
- + " public void doStuff(Class1.NestedClass arg) {}" + "}";
-
- // parse
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSource( new StringReader( source1 ) );
- builder.addSource( new StringReader( source2 ) );
-
- // find the parameter
- JavaClass class2 = builder.getClassByName( "package2.Class2" );
- JavaMethod method = class2.getMethods().get( 0 );
- JavaParameter parameter = method.getParameters().get( 0 );
- JavaType type = parameter.getType();
-
- // verify
- assertEquals( "Should include fully qualified name", "package1.Class1$NestedClass",
- type.getFullyQualifiedName() );
- }
-
- public void testSurvivesStaticImports()
- {
-
- // input sources
- String source =
- "" + "package package2;" + "import static package1.Class1.VALUE;" + "public class Class2 {"
- + " public void doStuff(String arg) {}" + "}";
-
- // parse
- JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSource( new StringReader( source ) );
-
- // find the parameter
- JavaClass class2 = builder.getClassByName( "package2.Class2" );
- assertNotNull( class2 );
- }
-
- public void testAnonymousClass()
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
-
- String source =
- "" + "public class AnimatedAlgorithm {\n"
- + " private SelectionListener mySelectionListener = new SelectionListenerAdapter() {\n"
- + " public void selectionEvent() {\n"
- + " for (int i = 0; i < recalcers.size(); i++) {\n" + " int something = 5;"
- + " }\n" + " }\n" + " };\n" + "}";
-
- builder.addSource( new StringReader( source ) );
- }
-
- // from QDOX-86
- public void testInnerClassInMethod()
- throws Exception
- {
- JavaProjectBuilder builder = new JavaProjectBuilder();
- String source =
- "package some.pack;\n" + "class Test {\n" + "void some(Inner.Inner2 a) {}\n" + "static interface Inner {\n"
- + "static interface Inner2 { }\n" + "}\n" + "}";
- builder.addSource( new StringReader( source ) );
- JavaMethod method = builder.getClassByName( "some.pack.Test" ).getMethods().get( 0 );
- JavaParameter parameter = method.getParameters().get( 0 );
- assertEquals( "some.pack.Test$Inner$Inner2", parameter.getJavaClass().getFullyQualifiedName() );
- assertEquals( "some.pack.Test$Inner$Inner2", parameter.getType().getFullyQualifiedName() );
- assertEquals( "some.pack.Test$Inner$Inner2", parameter.getFullyQualifiedName() );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/EmptyTestClasses.java b/src/test/java/com/thoughtworks/qdox/EmptyTestClasses.java
deleted file mode 100644
index 582b997..0000000
--- a/src/test/java/com/thoughtworks/qdox/EmptyTestClasses.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.thoughtworks.qdox;
-
-public class EmptyTestClasses {
-
-}
-class Spoon {}
-class Fork {}
-class Knife {}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/FieldsTest.java b/src/test/java/com/thoughtworks/qdox/FieldsTest.java
deleted file mode 100644
index 2054c68..0000000
--- a/src/test/java/com/thoughtworks/qdox/FieldsTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * $Id: FieldsTest.java 16 2008-02-20 17:57:08Z louis $
- */
-
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-
-public class FieldsTest extends TestCase
-{
- private JavaProjectBuilder builder = new JavaProjectBuilder();
-
- public void testAssignmentViaBitShift() {
- String source = ""
- + "public class X {\n"
- + " Object b = new Object();\n"
- + " int a = 1 << 30;\n"
- + "}\n";
-
- builder.addSource(new StringReader(source));
- JavaClass fooClass = builder.getClassByName("X");
- assertEquals("X", fooClass.getName());
- assertEquals("a", fooClass.getFieldByName("a").getName());
- assertEquals("1 << 30", fooClass.getFieldByName("a").getInitializationExpression().trim());
- }
-
- // from QDOX-114
- public void testNewArrayWithBitShift() {
- String source = ""
- + "public class X {\n"
- + " int a[] = new int[1 << 16];\n"
- + "}\n";
-
- builder.addSource(new StringReader(source));
- JavaClass fooClass = builder.getClassByName("X");
- assertEquals("X", fooClass.getName());
- assertEquals("a", fooClass.getFieldByName("a").getName());
- assertEquals("new int[1 << 16]", fooClass.getFieldByName("a").getInitializationExpression().trim());
- }
-
- //from QDOX-127
- //fails because returned value is " null"
- //which is already better then mentioned in the issue
- public void testCommentBeforeInitialization() throws Exception {
- String source = "public class X{\n" +
- "// Attributes\n" +
- "\n" +
- "/**" +
- "* Some decription" +
- "*/" +
- "private String uDI = null;\n" +
- "}";
-
- JavaClass cls = builder.addSource(new StringReader(source)).getClasses().get(0);
- JavaField field = cls.getFields().get(0);
- assertEquals("null", field.getInitializationExpression());
- }
-
- public void testTwoDocletTags() throws Exception {
- String source = "public class Foo {" +
- " /**\r\n" +
- " * @parameter implementation=source2.sub.MyBla\r\n" +
- " * @required\r\n" +
- " */\r\n" +
- " private Bla bla;" +
- "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get(0);
- JavaField field = cls.getFields().get(0);
- assertEquals( "", field.getComment() );
- assertEquals( 2, field.getTags().size() );
- }
-
- public void testCommentAndTwoDocletTags() throws Exception {
- String source = "public class Foo {" +
- " /**\r\n" +
- " * Being Lazy Always\r\n" +
- " * @parameter implementation=source2.sub.MyBla\r\n" +
- " * @required\r\n" +
- " */\r\n" +
- " private Bla bla;" +
- "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get(0);
- JavaField field = cls.getFields().get(0);
- assertEquals( "Being Lazy Always", field.getComment() );
- assertEquals( 2, field.getTags().size() );
- }
-
- public void testMultiCommentAndTwoDocletTags() throws Exception {
- String source = "public class Foo {" +
- " /**\r\n" +
- " * Being\r\n" +
- " * Lazy\r\n" +
- " * Always\r\n" +
- " * \r\n" +
- " * @parameter implementation=source2.sub.MyBla\r\n" +
- " * @required\r\n" +
- " */\r\n" +
- " private Bla bla;" +
- "}";
- JavaClass cls = builder.addSource( new StringReader( source ) ).getClasses().get(0);
- JavaField field = cls.getFields().get(0);
- assertEquals( "Being\r\nLazy\r\nAlways", field.getComment() );
- assertEquals( 2, field.getTags().size() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/JSR14Test.java b/src/test/java/com/thoughtworks/qdox/JSR14Test.java
deleted file mode 100644
index 54465a1..0000000
--- a/src/test/java/com/thoughtworks/qdox/JSR14Test.java
+++ /dev/null
@@ -1,509 +0,0 @@
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaGenericDeclaration;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.JavaTypeVariable;
-/**
- * QDOX-54 Support for retrieval of generic type information (JSR 14)
- *
- * Some core-classes have been changed, but most interfaces are kept the same.
- * Most important is the method Type.getGenericValue(), which does exactly what it says.
- * The WildcardType is added as a subclass of Type. This way we can easily define these types of Types
- *
- *
- * @author Robert Scholte
- *
- */
-public class JSR14Test extends TestCase {
-
- private JavaProjectBuilder builder = new JavaProjectBuilder();
-
- public void testSimpleSingleParameterizedTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.List<String> getList();");
- assertEquals("java.util.List", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.String>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getReturns().getValue());
- assertEquals("java.util.List<String>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testSimpleWildcardTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.List<?> getList();");
- assertEquals("java.util.List<?>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testSimpleExtendsWildcardTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.List<? extends Number> getList();");
- assertEquals("java.util.List", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.List<? extends java.lang.Number>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getReturns().getValue());
- assertEquals("java.util.List<? extends Number>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testSimpleSuperWildcardTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.List<? super Integer> getList();");
- assertEquals("java.util.List", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.List<? super java.lang.Integer>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getReturns().getValue());
- assertEquals("java.util.List<? super Integer>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testSimpleMultiParameterizedTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.Map<String, Object> getMap();");
- assertEquals("java.util.Map", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.Map", javaMethod.getReturns().getValue());
- assertEquals("java.util.Map<String,Object>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testComplexSingleParameterizedTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.List<java.util.Set<String>> getList();");
- assertEquals("java.util.List", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getReturns().getValue());
- assertEquals("java.util.List<java.util.Set<String>>", javaMethod.getReturns().getGenericValue());
- }
-
- public void testComplexMultiParameterizedTypeMethod() throws Exception {
- JavaMethod javaMethod = buildMethod("java.util.Map<String, java.util.Iterator<Number>> getMap();");
- assertEquals("java.util.Map", javaMethod.getReturns().getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.util.Iterator<java.lang.Number>>", javaMethod.getReturns().getGenericFullyQualifiedName());
- assertEquals("java.util.Map", javaMethod.getReturns().getValue());
- assertEquals("java.util.Map<String,java.util.Iterator<Number>>", javaMethod.getReturns().getGenericValue());
- }
-
- private JavaMethod buildMethod(String methodSource) {
- String source = "interface Something { " + methodSource + " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
- return javaMethod;
- }
-
- public void testSimpleSingleParameterizedTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<String> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.String>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaField.getType().getValue());
- assertEquals("java.util.List<String>", javaField.getType().getGenericValue());
- }
-
- public void testSimpleMultiParameterizedTypeField() {
- String source = "public class Something { " +
- "public java.util.Map<String, Object> aMap;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aMap");
- assertEquals("java.util.Map", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.Map", javaField.getType().getValue());
- assertEquals("java.util.Map<String,Object>", javaField.getType().getGenericValue());
- }
-
- public void testSimpleWildcardTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<?> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List<?>", javaField.getType().getGenericValue());
- }
-
- public void testSimpleExtendsWildcardTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<? extends Number> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.List<? extends java.lang.Number>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaField.getType().getValue());
- assertEquals("java.util.List<? extends Number>", javaField.getType().getGenericValue());
- }
-
- public void testSimpleSuperWildcardTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<? super Integer> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.List<? super java.lang.Integer>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaField.getType().getValue());
- assertEquals("java.util.List<? super Integer>", javaField.getType().getGenericValue());
- }
-
- public void testComplexSingleParameterizedTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<java.util.Set<String>> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaField.getType().getValue());
- assertEquals("java.util.List<java.util.Set<String>>", javaField.getType().getGenericValue());
- }
-
- public void testComplexMultiParameterizedTypeField() throws Exception {
- String source = "public class Something { " +
- "public java.util.List<java.util.Set<String>> aList;" +
- " }";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaField javaField = javaClass.getFieldByName("aList");
- assertEquals("java.util.List", javaField.getType().getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaField.getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaField.getType().getValue());
- assertEquals("java.util.List<java.util.Set<String>>", javaField.getType().getGenericValue());
- }
-
- public void testSimpleSingleParameterizedTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setList(java.util.List<String> aList);");
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.String>", javaMethod.getParameterByName("aList").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getValue());
- assertEquals("java.util.List<String>", javaMethod.getParameterByName("aList").getType().getGenericValue());
- }
-
- public void testSimpleWildcardTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setList(java.util.List<?> aList);");
- assertEquals("java.util.List<?>", javaMethod.getParameterByName("aList").getType().getGenericValue());
- }
-
- public void testSimpleExtendsWildcardTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setList(java.util.List<? extends Number> aList);");
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getFullyQualifiedName());
- assertEquals("java.util.List<? extends java.lang.Number>", javaMethod.getParameterByName("aList").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getValue());
- assertEquals("java.util.List<? extends Number>", javaMethod.getParameterByName("aList").getType().getGenericValue());
- }
-
- public void testSimpleSuperWildcardTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setList(java.util.List<? super Integer> aList);");
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getFullyQualifiedName());
- assertEquals("java.util.List<? super java.lang.Integer>", javaMethod.getParameterByName("aList").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getValue());
- assertEquals("java.util.List<? super Integer>", javaMethod.getParameterByName("aList").getType().getGenericValue());
- }
-
- public void testSimpleMultiParameterizedTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setMap(java.util.Map<String, Object> aMap);");
- assertEquals("java.util.Map", javaMethod.getParameterByName("aMap").getType().getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.lang.Object>", javaMethod.getParameterByName("aMap").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.Map", javaMethod.getParameterByName("aMap").getType().getValue());
- assertEquals("java.util.Map<String,Object>", javaMethod.getParameterByName("aMap").getType().getGenericValue());
- }
-
- public void testComplexSingleParameterizedTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setList(java.util.List<java.util.Set<String>> aList);");
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", javaMethod.getParameterByName("aList").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.List", javaMethod.getParameterByName("aList").getType().getValue());
- assertEquals("java.util.List<java.util.Set<String>>", javaMethod.getParameterByName("aList").getType().getGenericValue());
- }
-
- public void testComplexMultiParameterizedTypeParameter() throws Exception {
- JavaMethod javaMethod = buildMethod("void setMap(java.util.Map<String, java.util.Iterator<Number>> aMap);");
- assertEquals("java.util.Map", javaMethod.getParameterByName("aMap").getType().getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.util.Iterator<java.lang.Number>>", javaMethod.getParameterByName("aMap").getType().getGenericFullyQualifiedName());
- assertEquals("java.util.Map", javaMethod.getParameterByName("aMap").getType().getValue());
- assertEquals("java.util.Map<String,java.util.Iterator<Number>>", javaMethod.getParameterByName("aMap").getType().getGenericValue());
- }
-
- public void testSimpleSingleParameterizedTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<String> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List", superClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.String>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", superClass.getValue());
- assertEquals("java.util.List<String>", superClass.getGenericValue());
- }
-
- public void testSimpleMultiParameterizedTypeClassExtends() {
- String source = "public class Something extends java.util.Map<String, Object> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.Map", superClass.getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.lang.Object>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.Map", superClass.getValue());
- assertEquals("java.util.Map<String,Object>", superClass.getGenericValue());
- }
-
- public void testSimpleWildcardTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<?>{}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List<?>", superClass.getGenericValue());
- }
-
- public void testSimpleExtendsWildcardTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<? extends Number> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List", superClass.getFullyQualifiedName());
- assertEquals("java.util.List<? extends java.lang.Number>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", superClass.getValue());
- assertEquals("java.util.List<? extends Number>", superClass.getGenericValue());
- }
-
- public void testSimpleSuperWildcardTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<? super Integer> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List", superClass.getFullyQualifiedName());
- assertEquals("java.util.List<? super java.lang.Integer>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", superClass.getValue());
- assertEquals("java.util.List<? super Integer>", superClass.getGenericValue());
- }
-
- public void testComplexSingleParameterizedTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<java.util.Set<String>> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List", superClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", superClass.getValue());
- assertEquals("java.util.List<java.util.Set<String>>", superClass.getGenericValue());
- }
-
- public void testComplexMultiParameterizedTypeClassExtends() throws Exception {
- String source = "public class Something extends java.util.List<java.util.Set<String>> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType superClass = javaClass.getSuperClass();
- assertEquals("java.util.List", superClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", superClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", superClass.getValue());
- assertEquals("java.util.List<java.util.Set<String>>", superClass.getGenericValue());
- }
-
- public void testSimpleSingleParameterizedTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<String> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.String>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", implementsClass.getValue());
- assertEquals("java.util.List<String>", implementsClass.getGenericValue());
- }
-
- public void testSimpleMultiParameterizedTypeClassImplements() {
- String source = "public class Something implements java.util.Map<String, Object> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.Map", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.Map<java.lang.String,java.lang.Object>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.Map", implementsClass.getValue());
- assertEquals("java.util.Map<String,Object>", implementsClass.getGenericValue());
- }
-
- public void testSimpleWildcardTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<?>{}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List<?>", implementsClass.getGenericValue());
- }
-
- public void testSimpleExtendsWildcardTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<? extends Number> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.List<? extends java.lang.Number>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", implementsClass.getValue());
- assertEquals("java.util.List<? extends Number>", implementsClass.getGenericValue());
- }
-
- public void testSimpleSuperWildcardTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<? super Integer> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.List<? super java.lang.Integer>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", implementsClass.getValue());
- assertEquals("java.util.List<? super Integer>", implementsClass.getGenericValue());
- }
-
- public void testComplexSingleParameterizedTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<java.util.Set<String>> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", implementsClass.getValue());
- assertEquals("java.util.List<java.util.Set<String>>", implementsClass.getGenericValue());
- }
-
- public void testComplexMultiParameterizedTypeClassImplements() throws Exception {
- String source = "public class Something implements java.util.List<java.util.Set<String>> {}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaType implementsClass = javaClass.getImplements().get(0);
- assertEquals("java.util.List", implementsClass.getFullyQualifiedName());
- assertEquals("java.util.List<java.util.Set<java.lang.String>>", implementsClass.getGenericFullyQualifiedName());
- assertEquals("java.util.List", implementsClass.getValue());
- assertEquals("java.util.List<java.util.Set<String>>", implementsClass.getGenericValue());
- }
-
- public void testSimpleTypeVariable() throws Exception {
- String source = "public class Something {\n" +
- " public <T extends StringBuffer> void doStuff(T param) {}\n" +
- "}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaMethod javaMethod = javaSource.getClasses().get(0).getMethods().get(0);
- assertEquals( 1, javaMethod.getTypeParameters().size());
- JavaTypeVariable<JavaGenericDeclaration> typeVariable = javaMethod.getTypeParameters().get(0);
- assertEquals( "T", typeVariable.getName() );
- assertEquals( "T", typeVariable.getFullyQualifiedName());
- assertEquals( "<T extends java.lang.StringBuffer>", typeVariable.getGenericFullyQualifiedName());
- assertEquals( "T", typeVariable.getValue());
- assertEquals( "T extends StringBuffer", typeVariable.getGenericValue());
- }
-
- public void testComplexTypeVariable() throws Exception {
- String source = "class Collections {\n" +
- "public static <T, S extends T> void copy(List<T> dest, List<S> src){}\n" +
- "}";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaMethod javaMethod = javaSource.getClasses().get(0).getMethods().get(0);
- JavaTypeVariable<JavaGenericDeclaration> typeVariable0 = javaMethod.getTypeParameters().get(0);
- assertEquals("T", typeVariable0.getName());
- assertEquals("T", typeVariable0.getFullyQualifiedName());
- assertEquals("<T>", typeVariable0.getGenericFullyQualifiedName());
- assertEquals("T", typeVariable0.getValue());
- assertEquals("T", typeVariable0.getGenericValue());
-
- JavaTypeVariable<JavaGenericDeclaration> typeVariable1 = javaMethod.getTypeParameters().get(1);
- assertEquals("S", typeVariable1.getName());
- assertEquals("S", typeVariable1.getFullyQualifiedName());
- assertEquals("<S extends T>", typeVariable1.getGenericFullyQualifiedName());
- assertEquals("S", typeVariable1.getValue());
- assertEquals("S extends T", typeVariable1.getGenericValue());
- }
-
- public void testComplexTypeVariableMultipleBounds() throws Exception {
- String source = "class Collections\n" +
- "public static <T extends Object & Comparable<? super T>>\n" +
- "T max(Collection<? extends T> coll) {\n" +
- "return null;}\n";
-
- }
-
- //for qdox-150
- // second assert is based on java's Method.toString()
- // http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#toString()
- // 3rd and 4th are resolved Types, based on <T extends StringBuffer> in method
- public void testGenericMethodDeclarationSingleParameter() throws Exception {
- String source = "package com.thoughtworks.qdox;" +
- "import java.util.*;\n" +
- "public class TestQDOX150 {\n" +
- " public <T extends StringBuffer> List<StringBuffer> myMethod( T request ) throws Exception {\n" +
- " return null;\n" +
- " }\n" +
- "}\n";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
- JavaParameter paramType = javaMethod.getParameters().get(0);
- JavaType returnType = javaMethod.getReturns();
- assertEquals("myMethod(request)", javaMethod.getCallSignature());
- assertEquals("public java.util.List com.thoughtworks.qdox.TestQDOX150.myMethod(java.lang.StringBuffer) throws java.lang.Exception", javaMethod.toString());
- assertEquals("StringBuffer", paramType.getResolvedValue());
- assertEquals("java.lang.StringBuffer", paramType.getResolvedFullyQualifiedName());
- assertEquals("StringBuffer", paramType.getResolvedGenericValue());
- assertEquals("java.util.List", returnType.getFullyQualifiedName());
- assertEquals("java.util.List<java.lang.StringBuffer>", returnType.getGenericFullyQualifiedName());
- assertEquals("List", returnType.getValue());
- assertEquals("List<StringBuffer>", returnType.getGenericValue());
-
- }
-
- public void testGenericMethodDeclarationMultipleParameters() throws Exception {
- String source = "package com.thoughtworks.qdox;" +
- "import java.util.*;\n" +
- "public class TestQDOX150 {\n" +
- " public <T extends StringBuffer> List<StringBuffer> myMethod( T request, List<T> list ) throws Exception {\n" +
- " return null;\n" +
- " }\n" +
- "}\n";
- JavaSource javaSource = builder.addSource(new StringReader(source));
- JavaClass javaClass = javaSource.getClasses().get(0);
- JavaMethod javaMethod = javaClass.getMethods().get(0);
- JavaParameter paramType = javaMethod.getParameters().get(1);
- assertEquals("myMethod(request, list)", javaMethod.getCallSignature());
- assertEquals("public java.util.List com.thoughtworks.qdox.TestQDOX150.myMethod(java.lang.StringBuffer,java.util.List) throws java.lang.Exception", javaMethod.toString());
- assertEquals("List", paramType.getResolvedValue());
- assertEquals("java.util.List", paramType.getResolvedFullyQualifiedName());
- assertEquals("List<StringBuffer>", paramType.getResolvedGenericValue());
- assertEquals("java.util.List<java.lang.StringBuffer>", paramType.getResolvedGenericFullyQualifiedName());
- }
-
- //for QDOX-167
- public void testGenericTypedMethodCall() throws Exception {
- String source = "import java.util.*;\n" +
- "\n" +
- "public class MyClass\n" +
- "{\n" +
- "\n" +
- " private static final Map<String, String> map1 = Collections.<String, String>emptyMap();\n" +
- "\n" +
- " private static final Map<?, ?> map2 = Collections. <String, String> emptyMap();\n" +
- "\n" +
- "}";
- builder.addSource(new StringReader(source));
- }
-
- // For QDox-205
- public void testClassTypeParameters() throws Exception {
- String source1 = "class GenericControllerImpl<T, K, D extends GenericDAO<T, K>>\n" +
- " implements GenericController<T, K>\n {}";
- String source2 = "class GroupControllerImpl extends\n" +
- " GenericControllerImpl<Group, Long, GroupDAO>\n {}";
- String source3 = "interface GenericController<T, K> {}";
- JavaClass genericControllerImpl = builder.addSource(new StringReader(source1)).getClasses().get(0);
- JavaClass groupControllerImpl = builder.addSource(new StringReader(source2)).getClasses().get(0);
- JavaClass genericController = builder.addSource(new StringReader(source3)).getClasses().get(0);
- assertEquals( 3, genericControllerImpl.getTypeParameters().size() );
- assertEquals( 0, groupControllerImpl.getTypeParameters().size() );
- assertEquals( 2, genericController.getTypeParameters().size() );
- }
-
- // For QDOX-206
- public void testGenericsAndArrays() throws Exception {
- JavaMethod method = buildMethod( "public Map<String[], Object[]> test(Map<String[], Object[]> input);" );
- assertEquals("Map<java.lang.String[],java.lang.Object[]>", method.getReturns().toGenericString());
- assertEquals("Map<java.lang.String[],java.lang.Object[]>", method.getParameters().get(0).getType().toGenericString());
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/MethodsTest.java b/src/test/java/com/thoughtworks/qdox/MethodsTest.java
deleted file mode 100644
index 7334ba8..0000000
--- a/src/test/java/com/thoughtworks/qdox/MethodsTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.thoughtworks.qdox;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaSource;
-
-public class MethodsTest
- extends TestCase
-{
-
- private JavaProjectBuilder builder = new JavaProjectBuilder();
-
- public void testSupportsJava5VarArgsParameter()
- {
- JavaMethod javaMethod = buildMethod( "void doStuff(AThing param1, BThing... param2);" );
-
- JavaParameter standardParam = javaMethod.getParameterByName( "param1" );
- JavaParameter varArgsParam = javaMethod.getParameterByName( "param2" );
-
- assertFalse( "param1 should NOT be var args", standardParam.isVarArgs() );
- assertTrue( "param2 should be var args", varArgsParam.isVarArgs() );
- }
-
- public void testVarArgsParametersAreAlsoArrays()
- {
- JavaMethod javaMethod = buildMethod( "void doStuff(AThing param1, BThing[] param2, CThing... param3);" );
-
- JavaClass standardType = javaMethod.getParameterByName( "param1" ).getJavaClass();
- JavaClass arrayType = javaMethod.getParameterByName( "param2" ).getJavaClass();
- JavaClass varArgsType = javaMethod.getParameterByName( "param3" ).getJavaClass();
-
- assertFalse( "param1 should NOT be array", standardType.isArray() );
- assertTrue( "param2 should be array", arrayType.isArray() );
- assertFalse( "param3 should NOT be array", varArgsType.isArray() );
- }
-
- public void testSupportDefaultMethods()
- {
- JavaMethod javaMethod = buildMethod( "default String additionalStuff() { return \"\"; }" );
- assertTrue( javaMethod.isDefault() );
- }
-
- public void testVarArgsIncludedInToString()
- {
- JavaMethod javaMethod = buildMethod( "void doStuff(AThing param1, BThing... param2);" );
-
- assertEquals( "void doStuff(AThing param1, BThing... param2);\n", javaMethod.getCodeBlock() );
- }
-
- private JavaMethod buildMethod( String methodSource )
- {
- String source = "interface Something { " + methodSource + " }";
- JavaSource javaSource = builder.addSource( new StringReader( source ) );
- JavaClass javaClass = javaSource.getClasses().get( 0 );
- JavaMethod javaMethod = javaClass.getMethods().get( 0 );
- return javaMethod;
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/TestMultipleLevelGenericInheritance.java b/src/test/java/com/thoughtworks/qdox/TestMultipleLevelGenericInheritance.java
deleted file mode 100644
index d5d3bae..0000000
--- a/src/test/java/com/thoughtworks/qdox/TestMultipleLevelGenericInheritance.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.thoughtworks.qdox;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.JavaProjectBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaType;
-
-public class TestMultipleLevelGenericInheritance
-{
- private JavaProjectBuilder builder;
-
- @Before
- public void setUp()
- {
- builder = createBuilder();
- }
-
- @Test
- public void testMethodParametersOfIheritedMethodsAreCorrect()
- {
- final JavaClass clazz = builder.getClassByName( "HelloService" );
- final List<JavaMethod> methods = clazz.getMethods( true );
-
- JavaMethod method;
-
- method = methods.get( 0 );
- Assert.assertEquals( "get", method.getName() );
-
- method = methods.get( 1 );
- Assert.assertEquals( "set", method.getName() );
- assertFirstParameterIs( "Dto", method );
-
- method = methods.get( 2 );
- Assert.assertEquals( "validate", method.getName() );
- assertFirstParameterIs( "Dto", method );
-
- }
-
- private void assertFirstParameterIs( final String type, final JavaMethod method )
- {
- List<JavaType> parameterTypes;
- parameterTypes = method.getParameterTypes( true );
- Assert.assertEquals( 1, parameterTypes.size() );
- Assert.assertEquals( type, parameterTypes.get( 0 ).getCanonicalName() );
- }
-
- private JavaProjectBuilder createBuilder()
- {
- final JavaProjectBuilder builder = new JavaProjectBuilder();
- builder.addSource( getDtoClass() );
- builder.addSource( getGetterClass() );
- builder.addSource( getSetterClass() );
- builder.addSource( getValidatorClass() );
- builder.addSource( getHelloService() );
- return builder;
- }
-
- private Reader getDtoClass()
- {
- return new StringReader( "public class Dto {}" );
- }
-
- private Reader getGetterClass()
- {
- return new StringReader( "public interface Getter<T extends Object> { T get(); }" );
- }
-
- private Reader getValidatorClass()
- {
- return new StringReader( "public interface Validator<T extends Object> { void validate(T obj); }" );
- }
-
- private Reader getSetterClass()
- {
- return new StringReader( "public interface Setter<T extends Object> extends Validator<T> { void set(T obj); }" );
- }
-
- private Reader getHelloService()
- {
- return new StringReader( "public interface HelloService extends Getter<Dto>, Setter<Dto> {}" );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java b/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java
deleted file mode 100644
index fd65711..0000000
--- a/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java
+++ /dev/null
@@ -1,1336 +0,0 @@
-package com.thoughtworks.qdox.builder.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.expression.Add;
-import com.thoughtworks.qdox.model.expression.And;
-import com.thoughtworks.qdox.model.expression.AnnotationValue;
-import com.thoughtworks.qdox.model.expression.AnnotationValueList;
-import com.thoughtworks.qdox.model.expression.Cast;
-import com.thoughtworks.qdox.model.expression.Divide;
-import com.thoughtworks.qdox.model.expression.Equals;
-import com.thoughtworks.qdox.model.expression.ExclusiveOr;
-import com.thoughtworks.qdox.model.expression.FieldRef;
-import com.thoughtworks.qdox.model.expression.GreaterEquals;
-import com.thoughtworks.qdox.model.expression.GreaterThan;
-import com.thoughtworks.qdox.model.expression.LessEquals;
-import com.thoughtworks.qdox.model.expression.LessThan;
-import com.thoughtworks.qdox.model.expression.LogicalAnd;
-import com.thoughtworks.qdox.model.expression.LogicalNot;
-import com.thoughtworks.qdox.model.expression.LogicalOr;
-import com.thoughtworks.qdox.model.expression.MinusSign;
-import com.thoughtworks.qdox.model.expression.Multiply;
-import com.thoughtworks.qdox.model.expression.Not;
-import com.thoughtworks.qdox.model.expression.NotEquals;
-import com.thoughtworks.qdox.model.expression.Or;
-import com.thoughtworks.qdox.model.expression.ParenExpression;
-import com.thoughtworks.qdox.model.expression.PlusSign;
-import com.thoughtworks.qdox.model.expression.Query;
-import com.thoughtworks.qdox.model.expression.Remainder;
-import com.thoughtworks.qdox.model.expression.ShiftLeft;
-import com.thoughtworks.qdox.model.expression.ShiftRight;
-import com.thoughtworks.qdox.model.expression.Subtract;
-import com.thoughtworks.qdox.model.expression.TypeRef;
-import com.thoughtworks.qdox.model.expression.UnsignedShiftRight;
-import com.thoughtworks.qdox.model.impl.DefaultJavaAnnotation;
-
-public class EvaluatingVisitorTest
-{
- private EvaluatingVisitor visitor = new EvaluatingVisitorStub();
-
- @Test
- public void testUnaryNumericResultTypeInteger()
- throws Exception
- {
- assertEquals( Integer.class, EvaluatingVisitor.unaryNumericResultType( 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryNumericResultType( (byte) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryNumericResultType( (short) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryNumericResultType( (char) 0 ) );
- }
-
- @Test
- public void testUnaryNumericResultTypeLong()
- throws Exception
- {
- assertEquals( Long.class, EvaluatingVisitor.unaryNumericResultType( 0L ) );
- }
-
- @Test
- public void testUnaryNumericResultTypeVoid()
- throws Exception
- {
- assertEquals( void.class, EvaluatingVisitor.unaryNumericResultType( new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.unaryNumericResultType( (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.unaryNumericResultType( (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.unaryNumericResultType( null ) );
- }
-
- @Test
- public void testUnaryResultTypeInteger()
- throws Exception
- {
- assertEquals( Integer.class, EvaluatingVisitor.unaryResultType( 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryResultType( (byte) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryResultType( (short) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.unaryResultType( (char) 0 ) );
- }
-
- @Test
- public void testUnaryResultTypeLong()
- throws Exception
- {
- assertEquals( Long.class, EvaluatingVisitor.unaryResultType( 0L ) );
- }
-
- @Test
- public void testUnaryResultTypeDouble()
- throws Exception
- {
- assertEquals( Double.class, EvaluatingVisitor.unaryResultType( (double) 0 ) );
- }
-
- @Test
- public void testUnaryResultTypeFloat()
- throws Exception
- {
- assertEquals( Float.class, EvaluatingVisitor.unaryResultType( (float) 0 ) );
- }
-
- @Test
- public void testUnaryResultTypeVoid()
- throws Exception
- {
- assertEquals( void.class, EvaluatingVisitor.unaryResultType( new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.unaryResultType( null ) );
- }
-
- @Test
- public void testNumericResultTypeLong()
- throws Exception
- {
- assertEquals( Long.class, EvaluatingVisitor.numericResultType( (long) 0, (long) 0 ) );
- assertEquals( Long.class, EvaluatingVisitor.numericResultType( (int) 0, (long) 0 ) );
- assertEquals( Long.class, EvaluatingVisitor.numericResultType( (long) 0, (int) 0 ) );
- }
-
- @Test
- public void testNumericResultTypeInteger()
- throws Exception
- {
- assertEquals( Integer.class, EvaluatingVisitor.numericResultType( (int) 0, (int) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.numericResultType( (short) 0, (int) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.numericResultType( (int) 0, (short) 0 ) );
- }
-
- @Test
- public void testNumericResultTypeVoid()
- throws Exception
- {
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (double) 0, (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (float) 0, (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (double) 0, (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (float) 0, (float) 0 ) );
-
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (double) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (float) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (long) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (int) 0, new Object() ) );
-
- assertEquals( void.class, EvaluatingVisitor.numericResultType( new Object(), (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( new Object(), (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( new Object(), (long) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( new Object(), (int) 0 ) );
-
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (double) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (float) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (long) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( (int) 0, null ) );
-
- assertEquals( void.class, EvaluatingVisitor.numericResultType( null, (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( null, (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( null, (long) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.numericResultType( null, (int) 0 ) );
- }
-
- @Test
- public void testResultTypeDouble()
- throws Exception
- {
- // If either operand is of type double, the other is converted to double.
- assertEquals( Double.class, EvaluatingVisitor.resultType( (double) 0, (double) 0 ) );
- assertEquals( Double.class, EvaluatingVisitor.resultType( (float) 0, (double) 0 ) );
- assertEquals( Double.class, EvaluatingVisitor.resultType( (int) 0, (double) 0 ) );
- assertEquals( Double.class, EvaluatingVisitor.resultType( (double) 0, (float) 0 ) );
- assertEquals( Double.class, EvaluatingVisitor.resultType( (double) 0, (int) 0 ) );
- }
-
- @Test
- public void testResultTypeFloat()
- throws Exception
- {
- // Otherwise, if either operand is of type float, the other is converted to float.
- assertEquals( Float.class, EvaluatingVisitor.resultType( (float) 0, (float) 0 ) );
- assertEquals( Float.class, EvaluatingVisitor.resultType( (int) 0, (float) 0 ) );
- assertEquals( Float.class, EvaluatingVisitor.resultType( (float) 0, (int) 0 ) );
- }
-
- @Test
- public void testResultTypeLong()
- throws Exception
- {
- // Otherwise, if either operand is of type long, the other is converted to long.
- assertEquals( Long.class, EvaluatingVisitor.resultType( (long) 0, (long) 0 ) );
- assertEquals( Long.class, EvaluatingVisitor.resultType( (int) 0, (long) 0 ) );
- assertEquals( Long.class, EvaluatingVisitor.resultType( (long) 0, (int) 0 ) );
- }
-
- @Test
- public void testResultTypeInteger()
- throws Exception
- {
- // Otherwise, if either operand is of type long, the other is converted to long.
- assertEquals( Integer.class, EvaluatingVisitor.resultType( (int) 0, (int) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.resultType( (short) 0, (int) 0 ) );
- assertEquals( Integer.class, EvaluatingVisitor.resultType( (int) 0, (short) 0 ) );
- }
-
- @Test
- public void testResultTypeVoid()
- throws Exception
- {
- // Otherwise, if either operand is of type long, the other is converted to long.
- assertEquals( void.class, EvaluatingVisitor.resultType( (double) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (float) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (long) 0, new Object() ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (int) 0, new Object() ) );
-
- assertEquals( void.class, EvaluatingVisitor.resultType( new Object(), (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( new Object(), (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( new Object(), (long) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( new Object(), (int) 0 ) );
-
- assertEquals( void.class, EvaluatingVisitor.resultType( (double) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (float) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (long) 0, null ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( (int) 0, null ) );
-
- assertEquals( void.class, EvaluatingVisitor.resultType( null, (double) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( null, (float) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( null, (long) 0 ) );
- assertEquals( void.class, EvaluatingVisitor.resultType( null, (int) 0 ) );
- }
-
- @Test
- public void testVisitAdd()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 7.0D );
- when( rhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 2.0D );
- assertEquals( 7.0D + 2.0D, visitor.visit( new Add( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 7.0F );
- when( rhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 2.0F );
- assertEquals( 7.0F + 2.0F, visitor.visit( new Add( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L + 2L, visitor.visit( new Add( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 + 2, visitor.visit( new Add( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Add( lhs, rhs ) );
- fail( "Additive operations (+ and -) can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitAnd()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L & 2L, visitor.visit( new And( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 & 2, visitor.visit( new And( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new And( lhs, rhs ) );
- fail( "The and(&) operator can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitAnnotation()
- {
- try{
- JavaAnnotation annotation = mock(JavaAnnotation.class);
- visitor.visit( annotation );
- fail( "Visiting an annotation is not supported and should throw an UnsupportedOperationException" );
- }
- catch (UnsupportedOperationException e) {
- }
- }
-
- @Test
- public void testVisitAnnotationValueList() {
- {
- List<AnnotationValue> emptyList = Collections.emptyList();
- List<?> visitedResult = visitor.visit( new AnnotationValueList( emptyList ) );
- assertEquals( 0, visitedResult.size() );
- }
-
- {
- AnnotationValue annoVal = mock( AnnotationValue.class );
- Object singleResult = new Object();
- when( annoVal.accept( visitor ) ).thenReturn( singleResult );
- List<?> visitedResult = visitor.visit( new AnnotationValueList( Collections.singletonList( annoVal ) ) );
- assertEquals( 1, visitedResult.size() );
- assertSame( singleResult, visitedResult.get( 0 ) );
- }
- }
-
- @Test
- public void testVisitCast() throws Exception
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.accept( visitor ) ).thenReturn( 7 );
-
- JavaClass primitiveClass = mock( JavaClass.class );
- when( primitiveClass.isPrimitive() ).thenReturn( true );
-
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "byte" );
- assertEquals( (byte) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "char" );
- assertEquals( (char) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "short" );
- assertEquals( (short) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "int" );
- assertEquals( (int) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "long" );
- assertEquals( (long) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "float" );
- assertEquals( (float) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "double" );
- assertEquals( (double) 7, visitor.visit( new Cast( primitiveClass, value ) ) );
-
- try
- {
- when( primitiveClass.getFullyQualifiedName() ).thenReturn( "void" );
- visitor.visit( new Cast( primitiveClass, value ) );
-
- fail( "Although 'void' is a primitive, you can't cast to it" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
-
- JavaClass stringClass = mock( JavaClass.class );
- when( stringClass.getFullyQualifiedName() ).thenReturn( "java.lang.String" );
- when( value.accept( visitor ) ).thenReturn( "hello world" );
- assertEquals( (String) "hello world", visitor.visit( new Cast( stringClass, value ) ) );
-
- JavaClass listClass = mock( JavaClass.class );
- when( listClass.getFullyQualifiedName() ).thenReturn( "java.util.List" );
- Object list = Collections.EMPTY_LIST;
- when( value.accept( visitor ) ).thenReturn( list );
- assertEquals( (List<?>) list, visitor.visit( new Cast( listClass, value ) ) );
- }
-
- @Test
- public void testVisitDivide()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D / 2.0D, visitor.visit( new Divide( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F / 2.0F, visitor.visit( new Divide( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L / 2L, visitor.visit( new Divide( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 / 2, visitor.visit( new Divide( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Divide( lhs, rhs ) );
- fail( "The divide(/) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitEquals()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D == 2.0D, visitor.visit( new Equals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D == 7.0D, visitor.visit( new Equals( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F == 2.0F, visitor.visit( new Equals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F == 7.0F, visitor.visit( new Equals( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L == 2L, visitor.visit( new Equals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L == 7L, visitor.visit( new Equals( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 == 2, visitor.visit( new Equals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 == 7, visitor.visit( new Equals( lhs, rhs ) ) );
-
- // Objects
- Object object1 = new Object();
- Object object2 = new Object();
- when( lhs.accept( visitor ) ).thenReturn( object1 );
- when( rhs.accept( visitor ) ).thenReturn( object2 );
- assertEquals( object1 == object2, visitor.visit( new Equals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( object1 );
- assertEquals( object1 == object1, visitor.visit( new Equals( lhs, rhs ) ) );
- }
-
- @Test
- public void testVisitExlusiveOr()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L ^ 2L, visitor.visit( new ExclusiveOr( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 ^ 2, visitor.visit( new ExclusiveOr( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new ExclusiveOr( lhs, rhs ) );
- fail( "The exclusive-or(^) operator can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitFieldRef()
- {
- JavaAnnotatedElement annotatedElement = mock( JavaAnnotatedElement.class );
- FieldRef ref = new FieldRef( "fieldname" );
- ref.setContext( annotatedElement );
- try {
- visitor.visit( ref );
- fail( "fieldname should be a unresolvable field" );
- }
- catch( IllegalArgumentException e )
- {
- }
-
- JavaField nonStaticNonFinalfield = mock( JavaField.class );
-
- JavaClass declaringClass = mock( JavaClass.class );
- when( declaringClass.getFieldByName( "fieldname" ) ).thenReturn( nonStaticNonFinalfield );
-
- JavaClass annotatedClass = mock( JavaClass.class );
- try
- {
- visitor.visit( ref );
- fail( "fieldname should fail, because it's not-static and non-final" );
- }
- catch( IllegalArgumentException e)
- {
- }
-
-
- JavaField staticFinalfield = mock( JavaField.class );
- when( staticFinalfield.isStatic() ).thenReturn( true );
- when( staticFinalfield.isFinal() ).thenReturn( true );
- when( declaringClass.getFieldByName( "fieldname" ) ).thenReturn( staticFinalfield );
-
- ref = new FieldRef( "fieldname" );
- ref.setContext( annotatedClass );
- when( annotatedClass.getDeclaringClass() ).thenReturn( declaringClass );
- assertSame( EvaluatingVisitorStub.fieldReferenceValue, visitor.visit( ref ) );
-
- JavaMethod annotatedMethod = mock( JavaMethod.class );
- ref = new FieldRef( "fieldname" );
- ref.setContext( annotatedMethod );
- when( annotatedMethod.getDeclaringClass() ).thenReturn( declaringClass );
- assertSame( EvaluatingVisitorStub.fieldReferenceValue, visitor.visit( ref ) );
-
- JavaParameter annotatedParameter = mock( JavaParameter.class );
- ref = new FieldRef( "fieldname" );
- ref.setContext( annotatedParameter );
- when( annotatedParameter.getParentClass() ).thenReturn( declaringClass );
- assertSame( EvaluatingVisitorStub.fieldReferenceValue, visitor.visit( ref ) );
-
- JavaPackage annotatedPackage = mock( JavaPackage.class );
- ref = new FieldRef( "a.B.fieldname" );
- ref.setContext( annotatedPackage );
- JavaClass b = mock( JavaClass.class );
- when( b.getFieldByName( "fieldname" ) ).thenReturn( staticFinalfield );
- ClassLibrary classLibrary = mock( ClassLibrary.class );
- when( classLibrary.hasClassReference( "a.B" ) ).thenReturn( true );
- when( classLibrary.getJavaClass( "a.B" ) ).thenReturn( b );
- when( annotatedPackage.getJavaClassLibrary() ).thenReturn( classLibrary );
- assertSame( EvaluatingVisitorStub.fieldReferenceValue, visitor.visit( ref ) );
- }
-
-
- @Test
- public void testVisitGreaterEquals()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D >= 2.0D, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D >= 7.0D, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 2.0D >= 7.0D, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F >= 2.0F, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F >= 7.0F, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 2.0F >= 7.0F, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L >= 2L, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L >= 7L, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 2L >= 7L, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 >= 2, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 >=7, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 2 >= 7, visitor.visit( new GreaterEquals( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new GreaterEquals( lhs, rhs ) );
- fail( "The greater-equals(>=) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitGreaterThan()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D > 2.0D, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D > 7.0D, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 2.0D > 7.0D, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F > 2.0F, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F > 7.0F, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 2.0F > 7.0F, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L > 2L, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L > 7L, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 2L > 7L, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 > 2, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 > 7, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 2 > 7, visitor.visit( new GreaterThan( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new GreaterThan( lhs, rhs ) );
- fail( "The greater-than(>) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitLessEquals()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D <= 2.0D, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D <= 7.0D, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 2.0D <= 7.0D, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F <= 2.0F, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F <= 7.0F, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 2.0F <= 7.0F, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L <= 2L, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L <= 7L, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 2L <= 7L, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 <= 2, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 <= 7, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 2 <= 7, visitor.visit( new LessEquals( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new LessEquals( lhs, rhs ) );
- fail( "The less-equals(<=) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitLessThan()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D < 2.0D, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D < 7.0D, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 2.0D < 7.0D, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F < 2.0F, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F < 7.0F, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 2.0F < 7.0F, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L < 2L, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L < 7L, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 2L < 7L, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 < 2, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 < 7, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- when( lhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 2 < 7, visitor.visit( new LessThan( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new LessThan( lhs, rhs ) );
- fail( "The less-than(<) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void visitLogicalAnd()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- when( lhs.accept( visitor ) ).thenReturn( true );
- when( rhs.accept( visitor ) ).thenReturn( true );
- assertEquals( true && true, visitor.visit( new LogicalAnd( lhs, rhs ) ) );
-
-
- when( lhs.accept( visitor ) ).thenReturn( false );
- when( rhs.accept( visitor ) ).thenReturn( false );
- assertEquals( false && false, visitor.visit( new LogicalAnd( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new LogicalAnd( lhs, rhs ) );
- fail( "The logical and(&&) operator can only be performed on booleans" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void visitLogicalNot()
- {
- AnnotationValue value = mock( AnnotationValue.class );
-
- when( value.accept( visitor ) ).thenReturn( true );
- assertEquals( !true, visitor.visit( new LogicalNot( value ) ) );
-
- when( value.accept( visitor ) ).thenReturn( false );
- assertEquals( !false, visitor.visit( new LogicalNot( value ) ) );
-
- // Objects
- when( value.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new LogicalNot( value ) );
- fail( "The logical not(!) operator can only be performed on booleans" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void visitLogicalOr()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- when( lhs.accept( visitor ) ).thenReturn( true );
- when( rhs.accept( visitor ) ).thenReturn( true );
- assertEquals( true || true, visitor.visit( new LogicalOr( lhs, rhs ) ) );
-
-
- when( lhs.accept( visitor ) ).thenReturn( false );
- when( rhs.accept( visitor ) ).thenReturn( false );
- assertEquals( false || false, visitor.visit( new LogicalOr( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new LogicalOr( lhs, rhs ) );
- fail( "The logical or(||) operator can only be performed on booleans" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitMinusSign()
- {
- AnnotationValue value = mock( AnnotationValue.class );
-
- // Double
- when( value.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( -7.0D, visitor.visit( new MinusSign( value ) ) );
-
- // Float
- when( value.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( -7.0F, visitor.visit( new MinusSign( value ) ) );
-
- // Long
- when( value.accept( visitor ) ).thenReturn( 7L );
- assertEquals( -7L, visitor.visit( new MinusSign( value ) ) );
-
- // Integer
- when( value.accept( visitor ) ).thenReturn( 7 );
- assertEquals( -7, visitor.visit( new MinusSign( value ) ) );
-
- when( value.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new MinusSign( value ) );
- fail( "The minus(-) sign operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitMultiply()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D * 2.0D, visitor.visit( new Multiply( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F * 2.0F, visitor.visit( new Multiply( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L * 2L, visitor.visit( new Multiply( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 * 2, visitor.visit( new Multiply( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Multiply( lhs, rhs ) );
- fail( "The multiply(*) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitNot()
- {
- AnnotationValue value = mock( AnnotationValue.class );
-
- // Longs
- when( value.accept( visitor ) ).thenReturn( 7L );
- assertEquals( ~7L, visitor.visit( new Not( value ) ) );
-
- // Integers
- when( value.accept( visitor ) ).thenReturn( 7 );
- assertEquals( ~7, visitor.visit( new Not( value) ) );
-
- // Objects
- when( value.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Not( value ) );
- fail( "The not(~) operator can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitNotEquals()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D != 2.0D, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D != 7.0D, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F != 2.0F, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F != 7.0F, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L != 2L, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L != 7L, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 != 2, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7 != 7, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- // Objects
- Object object1 = new Object();
- Object object2 = new Object();
- when( lhs.accept( visitor ) ).thenReturn( object1 );
- when( rhs.accept( visitor ) ).thenReturn( object2 );
- assertEquals( object1 != object2, visitor.visit( new NotEquals( lhs, rhs ) ) );
-
- when( rhs.accept( visitor ) ).thenReturn( object1 );
- assertEquals( object1 != object1, visitor.visit( new NotEquals( lhs, rhs ) ) );
- }
-
- @Test
- public void testVisitOr()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L | 2L, visitor.visit( new Or( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 | 2, visitor.visit( new Or( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Or( lhs, rhs ) );
- fail( "The or(|) operator can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitParenExpression()
- {
- AnnotationValue value = mock( AnnotationValue.class );
-
- Object acceptResult = new Object();
- when( value.accept( visitor ) ).thenReturn( acceptResult );
- assertSame( acceptResult, visitor.visit( new ParenExpression( value ) ) );
- }
-
- @Test
- public void testVisitPlusSign()
- {
- AnnotationValue value = mock( AnnotationValue.class );
-
- // Double
- when( value.accept( visitor ) ).thenReturn( 7.0D );
- assertEquals( 7.0D, visitor.visit( new PlusSign( value ) ) );
-
- // Float
- when( value.accept( visitor ) ).thenReturn( 7.0F );
- assertEquals( 7.0F, visitor.visit( new PlusSign( value ) ) );
-
- // Long
- when( value.accept( visitor ) ).thenReturn( 7L );
- assertEquals( 7L, visitor.visit( new PlusSign( value ) ) );
-
- // Integer
- when( value.accept( visitor ) ).thenReturn( 7 );
- assertEquals( 7, visitor.visit( new PlusSign( value ) ) );
-
- when( value.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new PlusSign( value ) );
- fail( "The plus sign operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
-
- }
- }
-
- @Test
- public void testVisitQuery()
- {
- AnnotationValue condition = mock( AnnotationValue.class );
- AnnotationValue trueExpr = mock( AnnotationValue.class );
- AnnotationValue falseExpr = mock( AnnotationValue.class );
-
- when( trueExpr.accept( visitor ) ).thenReturn( "consequent" );
- when( falseExpr.accept( visitor ) ).thenReturn( "alternative" );
-
- // true condition
- when( condition.accept( visitor ) ).thenReturn( Boolean.TRUE );
- assertEquals( "consequent", visitor.visit( new Query( condition, trueExpr, falseExpr ) ) );
-
- when( condition.accept( visitor ) ).thenReturn( true );
- assertEquals( "consequent", visitor.visit( new Query( condition, trueExpr, falseExpr ) ) );
-
- // false condition
- when( condition.accept( visitor ) ).thenReturn( Boolean.FALSE );
- assertEquals( "alternative", visitor.visit( new Query( condition, trueExpr, falseExpr ) ) );
-
- when( condition.accept( visitor ) ).thenReturn( false );
- assertEquals( "alternative", visitor.visit( new Query( condition, trueExpr, falseExpr ) ) );
-
- when( condition.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Query( condition, trueExpr, falseExpr ) );
- fail( "The condition of the query( ? : ) must be a boolean" );
- }
- catch ( IllegalArgumentException iae )
- {
-
- }
- }
-
- @Test
- public void testVisitRemainder()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( visitor ) ).thenReturn( 7.0D );
- when( rhs.accept( visitor ) ).thenReturn( 2.0D );
- assertEquals( 7.0D % 2.0D, visitor.visit( new Remainder( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( visitor ) ).thenReturn( 7.0F );
- when( rhs.accept( visitor ) ).thenReturn( 2.0F );
- assertEquals( 7.0F % 2.0F, visitor.visit( new Remainder( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L % 2L, visitor.visit( new Remainder( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 % 2, visitor.visit( new Remainder( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Remainder( lhs, rhs ) );
- fail( "The remainder(%) operator can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitShiftLeft()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L << 2L, visitor.visit( new ShiftLeft( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 << 2, visitor.visit( new ShiftLeft( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( new Object() );
- when( rhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new ShiftLeft( lhs, rhs ) );
- fail( "Bitwise and bit shift operations can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitShiftRight()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L >> 2L, visitor.visit( new ShiftRight( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 >> 2, visitor.visit( new ShiftRight( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new ShiftRight( lhs, rhs ) );
- fail( "Bitwise and bit shift operations can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitSubtract()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Doubles
- when( lhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 7.0D );
- when( rhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 2.0D );
- assertEquals( 7.0D - 2.0D, visitor.visit( new Subtract( lhs, rhs ) ) );
-
- // Floats
- when( lhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 7.0F );
- when( rhs.accept( any( EvaluatingVisitor.class ) ) ).thenReturn( 2.0F );
- assertEquals( 7.0F - 2.0F, visitor.visit( new Subtract( lhs, rhs ) ) );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L - 2L, visitor.visit( new Subtract( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 - 2, visitor.visit( new Subtract( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new Subtract( lhs, rhs ) );
- fail( "Additive operations (+ and -) can only be performed on numeric types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- @Test
- public void testVisitTypeRef()
- {
- JavaType type = mock( JavaType.class );
- assertSame( type, visitor.visit( new TypeRef( type ) ) );
- }
-
- @Test
- public void testVisitUnsignedShiftRight()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
-
- // Longs
- when( lhs.accept( visitor ) ).thenReturn( 7L );
- when( rhs.accept( visitor ) ).thenReturn( 2L );
- assertEquals( 7L >>> 2L, visitor.visit( new UnsignedShiftRight( lhs, rhs ) ) );
-
- // Integers
- when( lhs.accept( visitor ) ).thenReturn( 7 );
- when( rhs.accept( visitor ) ).thenReturn( 2 );
- assertEquals( 7 >>> 2, visitor.visit( new UnsignedShiftRight( lhs, rhs ) ) );
-
- // Objects
- when( lhs.accept( visitor ) ).thenReturn( new Object() );
- when( rhs.accept( visitor ) ).thenReturn( new Object() );
- try
- {
- visitor.visit( new UnsignedShiftRight( lhs, rhs ) );
- fail( "Bitwise and bit shift operations can only be performed on integral types" );
- }
- catch ( IllegalArgumentException iae )
- {
- }
- }
-
- private static class EvaluatingVisitorStub extends EvaluatingVisitor {
-
- static final Object fieldReferenceValue = new Object();
-
- @Override
- protected Object getFieldReferenceValue( JavaField javaField )
- {
- return fieldReferenceValue;
- }
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/builder/impl/ModelBuilderTest.java b/src/test/java/com/thoughtworks/qdox/builder/impl/ModelBuilderTest.java
deleted file mode 100644
index b994797..0000000
--- a/src/test/java/com/thoughtworks/qdox/builder/impl/ModelBuilderTest.java
+++ /dev/null
@@ -1,862 +0,0 @@
-package com.thoughtworks.qdox.builder.impl;
-
-import static org.mockito.Mockito.*;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.library.ClassNameLibrary;
-import com.thoughtworks.qdox.model.DocletTagFactory;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.parser.structs.FieldDef;
-import com.thoughtworks.qdox.parser.structs.InitDef;
-import com.thoughtworks.qdox.parser.structs.MethodDef;
-import com.thoughtworks.qdox.parser.structs.PackageDef;
-import com.thoughtworks.qdox.parser.structs.TagDef;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-
-public class ModelBuilderTest extends TestCase {
-
- private ModelBuilder builder;
- private DocletTagFactory docletTagFactory;
-
- public ModelBuilderTest(String s) {
- super(s);
- }
-
- protected void setUp()
- throws Exception
- {
- docletTagFactory = mock( DocletTagFactory.class );
- builder = new ModelBuilder( new ClassNameLibrary(), docletTagFactory );
- }
-
- public void testNumberOfClassesGrows() throws Exception {
- assertEquals(0, builder.getSource().getClasses().size());
- builder.beginClass(new ClassDef());
- builder.endClass();
- assertEquals(1, builder.getSource().getClasses().size());
- builder.beginClass(new ClassDef());
- builder.endClass();
- assertEquals(2, builder.getSource().getClasses().size());
- }
-
- public void testSimpleClass() throws Exception {
- ClassDef cls = new ClassDef("Thingy");
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef("ThingyThing");
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("Thingy", source.getClasses().get(0).getName());
- assertEquals("ThingyThing", source.getClasses().get(1).getName());
- assertEquals(source, source.getClasses().get(0).getParentSource());
- }
-
- public void testInterface() throws Exception {
- ClassDef cls = new ClassDef();
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.setType( ClassDef.INTERFACE );
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(false, source.getClasses().get(0).isInterface());
- assertEquals(true, source.getClasses().get(1).isInterface());
- }
-
- public void testEnum() throws Exception {
- ClassDef cls = new ClassDef();
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.setType( ClassDef.ENUM );
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(false, source.getClasses().get(0).isEnum());
- assertEquals(true, source.getClasses().get(1).isEnum());
- }
-
- public void testAnnotationType() throws Exception {
- ClassDef cls = new ClassDef();
- cls.setType( ClassDef.ANNOTATION_TYPE );
- builder.beginClass(cls);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(1, source.getClasses().size());
- }
-
- public void testClassExtends() throws Exception {
- ClassDef cls = new ClassDef();
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.getExtends().add(new TypeDef("Another"));
- builder.beginClass(cls2);
- builder.endClass();
- builder.addImport("com.thoughtworks.*");
-
- JavaSource source = builder.getSource();
-
- assertEquals("java.lang.Object", source.getClasses().get(0).getSuperClass().getValue());
- assertEquals("Another", source.getClasses().get(1).getSuperClass().getValue());
-
- assertEquals(0, source.getClasses().get(0).getImplements().size());
- assertEquals(0, source.getClasses().get(1).getImplements().size());
-
-// With qdox-2.0 it's not possible to inspect the source during parsing, so this has become an invalid test
-/*
- //Add another class and see if Another gets resolved
- builder.addPackage(new PackageDef("com.thoughtworks"));
- ClassDef anotherCls = new ClassDef();
- anotherCls.name = "Another";
- builder.beginClass(anotherCls);
- builder.endClass();
-
- assertEquals("com.thoughtworks.Another", source.getClasses()[1].getSuperClass().getValue());
-*/
- }
-
- public void testInterfaceExtends() throws Exception {
- ClassDef cls = new ClassDef();
- cls.setType( ClassDef.INTERFACE );
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.setType( ClassDef.INTERFACE );
- cls2.getExtends().add(new TypeDef("Another"));
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(0, source.getClasses().get(0).getImplements().size());
- assertEquals(1, source.getClasses().get(1).getImplements().size());
- assertEquals("Another", source.getClasses().get(1).getImplements().get(0).getValue());
-
- assertNull(source.getClasses().get(0).getSuperClass());
- assertNull(source.getClasses().get(1).getSuperClass());
- }
-
- public void testInterfaceExtendsMultiple() throws Exception {
- ClassDef cls = new ClassDef();
- cls.setType( ClassDef.INTERFACE );
- cls.getExtends().add(new TypeDef("Another"));
- cls.getExtends().add(new TypeDef("java.io.Serializable"));
- cls.getExtends().add(new TypeDef("BottleOpener"));
- builder.beginClass(cls);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(3, source.getClasses().get(0).getImplements().size());
- assertEquals("Another", source.getClasses().get(0).getImplements().get(0).getValue());
- assertEquals("java.io.Serializable", source.getClasses().get(0).getImplements().get(1).getValue());
- assertEquals("BottleOpener", source.getClasses().get(0).getImplements().get(2).getValue());
-
- assertNull(source.getClasses().get(0).getSuperClass());
- }
-
- public void testClassImplements() throws Exception {
- ClassDef cls = new ClassDef();
- builder.beginClass(cls);
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.getImplements().add(new TypeDef("SomeInterface"));
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(0, source.getClasses().get(0).getImplements().size());
- assertEquals(1, source.getClasses().get(1).getImplements().size());
-
- assertEquals("SomeInterface", source.getClasses().get(1).getImplements().get(0).getValue());
-
- assertEquals("java.lang.Object", source.getClasses().get(0).getSuperClass().getValue());
- assertEquals("java.lang.Object", source.getClasses().get(1).getSuperClass().getValue());
- }
-
- public void testClassImplementsMultiple() throws Exception {
- ClassDef cls = new ClassDef();
- cls.getImplements().add(new TypeDef("SomeInterface"));
- cls.getImplements().add(new TypeDef("XX"));
- builder.beginClass(cls);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(2, source.getClasses().get(0).getImplements().size());
-
- assertEquals("SomeInterface", source.getClasses().get(0).getImplements().get(0).getValue());
- assertEquals("XX", source.getClasses().get(0).getImplements().get(1).getValue());
- }
-
- public void testClassExtendsAndImplements() throws Exception {
- ClassDef cls = new ClassDef();
- cls.getExtends().add(new TypeDef("SubClass"));
- cls.getImplements().add(new TypeDef("SomeInterface"));
- cls.getImplements().add(new TypeDef("XX"));
- builder.beginClass(cls);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(2, source.getClasses().get(0).getImplements().size());
-
- assertEquals("SomeInterface", source.getClasses().get(0).getImplements().get(0).getValue());
- assertEquals("XX", source.getClasses().get(0).getImplements().get(1).getValue());
-
- assertEquals("SubClass", source.getClasses().get(0).getSuperClass().getValue());
- }
-
- public void testClassModifiers() throws Exception {
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- ClassDef cls2 = new ClassDef();
- cls2.getModifiers().add("public");
- cls2.getModifiers().add("final");
- builder.beginClass(cls2);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals(0, source.getClasses().get(0).getModifiers().size());
- assertEquals(2, source.getClasses().get(1).getModifiers().size());
-
- List<String> modifiers = source.getClasses().get(1).getModifiers();
- assertEquals("public", modifiers.get(0));
- assertEquals("final", modifiers.get(1));
- }
-
- public void testAddMethodsToCorrectClass() throws Exception {
- builder.beginClass(new ClassDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.endClass();
-
- builder.beginClass(new ClassDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.endClass();
-
- builder.beginClass(new ClassDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
- assertEquals(1, source.getClasses().get(0).getMethods().size());
- assertEquals(3, source.getClasses().get(1).getMethods().size());
- assertEquals(2, source.getClasses().get(2).getMethods().size());
- }
-
- public void testInnerClass() throws Exception {
- builder.addPackage(new PackageDef("xyz"));
-
- ClassDef outerDef = new ClassDef("Outer");
- builder.beginClass(outerDef);
-
- ClassDef innerDef = new ClassDef("Inner");
- builder.beginClass(innerDef);
-
- MethodDef fooDef = new MethodDef();
- fooDef.setName("foo");
- builder.beginMethod();
- builder.endMethod(fooDef);
- builder.endClass();
-
- MethodDef barDef = new MethodDef();
- barDef.setName("bar");
- builder.beginMethod();
- builder.endMethod(barDef);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- assertEquals(1, source.getClasses().size());
- JavaClass outerClass = source.getClasses().get(0);
- assertEquals("xyz.Outer", outerClass.getFullyQualifiedName());
- assertEquals(1, outerClass.getMethods().size());
- assertEquals("bar", outerClass.getMethods().get(0).getName());
- assertEquals(1, outerClass.getNestedClasses().size());
- JavaClass innerClass = outerClass.getNestedClasses().get(0);
- assertEquals("xyz.Outer$Inner", innerClass.getFullyQualifiedName());
- assertEquals(1, innerClass.getMethods().size());
- assertEquals("foo", innerClass.getMethods().get(0).getName());
- }
-
- public void testSimpleMethod() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
- mth.setName("doSomething");
- mth.setReturnType(new TypeDef("void"));
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod doSomething = source.getClasses().get(0).getMethods().get(0);
- assertEquals("doSomething", doSomething.getName());
- assertEquals("void", doSomething.getReturns().getValue());
- JavaSource parentSource = doSomething.getReturns().getParent().getParentSource();
- assertSame(source, parentSource);
- assertEquals(0, doSomething.getModifiers().size());
- assertEquals(0, doSomething.getParameters().size());
- assertEquals(0, doSomething.getExceptions().size());
- }
-
- public void testMethodNoArray() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
- mth.setName("doSomething");
- mth.setReturnType(new TypeDef("void"));
- mth.setDimensions(0);
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(0, result.getReturns().getDimensions());
- }
-
- public void testMethod1dArray() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
- mth.setName("doSomething");
- mth.setReturnType(new TypeDef("void"));
- mth.setDimensions(1);
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(1, result.getReturns().getDimensions());
- }
-
- public void testMethod2dArray() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
- mth.setName("doSomething");
- mth.setReturnType(new TypeDef("void"));
- mth.setDimensions(2);
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(2, result.getReturns().getDimensions());
- }
-
- public void testMethodParameters() throws Exception {
- builder.beginClass(new ClassDef());
- builder.beginMethod();
-
- MethodDef mth = new MethodDef();
-
- FieldDef f1 = new FieldDef();
- f1.setName( "count" );
- f1.setType( new TypeDef("int") );
- f1.getModifiers().add("final");
- builder.addParameter( f1 );
-
- FieldDef f2 = new FieldDef();
- f2.setName( "name" );
- f2.setType( new TypeDef("String") );
- builder.addParameter( f2 );
-
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(2, result.getParameters().size());
- assertEquals("count", result.getParameters().get(0).getName());
- assertEquals("int", result.getParameters().get(0).getType().getValue());
- assertEquals("name", result.getParameters().get(1).getName());
- assertEquals("String", result.getParameters().get(1).getType().getValue());
- }
-
- public void testMethodParametersWithArrays() throws Exception {
- builder.beginClass(new ClassDef());
- builder.beginMethod();
- MethodDef mth = new MethodDef();
-
- FieldDef f1 = new FieldDef();
- f1.setName( "count" );
- f1.setType( new TypeDef("int") );
- f1.getModifiers().add("final");
- f1.setDimensions( 1 );
- builder.addParameter( f1 );
-
-
- FieldDef f2 = new FieldDef();
- f2.setName( "name" );
- f2.setType( new TypeDef("String") );
- f2.setDimensions( 2 );
- builder.addParameter( f2 );
-
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(1, result.getParameters().get(0).getJavaClass().getDimensions());
- assertEquals(2, result.getParameters().get(1).getJavaClass().getDimensions());
- }
-
- public void testMethodExceptions() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
-
- mth.getExceptions().add(new TypeDef("RuntimeException"));
- mth.getExceptions().add(new TypeDef("java.io.IOException"));
-
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(2, result.getExceptions().size());
- assertEquals("RuntimeException", result.getExceptions().get(0).getValue());
- assertEquals("java.io.IOException", result.getExceptions().get(1).getValue());
- }
-
- public void testMethodModifiers() throws Exception {
- builder.beginClass(new ClassDef());
- MethodDef mth = new MethodDef();
-
- mth.getModifiers().add("public");
- mth.getModifiers().add("final");
- mth.getModifiers().add("synchronized");
-
- builder.beginMethod();
- builder.endMethod(mth);
- builder.endClass();
-
- JavaSource source = builder.getSource();
- JavaMethod result = source.getClasses().get(0).getMethods().get(0);
- assertEquals(3, result.getModifiers().size());
-
- List<String> modifiers = result.getModifiers();
- assertEquals("public", modifiers.get(0));
- assertEquals("final", modifiers.get(1));
- assertEquals("synchronized", modifiers.get(2));
- }
-
- public void testSimpleField() throws Exception {
- builder.beginClass(new ClassDef());
-
- FieldDef fld = new FieldDef();
- fld.setName( "count" );
- fld.setType( new TypeDef("int") );
- builder.beginField(fld);
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaField result = source.getClasses().get(0).getFields().get(0);
- assertNotNull(result);
- assertEquals("count", result.getName());
- assertEquals("int", result.getType().getValue());
-
- }
-
- public void testFieldWithModifiers() throws Exception {
- builder.beginClass(new ClassDef());
-
- FieldDef fld = new FieldDef();
- fld.getModifiers().add("blah2");
- fld.getModifiers().add("blah");
- builder.beginField(fld);
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaField result = source.getClasses().get(0).getFields().get(0);
- assertNotNull(result);
- assertNotNull(result.getModifiers());
- assertEquals("blah2", result.getModifiers().get(0));
- assertEquals("blah", result.getModifiers().get(1));
- }
-
- public void testFieldNoArray() throws Exception {
- builder.beginClass(new ClassDef());
-
- FieldDef fld = new FieldDef();
- fld.setName( "count" );
- fld.setType( new TypeDef("int") );
- fld.setDimensions( 0 );
- builder.beginField(fld);
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaField result = source.getClasses().get(0).getFields().get(0);
- assertEquals(0, result.getType().getDimensions());
-
- }
-
- public void testField1dArray() throws Exception {
- builder.beginClass(new ClassDef());
-
- FieldDef fld = new FieldDef();
- fld.setName( "count" );
- fld.setType( new TypeDef("int") );
- fld.setDimensions( 1 );
-
- builder.beginField(fld);
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaField result = source.getClasses().get(0).getFields().get(0);
- assertEquals(1, result.getType().getDimensions());
-
- }
-
- public void testField2dArray() throws Exception {
- builder.beginClass(new ClassDef());
-
- FieldDef fld = new FieldDef();
- fld.setName( "count" );
- fld.setType( new TypeDef("int") );
- fld.setDimensions( 2 );
- builder.beginField(fld);
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaField result = source.getClasses().get(0).getFields().get(0);
- assertEquals(2, result.getType().getDimensions());
- }
-
- public void testSimpleConstructor() throws Exception {
- builder.beginClass(new ClassDef());
-
- MethodDef c1 = new MethodDef();
- c1.setName("MyClass");
- builder.beginConstructor();
- builder.endConstructor(c1);
-
- MethodDef m1 = new MethodDef();
- m1.setName("method");
- m1.setReturnType(new TypeDef("void"));
- builder.beginMethod();
- builder.endMethod(m1);
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- JavaConstructor result1 = source.getClasses().get(0).getConstructors().get(0);
- JavaMethod result2 = source.getClasses().get(0).getMethods().get(0);
-
- assertNotNull(result1);
- assertNotNull(result2);
- assertNotNull(result2.getReturns());
- }
-
- public void testJavaDocOnClass() throws Exception {
- builder.addJavaDoc("Hello");
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
- assertEquals("Hello", source.getClasses().get(0).getComment());
- }
-
- public void testJavaDocSpiradiclyOnManyClasses() throws Exception {
-
- builder.addJavaDoc("Hello");
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- builder.addJavaDoc("World");
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("Hello", source.getClasses().get(0).getComment());
- assertNull(source.getClasses().get(1).getComment());
- assertEquals("World", source.getClasses().get(2).getComment());
- }
-
- public void testJavaDocOnMethod() throws Exception {
- builder.beginClass(new ClassDef());
-
- builder.addJavaDoc("Hello");
- builder.beginMethod();
- builder.endMethod(new MethodDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertNull(source.getClasses().get(0).getComment());
- assertEquals("Hello", source.getClasses().get(0).getMethods().get(0).getComment());
- }
-
- public void testJavaDocOnField() throws Exception {
- builder.beginClass(new ClassDef());
-
- builder.addJavaDoc("Hello");
- builder.beginField(new FieldDef());
- builder.endField();
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertNull(source.getClasses().get(0).getComment());
- assertEquals("Hello", source.getClasses().get(0).getFields().get(0).getComment());
- }
-
- public void testJavaDocOnMethodsAndFields() throws Exception {
- builder.addJavaDoc("Thing");
- builder.beginClass(new ClassDef());
-
- builder.beginField(new FieldDef());// f0
- builder.endField();
-
- builder.addJavaDoc("Hello");
- builder.beginMethod();
- builder.endMethod(new MethodDef());//m0
-
- builder.addJavaDoc("Hello field");
- builder.beginField(new FieldDef());//f1
- builder.endField();
-
- builder.beginMethod();
- builder.endMethod(new MethodDef());//m1
-
- builder.addJavaDoc("World");
- builder.beginMethod();
- builder.endMethod(new MethodDef());//m2
-
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("Thing", source.getClasses().get(0).getComment());
- assertNull(source.getClasses().get(0).getFields().get(0).getComment());
- assertEquals("Hello field", source.getClasses().get(0).getFields().get(1).getComment());
- assertEquals("Hello", source.getClasses().get(0).getMethods().get(0).getComment());
- assertNull(source.getClasses().get(0).getMethods().get(1).getComment());
- assertEquals("World", source.getClasses().get(0).getMethods().get(2).getComment());
- }
-
- public void testDocletTag() throws Exception {
- builder.addJavaDoc("Hello");
- builder.addJavaDocTag(new TagDef("cheese", "is good"));
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("Hello", source.getClasses().get(0).getComment());
- assertEquals(1, source.getClasses().get(0).getTags().size());
-
- verify( docletTagFactory ).createDocletTag( eq("cheese"), eq("is good"), isA( JavaClass.class ), eq(-1) );
- verifyNoMoreInteractions( docletTagFactory );
-
-// assertEquals("cheese", source.getClasses().get(0).getTags().get(0).getName());
-// assertEquals("is good", source.getClasses().get(0).getTags().get(0).getValue());
- }
-
- public void testDocletTagWithNoComment() throws Exception {
- builder.addJavaDoc(""); // parser will always call this method to signify start of javadoc
- builder.addJavaDocTag(new TagDef("cheese", "is good"));
- builder.beginClass(new ClassDef());
-
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("", source.getClasses().get(0).getComment());
- assertEquals(1, source.getClasses().get(0).getTags().size());
-
- verify( docletTagFactory ).createDocletTag( eq("cheese"), eq("is good"), isA( JavaClass.class ), eq(-1) );
- verifyNoMoreInteractions( docletTagFactory );
-
-// assertEquals("cheese", source.getClasses().get(0).getTags().get(0).getName());
-// assertEquals("is good", source.getClasses().get(0).getTags().get(0).getValue());
- }
-
- public void testMultipleDocletTags() throws Exception {
- builder.addJavaDoc("Hello");
- builder.addJavaDocTag(new TagDef("cheese", "is good"));
- builder.addJavaDocTag(new TagDef("food", "is great"));
- builder.addJavaDocTag(new TagDef("chairs", "are boring"));
- builder.beginClass(new ClassDef());
-
- builder.endClass();
-
- JavaSource source = builder.getSource();
-
- assertEquals("Hello", source.getClasses().get(0).getComment());
- assertEquals(3, source.getClasses().get(0).getTags().size());
-
- verify( docletTagFactory ).createDocletTag( eq("cheese"), eq("is good"), isA( JavaClass.class ), eq(-1) );
- verify( docletTagFactory ).createDocletTag( eq("food"), eq("is great"), isA( JavaClass.class ), eq(-1) );
- verify( docletTagFactory ).createDocletTag( eq("chairs"), eq("are boring"), isA( JavaClass.class ), eq(-1) );
- verifyNoMoreInteractions( docletTagFactory );
-
-// assertEquals("cheese", source.getClasses().get(0).getTags().get(0).getName());
-// assertEquals("is good", source.getClasses().get(0).getTags().get(0).getValue());
-// assertEquals("food", source.getClasses().get(0).getTags().get(1).getName());
-// assertEquals("is great", source.getClasses().get(0).getTags().get(1).getValue());
-// assertEquals("chairs", source.getClasses().get(0).getTags().get(2).getName());
-// assertEquals("are boring", source.getClasses().get(0).getTags().get(2).getValue());
- }
-
- public void testDocletTagsOnMethodsAndFields() throws Exception {
- builder.addJavaDoc("");
- builder.addJavaDocTag(new TagDef("cheese", "is good"));
- builder.beginClass(new ClassDef());
-
- builder.addJavaDoc("");
- builder.addJavaDocTag(new TagDef("food", "is great"));
- builder.beginMethod();
- builder.endMethod(new MethodDef());
-
- builder.addJavaDoc("");
- builder.addJavaDocTag(new TagDef("chairs", "are boring"));
- builder.beginField(new FieldDef());
- builder.endField();
- builder.endClass();
-
- verify( docletTagFactory ).createDocletTag( eq("cheese"), eq("is good"), isA( JavaClass.class ), eq(-1) );
- verify( docletTagFactory ).createDocletTag( eq("food"), eq("is great"), isA( JavaMethod.class ), eq(-1) );
- verify( docletTagFactory ).createDocletTag( eq("chairs"), eq("are boring"), isA( JavaField.class ), eq(-1) );
- verifyNoMoreInteractions( docletTagFactory );
-
-// assertEquals("cheese", source.getClasses().get(0).getTags().get(0).getName());
-// assertEquals("is good", source.getClasses().get(0).getTags().get(0).getValue());
-// assertEquals("food", source.getClasses().get(0).getMethods().get(0).getTags().get(0).getName());
-// assertEquals("is great", source.getClasses().get(0).getMethods().get(0).getTags().get(0).getValue());
-// assertEquals("chairs", source.getClasses().get(0).getFields().get(0).getTags().get(0).getName());
-// assertEquals("are boring", source.getClasses().get(0).getFields().get(0).getTags().get(0).getValue());
- }
-
- public void testRetrieveJavaSource() throws Exception {
- builder.beginClass(new ClassDef());
- builder.endClass();
-
- JavaSource source = builder.getSource();
- assertNotNull(source);
- }
-
- public void testJavaSourceClassCount() throws Exception {
- builder.beginClass(new ClassDef());
- builder.endClass();
- builder.beginClass(new ClassDef());
- builder.endClass();
- builder.beginClass(new ClassDef());
- builder.endClass();
- JavaSource result = builder.getSource();
- assertEquals(3, result.getClasses().size());
- }
-
- public void testJavaSourceNoPackage() throws Exception {
- JavaSource result = builder.getSource();
- assertNull(result.getPackage());
- }
-
- public void testJavaSourceWithPackage() throws Exception {
- builder.addPackage(new PackageDef("com.blah.thing"));
- JavaSource result = builder.getSource();
- assertEquals("com.blah.thing", result.getPackage().getName());
- }
-
- public void testJavaSourceNoImports() throws Exception {
- JavaSource result = builder.getSource();
- assertEquals(0, result.getImports().size());
- }
-
- public void testJavaSourceOneImport() throws Exception {
- builder.addImport("com.blah.Thing");
- JavaSource result = builder.getSource();
- assertEquals(1, result.getImports().size());
- assertEquals("com.blah.Thing", result.getImports().get(0));
- }
-
- public void testJavaSourceMultipleImports() throws Exception {
- builder.addImport("com.blah.Thing");
- builder.addImport("java.util.List");
- builder.addImport("org.apache.*");
- JavaSource result = builder.getSource();
- assertEquals(3, result.getImports().size());
- assertEquals("com.blah.Thing", result.getImports().get(0));
- assertEquals("java.util.List", result.getImports().get(1));
- assertEquals("org.apache.*", result.getImports().get(2));
- }
-
- public void testStaticInitializers() throws Exception
- {
- builder.beginClass( new ClassDef( "Foo" ) );
- builder.addInitializer( new InitDef( "//test", true ) );
- builder.addInitializer( new InitDef( null, true ) );
- builder.endClass();
- JavaClass cls = builder.getSource().getClassByName( "Foo" );
- assertEquals( 2, cls.getInitializers().size() );
- assertEquals( "//test", cls.getInitializers().get( 0 ).getBlockContent() );
- assertTrue( cls.getInitializers().get( 0 ).isStatic() );
- assertEquals( null, cls.getInitializers().get( 1 ).getBlockContent() );
- assertTrue(cls.getInitializers().get( 0 ).isStatic() );
- }
-
- public void testInstanceInitializers() throws Exception
- {
- builder.beginClass( new ClassDef( "Foo" ) );
- builder.addInitializer( new InitDef( "//test", false ) );
- builder.addInitializer( new InitDef( null, false ) );
- builder.endClass();
- JavaClass cls = builder.getSource().getClassByName( "Foo" );
- assertEquals( 2, cls.getInitializers().size() );
- assertEquals( "//test", cls.getInitializers().get( 0 ).getBlockContent() );
- assertFalse( cls.getInitializers().get( 0 ).isStatic() );
- assertEquals( null, cls.getInitializers().get( 1 ).getBlockContent() );
- assertFalse( cls.getInitializers().get( 0 ).isStatic() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java b/src/test/java/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java
deleted file mode 100644
index 7c585cb..0000000
--- a/src/test/java/com/thoughtworks/qdox/directorywalker/DirectoryScannerTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.util.List;
-
-import org.junit.Test;
-
-public class DirectoryScannerTest
-{
-
- private File newMockFile( String name )
- {
- return newMockFile( name, false );
- }
-
- private File newMockFile( String name, boolean isDirectory )
- {
- File result = mock( File.class );
- when( result.getName() ).thenReturn( name );
- when( result.isDirectory() ).thenReturn( isDirectory );
- return result;
- }
-
- @Test
- public void testSingleDirectory()
- {
- File rootDir = newMockFile( "root", true );
- {
- File blahTxt = newMockFile( "blah.txt" );
- File fooTxt = newMockFile( "foo.txt" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { blahTxt, fooTxt, pigJava } );
- }
-
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- List<File> files = scanner.scan();
- assertEquals( 3, files.size() );
- assertEquals( "blah.txt", files.get( 0 ).getName() );
- assertEquals( "foo.txt", files.get( 1 ).getName() );
- assertEquals( "pig.java", files.get( 2 ).getName() );
- }
-
- @Test
- public void testDirectoryWithSubdir()
- {
- File rootDir = newMockFile( "root", true );
- {
- File subDir = newMockFile( "subdir", true );
- {
- File child1Txt = newMockFile( "child1.txt" );
- File child2Txt = newMockFile( "child2.txt" );
-
- when( subDir.listFiles() ).thenReturn( new File[] { child1Txt, child2Txt } );
- }
- File fooTxt = newMockFile( "foo.txt" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { subDir, fooTxt, pigJava } );
- }
-
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- List<File> files = scanner.scan();
- assertEquals( 4, files.size() );
- assertEquals( "child1.txt", files.get( 0 ).getName() );
- assertEquals( "child2.txt", files.get( 1 ).getName() );
- assertEquals( "foo.txt", files.get( 2 ).getName() );
- assertEquals( "pig.java", files.get( 3 ).getName() );
- }
-
- @Test
- public void testDirectoryWithSubdirWithSubdir()
- {
- File rootDir = newMockFile( "root", true );
- {
- File subDir1 = newMockFile( "subdir", true );
- {
- File subDir2 = newMockFile( "subdir2", true );
- {
- File grandChild1Txt = newMockFile( "grandChild1.txt" );
-
- when( subDir2.listFiles() ).thenReturn( new File[] { grandChild1Txt } );
- }
- File child1Txt = newMockFile( "child1.txt" );
- File child2Txt = newMockFile( "child2.txt" );
-
- when( subDir1.listFiles() ).thenReturn( new File[] { subDir2, child1Txt, child2Txt } );
-
- }
- File fooTxt = newMockFile( "foo.txt" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { subDir1, fooTxt, pigJava } );
- }
-
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- List<File> files = scanner.scan();
- assertEquals( 5, files.size() );
- assertEquals( "grandChild1.txt", files.get( 0 ).getName() );
- assertEquals( "child1.txt", files.get( 1 ).getName() );
- assertEquals( "child2.txt", files.get( 2 ).getName() );
- assertEquals( "foo.txt", files.get( 3 ).getName() );
- assertEquals( "pig.java", files.get( 4 ).getName() );
- }
-
- @Test
- public void testSuffixFilter()
- {
- File rootDir = newMockFile( "root", true );
- {
- File blahTxt = newMockFile( "blah.txt" );
- File fooJava = newMockFile( "foo.java" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { blahTxt, fooJava, pigJava } );
- }
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- scanner.addFilter( new SuffixFilter( ".java" ) );
- List<File> files = scanner.scan();
- assertEquals( 2, files.size() );
- assertEquals( "foo.java", files.get( 0 ).getName() );
- assertEquals( "pig.java", files.get( 1 ).getName() );
- }
-
- @Test
- public void testFilterCallback()
- {
- File rootDir = newMockFile( "root", true );
- {
- File blahTxt = newMockFile( "blah.txt" );
- File fooJava = newMockFile( "foo.java" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { blahTxt, fooJava, pigJava } );
- }
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- Filter mockFilter = new Filter()
- {
- public boolean filter( File file )
- {
- return file.getName().equals( "foo.java" );
- }
- };
- scanner.addFilter( mockFilter );
- List<File> files = scanner.scan();
- assertEquals( 1, files.size() );
- assertEquals( "foo.java", files.get( 0 ).getName() );
- }
-
- @Test
- public void testMultipleFilters()
- {
- File rootDir = newMockFile( "root", true );
- {
- File blahTxt = newMockFile( "blah.txt" );
- File fooJava = newMockFile( "foo.java" );
- File pigJava = newMockFile( "pig.java" );
- File fooTxt = newMockFile( "foo.txt" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { blahTxt, fooJava, pigJava, fooTxt } );
- }
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- scanner.addFilter( new SuffixFilter( ".java" ) );
- scanner.addFilter( new Filter()
- {
- public boolean filter( File file )
- {
- return file.getName().startsWith( "foo" );
- }
- } );
- List<File> files = scanner.scan();
- assertEquals( 1, files.size() );
- assertEquals( "foo.java", files.get( 0 ).getName() );
- }
-
- @Test
- public void testFileVisitor()
- {
- File rootDir = newMockFile( "root", true );
-
- File blahTxt = newMockFile( "blah.txt" );
- File fooJava = newMockFile( "foo.java" );
- File pigJava = newMockFile( "pig.java" );
-
- when( rootDir.listFiles() ).thenReturn( new File[] { blahTxt, fooJava, pigJava } );
-
- DirectoryScanner scanner = new DirectoryScanner( rootDir );
- FileVisitor visitor = mock( FileVisitor.class );
- scanner.scan( visitor );
-
- verify( visitor ).visitFile( blahTxt );
- verify( visitor ).visitFile( fooJava );
- verify( visitor ).visitFile( pigJava );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/directorywalker/SuffixFilterTest.java b/src/test/java/com/thoughtworks/qdox/directorywalker/SuffixFilterTest.java
deleted file mode 100644
index 1b262ff..0000000
--- a/src/test/java/com/thoughtworks/qdox/directorywalker/SuffixFilterTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.thoughtworks.qdox.directorywalker;
-
-import java.io.File;
-
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class SuffixFilterTest
-{
-
- @Test
- public void testNullFile()
- {
- try
- {
- new SuffixFilter( ".java" ).filter( null );
- fail( "Can't filter null" );
- }
- catch ( NullPointerException e )
- {
- }
- }
-
- @Test
- public void testNullSuffix()
- {
- try
- {
- new SuffixFilter( null ).filter( new File( "test.java" ) );
- fail( "Can't filter without a suffix" );
- }
- catch ( NullPointerException e )
- {
- }
- }
-
- @Test
- public void testEmptySuffix()
- {
- assertTrue( new SuffixFilter( "" ).filter( new File("test.java") ) );
- }
-
- @Test
- public void testMatchingSuffix()
- {
- assertTrue( new SuffixFilter( ".java" ).filter( new File("test.java") ) );
- }
-
- @Test
- public void testNonMatchingSuffix()
- {
- assertFalse( new SuffixFilter( "test" ).filter( new File("test.java") ) );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/AbstractClassLibraryTest.java b/src/test/java/com/thoughtworks/qdox/library/AbstractClassLibraryTest.java
deleted file mode 100644
index c955ca4..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/AbstractClassLibraryTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-
-public class AbstractClassLibraryTest
- extends TestCase
-{
-
- private AbstractClassLibrary nullClassLibrary = new AbstractClassLibrary()
- {
- protected JavaClass resolveJavaClass( String name )
- {
- return null;
- }
- protected JavaPackage resolveJavaPackage(String name) {
- return null;
- }
- protected boolean containsClassReference( String name )
- {
- return false;
- }
- };
- private AbstractClassLibrary parentClassLibrary;
- private AbstractClassLibrary filledChildClassLibrary;
- private AbstractClassLibrary emptyChildClassLibrary;
-
- protected void setUp()
- throws Exception
- {
- parentClassLibrary = new AbstractClassLibrary()
- {
- protected JavaClass resolveJavaClass( String name )
- {
- return new DefaultJavaClass(name);
- }
- protected JavaPackage resolveJavaPackage(String name) {
- return new DefaultJavaPackage(name);
- }
- protected boolean containsClassReference( String name )
- {
- throw new RuntimeException();
- }
- };
-
- filledChildClassLibrary = new AbstractClassLibrary(parentClassLibrary)
- {
- protected JavaClass resolveJavaClass( String name )
- {
- return new DefaultJavaClass(name);
- }
- protected JavaPackage resolveJavaPackage(String name) {
- return new DefaultJavaPackage(name);
- }
- protected boolean containsClassReference( String name )
- {
- throw new RuntimeException();
- }
- };
- emptyChildClassLibrary = new AbstractClassLibrary(parentClassLibrary)
- {
- protected JavaClass resolveJavaClass( String name )
- {
- return null;
- }
- protected JavaPackage resolveJavaPackage(String name) {
- return null;
- }
- protected boolean containsClassReference( String name )
- {
- throw new RuntimeException();
- }
- };
- }
-
- /*
- * Never null, empty by default
- */
- public void testGetJavaSources() throws Exception {
- assertEquals( 0, nullClassLibrary.getJavaSources().size() );
- }
-
- /*
- * Never null, empty by default
- */
- public void testGetJavaClasses() throws Exception {
- assertEquals( 0, nullClassLibrary.getJavaClasses().size() );
- }
-
- public void testGetJavaClassByName() throws Exception {
- assertEquals( null, nullClassLibrary.getJavaClass( "java.lang.String" ) );
- assertEquals( null, nullClassLibrary.getJavaClass( "com.thoughtworks.qdox.JavaProjectBuilder" ) );
- }
-
- public void testChainedJavaClass() throws Exception {
- //prepare libraries
- parentClassLibrary.getJavaClass( "ParentClass" );
- filledChildClassLibrary.getJavaClass( "ChildClass" );
-
- Collection<JavaClass> parentClasses = parentClassLibrary.getJavaClasses( new AbstractClassLibrary.ClassLibraryFilter(){
- public boolean accept(AbstractClassLibrary classLibrary) { return true; };
- } );
- assertEquals(1, parentClasses.size());
- assertEquals( "ParentClass", parentClasses.iterator().next().getFullyQualifiedName() );
-
- Collection<JavaClass> filledClasses = filledChildClassLibrary.getJavaClasses(new AbstractClassLibrary.ClassLibraryFilter(){
- public boolean accept(AbstractClassLibrary classLibrary) { return true; };
- } );
- assertEquals(2, filledClasses.size() );
- Iterator<JavaClass> iter = filledClasses.iterator();
- assertEquals( "ChildClass", iter.next().getFullyQualifiedName() );
- assertEquals( "ParentClass", iter.next().getFullyQualifiedName() );
-
- Collection<JavaClass> emptyClasses = emptyChildClassLibrary.getJavaClasses(new AbstractClassLibrary.ClassLibraryFilter(){
- public boolean accept(AbstractClassLibrary classLibrary) { return true; };
- } );
- assertEquals(1, emptyClasses.size() );
- assertEquals( "ParentClass", emptyClasses.iterator().next().getFullyQualifiedName() );
- }
-
-
- /*
- * Never null, empty by default
- */
- public void testGetJavaPackages() throws Exception {
- assertEquals( 0, nullClassLibrary.getJavaPackages().size() );
- }
-
- public void testGetJavaPackageByName() throws Exception {
- assertEquals( null, nullClassLibrary.getJavaPackage( "java.lang" ) );
- assertEquals( null, nullClassLibrary.getJavaPackage( "com.thoughtworks" ) );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/ClassLibraryBuilderTest.java b/src/test/java/com/thoughtworks/qdox/library/ClassLibraryBuilderTest.java
deleted file mode 100644
index 318daac..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/ClassLibraryBuilderTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-import java.io.ByteArrayInputStream;
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-public abstract class ClassLibraryBuilderTest
- extends TestCase
-{
-
- protected abstract ClassLibraryBuilder getClassLibraryBuilder();
-
- public final void testAppendClassLoader() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- ClassLibraryBuilder result = libraryBuilder.appendClassLoader( null );
- assertSame( libraryBuilder, result );
- }
-
- public final void testAppendDefaultClassLoaders() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- ClassLibraryBuilder result = libraryBuilder.appendDefaultClassLoaders();
- assertSame( libraryBuilder, result );
- }
-
- public final void testAppendSourceFolder() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- ClassLibraryBuilder result = libraryBuilder.appendSourceFolder( null );
- assertSame( libraryBuilder, result );
- }
-
- public final void testAppendSourceInputStream() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- ClassLibraryBuilder result = libraryBuilder.appendSource( new ByteArrayInputStream( new byte[]{} ) );
- assertSame( libraryBuilder, result );
- }
-
- public final void testAppendSourceReader() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- ClassLibraryBuilder result = libraryBuilder.appendSource( new StringReader("") );
- assertSame( libraryBuilder, result );
- }
-
-// public final void testAppendSourceURL() throws Exception
-// {
-// ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
-// ClassLibraryBuilder result = libraryBuilder.appendSource( (URL) null );
-// assertSame( libraryBuilder, result );
-// }
-//
-// public final void testAppendSourceFile() throws Exception
-// {
-// ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
-// ClassLibraryBuilder result = libraryBuilder.appendSource( (File) null );
-// assertSame( libraryBuilder, result );
-// }
-
- public final void testGetClassLibrary() throws Exception
- {
- ClassLibraryBuilder libraryBuilder = getClassLibraryBuilder();
- assertNotNull( libraryBuilder.getClassLibrary() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/ClassLoaderLibraryTest.java b/src/test/java/com/thoughtworks/qdox/library/ClassLoaderLibraryTest.java
deleted file mode 100644
index 0b73387..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/ClassLoaderLibraryTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-import junit.framework.TestCase;
-
-public class ClassLoaderLibraryTest
- extends TestCase
-{
-
- private ClassLoaderLibrary classLoaderLibrary;
-
- protected void setUp()
- throws Exception
- {
- classLoaderLibrary = new ClassLoaderLibrary(null);
- }
-
- public void testNoClassLoaders() throws Exception {
- assertNull( classLoaderLibrary.getJavaClass( "java.lang.String") );
- }
-
- public void testWithClassLoader() throws Exception {
- classLoaderLibrary.addClassLoader(getClass().getClassLoader());
- assertNotNull(classLoaderLibrary.getJavaClass("java.lang.String"));
- assertNotNull(classLoaderLibrary.getJavaClass("java.util.Collection"));
- assertNull(classLoaderLibrary.getJavaClass("java.util.GoatCrusher"));
- }
-
- public void testDefaultClassLoader() throws Exception {
- classLoaderLibrary.addDefaultLoader();
- assertNotNull(classLoaderLibrary.getJavaClass( "java.lang.String"));
- assertNotNull(classLoaderLibrary.getJavaClass("java.util.Collection"));
- assertNotNull(classLoaderLibrary.getJavaClass("java.util.Map$Entry"));
- assertNull(classLoaderLibrary.getJavaClass("java.util.GoatCrusher"));
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/JavaClassContextTest.java b/src/test/java/com/thoughtworks/qdox/library/JavaClassContextTest.java
deleted file mode 100644
index 05a0e2e..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/JavaClassContextTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
-import com.thoughtworks.qdox.model.impl.DefaultJavaPackage;
-import com.thoughtworks.qdox.model.impl.DefaultJavaSource;
-
-public class JavaClassContextTest
- extends TestCase
-{
-
- private JavaClassContext context;
-
- protected void setUp()
- throws Exception
- {
- context = new JavaClassContext();
- }
-
- public void testGetClassByName() throws Exception
- {
- assertNull( context.getClassByName( null ) );
- assertNull( "a new context should be empty, not even contain java.lang.Object", context.getClassByName( "java.lang.Object" ) );
- JavaClass clazz = new DefaultJavaClass( "com.foo.Bar" );
- context.add( clazz );
- //check case sensitive
- assertNull( context.getClassByName( "com.foo.bar" ) );
- assertEquals( clazz, context.getClassByName( "com.foo.Bar" ) );
- }
-
- public void testRemoveClassByName() throws Exception
- {
- assertNull( context.removeClassByName( null ));
- assertNull( context.removeClassByName( "com.foo.Bar" ) );
- JavaClass clazz = new DefaultJavaClass( "com.foo.Bar" );
- context.add( clazz );
- //check case sensitive
- assertNull( context.getClassByName( "com.foo.bar" ) );
- assertEquals( clazz, context.removeClassByName( "com.foo.Bar" ) );
- }
-
- public void testGetClasses() throws Exception
- {
- assertNotNull( context.getClasses() );
- assertEquals( 0, context.getClasses().size() );
-
- JavaClass clazz = new DefaultJavaClass( "com.foo.Bar" );
- context.add( clazz );
- assertEquals( 1, context.getClasses().size() );
- //weird case, add same class
- JavaClass clazz_copy = new DefaultJavaClass( "com.foo.Bar" );
- context.add( clazz_copy );
- assertEquals( 1, context.getClasses().size() );
-
- context.removeClassByName( "com.foo.Bar" );
-
- assertNotNull( context.getClasses() );
- assertEquals( 0, context.getClasses().size() );
- }
-
- public void testAddJavaClass() throws Exception
- {
- JavaClass clazz = new DefaultJavaClass( "com.foo.Bar" );
- context.add( clazz );
- //check case sensitive
- assertNull( context.getClassByName( "com.foo.bar" ) );
- assertEquals( clazz, context.getClassByName( "com.foo.Bar" ) );
-
- //weird case, should never happen
- try {
- context.add( (JavaClass) null );
- }
- catch(NullPointerException npe) {}
- }
-
- public void testGetPackageByName() throws Exception
- {
- assertNull( context.getPackageByName( null ) );
- assertNull( context.getPackageByName( "java.lang" ) );
- JavaPackage pckg = new DefaultJavaPackage("com.foo");
- context.add( pckg );
- assertEquals( pckg, context.getPackageByName( "com.foo" ) );
- }
-
- public void testRemovePackageByName() throws Exception
- {
- assertNull( context.removePackageByName( null ) );
- assertNull( context.removePackageByName( "com.foo" ) );
- JavaPackage pckg = new DefaultJavaPackage("com.foo");
- context.add( pckg );
- assertEquals( pckg, context.removePackageByName( "com.foo" ) );
- }
-
- public void testAddJavaPackage() throws Exception
- {
- JavaPackage pckg = new DefaultJavaPackage("com.foo");
- context.add( pckg );
- //check case sensitive
- assertNull( context.getClassByName( "com.bar" ) );
- assertEquals( pckg, context.getPackageByName( "com.foo" ) );
-
- //null-safe
- context.add( (JavaPackage) null );
- }
-
- public void testGetPackages() throws Exception
- {
- assertNotNull( context.getPackages() );
- assertEquals( 0, context.getPackages().size() );
-
- JavaPackage pckg = new DefaultJavaPackage("com.foo");
- context.add( pckg );
- assertEquals( 1, context.getPackages().size() );
- //add same package
- JavaPackage pckg_copy = new DefaultJavaPackage("com.foo");
- context.add( pckg_copy );
- assertEquals( 1, context.getPackages().size() );
-
- context.removePackageByName( "com.foo" );
- assertNotNull( context.getPackages() );
- assertEquals( 0, context.getPackages().size() );
- }
-
- public void testAddJavaSource() throws Exception
- {
- JavaSource source = new DefaultJavaSource(null);
- context.add( source );
-
- //null-safe
- context.add( (JavaSource) null );
- }
-
- public void testGetSources() throws Exception
- {
- assertNotNull( context.getSources() );
- assertEquals( 0, context.getSources().size() );
-
- JavaSource source = new DefaultJavaSource(null);
- context.add( source );
- assertEquals( 1, context.getSources().size() );
-
- //every source is unique, just add it
- JavaSource source_copy = new DefaultJavaSource(null);
- context.add( source_copy );
- assertEquals( 2, context.getSources().size() );
- }
-
- public void testAdd() throws Exception {
- context.add(new DefaultJavaClass("com.blah.Ping"));
- context.add(new DefaultJavaClass("com.moo.Poo"));
- assertTrue(context.getClassByName("com.blah.Ping") != null );
- assertTrue(context.getClassByName("com.moo.Poo") != null);
- assertTrue(context.getClassByName("com.not.You") == null);
- }
-
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilderTest.java b/src/test/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilderTest.java
deleted file mode 100644
index 51d8bc9..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/OrderedClassLibraryBuilderTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-
-public class OrderedClassLibraryBuilderTest
- extends ClassLibraryBuilderTest
-{
- protected ClassLibraryBuilder getClassLibraryBuilder()
- {
- return new OrderedClassLibraryBuilder();
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilderTest.java b/src/test/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilderTest.java
deleted file mode 100644
index d0ecf23..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/SortedClassLibraryBuilderTest.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-public class SortedClassLibraryBuilderTest
- extends ClassLibraryBuilderTest
-{
- protected ClassLibraryBuilder getClassLibraryBuilder()
- {
- return new SortedClassLibraryBuilder();
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/library/SourceLibraryTest.java b/src/test/java/com/thoughtworks/qdox/library/SourceLibraryTest.java
deleted file mode 100644
index 87b8032..0000000
--- a/src/test/java/com/thoughtworks/qdox/library/SourceLibraryTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.thoughtworks.qdox.library;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.parser.ParseException;
-
-public class SourceLibraryTest
- extends TestCase
-{
- private SourceLibrary sourceLibrary;
-
- protected void setUp()
- throws Exception
- {
- sourceLibrary = new SourceLibrary( null );
- }
-
- protected void tearDown()
- throws Exception
- {
- deleteDir("target/test-source");
- }
-
- private File createFile(String fileName, String packageName, String className) throws Exception {
- File file = new File(fileName);
- file.getParentFile().mkdirs();
- FileWriter writer = new FileWriter(file);
- writer.write("// this file generated by JavaDocBuilderTest - feel free to delete it\n");
- writer.write("package " + packageName + ";\n\n");
- writer.write("public class " + className + " {\n\n // empty\n\n}\n");
- writer.close();
- return file;
- }
-
- private void deleteDir(String path) {
- File dir = new File(path);
- if (dir.exists()) {
- File[] children = dir.listFiles();
- for (int i = 0; i < children.length; i++) {
- File file = children[i];
- if (file.isDirectory()) {
- deleteDir(file.getAbsolutePath());
- } else {
- file.delete();
- }
- }
- dir.delete();
- }
- }
-
- //QDOX-221
- public void testClosedStream() throws Exception {
- File badFile = createFile("target/test-source/com/blah/Bad.java", "com.blah", "@%! BAD {}}}}");
- InputStream stream = new FileInputStream( badFile );
- try {
- sourceLibrary.addSource( stream );
- }
- catch(ParseException ex) {
- try {
- stream.read();
- fail("Stream should be closed");
- }
- catch(IOException ioe) {}
- }
- }
-
- //QDOX-221
- public void testClosedReader() throws Exception {
- File badFile = createFile("target/test-source/com/blah/Bad.java", "com.blah", "@%! BAD {}}}}");
- Reader reader= new FileReader( badFile );
- try {
- sourceLibrary.addSource( reader );
- }
- catch(ParseException ex) {
- try {
- reader.read();
- fail("Reader should be closed");
- }
- catch(IOException ioe) {}
- }
- }
-
- // ensure encoding is read
- public void testUTF8() throws Exception {
- File file = new File( "src/test/resources/com/thoughtworks/qdox/testdata/UTF8.java");
- sourceLibrary.setEncoding( "UTF-8" );
- JavaSource src = sourceLibrary.addSource( file );
- assertEquals("TEST-CHARS: \u00DF\u0131\u03A3\u042F\u05D0\u20AC", src.getClassByName( "UTF8" ).getComment());
- }
-
- public void testLatin1() throws Exception {
- File file = new File( "src/test/resources/com/thoughtworks/qdox/testdata/Latin1.java");
- sourceLibrary.setEncoding( "ISO-8859-1" );
- JavaSource src = sourceLibrary.addSource( file );
- assertEquals("TEST-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", src.getClassByName( "Latin1" ).getComment());
- }
-
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java
deleted file mode 100644
index 471d473..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaClassTest.java
+++ /dev/null
@@ -1,883 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public abstract class JavaClassTest<C extends JavaClass> {
-
- private C cls;
- private JavaSource src;
-
- //contructors
- public abstract C newJavaClass();
- public abstract C newJavaClass(String name);
-
- //setters
- public abstract void setClasses(C clazz, List<JavaClass> innerClazz);
- public abstract void setComment(C clazz, String comment);
- public abstract void setDeclaringClass( C clazz, JavaClass declaringClazz );
- public abstract void setEnum(C clazz, boolean isEnum);
- public abstract void setFields(C clazz, List<JavaField> fields);
- public abstract void setImplementz(C clazz, List<JavaClass> implementz);
- public abstract void setInterface(C clazz, boolean isInterface);
- public abstract void setMethods(C clazz, List<JavaMethod> method);
- public abstract void setModifiers(C clazz, List<String> modifiers);
- public abstract void setName(C clazz, String name);
- public abstract void setPackage(C clazz, JavaPackage pckg);
- public abstract void setSuperClass(C clazz, JavaType type);
- public abstract void setSource( C clazz, JavaSource source );
-
- public JavaPackage newJavaPackage(String name) {
- JavaPackage result = mock(JavaPackage.class);
- when(result.getName()).thenReturn( name );
- return result;
- }
-
- public JavaParameter newJavaParameter(JavaType type, String name) {
- return newJavaParameter( type, name, false );
- }
-
- public JavaParameter newJavaParameter(JavaType type, String name, boolean varArgs)
- {
- JavaParameter result = mock(JavaParameter.class);
- when( result.getType()).thenReturn( type );
- when( result.getName()).thenReturn( name );
- when( result.isVarArgs()).thenReturn( varArgs );
- return result;
- }
-
- public abstract JavaSource newJavaSource();
-
- public JavaType newType( String fullname )
- {
- JavaType result = mock( JavaType.class );
- when( result.getFullyQualifiedName() ).thenReturn( fullname );
- when( result.getValue() ).thenReturn( fullname.replace( '$', '.' ) );
- when( result.getCanonicalName() ).thenReturn( fullname.replace( '$', '.' ) );
- when( result.getGenericCanonicalName() ).thenReturn( fullname.replace( '$', '.' ) );
- return result;
- }
-
- public abstract void setPackage(JavaSource source, JavaPackage pckg);
-
- public abstract void addClass(JavaSource source, JavaClass clazz);
-
- @Before
- public void setUp() throws Exception {
- src = newJavaSource();
- cls = newJavaClass();
- addClass(src, cls);
- }
-
- @Test
- public void testGetCodeBlockSimpleClass() throws Exception {
- setName(cls, "MyClass");
- String expected = ""
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockSimpleInterface() throws Exception {
- setName(cls, "MyClass");
- setInterface(cls, true);
- String expected = ""
- + "interface MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockSimpleEnum() throws Exception {
- setName(cls, "MyEnum");
- setEnum(cls, true);
- String expected = ""
- + "enum MyEnum {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassExtends() throws Exception {
- setName(cls, "MyClass");
- setSuperClass(cls, newType("SuperClass"));
- String expected = ""
- + "class MyClass extends SuperClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockInterfaceExtends() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface"}));
- setInterface(cls, true);
- String expected = ""
- + "interface MyClass extends SomeInterface {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockInterfaceExtendsTwo() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface", "AnotherInterface"}));
- setInterface(cls, true);
- String expected = ""
- + "interface MyClass extends SomeInterface, AnotherInterface {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockInterfaceExtendsThree() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface", "AnotherInterface", "Thingy"}));
- setInterface(cls, true);
- String expected = ""
- + "interface MyClass extends SomeInterface, AnotherInterface, Thingy {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassImplements() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface"}));
- String expected = ""
- + "class MyClass implements SomeInterface {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassImplementsTwo() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface", "AnotherInterface", "Xx"}));
- String expected = ""
- + "class MyClass implements SomeInterface, AnotherInterface, Xx {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassImplementsAndExtends() throws Exception {
- setName(cls, "MyClass");
- setImplementz(cls, type(new String[]{"SomeInterface", "AnotherInterface", "Xx"}));
- setSuperClass(cls, newType("SubMarine"));
- String expected = ""
- + "class MyClass extends SubMarine implements SomeInterface, AnotherInterface, Xx {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockModifers() throws Exception {
- setName(cls, "MyClass");
- setModifiers(cls, Arrays.asList(new String[]{"public", "final"}));
- String expected = ""
- + "public final class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockModifersProtectionAlwaysFirst() throws Exception {
- setName(cls, "MyClass");
- setModifiers(cls, Arrays.asList(new String[]{"final", "public"}));
- String expected = ""
- + "public final class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
-
- setModifiers(cls, Arrays.asList(new String[]{"abstract", "protected"}));
- expected = ""
- + "protected abstract class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithOneMethod() throws Exception {
- setName(cls, "MyClass");
- JavaMethod mth = mock(JavaMethod.class);
- when(mth.getName()).thenReturn( "doStuff" );
- JavaType voidType = newType("void");
- when(mth.getReturnType()).thenReturn( voidType );
-
- setMethods(cls, Collections.singletonList( mth ));
- String expected = ""
- + "class MyClass {\n"
- + "\n"
- + "\tvoid doStuff();\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithThreeMethods() throws Exception {
- setName(cls, "MyClass");
- List<JavaMethod> methods = new ArrayList<JavaMethod>();
- {
- JavaMethod mth = mock(JavaMethod.class);
- when(mth.getName()).thenReturn( "doStuff" );
- JavaType voidType = newType( "void" );
- when(mth.getReturnType()).thenReturn( voidType );
- methods.add(mth);
- }
-
- {
- JavaMethod mth = mock(JavaMethod.class);
- when(mth.getName()).thenReturn( "somethingElse" );
- JavaType gooseType = newType("Goose");
- when(mth.getReturnType()).thenReturn( gooseType );
- methods.add(mth);
- }
-
- {
- JavaMethod mth = mock(JavaMethod.class);
- when(mth.getName()).thenReturn( "eat" );
- JavaType voidType = newType("void");
- when(mth.getReturnType()).thenReturn( voidType );
- methods.add(mth);
- }
- setMethods( cls, methods );
-
- String expected = ""
- + "class MyClass {\n"
- + "\n"
- + "\tvoid doStuff();\n"
- + "\n"
- + "\tGoose somethingElse();\n"
- + "\n"
- + "\tvoid eat();\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithTwoFields() throws Exception {
- setName(cls, "MyClass");
- List<JavaField> fields = new ArrayList<JavaField>();
- {
- JavaField fld = mock( JavaField.class );
- when(fld.getName()).thenReturn( "count" );
- JavaClass intType = newJavaClass("int");
- when(fld.getType()).thenReturn( intType );
- when(fld.getDeclaringClass()).thenReturn( cls );
- fields.add( fld );
- }
-
- {
- JavaField fld = mock( JavaField.class );
- when(fld.getName()).thenReturn( "thing" );
- JavaClass stringType = newJavaClass( "String" );
- when(fld.getType()).thenReturn( stringType );
- when(fld.getModifiers()).thenReturn( Collections.singletonList( "public" ) );
- when(fld.getDeclaringClass()).thenReturn( cls );
- fields.add( fld );
- }
- setFields( cls, fields );
-
- String expected = ""
- + "class MyClass {\n"
- + "\n"
- + "\tint count;\n"
- + "\n"
- + "\tpublic String thing;\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithInnerClass() throws Exception {
- setName(cls, "Outer");
- JavaClass innerClass = mock( JavaClass.class );
- when( innerClass.getName() ).thenReturn( "Inner" );
- setClasses(cls, Collections.singletonList( innerClass ) );
-
- String expected = ""
- + "class Outer {\n"
- + "\n"
- + "\tclass Inner {\n"
- + "\n"
- + "\t}\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithInnerEnum() throws Exception {
- setName(cls, "Outer");
- JavaClass innerEnum = mock( JavaClass.class );
- when( innerEnum.getName() ).thenReturn( "Inner" );
- when( innerEnum.isEnum() ).thenReturn( true );
- setClasses(cls, Collections.singletonList( innerEnum ) );
-
- String expected = ""
- + "class Outer {\n"
- + "\n"
- + "\tenum Inner {\n"
- + "\n"
- + "\t}\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockEnumWithInnerClass() throws Exception {
- setName(cls, "Outer");
- setEnum(cls, true);
- JavaClass innerClass = mock( JavaClass.class );
- when( innerClass.getName() ).thenReturn( "Inner" );
- setClasses(cls, Collections.singletonList( innerClass ) );
-
- String expected = ""
- + "enum Outer {\n"
- + "\n"
- + "\tclass Inner {\n"
- + "\n"
- + "\t}\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithComment() throws Exception {
- setName(cls, "MyClass");
- setComment(cls, "Hello World");
-
- String expected = ""
- + "/**\n"
- + " * Hello World\n"
- + " */\n"
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockClassWithIndentedCommentsForFieldAndMethod() throws Exception {
- setName(cls, "MyClass");
- setComment(cls, "Hello World");
-
- JavaMethod mth = mock(JavaMethod.class);
- when(mth.getName()).thenReturn( "thingy" );
- JavaClass stringType = newJavaClass( "String" );
- when(mth.getReturnType()).thenReturn( stringType );
- when(mth.getComment()).thenReturn( "Hello Method" );
- setMethods( cls, Collections.singletonList( mth ) );
-
- JavaField fld = mock(JavaField.class);
- when(fld.getType()).thenReturn( stringType );
- when(fld.getName()).thenReturn( "thing" );
- when(fld.getComment()).thenReturn( "Hello Field" );
- when(fld.getDeclaringClass()).thenReturn( cls );
- setFields( cls, Collections.singletonList( fld ) );
-
- String expected = ""
- + "/**\n"
- + " * Hello World\n"
- + " */\n"
- + "class MyClass {\n"
- + "\n"
- + "\t/**\n"
- + "\t * Hello Field\n"
- + "\t */\n"
- + "\tString thing;\n"
- + "\n"
- + "\t/**\n"
- + "\t * Hello Method\n"
- + "\t */\n"
- + "\tString thingy();\n"
- + "\n"
- + "}\n";
- assertEquals(expected, cls.getCodeBlock());
- }
-
- @Test
- public void testIsPublic()
- {
- assertTrue( !cls.isPublic() );
-
- setModifiers( cls, Arrays.asList( new String[] { "public" } ) );
- assertTrue( cls.isPublic() );
- }
-
- @Test
- public void testIsProtected()
- {
- assertTrue( !cls.isProtected() );
-
- setModifiers( cls, Arrays.asList( new String[] { "protected" } ) );
- assertTrue( cls.isProtected() );
- }
-
- @Test
- public void testIsPrivate()
- {
- assertTrue( !cls.isPrivate() );
-
- setModifiers( cls, Arrays.asList( new String[] { "private" } ) );
- assertTrue( cls.isPrivate() );
- }
-
- @Test
- public void testIsAbstract()
- {
- assertTrue( !cls.isAbstract() );
-
- setModifiers( cls, Arrays.asList( new String[] { "abstract" } ) );
- assertTrue( cls.isAbstract() );
- }
-
- @Test
- public void testIsFinal()
- {
- assertTrue( !cls.isFinal() );
-
- setModifiers( cls, Arrays.asList( new String[] { "final" } ) );
- assertTrue( cls.isFinal() );
- }
-
- @Test
- public void testIsStatic()
- {
- assertTrue( !cls.isStatic() );
-
- setModifiers( cls, Arrays.asList( new String[] { "static" } ) );
- assertTrue( cls.isStatic() );
- }
-
- @Test
- public void testIsVoid()
- {
- setName( cls, "void" );
- assertTrue( cls.isVoid() );
-
- setName( cls, "Void" );
- assertFalse( cls.isVoid() );
- }
-
- @Test
- public void testQualifiedType() throws Exception {
- setPackage(src, newJavaPackage("com.thoughtworks.qdox"));
-
- setName(cls, "MyClass");
-
- assertEquals("MyClass", cls.getName());
- assertEquals("com.thoughtworks.qdox", cls.getPackage().getName());
- assertEquals("com.thoughtworks.qdox", cls.getPackageName());
- assertEquals("com.thoughtworks.qdox.MyClass",
- cls.getFullyQualifiedName());
- }
-
- @Test
- public void testGetClassNamePrefix() {
- setPackage(src, newJavaPackage("foo.bar"));
- setName(cls, "Stanley");
- assertEquals("foo.bar.Stanley$", cls.getClassNamePrefix());
- }
-
- @Test
- public void testInnerClass() throws Exception
- {
- JavaPackage pkg = mock(JavaPackage.class);
- when(pkg.getName()).thenReturn( "foo.bar" );
-
- JavaClass outer = mock( JavaClass.class );
- when( outer.getName() ).thenReturn( "Outer" );
- when( outer.getPackageName() ).thenReturn( "foo.bar" );
- when( outer.getClassNamePrefix() ).thenReturn( "foo.bar.Outer$" );
-
- C inner = newJavaClass();
- setName(inner, "Inner");
- setPackage( inner, pkg );
- setDeclaringClass( inner, outer );
-
-
- assertEquals("Inner", inner.getName());
- assertEquals("foo.bar", inner.getPackageName());
- assertEquals("foo.bar.Outer$Inner", inner.getFullyQualifiedName());
-
- assertEquals("Inner", inner.getName());
- assertEquals("foo.bar", inner.getPackageName());
- assertEquals("foo.bar.Outer$Inner", inner.getFullyQualifiedName());
- }
-
- @Test
- public void testDefaultPackageClass() {
- setPackage(src, null);
- setName(cls, "DefaultPackageClass");
-
- assertEquals("", src.getClasses().get(0).getPackageName());
- assertEquals("DefaultPackageClass", src.getClasses().get(0).getFullyQualifiedName());
- }
-
- @Test
- public void testDefaultClassSuperclass() throws Exception {
- setName(cls, "MyClass");
- assertEquals("java.lang.Object", cls.getSuperClass().getValue());
- setSuperClass(cls, newType("x.X"));
- assertEquals("x.X", cls.getSuperClass().getValue());
- }
-
- @Test
- public void testDefaultInterfaceSuperclass() throws Exception {
- setName(cls, "MyInterface");
- setInterface(cls, true);
- assertNull(cls.getSuperClass());
- setSuperClass(cls, newType("x.X"));
- assertEquals("x.X", cls.getSuperClass().getValue());
- }
-
- @Test
- public void testEnumSuperclass() throws Exception {
- setName(cls, "MyEnum");
- setEnum(cls, true);
- assertEquals("java.lang.Enum", cls.getSuperClass().getValue());
- }
-
- @Test
- public void testEnumCannotExtendAnythingElse() throws Exception {
- setName(cls, "MyEnum");
- setEnum(cls, true);
- try {
- setSuperClass(cls, newType("x.X"));
- fail("expected an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("enums cannot extend other classes", e.getMessage());
- }
- }
-
- @Test
- public void testGetEnumConstants() {
- setName( cls, "MyEnum" );
- assertNull( cls.getEnumConstants() );
-
- setEnum( cls, true );
- assertNotNull( cls.getEnumConstants() );
- assertEquals( 0, cls.getEnumConstants().size() );
-
- List<JavaField> fields = new ArrayList<JavaField>();
- JavaField nonEnumConstantField = mock(JavaField.class);
- fields.add( nonEnumConstantField );
- setFields( cls, fields );
- assertEquals( 0, cls.getEnumConstants().size() );
-
- JavaField enumConstantField = mock(JavaField.class);
- when ( enumConstantField.isEnumConstant() ).thenReturn( true );
- fields.add( enumConstantField );
- setFields( cls, fields );
- assertEquals( 1, cls.getEnumConstants().size() );
- }
-
- @Test
- public void testGetEnumConstantByName() {
- setName( cls, "MyEnum" );
-
- List<JavaField> fields = new ArrayList<JavaField>();
- JavaField nonEnumConstantField = mock(JavaField.class);
- when ( nonEnumConstantField.getName() ).thenReturn( "nonEnumField" );
- fields.add( nonEnumConstantField );
- setFields( cls, fields );
- assertEquals( null, cls.getEnumConstantByName( "nonEnumField" ) );
-
- JavaField enumConstantField = mock(JavaField.class);
- when ( enumConstantField.isEnumConstant() ).thenReturn( true );
- when ( enumConstantField.getName() ).thenReturn( "enumField" );
- fields.add( enumConstantField );
- setFields( cls, fields );
- assertEquals( enumConstantField, cls.getEnumConstantByName( "enumField" ) );
- }
-
- @Test
- public void testCanGetFieldByName() throws Exception {
- JavaField fredField = mock(JavaField.class);
- when(fredField.getName()).thenReturn( "fred" );
- JavaClass intType = newJavaClass("int");
- when(fredField.getType()).thenReturn( intType );
- when(fredField.getDeclaringClass()).thenReturn( cls );
- setFields( cls, Collections.singletonList( fredField ) );
-
- assertEquals(fredField, cls.getFieldByName("fred"));
- assertEquals(null, cls.getFieldByName("barney"));
- }
-
- @Test
- public void testCanGetMethodBySignature() {
- final String methodName = "doStuff";
- final List<JavaType> parameterTypes = javaType(new String[]{"int", "double"});
- JavaMethod method = mock(JavaMethod.class);
- when(method.getName()).thenReturn(methodName);
- //both signatureMatches-methods are allowed
- when(method.signatureMatches( "doStuff", parameterTypes )).thenReturn( true );
- when(method.signatureMatches( "doStuff", parameterTypes, false )).thenReturn( true );
- setMethods(cls, Collections.singletonList( method ));
-
- assertSame(
- method,
- cls.getMethodBySignature("doStuff", parameterTypes)
- );
- assertEquals(
- null,
- cls.getMethodBySignature("doStuff", Collections.EMPTY_LIST)
- );
- assertEquals(
- null,
- cls.getMethodBySignature("sitIdlyBy", parameterTypes)
- );
- }
-
- @Test
- public void testCanGetInnerClassByName() throws Exception
- {
- JavaClass innerClass = mock( JavaClass.class );
- when( innerClass.getName() ).thenReturn( "Inner" );
- setClasses(cls, Collections.singletonList( innerClass ) );
-
- assertEquals(innerClass, cls.getNestedClassByName("Inner"));
- assertEquals(null, cls.getNestedClassByName("Bogus"));
- }
-
- @Test
- public void testResolveTypeDefaultsToParentScope()
- throws Exception
- {
- setName( cls, "X" );
- assertEquals( "int", cls.resolveType( "int" ) );
- assertEquals( "int", cls.resolveCanonicalName( "int" ) );
- assertEquals( "int", cls.resolveFullyQualifiedName( "int" ) );
- }
-
- @Test
- public void testResolveTypeInnerClass() throws Exception {
- setPackage(src, newJavaPackage("p"));
- setName(cls, "X");
- JavaClass innerClass = mock(JavaClass.class );
- when( innerClass.getName() ).thenReturn( "DogFood" );
- when( innerClass.getFullyQualifiedName() ).thenReturn( "p.X$DogFood" );
- setClasses(cls, Collections.singletonList( innerClass ) );
-
- assertEquals("p.X$DogFood", cls.resolveType("DogFood"));
- assertEquals(null, cls.resolveType("Food"));
- }
-
- @Test
- public void testGetBeanPropertiesReturnsEmptyForEmptyClass() throws Exception {
- assertEquals(0, cls.getBeanProperties().size());
- }
-
- @Test
- public void testGetBeanPropertiesFindsSimpleProperties() throws Exception {
- List<JavaMethod> methods = new ArrayList<JavaMethod>();
- JavaMethod setFooMethod = mock(JavaMethod.class);
- when(setFooMethod.getName()).thenReturn( "setFoo" );
- JavaClass intType = newJavaClass("int");
- List<JavaParameter> parameters = Collections.singletonList( newJavaParameter( intType, "foo" ) );
- when(setFooMethod.getParameters()).thenReturn( parameters );
- when(setFooMethod.isPropertyMutator()).thenReturn( true );
- when(setFooMethod.getPropertyName()).thenReturn( "foo" );
- when(setFooMethod.getPropertyType()).thenReturn( intType );
- methods.add(setFooMethod);
-
- JavaMethod getFooMethod = mock(JavaMethod.class);
- when(getFooMethod.getName()).thenReturn( "getFoo" );
- when(getFooMethod.getReturnType()).thenReturn( intType );
- when(getFooMethod.isPropertyAccessor()).thenReturn( true );
- when(getFooMethod.getPropertyName()).thenReturn( "foo" );
- when(getFooMethod.getPropertyType()).thenReturn( intType );
- methods.add( getFooMethod );
-
- setMethods( cls, methods );
-
- assertEquals(1, cls.getBeanProperties().size());
- BeanProperty fooProp = cls.getBeanProperties().get(0);
- assertEquals("foo", fooProp.getName());
- assertEquals(intType, fooProp.getType());
- assertEquals(getFooMethod, fooProp.getAccessor());
- assertEquals(setFooMethod, fooProp.getMutator());
- }
-
- @Test
- public void testToStringClass() {
- setName(cls, "com.MyClass");
- assertEquals("class com.MyClass", cls.toString());
- }
-
- @Test
- public void testInnerClassToString() throws Exception {
- JavaClass jOuterClass = mock(JavaClass.class);
- when(jOuterClass.getClassNamePrefix()).thenReturn( "com.thoughtworks.qdox.model.OuterClass$" );
-
- C jInnerClass = newJavaClass( "InnerClass" );
- setDeclaringClass( jInnerClass, jOuterClass );
-
- assertEquals("class com.thoughtworks.qdox.model.OuterClass$InnerClass", jInnerClass.toString());
- }
-
- @Test
- public void testInnerClassType() {
- JavaClass jOuterClass = mock(JavaClass.class);
- when(jOuterClass.getClassNamePrefix()).thenReturn("com.thoughtworks.qdox.model.OuterClass$");
-
- C jInnerClass = newJavaClass("InnerClass");
- setDeclaringClass( jInnerClass, jOuterClass );
-
- assertEquals( "com.thoughtworks.qdox.model.OuterClass$InnerClass", jInnerClass.getFullyQualifiedName() );
- }
-
- @Test
- public void testInnerInterfaceToString() {
- JavaClass jOuterClass = mock(JavaClass.class);
- when(jOuterClass.getClassNamePrefix()).thenReturn( "com.thoughtworks.qdox.model.OuterClass$");
-
- C jInnerInterface = newJavaClass( "InnerInterface" );
- setInterface( jInnerInterface, true );
- setDeclaringClass( jInnerInterface, jOuterClass );
-
- assertEquals("interface com.thoughtworks.qdox.model.OuterClass$InnerInterface", jInnerInterface.toString());
- }
-
- @Test
- public void testToStringInterface() {
- setName(cls, "com.MyClass");
- setInterface(cls, true);
- assertEquals("interface com.MyClass", cls.toString());
- }
-
- @Test
- public void testEquals()
- {
- C c1 = newJavaClass( "java.util.String" );
- C c2 = newJavaClass( "java.util.String" );
- C c3 = newJavaClass( "org.mycompany.String" );
-
- assertEquals( c1, c1 );
- assertThat( c1, not( new Object() ) );
- assertEquals( c1, c2 );
- assertThat( c1, not( c3 ) );
- }
-
- /**
- * @codehaus.jira QDOX-59
- */
- @Test
- public void testBeanPropertiesAreReturnedInOrderDeclared() {
- List<JavaMethod> methods = new ArrayList<JavaMethod>();
- JavaMethod getFooMethod = mock(JavaMethod.class);
- when(getFooMethod.getName()).thenReturn( "getFoo" );
- JavaClass intType = newJavaClass("int");
- when(getFooMethod.getReturnType()).thenReturn( intType );
- when(getFooMethod.getPropertyName()).thenReturn( "foo" );
- when(getFooMethod.isPropertyAccessor()).thenReturn( true );
- methods.add( getFooMethod );
-
- JavaMethod getBarMethod = mock(JavaMethod.class);
- when(getBarMethod.getName()).thenReturn( "getBar" );
- when(getBarMethod.getReturnType()).thenReturn( intType );
- when(getBarMethod.getPropertyName()).thenReturn( "bar" );
- when(getBarMethod.isPropertyAccessor()).thenReturn( true );
- methods.add( getBarMethod );
-
- JavaMethod getMcFNordMethod = mock(JavaMethod.class);
- when(getMcFNordMethod.getName()).thenReturn( "getMcFnord" );
- JavaClass stringType = newJavaClass("String");
- when(getMcFNordMethod.getReturnType()).thenReturn( stringType );
- when(getMcFNordMethod.getPropertyName()).thenReturn( "mcFnord" );
- when(getMcFNordMethod.isPropertyAccessor()).thenReturn( true );
- methods.add( getMcFNordMethod );
- setMethods( cls, methods );
-
- List<BeanProperty> properties = cls.getBeanProperties();
- assertEquals(3, properties.size());
- assertEquals("foo", properties.get(0).getName());
- assertEquals("bar", properties.get(1).getName());
- assertEquals("mcFnord", properties.get(2).getName());
- }
-
- private List<JavaClass> type(String[] typeNames) {
- List<JavaClass> result = new LinkedList<JavaClass>();
- for (int i = 0; i < typeNames.length; i++) {
- result.add(newJavaClass(typeNames[i]));
- }
- return result;
- }
-
- private List<JavaType> javaType(String[] typeNames)
- {
- return new LinkedList<JavaType>(type(typeNames));
- }
-
- // QDOX-201
- @Test
- public void testGetVarArgMethodSignature() {
- List<JavaMethod> methods = new ArrayList<JavaMethod>();
- JavaMethod simpleMethod = mock(JavaMethod.class);
-
- JavaType stringType = newType( "String" );
- //both signatureMatches-methods are allowed
- when(simpleMethod.signatureMatches( "doSomething", Collections.singletonList( stringType ) )).thenReturn( true );
- when(simpleMethod.signatureMatches( "doSomething", Collections.singletonList( stringType ), false )).thenReturn( true );
- methods.add( simpleMethod );
-
- JavaMethod varArgMethod = mock(JavaMethod.class);
- when(varArgMethod.signatureMatches( "doSomething", Collections.singletonList( stringType ), true )).thenReturn( true );
- methods.add( varArgMethod );
-
- setMethods( cls, methods );
-
- assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ) ) );
- assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), false ) );
- assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), true ) );
- assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), false, false ) );
- assertEquals( varArgMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), false, true ) );
- assertEquals( simpleMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), true, false ) );
- assertEquals( varArgMethod, cls.getMethodBySignature( "doSomething", Collections.singletonList( stringType ), true, true ) );
- }
-
- @Ignore
- public void testJavaLangObjectAsDefaultSuperClass() throws Exception {
- //up untill now this succeeds, because other tests have already set the static value of OBJECT
- //running this test alone make it fail, so it's not a proper test.
- //should be fixed if we can get rid of the Type-visibility
- JavaClass clazz = newJavaClass( "a.b.Sample" );
- assertEquals( "java.lang.Object", clazz.getSuperJavaClass().getFullyQualifiedName() );
- assertEquals( "java.lang.Object", clazz.getSuperClass().getFullyQualifiedName() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java
deleted file mode 100644
index 56e4804..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaConstructorTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.hamcrest.core.IsNot.*;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.Test;
-
-public abstract class JavaConstructorTest<D extends JavaConstructor>
-{
-
- protected abstract D newJavaConstructor( String string );
-
- protected abstract void setModifiers( D constructor, List<String> asList );
- protected abstract void setParentClass( D constructor, JavaClass cls );
- protected abstract void setParameters( D constructor, List<JavaParameter> singletonList );
-
- private JavaType newType( String name )
- {
- return newType( name, 0 );
- }
-
- private JavaType newType( String name, int dimensions )
- {
- JavaType result = mock(JavaType.class);
- when(result.getFullyQualifiedName()).thenReturn( name );
- return result;
-
- }
-
- private JavaParameter newJavaParameter( JavaType type, String name )
- {
- JavaParameter result = mock( JavaParameter.class );
- when( result.getType() ).thenReturn( type );
- when( result.getName() ).thenReturn( name );
- return result;
- }
-
- @Test
- public void testGetCodeBlockConstructor() throws Exception {
- D constructor = newJavaConstructor( "Blah" );
- setModifiers(constructor, Arrays.asList(new String[]{"public"}));
- assertEquals("public Blah() {\n}\n", constructor.getCodeBlock());
- }
-
-
- @Test
- public void testConstructorToString() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getFullyQualifiedName()).thenReturn( "a.b.Executor" );
- D constructor = newJavaConstructor( "Executor" );
- setParentClass( constructor, cls );
- assertEquals("a.b.Executor()", constructor.toString());
- }
-
- @Test
- public void testConstructorParameterTypes() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getFullyQualifiedName()).thenReturn( "a.b.Executor" );
- D constructor = newJavaConstructor( "Executor" );
- setParameters( constructor, Collections.singletonList( newJavaParameter( newType("a.b.C"), "param" ) ));
- setParentClass( constructor, cls );
- assertEquals("a.b.C", constructor.getParameterTypes().get(0).getFullyQualifiedName());
- }
-
- @Test
- public void testHashCode() throws Exception {
- assertTrue( "hashCode should never resolve to 0", newJavaConstructor( "" ).hashCode() != 0 );
-
- D c1 = newJavaConstructor( "Thong" );
- D c2 = newJavaConstructor( "Thong" );
-
- assertEquals(c1.hashCode(), c2.hashCode());
- }
-
- @Test
- public void testEquals()
- throws Exception
- {
- D c1 = newJavaConstructor( "thing" );
- D c2 = newJavaConstructor( "Thong" );
- D c3 = newJavaConstructor( "Thong" );
-
- D c4 = newJavaConstructor( "Thong" );
- setParentClass( c4, mock( JavaClass.class ) );
-
- assertEquals( c1, c1 );
- assertThat( c1, not( new Object() ) );
- assertThat( c1, not(c2) );
- assertEquals( c2, c3 );
- assertThat( c3, not(c4) );
- }
-
- @Test
- public void testIsPublic()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isPublic() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "public" } ) );
- assertTrue( cstr.isPublic() );
- }
-
- @Test
- public void testIsProtected()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isProtected() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "protected" } ) );
- assertTrue( cstr.isProtected() );
- }
-
- @Test
- public void testIsPrivate()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isPrivate() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "private" } ) );
- assertTrue( cstr.isPrivate() );
- }
-
- @Test
- public void testIsAbstract()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isAbstract() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "abstract" } ) );
- assertTrue( cstr.isAbstract() );
- }
-
- @Test
- public void testIsFinal()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isFinal() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "final" } ) );
- assertTrue( cstr.isFinal() );
- }
-
- @Test
- public void testIsNavite()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isNative() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "native" } ) );
- assertTrue( cstr.isNative() );
- }
-
- @Test
- public void testIsStatic()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isStatic() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "static" } ) );
- assertTrue( cstr.isStatic() );
- }
-
- @Test
- public void testIsStrict()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isStrictfp() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "strictfp" } ) );
- assertTrue( cstr.isStrictfp() );
- }
-
- @Test
- public void testIsSynchronized()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isSynchronized() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "synchronized" } ) );
- assertTrue( cstr.isSynchronized() );
- }
-
- @Test
- public void testIsTransient()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isTransient() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "transient" } ) );
- assertTrue( cstr.isTransient() );
- }
-
- @Test
- public void testIsVolatile()
- {
- D cstr = newJavaConstructor( "Constructor" );
- assertTrue( !cstr.isVolatile() );
-
- setModifiers( cstr, Arrays.asList( new String[] { "volatile" } ) );
- assertTrue( cstr.isVolatile() );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java
deleted file mode 100644
index aff3cb5..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaFieldTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.mockito.Mockito.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public abstract class JavaFieldTest<F extends JavaField> extends TestCase {
-
- public JavaFieldTest(String s) {
- super(s);
- }
-
- //constructors
- public abstract F newJavaField();
- public abstract F newJavaField(JavaClass type, String name);
-
- //setters
- public abstract void setComment(F fld, String comment);
- public abstract void setInitializationExpression(F fld, String expression);
- public abstract void setModifiers(F fld, List<String> modifiers);
- public abstract void setName(F fld, String name);
- public abstract void setType(F fld, JavaClass type);
- public abstract void setDeclaringClass(F fld, JavaClass cls);
-
- public JavaClass newJavaClass( String fullname )
- {
- return newJavaClass( fullname, 0 );
- }
-
- public JavaClass newJavaClass(String fullname, int dimensions)
- {
- JavaClass result = mock( JavaClass.class );
- when( result.getFullyQualifiedName() ).thenReturn( fullname );
- String canonicalName = fullname.replace( '$', '.' );
- when( result.getValue() ).thenReturn( canonicalName );
- when( result.getDimensions()).thenReturn( dimensions );
- for(int i = 0; i < dimensions; i++)
- {
- canonicalName += "[]";
- }
- when( result.getCanonicalName() ).thenReturn( canonicalName );
- when( result.getGenericCanonicalName() ).thenReturn( canonicalName );
- return result;
- }
-
- public void testHashCode()
- {
- assertTrue( "hashCode should never resolve to 0", newJavaField().hashCode() != 0 );
- }
-
- public void testGetCodeBlock() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- assertEquals("int count;\n", fld.getCodeBlock());
- }
-
- public void testGetCodeBlockWithModifiers() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- setModifiers(fld, Arrays.asList(new String[]{"public", "final"}));
- assertEquals("public final int count;\n", fld.getCodeBlock());
- }
-
- public void testGetCodeBlockWithComment() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- setComment(fld, "Hello");
- String expected = ""
- + "/**\n"
- + " * Hello\n"
- + " */\n"
- + "int count;\n";
- assertEquals(expected, fld.getCodeBlock());
- }
-
- public void testGetCodeBlock1dArray() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int", 1));
- String expected = "int[] count;\n";
- assertEquals(expected, fld.getCodeBlock());
- }
-
- public void testGetCodeBlock2dArray() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int", 2));
- String expected = "int[][] count;\n";
- assertEquals(expected, fld.getCodeBlock());
- }
-
- public void testGetCodeBlockWithValue() throws Exception {
- F fld = newJavaField();
- setName(fld, "stuff");
- setType(fld, newJavaClass("String"));
- setInitializationExpression(fld, "STUFF + getThing()");
- String expected = "String stuff = STUFF + getThing();\n";
- assertEquals(expected, fld.getCodeBlock());
- }
-
- public void testShouldReturnFieldNameForCallSignature() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- setModifiers(fld, Arrays.asList(new String[]{"public", "final"}));
- assertEquals("count", fld.getCallSignature());
- }
-
- public void testShouldReturnProperDeclarationSignatureWithModifiers() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- setModifiers(fld, Arrays.asList(new String[]{"public", "final"}));
- assertEquals("public final int count", fld.getDeclarationSignature(true));
- }
-
- public void testShouldReturnProperDeclarationSignatureWithoutModifiers() throws Exception {
- F fld = newJavaField();
- setName(fld, "count");
- setType(fld, newJavaClass("int"));
- setModifiers(fld, Arrays.asList(new String[]{"public", "final"}));
- assertEquals("int count", fld.getDeclarationSignature(false));
- }
-
- public void testToStringThreadMIN_PRIORITY() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getFullyQualifiedName()).thenReturn( "java.lang.Thread" );
- F fld = newJavaField(newJavaClass("int"), "MIN_PRIORITY");
- setModifiers(fld, Arrays.asList(new String[] {"final", "static", "public"}));
- setDeclaringClass( fld, cls );
- assertEquals("public static final int java.lang.Thread.MIN_PRIORITY", fld.toString());
- }
-
- public void testToStringFieldDescriptorFd() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getFullyQualifiedName()).thenReturn("java.io.FileDescriptor");
- F fld = newJavaField(newJavaClass("int"), "fd");
- setModifiers(fld, Arrays.asList(new String[]{"private"}));
- setDeclaringClass( fld, cls );
- assertEquals("private int java.io.FileDescriptor.fd", fld.toString());
- }
-
- public void testIsPublic()
- {
- F fld = newJavaField();
- assertTrue( !fld.isPublic() );
-
- setModifiers( fld, Arrays.asList( new String[] { "public" } ) );
- assertTrue( fld.isPublic() );
- }
-
- public void testIsProtected()
- {
- F fld = newJavaField();
- assertTrue( !fld.isProtected() );
-
- setModifiers( fld, Arrays.asList( new String[] { "protected" } ) );
- assertTrue( fld.isProtected() );
- }
-
- public void testIsPrivate()
- {
- F fld = newJavaField();
- assertTrue( !fld.isPrivate() );
-
- setModifiers( fld, Arrays.asList( new String[] { "private" } ) );
- assertTrue( fld.isPrivate() );
- }
-
- public void testIsAbstract()
- {
- F fld = newJavaField();
- assertTrue( !fld.isAbstract() );
-
- setModifiers( fld, Arrays.asList( new String[] { "abstract" } ) );
- assertTrue( fld.isAbstract() );
- }
-
- public void testIsFinal()
- {
- F fld = newJavaField();
- assertTrue( !fld.isFinal() );
-
- setModifiers( fld, Arrays.asList( new String[] { "final" } ) );
- assertTrue( fld.isFinal() );
- }
-
- public void testIsNavite()
- {
- F fld = newJavaField();
- assertTrue( !fld.isNative() );
-
- setModifiers( fld, Arrays.asList( new String[] { "native" } ) );
- assertTrue( fld.isNative() );
- }
-
- public void testIsStatic()
- {
- F fld = newJavaField();
- assertTrue( !fld.isStatic() );
-
- setModifiers( fld, Arrays.asList( new String[] { "static" } ) );
- assertTrue( fld.isStatic() );
- }
-
- public void testIsStrict()
- {
- F fld = newJavaField();
- assertTrue( !fld.isStrictfp() );
-
- setModifiers( fld, Arrays.asList( new String[] { "strictfp" } ) );
- assertTrue( fld.isStrictfp() );
- }
-
- public void testIsSynchronized()
- {
- F fld = newJavaField();
- assertTrue( !fld.isSynchronized() );
-
- setModifiers( fld, Arrays.asList( new String[] { "synchronized" } ) );
- assertTrue( fld.isSynchronized() );
- }
-
- public void testIsTransient()
- {
- F fld = newJavaField();
- assertTrue( !fld.isTransient() );
-
- setModifiers( fld, Arrays.asList( new String[] { "transient" } ) );
- assertTrue( fld.isTransient() );
- }
-
- public void testIsVolatile()
- {
- F fld = newJavaField();
- assertTrue( !fld.isVolatile() );
-
- setModifiers( fld, Arrays.asList( new String[] { "volatile" } ) );
- assertTrue( fld.isVolatile() );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java
deleted file mode 100644
index 11f4fa8..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaMethodTest.java
+++ /dev/null
@@ -1,580 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.model.impl.DefaultJavaType;
-
-public abstract class JavaMethodTest<M extends JavaMethod> {
-
- private M mth;
-
- //constructors
- public abstract M newJavaMethod();
- public abstract M newJavaMethod(JavaClass returns, String name);
-
- //setters
- public abstract void setExceptions(M method, List<JavaClass> exceptions);
- public abstract void setComment(M method, String comment);
- public abstract void setName(M method, String name);
- public abstract void setModifiers(M method, List<String> modifiers);
- public abstract void setParameters(M method, List<JavaParameter> parameters);
- public abstract void setParentClass(M method, JavaClass clazz);
- public abstract void setReturns(M method, JavaClass type);
- public abstract void setSourceCode(M method, String code);
-
- public JavaParameter newJavaParameter(JavaClass type, String name)
- {
- return newJavaParameter( type, name, false );
- }
-
- public JavaParameter newJavaParameter(JavaClass type, String name, boolean varArgs)
- {
- JavaParameter result = mock(JavaParameter.class);
- when( result.getType() ).thenReturn( type );
- String genericCanonicalName = type.getGenericCanonicalName();
- when( result.getGenericCanonicalName() ).thenReturn( genericCanonicalName );
- when( result.getName() ).thenReturn( name );
- when( result.isVarArgs() ).thenReturn( varArgs );
- return result;
- }
-
- public JavaClass newType( String fullname )
- {
- return newType( fullname, 0 );
- }
-
- public JavaClass newType(String fullname, int dimensions)
- {
- JavaClass result = mock( JavaClass.class );
- when( result.getFullyQualifiedName() ).thenReturn( fullname );
- String canonicalName = fullname.replace( '$', '.' );
- when( result.getValue() ).thenReturn( canonicalName );
- when( result.getDimensions()).thenReturn( dimensions );
- for(int i = 0; i < dimensions; i++)
- {
- canonicalName += "[]";
- }
- when( result.getCanonicalName() ).thenReturn( canonicalName );
- when( result.getGenericCanonicalName() ).thenReturn( canonicalName );
- return result;
- }
-
- @Before
- public void setUp() throws Exception {
- mth = newJavaMethod();
- }
-
- private void createSignatureTestMethod() {
- setName(mth, "blah");
- setModifiers(mth, Arrays.asList(new String[]{"protected", "final"}));
- setReturns(mth, newType("void"));
- setExceptions(mth, Arrays.asList( new JavaClass[] {
- newType("FishException"),
- newType("FruitException"),
- } ));
- setParameters( mth, Arrays.asList( newJavaParameter(newType("int"), "count"), newJavaParameter(newType("MyThing"), "t") ) );
- }
-
-
- @Test
- public void testDeclarationSignatureWithModifiers() {
- createSignatureTestMethod();
- String signature = mth.getDeclarationSignature(true);
- assertEquals("protected final void blah(int count, MyThing t) throws FishException, FruitException", signature);
- }
-
- @Test
- public void testDeclarationSignatureWithoutModifiers() {
- createSignatureTestMethod();
- String signature = mth.getDeclarationSignature(false);
- assertEquals("void blah(int count, MyThing t) throws FishException, FruitException", signature);
- }
-
- @Test
- public void testCallSignature() {
- createSignatureTestMethod();
- String signature = mth.getCallSignature();
- assertEquals("blah(count, t)", signature);
- }
-
-// public void testSignatureWithVarArgs() throws Exception {
-// mth.setName( "method" );
-// mth.addParameter( new JavaParameter(new Type("java.lang.String"), "param", true) );
-// assertEquals( mth, clazz.getMethodBySignature( "method", new Type[] { new Type("java.lang.String", true)} ) );
-// }
-
- @Test
- public void testGetCodeBlockSimple() throws Exception {
- setName(mth, "doSomething");
- setReturns(mth, newType("java.lang.String"));
- assertEquals("java.lang.String doSomething();\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockOneParam() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setParameters( mth, Collections.singletonList( newJavaParameter(newType("String"), "thingy") ) );
- assertEquals("void blah(String thingy);\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockTwoParams() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setParameters(mth, Arrays.asList( newJavaParameter(newType("int"), "count"), newJavaParameter(newType("MyThing"), "t") ) );
- assertEquals("void blah(int count, MyThing t);\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockThreeParams() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setParameters(mth, Arrays.asList( newJavaParameter(newType("int"), "count"), newJavaParameter(newType("MyThing"), "t"), newJavaParameter(newType("java.lang.Meat"), "beef") ));
- assertEquals("void blah(int count, MyThing t, java.lang.Meat beef);\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockModifiersWithAccessLevelFirst() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setModifiers(mth, Arrays.asList(new String[]{"synchronized", "public", "final"}));
- assertEquals("public synchronized final void blah();\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockOneException() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setExceptions( mth, Arrays.asList( new JavaClass[] { newType( "RuntimeException" ) } ) );
- assertEquals("void blah() throws RuntimeException;\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockTwoException() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setExceptions(mth, Arrays.asList( new JavaClass[]{newType("RuntimeException"), newType("java.lang.SheepException")}));
- assertEquals("void blah() throws RuntimeException, java.lang.SheepException;\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockThreeException() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setExceptions(mth, Arrays.asList( new JavaClass[]{newType("RuntimeException"), newType("java.lang.SheepException"), newType("CowException")}));
- assertEquals("void blah() throws RuntimeException, java.lang.SheepException, CowException;\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockWithComment() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setComment(mth, "Hello");
- String expect = ""
- + "/**\n"
- + " * Hello\n"
- + " */\n"
- + "void blah();\n";
- assertEquals(expect, mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlock1dArray() throws Exception {
- setName(mth, "doSomething");
- setReturns(mth, newType("java.lang.String", 1));
- assertEquals("java.lang.String[] doSomething();\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlock2dArray() throws Exception {
- setName(mth, "doSomething");
- setReturns(mth, newType("java.lang.String", 2));
- assertEquals("java.lang.String[][] doSomething();\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockParamArray() throws Exception {
- setName(mth, "blah");
- setReturns(mth, newType("void"));
- setParameters( mth, Arrays.asList( newJavaParameter( newType("int", 2), "count"), newJavaParameter( newType("MyThing", 1), "t") ) );
- assertEquals("void blah(int[][] count, MyThing[] t);\n", mth.getCodeBlock());
- }
-
- @Test
- public void testGetCodeBlockWithBody() throws Exception {
- setName(mth, "doStuff");
- setReturns(mth, newType("java.lang.String"));
- setSourceCode(mth, " int x = 2;\n return STUFF;\n");
-
- assertEquals("" +
- "java.lang.String doStuff() {\n" +
- " int x = 2;\n" +
- " return STUFF;\n" +
- "}\n",
- mth.getCodeBlock());
- }
-
- @Test
- public void testEquals() throws Exception {
- JavaClass voidType = newType("void");
-
- setName(mth, "thing");
- setReturns(mth, voidType);
-
- M m2 = newJavaMethod();
- setName(m2, "thing");
- setReturns(m2, voidType);
-
- M m3 = newJavaMethod();
- setName(m3, "thingy");
- setReturns(m3, voidType);
-
- M m4 = newJavaMethod();
- setName(m4, "thing");
- setReturns(m4, newType("int"));
-
- M m5 = newJavaMethod();
- M m6 = newJavaMethod();
-
- M m7 = newJavaMethod();
- setReturns(m7, newType("int"));
-
- M m8 = newJavaMethod();
- setReturns(m8, newType("int"));
-// JavaClass declaringClass = mock( JavaClass.class );
-// when( declaringClass.getFullyQualifiedName() ).thenReturn( "com.foo.bar" );
- setParentClass( m8, mock( JavaClass.class ) );
-
- assertEquals(mth, mth);
- assertThat(mth, not(new Object()));
- assertEquals(mth, m2);
- assertEquals(m2, mth);
- assertThat(mth, not(m3));
- assertThat(mth, not(m4));
- assertFalse(mth.equals(null));
- assertThat( m4, not(m5) );
- assertThat( m5, not(m4) );
- assertEquals( m5, m6 );
- assertThat( m5, not(m7) );
- assertThat( m7, not(m8) );
- }
-
- @Test
- public void testEqualsWithParameters() throws Exception {
- JavaClass voidType = newType("void");
- JavaClass intArrayType = newType("int", 1);
- JavaClass stringArrayType = newType("java.lang.String", 2);
- JavaClass xArrayType = newType("X", 3);
-
- JavaParameter intArrayParam = newJavaParameter(intArrayType, "blah");
- JavaParameter stringArrayParam = newJavaParameter(stringArrayType, "thing");
- JavaParameter xArrayParameter = newJavaParameter(xArrayType, "blah");
-
- setName( mth, "thing" );
- setParameters( mth, Arrays.asList( intArrayParam, stringArrayParam, xArrayParameter ) );
- setReturns( mth, voidType );
-
- M m2 = newJavaMethod();
- setName( m2, "thing" );
- setParameters( m2, Arrays.asList( intArrayParam, stringArrayParam, xArrayParameter ) );
- setReturns( m2, voidType );
-
- M m3 = newJavaMethod();
- setName( m3, "thing" );
- setParameters( m3, Arrays.asList( intArrayParam, stringArrayParam ) );
- setReturns( m3, voidType );
-
- // dimension
- M m5 = newJavaMethod();
- setName( m5, "thing" );
- setParameters( m5,
- Arrays.asList( intArrayParam, stringArrayParam, newJavaParameter( newType( "X", 9 ), "blah" ) ) );
- setReturns( m5, voidType );
-
- assertEquals( mth, m2 );
- assertEquals( m2, mth );
- assertThat( mth, not(m3) );
- assertThat( mth, not(m5) );
- }
-
- @Test
- public void testHashCode()
- throws Exception
- {
- assertTrue( "hashCode should never resolve to 0", newJavaMethod( DefaultJavaType.VOID, "" ).hashCode() != 0 );
-
- JavaClass voidType = newType( "void" );
- JavaClass intType = newType( "int", 1 );
- JavaClass stringArrayType = newType( "java.lang.String", 2 );
- JavaClass xArrayType = newType( "X", 3 );
-
- JavaParameter intParam = newJavaParameter( intType, "blah" );
- JavaParameter stringArrayParam = newJavaParameter( stringArrayType, "thing" );
- JavaParameter xArrayParam = newJavaParameter( xArrayType, "blah" );
-
- setName( mth, "thing" );
- setParameters( mth, Arrays.asList( intParam, stringArrayParam, xArrayParam ) );
- setReturns( mth, voidType );
-
- M m2 = newJavaMethod();
- setName( m2, "thing" );
- setParameters( m2, Arrays.asList( intParam, stringArrayParam, xArrayParam ) );
- setReturns( m2, voidType );
-
- M m3 = newJavaMethod();
- setName( m3, "thing" );
- setParameters( m3, Arrays.asList( intParam, stringArrayParam ) );
- setReturns( m3, voidType );
-
- assertEquals( mth.hashCode(), m2.hashCode() );
- assertTrue( mth.hashCode() != m3.hashCode() );
- }
-
- @Test
- public void testSignatureMatches() throws Exception {
- JavaClass intType = newType("int");
- JavaClass longArrayType = newType("long", 2);
-
- setName(mth, "thing");
- setParameters(mth, Arrays.asList( newJavaParameter(intType, "x"), newJavaParameter(longArrayType, "y") ));
- setReturns(mth, newType("void"));
-
- JavaType[] correctTypes = new JavaClass[]{
- intType,
- longArrayType
- };
-
- JavaType[] wrongTypes1 = new JavaClass[]{
- newType("int", 2),
- newType("long")
- };
-
- JavaType[] wrongTypes2 = new JavaClass[]{
- intType,
- longArrayType,
- newType("double")
- };
-
- assertTrue(mth.signatureMatches("thing", Arrays.asList( correctTypes )));
- assertFalse(mth.signatureMatches("xxx", Arrays.asList( correctTypes )));
- assertFalse(mth.signatureMatches("thing", Arrays.asList( wrongTypes1 )));
- assertFalse(mth.signatureMatches("thing", Arrays.asList( wrongTypes2 )));
- }
-
- @Test
- public void testVarArgSignatureMatches() throws Exception {
- JavaClass intType = newType("int");
- JavaClass longArrayType = newType("long", 2);
-
- setName(mth, "thing");
- setParameters(mth, Arrays.asList( newJavaParameter(intType, "x"), newJavaParameter(longArrayType, "y", true) ));
- setReturns(mth, newType("void"));
-
- JavaType[] correctTypes = new JavaClass[]{
- intType,
- longArrayType
- };
-
- JavaType[] wrongTypes1 = new JavaClass[]{
- newType("int", 2),
- newType("long")
- };
-
- JavaType[] wrongTypes2 = new JavaClass[]{
- intType,
- longArrayType,
- newType("double")
- };
-
- assertTrue(mth.signatureMatches("thing", Arrays.asList( correctTypes ), true));
- assertFalse(mth.signatureMatches("thing", Arrays.asList( correctTypes ), false));
- assertFalse(mth.signatureMatches("xxx", Arrays.asList( correctTypes ), true));
- assertFalse(mth.signatureMatches("thing", Arrays.asList( wrongTypes1 ), true));
- assertFalse(mth.signatureMatches("thing", Arrays.asList( wrongTypes2 ), true));
- }
-
- @Test
- public void testParentClass() throws Exception {
- JavaClass clazz = mock(JavaClass.class);
- setParentClass( mth, clazz );
- assertSame(clazz, mth.getParentClass());
- }
-
- @Test
- public void testCanGetParameterByName() throws Exception {
- JavaParameter paramX = newJavaParameter(newType("int"), "x");
- setParameters(mth, Arrays.asList( paramX, newJavaParameter(newType("string"), "y") ));
-
- assertEquals(paramX, mth.getParameterByName("x"));
- assertEquals(null, mth.getParameterByName("z"));
- }
-
- @Test
- public void testToString() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getFullyQualifiedName()).thenReturn( "java.lang.Object" );
- M mthd = newJavaMethod(newType("boolean"),"equals");
- setParentClass(mthd, cls);
- setModifiers(mthd, Arrays.asList(new String[]{"public"}));
- setParameters(mthd, Collections.singletonList( newJavaParameter(newType("java.lang.Object"), null) ));
- assertEquals("public boolean java.lang.Object.equals(java.lang.Object)", mthd.toString());
- }
-
- @Test
- public void testIsPublic()
- {
- assertTrue( !mth.isPublic() );
-
- setModifiers( mth, Arrays.asList( new String[] { "public" } ) );
- assertTrue( mth.isPublic() );
- }
-
- @Test
- public void testIsProtected()
- {
- assertTrue( !mth.isProtected() );
-
- setModifiers( mth, Arrays.asList( new String[] { "protected" } ) );
- assertTrue( mth.isProtected() );
- }
-
- @Test
- public void testIsPrivate()
- {
- assertTrue( !mth.isPrivate() );
-
- setModifiers( mth, Arrays.asList( new String[] { "private" } ) );
- assertTrue( mth.isPrivate() );
- }
-
- @Test
- public void testIsAbstract()
- {
- assertTrue( !mth.isAbstract() );
-
- setModifiers( mth, Arrays.asList( new String[] { "abstract" } ) );
- assertTrue( mth.isAbstract() );
- }
-
- @Test
- public void testIsFinal()
- {
- assertTrue( !mth.isFinal() );
-
- setModifiers( mth, Arrays.asList( new String[] { "final" } ) );
- assertTrue( mth.isFinal() );
- }
-
- @Test
- public void testIsNavite()
- {
- assertTrue( !mth.isNative() );
-
- setModifiers( mth, Arrays.asList( new String[] { "native" } ) );
- assertTrue( mth.isNative() );
- }
-
- @Test
- public void testIsStatic()
- {
- assertTrue( !mth.isStatic() );
-
- setModifiers( mth, Arrays.asList( new String[] { "static" } ) );
- assertTrue( mth.isStatic() );
- }
-
- @Test
- public void testIsStrict()
- {
- assertTrue( !mth.isStrictfp() );
-
- setModifiers( mth, Arrays.asList( new String[] { "strictfp" } ) );
- assertTrue( mth.isStrictfp() );
- }
-
- @Test
- public void testIsSynchronized()
- {
- assertTrue( !mth.isSynchronized() );
-
- setModifiers( mth, Arrays.asList( new String[] { "synchronized" } ) );
- assertTrue( mth.isSynchronized() );
- }
-
- @Test
- public void testIsTransient()
- {
- assertTrue( !mth.isTransient() );
-
- setModifiers( mth, Arrays.asList( new String[] { "transient" } ) );
- assertTrue( mth.isTransient() );
- }
-
- @Test
- public void testIsVolatile()
- {
- assertTrue( !mth.isVolatile() );
-
- setModifiers( mth, Arrays.asList( new String[] { "volatile" } ) );
- assertTrue( mth.isVolatile() );
- }
-
- @Test
- public void testIsPropertyAccessor()
- {
- M getNameMethod = newJavaMethod( newType( "java.lang.String" ), "getName" );
- assertTrue( getNameMethod.isPropertyAccessor() );
-
- M isValidMethod = newJavaMethod( newType( "boolean" ), "isValid" );
- assertTrue( isValidMethod.isPropertyAccessor() );
-
- M getNameWithParamMethod = newJavaMethod( newType( "boolean" ), "getName" );
- setParameters( getNameWithParamMethod, Collections.singletonList( mock(JavaParameter.class) ) );
- assertFalse( getNameWithParamMethod.isPropertyAccessor() );
-
- M gettingUpMethod = newJavaMethod( newType( "java.lang.String" ), "gettingUp" );
- assertFalse( gettingUpMethod.isPropertyAccessor() );
-
- M isolatedMethod = newJavaMethod( newType( "boolean" ), "isolated" );
- assertFalse( isolatedMethod.isPropertyAccessor() );
-
- M staticGetNameMethod = newJavaMethod( newType( "java.lang.String" ), "getName" );
- setModifiers( staticGetNameMethod, Collections.singletonList( "static" ) );
- assertFalse( staticGetNameMethod.isPropertyAccessor() );
- }
-
- @Test
- public void testIsPropertyMutator()
- {
- M setNameMethod = newJavaMethod( DefaultJavaType.VOID, "setName" );
- setParameters( setNameMethod, Collections.singletonList( mock(JavaParameter.class) ) );
- assertTrue( setNameMethod.isPropertyMutator() );
-
- M setUpMethod = newJavaMethod( DefaultJavaType.VOID, "setUp" );
- assertFalse( setUpMethod.isPropertyMutator() );
-
- M settingUpMethod = newJavaMethod( DefaultJavaType.VOID, "settingUp" );
- setParameters( settingUpMethod, Collections.singletonList( mock(JavaParameter.class) ) );
- assertFalse( settingUpMethod.isPropertyMutator() );
-
- M staticSetNameMethod = newJavaMethod( DefaultJavaType.VOID, "setName" );
- setModifiers( staticSetNameMethod, Collections.singletonList( "static" ) );
- setParameters( staticSetNameMethod, Collections.singletonList( mock(JavaParameter.class) ) );
- assertFalse( staticSetNameMethod.isPropertyMutator() );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaPackageTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaPackageTest.java
deleted file mode 100644
index ce692cf..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaPackageTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public abstract class JavaPackageTest<P extends JavaPackage>
-{
-
- public abstract P newJavaPackage( String name );
-
- @Test
- public void testToStringJavaLang()
- throws Exception
- {
- P pckg = newJavaPackage( "java.lang" );
- assertEquals( "package java.lang", pckg.toString() );
- }
-
- @Test
- public void testEquals()
- throws Exception
- {
- P pckg = newJavaPackage( "java.lang" );
-
- assertTrue( pckg.equals( pckg ) );
- assertFalse( pckg.equals( null ) );
- assertFalse( pckg.equals( new Object() ) );
-
- JavaPackage mockPckg = mock( JavaPackage.class );
- when( mockPckg.getName() ).thenReturn( "java.lang" );
-
- assertTrue( pckg.equals( mockPckg ) );
- }
-
- public void testHashCode()
- {
- assertTrue( "hashCode should never resolve to 0", newJavaPackage( "" ).hashCode() != 0 );
- }
-
-
- @Test
- public void testListAccessors() throws Exception {
- P pckg = newJavaPackage( "com.foo.bar" );
- assertNotNull( pckg.getSubPackages() );
- assertEquals( 0, pckg.getSubPackages().size() );
- }
-
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaParameterTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaParameterTest.java
deleted file mode 100644
index e2c57b8..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaParameterTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.thoughtworks.qdox.model.impl.DefaultJavaType;
-
-import junit.framework.TestCase;
-
-public abstract class JavaParameterTest<P extends JavaParameter>
- extends TestCase
-{
-
- public JavaParameterTest( String s )
- {
- super( s );
- }
-
- // constructors
- protected abstract P newJavaParameter( JavaClass type, String name );
-
- protected abstract P newJavaParameter( JavaClass type, String name, boolean varArgs );
-
- // setters
- protected abstract void setMethod( P parameter, JavaMethod method );
-
- protected abstract void setConstructor( P parameter, JavaConstructor constructor );
-
- protected JavaClass newType( String typeName )
- {
- JavaClass result = mock( JavaClass.class );
- when( result.getFullyQualifiedName() ).thenReturn( typeName );
- return result;
- }
-
- public void testHashCode()
- {
- assertTrue( "hashCode should never resolve to 0", newJavaParameter( DefaultJavaType.VOID, "" ).hashCode() != 0 );
-
- P simpleParameter = newJavaParameter( DefaultJavaType.VOID, "", false );
- P varArgParameter = newJavaParameter( DefaultJavaType.VOID, "", true );
-
- assertTrue( simpleParameter.hashCode() != varArgParameter.hashCode() );
- }
-
- public void testEquals()
- {
- P simpleParameter = newJavaParameter( DefaultJavaType.VOID, "", false );
- P varArgParameter = newJavaParameter( DefaultJavaType.VOID, "", true );
- assertTrue( !simpleParameter.equals( varArgParameter ) );
-
- // name of parameter shouldn't matter
- P fooParameter = newJavaParameter( DefaultJavaType.VOID, "foo" );
- P barParameter = newJavaParameter( DefaultJavaType.VOID, "bar" );
- assertEquals( fooParameter, barParameter );
- }
-
- public void testMethodDeclarator()
- throws Exception
- {
- P p = newJavaParameter( newType( "x" ), "x" );
- assertNull( p.getDeclarator() );
-
- JavaMethod m = mock( JavaMethod.class );
- setMethod( p, m );
- assertSame( m, p.getDeclarator() );
- }
-
- public void testConstgructorDeclarator()
- throws Exception
- {
- P p = newJavaParameter( newType( "x" ), "x" );
- assertNull( p.getDeclarator() );
-
- JavaConstructor c = mock( JavaConstructor.class );
- setConstructor( p, c );
- assertSame( c, p.getDeclarator() );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaSourceTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaSourceTest.java
deleted file mode 100644
index 4ad29cb..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaSourceTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
-
-public abstract class JavaSourceTest<S extends JavaSource> extends TestCase {
-
- private S source;
-
- public JavaSourceTest(String s) {
- super(s);
- }
-
- //constructors
- public abstract S newJavaSource(ClassLibrary classLibrary);
-
- //setters
- public abstract void setClasses(S source, List<JavaClass> classes);
- public abstract void setImports(S source, List<String> imports);
- public abstract void setPackage(S source, JavaPackage pckg);
-
- public JavaPackage newJavaPackage(String name) {
- JavaPackage result = mock( JavaPackage.class );
- when( result.getName() ).thenReturn( name );
- return result;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- source = newJavaSource(new SortedClassLibraryBuilder().appendDefaultClassLoaders().getClassLibrary());
- }
-
- public void testToStringOneClass() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getName()).thenReturn( "MyClass" );
- setClasses( source, Collections.singletonList( cls ) );
- String expected = ""
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testToStringMultipleClass() throws Exception {
- List<JavaClass> classes = new ArrayList<JavaClass>();
- JavaClass cls1 = mock(JavaClass.class);
- when(cls1.getName()).thenReturn( "MyClass1" );
- classes.add( cls1 );
- JavaClass cls2 = mock(JavaClass.class);
- when(cls2.getName()).thenReturn( "MyClass2" );
- classes.add( cls2 );
- JavaClass cls3 = mock(JavaClass.class);
- when(cls3.getName()).thenReturn( "MyClass3" );
- classes.add( cls3 );
-
- setClasses( source, classes );
-
- String expected = ""
- + "class MyClass1 {\n"
- + "\n"
- + "}\n"
- + "\n"
- + "class MyClass2 {\n"
- + "\n"
- + "}\n"
- + "\n"
- + "class MyClass3 {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testToStringPackage() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getName()).thenReturn("MyClass");
-
- setClasses(source, Collections.singletonList( cls ));
- setPackage(source, newJavaPackage("com.thing"));
- String expected = ""
- + "package com.thing;\n"
- + "\n"
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testToStringImport() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getName()).thenReturn("MyClass");
- setClasses(source, Collections.singletonList( cls ));
- setImports(source, Collections.singletonList("java.util.*"));
- String expected = ""
- + "import java.util.*;\n"
- + "\n"
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testToStringMultipleImports() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getName()).thenReturn("MyClass");
- setClasses(source, Collections.singletonList( cls ));
- List<String> imports = new ArrayList<String>();
- imports.add("java.util.*");
- imports.add("com.blah.Thing");
- imports.add("xxx");
- setImports( source, imports );
- String expected = ""
- + "import java.util.*;\n"
- + "import com.blah.Thing;\n"
- + "import xxx;\n"
- + "\n"
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testToStringImportAndPackage() throws Exception {
- JavaClass cls = mock(JavaClass.class);
- when(cls.getName()).thenReturn("MyClass");
- setClasses(source, Collections.singletonList( cls ));
- setImports(source, Collections.singletonList( "java.util.*" ));
- setPackage(source, newJavaPackage("com.moo"));
- String expected = ""
- + "package com.moo;\n"
- + "\n"
- + "import java.util.*;\n"
- + "\n"
- + "class MyClass {\n"
- + "\n"
- + "}\n";
- assertEquals(expected, source.toString());
- }
-
- public void testGetClassNamePrefix() {
- assertEquals("", source.getClassNamePrefix());
- setPackage(source, newJavaPackage("foo.bar"));
- assertEquals("foo.bar.", source.getClassNamePrefix());
- }
-
- public void testResolveJavaPrimitive() throws Exception {
- List<String> imports = new ArrayList<String>();
- imports.add("bogus.int");
- imports.add("bogus.double");
- setImports( source, imports );
- String[] primitives = new String[]{
- "boolean", "byte", "char", "double",
- "float", "int", "long", "short", "void"
- };
- for (int i = 0; i < primitives.length; i++) {
- assertEquals(primitives[i], source.resolveType(primitives[i]));
- }
- }
-
- public void testDontResolveMissingClasses() throws Exception {
- assertEquals(null, source.resolveType("not.Found"));
- }
-
- public void testResolveFullyQualifiedName() throws Exception
- {
- assertNotNull( source.getJavaClassLibrary().getJavaClass( "open.Bar" ) );
- assertEquals( "open.Bar", source.resolveType( "open.Bar" ) );
- }
-
- public void testResolveFullyQualifiedImport() throws Exception {
- setImports( source, Collections.singletonList( "foo.Bar" ) );
- assertNotNull( source.getJavaClassLibrary().getJavaClass( "foo.Bar" ) );
- assertEquals( "foo.Bar", source.resolveType( "Bar" ) );
- }
-
- public void testResolveChooseFirstMatchingImport() throws Exception {
- List<String> imports = new ArrayList<String>();
- imports.add( "bogus.package.MyType" );
- imports.add( "com.thoughtworks.qdox.model.Type" );
- imports.add( "another.package.Type" );
- setImports( source, imports );
- assertNotNull( source.getJavaClassLibrary().getJavaClass( "bogus.package.MyType" ) );
- assertNotNull( source.getJavaClassLibrary().getJavaClass( "com.thoughtworks.qdox.model.Type" ) );
- assertNotNull( source.getJavaClassLibrary().getJavaClass( "another.package.Type" ) );
- assertEquals( "com.thoughtworks.qdox.model.Type", source.resolveType( "Type" ) );
- }
-
- public void testResolveSamePackage() throws Exception {
- setPackage(source, newJavaPackage("foo"));
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Bar") );
- assertEquals("foo.Bar", source.resolveType("Bar"));
- }
-
- public void testResolveFullyQualifiedTrumpsSamePackage() throws Exception {
- setPackage(source, newJavaPackage("foo"));
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Bar") );
- assertNotNull( source.getJavaClassLibrary().getJavaClass("open.Bar") );
- assertEquals("open.Bar", source.resolveType("open.Bar"));
- }
-
- public void testResolveFullyQualifiedTrumpsWildCard() throws Exception {
- List<String> imports = new ArrayList<String>();
- imports.add("bar.Bar");
- imports.add("foo.Bar");
- setImports( source, imports );
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.*") );
- assertNotNull( source.getJavaClassLibrary().getJavaClass("bar.Bar") );
- assertEquals("bar.Bar", source.resolveType("Bar"));
- }
-
- public void testResolveWildcard() throws Exception {
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Bar") );
- setImports(source, Collections.singletonList("foo.*"));
- assertEquals("foo.Bar", source.resolveType("Bar"));
- }
-
- public void testResolveJavaLangClass() throws Exception {
- assertNotNull( source.getJavaClassLibrary().getJavaClass("java.lang.System") );
- assertEquals("java.lang.System", source.resolveType("System"));
- }
-
- public void testResolveSamePackageTrumpsWildcard() throws Exception {
- List<String> imports = new ArrayList<String>();
- imports.add("com.thoughtworks.qdox.model.Type");
- imports.add("foo.*");
- setImports( source, imports );
- assertNotNull( source.getJavaClassLibrary().getJavaClass("com.thoughtworks.qdox.model.Type") );
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Type") );
- assertEquals("com.thoughtworks.qdox.model.Type", source.resolveType("Type"));
- }
-
- public void testResolveFullyQualifiedInnerClass() throws Exception {
- setPackage(source, newJavaPackage("foo"));
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Bar$Fnord") );
- assertEquals("foo.Bar$Fnord", source.resolveType("foo.Bar.Fnord"));
- }
-
- public void testResolvePartiallySpecifiedInnerClass() throws Exception {
- setPackage(source, newJavaPackage("foo"));
- setImports(source, Collections.singletonList("java.util.*"));
- assertNotNull( source.getJavaClassLibrary().getJavaClass("foo.Bar$Fnord") );
- assertEquals("foo.Bar$Fnord", source.resolveType("Bar.Fnord"));
- assertEquals("java.util.Map$Entry", source.resolveType("Map.Entry"));
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/JavaTypeTest.java b/src/test/java/com/thoughtworks/qdox/model/JavaTypeTest.java
deleted file mode 100644
index 937c884..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/JavaTypeTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.thoughtworks.qdox.model;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.core.IsNot.*;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.model.impl.DefaultJavaType;
-
-public abstract class JavaTypeTest<T extends JavaType>
-{
-
- public abstract T newType( String fullname );
-
- public abstract T newType( String fullname, int dimensions );
-
- @Test
- public void testToString()
- throws Exception
- {
- assertEquals( "int", newType( "int" ).toString() );
- assertEquals( "int[]", newType( "int", 1 ).toString() );
- assertEquals( "long[][][]", newType( "long", 3 ).toString() );
- }
-
- @Test
- public void testFullyQualifiedName()
- throws Exception
- {
- assertEquals( "int", newType( "int" ).getFullyQualifiedName() );
- assertEquals( "int[]", newType( "int", 1 ).getFullyQualifiedName() );
- assertEquals( "long[][][]", newType( "long", 3 ).getFullyQualifiedName() );
- }
-
- @Test
- public void testEquals()
- throws Exception
- {
- assertEquals( newType( "string" ), newType( "string" ) );
- assertThat( newType( "string" ), not( newType( "int" ) ) );
- assertThat( newType( "long", 1 ), not( newType( "long" ) ) );
- assertThat( newType( "long" ), not( newType( "long", 2 ) ) );
- assertFalse( newType( "int" ).equals( null ) );
- }
-
- @Test
- public void testToStringVoid()
- {
- assertEquals( "void", DefaultJavaType.VOID.toString() );
- }
-
- @Test
- public void testToStringBoolean()
- {
- assertEquals( "boolean", newType( "boolean" ).toString() );
- }
-
- @Test
- public void testToStringInt()
- {
- assertEquals( "int", newType( "int" ).toString() );
- }
-
- @Test
- public void testToStringLong()
- {
- assertEquals( "long", newType( "long" ).toString() );
- }
-
- @Test
- public void testToStringFloat()
- {
- assertEquals( "float", newType( "float" ).toString() );
- }
-
- @Test
- public void testToStringDouble()
- {
- assertEquals( "double", newType( "double" ).toString() );
- }
-
- @Test
- public void testToStringChar()
- {
- assertEquals( "char", newType( "char" ).toString() );
- }
-
- @Test
- public void testToStringByte()
- {
- assertEquals( "byte", newType( "byte" ).toString() );
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/AddTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/AddTest.java
deleted file mode 100644
index a26f896..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/AddTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class AddTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Add expr = new Add( lhs, rhs );
- assertEquals( "2 + 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Add expr = new Add( lhs, rhs );
- assertEquals( lhs + " + " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Add expr = new Add( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/AndTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/AndTest.java
deleted file mode 100644
index 106f0cd..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/AndTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class AndTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- And expr = new And( lhs, rhs );
- assertEquals( "2 & 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- And expr = new And( lhs, rhs );
- assertEquals( lhs + " & " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- And expr = new And( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/AnnotationValueListTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/AnnotationValueListTest.java
deleted file mode 100644
index ecf862c..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/AnnotationValueListTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.Test;
-
-
-public class AnnotationValueListTest
-{
-
- @Test
- public void testParameterValue_emptyList()
- {
- AnnotationValueList expr = new AnnotationValueList ( Collections.<AnnotationValue>emptyList() );
- assertEquals( Collections.<Object>emptyList(), expr.getParameterValue() );
- }
-
- @Test
- public void testToString_emptyList()
- {
- AnnotationValueList expr = new AnnotationValueList ( Collections.<AnnotationValue>emptyList() );
- assertEquals( "{}", expr.toString() );
- }
-
- @Test
- public void testParameterValue_singletonList()
- {
- AnnotationValue value= mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "2" );
- AnnotationValueList expr = new AnnotationValueList ( Collections.singletonList( value ) );
- assertEquals( Collections.singletonList( "2" ), expr.getParameterValue() );
- }
-
- @Test
- public void testToString_singletonList()
- {
- AnnotationValue value= mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "2" );
- AnnotationValueList expr = new AnnotationValueList ( Collections.singletonList( value ) );
- assertEquals( "{" + value+ "}", expr.toString() );
- }
-
- @Test
- public void testParameterValue_twoElementsList()
- {
- AnnotationValue value1 = mock( AnnotationValue.class );
- when( value1.getParameterValue() ).thenReturn( "2" );
- AnnotationValue value2 = mock( AnnotationValue.class );
- when( value2.getParameterValue() ).thenReturn( "3" );
- List<AnnotationValue> actualList = new LinkedList<AnnotationValue>();
- actualList.add( value1 );
- actualList.add( value2 );
- AnnotationValueList expr = new AnnotationValueList( actualList );
- List<String> expectedParameterValue = new LinkedList<String>();
- expectedParameterValue.add( "2" );
- expectedParameterValue.add( "3" );
- assertEquals( expectedParameterValue, expr.getParameterValue() );
- }
-
- @Test
- public void testToString_twoElementsList()
- {
- AnnotationValue value1 = mock( AnnotationValue.class );
- when( value1.getParameterValue() ).thenReturn( "2" );
- AnnotationValue value2 = mock( AnnotationValue.class );
- when( value2.getParameterValue() ).thenReturn( "3" );
- List<AnnotationValue> actualList = new LinkedList<AnnotationValue>();
- actualList.add( value1 );
- actualList.add( value2 );
- AnnotationValueList expr = new AnnotationValueList( actualList );
- List<String> expectedParameterValue = new LinkedList<String>();
- expectedParameterValue.add( "2" );
- expectedParameterValue.add( "3" );
- assertEquals( "{" + value1+ ", " + value2 + "}", expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- AnnotationValueList expr = new AnnotationValueList ( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/AssignmentTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/AssignmentTest.java
deleted file mode 100644
index 4d2bd1d..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/AssignmentTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class AssignmentTest
-{
- @Test
- public void testParameterValue()
- {
- Expression lhs = mock( Expression.class );
- Expression rhs = mock( Expression.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Assignment expr = new Assignment( lhs, ">>>=", rhs );
- assertEquals( "2 >>>= 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- Expression lhs = mock( Expression.class );
- Expression rhs = mock( Expression.class );
- Assignment expr = new Assignment( lhs, "+=",rhs );
- assertEquals( lhs + " += " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Assignment expr = new Assignment( null, null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/CastTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/CastTest.java
deleted file mode 100644
index 80fb7ba..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/CastTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.model.JavaType;
-
-public class CastTest
-{
- @Test
- public void testParameterValue()
- {
- JavaType type = mock(JavaType.class);
- AnnotationValue value = mock( AnnotationValue.class );
- when( type.getCanonicalName() ).thenReturn( "int" );
- when( value.getParameterValue() ).thenReturn( "3" );
- Cast expr = new Cast( type, value );
- assertEquals( "(int) 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- JavaType type = mock(JavaType.class);
- AnnotationValue value = mock( AnnotationValue.class );
- Cast expr = new Cast( type, value );
- assertEquals( "(" +type+ ") " + value, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Cast expr = new Cast( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/ConstantTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/ConstantTest.java
deleted file mode 100644
index 40bc074..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/ConstantTest.java
+++ /dev/null
@@ -1,280 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-
-public class ConstantTest
-{
-
- @Test
- public void testBinaryInteger() {
- assertEquals( Integer.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b0" ).getValue() );
- assertEquals( Integer.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B0" ).getValue() );
-
- assertEquals( Integer.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b00" ).getValue() );
- assertEquals( Integer.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B00" ).getValue() );
-
- assertEquals( Integer.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0b10" ).getValue() );
- assertEquals( Integer.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0B10" ).getValue() );
- }
-
- @Test
- public void testOctalInteger() {
- assertEquals( Integer.valueOf( "0", 8 ), Constant.newIntegerLiteral( "00" ).getValue() );
- assertEquals( Integer.valueOf( "0", 8 ), Constant.newIntegerLiteral( "000" ).getValue() );
- assertEquals( Integer.valueOf( "10", 8 ), Constant.newIntegerLiteral( "010" ).getValue() );
- }
-
-
- @Test
- public void testDecimalInteger() {
- assertEquals( Integer.valueOf( "0" ), Constant.newIntegerLiteral( "0" ).getValue() );
- assertEquals( Integer.valueOf( "10" ), Constant.newIntegerLiteral( "10" ).getValue() );
- }
-
- @Test
- public void testHexInteger() {
- assertEquals( Integer.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x0" ).getValue() );
- assertEquals( Integer.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X0" ).getValue() );
-
- assertEquals( Integer.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x00" ).getValue() );
- assertEquals( Integer.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X00" ).getValue() );
-
- assertEquals( Integer.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0x10" ).getValue() );
- assertEquals( Integer.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0X10" ).getValue() );
- }
-
- @Test
- public void testBinaryLong() {
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b0l" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b0L" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B0l" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B0L" ).getValue() );
-
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b00l" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0b00L" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B00l" ).getValue() );
- assertEquals( Long.valueOf( "0", 2 ), Constant.newIntegerLiteral( "0B00L" ).getValue() );
-
- assertEquals( Long.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0b10l" ).getValue() );
- assertEquals( Long.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0b10L" ).getValue() );
- assertEquals( Long.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0B10l" ).getValue() );
- assertEquals( Long.valueOf( "10", 2 ), Constant.newIntegerLiteral( "0B10L" ).getValue() );
- }
-
- @Test
- public void testOctalLong() {
- assertEquals( Long.valueOf( "0", 8 ), Constant.newIntegerLiteral( "00l" ).getValue() );
- assertEquals( Long.valueOf( "0", 8 ), Constant.newIntegerLiteral( "00L" ).getValue() );
-
- assertEquals( Long.valueOf( "0", 8 ), Constant.newIntegerLiteral( "000l" ).getValue() );
- assertEquals( Long.valueOf( "0", 8 ), Constant.newIntegerLiteral( "000L" ).getValue() );
-
- assertEquals( Long.valueOf( "10", 8 ), Constant.newIntegerLiteral( "010l" ).getValue() );
- assertEquals( Long.valueOf( "10", 8 ), Constant.newIntegerLiteral( "010L" ).getValue() );
-
- }
-
- @Test
- public void testDecimalLong() {
- assertEquals( Long.valueOf( "0" ), Constant.newIntegerLiteral( "0l" ).getValue() );
- assertEquals( Long.valueOf( "0" ), Constant.newIntegerLiteral( "0L" ).getValue() );
-
- assertEquals( Long.valueOf( "10" ), Constant.newIntegerLiteral( "10l" ).getValue() );
- assertEquals( Long.valueOf( "10" ), Constant.newIntegerLiteral( "10L" ).getValue() );
- }
-
- @Test
- public void testHexLong() {
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x0l" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X0l" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x0L" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X0L" ).getValue() );
-
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x00l" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X00l" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0x00L" ).getValue() );
- assertEquals( Long.valueOf( "0", 16 ), Constant.newIntegerLiteral( "0X00L" ).getValue() );
-
- assertEquals( Long.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0x10l" ).getValue() );
- assertEquals( Long.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0X10l" ).getValue() );
- assertEquals( Long.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0x10L" ).getValue() );
- assertEquals( Long.valueOf( "10", 16 ), Constant.newIntegerLiteral( "0X10L" ).getValue() );
- }
-
- @Test
- public void testBoolean() {
- assertEquals( Boolean.TRUE, Constant.newBooleanLiteral( "true" ).getValue() );
- assertEquals( Boolean.FALSE, Constant.newBooleanLiteral( "false" ).getValue() );
- }
-
-
- @Test
- public void testDecimalFloatingPoint() {
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.0" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.0f" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.0F" ).getValue() );
-
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "000.0" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "000.0f" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "000.0F" ).getValue() );
-
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.000" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.000f" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( "0.000F" ).getValue() );
-
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".0" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".0f" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".0F" ).getValue() );
-
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".00" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".00f" ).getValue() );
- assertEquals( Float.valueOf( "0.0" ), Constant.newFloatingPointLiteral( ".00F" ).getValue() );
-
- assertEquals( Float.valueOf( "0" ), Constant.newFloatingPointLiteral( "0f" ).getValue() );
- assertEquals( Float.valueOf( "0" ), Constant.newFloatingPointLiteral( "0F" ).getValue() );
-
- }
-
- @Test
- public void testDecimalFloatingPointWithExponent() {
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e1F" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E1F" ).getValue() );
-
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0e-1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0E-1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0e-1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0E-1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0e-1F" ).getValue() );
- assertEquals( Float.valueOf( "2.0e-1" ), Constant.newFloatingPointLiteral( "2.0E-1F" ).getValue() );
-
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e+1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E+1" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e+1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E+1f" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0e+1F" ).getValue() );
- assertEquals( Float.valueOf( "2.0e1" ), Constant.newFloatingPointLiteral( "2.0E+1F" ).getValue() );
-
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e1" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E1" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e1F" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E1F" ).getValue() );
-
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2e-1" ).getValue() );
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2E-1" ).getValue() );
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2e-1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2E-1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2e-1F" ).getValue() );
- assertEquals( Float.valueOf( ".2e-1" ), Constant.newFloatingPointLiteral( ".2E-1F" ).getValue() );
-
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e+1" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E+1" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e+1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E+1f" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2e+1F" ).getValue() );
- assertEquals( Float.valueOf( ".2e1" ), Constant.newFloatingPointLiteral( ".2E+1F" ).getValue() );
-
- assertEquals( Float.valueOf( "2e1" ), Constant.newFloatingPointLiteral( "2e1" ).getValue() );
- assertEquals( Float.valueOf( "2e1" ), Constant.newFloatingPointLiteral( "2E1" ).getValue() );
-
- assertEquals( Float.valueOf( "2e-1" ), Constant.newFloatingPointLiteral( "2e-1" ).getValue() );
- assertEquals( Float.valueOf( "2e-1" ), Constant.newFloatingPointLiteral( "2E-1" ).getValue() );
-
- assertEquals( Float.valueOf( "2e1" ), Constant.newFloatingPointLiteral( "2e+1" ).getValue() );
- assertEquals( Float.valueOf( "2e1" ), Constant.newFloatingPointLiteral( "2E+1" ).getValue() );
- }
-
- @Test
- public void testHexadecimalFloatingPoint() {
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2p-1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2p-1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2p+1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2p+1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2.p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2.p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2.p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2.p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0x2.p-1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p-1" ), Constant.newFloatingPointLiteral( "0X2.p-1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0x2.p+1F" ).getValue() );
- assertEquals( Float.valueOf( "0x2p1" ), Constant.newFloatingPointLiteral( "0X2.p+1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p1F" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0x.2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0X.2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0x.2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0X.2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0x.2p-1F" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p-1" ), Constant.newFloatingPointLiteral( "0X.2p-1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0x.2p+1F" ).getValue() );
- assertEquals( Float.valueOf( "0x.2p1" ), Constant.newFloatingPointLiteral( "0X.2p+1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p1F" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0x3.2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0X3.2p-1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0x3.2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0X3.2p-1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0x3.2p-1F" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p-1" ), Constant.newFloatingPointLiteral( "0X3.2p-1F" ).getValue() );
-
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p+1" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p+1f" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0x3.2p+1F" ).getValue() );
- assertEquals( Float.valueOf( "0x3.2p1" ), Constant.newFloatingPointLiteral( "0X3.2p+1F" ).getValue() );
-}
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/DivideTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/DivideTest.java
deleted file mode 100644
index 985d9ad..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/DivideTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class DivideTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Divide expr = new Divide( lhs, rhs );
- assertEquals( "2 / 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Divide expr = new Divide( lhs, rhs );
- assertEquals( lhs + " / " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Divide expr = new Divide( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/EqualsTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/EqualsTest.java
deleted file mode 100644
index f47b031..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/EqualsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class EqualsTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Equals expr = new Equals( lhs, rhs );
- assertEquals( "2 == 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Equals expr = new Equals( lhs, rhs );
- assertEquals( lhs + " == " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Equals expr = new Equals( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/ExclusiveOrTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/ExclusiveOrTest.java
deleted file mode 100644
index d6fa1c4..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/ExclusiveOrTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class ExclusiveOrTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- ExclusiveOr expr = new ExclusiveOr( lhs, rhs );
- assertEquals( "2 ^ 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- ExclusiveOr expr = new ExclusiveOr( lhs, rhs );
- assertEquals( lhs + " ^ " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- ExclusiveOr expr = new ExclusiveOr( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/FieldRefTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/FieldRefTest.java
deleted file mode 100644
index f4e8c32..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/FieldRefTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class FieldRefTest
-{
-
- @Test
- public void testParameterValue()
- {
- FieldRef expr = new FieldRef( "aField" );
- assertEquals( "aField", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- FieldRef expr = new FieldRef( "aField" );
- assertEquals( "aField", expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- FieldRef expr = new FieldRef( "" );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/GreaterEqualsTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/GreaterEqualsTest.java
deleted file mode 100644
index 5aced6d..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/GreaterEqualsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class GreaterEqualsTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- GreaterEquals expr = new GreaterEquals( lhs, rhs );
- assertEquals( "2 >= 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- GreaterEquals expr = new GreaterEquals( lhs, rhs );
- assertEquals( lhs + " >= " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- GreaterEquals expr = new GreaterEquals( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/GreaterThanTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/GreaterThanTest.java
deleted file mode 100644
index c0a5a89..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/GreaterThanTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class GreaterThanTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- GreaterThan expr = new GreaterThan( lhs, rhs );
- assertEquals( "2 > 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- GreaterThan expr = new GreaterThan( lhs, rhs );
- assertEquals( lhs + " > " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- GreaterThan expr = new GreaterThan( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/LessEqualsTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/LessEqualsTest.java
deleted file mode 100644
index 32cf068..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/LessEqualsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class LessEqualsTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- LessEquals expr = new LessEquals( lhs, rhs );
- assertEquals( "2 <= 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- LessEquals expr = new LessEquals( lhs, rhs );
- assertEquals( lhs + " <= " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- LessEquals expr = new LessEquals( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/LessThanTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/LessThanTest.java
deleted file mode 100644
index 636e3cd..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/LessThanTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class LessThanTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- LessThan expr = new LessThan( lhs, rhs );
- assertEquals( "2 < 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- LessThan expr = new LessThan( lhs, rhs );
- assertEquals( lhs + " < " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- LessThan expr = new LessThan( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalAndTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/LogicalAndTest.java
deleted file mode 100644
index 2c30abb..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalAndTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class LogicalAndTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- LogicalAnd expr = new LogicalAnd( lhs, rhs );
- assertEquals( "2 && 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- LogicalAnd expr = new LogicalAnd( lhs, rhs );
- assertEquals( lhs + " && " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- LogicalAnd expr = new LogicalAnd( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalNotTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/LogicalNotTest.java
deleted file mode 100644
index 6b86b53..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalNotTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class LogicalNotTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "valid" );
- LogicalNot expr = new LogicalNot( value );
- assertEquals( "!valid", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- LogicalNot expr = new LogicalNot( value );
- assertEquals( "!" + value, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- LogicalNot expr = new LogicalNot( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalOrTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/LogicalOrTest.java
deleted file mode 100644
index 1cbeaab..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/LogicalOrTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class LogicalOrTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- LogicalOr expr = new LogicalOr( lhs, rhs );
- assertEquals( "2 || 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- LogicalOr expr = new LogicalOr( lhs, rhs );
- assertEquals( lhs + " || " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- LogicalOr expr = new LogicalOr( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/MinusSignTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/MinusSignTest.java
deleted file mode 100644
index 519a5d4..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/MinusSignTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class MinusSignTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "2" );
- MinusSign expr = new MinusSign( value );
- assertEquals( "-2", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- MinusSign expr = new MinusSign( value );
- assertEquals( "-" + value, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- MinusSign expr = new MinusSign( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/MultiplyTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/MultiplyTest.java
deleted file mode 100644
index 7d2be13..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/MultiplyTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class MultiplyTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Multiply expr = new Multiply( lhs, rhs );
- assertEquals( "2 * 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Multiply expr = new Multiply( lhs, rhs );
- assertEquals( lhs + " * " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Multiply expr = new Multiply( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/NotEqualsTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/NotEqualsTest.java
deleted file mode 100644
index 8b56de0..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/NotEqualsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class NotEqualsTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- NotEquals expr = new NotEquals( lhs, rhs );
- assertEquals( "2 != 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- NotEquals expr = new NotEquals( lhs, rhs );
- assertEquals( lhs + " != " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- NotEquals expr = new NotEquals( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/NotTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/NotTest.java
deleted file mode 100644
index 523f051..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/NotTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class NotTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "valid" );
- Not expr = new Not( value );
- assertEquals( "~valid", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- Not expr = new Not( value );
- assertEquals( "~" + value, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Not expr = new Not( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/OrTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/OrTest.java
deleted file mode 100644
index 04ce6ce..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/OrTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class OrTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Or expr = new Or( lhs, rhs );
- assertEquals( "2 | 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Or expr = new Or( lhs, rhs );
- assertEquals( lhs + " | " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Or expr = new Or( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/ParenExpressionTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/ParenExpressionTest.java
deleted file mode 100644
index 652d008..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/ParenExpressionTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class ParenExpressionTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "expression" );
- ParenExpression expr = new ParenExpression( value );
- assertEquals( "(expression)", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- ParenExpression expr = new ParenExpression( value );
- assertEquals( "(" + value + ")", expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- ParenExpression expr = new ParenExpression( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/PlusSignTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/PlusSignTest.java
deleted file mode 100644
index 6436587..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/PlusSignTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class PlusSignTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "2" );
- PlusSign expr = new PlusSign( value );
- assertEquals( "+2", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- PlusSign expr = new PlusSign( value );
- assertEquals( "+" + value, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- PlusSign expr = new PlusSign( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/PostDecrementTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/PostDecrementTest.java
deleted file mode 100644
index 451bf36..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/PostDecrementTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class PostDecrementTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PostDecrement expr = new PostDecrement( value );
- assertEquals( "index--", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PostDecrement expr = new PostDecrement( value );
- assertEquals( value.toString() + "--", expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- PostDecrement expr = new PostDecrement( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/PostIncrementTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/PostIncrementTest.java
deleted file mode 100644
index ea684d4..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/PostIncrementTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class PostIncrementTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PostIncrement expr = new PostIncrement( value );
- assertEquals( "index++", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PostIncrement expr = new PostIncrement( value );
- assertEquals( value.toString() + "++", expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- PostIncrement expr = new PostIncrement( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/PreDecrementTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/PreDecrementTest.java
deleted file mode 100644
index 7c30363..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/PreDecrementTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class PreDecrementTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PreDecrement expr = new PreDecrement( value );
- assertEquals( "--index", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PreDecrement expr = new PreDecrement( value );
- assertEquals( "--" + value.toString(), expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- PreDecrement expr = new PreDecrement( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/PreIncrementTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/PreIncrementTest.java
deleted file mode 100644
index 164a9c3..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/PreIncrementTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class PreIncrementTest
-{
- @Test
- public void testParameterValue()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PreIncrement expr = new PreIncrement( value );
- assertEquals( "++index", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue value = mock( AnnotationValue.class );
- when( value.getParameterValue() ).thenReturn( "index" );
- PreIncrement expr = new PreIncrement( value );
- assertEquals( "++" + value.toString(), expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- PreIncrement expr = new PreIncrement( null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/QueryTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/QueryTest.java
deleted file mode 100644
index 6722634..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/QueryTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class QueryTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue condition = mock( AnnotationValue.class );
- AnnotationValue trueExpr = mock( AnnotationValue.class );
- AnnotationValue falseExpr = mock( AnnotationValue.class );
- when( condition.getParameterValue() ).thenReturn( "predicate" );
- when( trueExpr.getParameterValue() ).thenReturn( "consequent" );
- when( falseExpr.getParameterValue() ).thenReturn( "alternative" );
- Query expr = new Query( condition, trueExpr, falseExpr );
- assertEquals( "predicate ? consequent : alternative", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue condition = mock( AnnotationValue.class );
- AnnotationValue trueExpr = mock( AnnotationValue.class );
- AnnotationValue falseExpr = mock( AnnotationValue.class );
- Query expr = new Query( condition, trueExpr, falseExpr );
- assertEquals( condition + " ? " + trueExpr + " : " + falseExpr, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Query expr = new Query( null, null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/RemainderTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/RemainderTest.java
deleted file mode 100644
index cd61014..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/RemainderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class RemainderTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Remainder expr = new Remainder( lhs, rhs );
- assertEquals( "2 * 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Remainder expr = new Remainder( lhs, rhs );
- assertEquals( lhs + " * " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Remainder expr = new Remainder( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/ShiftLeftTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/ShiftLeftTest.java
deleted file mode 100644
index 45f6e2a..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/ShiftLeftTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class ShiftLeftTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- ShiftLeft expr = new ShiftLeft( lhs, rhs );
- assertEquals( "2 << 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- ShiftLeft expr = new ShiftLeft( lhs, rhs );
- assertEquals( lhs + " << " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- ShiftRight expr = new ShiftRight( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/ShiftRightTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/ShiftRightTest.java
deleted file mode 100644
index b8b7a60..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/ShiftRightTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-
-public class ShiftRightTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- ShiftRight expr = new ShiftRight( lhs, rhs );
- assertEquals( "2 >> 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- ShiftRight expr = new ShiftRight( lhs, rhs );
- assertEquals( lhs + " >> " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- ShiftRight expr = new ShiftRight( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/SubtractTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/SubtractTest.java
deleted file mode 100644
index 88fa372..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/SubtractTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class SubtractTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- Subtract expr = new Subtract( lhs, rhs );
- assertEquals( "2 - 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- Subtract expr = new Subtract( lhs, rhs );
- assertEquals( lhs + " - " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- Subtract expr = new Subtract( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRightTest.java b/src/test/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRightTest.java
deleted file mode 100644
index fecfdbe..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/expression/UnsignedShiftRightTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.thoughtworks.qdox.model.expression;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-
-public class UnsignedShiftRightTest
-{
-
- @Test
- public void testParameterValue()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- when( lhs.getParameterValue() ).thenReturn( "2" );
- when( rhs.getParameterValue() ).thenReturn( "3" );
- UnsignedShiftRight expr = new UnsignedShiftRight( lhs, rhs );
- assertEquals( "2 >>> 3", expr.getParameterValue() );
- }
-
- @Test
- public void testToString()
- {
- AnnotationValue lhs = mock( AnnotationValue.class );
- AnnotationValue rhs = mock( AnnotationValue.class );
- UnsignedShiftRight expr = new UnsignedShiftRight( lhs, rhs );
- assertEquals( lhs + " >>> " + rhs, expr.toString() );
- }
-
- @Test
- public void testAccept()
- {
- ExpressionVisitor visitor = mock( ExpressionVisitor.class );
- UnsignedShiftRight expr = new UnsignedShiftRight( null, null );
- Object visitResult = new Object();
- when( visitor.visit( expr ) ).thenReturn( visitResult );
- assertSame( expr.accept( visitor ), visitResult );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntityTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntityTest.java
deleted file mode 100644
index aae5d62..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/AbstractJavaEntityTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.model.DocletTag;
-
-public class AbstractJavaEntityTest {
-
- private AbstractJavaEntity newAbstractJavaEntity() {
- return new AbstractJavaEntity()
- {
- public String getCodeBlock()
- {
- return null;
- }
- };
- }
-
- @Test
- public void testGetTagsByNameMethod() throws Exception {
- AbstractBaseJavaEntity entity = newAbstractJavaEntity();
- List<DocletTag> tags = new LinkedList<DocletTag>();
-
- DocletTag monkeyIsGoodTag = mock(DocletTag.class);
- when(monkeyIsGoodTag.getName()).thenReturn( "monkey" );
- DocletTag monkeyIsFunnyTag = mock(DocletTag.class);
- when(monkeyIsFunnyTag.getName()).thenReturn( "monkey" );
- DocletTag horseNotSoMuchTag = mock(DocletTag.class);
- when(horseNotSoMuchTag.getName()).thenReturn( "horse" );
-
- tags.add(monkeyIsGoodTag);
- tags.add(monkeyIsFunnyTag);
- tags.add(horseNotSoMuchTag);
- entity.setTags(tags);
-
- assertEquals(2, entity.getTagsByName("monkey").size());
- assertEquals(1, entity.getTagsByName("horse").size());
- assertEquals(0, entity.getTagsByName("non existent tag").size());
- }
-
- @Test
- public void testGetSingleTagByName() throws Exception {
- AbstractBaseJavaEntity entity = newAbstractJavaEntity();
- List<DocletTag> tags = new LinkedList<DocletTag>();
-
- DocletTag monkeyIsGoodTag = mock(DocletTag.class);
- when(monkeyIsGoodTag.getName()).thenReturn( "monkey" );
- when(monkeyIsGoodTag.getValue()).thenReturn( "is good" );
- DocletTag monkeyIsFunnyTag = mock(DocletTag.class);
- when(monkeyIsFunnyTag.getName()).thenReturn( "monkey" );
- when(monkeyIsFunnyTag.getValue()).thenReturn( "is funny" );
- DocletTag horseNotSoMuchTag = mock(DocletTag.class);
- when(horseNotSoMuchTag.getName()).thenReturn( "horse" );
- when(horseNotSoMuchTag.getValue()).thenReturn( "not so much" );
-
- tags.add(monkeyIsGoodTag);
- tags.add(monkeyIsFunnyTag);
- tags.add(horseNotSoMuchTag);
- entity.setTags(tags);
-
- assertEquals("is good", entity.getTagByName("monkey").getValue());
- assertEquals("not so much", entity.getTagByName("horse").getValue());
- assertNull(entity.getTagByName("cow"));
-
- }
-
- @Test
- public void testPublicModifer() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers( Collections.singletonList( "public" ) );
- assertTrue( entity.isPublic() );
- }
-
- @Test
- public void testPrivateModifer() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers(Collections.singletonList( "private" ));
- assertTrue(entity.isPrivate());
- }
-
- @Test
- public void testAbstractModifer() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers(Arrays.asList(new String[]{"public", "abstract"}));
- assertTrue(entity.isAbstract());
- assertTrue(!entity.isPrivate());
- }
-
- @Test
- public void testProtectedModifer() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers(Arrays.asList(new String[]{"protected", "abstract", "synchronized", "transient"}));
- assertTrue(entity.isProtected());
- assertTrue(entity.isSynchronized());
- assertTrue(entity.isTransient());
- }
-
- @Test
- public void testStaticModifer() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers(Arrays.asList(new String[]{"public", "static", "final"}));
- assertTrue(entity.isStatic());
- assertTrue(entity.isFinal());
- }
-
- @Test
- public void testQDOX30() {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- entity.setModifiers(Arrays.asList(new String[]{"native", "volatile", "strictfp"}));
- assertTrue(entity.isNative());
- assertTrue(entity.isVolatile());
- assertTrue(entity.isStrictfp());
- }
-
- @Test
- public void testGetTagsReturnsEmptyArrayInsteadOfNull() throws Exception {
- AbstractJavaEntity entity = newAbstractJavaEntity();
- assertEquals(0, entity.getTags().size());
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassIT.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassIT.java
deleted file mode 100644
index b4bf9cf..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassIT.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.library.ClassLoaderLibrary;
-import com.thoughtworks.qdox.model.BeanProperty;
-import com.thoughtworks.qdox.model.JavaClass;
-
-public class DefaultJavaClassIT
-{
- private ClassLoaderLibrary library;
-
- @Before
- public void setUp()
- {
- library = new ClassLoaderLibrary( null );
- library.addDefaultLoader();
- }
-
- @Test
- public void testSuperJavaClass() throws Exception
- {
- JavaClass hashSetClass = library.getJavaClass( "java.util.HashSet" );
- assertTrue( hashSetClass instanceof DefaultJavaClass );
-
- JavaClass superClass = hashSetClass.getSuperJavaClass();
- assertEquals( "java.util.AbstractSet", superClass.getFullyQualifiedName() );
- assertEquals( "java.util.AbstractSet", Class.forName( "java.util.HashSet" ).getSuperclass().getName() );
- }
-
- @Test
- public void testIsAJavaClass() throws Exception
- {
- JavaClass hashSetClass = library.getJavaClass( "java.util.HashSet" );
- assertTrue( hashSetClass instanceof DefaultJavaClass );
-
- JavaClass setClass = library.getJavaClass( "java.util.Set" );
- assertTrue( hashSetClass.isA( setClass ) );
- assertTrue( hashSetClass.isA( "java.util.Set" ) );
- //watch it!! isA() is the inverse of isAssignableFrom()
- assertTrue( Class.forName( "java.util.Set" ).isAssignableFrom( Class.forName( "java.util.HashSet" ) ) );
- }
-
- @Test
- public void testDeclaringClass() throws Exception
- {
- JavaClass entryClass = library.getJavaClass( "java.util.Map$Entry" );
- assertTrue( entryClass instanceof DefaultJavaClass );
-
- assertEquals( "java.util.Map", entryClass.getDeclaringClass().getFullyQualifiedName() );
- assertEquals( "java.util.Map", Class.forName( "java.util.Map$Entry" ).getDeclaringClass().getName() );
- }
-
- @Test
- public void testDeclaredClasses() throws Exception {
- JavaClass mapClass = library.getJavaClass( "java.util.Map" );
- assertTrue( mapClass instanceof DefaultJavaClass );
-
- assertEquals( 1, mapClass.getNestedClasses().size() );
- assertEquals( "java.util.Map$Entry", mapClass.getNestedClassByName( "Entry" ).getFullyQualifiedName() );
- assertEquals( 1, Class.forName( "java.util.Map" ).getDeclaredClasses().length );
- assertEquals( "java.util.Map$Entry", Class.forName( "java.util.Map" ).getDeclaredClasses()[0].getName() );
- }
-
- @Test
- public void testBeanProperty() throws Exception
- {
- JavaClass entryClass = library.getJavaClass( "java.util.Map$Entry" );
- BeanProperty valueBean = entryClass.getBeanProperty( "value" );
- assertNotNull( valueBean );
- assertEquals( "java.lang.Object", valueBean.getType().getFullyQualifiedName() );
- assertNotNull( valueBean.getAccessor() );
- assertEquals( "public abstract java.lang.Object java.util.Map$Entry.getValue()", valueBean.getAccessor().toString() );
- assertNotNull( valueBean.getMutator() );
- assertEquals( "public abstract java.lang.Object java.util.Map$Entry.setValue(java.lang.Object)", valueBean.getMutator().toString() );
-
- BeanProperty keyBean = entryClass.getBeanProperty( "key" );
- assertNotNull( keyBean.getAccessor() );
- assertEquals( "public abstract java.lang.Object java.util.Map$Entry.getKey()", keyBean.getAccessor().toString() );
- assertNull( keyBean.getMutator() );
- }
-
- @Test
- public void testNames() throws Exception
- {
- //subclass
- JavaClass entryClass = library.getJavaClass( "java.util.Map$Entry" );
- assertTrue( entryClass instanceof DefaultJavaClass );
-
- assertEquals( "java.util.Map$Entry", entryClass.getFullyQualifiedName() );
- assertEquals( "java.util.Map$Entry", Class.forName( "java.util.Map$Entry" ).getName() );
- assertEquals( "java.util.Map.Entry", entryClass.getCanonicalName() );
- assertEquals( "java.util.Map.Entry", Class.forName( "java.util.Map$Entry" ).getCanonicalName() );
- assertEquals( "Map.Entry", entryClass.getValue() );
-
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassTest.java
deleted file mode 100644
index 2421f56..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaClassTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.library.SortedClassLibraryBuilder;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaClassTest;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaType;
-
-public class DefaultJavaClassTest
- extends JavaClassTest<DefaultJavaClass>
-{
-
- public DefaultJavaClass newJavaClass()
- {
- return new DefaultJavaClass();
- }
-
- public DefaultJavaClass newJavaClass( String name )
- {
- return new DefaultJavaClass( name );
- }
-
- public JavaSource newJavaSource()
- {
- return new DefaultJavaSource(new SortedClassLibraryBuilder().getClassLibrary());
- }
-
- // Add-methods
- public void setClasses( DefaultJavaClass clazz, List<JavaClass> innerClasses )
- {
- for( JavaClass innerClazz : innerClasses )
- {
- clazz.addClass( innerClazz );
- }
- }
-
- public void addClass( JavaSource source, JavaClass clazz )
- {
- ((DefaultJavaClass) clazz).setSource( source );
- ((DefaultJavaSource) source).addClass( clazz );
- }
-
- // Set-methods
- public void setComment( DefaultJavaClass clazz, String comment )
- {
- clazz.setComment( comment );
- }
-
- @Override
- public void setDeclaringClass( DefaultJavaClass clazz, JavaClass declaringClazz )
- {
- clazz.setParentClass( declaringClazz );
-
- }
-
- public void setEnum( DefaultJavaClass clazz, boolean isEnum )
- {
- clazz.setEnum( isEnum );
- }
-
- public void setImplementz( DefaultJavaClass clazz, List<JavaClass> implementz )
- {
- clazz.setImplementz( implementz );
- }
-
- public void setInterface( DefaultJavaClass clazz, boolean isInterface )
- {
- clazz.setInterface( isInterface );
- }
-
- public void setModifiers( DefaultJavaClass clazz, List<String> modifiers )
- {
- clazz.setModifiers( modifiers );
- }
-
- public void setName( DefaultJavaClass clazz, String name )
- {
- clazz.setName( name );
- }
-
- public void setPackage( DefaultJavaClass clazz, JavaPackage pckg )
- {
- clazz.setJavaPackage( pckg );
- }
-
- public void setPackage( JavaSource source, JavaPackage pckg )
- {
- ((DefaultJavaSource) source).setPackage( pckg );
- }
-
- public void setSuperClass( DefaultJavaClass clazz, JavaType type )
- {
- clazz.setSuperClass( type );
- }
-
- @Override
- public void setFields( DefaultJavaClass clazz, List<JavaField> fields )
- {
- for(JavaField field : fields) {
- clazz.addField( field );
- }
- }
-
- @Override
- public void setSource( DefaultJavaClass clazz, JavaSource source )
- {
- clazz.setSource( source );
- }
-
- @Override
- public void setMethods( DefaultJavaClass clazz, List<JavaMethod> methods )
- {
- for(JavaMethod method : methods) {
- clazz.addMethod( method );
- }
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructorTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructorTest.java
deleted file mode 100644
index 276b099..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaConstructorTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.mockito.Mockito.*;
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructorTest;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.impl.DefaultJavaConstructor;
-
-
-public class DefaultJavaConstructorTest extends JavaConstructorTest<DefaultJavaConstructor>
-{
-
- @Override
- protected DefaultJavaConstructor newJavaConstructor( String name )
- {
- DefaultJavaConstructor result = new DefaultJavaConstructor();
- result.setName( name );
- return result;
- }
-
- @Override
- protected void setModifiers( DefaultJavaConstructor constructor, List<String> modifiers )
- {
- constructor.setModifiers( modifiers );
-
- }
-
- @Override
- protected void setParameters( DefaultJavaConstructor constructor, List<JavaParameter> parameters )
- {
- constructor.setParameters( parameters );
- }
-
- @Override
- protected void setParentClass( DefaultJavaConstructor constructor, JavaClass parentClass )
- {
- constructor.setParentClass( parentClass );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaFieldTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaFieldTest.java
deleted file mode 100644
index c93cf23..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaFieldTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaFieldTest;
-import com.thoughtworks.qdox.model.JavaSource;
-
-public class DefaultJavaFieldTest
- extends JavaFieldTest<DefaultJavaField>
-{
-
- public DefaultJavaFieldTest( String s )
- {
- super( s );
- }
-
- @Override
- public DefaultJavaField newJavaField()
- {
- JavaSource source = new DefaultJavaSource( null );
- JavaClass javaClass = new DefaultJavaClass( source );
- DefaultJavaField result = new DefaultJavaField();
- result.setParentClass( javaClass );
- return result;
- }
-
- @Override
- public DefaultJavaField newJavaField( JavaClass type, String name )
- {
- return new DefaultJavaField( type, name );
- }
-
- @Override
- public void setComment( DefaultJavaField fld, String comment )
- {
- fld.setComment( comment );
- }
-
- @Override
- public void setInitializationExpression( DefaultJavaField fld, String expression )
- {
- fld.setInitializationExpression( expression );
- }
-
- @Override
- public void setModifiers( DefaultJavaField fld, List<String> modifiers )
- {
- fld.setModifiers( modifiers );
- }
-
- @Override
- public void setName( DefaultJavaField fld, String name )
- {
- fld.setName( name );
- }
-
- @Override
- public void setType( DefaultJavaField fld, JavaClass type )
- {
- fld.setType( type );
- }
-
- @Override
- public void setDeclaringClass( DefaultJavaField fld, JavaClass cls )
- {
- fld.setParentClass( cls );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethodTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethodTest.java
deleted file mode 100644
index 84c5ed5..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaMethodTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaMethodTest;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.impl.DefaultJavaMethod;
-
-public class DefaultJavaMethodTest
- extends JavaMethodTest<DefaultJavaMethod>
-{
-
- public DefaultJavaMethod newJavaMethod()
- {
- return new DefaultJavaMethod();
- }
-
- public DefaultJavaMethod newJavaMethod( JavaClass returns, String name )
- {
- return new DefaultJavaMethod( returns, name );
- }
-
- public void setExceptions( DefaultJavaMethod method, List<JavaClass> exceptions )
- {
- method.setExceptions( exceptions );
- }
-
- public void setComment( DefaultJavaMethod method, String comment )
- {
- method.setComment( comment );
- }
-
- public void setName( DefaultJavaMethod method, String name )
- {
- method.setName( name );
- }
-
- public void setModifiers( DefaultJavaMethod method, List<String> modifiers )
- {
- method.setModifiers( modifiers );
- }
-
- public void setReturns( DefaultJavaMethod method, JavaClass type )
- {
- method.setReturns( type );
- }
-
- public void setParentClass( DefaultJavaMethod method, JavaClass clazz )
- {
- method.setParentClass( clazz );
- }
-
- @Override
- public void setParameters( DefaultJavaMethod method, List<JavaParameter> parameters )
- {
- method.setParameters( parameters );
- }
-
- public void setSourceCode( DefaultJavaMethod method, String code )
- {
- method.setSourceCode( code );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackageTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackageTest.java
deleted file mode 100644
index c4ba43d..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaPackageTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.mockito.Mockito.*;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaPackageTest;
-
-public class DefaultJavaPackageTest extends JavaPackageTest<DefaultJavaPackage>
-{
-
- public DefaultJavaPackage newJavaPackage( String name )
- {
- DefaultJavaPackage result = new DefaultJavaPackage( name );
- result.setClassLibrary( mock(ClassLibrary.class) );
- return result;
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterTest.java
deleted file mode 100644
index 71a9494..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaParameterTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaConstructor;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameterTest;
-import com.thoughtworks.qdox.model.impl.DefaultJavaParameter;
-
-public class DefaultJavaParameterTest extends JavaParameterTest<DefaultJavaParameter>
-{
-
- public DefaultJavaParameterTest( String s )
- {
- super( s );
- }
-
- @Override
- protected DefaultJavaParameter newJavaParameter( JavaClass type, String name )
- {
- return new DefaultJavaParameter( type, name );
- }
-
- @Override
- protected DefaultJavaParameter newJavaParameter( JavaClass type, String name, boolean varArgs )
- {
- return new DefaultJavaParameter( type, name, varArgs );
- }
-
- @Override
- protected void setMethod( DefaultJavaParameter parameter, JavaMethod method )
- {
- parameter.setDeclarator( method );
- }
-
- @Override
- protected void setConstructor( DefaultJavaParameter parameter, JavaConstructor constructor )
- {
- parameter.setDeclarator( constructor );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaSourceTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaSourceTest.java
deleted file mode 100644
index 67b5ed7..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaSourceTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import java.util.List;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaPackage;
-import com.thoughtworks.qdox.model.JavaSourceTest;
-
-public class DefaultJavaSourceTest extends JavaSourceTest<DefaultJavaSource>
-{
-
- public DefaultJavaSourceTest( String s )
- {
- super( s );
- }
-
- public DefaultJavaSource newJavaSource( ClassLibrary classLibrary )
- {
- return new DefaultJavaSource(classLibrary);
- }
-
- public void setPackage( DefaultJavaSource source, JavaPackage pckg )
- {
- source.setPackage( pckg );
- }
-
- @Override
- public void setClasses( DefaultJavaSource source, List<JavaClass> classes )
- {
- for(JavaClass cls: classes) {
- source.addClass( cls );
- }
- }
-
- @Override
- public void setImports( DefaultJavaSource source, List<String> imports )
- {
- for(String imprt : imports) {
- source.addImport( imprt );
- }
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeIT.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeIT.java
deleted file mode 100644
index 3daf49e..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultJavaTypeIT.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.library.ClassLoaderLibrary;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaType;
-
-public class DefaultJavaTypeIT
-{
- private ClassLoaderLibrary library;
-
- @Before
- public void setUp()
- {
- library = new ClassLoaderLibrary( null );
- library.addDefaultLoader();
- }
-
-
- @Test
- public void testSuperClass()
- {
- JavaClass hashSetClass = library.getJavaClass( "java.util.HashSet" );
- assertTrue( hashSetClass instanceof DefaultJavaClass );
- JavaType hashSetSuperClass = hashSetClass.getSuperClass();
- assertEquals( "java.util.AbstractSet", hashSetSuperClass.getFullyQualifiedName() );
- assertEquals( "java.util.AbstractSet", hashSetSuperClass.getCanonicalName() );
- assertEquals( "java.util.AbstractSet", hashSetSuperClass.getValue() );
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultTypeTest.java b/src/test/java/com/thoughtworks/qdox/model/impl/DefaultTypeTest.java
deleted file mode 100644
index 544f2c6..0000000
--- a/src/test/java/com/thoughtworks/qdox/model/impl/DefaultTypeTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.thoughtworks.qdox.model.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-
-import org.junit.Test;
-
-import com.thoughtworks.qdox.library.ClassLibrary;
-import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.JavaTypeTest;
-
-public class DefaultTypeTest
- extends JavaTypeTest<DefaultJavaType>
-{
-
- public JavaSource newJavaSource( ClassLibrary library )
- {
- return new DefaultJavaSource( library );
- }
-
- public DefaultJavaType newType( String fullname )
- {
- return new DefaultJavaType( fullname );
- }
-
- public DefaultJavaType newType( String fullname, int dimensions )
- {
- return new DefaultJavaType( fullname, dimensions );
- }
-
- public DefaultJavaType newType( String fullname, int dimensions, JavaSource source )
- {
- return new DefaultJavaType( fullname, dimensions, source );
- }
-
- @Test
- public void testArrayType()
- throws Exception
- {
- DefaultJavaType type = newType( "int", 1 );
- assertTrue( type.isArray() );
- }
-
- @Test
- public void testComponentType()
- throws Exception
- {
- assertNull( newType( "int" ).getComponentType() );
- assertEquals( "int", newType( "int", 1 ).getComponentType().getFullyQualifiedName() );
- assertEquals( "long", newType( "long", 3 ).getComponentType().getFullyQualifiedName() );
- }
-
- @Test
- public void testResolving()
- throws Exception
- {
- JavaSource src = mock( JavaSource.class );
- when( src.getImports() ).thenReturn( Collections.singletonList( "foo.*" ) );
- DefaultJavaType type = DefaultJavaType.createUnresolved( "Bar", 0, src );
- assertEquals( false, type.isResolved() );
-
- when( src.resolveType( "Bar" ) ).thenReturn( "foo.Bar" );
- assertEquals( true, type.isResolved() );
- assertEquals( "Bar", type.getValue() );
- assertEquals( "foo.Bar", type.getFullyQualifiedName() );
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java b/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java
deleted file mode 100644
index 16b9c40..0000000
--- a/src/test/java/com/thoughtworks/qdox/parser/ParseExceptionTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ParseExceptionTest
-{
-
- @Test
- public void testNullParseException()
- {
- ParseException pe = new ParseException( null, -1, -1 );
- try {
- pe.getMessage();
- fail( "Message should never be null" );
- }
- catch( NullPointerException npe )
- {
- }
- }
-
- @Test
- public void testEmptyParseException()
- {
- ParseException pe = new ParseException( "", -1, -1 );
- assertEquals("", pe.getMessage());
- }
-
- @Test
- public void testNegativeColumnParseException()
- {
- ParseException pe = new ParseException( "Failed to parse:", 5, -50 );
- assertEquals("Failed to parse: @[5]", pe.getMessage());
- }
-
- @Test
- public void testPositiveColumnParseException()
- {
- ParseException pe = new ParseException( "Failed to parse:", 5, 50 );
- assertEquals("Failed to parse: @[5,50]", pe.getMessage());
- }
-
- @Test
- public void testSurceInfoParseException()
- {
- ParseException pe = new ParseException( "Failed to parse:", 5, 50 );
- pe.setSourceInfo( "com/foo/Bar.java" );
- assertEquals("Failed to parse: @[5,50] in com/foo/Bar.java", pe.getMessage());
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/parser/ParserTest.java b/src/test/java/com/thoughtworks/qdox/parser/ParserTest.java
deleted file mode 100644
index 19f9409..0000000
--- a/src/test/java/com/thoughtworks/qdox/parser/ParserTest.java
+++ /dev/null
@@ -1,2853 +0,0 @@
-package com.thoughtworks.qdox.parser;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import junit.framework.TestCase;
-
-import org.junit.Assert;
-import org.mockito.ArgumentCaptor;
-import org.mockito.stubbing.answers.ReturnsElementsOf;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.parser.impl.Parser;
-import com.thoughtworks.qdox.parser.structs.AnnoDef;
-import com.thoughtworks.qdox.parser.structs.ClassDef;
-import com.thoughtworks.qdox.parser.structs.FieldDef;
-import com.thoughtworks.qdox.parser.structs.InitDef;
-import com.thoughtworks.qdox.parser.structs.MethodDef;
-import com.thoughtworks.qdox.parser.structs.PackageDef;
-import com.thoughtworks.qdox.parser.structs.TypeDef;
-import com.thoughtworks.qdox.parser.structs.WildcardTypeDef;
-
-public class ParserTest extends TestCase {
-
- private Collection<Integer> lexValues = new LinkedList<Integer>();
- private Collection<String> textValues = new LinkedList<String>();
- private Collection<String> codeBodyValues = new LinkedList<String>();
-
- private JavaLexer lexer;
- private Builder builder;
-
- public ParserTest(String s) {
- super(s);
- }
-
- protected void setUp() throws Exception {
- builder = mock(Builder.class);
- lexer = mock(JavaLexer.class);
- lexValues.clear();
- textValues.clear();
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- verifyNoMoreInteractions( builder );
- }
-
- public void testPackageWithOneWord() throws Exception {
-
- // setup values
- setupLex(Parser.PACKAGE);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- ArgumentCaptor<PackageDef> argument = ArgumentCaptor.forClass(PackageDef.class);
- verify(builder).addPackage( argument.capture() );
- assertEquals( "mypackage", argument.getValue().getName() );
- }
-
- public void testPackageWithMultipleWords() throws Exception {
-
- // setup values
- setupLex(Parser.PACKAGE);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "thingy");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- ArgumentCaptor<PackageDef> argument = ArgumentCaptor.forClass(PackageDef.class);
- verify(builder).addPackage( argument.capture() );
- assertEquals( "com.blah.thingy.x", argument.getValue().getName() );
- }
-
- public void testImportWithOneWord() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "mypackage" );
- }
-
- public void testImportWithMultipleWords() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "thingy");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "com.blah.thingy.x" );
- }
-
- public void testImportWithOneWordAndStar() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.DOT);
- setupLex(Parser.STAR);
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "mypackage.*" );
- }
-
- public void testImportWithMultipleWordsAndStar() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "thingy");
- setupLex(Parser.DOT);
- setupLex(Parser.STAR);
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "com.blah.thingy.*" );
- }
-
- public void testImportStaticWithOneWord() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.STATIC);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "static mypackage" );
- }
-
- public void testImportStaticWithMultipleWords() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.STATIC);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Thingy");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "static com.blah.Thingy.x" );
- }
-
- public void testImportStaticWithOneWordAndStar() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.STATIC);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.DOT);
- setupLex(Parser.STAR);
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addImport( "static MyClass.*" );
- }
-
- public void testImportStaticWithMultipleWordsAndStar() throws Exception {
-
- // setup values
- setupLex(Parser.IMPORT);
- setupLex(Parser.STATIC);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Thingy");
- setupLex(Parser.DOT);
- setupLex(Parser.STAR);
- setupLex(Parser.SEMI);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // verify
- verify( builder ).addImport( "static com.blah.Thingy.*" );
- }
-
- public void testEmptyVanillaClass() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).endClass();
-
- assertEquals( "MyClass", classCaptor.getValue().getName() );
- }
-
- public void testEmptyVanillaInterface() throws Exception {
-
- // setup values
- setupLex(Parser.INTERFACE);
- setupLex(Parser.IDENTIFIER, "MyInterface");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).endClass();
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyInterface", cls.getName() );
- assertEquals( ClassDef.INTERFACE, cls.getType() );
- }
-
- public void testEmptyVanillaEnum() throws Exception {
-
- // setup values
- setupLex(Parser.ENUM);
- setupLex(Parser.IDENTIFIER, "MyEnum");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).endClass();
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyEnum", cls.getName() );
- assertEquals( ClassDef.ENUM, cls.getType() );
- }
-
- public void testEmptyClassExtendsAnotherClass() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MySubClass");
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "MyBaseClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MySubClass", cls.getName() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "com.blah.MyBaseClass" ) },
- cls.getExtends().toArray( new TypeDef[0] ) );
- }
-
- public void testEmptyInterfaceExtendsMultipleInterfaces() throws Exception {
-
- // setup values
- setupLex(Parser.INTERFACE);
- setupLex(Parser.IDENTIFIER, "MyInterface");
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "AnotherInterface");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "Serializable");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyInterface", cls.getName() );
- assertEquals( ClassDef.INTERFACE, cls.getType() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "com.blah.AnotherInterface" ),
- new TypeDef( "Serializable" ) }, cls.getExtends().toArray( new TypeDef[0] ) );
- }
-
- public void testEmptyClassImplementsOneInterface() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.IMPLEMENTS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "AnInterface");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new TypeDef[] {new TypeDef("com.blah.AnInterface")}, cls.getImplements().toArray( new TypeDef[0] ));
- }
-
- public void testEmptyClassImplementsMultipleInterfaces() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.IMPLEMENTS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "AnInterface");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "io");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Serializable");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "Eatable");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "com.blah.AnInterface" ),
- new TypeDef( "java.io.Serializable" ), new TypeDef( "Eatable" ) }, cls.getImplements().toArray( new TypeDef[0] ) );
- }
-
- public void testEmptyClassExtendsOneClassAndImplementsOneInterface() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "BaseClass");
- setupLex(Parser.IMPLEMENTS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "AnInterface");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "mypackage.BaseClass" ) },
- cls.getExtends().toArray( new TypeDef[0] ) );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "com.blah.AnInterface" ) },
- cls.getImplements().toArray( new TypeDef[0] ) );
- }
-
- public void testEmptyClassExtendsOneClassAndImplementsMultipleInterface() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "mypackage");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "BaseClass");
- setupLex(Parser.IMPLEMENTS);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "AnInterface");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "io");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Serializable");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "Eatable");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "mypackage.BaseClass" ) },
- cls.getExtends().toArray( new TypeDef[0] ) );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "com.blah.AnInterface" ),
- new TypeDef( "java.io.Serializable" ), new TypeDef( "Eatable" ) }, cls.getImplements().toArray( new TypeDef[0] ) );
- }
-
- public void testEmptyClassWithPublicFinalModifiers() throws Exception {
-
- // setup values
- setupLex(Parser.PUBLIC);
- setupLex(Parser.FINAL);
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new String[] { "public", "final" }, cls.getModifiers().toArray( new String[0] ) );
- }
-
- public void testEmptyClassWithAllModifiers() throws Exception {
-
- // setup values
- setupLex(Parser.PUBLIC);
- setupLex(Parser.PROTECTED);
- setupLex(Parser.PRIVATE);
- setupLex(Parser.FINAL);
- setupLex(Parser.ABSTRACT);
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- Assert.assertArrayEquals( new String[] {"public", "protected","private", "final", "abstract" }, cls.getModifiers().toArray( new String[0] ) );
- }
-
- public void testMultipleClassesInSingleFile() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "Class1");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
-
- setupLex(Parser.PUBLIC);
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "Class2");
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "SubClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
-
- setupLex(Parser.INTERFACE);
- setupLex(Parser.IDENTIFIER, "Intf1");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder, times(3)).beginClass( classCaptor.capture() );
- verify(builder, times(3)).endClass();
-
- ClassDef cls1 = classCaptor.getAllValues().get( 0 );
- assertEquals( "Class1", cls1.getName());
- assertEquals( ClassDef.CLASS, cls1.getType() );
-
- ClassDef cls2 = classCaptor.getAllValues().get( 1 );
- assertEquals( "Class2", cls2.getName() );
- assertEquals( ClassDef.CLASS, cls2.getType() );
- Assert.assertArrayEquals( new String[]{"public"}, cls2.getModifiers().toArray( new String[0] ));
- Assert.assertArrayEquals( new TypeDef[]{new TypeDef("SubClass")}, cls2.getExtends().toArray( new TypeDef[0] ));
-
- ClassDef cls3 = classCaptor.getAllValues().get( 2 );
- assertEquals( "Intf1", cls3.getName() );
- assertEquals( ClassDef.INTERFACE, cls3.getType() );
- }
-
- public void testSemiColonBetweenClass() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "Class1");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(Parser.SEMI); // ;
-
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "Class2");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
- setupLex(Parser.SEMI); // ;
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder, times(2)).beginClass( classCaptor.capture() );
- verify(builder, times(2)).endClass();
-
- ClassDef cls1 = classCaptor.getAllValues().get( 0 );
- assertEquals( "Class1", cls1.getName() );
- assertEquals( ClassDef.CLASS, cls1.getType() );
-
- ClassDef cls2 = classCaptor.getAllValues().get( 1 );
- assertEquals( "Class2", cls2.getName() );
- assertEquals( ClassDef.CLASS, cls2.getType() );
- }
-
-/*can't be tested like this anymore*/
-// public void testJavaDocAppearingAllOverThePlace() throws Exception {
-//
-// // setup values
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc1");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc2");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.PACKAGE);
-// setupLex(Parser.IDENTIFIER, "mypackage");
-// setupLex(Parser.SEMI);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc3");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc4");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.IMPORT);
-// setupLex(Parser.IDENTIFIER, "anotherpackage");
-// setupLex(Parser.DOT);
-// setupLex(Parser.IDENTIFIER, "Something");
-// setupLex(Parser.SEMI);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc5");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc6");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.IMPORT);
-// setupLex(Parser.IDENTIFIER, "elsewhere");
-// setupLex(Parser.DOT);
-// setupLex(Parser.STAR);
-// setupLex(Parser.SEMI);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc7");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc8");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.PUBLIC);
-// setupLex(Parser.CLASS);
-// setupLex(Parser.IDENTIFIER, "MyClass");
-// setupLex(Parser.BRACEOPEN);
-// setupLex(Parser.BRACECLOSE);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc9");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(Parser.JAVADOCSTART);
-// setupLex(Parser.JAVADOCLINE, "javadoc10");
-// setupLex(Parser.JAVADOCEND);
-//
-// setupLex(0);
-//
-// // execute
-// Parser parser = new Parser(lexer, builder);
-// parser.parse();
-//
-// // expectations
-// ClassDef cls = new ClassDef();
-// cls.name = "MyClass";
-// cls.modifiers.add("public");
-//
-// // verify
-// verify(builder).addJavaDoc("javadoc1");
-// verify(builder).addJavaDoc("javadoc2");
-// verify(builder).addPackage( new PackageDef( "mypackage" ) );
-// verify(builder).addJavaDoc("javadoc3");
-// verify(builder).addJavaDoc("javadoc4");
-// verify(builder).addImport( "anotherpackage.Something" );
-// verify(builder).addJavaDoc("javadoc5");
-// verify(builder).addJavaDoc("javadoc6");
-// verify(builder).addImport("elsewhere.*");
-// verify(builder).addJavaDoc("javadoc7");
-// verify(builder).beginClass( cls );
-// verify(builder).endClass();
-// verify(builder).addJavaDoc("javadoc8");
-// verify(builder).addJavaDoc("javadoc9");
-// verify(builder).addJavaDoc("javadoc10");
-//
-// }
-
- public void testSimpleVoidMethod() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
-
- // verify
- verify(builder).beginClass(classCaptor.capture());
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
-
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
- }
-
- public void testSimpleVoidMethodWithNoCode() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- }
-
- public void testSimpleMethodReturningSomething() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "Something");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("Something"), mth.getReturnType() );
- }
-
- public void testSimpleMethodReturningSomethingFullyQualified() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Something");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("com.blah.Something"), mth.getReturnType() );
- }
-
- public void testSimpleMethodWithAllModifiers() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.PUBLIC);
- setupLex(Parser.PROTECTED);
- setupLex(Parser.PRIVATE);
- setupLex(Parser.ABSTRACT);
- setupLex(Parser.STATIC);
- setupLex(Parser.FINAL);
- setupLex(Parser.NATIVE);
- setupLex(Parser.SYNCHRONIZED);
- setupLex(Parser.VOLATILE);
- setupLex(Parser.IDENTIFIER, "com");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "blah");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "Something");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> captor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( captor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = captor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("com.blah.Something"), mth.getReturnType() );
- Assert.assertArrayEquals(new String[]{"public", "protected", "private", "abstract", "static", "final", "native", "synchronized", "volatile"},
- mth.getModifiers().toArray(new String[0]));
- }
-
- public void testMethodWithOneArg() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "numberOfTimes");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> p1 = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).addParameter( p1.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
- FieldDef prm = p1.getValue();
- assertEquals( "numberOfTimes", prm.getName() );
- assertEquals( new TypeDef("int"), prm.getType() );
- }
-
- public void testMethodWithOneFullyQualifiedArg() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "lang");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "numberOfTimes");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> p1 = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).addParameter( p1.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
- FieldDef prm = p1.getValue();
- assertEquals( "numberOfTimes", prm.getName() );
- assertEquals( new TypeDef("java.lang.String"), prm.getType() );
- }
-
- public void testMethodWithTwoArgs() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "numberOfTimes");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "name");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> p = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder, times(2) ).addParameter( p.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
-
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
-
- FieldDef p1 = p.getAllValues().get( 0 );
- assertEquals( "numberOfTimes", p1.getName() );
- assertEquals( new TypeDef( "int" ), p1.getType() );
- FieldDef p2 = p.getAllValues().get( 1 );
- assertEquals( "name", p2.getName() );
- assertEquals( new TypeDef( "String" ), p2.getType() );
-
- }
-
- public void testMethodWithThreeArgs() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "numberOfTimes");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "name");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "boolean");
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder, times(3) ).addParameter( parameterCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
-
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
-
- FieldDef p1 = parameterCaptor.getAllValues().get( 0 );
- assertEquals( "numberOfTimes", p1.getName() );
- assertEquals( new TypeDef( "int" ), p1.getType() );
- FieldDef p2 = parameterCaptor.getAllValues().get( 1 );
- assertEquals( "name", p2.getName() );
- assertEquals( new TypeDef( "String" ), p2.getType() );
- FieldDef p3 = parameterCaptor.getAllValues().get( 2 );
- assertEquals( "x", p3.getName() );
- assertEquals( new TypeDef( "boolean" ), p3.getType() );
- }
-
- public void testMethodWithOneArgThatHasModifier() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.FINAL);
- setupLex(Parser.VOLATILE);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "numberOfTimes");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).addParameter( parameterCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
-
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
-
- assertEquals( "numberOfTimes", parameterCaptor.getValue().getName() );
- Assert.assertArrayEquals( new String[] { "final", "volatile" }, parameterCaptor.getValue().getModifiers().toArray( new String[0] ) );
- assertEquals( new TypeDef("int"), parameterCaptor.getValue().getType() );
- }
-
- public void testMethodThrowingOneException() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef("IOException")}, mth.getExceptions().toArray(new TypeDef[0]));
- }
-
- public void testMethodThrowingTwoExceptions() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "MyException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "IOException" ), new TypeDef( "MyException" ) },
- mth.getExceptions().toArray( new TypeDef[0] ) );
-
- }
-
- public void testMethodThrowingThreeExceptions() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "MyException");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "AnotherException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "IOException" ), new TypeDef( "MyException" ),
- new TypeDef( "AnotherException" ) }, mth.getExceptions().toArray( new TypeDef[0] ) );
- }
-
- public void testMethodThrowingOneFullyQualifiedException() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "io");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef("void"), mth.getReturnType() );
- Assert.assertArrayEquals( new TypeDef[] {new TypeDef("java.io.IOException")}, mth.getExceptions().toArray( new TypeDef[0] ) );
- }
-
- public void testMethodThrowingTwoFullyQualifiedException() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doSomething");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "io");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "lang");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "RuntimeException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doSomething", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "java.io.IOException" ),
- new TypeDef( "java.lang.RuntimeException" ) }, mth.getExceptions().toArray( new TypeDef[0] ) );
- }
-
- public void testDefaultConstructor() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginConstructor();
- verify(builder).endConstructor( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "MyClass", mth.getName() );
- assertEquals(true, mth.isConstructor() );
- }
-
- public void testPublicConstructorWithParam() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.PUBLIC);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginConstructor();
- verify( builder ).addParameter( parameterCaptor.capture() );
- verify( builder ).endConstructor( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "MyClass", mth.getName() );
- assertEquals( true, mth.isConstructor() );
- Assert.assertArrayEquals( new String[] { "public" }, mth.getModifiers().toArray( new String[0] ) );
-
- assertEquals( "count", parameterCaptor.getValue().getName() );
- assertEquals( new TypeDef( "int" ), parameterCaptor.getValue().getType() );
- }
-
- public void testConstructorWithMultipleParams() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.PUBLIC);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "lang");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "thingy");
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginConstructor();
- verify( builder, times( 2 ) ).addParameter( parameterCaptor.capture() );
- verify( builder ).endConstructor( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "MyClass", mth.getName() );
- assertEquals( true, mth.isConstructor() );
- Assert.assertArrayEquals( new String[] { "public" }, mth.getModifiers().toArray( new String[0] ) );
- FieldDef p1 = parameterCaptor.getAllValues().get( 0 );
- assertEquals( "count", p1.getName() );
- assertEquals( new TypeDef( "int" ), p1.getType() );
- FieldDef p2 = parameterCaptor.getAllValues().get( 1 );
- assertEquals( "thingy", p2.getName() );
- assertEquals( new TypeDef( "java.lang.String" ), p2.getType() );
- }
-
- public void testConstructorWithException() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "SomeException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginConstructor();
- verify( builder ).endConstructor( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "MyClass", mth.getName() );
- assertEquals( true, mth.isConstructor() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef( "SomeException" ) },
- mth.getExceptions().toArray( new TypeDef[0] ) );
- }
-
- public void testConstructorWithMultipleException() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.THROWS);
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "io");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "IOException");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "SomeException");
- setupLex(Parser.CODEBLOCK);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginConstructor();
- verify(builder).endConstructor( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName());
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "MyClass", mth.getName() );
- assertEquals( true, mth.isConstructor() );
- Assert.assertArrayEquals( new TypeDef[] { new TypeDef("java.io.IOException"), new TypeDef("SomeException") },
- mth.getExceptions().toArray( new TypeDef[0] ) );
- }
-
- public void testField() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginField( fieldCaptor.capture() );
- verify(builder).endField();
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals(new TypeDef("int"), fld.getType() );
-
- }
-
- public void testFieldFullyQualified() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "java");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "lang");
- setupLex(Parser.DOT);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( new TypeDef( "java.lang.String" ), fld.getType() );
- }
-
- public void testFieldWithModifiers() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.PUBLIC);
- setupLex(Parser.PROTECTED);
- setupLex(Parser.PRIVATE);
- setupLex(Parser.STATIC);
- setupLex(Parser.FINAL);
- setupLex(Parser.TRANSIENT);
- setupLex(Parser.STRICTFP);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( new TypeDef("int"), fld.getType() );
- Assert.assertArrayEquals( new String[] {"public", "protected", "private", "static", "final", "transient", "strictfp"},
- fld.getModifiers().toArray(new String[0]));
- }
-
- public void testFieldWithMultipleDefinitionsOnOneLine() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.IDENTIFIER, "thing");
- setupLex(Parser.COMMA);
- setupLex(Parser.IDENTIFIER, "another");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder, times( 2 ) ).beginField( fieldCaptor.capture() );
- verify( builder, times( 2 ) ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld1 = fieldCaptor.getAllValues().get( 0 );
- assertEquals( "thing", fld1.getName() );
- assertEquals( new TypeDef("String"), fld1.getType() );
- FieldDef fld2 = fieldCaptor.getAllValues().get( 1 );
- assertEquals( "another", fld2.getName() );
- assertEquals( new TypeDef("String"), fld2.getType() );
- }
-
- public void testFieldWithSimpleGenericType() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "List");
- setupLex(Parser.LESSTHAN);
- setupLex(Parser.IDENTIFIER, "String");
- setupLex(Parser.GREATERTHAN);
-
- setupLex(Parser.IDENTIFIER, "l");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "l", fld.getName() );
- assertEquals( "List", fld.getType().getName() );
- assertEquals( 1, fld.getType().getActualArgumentTypes().size() );
- assertEquals( new TypeDef( "String" ), fld.getType().getActualArgumentTypes().get( 0 ) );
- }
-
- public void testFieldWithWildcardGenericType() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "List");
- setupLex(Parser.LESSTHAN);
- setupLex(Parser.QUERY);
- setupLex(Parser.EXTENDS);
- setupLex(Parser.IDENTIFIER, "A");
- setupLex(Parser.GREATERTHAN);
-
- setupLex(Parser.IDENTIFIER, "l");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "l", fld.getName() );
- assertEquals( "List", fld.getType().getName() );
- assertEquals( 1, fld.getType().getActualArgumentTypes().size() );
- assertEquals( new WildcardTypeDef( new TypeDef( "A" ), "extends" ), fld.getType().getActualArgumentTypes().get( 0 ) );
- }
-
- public void testStaticBlock() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.STATIC);
- setupLex(Parser.CODEBLOCK);
-
- // a random method afterwards
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doStuff");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expect no the method, and it shouldn't be static.
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<InitDef> initCaptor = ArgumentCaptor.forClass( InitDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).addInitializer( initCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
-
- MethodDef method = methodCaptor.getValue();
- assertEquals( "doStuff", method.getName() );
- assertEquals( new TypeDef("void"), method.getReturnType() );
- }
-
- public void testInnerClass() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "InnerCls");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
-
- setupLex(Parser.BRACECLOSE);
-
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "AnotherClass");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.BRACECLOSE);
-
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify(builder, times(3) ).beginClass( classCaptor.capture() );
- verify(builder, times(3)).endClass();
-
- assertEquals( "MyClass", classCaptor.getAllValues().get( 0 ).getName() );
- assertEquals( "InnerCls", classCaptor.getAllValues().get( 1 ).getName() );
- assertEquals( "AnotherClass", classCaptor.getAllValues().get( 2 ).getName() );
- }
-
- public void testRogueSemiColon() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "MyClass");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "MyClass", cls.getName() );
- }
-
- public void testFieldNotArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( new TypeDef("int"), fld.getType() );
- assertEquals( 0, fld.getDimensions() );
- }
-
- public void testFieldArrayOnType() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( 0, fld.getDimensions() );
- assertEquals( "int", fld.getType().getName() );
- assertEquals( 1, fld.getType().getDimensions() );
- }
-
- public void testField2dArrayOnType() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( 0, fld.getDimensions() );
- assertEquals( "int", fld.getType().getName() );
- assertEquals( 2, fld.getType().getDimensions() );
- }
-
- public void testFieldArrayOnName() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( 1, fld.getDimensions() );
- assertEquals( new TypeDef( "int", 0 ), fld.getType() );
- }
-
- public void testField3dArrayOnTypeAndName() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( fieldCaptor.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getValue();
- assertEquals( "count", fld.getName() );
- assertEquals( 1, fld.getDimensions() );
- assertEquals( "int", fld.getType().getName() );
- assertEquals( 2, fld.getType().getDimensions() );
- }
-
- public void testFieldArrayThenAnotherNonArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count2");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder, times( 2 ) ).beginField( fieldCaptor.capture() );
- verify( builder, times( 2 ) ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- FieldDef fld = fieldCaptor.getAllValues().get( 0 );
- assertEquals( "count", fld.getName() );
- assertEquals( 1, fld.getDimensions() );
- assertEquals( new TypeDef( "int" ), fld.getType() );
- FieldDef fld2 = fieldCaptor.getAllValues().get( 1 );
- assertEquals( "count2", fld2.getName() );
- assertEquals( 0, fld2.getDimensions() );
- assertEquals( new TypeDef( "int" ), fld2.getType() );
- }
-
- public void testMethodNoArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( new TypeDef("int"), mth.getReturnType() );
- assertEquals( 0, mth.getDimensions() );
- }
-
- public void testMethodArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( "int", mth.getReturnType().getName() );
- assertEquals( 1, mth.getReturnType().getDimensions());
- }
-
- public void testMethodWithArrayDefinedAtEnd() throws Exception {
-
- // It is legal in Java to define a method like this:
- // String doStuff()[] {
- // ... which is equivalent to:
- // String[] doStuff() {
- // This is done in some places in the JDK.
-
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( 1, mth.getDimensions() );
- assertEquals( new TypeDef("int"), mth.getReturnType() );
- }
-
- public void testMethodReturningArrayWithParamNoArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "p1");
-
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).addParameter( parameterCaptor.capture() );
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( new TypeDef( "int", 1 ), mth.getReturnType() );
- FieldDef prm = parameterCaptor.getValue();
- assertEquals( "p1", prm.getName() );
- assertEquals( new TypeDef( "int" ), prm.getType() );
- assertEquals( 0, prm.getDimensions() );
- }
-
- public void testMethodReturningNoArrayWithParamArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "p1");
-
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).addParameter( parameterCaptor.capture() );
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( new TypeDef( "int" ), mth.getReturnType() );
- assertEquals( 0, mth.getDimensions() );
- FieldDef prm = parameterCaptor.getValue();
- assertEquals( "p1", prm.getName() );
- assertEquals( 0, prm.getDimensions() );
- assertEquals( "int", prm.getType().getName() );
- assertEquals( 1, prm.getType().getDimensions() );
- }
-
- public void testMethodReturningArrayWithParam2dArray() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "count");
- setupLex(Parser.PARENOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.SQUAREOPEN);
- setupLex(Parser.SQUARECLOSE);
- setupLex(Parser.IDENTIFIER, "p1");
-
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass(MethodDef.class);
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify(builder).beginClass( classCaptor.capture() );
- verify(builder).beginMethod();
- verify(builder).addParameter( parameterCaptor.capture() );
- verify(builder).endMethod( methodCaptor.capture() );
- verify(builder).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "count", mth.getName() );
- assertEquals( new TypeDef("int", 1), mth.getReturnType() );
- FieldDef prm = parameterCaptor.getValue();
- assertEquals( "p1", prm.getName() );
- assertEquals( "int", prm.getType().getName() );
- assertEquals( 2, prm.getType().getDimensions() );
-
- }
-
- public void testMethodWithVarArgsParameter() throws Exception {
-
- // setup values
- setupLex(Parser.CLASS);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "void");
- setupLex(Parser.IDENTIFIER, "doStuff");
- setupLex(Parser.PARENOPEN);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.DOTDOTDOT);
- setupLex(Parser.IDENTIFIER, "stuff");
-
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
- ArgumentCaptor<FieldDef> parameterCaptor = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).addParameter( parameterCaptor.capture() );
- verify( builder ).endMethod( methodCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- MethodDef mth = methodCaptor.getValue();
- assertEquals( "doStuff", mth.getName() );
- assertEquals( new TypeDef( "void" ), mth.getReturnType() );
- FieldDef prm = parameterCaptor.getValue();
- assertEquals( "stuff", prm.getName() );
- assertEquals( new TypeDef( "int" ), prm.getType() );
- assertEquals( 0, prm.getDimensions() );
- assertEquals( true, prm.isVarArgs() );
- }
-
- public void testEnumWithConstructors() throws Exception {
- setupLex(Parser.ENUM);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "a");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.IDENTIFIER, "int");
- setupLex(Parser.IDENTIFIER, "someField");
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- // MethodDef mth = new MethodDef();
- // mth.name = "a";
-
- ArgumentCaptor<FieldDef> f = ArgumentCaptor.forClass( FieldDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- // verify(mockBuilder).beginConstructor();
- // verify(mockBuilder).endConstructor(mth);
- verify( builder, times( 2 ) ).beginField( f.capture() );
- verify( builder, times( 2 ) ).endField();
- verify( builder ).endClass();
- verifyNoMoreInteractions( builder );
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- assertEquals( ClassDef.ENUM, cls.getType() );
- FieldDef fld0 = f.getAllValues().get( 0 );
- assertEquals( "a", fld0.getName() );
- assertEquals( new TypeDef( "x" ), fld0.getType() ); // bug @todo fixme
- assertEquals( "", fld0.getBody() );
- FieldDef fld1 = f.getAllValues().get( 1 );
- assertEquals( "someField", fld1.getName() );
- assertEquals( new TypeDef( "int" ), fld1.getType() );
- assertEquals( null, fld1.getBody() );
- }
-
- public void testEnumEndingWithExtraComma() throws Exception {
- setupLex(Parser.ENUM);
- setupLex(Parser.IDENTIFIER, "x");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "a");
- setupLex(Parser.COMMA);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
-// MethodDef mth = new MethodDef();
-// mth.name = "a";
- ArgumentCaptor<FieldDef> f = ArgumentCaptor.forClass(FieldDef.class);
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- // verify(mockBuilder).beginConstructor();
- // verify(mockBuilder).endConstructor(mth);
- verify( builder ).beginField( f.capture() );
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- assertEquals( ClassDef.ENUM, cls.getType() );
- FieldDef fld = f.getValue();
- assertEquals( "a", fld.getName() );
- assertEquals( new TypeDef( "x" ), fld.getType() ); //bug @todo fixme
- assertEquals( "" , fld.getBody() );
- }
-
- // QDOX-266
- public void testEnumConstantWithClassBody() throws Exception
- {
- setupLex(Parser.PUBLIC);
- setupLex(Parser.ENUM);
- setupLex(Parser.IDENTIFIER, "MethodLocationOfEnumMethod");
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.IDENTIFIER, "A");
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
-
- setupLex(Parser.BRACEOPEN);
-
- setupLex(Parser.AT);
- setupLex(Parser.IDENTIFIER, "Override");
- setupLex(Parser.PUBLIC);
- setupLex(Parser.IDENTIFIER, "void" );
- setupLex(Parser.IDENTIFIER, "method" );
- setupLex(Parser.PARENOPEN);
- setupLex(Parser.PARENCLOSE);
- setupLex(Parser.CODEBLOCK);
- setupLex(Parser.SEMI);
-
- setupLex(Parser.BRACECLOSE);
-
- setupLex(Parser.BRACECLOSE);
- setupLex(0);
-
- // execute
- Parser parser = new Parser(lexer, builder);
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<FieldDef> f = ArgumentCaptor.forClass(FieldDef.class);
- ArgumentCaptor<ClassDef> enumConstantClassCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<AnnoDef> annoCaptor = ArgumentCaptor.forClass( AnnoDef.class );
- ArgumentCaptor<MethodDef> methodClassCaptor = ArgumentCaptor.forClass( MethodDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).beginField( f.capture() );
- verify( builder ).beginClass( enumConstantClassCaptor.capture() );
- verify( builder ).addAnnotation( annoCaptor.capture() );
- verify( builder ).beginMethod();
- verify( builder ).endMethod( methodClassCaptor.capture() );
- verify( builder ).endClass();
- verify( builder ).endField();
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( true, cls.getModifiers().contains( "public" ) );
- assertEquals( ClassDef.ENUM, cls.getType() );
- assertEquals( "MethodLocationOfEnumMethod", cls.getName() );
- FieldDef fld = f.getValue();
- assertEquals( "A", fld.getName() );
- assertEquals( new TypeDef( "MethodLocationOfEnumMethod" ), fld.getType() );
- //ClassDef ecCls = enumConstantClassCaptor.getValue();
- AnnoDef ann = annoCaptor.getValue();
- assertEquals( "Override", ann.getTypeDef().getName() );
- MethodDef mth = methodClassCaptor.getValue();
- assertEquals( "method", mth.getName() );
-
-// Class methodLocationOfEnumMethod = MethodLocationOfEnumMethod.class;
-// Field a = methodLocationOfEnumMethod.getField( "A" );
-// assertNotNull( a );
-// assertSame( methodLocationOfEnumMethod, a.getDeclaringClass() );
-// assertSame( methodLocationOfEnumMethod, a.getType() );
-// assertEquals( 2, methodLocationOfEnumMethod.getDeclaredMethods().length);
- }
-
- public void testStaticInitializer()
- throws Exception
- {
- // setup values
- setupLex( Parser.CLASS );
- setupLex( Parser.IDENTIFIER, "x" );
- setupLex( Parser.BRACEOPEN );
-
- setupLex( Parser.STATIC );
- setupLex( Parser.CODEBLOCK, null, "//test" );
-
- setupLex( Parser.BRACECLOSE );
- setupLex( 0 );
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<InitDef> initCaptor = ArgumentCaptor.forClass( InitDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).addInitializer( initCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- InitDef init = initCaptor.getValue();
- assertTrue( init.isStatic() );
- assertEquals( "//test", init.getBlockContent() );
- }
-
- public void testInstanceInitializer() throws Exception
- {
- // setup values
- setupLex( Parser.CLASS );
- setupLex( Parser.IDENTIFIER, "x" );
- setupLex( Parser.BRACEOPEN );
-
- setupLex( Parser.CODEBLOCK, null, "//test" );
-
- setupLex( Parser.BRACECLOSE );
- setupLex( 0 );
-
- // execute
- Parser parser = new Parser( lexer, builder );
- parser.parse();
-
- // expectations
- ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
- ArgumentCaptor<InitDef> initCaptor = ArgumentCaptor.forClass( InitDef.class );
-
- // verify
- verify( builder ).beginClass( classCaptor.capture() );
- verify( builder ).addInitializer( initCaptor.capture() );
- verify( builder ).endClass();
-
- ClassDef cls = classCaptor.getValue();
- assertEquals( "x", cls.getName() );
- InitDef init = initCaptor.getValue();
- assertFalse( init.isStatic() );
- assertEquals( "//test", init.getBlockContent() );
- }
-
- private void setupLex(int token, String value) {
- lexValues.add( token );
- textValues.add( value );
- }
-
- private void setupLex(int token, String value, String codeBody ) {
- setupLex( token, value );
- codeBodyValues.add( codeBody );
- }
-
- private void setupLex( int token ) throws Exception
- {
- setupLex( token, null );
- if ( token == 0 )
- {
- when( lexer.lex() ).thenAnswer( new ReturnsElementsOf( lexValues ) );
- when( lexer.text() ).thenAnswer( new ReturnsElementsOf( textValues ) );
- when( lexer.getCodeBody() ).thenAnswer( new ReturnsElementsOf( codeBodyValues ) );
- when( lexer.getLine() ).thenReturn( -1 );
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentLexerTest.java b/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentLexerTest.java
deleted file mode 100644
index 01a13e5..0000000
--- a/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentLexerTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package com.thoughtworks.qdox.parser.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.StringReader;
-
-import org.junit.Test;
-
-public class DefaultJavaCommentLexerTest
-{
- private DefaultJavaCommentLexer lexer;
-
- @Test
- public void testSingleLineComment() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("// this is a single line comment"));
- lexAssert( 0 );
- assertEquals( "// this is a single line comment", lexer.getCodeBody() );
- }
-
- @Test
- public void testCompactMultiLineComment() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/**/"));
- lexAssert( 0 );
- assertEquals( "/**/", lexer.getCodeBody() );
- }
-
- @Test
- public void testSingleRowMultiLineComment() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/* multiline comment with one row */"));
- lexAssert( 0 );
- assertEquals( "/* multiline comment with one row */", lexer.getCodeBody() );
- }
-
- @Test
- public void testJavaDocComment() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/** multiline comment with one row */"));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "multiline comment with one row");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert( 0 );
- }
-
- @Test
- public void testSingleTagJavaDoc() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/** @deprecated */"));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@deprecated");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert( 0 );
- }
-
- @Test
- public void testDeprecatedJavaDoc() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/** @author John Doe */"));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@author");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "John Doe");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert( 0 );
- }
-
- @Test
- public void testMultiTagJavaDoc() throws Exception {
- lexer = new DefaultJavaCommentLexer( new StringReader("/** @deprecated\n" +
- " * @author John Doe */"));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@deprecated");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@author");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "John Doe");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert( 0 );
- }
-
- @Test
- public void testDocletTags() throws Exception {
- String in = ""
- + "/**\n"
- + " * @hello world\n"
- + " * @a b c d\n"
- + " * @bye\n"
- + " * @bye:bye\n"
- + " */";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@hello");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "world\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@a");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "b c d\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@bye");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@bye:bye");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testOneLinerDocComment() throws Exception {
- String in = "/** @hello world */";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@hello");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "world");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testCompressedDocComment() throws Exception {
- String in = "/**@foo bar*/";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@foo");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "bar");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testDeepJavadocTag() throws Exception {
- String in = " /** * *** * @m x \n" +
- "*/";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "* *** * @m x \n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testDocCommentContainingAtSymbols() throws Exception {
- String in = ""
- + "/**\n"
- + " * joe at truemesh.com\n"
- + " * {@link here}.\n"
- + " * me @home\n"
- + " * geeks @ play\n"
- + " */";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "joe at truemesh.com\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "{@link here}.\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "me @home\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "geeks @ play\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testDocCommentContainingStars() throws Exception {
- String in = ""
- + "/**\n"
- + " * 5 * 4\n"
- + " * SELECT COUNT(*)\n"
- + " * **stars**everywhere** \n"
- + " */";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "5 * 4\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "SELECT COUNT(*)\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "**stars**everywhere** \n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- @Test
- public void testExtraStarsAreIgnoredAtStartAndEnd() throws Exception {
- String in = ""
- + "/*****\n"
- + " * blah\n"
- + " *****/";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/*****");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "blah\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*****/");
- lexAssert(0);
- }
-
- @Test
- public void testExtraStarsCompressed() throws Exception {
- String in = ""
- + "/***blah***/";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/***");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "blah");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "***/");
- lexAssert(0);
- }
-
- @Test
- public void testIgnoreStarPrefix() throws Exception {
- String in = ""
- + "/**\n"
- + " * simple\n"
- + "\t * indented\n"
- + " *nospace\n"
- + " *** multistar\n"
- + " *\n"
- + " */";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "simple\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "indented\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "nospace\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "multistar\n");
- lexAssert(DefaultJavaCommentParser.JAVADOCLINE, "\n");
-
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- // QDOX-200
- @Test
- public void testCompactJavaDocTag() throws Exception {
- String in = "/** @foo*/";
- lexer = new DefaultJavaCommentLexer(new StringReader(in));
- lexAssert(DefaultJavaCommentParser.JAVADOCSTART, "/**");
- lexAssert(DefaultJavaCommentParser.JAVADOCTAG, "@foo");
- lexAssert(DefaultJavaCommentParser.JAVADOCEND, "*/");
- lexAssert(0);
- }
-
- private void lexAssert(int lex) throws IOException {
- lexAssert( lex, "" );
-
- }
- private void lexAssert(int lex, String text) throws IOException {
- assertEquals(lex, lexer.lex());
- assertEquals(text, lexer.text());
- }
-
-}
diff --git a/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentParserTest.java b/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentParserTest.java
deleted file mode 100644
index dee88c1..0000000
--- a/src/test/java/com/thoughtworks/qdox/parser/impl/DefaultJavaCommentParserTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package com.thoughtworks.qdox.parser.impl;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.stubbing.answers.ReturnsElementsOf;
-
-import com.thoughtworks.qdox.builder.Builder;
-import com.thoughtworks.qdox.parser.structs.TagDef;
-
-public class DefaultJavaCommentParserTest
-{
-
- private Collection<Integer> lexValues = new LinkedList<Integer>();
- private Collection<String> textValues = new LinkedList<String>();
-
- private DefaultJavaCommentLexer lexer;
- private Builder builder;
-
- @Before
- public void setUp() throws Exception {
- lexer = mock(DefaultJavaCommentLexer.class);
- builder = mock(Builder.class);
- lexValues.clear();
- textValues.clear();
- }
-
- @After
- public void tearDown()
- throws Exception
- {
- verifyNoMoreInteractions( builder );
- }
-
- @Test
- public void testOneLineJavaDoc() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "This is great!");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addJavaDoc( "This is great!" );
- }
-
- @Test
- public void testOneJavaDocTag() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@This");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "is great!");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- ArgumentCaptor<TagDef> tagCaptor = ArgumentCaptor.forClass( TagDef.class );
-
- // verify
- verify(builder).addJavaDocTag( tagCaptor.capture() );
- TagDef tag = tagCaptor.getValue();
- assertEquals( "This", tag.getName() );
- assertEquals( "is great!", tag.getText() );
- }
-
- @Test
- public void testOneJavaDocTagWithNoValue() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@eatme");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- ArgumentCaptor<TagDef> tagCaptor = ArgumentCaptor.forClass( TagDef.class );
-
- // verify
- verify(builder).addJavaDocTag( tagCaptor.capture() );
- TagDef tag = tagCaptor.getValue();
- assertEquals( "eatme", tag.getName() );
- assertEquals( "", tag.getText() );
- }
-
- @Test
- public void testOneMultiLineJavaDocTag() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@This");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "is great! Mmmkay.");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- ArgumentCaptor<TagDef> tagCaptor = ArgumentCaptor.forClass( TagDef.class );
-
- // verify
- verify( builder ).addJavaDocTag( tagCaptor.capture() );
- TagDef tag = tagCaptor.getValue();
- assertEquals( "This", tag.getName() );
- assertEquals( "is great! Mmmkay.", tag.getText() );
- }
-
- @Test
- public void testMultipleJavaDocTags() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@This");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "is great!");
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@mock");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "generate");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- ArgumentCaptor<TagDef> tagCaptor = ArgumentCaptor.forClass( TagDef.class );
-
- // verify
- verify(builder, times(2)).addJavaDocTag( tagCaptor.capture() );
- TagDef tag1 = tagCaptor.getAllValues().get( 0 );
- assertEquals( "This", tag1.getName() );
- assertEquals( "is great!", tag1.getText() );
- TagDef tag2 = tagCaptor.getAllValues().get( 1 ) ;
- assertEquals( "mock", tag2.getName() );
- assertEquals( "generate", tag2.getText() );
- }
-
- @Test
- public void testJavaDocTextAndMultipleJavaDocTags() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "Welcome! Here is my class.");
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@This");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "is great!");
- setupLex(DefaultJavaCommentParser.JAVADOCTAG, "@mock");
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "generate");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- ArgumentCaptor<TagDef> tagCaptor = ArgumentCaptor.forClass( TagDef.class );
-
- // verify
- verify(builder).addJavaDoc( "Welcome! Here is my class." );
- verify(builder, times(2) ).addJavaDocTag( tagCaptor.capture() );
- TagDef tag1 = tagCaptor.getAllValues().get( 0 );
- assertEquals( "This", tag1.getName() );
- assertEquals( "is great!", tag1.getText() );
- TagDef tag2 = tagCaptor.getAllValues().get( 1 ) ;
- assertEquals( "mock", tag2.getName() );
- assertEquals( "generate", tag2.getText() );
- }
-
- @Test
- public void testJavaDocEmpty() throws Exception {
-
- // setup values
- setupLex(DefaultJavaCommentParser.JAVADOCSTART);
- setupLex(DefaultJavaCommentParser.JAVADOCLINE, "");
- setupLex(DefaultJavaCommentParser.JAVADOCEND);
- setupLex(0);
-
- // execute
- DefaultJavaCommentParser parser = new DefaultJavaCommentParser(lexer, builder);
- parser.parse();
-
- // verify
- verify(builder).addJavaDoc( "" );
- }
-
- private void setupLex(int token, String value) {
- lexValues.add( token );
- textValues.add( value );
- }
-
- private void setupLex(int token) throws IOException {
- setupLex(token, null);
- if( token == 0)
- {
- when( lexer.lex() ).thenAnswer( new ReturnsElementsOf( lexValues ) );
- when( lexer.text() ).thenAnswer( new ReturnsElementsOf( textValues ) );
- when( lexer.getLine() ).thenReturn( -1 );
- }
- }
-}
diff --git a/src/test/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriterTest.java b/src/test/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriterTest.java
deleted file mode 100644
index 1b62a0a..0000000
--- a/src/test/java/com/thoughtworks/qdox/writer/impl/DefaultModelWriterTest.java
+++ /dev/null
@@ -1,395 +0,0 @@
-package com.thoughtworks.qdox.writer.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.thoughtworks.qdox.model.DocletTag;
-import com.thoughtworks.qdox.model.JavaAnnotatedElement;
-import com.thoughtworks.qdox.model.JavaAnnotation;
-import com.thoughtworks.qdox.model.JavaClass;
-import com.thoughtworks.qdox.model.JavaField;
-import com.thoughtworks.qdox.model.JavaInitializer;
-import com.thoughtworks.qdox.model.JavaMethod;
-import com.thoughtworks.qdox.model.JavaParameter;
-import com.thoughtworks.qdox.model.JavaType;
-import com.thoughtworks.qdox.model.expression.Expression;
-
-public class DefaultModelWriterTest {
-
- private DefaultModelWriter modelWriter;
-
- @Before
- public void onSetup(){
- modelWriter = new DefaultModelWriter();
- }
-
- @Test
- public void testCommentToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- when(annotatedElement.getComment()).thenReturn("Hello");
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * Hello\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testMultilineCommentToString() {
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- when(annotatedElement.getComment()).thenReturn("Hello\nWorld");
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * Hello\n"
- + " * World\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
-
- }
-
- @Test
- public void testEmptyCommentToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- when(annotatedElement.getComment()).thenReturn("");
-
- // expectation
- String expected = ""
- + "/**\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testNoCommentToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
-
- // expectation
- String expected = "";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testCommentWithTagToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- when(annotatedElement.getComment()).thenReturn("Hello");
- DocletTag monkeyTag = mock(DocletTag.class);
- when(monkeyTag.getName()).thenReturn( "monkey" );
- when(monkeyTag.getValue()).thenReturn( "is in the tree" );
- when(annotatedElement.getTags()).thenReturn(Collections.singletonList( monkeyTag ));
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * Hello\n"
- + " *\n"
- + " * @monkey is in the tree\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testCommentWithMultipleTagsToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- when(annotatedElement.getComment()).thenReturn("Hello");
- List<DocletTag> tags = new LinkedList<DocletTag>();
- DocletTag monkeyTag = mock(DocletTag.class);
- when(monkeyTag.getName()).thenReturn( "monkey" );
- when(monkeyTag.getValue()).thenReturn( "is in the tree" );
- tags.add( monkeyTag );
- DocletTag seeTag = mock( DocletTag.class );
- when(seeTag.getName()).thenReturn( "see" );
- when(seeTag.getValue()).thenReturn("the doctor" );
- tags.add(seeTag);
- when(annotatedElement.getTags()).thenReturn(tags);
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * Hello\n"
- + " *\n"
- + " * @monkey is in the tree\n"
- + " * @see the doctor\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testTagButNoCommentToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- DocletTag monkeyTag = mock(DocletTag.class);
- when(monkeyTag.getName()).thenReturn( "monkey" );
- when(monkeyTag.getValue()).thenReturn( "is in the tree" );
- when(annotatedElement.getTags()).thenReturn(Collections.singletonList( monkeyTag ));
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * @monkey is in the tree\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
- @Test
- public void testTagWithNoValueToString() {
- // setup
- JavaAnnotatedElement annotatedElement = mock(JavaAnnotatedElement.class);
- DocletTag monkeyTag = mock(DocletTag.class);
- when(monkeyTag.getName()).thenReturn( "monkey" );
- when(monkeyTag.getValue()).thenReturn( "" );
- when(annotatedElement.getTags()).thenReturn(Collections.singletonList( monkeyTag ));
-
- // expectation
- String expected = ""
- + "/**\n"
- + " * @monkey\n"
- + " */\n";
-
- // run
- modelWriter.commentHeader(annotatedElement);
-
- // verify
- assertEquals(expected, modelWriter.toString());
- }
-
-
- //enum Eon { HADEAN, ARCHAEAN, PROTEROZOIC, PHANEROZOIC }
-
- @Test
- public void testEnumConstant()
- {
- //setup
- JavaField enumConstant = mock(JavaField.class);
- when(enumConstant.isEnumConstant()).thenReturn( true );
- when(enumConstant.getName()).thenReturn( "HADEAN" );
-
- //expectation
- String expected = "HADEAN;\n";
-
- //run
- modelWriter.writeField( enumConstant );
-
- //verify
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testEnumConstantWithArgument()
- {
- // setup
- JavaField enumConstant = mock( JavaField.class );
- when( enumConstant.isEnumConstant() ).thenReturn( true );
- when( enumConstant.getName() ).thenReturn( "PENNY" );
- Expression arg = mock( Expression.class );
- when( arg.getParameterValue()).thenReturn( "1" );
- when( enumConstant.getEnumConstantArguments() ).thenReturn( Collections.singletonList( arg ) );
-
- //expectation
- String expected = "PENNY( 1 );\n";
-
- //run
- modelWriter.writeField( enumConstant );
-
- //verify
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testEnumConstantWithArguments()
- {
- // setup
- JavaField enumConstant = mock( JavaField.class );
- when( enumConstant.isEnumConstant() ).thenReturn( true );
- when( enumConstant.getName() ).thenReturn( "EARTH" );
-
- List<Expression> args = new ArrayList<Expression>();
- Expression mass = mock( Expression.class );
- when( mass.getParameterValue()).thenReturn( "5.976e+24" );
- args.add( mass );
- Expression radius = mock( Expression.class );
- when( radius.getParameterValue()).thenReturn( "6.37814e6" );
- args.add( radius );
- when( enumConstant.getEnumConstantArguments() ).thenReturn( args );
-
- //expectation
- String expected = "EARTH( 5.976e+24, 6.37814e6 );\n";
-
- //run
- modelWriter.writeField( enumConstant );
-
- //verify
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testEnumConstantClass()
- {
- // setup
- JavaField enumConstant = mock( JavaField.class );
- when( enumConstant.isEnumConstant() ).thenReturn( true );
- when( enumConstant.getName() ).thenReturn( "PLUS" );
-
- JavaClass cls = mock( JavaClass.class );
- JavaMethod eval = mock( JavaMethod.class );
- JavaType doubleType = mock( JavaType.class );
- when( doubleType.getGenericCanonicalName() ).thenReturn( "double" );
- when( eval.getReturnType() ).thenReturn( doubleType );
- when( eval.getName() ).thenReturn( "eval" );
- List<JavaParameter> params = new ArrayList<JavaParameter>();
- JavaParameter x = mock( JavaParameter.class );
- when( x.getGenericCanonicalName() ).thenReturn( "double" );
- when( x.getName() ).thenReturn( "x" );
- params.add( x );
- JavaParameter y = mock( JavaParameter.class );
- when( y.getGenericCanonicalName() ).thenReturn( "double" );
- when( y.getName() ).thenReturn( "y" );
- params.add( y );
- when( eval.getParameters() ).thenReturn( params );
- when( cls.getMethods() ).thenReturn( Collections.singletonList( eval ) );
- when( enumConstant.getEnumConstantClass() ).thenReturn( cls );
-
- //expectation
- String expected = "PLUS {\n" +
- "\n" +
- "\tdouble eval(double x, double y);\n" +
- "\n" +
- "}\n" +
- ";\n";
-
- //run
- modelWriter.writeField( enumConstant );
-
- //verify
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testJavaParameter()
- {
- JavaParameter prm = mock( JavaParameter.class );
-
- when( prm.getGenericCanonicalName() ).thenReturn( "java.lang.String" );
- when( prm.getName() ).thenReturn( "argument" );
-
- modelWriter.writeParameter( prm );
-
- String expected = "java.lang.String argument";
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testJavaParameterVarArgs()
- {
- JavaParameter prm = mock( JavaParameter.class );
-
- when( prm.getGenericCanonicalName() ).thenReturn( "java.lang.String" );
- when( prm.getName() ).thenReturn( "argument" );
- when( prm.isVarArgs() ).thenReturn( true );
-
- modelWriter.writeParameter( prm );
-
- String expected = "java.lang.String... argument";
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testStaticInitializer()
- {
-
- JavaInitializer init = mock( JavaInitializer.class );
- when( init.isStatic() ).thenReturn( true );
- when( init.getBlockContent() ).thenReturn( "//test" );
-
- modelWriter.writeInitializer( init );
-
- String expected = "static {\n" +
- "\t//test\n" +
- "}\n";
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testInstanceInitializer()
- {
-
- JavaInitializer init = mock( JavaInitializer.class );
- when( init.isStatic() ).thenReturn( false );
- when( init.getBlockContent() ).thenReturn( "//test" );
-
- modelWriter.writeInitializer( init );
-
- String expected = "{\n" +
- "\t//test\n" +
- "}\n";
- assertEquals( expected, modelWriter.toString() );
- }
-
- @Test
- public void testAnnotation()
- {
-
- JavaClass annType = mock( JavaClass.class );
- when( annType.getGenericCanonicalName() ).thenReturn( "Anno" );
- JavaAnnotation ann = mock( JavaAnnotation.class );
- when( ann.getType() ).thenReturn( annType );
-
- modelWriter.writeAnnotation( ann );
-
- String expected = "@Anno\n";
- assertEquals( expected, modelWriter.toString() );
- }
-
-}
diff --git a/src/test/resources/com/thoughtworks/qdox/testdata/Latin1.java b/src/test/resources/com/thoughtworks/qdox/testdata/Latin1.java
deleted file mode 100644
index 4dde3d6..0000000
--- a/src/test/resources/com/thoughtworks/qdox/testdata/Latin1.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.thoughtworks.qdox.testdata;
-
-/**
- * TEST-CHARS: �������
- */
-public class Latin1
-{
-}
diff --git a/src/test/resources/com/thoughtworks/qdox/testdata/PropertyClass.java b/src/test/resources/com/thoughtworks/qdox/testdata/PropertyClass.java
deleted file mode 100644
index 5fdb1f8..0000000
--- a/src/test/resources/com/thoughtworks/qdox/testdata/PropertyClass.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.thoughtworks.qdox.testdata;
-
-// used as test data for properties and binary support and other tests
-
-/**
- * @foo bar="zap"
- * @aslak.foo bar="dodgeme"
- */
-public class PropertyClass extends Superclass {
- public static boolean aField;
-
- static {
- aField = true;
- }
-
- protected int protectedField;
-
- private int privateField;
-
- public PropertyClass() {
- }
-
- protected PropertyClass(PropertyClass other) {
- privateField = other.privateField;
- }
-
- // not a bean property, sice it's static
- public static String getFoo() {
- return "foo";
- }
-
- public boolean isBar() {
- return aField;
- }
-
- // not a bean property
- public void set(int i) {
- }
-
- // not a bean property
- public final String get() {
- return null;
- }
-
- protected void protectedMethod() {
- privateField = 2;
- protectedField = privateMethod();
- }
-
- private int privateMethod() {
- return privateField;
- }
-}
-
-class Superclass {
- public int shouldntBeInherited;
-
- public int getShouldntBeInherited() {
- return shouldntBeInherited;
- }
-}
\ No newline at end of file
diff --git a/src/test/resources/com/thoughtworks/qdox/testdata/UTF8.java b/src/test/resources/com/thoughtworks/qdox/testdata/UTF8.java
deleted file mode 100644
index 78e9659..0000000
--- a/src/test/resources/com/thoughtworks/qdox/testdata/UTF8.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.thoughtworks.qdox.testdata;
-
-/**
- * TEST-CHARS: ßıΣЯא€
- */
-public class UTF8 {
-
-
-}
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/qdox.git
More information about the pkg-java-commits
mailing list