You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by cc...@apache.org on 2009/03/16 16:40:57 UTC
svn commit: r754938 [1/2] - in
/incubator/kato/trunk/import/org.apache.kato.anttasks: ./ .settings/
META-INF/ lib/ src/ src/com/ src/com/ibm/ src/com/ibm/dtfj/
src/com/ibm/dtfj/anttasks/ src/com/ibm/dtfj/anttasks/sitebuilder/
src/com/ibm/dtfj/anttasks/...
Author: ccristal
Date: Mon Mar 16 16:40:55 2009
New Revision: 754938
URL: http://svn.apache.org/viewvc?rev=754938&view=rev
Log:
Initial code contribution from IBM.
Added:
incubator/kato/trunk/import/org.apache.kato.anttasks/
incubator/kato/trunk/import/org.apache.kato.anttasks/.classpath
incubator/kato/trunk/import/org.apache.kato.anttasks/.project
incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/
incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.core.resources.prefs
incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.jdt.core.prefs
incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/
incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/MANIFEST.MF
incubator/kato/trunk/import/org.apache.kato.anttasks/build.properties
incubator/kato/trunk/import/org.apache.kato.anttasks/build.xml
incubator/kato/trunk/import/org.apache.kato.anttasks/lib/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/anttasks.properties
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Archive.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Category.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Description.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/SiteBuilder.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinition.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionException.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionWriterDoclet.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLReader.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLWriter.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKListBuilder.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEnvironmentExpression.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEvaluationException.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpression.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionEvaluator.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionParser.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagFactory.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTagGroup.java
incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKTestTag.java
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/features/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test1.java
incubator/kato/trunk/import/org.apache.kato.anttasks/testdata/tagsrc/com/tests/foo/Test2.java
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/site.xml
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/test1/test.xml
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/
incubator/kato/trunk/import/org.apache.kato.anttasks/tests/testListBuilder/test.xml
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionParser.java
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestExpressionTokenizer.java
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKDefinitionWriter.java
incubator/kato/trunk/import/org.apache.kato.anttasks/testsrc/test/ibm/dtfj/anttasks/tcklistbuilder/TestTCKTagDefinitions.java
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/.classpath
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/.classpath?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/.classpath (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/.classpath Mon Mar 16 16:40:55 2009
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="testsrc"/>
+ <classpathentry kind="src" path="testdata/tagsrc"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="lib" path="lib/ant.jar"/>
+ <classpathentry kind="lib" path="lib/tools.jar"/>
+ <classpathentry kind="lib" path="lib/junit.jar"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
\ No newline at end of file
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/.project
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/.project?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/.project (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/.project Mon Mar 16 16:40:55 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.kato.anttasks</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.core.resources.prefs?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.core.resources.prefs (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.core.resources.prefs Mon Mar 16 16:40:55 2009
@@ -0,0 +1,9 @@
+#Fri Jan 30 14:26:56 GMT 2009
+eclipse.preferences.version=1
+encoding//bin/com/ibm/dtfj/anttasks/anttasks.properties=ISO-8859-1
+encoding//src/com/ibm/dtfj/anttasks/anttasks.properties=ISO-8859-1
+encoding//tests/test1/site.xml=UTF-8
+encoding//tests/test1/test.xml=UTF-8
+encoding//tests/testListBuilder/test.xml=UTF-8
+encoding/build.properties=ISO-8859-1
+encoding/build.xml=UTF-8
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.jdt.core.prefs?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/.settings/org.eclipse.jdt.core.prefs Mon Mar 16 16:40:55 2009
@@ -0,0 +1,12 @@
+#Fri Nov 14 10:50:31 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
+org.eclipse.jdt.core.compiler.source=1.4
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/MANIFEST.MF?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/MANIFEST.MF (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/META-INF/MANIFEST.MF Mon Mar 16 16:40:55 2009
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Anttasks
+Bundle-SymbolicName: org.apache.kato.anttasks
+Bundle-Version: 1.0.0
+Bundle-ClassPath: anttasks.jar,
+ lib/ant.jar,
+ javasdks/sun/j2sdk1.4.2_18/lib/tools.jar,
+ lib/junit.jar
+Export-Package: com.ibm.dtfj.anttasks.tcklistbuilder
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/build.properties
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/build.properties?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/build.properties (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/build.properties Mon Mar 16 16:40:55 2009
@@ -0,0 +1,19 @@
+#-------------------------------------------------------------------------------
+# Licensed 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.
+#-------------------------------------------------------------------------------
+src=./src
+bin=./bin
+testsrc=./testsrc
+testdata.src=./testdata/tagsrc
+junit.path=./lib/junit.jar
+srclevel=1.4
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/build.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/build.xml?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/build.xml (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/build.xml Mon Mar 16 16:40:55 2009
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed 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 default="default">
+
+ <property file="./build.properties"/>
+ <property name="publish1" location="../builder.dtfj/lib"/>
+ <property name="publish2" location="../builder.tck/lib"/>
+ <property name="dtfjantjar" location="dtfjant.jar"/>
+
+ <target name="default">
+ <antcall target="clean" />
+ <antcall target="compile" />
+ <antcall target="jar" />
+ <antcall target="test" />
+
+ <antcall target="publish" />
+
+ </target>
+
+ <target name="publish">
+ <copy file="${dtfjantjar}" todir="${publish1}"/>
+ <copy file="${dtfjantjar}" todir="${publish2}"/>
+ </target>
+ <!-- remove compiled classes and jars-->
+
+ <target name="clean">
+ <delete dir="${bin}"/>
+ <mkdir dir="${bin}"/>
+
+
+ </target>
+
+ <!-- compile -->
+
+ <target name="compile">
+ <mkdir dir="${bin}" />
+ <javac srcdir="${src}" destdir="${bin}" debug="true" source="1.4">
+ <classpath>
+ <pathelement location="lib/ant.jar"/>
+
+ </classpath>
+
+ </javac>
+
+ <javac srcdir="${testsrc}" debug="on" destdir="${bin}" source="${srclevel}" target="${srclevel}" >
+ <classpath>
+ <path location="${junit.path}" />
+ </classpath>
+ </javac>
+ </target>
+
+
+ <target name="test" unless="no.test">
+
+ <junit>
+ <classpath>
+ <path location="${junit.path}" />
+ <path location="${bin}" />
+ </classpath>
+
+
+
+
+ <batchtest haltonerror="true" fork="yes" todir="${junit.output}">
+ <fileset dir="${testsrc}">
+ <include name="**/*Test*.java" />
+ <exclude name="**/AllTests.java" />
+ </fileset>
+ </batchtest>
+
+ </junit>
+
+ <property name="sitefile" location="${java.io.tmpdir}/sitetest.xml"/>
+
+ <ant inheritall="true" antfile="./tests/test1/test.xml" />
+ <ant inheritall="true" antfile="./tests/testListBuilder/test.xml" />
+ </target>
+
+ <target name="jar">
+
+ <jar destfile="${dtfjantjar}">
+ <fileset dir="${bin}"/>
+ <fileset dir="${src}">
+ <include name="**/*.properties"/>
+ </fileset>
+ </jar>
+ </target>
+
+
+
+
+
+
+</project>
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/anttasks.properties
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/anttasks.properties?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/anttasks.properties (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/anttasks.properties Mon Mar 16 16:40:55 2009
@@ -0,0 +1,15 @@
+#-------------------------------------------------------------------------------
+# Licensed 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.
+#-------------------------------------------------------------------------------
+sitebuilder=com.ibm.dtfj.anttasks.sitebuilder.SiteBuilder
+tcklistbuilder=com.ibm.dtfj.anttasks.tcklistbuilder.TCKListBuilder
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Archive.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Archive.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Archive.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Archive.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.sitebuilder;
+
+public class Archive {
+
+ private String path=null;
+ private String url=null;
+ public String getPath() {
+ return path;
+ }
+ public void setPath(String path) {
+ this.path = path;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Category.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Category.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Category.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Category.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.sitebuilder;
+
+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.types.FileSet;
+
+public class Category {
+
+ private String name=null;
+ private String label=null;
+ private String urlPrefix="";
+ private Description description=null;
+ private Vector filesets=new Vector();
+ public void setName(String name) {
+ this.name=name;
+ }
+ public String getLabel() {
+ return label;
+ }
+ public void setLabel(String label) {
+ this.label = label;
+ }
+ public String getName() {
+ return name;
+ }
+ public void addFileSet(FileSet fileset) {
+ filesets.add(fileset);
+ }
+
+ public Vector getFiles() {
+ Vector results=new Vector();
+ Iterator i=filesets.iterator();
+ while(i.hasNext()) {
+ FileSet fs=(FileSet) i.next();
+ DirectoryScanner scanner=fs.getDirectoryScanner();
+ String[] files=scanner.getIncludedFiles();
+ if(files!=null && files.length>0) {
+ for(int f=0;f<files.length;f++) {
+ results.add(files[f]);
+ }
+ }
+ }
+ return results;
+ }
+ public String getUrlPrefix() {
+ return urlPrefix;
+ }
+ public void setUrlPrefix(String urlPrefix) {
+ this.urlPrefix = urlPrefix;
+ }
+ public void addDescription(Description d) {
+ if(description!=null) throw new BuildException("only one description allowed");
+ this.description=d;
+ }
+ public String getDescriptionText() {
+ if(description==null) return "";
+ return description.getText();
+ }
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Description.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Description.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Description.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/Description.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.sitebuilder;
+
+public class Description {
+ private StringBuffer text=new StringBuffer();
+ private String url=null;
+
+ public void addText(String text) {
+ this.text.append(text);
+ }
+
+ public String getText() {
+ return text.toString().trim();
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/SiteBuilder.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/SiteBuilder.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/SiteBuilder.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/sitebuilder/SiteBuilder.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.sitebuilder;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class SiteBuilder extends Task {
+
+ private File siteFile=null; // location of file that will be created
+ private URL mirrorsURL=null;
+ private Vector categories=new Vector();
+ private Vector archives=new Vector();
+ private Description description=null;
+ public void setFile(File siteFile) {
+ this.siteFile=siteFile;
+ }
+
+ public void addDescription(Description d) {
+ if(description!=null) throw new BuildException("only one description allowed");
+ this.description=d;
+ }
+ public void addCategory(Category category) {
+ categories.add(category);
+ }
+ public void addArchive(Archive archive) {
+ archives.add(archive);
+ }
+ public void setMirrorsURL(URL url) {
+ this.mirrorsURL=url;
+ }
+
+ public void execute() throws BuildException {
+ try {
+ execute1();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ public void execute1() throws BuildException {
+
+ if(siteFile==null) throw new BuildException("missing site file");
+
+ if(categories.isEmpty()) throw new BuildException("no categories specified");
+
+ try {
+ FileWriter fw=new FileWriter(siteFile);
+ PrintWriter pw=new PrintWriter(fw);
+
+ // write document header
+
+ pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ pw.println("<!-- AUTO GENERATED SITE FILE using "+getClass().getName()+" -->");
+
+ // write start site tag
+
+ pw.print("<site");
+ if(mirrorsURL!=null) {
+ pw.print(" mirrorsURL=\""+mirrorsURL.toExternalForm()+"\" ");
+ }
+ pw.println(">");
+
+ // write description
+ if(description!=null) {
+
+ pw.print("<description");
+ String url=description.getUrl();
+ if(url!=null) pw.print(" url=\""+url+"\" ");
+ pw.println(">");
+ pw.println(description.getText().trim());
+ pw.println("</description>");
+ }
+ // write categories
+ Iterator categoryIterator=categories.iterator();
+ while(categoryIterator.hasNext()) {
+ Category category=(Category) categoryIterator.next();
+ writeCategoryEntries(pw,category);
+ }
+ // write categories
+ categoryIterator=categories.iterator();
+ while(categoryIterator.hasNext()) {
+ Category category=(Category) categoryIterator.next();
+ writeCategoryHeaders(pw,category);
+ }
+ // write archives
+ writeArchives(pw);
+
+ // write end site tag
+
+ pw.println("</site>");
+
+ pw.close();
+ } catch (IOException e) {
+
+ throw new BuildException(e);
+ }
+
+ }
+
+
+ private void writeArchives(PrintWriter pw) {
+ Iterator i=archives.iterator();
+ while(i.hasNext()) {
+ Archive archive=(Archive) i.next();
+ String path=archive.getPath();
+ String url=archive.getUrl();
+ pw.println("<archive path=\""+path+"\" url=\""+url+"\"/>");
+ }
+
+ }
+
+ private void writeCategoryEntries(PrintWriter pw, Category category) {
+ String label=category.getLabel();
+ if(label==null) throw new BuildException("category label missing");
+ String name=category.getName();
+ if(name==null) throw new BuildException("category name missing");
+
+ String urlPrefix=category.getUrlPrefix();
+
+ Vector files=category.getFiles();
+ Iterator fileIterator=files.iterator();
+ while(fileIterator.hasNext()) {
+ String fileName=(String) fileIterator.next();
+ int underscore=fileName.indexOf("_");
+ String version=fileName;
+ String id=fileName;
+
+
+ if(underscore>1) {
+ id=fileName.substring(0,underscore);
+ version=fileName.substring(underscore+1);
+ }
+
+ if(version.endsWith(".jar") || version.endsWith(".zip")) {
+ version=version.substring(0,version.length()-4);
+ }
+ pw.println("\t<feature url=\""+urlPrefix+fileName+"\" id=\""+id+"\" version=\""+version+"\">");
+ pw.println("\t\t<category name=\""+name+"\"/>");
+ pw.println("\t</feature>");
+ }
+
+ }
+
+ public URL getMirrorsURL() {
+ return mirrorsURL;
+ }
+
+ private void writeCategoryHeaders(PrintWriter pw, Category category) {
+ String label=category.getLabel();
+ if(label==null) throw new BuildException("category label missing");
+ String name=category.getName();
+ if(name==null) throw new BuildException("category name missing");
+
+ pw.print("<category-def name=\""+name+"\" label=\""+label+"\"");
+ String description=category.getDescriptionText();
+ if(description.trim().equals("")==false) {
+ pw.println(">");
+ pw.println("<description>");
+ pw.println(description);
+ pw.println("</description>");
+ pw.println("</category-def>");
+ }
+ else {
+ pw.println("/>");
+ }
+
+
+
+ }
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinition.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinition.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinition.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinition.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+/**
+ * TCKDefinition class
+ *
+ * Represents the TCK test suite in terms of tests to execute
+ * and any restrictions on execution environments
+ *
+ */
+public class TCKDefinition {
+
+ private String createdDate=new Date().toString();
+ private static TCKTagFactory tagFactory=new TCKTagFactory();
+ private TCKDefinitionGroup root=new TCKDefinitionGroup("root");
+
+ public abstract class TCKEntityDefinition {
+
+ private String name=null;
+ Map tags=new TreeMap();
+ private TCKEntityGroupDefinition parent=null;
+
+ public TCKEntityDefinition(String name) {
+ this.name=name;
+ }
+ public void addTags(List tckTags) {
+ Iterator i=tckTags.iterator();
+ while(i.hasNext()) {
+ TCKTestTag tag=(TCKTestTag) i.next();
+ tags.put(tag.getTagName(),tag);
+
+ }
+
+ }
+
+ public void addTag(TCKTestTag tag) {
+ tags.put(tag.getTagName(),tag);
+ }
+
+ public String getName() {
+ return name;
+ }
+ public Iterator iterateTags() {
+ return tags.values().iterator();
+ }
+ public String getQualifiedName() {
+ if(parent==null) return name;
+ return parent.getQualifiedName()+"."+name;
+ }
+ public TCKEntityGroupDefinition getParent() {
+ return parent;
+ }
+ public void setParent(TCKEntityGroupDefinition parent) {
+ this.parent = parent;
+ }
+
+ }
+ public abstract class TCKEntityGroupDefinition extends TCKEntityDefinition{
+ public TCKEntityGroupDefinition(String name) {
+ super(name);
+
+ }
+ public void getChildren(Class clazz, List list) {
+
+ Iterator kids=iterator();
+ while(kids.hasNext()) {
+ TCKEntityDefinition e=(TCKEntityDefinition) kids.next();
+ if(e.getClass()==clazz) list.add(e);
+ if(e instanceof TCKEntityGroupDefinition) {
+ TCKEntityGroupDefinition group=(TCKEntityGroupDefinition) e;
+ group.getChildren(clazz, list);
+ }
+ }
+
+ }
+
+ private TreeMap children=new TreeMap();
+ public Iterator iterator() {
+
+ return children.values().iterator();
+ }
+ public void addChild(TCKEntityDefinition def) {
+ def.setParent(this);
+ children.put(def.getName(),def);
+
+ }
+
+
+ public TCKEntityDefinition getChild(String name) {
+
+ return (TCKEntityDefinition) children.get(name);
+ }
+
+
+ public boolean hasChild(String name) {
+ return children.containsKey(name);
+ }
+
+
+ }
+
+ public class TCKClassDefinition extends TCKEntityGroupDefinition{
+
+ public TCKClassDefinition(String name) {
+ super(name);
+
+ }
+
+ public TCKMethodDefinition createMethod(String name) {
+ if(hasChild(name)) {
+ return (TCKMethodDefinition) getChild(name);
+ }
+ else {
+ TCKMethodDefinition def=new TCKMethodDefinition(name);
+ addChild(def);
+ return def;
+ }
+ }
+
+ public String getQualifedClassName() {
+ return getParent().getName()+"."+getName();
+ }
+
+
+
+ }
+
+ public class TCKMethodDefinition extends TCKEntityDefinition{
+
+ public TCKMethodDefinition(String name) {
+ super(name);
+
+ }
+
+
+
+ }
+
+ public class TCKPackageDefinition extends TCKEntityGroupDefinition {
+
+
+
+
+ public TCKPackageDefinition(String name) {
+ super(name);
+
+ }
+
+ public TCKClassDefinition createClass(String name) {
+ if(hasChild(name)) {
+ return (TCKClassDefinition) getChild(name);
+ }
+ else {
+ TCKClassDefinition def=new TCKClassDefinition(name);
+ addChild(def);
+ return def;
+ }
+ }
+
+ }
+
+ public class TCKDefinitionGroup extends TCKEntityGroupDefinition{
+
+ public TCKDefinitionGroup(String name) {
+ super(name);
+
+ }
+
+ public TCKPackageDefinition createPackage(String name) {
+
+ if(hasChild(name)) {
+ return (TCKPackageDefinition) getChild(name);
+ }
+ else {
+ TCKPackageDefinition def=new TCKPackageDefinition(name);
+ addChild(def);
+ return def;
+ }
+
+ }
+ }
+
+ public TCKClassDefinition createClass(String packageName, String clazzName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+ public TCKTestTag getTag(String tagName,String value) throws TCKDefinitionException {
+
+ return TCKTagFactory.create(tagName,value);
+
+ }
+
+
+
+
+ public TCKDefinitionGroup getRoot() {
+ return root;
+ }
+
+
+ public TCKPackageDefinition createPackage(String name) {
+ return root.createPackage(name);
+ }
+
+
+ /**
+ * Retrieve the method named in the class / package defined
+ *
+ * @param packageName
+ * @param className
+ * @param methodName
+ * @return null if no package, class or method found
+ */
+
+ public TCKMethodDefinition getMethod(String packageName, String className,
+ String methodName) {
+
+ TCKEntityGroupDefinition pkg=(TCKEntityGroupDefinition) root.getChild(packageName);
+ if(pkg==null) return null;
+
+ TCKEntityGroupDefinition clazz=(TCKEntityGroupDefinition) pkg.getChild(className);
+ if(clazz==null) return null;
+
+ return (TCKMethodDefinition) clazz.getChild(methodName);
+
+
+
+ }
+
+
+
+ public boolean isValidTag(String tagName) {
+ return tagFactory.isValidTagName(tagName);
+ }
+
+
+
+ public Iterator classIterator() {
+ List allClasses=new LinkedList();
+ root.getChildren(TCKClassDefinition.class,allClasses);
+ return allClasses.iterator();
+ }
+
+
+
+ /**
+ * Returns the tag group in effect for this package, class and method
+ *
+ * @param packageName
+ * @param className
+ * @param methodName
+ *
+ */
+ public TCKTagGroup getTagGroup(String packageName, String className,
+ String methodName) {
+
+
+ TreeMap tags=new TreeMap();
+
+ TCKMethodDefinition m=getMethod(packageName, className, methodName);
+
+ tags.putAll(m.tags);
+
+ TCKClassDefinition clazz=(TCKClassDefinition) m.getParent();
+
+ tags.putAll(clazz.tags);
+
+ TCKPackageDefinition pkg=(TCKPackageDefinition) clazz.getParent();
+
+ tags.putAll(pkg.tags);
+
+ tags.putAll(root.tags);
+
+
+ return new TCKTagGroup(tags);
+ }
+
+
+
+ public String getCreatedDate() {
+ return createdDate;
+ }
+
+
+
+ public void setCreatedDate(String createdDate) {
+ this.createdDate = createdDate;
+ }
+
+
+
+ public int classCount() {
+ List allClasses=new LinkedList();
+ root.getChildren(TCKClassDefinition.class,allClasses);
+ return allClasses.size();
+ }
+
+
+
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionException.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionException.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionException.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionException.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+public class TCKDefinitionException extends Exception {
+
+ private static final long serialVersionUID = -8226819915399329096L;
+ private String className=null;
+ private String methodName=null;
+
+ public TCKDefinitionException(String string) {
+ this(null,null,string);
+ }
+ public TCKDefinitionException(String classname,String methodname,String string) {
+ super(string);
+ this.className=classname;
+ this.methodName=methodname;
+
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionWriterDoclet.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionWriterDoclet.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionWriterDoclet.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionWriterDoclet.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+/**
+ * A javadoc doclet designed to work in conjunction with the tcklistbuilder
+ * ant task. The aim of this class is to create an xml definition file holding the test
+ * execution characteristics required for the DTFJ TCK
+ *
+ */
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKMethodDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKPackageDefinition;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.MethodDoc;
+import com.sun.javadoc.Parameter;
+import com.sun.javadoc.RootDoc;
+import com.sun.javadoc.Tag;
+
+public class TCKDefinitionWriterDoclet {
+
+ private static File output=null;
+
+ /**
+ * Validate command line options passed in from javadoc
+ *
+ * @param options - input array
+ * @param reporter - where to report errors
+ * @return true is valid
+ */
+ public static boolean validOptions(String options[][],
+ DocErrorReporter reporter) {
+
+
+ for (int i = 0; i < options.length; i++) {
+ String[] opt = options[i];
+ if (opt[0].equals("-outfile")) {
+ output = new File(opt[1]);
+ }
+ }
+
+ return output!=null;
+
+
+ }
+
+ public static int optionLength(String option) {
+
+ if(option.equals("-outfile")) {
+ return 2;
+ }
+ return 2;
+ }
+
+
+ /**
+ * Doclet entry point. Runs though all classes passed in
+ *
+ * @param root
+ *
+ * @throws TCKDefinitionException
+ * @throws TCKDefinitionException
+ */
+ public static boolean start(RootDoc root) {
+ TCKDefinition definition=null;
+
+ try {
+ definition=createTCKDefinition(root.classes());
+ } catch(TCKDefinitionException de) {
+ String className=de.getClassName();
+ String method=de.getMethodName();
+ String message=de.getMessage();
+ System.err.println("Tag passing error: class="+className+" method="+method+" error is "+message);
+ return false;
+ }
+ System.out.println("Definitions for "+definition.classCount()+" classes created");
+
+ TCKDefinitionXMLWriter writer=new TCKDefinitionXMLWriter(definition);
+ try {
+ writer.write(output);
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ return false;
+ }
+
+
+ return true;
+
+ }
+
+ /**
+ * Write contents to tck list builder and hence out to
+ * xml file
+ *
+ *
+ * @param classes
+ * @throws TCKDefinitionException
+ */
+ private static TCKDefinition createTCKDefinition(ClassDoc[] classes) throws TCKDefinitionException {
+ TCKDefinition definition=new TCKDefinition();
+
+ for (int i=0; i < classes.length; i++) {
+
+ ClassDoc clazz=classes[i];
+ if(clazz.isAbstract()) continue; // ignore abstract classes
+ if(clazz.containingClass()!=null) continue; // ignore inner classes
+ ClassDoc superClass=clazz.superclass();
+
+ if(superClass==null) {
+ System.out.println("skipping "+clazz.qualifiedName()+" (no parent)");
+ continue; // not a TCK test by definition
+ }
+ String className=superClass.name();
+
+
+ if(className.equals("TCKJavaRuntimeTestcase")==false &&
+ className.equals("TestCase")==false &&
+ className.equals("TCKProcessTestcase")==false &&
+ className.equals("AbstractDTFJTestcase")==false) {
+ System.out.println("skipping "+clazz.qualifiedName()+" (parent ["+className+"] not a testcase)");
+ continue; // not a subclass of a testcase
+ }
+
+
+ TCKPackageDefinition packageDef=definition.createPackage(clazz.containingPackage().name());
+ TCKClassDefinition cdef=packageDef.createClass(clazz.name());
+
+ Tag[] tags=clazz.tags();
+ List tckTags;
+ try {
+ tckTags = parseTCKTags(definition,tags);
+ } catch (TCKDefinitionException e) {
+
+ throw new TCKDefinitionException(cdef.getQualifedClassName(),null,e.getMessage());
+ }
+ cdef.addTags(tckTags);
+
+ MethodDoc[] methods = clazz.methods();
+
+ for (int m=0; m < methods.length; m++) {
+ MethodDoc method=methods[m];
+ if(method.name().startsWith("test")==false) continue; // not a test methods
+ if(method.isAbstract()) continue;
+ if(method.isConstructor()) continue;
+ if(method.isPublic()==false) continue;
+
+ Parameter[] parms=method.parameters();
+ if(parms!=null && parms.length>0) continue; // not a test method
+
+ // a real test method
+
+
+ TCKMethodDefinition mdef=cdef.createMethod(method.name());
+ tags = method.tags();
+ try {
+ tckTags=parseTCKTags(definition,tags);
+ mdef.addTags(tckTags);
+ } catch(TCKDefinitionException de) {
+ de.setMethodName(method.name());
+ de.setClassName(clazz.qualifiedName());
+ }
+ }
+
+ }
+
+ return definition;
+ }
+
+ private static List parseTCKTags(TCKDefinition definition, Tag[] tags) throws TCKDefinitionException {
+
+ List list=new LinkedList();
+
+ for (int t=0; t < tags.length; t++) {
+ Tag clazztag=tags[t];
+ String tagName=clazztag.name();
+ if(tagName.length()==1) continue; // just an @ sign
+ tagName=tagName.substring(1); // drop the @
+ if(definition.isValidTag(tagName)==false) continue; // not our tag
+ String value=clazztag.text();
+
+
+ TCKTestTag tag=definition.getTag(tagName,value);
+ if(tag!=null) list.add(tag);
+
+ }
+ return list;
+ }
+
+
+
+
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLReader.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLReader.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLReader.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKMethodDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKPackageDefinition;
+
+/**
+ * Class to load a TCK Definition from an XML definition file
+ *
+ */
+public class TCKDefinitionXMLReader {
+
+
+
+ public static TCKDefinition load(InputStream in ) throws Exception {
+
+ DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder=factory.newDocumentBuilder();
+ Document doc=builder.parse(in);
+
+ return buildDefinition(doc);
+
+
+
+ }
+
+ private static TCKDefinition buildDefinition(Document doc) throws IOException, TCKDefinitionException {
+
+ TCKDefinition def=new TCKDefinition();
+
+ Element top=doc.getDocumentElement();
+ String tagName=top.getTagName();
+ if(tagName.equals("tckdef")==false) throw new IOException("root tag ["+tagName+"] is incorrect. Should be 'tckdef'");
+
+ String dateAttr=top.getAttribute("created");
+ def.setCreatedDate(dateAttr);
+
+ List tags=loadTags(top);
+ def.getRoot().addTags(tags);
+
+ NodeList kids=top.getElementsByTagName("package");
+ loadPackages(def,kids);
+
+
+ return def;
+ }
+
+ private static List loadTags(Element top) throws TCKDefinitionException {
+ List list=new LinkedList();
+ for(int i=0;i<TCKTagFactory.tagnames.length;i++) {
+ String tagName=TCKTagFactory.tagnames[i];
+ if(top.hasAttribute(tagName)) {
+ String value=top.getAttribute(tagName);
+ TCKTestTag tag=TCKTagFactory.create(tagName, value);
+ list.add(tag);
+ }
+ }
+ return list;
+ }
+
+ private static void loadPackages(TCKDefinition def, NodeList kids) throws IOException, TCKDefinitionException {
+
+ int length=kids.getLength();
+ for(int i=0;i<length;i++) {
+ Element packageElement=(Element) kids.item(i);
+ String packageName=getRequired(packageElement,"name");
+ TCKPackageDefinition pkg=def.createPackage(packageName);
+ List tags=loadTags(packageElement);
+ pkg.addTags(tags);
+
+ NodeList k=packageElement.getElementsByTagName("class");
+ loadClasses(pkg,k);
+
+ }
+
+ }
+private static void loadClasses(TCKPackageDefinition def, NodeList kids) throws IOException, TCKDefinitionException {
+
+ int length=kids.getLength();
+ for(int i=0;i<length;i++) {
+ Element packageElement=(Element) kids.item(i);
+ String className=getRequired(packageElement,"name");
+ TCKClassDefinition clazz=def.createClass(className);
+ List tags=loadTags(packageElement);
+ clazz.addTags(tags);
+
+ NodeList k=packageElement.getElementsByTagName("method");
+ loadMethods(clazz,k);
+
+ }
+
+ }
+private static void loadMethods(TCKClassDefinition def, NodeList kids) throws IOException, TCKDefinitionException {
+
+ int length=kids.getLength();
+ for(int i=0;i<length;i++) {
+ Element packageElement=(Element) kids.item(i);
+ String methodName=getRequired(packageElement,"name");
+ TCKMethodDefinition method=def.createMethod(methodName);
+ List tags=loadTags(packageElement);
+ method.addTags(tags);
+
+
+ }
+
+}
+
+ private static String getRequired(Element e, String attrName) throws IOException {
+ if(e.hasAttribute(attrName)==false) throw new IOException("missing attribute "+attrName+" on tag "+e.getTagName());
+ return e.getAttribute(attrName);
+ }
+
+ public TCKDefinition load(File testSuiteFile) throws Exception {
+ FileInputStream fis=new FileInputStream(testSuiteFile);
+ TCKDefinition def=load(fis);
+ fis.close();
+ return def;
+ }
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLWriter.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLWriter.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKDefinitionXMLWriter.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKDefinitionGroup;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKEntityDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKMethodDefinition;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinition.TCKPackageDefinition;
+
+/**
+ * Clas to emit a TCK Definition as an XML file
+ *
+ */
+public class TCKDefinitionXMLWriter {
+
+ private PrintWriter out=null;
+
+ private TCKDefinition definition=null;
+
+ public TCKDefinitionXMLWriter(TCKDefinition definition) {
+ this.definition=definition;
+ }
+
+ public void write(File output) throws IOException {
+ FileWriter fw=new FileWriter(output);
+ out=new PrintWriter(fw);
+ write(out);
+ out.close();
+ }
+
+ public void write(PrintWriter out) {
+
+ writeHeader(out);
+ TCKDefinitionGroup root=definition.getRoot();
+
+ Iterator pkgs=root.iterator();
+
+ while(pkgs.hasNext()) {
+ TCKPackageDefinition packageDef=(TCKPackageDefinition) pkgs.next();
+ writePackage(out,packageDef);
+ }
+ writeTrailer(out);
+
+ }
+
+
+ /**
+ * Write out package level definitions
+ *
+ * @param out
+ * @param packageDef
+ */
+ private void writePackage(PrintWriter out, TCKPackageDefinition packageDef) {
+
+ out.println("<package name=\""+escape(packageDef.getName())+"\" "+getTagAttributes(packageDef)+">");
+
+ Iterator classes=packageDef.iterator();
+ while(classes.hasNext()) {
+ TCKClassDefinition classDef=(TCKClassDefinition) classes.next();
+ writeClass(out,classDef);
+ }
+ out.println("</package>");
+
+ }
+
+ private void writeClass(PrintWriter out, TCKClassDefinition classDef) {
+ out.println("<class name=\""+escape(classDef.getName())+"\" "+getTagAttributes(classDef)+">");
+
+ Iterator methods=classDef.iterator();
+ while(methods.hasNext()) {
+ TCKMethodDefinition methodDef=(TCKMethodDefinition) methods.next();
+ writeMethod(out,methodDef);
+ }
+ out.println("</class>");
+
+ }
+
+ private String getTagAttributes(TCKEntityDefinition def) {
+
+ StringBuffer buffer=new StringBuffer();
+
+ Iterator tags=def.iterateTags();
+ while(tags.hasNext()) {
+ TCKTestTag tag=(TCKTestTag) tags.next();
+ String name=tag.getTagName();
+ String value=tag.getValue();
+ buffer.append(name);
+ buffer.append("=\"");
+ buffer.append(escape(value));
+ buffer.append("\" ");
+
+ }
+ return new String(buffer);
+ }
+
+ private void writeMethod(PrintWriter out2, TCKMethodDefinition methodDef) {
+
+ out.println("<method name=\""+escape(methodDef.getName())+"\" "+getTagAttributes(methodDef)+"/>");
+ }
+
+ /**
+ * Convert string into acceptable values for an xml file
+ *
+ * @param value
+ * @return safe value
+ */
+ public static String escape(String value) {
+
+ value=value.replaceAll("&","&"); // do this first!
+ value=value.replaceAll("<","<");
+ value=value.replaceAll(">",">");
+
+ return value;
+ }
+
+ private void writeTrailer(PrintWriter out) {
+ out.println("</tckdef>");
+
+ }
+
+ private void writeHeader(PrintWriter out) {
+ out.println("<tckdef "+getTagAttributes(definition.getRoot())+ " created=\""+definition.getCreatedDate()+"\" >");
+
+ }
+
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKListBuilder.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKListBuilder.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKListBuilder.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKListBuilder.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Javadoc;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Wrapper ant task around javadoc task. Adds in required TCK Doclet
+ *
+ */
+public class TCKListBuilder extends Javadoc{
+
+ private Path output=null;
+ private Path docletPath=null;
+
+ public TCKListBuilder() {
+
+
+ }
+ public void execute() throws BuildException {
+
+
+ if(output==null) throw new BuildException("tcklistbuilder missing required attribute 'output'");
+ if(docletPath==null) throw new BuildException("tcklistbuilder missing required attribute 'docletpath'");
+
+ // Configure required doclet
+
+ DocletInfo doclet=createDoclet();
+ doclet.setName("com.ibm.dtfj.anttasks.tcklistbuilder.TCKDefinitionWriterDoclet");
+ Path path=doclet.createPath();
+ path.setPath(docletPath.toString());
+
+ DocletParam parameter=doclet.createParam();
+ parameter.setName("-outfile");
+ parameter.setValue(output.toString());
+
+ super.execute();
+
+
+ }
+
+
+
+ public void setListOutput(File f) {
+
+ }
+ public void setOutput(Path output) {
+ this.output = output;
+ }
+ public void setDocletPath(Path docletPath) {
+ this.docletPath = docletPath;
+ }
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEnvironmentExpression.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEnvironmentExpression.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEnvironmentExpression.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEnvironmentExpression.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+
+public class TCKSelectionEnvironmentExpression extends TCKSelectionExpression {
+
+
+
+ public TCKSelectionEnvironmentExpression(String key, int operator, Object value) {
+ super(null,null);
+ this.key=key;
+ this.checkvalue=value;
+ this.operator=operator;
+ }
+
+ String key=null;
+ Object checkvalue=null;
+ int operator=0;
+
+ public String toString() {
+ return key+" "+TCKSelectionExpression.getOperatorValue(operator)+" "+checkvalue;
+ }
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEvaluationException.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEvaluationException.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEvaluationException.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionEvaluationException.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+public class TCKSelectionEvaluationException extends RuntimeException {
+
+ private static final long serialVersionUID = 3588373442848019903L;
+
+ public TCKSelectionEvaluationException() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public TCKSelectionEvaluationException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public TCKSelectionEvaluationException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public TCKSelectionEvaluationException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+
+
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpression.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpression.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpression.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpression.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+public abstract class TCKSelectionExpression {
+
+ public static final int EQ=1;
+ public static final int NE=2;
+ public static final int GT=3;
+ public static final int LT=4;
+ public static final int LE=5;
+ public static final int GE=6;
+ public static final int AND=7;
+ public static final int OR=8;
+
+ private static String[] names=new String[]{"unrecognised","=","!-",">","<",">=","<=","&&","||"};
+
+
+
+ public static String getOperatorValue(int v) {
+ if(v<0 || v>=names.length) return "?";
+ return names[v];
+ }
+ TCKSelectionExpression leftExpression=null;
+ TCKSelectionExpression rightExpression=null;
+
+ public TCKSelectionExpression(TCKSelectionExpression leftExpression,
+ TCKSelectionExpression rightExpression) {
+ this.leftExpression=leftExpression;
+ this.rightExpression=rightExpression;
+ }
+
+
+
+
+ public static class OrExpression extends TCKSelectionExpression {
+
+ public OrExpression(TCKSelectionExpression leftExpression,
+ TCKSelectionExpression rightExpression) {
+ super(leftExpression, rightExpression);
+
+ }
+
+ public String toString() {
+ return leftExpression+" OR "+rightExpression;
+ }
+
+ }
+ public static class AndExpression extends TCKSelectionExpression {
+
+ public AndExpression(TCKSelectionExpression leftExpression,
+ TCKSelectionExpression rightExpression) {
+ super(leftExpression, rightExpression);
+
+ }
+
+ public String toString() {
+ return leftExpression+" AND "+rightExpression;
+ }
+ }
+public TCKSelectionExpression getLeftExpression() {
+ return leftExpression;
+}
+
+public void setLeftExpression(TCKSelectionExpression leftExpression) {
+ this.leftExpression = leftExpression;
+}
+
+public TCKSelectionExpression getRightExpression() {
+ return rightExpression;
+}
+
+public void setRightExpression(TCKSelectionExpression rightExpression) {
+ this.rightExpression = rightExpression;
+}
+
+}
Added: incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionEvaluator.java?rev=754938&view=auto
==============================================================================
--- incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionEvaluator.java (added)
+++ incubator/kato/trunk/import/org.apache.kato.anttasks/src/com/ibm/dtfj/anttasks/tcklistbuilder/TCKSelectionExpressionEvaluator.java Mon Mar 16 16:40:55 2009
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Licensed 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.ibm.dtfj.anttasks.tcklistbuilder;
+
+import java.util.Map;
+
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpression.OrExpression;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpression.AndExpression;
+import com.ibm.dtfj.anttasks.tcklistbuilder.TCKSelectionExpressionParser.Numeric;
+
+public class TCKSelectionExpressionEvaluator {
+
+ private boolean trace=false;
+
+ public TCKSelectionExpressionEvaluator() {
+
+ }
+
+ public boolean evaluate(TCKSelectionExpression expression,Map values) {
+
+ report(expression);
+ boolean result=evaluate0(expression, values);
+ report(expression,result);
+ return result;
+ }
+ private void report(TCKSelectionExpression expression, boolean result) {
+ if(trace) System.out.println("<"+expression.toString()+" = "+result);
+
+ }
+
+ private void report(TCKSelectionExpression expression) {
+ if(trace) System.out.println(">"+expression.toString());
+
+ }
+
+ private boolean evaluate0(TCKSelectionExpression expression,Map values) {
+
+
+ if(expression instanceof OrExpression ) {
+
+ if(evaluate(expression.leftExpression,values)==true) return true;
+ if(evaluate(expression.rightExpression,values)==true) return true;
+ return false;
+
+ }
+ else if(expression instanceof AndExpression) {
+
+ if(evaluate(expression.leftExpression,values)==false) return false;
+ if(evaluate(expression.rightExpression,values)==false) return false;
+ return true;
+
+ }
+ else if(expression instanceof TCKSelectionEnvironmentExpression){
+
+ TCKSelectionEnvironmentExpression e=(TCKSelectionEnvironmentExpression) expression;
+
+
+ Object value=values.get(e.key);
+
+ report(e.key+" is "+value+" (check is "+TCKSelectionExpression.getOperatorValue(e.operator));
+
+
+ if(e.checkvalue instanceof Numeric) {
+
+ return evalInteger(e,value);
+
+ }
+ else {
+ String check=e.checkvalue.toString();
+ int compareTo=check.compareTo(value);
+
+ switch(e.operator) {
+
+ case TCKSelectionExpression.EQ : return compareTo==0;
+ case TCKSelectionExpression.NE : return compareTo!=0;
+ case TCKSelectionExpression.GT : return compareTo<0;
+ case TCKSelectionExpression.LT : return compareTo>0;
+ case TCKSelectionExpression.GE : return compareTo<=0;
+ case TCKSelectionExpression.LE : return compareTo>=0;
+ }
+ }
+
+ // illegal comparison..
+
+
+ throw new TCKSelectionEvaluationException("operator "+TCKSelectionExpression.getOperatorValue(e.operator)+" invalid for data type "+e.checkvalue.getClass());
+
+ }
+ else {
+ throw new TCKSelectionEvaluationException("evaluation class "+expression+" is not understood");
+ }
+ }
+
+ private boolean evalInteger(TCKSelectionEnvironmentExpression e,Object value) {
+ int checkint=Integer.parseInt(e.checkvalue.toString());
+ Number number=(Number) value;
+ int valueint=number.intValue();
+
+ switch(e.operator) {
+
+ case TCKSelectionExpression.EQ :
+ return checkint==valueint;
+ case TCKSelectionExpression.NE :
+ return checkint!=valueint;
+ case TCKSelectionExpression.GE : // check is same
+ return checkint>=valueint;
+ case TCKSelectionExpression.GT : // is ge incoming
+ return checkint>valueint;
+ case TCKSelectionExpression.LE :
+ return checkint<=valueint;
+ case TCKSelectionExpression.LT : // checkdate is le incoming
+ return checkint<valueint;
+
+ }
+ throw new IllegalArgumentException("operator is invalid");
+ }
+
+ private void report(String string) {
+ if(trace) System.out.println(string);
+
+ }
+
+ public void trace(boolean b) {
+ trace=b;
+
+ }
+}