Removing files that are no longer present in the final version of the book samples
1.1 --- a/samples/componentinjection/build.xml Sat Jun 14 10:32:31 2008 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,69 +0,0 @@
1.4 -<?xml version="1.0" encoding="UTF-8"?>
1.5 -<!-- You may freely edit this file. See commented blocks below for -->
1.6 -<!-- some examples of how to customize the build. -->
1.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
1.8 -<project name="componentinjection" default="default" basedir=".">
1.9 - <description>Builds, tests, and runs the project componentinjection.</description>
1.10 - <import file="nbproject/build-impl.xml"/>
1.11 - <!--
1.12 -
1.13 - There exist several targets which are by default empty and which can be
1.14 - used for execution of your tasks. These targets are usually executed
1.15 - before and after some main targets. They are:
1.16 -
1.17 - -pre-init: called before initialization of project properties
1.18 - -post-init: called after initialization of project properties
1.19 - -pre-compile: called before javac compilation
1.20 - -post-compile: called after javac compilation
1.21 - -pre-compile-single: called before javac compilation of single file
1.22 - -post-compile-single: called after javac compilation of single file
1.23 - -pre-compile-test: called before javac compilation of JUnit tests
1.24 - -post-compile-test: called after javac compilation of JUnit tests
1.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
1.26 - -post-compile-test-single: called after javac compilation of single JUunit test
1.27 - -pre-jar: called before JAR building
1.28 - -post-jar: called after JAR building
1.29 - -post-clean: called after cleaning build products
1.30 -
1.31 - (Targets beginning with '-' are not intended to be called on their own.)
1.32 -
1.33 - Example of inserting an obfuscator after compilation could look like this:
1.34 -
1.35 - <target name="-post-compile">
1.36 - <obfuscate>
1.37 - <fileset dir="${build.classes.dir}"/>
1.38 - </obfuscate>
1.39 - </target>
1.40 -
1.41 - For list of available properties check the imported
1.42 - nbproject/build-impl.xml file.
1.43 -
1.44 -
1.45 - Another way to customize the build is by overriding existing main targets.
1.46 - The targets of interest are:
1.47 -
1.48 - -init-macrodef-javac: defines macro for javac compilation
1.49 - -init-macrodef-junit: defines macro for junit execution
1.50 - -init-macrodef-debug: defines macro for class debugging
1.51 - -init-macrodef-java: defines macro for class execution
1.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
1.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
1.54 - run: execution of project
1.55 - -javadoc-build: Javadoc generation
1.56 - test-report: JUnit report generation
1.57 -
1.58 - An example of overriding the target for project execution could look like this:
1.59 -
1.60 - <target name="run" depends="componentinjection-impl.jar">
1.61 - <exec dir="bin" executable="launcher.exe">
1.62 - <arg file="${dist.jar}"/>
1.63 - </exec>
1.64 - </target>
1.65 -
1.66 - Notice that the overridden target depends on the jar target and not only on
1.67 - the compile target as the regular run target does. Again, for a list of available
1.68 - properties which you can use, check the target you are overriding in the
1.69 - nbproject/build-impl.xml file.
1.70 -
1.71 - -->
1.72 -</project>
2.1 --- a/samples/componentinjection/nbproject/build-impl.xml Sat Jun 14 10:32:31 2008 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,627 +0,0 @@
2.4 -<?xml version="1.0" encoding="UTF-8"?>
2.5 -<!--
2.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
2.7 -*** EDIT ../build.xml INSTEAD ***
2.8 -
2.9 -For the purpose of easier reading the script
2.10 -is divided into following sections:
2.11 -
2.12 - - initialization
2.13 - - compilation
2.14 - - jar
2.15 - - execution
2.16 - - debugging
2.17 - - javadoc
2.18 - - junit compilation
2.19 - - junit execution
2.20 - - junit debugging
2.21 - - applet
2.22 - - cleanup
2.23 -
2.24 - -->
2.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="componentinjection-impl">
2.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
2.27 - <!--
2.28 - ======================
2.29 - INITIALIZATION SECTION
2.30 - ======================
2.31 - -->
2.32 - <target name="-pre-init">
2.33 - <!-- Empty placeholder for easier customization. -->
2.34 - <!-- You can override this target in the ../build.xml file. -->
2.35 - </target>
2.36 - <target depends="-pre-init" name="-init-private">
2.37 - <property file="nbproject/private/config.properties"/>
2.38 - <property file="nbproject/private/configs/${config}.properties"/>
2.39 - <property file="nbproject/private/private.properties"/>
2.40 - </target>
2.41 - <target depends="-pre-init,-init-private" name="-init-user">
2.42 - <property file="${user.properties.file}"/>
2.43 - <!-- The two properties below are usually overridden -->
2.44 - <!-- by the active platform. Just a fallback. -->
2.45 - <property name="default.javac.source" value="1.4"/>
2.46 - <property name="default.javac.target" value="1.4"/>
2.47 - </target>
2.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
2.49 - <property file="nbproject/configs/${config}.properties"/>
2.50 - <property file="nbproject/project.properties"/>
2.51 - </target>
2.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
2.53 - <available file="${manifest.file}" property="manifest.available"/>
2.54 - <condition property="manifest.available+main.class">
2.55 - <and>
2.56 - <isset property="manifest.available"/>
2.57 - <isset property="main.class"/>
2.58 - <not>
2.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
2.60 - </not>
2.61 - </and>
2.62 - </condition>
2.63 - <condition property="manifest.available+main.class+mkdist.available">
2.64 - <and>
2.65 - <istrue value="${manifest.available+main.class}"/>
2.66 - <isset property="libs.CopyLibs.classpath"/>
2.67 - </and>
2.68 - </condition>
2.69 - <condition property="have.tests">
2.70 - <or>
2.71 - <available file="${test.src.dir}"/>
2.72 - </or>
2.73 - </condition>
2.74 - <condition property="have.sources">
2.75 - <or>
2.76 - <available file="${src.dir}"/>
2.77 - </or>
2.78 - </condition>
2.79 - <condition property="netbeans.home+have.tests">
2.80 - <and>
2.81 - <isset property="netbeans.home"/>
2.82 - <isset property="have.tests"/>
2.83 - </and>
2.84 - </condition>
2.85 - <condition property="no.javadoc.preview">
2.86 - <and>
2.87 - <isset property="javadoc.preview"/>
2.88 - <isfalse value="${javadoc.preview}"/>
2.89 - </and>
2.90 - </condition>
2.91 - <property name="run.jvmargs" value=""/>
2.92 - <property name="javac.compilerargs" value=""/>
2.93 - <property name="work.dir" value="${basedir}"/>
2.94 - <condition property="no.deps">
2.95 - <and>
2.96 - <istrue value="${no.dependencies}"/>
2.97 - </and>
2.98 - </condition>
2.99 - <property name="javac.debug" value="true"/>
2.100 - <property name="javadoc.preview" value="true"/>
2.101 - <property name="application.args" value=""/>
2.102 - <property name="source.encoding" value="${file.encoding}"/>
2.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
2.104 - <and>
2.105 - <isset property="javadoc.encoding"/>
2.106 - <not>
2.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
2.108 - </not>
2.109 - </and>
2.110 - </condition>
2.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
2.112 - <property name="includes" value="**"/>
2.113 - <property name="excludes" value=""/>
2.114 - <property name="do.depend" value="false"/>
2.115 - <condition property="do.depend.true">
2.116 - <istrue value="${do.depend}"/>
2.117 - </condition>
2.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
2.119 - <and>
2.120 - <isset property="jaxws.endorsed.dir"/>
2.121 - <available file="nbproject/jaxws-build.xml"/>
2.122 - </and>
2.123 - </condition>
2.124 - </target>
2.125 - <target name="-post-init">
2.126 - <!-- Empty placeholder for easier customization. -->
2.127 - <!-- You can override this target in the ../build.xml file. -->
2.128 - </target>
2.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
2.130 - <fail unless="src.dir">Must set src.dir</fail>
2.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
2.132 - <fail unless="build.dir">Must set build.dir</fail>
2.133 - <fail unless="dist.dir">Must set dist.dir</fail>
2.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
2.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
2.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
2.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
2.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
2.139 - <fail unless="dist.jar">Must set dist.jar</fail>
2.140 - </target>
2.141 - <target name="-init-macrodef-property">
2.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
2.143 - <attribute name="name"/>
2.144 - <attribute name="value"/>
2.145 - <sequential>
2.146 - <property name="@{name}" value="${@{value}}"/>
2.147 - </sequential>
2.148 - </macrodef>
2.149 - </target>
2.150 - <target name="-init-macrodef-javac">
2.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
2.152 - <attribute default="${src.dir}" name="srcdir"/>
2.153 - <attribute default="${build.classes.dir}" name="destdir"/>
2.154 - <attribute default="${javac.classpath}" name="classpath"/>
2.155 - <attribute default="${includes}" name="includes"/>
2.156 - <attribute default="${excludes}" name="excludes"/>
2.157 - <attribute default="${javac.debug}" name="debug"/>
2.158 - <attribute default="" name="sourcepath"/>
2.159 - <element name="customize" optional="true"/>
2.160 - <sequential>
2.161 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
2.162 - <classpath>
2.163 - <path path="@{classpath}"/>
2.164 - </classpath>
2.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
2.166 - <customize/>
2.167 - </javac>
2.168 - </sequential>
2.169 - </macrodef>
2.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
2.171 - <attribute default="${src.dir}" name="srcdir"/>
2.172 - <attribute default="${build.classes.dir}" name="destdir"/>
2.173 - <attribute default="${javac.classpath}" name="classpath"/>
2.174 - <sequential>
2.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
2.176 - <classpath>
2.177 - <path path="@{classpath}"/>
2.178 - </classpath>
2.179 - </depend>
2.180 - </sequential>
2.181 - </macrodef>
2.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
2.183 - <attribute default="${build.classes.dir}" name="destdir"/>
2.184 - <sequential>
2.185 - <fail unless="javac.includes">Must set javac.includes</fail>
2.186 - <pathconvert pathsep="," property="javac.includes.binary">
2.187 - <path>
2.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
2.189 - </path>
2.190 - <globmapper from="*.java" to="*.class"/>
2.191 - </pathconvert>
2.192 - <delete>
2.193 - <files includes="${javac.includes.binary}"/>
2.194 - </delete>
2.195 - </sequential>
2.196 - </macrodef>
2.197 - </target>
2.198 - <target name="-init-macrodef-junit">
2.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
2.200 - <attribute default="${includes}" name="includes"/>
2.201 - <attribute default="${excludes}" name="excludes"/>
2.202 - <attribute default="**" name="testincludes"/>
2.203 - <sequential>
2.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
2.205 - <batchtest todir="${build.test.results.dir}">
2.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
2.207 - <filename name="@{testincludes}"/>
2.208 - </fileset>
2.209 - </batchtest>
2.210 - <classpath>
2.211 - <path path="${run.test.classpath}"/>
2.212 - </classpath>
2.213 - <syspropertyset>
2.214 - <propertyref prefix="test-sys-prop."/>
2.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
2.216 - </syspropertyset>
2.217 - <formatter type="brief" usefile="false"/>
2.218 - <formatter type="xml"/>
2.219 - <jvmarg line="${run.jvmargs}"/>
2.220 - </junit>
2.221 - </sequential>
2.222 - </macrodef>
2.223 - </target>
2.224 - <target name="-init-macrodef-nbjpda">
2.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
2.226 - <attribute default="${main.class}" name="name"/>
2.227 - <attribute default="${debug.classpath}" name="classpath"/>
2.228 - <attribute default="" name="stopclassname"/>
2.229 - <sequential>
2.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
2.231 - <classpath>
2.232 - <path path="@{classpath}"/>
2.233 - </classpath>
2.234 - </nbjpdastart>
2.235 - </sequential>
2.236 - </macrodef>
2.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
2.238 - <attribute default="${build.classes.dir}" name="dir"/>
2.239 - <sequential>
2.240 - <nbjpdareload>
2.241 - <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
2.242 - </nbjpdareload>
2.243 - </sequential>
2.244 - </macrodef>
2.245 - </target>
2.246 - <target name="-init-debug-args">
2.247 - <property name="version-output" value="java version "${ant.java.version}"/>
2.248 - <condition property="have-jdk-older-than-1.4">
2.249 - <or>
2.250 - <contains string="${version-output}" substring="java version "1.0"/>
2.251 - <contains string="${version-output}" substring="java version "1.1"/>
2.252 - <contains string="${version-output}" substring="java version "1.2"/>
2.253 - <contains string="${version-output}" substring="java version "1.3"/>
2.254 - </or>
2.255 - </condition>
2.256 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
2.257 - <istrue value="${have-jdk-older-than-1.4}"/>
2.258 - </condition>
2.259 - </target>
2.260 - <target depends="-init-debug-args" name="-init-macrodef-debug">
2.261 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
2.262 - <attribute default="${main.class}" name="classname"/>
2.263 - <attribute default="${debug.classpath}" name="classpath"/>
2.264 - <element name="customize" optional="true"/>
2.265 - <sequential>
2.266 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.267 - <jvmarg line="${debug-args-line}"/>
2.268 - <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
2.269 - <jvmarg line="${run.jvmargs}"/>
2.270 - <classpath>
2.271 - <path path="@{classpath}"/>
2.272 - </classpath>
2.273 - <syspropertyset>
2.274 - <propertyref prefix="run-sys-prop."/>
2.275 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.276 - </syspropertyset>
2.277 - <customize/>
2.278 - </java>
2.279 - </sequential>
2.280 - </macrodef>
2.281 - </target>
2.282 - <target name="-init-macrodef-java">
2.283 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
2.284 - <attribute default="${main.class}" name="classname"/>
2.285 - <element name="customize" optional="true"/>
2.286 - <sequential>
2.287 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.288 - <jvmarg line="${run.jvmargs}"/>
2.289 - <classpath>
2.290 - <path path="${run.classpath}"/>
2.291 - </classpath>
2.292 - <syspropertyset>
2.293 - <propertyref prefix="run-sys-prop."/>
2.294 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.295 - </syspropertyset>
2.296 - <customize/>
2.297 - </java>
2.298 - </sequential>
2.299 - </macrodef>
2.300 - </target>
2.301 - <target name="-init-presetdef-jar">
2.302 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
2.303 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
2.304 - <j2seproject1:fileset dir="${build.classes.dir}"/>
2.305 - </jar>
2.306 - </presetdef>
2.307 - </target>
2.308 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
2.309 - <!--
2.310 - ===================
2.311 - COMPILATION SECTION
2.312 - ===================
2.313 - -->
2.314 - <target depends="init" name="deps-jar" unless="no.deps"/>
2.315 - <target depends="init,deps-jar" name="-pre-pre-compile">
2.316 - <mkdir dir="${build.classes.dir}"/>
2.317 - </target>
2.318 - <target name="-pre-compile">
2.319 - <!-- Empty placeholder for easier customization. -->
2.320 - <!-- You can override this target in the ../build.xml file. -->
2.321 - </target>
2.322 - <target if="do.depend.true" name="-compile-depend">
2.323 - <j2seproject3:depend/>
2.324 - </target>
2.325 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
2.326 - <j2seproject3:javac/>
2.327 - <copy todir="${build.classes.dir}">
2.328 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.329 - </copy>
2.330 - </target>
2.331 - <target name="-post-compile">
2.332 - <!-- Empty placeholder for easier customization. -->
2.333 - <!-- You can override this target in the ../build.xml file. -->
2.334 - </target>
2.335 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
2.336 - <target name="-pre-compile-single">
2.337 - <!-- Empty placeholder for easier customization. -->
2.338 - <!-- You can override this target in the ../build.xml file. -->
2.339 - </target>
2.340 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
2.341 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.342 - <j2seproject3:force-recompile/>
2.343 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
2.344 - </target>
2.345 - <target name="-post-compile-single">
2.346 - <!-- Empty placeholder for easier customization. -->
2.347 - <!-- You can override this target in the ../build.xml file. -->
2.348 - </target>
2.349 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
2.350 - <!--
2.351 - ====================
2.352 - JAR BUILDING SECTION
2.353 - ====================
2.354 - -->
2.355 - <target depends="init" name="-pre-pre-jar">
2.356 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
2.357 - <mkdir dir="${dist.jar.dir}"/>
2.358 - </target>
2.359 - <target name="-pre-jar">
2.360 - <!-- Empty placeholder for easier customization. -->
2.361 - <!-- You can override this target in the ../build.xml file. -->
2.362 - </target>
2.363 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
2.364 - <j2seproject1:jar/>
2.365 - </target>
2.366 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
2.367 - <j2seproject1:jar manifest="${manifest.file}"/>
2.368 - </target>
2.369 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
2.370 - <j2seproject1:jar manifest="${manifest.file}">
2.371 - <j2seproject1:manifest>
2.372 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
2.373 - </j2seproject1:manifest>
2.374 - </j2seproject1:jar>
2.375 - <echo>To run this application from the command line without Ant, try:</echo>
2.376 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.377 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.378 - <pathconvert property="run.classpath.with.dist.jar">
2.379 - <path path="${run.classpath}"/>
2.380 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
2.381 - </pathconvert>
2.382 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
2.383 - </target>
2.384 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
2.385 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.386 - <pathconvert property="run.classpath.without.build.classes.dir">
2.387 - <path path="${run.classpath}"/>
2.388 - <map from="${build.classes.dir.resolved}" to=""/>
2.389 - </pathconvert>
2.390 - <pathconvert pathsep=" " property="jar.classpath">
2.391 - <path path="${run.classpath.without.build.classes.dir}"/>
2.392 - <chainedmapper>
2.393 - <flattenmapper/>
2.394 - <globmapper from="*" to="lib/*"/>
2.395 - </chainedmapper>
2.396 - </pathconvert>
2.397 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
2.398 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
2.399 - <fileset dir="${build.classes.dir}"/>
2.400 - <manifest>
2.401 - <attribute name="Main-Class" value="${main.class}"/>
2.402 - <attribute name="Class-Path" value="${jar.classpath}"/>
2.403 - </manifest>
2.404 - </copylibs>
2.405 - <echo>To run this application from the command line without Ant, try:</echo>
2.406 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.407 - <echo>java -jar "${dist.jar.resolved}"</echo>
2.408 - </target>
2.409 - <target name="-post-jar">
2.410 - <!-- Empty placeholder for easier customization. -->
2.411 - <!-- You can override this target in the ../build.xml file. -->
2.412 - </target>
2.413 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
2.414 - <!--
2.415 - =================
2.416 - EXECUTION SECTION
2.417 - =================
2.418 - -->
2.419 - <target depends="init,compile" description="Run a main class." name="run">
2.420 - <j2seproject1:java>
2.421 - <customize>
2.422 - <arg line="${application.args}"/>
2.423 - </customize>
2.424 - </j2seproject1:java>
2.425 - </target>
2.426 - <target name="-do-not-recompile">
2.427 - <property name="javac.includes.binary" value=""/>
2.428 - </target>
2.429 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
2.430 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
2.431 - <j2seproject1:java classname="${run.class}"/>
2.432 - </target>
2.433 - <!--
2.434 - =================
2.435 - DEBUGGING SECTION
2.436 - =================
2.437 - -->
2.438 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
2.439 - <j2seproject1:nbjpdastart name="${debug.class}"/>
2.440 - </target>
2.441 - <target depends="init,compile" name="-debug-start-debuggee">
2.442 - <j2seproject3:debug>
2.443 - <customize>
2.444 - <arg line="${application.args}"/>
2.445 - </customize>
2.446 - </j2seproject3:debug>
2.447 - </target>
2.448 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
2.449 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
2.450 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
2.451 - </target>
2.452 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
2.453 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
2.454 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
2.455 - <j2seproject3:debug classname="${debug.class}"/>
2.456 - </target>
2.457 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
2.458 - <target depends="init" name="-pre-debug-fix">
2.459 - <fail unless="fix.includes">Must set fix.includes</fail>
2.460 - <property name="javac.includes" value="${fix.includes}.java"/>
2.461 - </target>
2.462 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
2.463 - <j2seproject1:nbjpdareload/>
2.464 - </target>
2.465 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
2.466 - <!--
2.467 - ===============
2.468 - JAVADOC SECTION
2.469 - ===============
2.470 - -->
2.471 - <target depends="init" name="-javadoc-build">
2.472 - <mkdir dir="${dist.javadoc.dir}"/>
2.473 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
2.474 - <classpath>
2.475 - <path path="${javac.classpath}"/>
2.476 - </classpath>
2.477 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
2.478 - <filename name="**/*.java"/>
2.479 - </fileset>
2.480 - </javadoc>
2.481 - </target>
2.482 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
2.483 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
2.484 - </target>
2.485 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
2.486 - <!--
2.487 - =========================
2.488 - JUNIT COMPILATION SECTION
2.489 - =========================
2.490 - -->
2.491 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
2.492 - <mkdir dir="${build.test.classes.dir}"/>
2.493 - </target>
2.494 - <target name="-pre-compile-test">
2.495 - <!-- Empty placeholder for easier customization. -->
2.496 - <!-- You can override this target in the ../build.xml file. -->
2.497 - </target>
2.498 - <target if="do.depend.true" name="-compile-test-depend">
2.499 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.500 - </target>
2.501 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
2.502 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.503 - <copy todir="${build.test.classes.dir}">
2.504 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.505 - </copy>
2.506 - </target>
2.507 - <target name="-post-compile-test">
2.508 - <!-- Empty placeholder for easier customization. -->
2.509 - <!-- You can override this target in the ../build.xml file. -->
2.510 - </target>
2.511 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
2.512 - <target name="-pre-compile-test-single">
2.513 - <!-- Empty placeholder for easier customization. -->
2.514 - <!-- You can override this target in the ../build.xml file. -->
2.515 - </target>
2.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
2.517 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.518 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
2.519 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
2.520 - <copy todir="${build.test.classes.dir}">
2.521 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.522 - </copy>
2.523 - </target>
2.524 - <target name="-post-compile-test-single">
2.525 - <!-- Empty placeholder for easier customization. -->
2.526 - <!-- You can override this target in the ../build.xml file. -->
2.527 - </target>
2.528 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
2.529 - <!--
2.530 - =======================
2.531 - JUNIT EXECUTION SECTION
2.532 - =======================
2.533 - -->
2.534 - <target depends="init" if="have.tests" name="-pre-test-run">
2.535 - <mkdir dir="${build.test.results.dir}"/>
2.536 - </target>
2.537 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
2.538 - <j2seproject3:junit testincludes="**/*Test.java"/>
2.539 - </target>
2.540 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
2.541 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.542 - </target>
2.543 - <target depends="init" if="have.tests" name="test-report"/>
2.544 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
2.545 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
2.546 - <target depends="init" if="have.tests" name="-pre-test-run-single">
2.547 - <mkdir dir="${build.test.results.dir}"/>
2.548 - </target>
2.549 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
2.550 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
2.551 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
2.552 - </target>
2.553 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
2.554 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.555 - </target>
2.556 - <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
2.557 - <!--
2.558 - =======================
2.559 - JUNIT DEBUGGING SECTION
2.560 - =======================
2.561 - -->
2.562 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
2.563 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
2.564 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
2.565 - <delete file="${test.report.file}"/>
2.566 - <mkdir dir="${build.test.results.dir}"/>
2.567 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
2.568 - <customize>
2.569 - <syspropertyset>
2.570 - <propertyref prefix="test-sys-prop."/>
2.571 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
2.572 - </syspropertyset>
2.573 - <arg value="${test.class}"/>
2.574 - <arg value="showoutput=true"/>
2.575 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
2.576 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
2.577 - </customize>
2.578 - </j2seproject3:debug>
2.579 - </target>
2.580 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
2.581 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
2.582 - </target>
2.583 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
2.584 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
2.585 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
2.586 - </target>
2.587 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
2.588 - <!--
2.589 - =========================
2.590 - APPLET EXECUTION SECTION
2.591 - =========================
2.592 - -->
2.593 - <target depends="init,compile-single" name="run-applet">
2.594 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.595 - <j2seproject1:java classname="sun.applet.AppletViewer">
2.596 - <customize>
2.597 - <arg value="${applet.url}"/>
2.598 - </customize>
2.599 - </j2seproject1:java>
2.600 - </target>
2.601 - <!--
2.602 - =========================
2.603 - APPLET DEBUGGING SECTION
2.604 - =========================
2.605 - -->
2.606 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
2.607 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.608 - <j2seproject3:debug classname="sun.applet.AppletViewer">
2.609 - <customize>
2.610 - <arg value="${applet.url}"/>
2.611 - </customize>
2.612 - </j2seproject3:debug>
2.613 - </target>
2.614 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
2.615 - <!--
2.616 - ===============
2.617 - CLEANUP SECTION
2.618 - ===============
2.619 - -->
2.620 - <target depends="init" name="deps-clean" unless="no.deps"/>
2.621 - <target depends="init" name="-do-clean">
2.622 - <delete dir="${build.dir}"/>
2.623 - <delete dir="${dist.dir}"/>
2.624 - </target>
2.625 - <target name="-post-clean">
2.626 - <!-- Empty placeholder for easier customization. -->
2.627 - <!-- You can override this target in the ../build.xml file. -->
2.628 - </target>
2.629 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
2.630 -</project>
3.1 --- a/samples/componentinjection/nbproject/genfiles.properties Sat Jun 14 10:32:31 2008 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,8 +0,0 @@
3.4 -build.xml.data.CRC32=72cbbae6
3.5 -build.xml.script.CRC32=72ca7645
3.6 -build.xml.stylesheet.CRC32=be360661
3.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
3.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
3.9 -nbproject/build-impl.xml.data.CRC32=72cbbae6
3.10 -nbproject/build-impl.xml.script.CRC32=a1a473ce
3.11 -nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
4.1 --- a/samples/componentinjection/nbproject/project.properties Sat Jun 14 10:32:31 2008 +0200
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,65 +0,0 @@
4.4 -build.classes.dir=${build.dir}/classes
4.5 -build.classes.excludes=**/*.java,**/*.form
4.6 -# This directory is removed when the project is cleaned:
4.7 -build.dir=build
4.8 -build.generated.dir=${build.dir}/generated
4.9 -# Only compile against the classpath explicitly listed here:
4.10 -build.sysclasspath=ignore
4.11 -build.test.classes.dir=${build.dir}/test/classes
4.12 -build.test.results.dir=${build.dir}/test/results
4.13 -debug.classpath=\
4.14 - ${run.classpath}
4.15 -debug.test.classpath=\
4.16 - ${run.test.classpath}
4.17 -# This directory is removed when the project is cleaned:
4.18 -dist.dir=dist
4.19 -dist.jar=${dist.dir}/componentinjection.jar
4.20 -dist.javadoc.dir=${dist.dir}/javadoc
4.21 -excludes=
4.22 -file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar
4.23 -file.reference.org-netbeans-insane.jar=../libs/dist/org-netbeans-insane.jar
4.24 -file.reference.org-netbeans-modules-nbjunit.jar=../libs/dist/org-netbeans-modules-nbjunit.jar
4.25 -file.reference.org-openide-util.jar=../libs/dist/org-openide-util.jar
4.26 -includes=**
4.27 -jar.compress=false
4.28 -javac.classpath=\
4.29 - ${file.reference.org-openide-util.jar}
4.30 -# Space-separated list of extra javac options
4.31 -javac.compilerargs=
4.32 -javac.deprecation=false
4.33 -javac.source=1.5
4.34 -javac.target=1.5
4.35 -javac.test.classpath=\
4.36 - ${javac.classpath}:\
4.37 - ${build.classes.dir}:\
4.38 - ${libs.junit.classpath}:\
4.39 - ${libs.junit_4.classpath}:\
4.40 - ${file.reference.junit-4.4.jar}:\
4.41 - ${file.reference.org-netbeans-insane.jar}:\
4.42 - ${file.reference.org-netbeans-modules-nbjunit.jar}
4.43 -javadoc.additionalparam=
4.44 -javadoc.author=false
4.45 -javadoc.encoding=${source.encoding}
4.46 -javadoc.noindex=false
4.47 -javadoc.nonavbar=false
4.48 -javadoc.notree=false
4.49 -javadoc.private=false
4.50 -javadoc.splitindex=true
4.51 -javadoc.use=true
4.52 -javadoc.version=false
4.53 -javadoc.windowtitle=
4.54 -meta.inf.dir=${src.dir}/META-INF
4.55 -platform.active=default_platform
4.56 -run.classpath=\
4.57 - ${javac.classpath}:\
4.58 - ${build.classes.dir}
4.59 -# Space-separated list of JVM arguments used when running the project
4.60 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
4.61 -# or test-sys-prop.name=value to set system properties for unit tests):
4.62 -run.jvmargs=
4.63 -run.test.classpath=\
4.64 - ${javac.test.classpath}:\
4.65 - ${build.test.classes.dir}
4.66 -source.encoding=UTF-8
4.67 -src.dir=src
4.68 -test.src.dir=test
5.1 --- a/samples/componentinjection/nbproject/project.xml Sat Jun 14 10:32:31 2008 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,16 +0,0 @@
5.4 -<?xml version="1.0" encoding="UTF-8"?>
5.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
5.6 - <type>org.netbeans.modules.java.j2seproject</type>
5.7 - <configuration>
5.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
5.9 - <name>componentinjection</name>
5.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
5.11 - <source-roots>
5.12 - <root id="src.dir"/>
5.13 - </source-roots>
5.14 - <test-roots>
5.15 - <root id="test.src.dir"/>
5.16 - </test-roots>
5.17 - </data>
5.18 - </configuration>
5.19 -</project>
6.1 --- a/samples/componentinjection/src/org/apidesign/component/DefineInjectionSlot.java Sat Jun 14 10:32:31 2008 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,23 +0,0 @@
6.4 -package org.apidesign.component;
6.5 -
6.6 -import java.util.Collection;
6.7 -import org.openide.util.Lookup;
6.8 -
6.9 -public class DefineInjectionSlot {
6.10 - private DefineInjectionSlot() {
6.11 - }
6.12 -
6.13 - // BEGIN: lookup.define.slot
6.14 - public static <T> T singleSlot(Class<T> clazz) {
6.15 - // get one implementation
6.16 - T instance = Lookup.getDefault().lookup(clazz);
6.17 - return instance;
6.18 - }
6.19 -
6.20 - public static <T> Collection<? extends T> multiSlot(Class<T> clazz) {
6.21 - // get all registered implementations
6.22 - Collection<? extends T> all = Lookup.getDefault().lookupAll(clazz);
6.23 - return all;
6.24 - }
6.25 - // END: lookup.define.slot
6.26 -}
7.1 --- a/samples/componentinjection/src/org/apidesign/component/InjectionSlot.java Sat Jun 14 10:32:31 2008 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,18 +0,0 @@
7.4 -package org.apidesign.component;
7.5 -
7.6 -import java.util.Collection;
7.7 -import org.openide.util.Lookup;
7.8 -
7.9 -// BEGIN: lookup.define.slot
7.10 -public class InjectionSlot {
7.11 - public static InjectionSlot singleSlot() {
7.12 - // get one implementation
7.13 - return Lookup.getDefault().lookup(InjectionSlot.class);
7.14 - }
7.15 -
7.16 - public static Collection<? extends InjectionSlot> multiSlot() {
7.17 - // get all registered implementations
7.18 - return Lookup.getDefault().lookupAll(InjectionSlot.class);
7.19 - }
7.20 -}
7.21 -// END: lookup.define.slot
8.1 --- a/samples/componentinjection/src/org/apidesign/component/InjectionViaServiceLoader.java Sat Jun 14 10:32:31 2008 +0200
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,22 +0,0 @@
8.4 -package org.apidesign.component;
8.5 -
8.6 -import java.util.Collection;
8.7 -import java.util.ServiceLoader;
8.8 -import org.openide.util.Lookup;
8.9 -
8.10 -public class InjectionViaServiceLoader {
8.11 - private InjectionViaServiceLoader() {
8.12 - }
8.13 -
8.14 - // BEGIN: lookup.query.serviceloader
8.15 - public static InjectionSlot singleSlot() {
8.16 - // get one implementation
8.17 - return ServiceLoader.load(InjectionSlot.class).iterator().next();
8.18 - }
8.19 -
8.20 - public static Iterable<? extends InjectionSlot> multiSlot() {
8.21 - // get all registered implementations
8.22 - return ServiceLoader.load(InjectionSlot.class);
8.23 - }
8.24 - // END: lookup.query.serviceloader
8.25 -}
9.1 --- a/samples/componentinjection/src/org/apidesign/component/property/ToolkitFactory.java Sat Jun 14 10:32:31 2008 +0200
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,323 +0,0 @@
9.4 -/*
9.5 - * To change this template, choose Tools | Templates
9.6 - * and open the template in the editor.
9.7 - */
9.8 -
9.9 -package org.apidesign.component.property;
9.10 -
9.11 -import java.awt.Button;
9.12 -import java.awt.Canvas;
9.13 -import java.awt.Checkbox;
9.14 -import java.awt.CheckboxMenuItem;
9.15 -import java.awt.Choice;
9.16 -import java.awt.Desktop;
9.17 -import java.awt.Dialog;
9.18 -import java.awt.Dialog.ModalExclusionType;
9.19 -import java.awt.Dialog.ModalityType;
9.20 -import java.awt.Dimension;
9.21 -import java.awt.EventQueue;
9.22 -import java.awt.FileDialog;
9.23 -import java.awt.Font;
9.24 -import java.awt.FontMetrics;
9.25 -import java.awt.Frame;
9.26 -import java.awt.HeadlessException;
9.27 -import java.awt.Image;
9.28 -import java.awt.Label;
9.29 -import java.awt.List;
9.30 -import java.awt.Menu;
9.31 -import java.awt.MenuBar;
9.32 -import java.awt.MenuItem;
9.33 -import java.awt.Panel;
9.34 -import java.awt.PopupMenu;
9.35 -import java.awt.PrintJob;
9.36 -import java.awt.ScrollPane;
9.37 -import java.awt.Scrollbar;
9.38 -import java.awt.TextArea;
9.39 -import java.awt.TextField;
9.40 -import java.awt.Toolkit;
9.41 -import java.awt.Window;
9.42 -import java.awt.datatransfer.Clipboard;
9.43 -import java.awt.dnd.DragGestureEvent;
9.44 -import java.awt.dnd.InvalidDnDOperationException;
9.45 -import java.awt.dnd.peer.DragSourceContextPeer;
9.46 -import java.awt.font.TextAttribute;
9.47 -import java.awt.im.InputMethodHighlight;
9.48 -import java.awt.image.ColorModel;
9.49 -import java.awt.image.ImageObserver;
9.50 -import java.awt.image.ImageProducer;
9.51 -import java.awt.peer.ButtonPeer;
9.52 -import java.awt.peer.CanvasPeer;
9.53 -import java.awt.peer.CheckboxMenuItemPeer;
9.54 -import java.awt.peer.CheckboxPeer;
9.55 -import java.awt.peer.ChoicePeer;
9.56 -import java.awt.peer.DesktopPeer;
9.57 -import java.awt.peer.DialogPeer;
9.58 -import java.awt.peer.FileDialogPeer;
9.59 -import java.awt.peer.FontPeer;
9.60 -import java.awt.peer.FramePeer;
9.61 -import java.awt.peer.LabelPeer;
9.62 -import java.awt.peer.ListPeer;
9.63 -import java.awt.peer.MenuBarPeer;
9.64 -import java.awt.peer.MenuItemPeer;
9.65 -import java.awt.peer.MenuPeer;
9.66 -import java.awt.peer.PanelPeer;
9.67 -import java.awt.peer.PopupMenuPeer;
9.68 -import java.awt.peer.ScrollPanePeer;
9.69 -import java.awt.peer.ScrollbarPeer;
9.70 -import java.awt.peer.TextAreaPeer;
9.71 -import java.awt.peer.TextFieldPeer;
9.72 -import java.awt.peer.WindowPeer;
9.73 -import java.net.URL;
9.74 -import java.util.Map;
9.75 -import java.util.Properties;
9.76 -import java.util.logging.Level;
9.77 -import java.util.logging.Logger;
9.78 -
9.79 -public class ToolkitFactory {
9.80 - private static Logger LOG = Logger.getLogger(ToolkitFactory.class.getName());
9.81 -
9.82 - // BEGIN: lookup.init.toolkit
9.83 - public Toolkit getDefaultToolkit () {
9.84 - java.awt.Toolkit t = null;
9.85 - String classname = System.getProperty ("java.awt.Toolkit");
9.86 - if (classname != null) {
9.87 - try {
9.88 - Class c = Class.forName (classname);
9.89 - t = (java.awt.Toolkit)c.newInstance ();
9.90 - } catch (Exception ex) {
9.91 - LOG.log(
9.92 - Level.WARNING,
9.93 - "Cannot initialize toolkit: " + classname, ex
9.94 - );
9.95 - }
9.96 - }
9.97 - // fallback
9.98 - if (t == null) {
9.99 - t = new GenericAWTToolkit ();
9.100 - }
9.101 - return t;
9.102 - }
9.103 - // END: lookup.init.toolkit
9.104 -
9.105 - private static final class GenericAWTToolkit extends Toolkit {
9.106 - @Override
9.107 - protected DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException {
9.108 - throw new UnsupportedOperationException();
9.109 - }
9.110 -
9.111 - @Override
9.112 - protected ButtonPeer createButton(Button target) throws HeadlessException {
9.113 - throw new UnsupportedOperationException();
9.114 - }
9.115 -
9.116 - @Override
9.117 - protected TextFieldPeer createTextField(TextField target) throws HeadlessException {
9.118 - throw new UnsupportedOperationException();
9.119 - }
9.120 -
9.121 - @Override
9.122 - protected LabelPeer createLabel(Label target) throws HeadlessException {
9.123 - throw new UnsupportedOperationException();
9.124 - }
9.125 -
9.126 - @Override
9.127 - protected ListPeer createList(List target) throws HeadlessException {
9.128 - throw new UnsupportedOperationException();
9.129 - }
9.130 -
9.131 - @Override
9.132 - protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException {
9.133 - throw new UnsupportedOperationException();
9.134 - }
9.135 -
9.136 - @Override
9.137 - protected ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException {
9.138 - throw new UnsupportedOperationException();
9.139 - }
9.140 -
9.141 - @Override
9.142 - protected ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException {
9.143 - throw new UnsupportedOperationException();
9.144 - }
9.145 -
9.146 - @Override
9.147 - protected TextAreaPeer createTextArea(TextArea target) throws HeadlessException {
9.148 - throw new UnsupportedOperationException();
9.149 - }
9.150 -
9.151 - @Override
9.152 - protected ChoicePeer createChoice(Choice target) throws HeadlessException {
9.153 - throw new UnsupportedOperationException();
9.154 - }
9.155 -
9.156 - @Override
9.157 - protected FramePeer createFrame(Frame target) throws HeadlessException {
9.158 - throw new UnsupportedOperationException();
9.159 - }
9.160 -
9.161 - @Override
9.162 - protected CanvasPeer createCanvas(Canvas target) {
9.163 - throw new UnsupportedOperationException();
9.164 - }
9.165 -
9.166 - @Override
9.167 - protected PanelPeer createPanel(Panel target) {
9.168 - throw new UnsupportedOperationException();
9.169 - }
9.170 -
9.171 - @Override
9.172 - protected WindowPeer createWindow(Window target) throws HeadlessException {
9.173 - throw new UnsupportedOperationException();
9.174 - }
9.175 -
9.176 - @Override
9.177 - protected DialogPeer createDialog(Dialog target) throws HeadlessException {
9.178 - throw new UnsupportedOperationException();
9.179 - }
9.180 -
9.181 - @Override
9.182 - protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException {
9.183 - throw new UnsupportedOperationException();
9.184 - }
9.185 -
9.186 - @Override
9.187 - protected MenuPeer createMenu(Menu target) throws HeadlessException {
9.188 - throw new UnsupportedOperationException();
9.189 - }
9.190 -
9.191 - @Override
9.192 - protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException {
9.193 - throw new UnsupportedOperationException();
9.194 - }
9.195 -
9.196 - @Override
9.197 - protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException {
9.198 - throw new UnsupportedOperationException();
9.199 - }
9.200 -
9.201 - @Override
9.202 - protected FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException {
9.203 - throw new UnsupportedOperationException();
9.204 - }
9.205 -
9.206 - @Override
9.207 - protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException {
9.208 - throw new UnsupportedOperationException();
9.209 - }
9.210 -
9.211 - @Override
9.212 - protected FontPeer getFontPeer(String name, int style) {
9.213 - throw new UnsupportedOperationException();
9.214 - }
9.215 -
9.216 - @Override
9.217 - public Dimension getScreenSize() throws HeadlessException {
9.218 - throw new UnsupportedOperationException();
9.219 - }
9.220 -
9.221 - @Override
9.222 - public int getScreenResolution() throws HeadlessException {
9.223 - throw new UnsupportedOperationException();
9.224 - }
9.225 -
9.226 - @Override
9.227 - public ColorModel getColorModel() throws HeadlessException {
9.228 - throw new UnsupportedOperationException();
9.229 - }
9.230 -
9.231 - @Override
9.232 - public String[] getFontList() {
9.233 - throw new UnsupportedOperationException();
9.234 - }
9.235 -
9.236 - @Override
9.237 - public FontMetrics getFontMetrics(Font font) {
9.238 - throw new UnsupportedOperationException();
9.239 - }
9.240 -
9.241 - @Override
9.242 - public void sync() {
9.243 - throw new UnsupportedOperationException();
9.244 - }
9.245 -
9.246 - @Override
9.247 - public Image getImage(String filename) {
9.248 - throw new UnsupportedOperationException();
9.249 - }
9.250 -
9.251 - @Override
9.252 - public Image getImage(URL url) {
9.253 - throw new UnsupportedOperationException();
9.254 - }
9.255 -
9.256 - @Override
9.257 - public Image createImage(String filename) {
9.258 - throw new UnsupportedOperationException();
9.259 - }
9.260 -
9.261 - @Override
9.262 - public Image createImage(URL url) {
9.263 - throw new UnsupportedOperationException();
9.264 - }
9.265 -
9.266 - @Override
9.267 - public boolean prepareImage(Image image, int width, int height, ImageObserver observer) {
9.268 - throw new UnsupportedOperationException();
9.269 - }
9.270 -
9.271 - @Override
9.272 - public int checkImage(Image image, int width, int height, ImageObserver observer) {
9.273 - throw new UnsupportedOperationException();
9.274 - }
9.275 -
9.276 - @Override
9.277 - public Image createImage(ImageProducer producer) {
9.278 - throw new UnsupportedOperationException();
9.279 - }
9.280 -
9.281 - @Override
9.282 - public Image createImage(byte[] imagedata, int imageoffset, int imagelength) {
9.283 - throw new UnsupportedOperationException();
9.284 - }
9.285 -
9.286 - @Override
9.287 - public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
9.288 - throw new UnsupportedOperationException();
9.289 - }
9.290 -
9.291 - @Override
9.292 - public void beep() {
9.293 - throw new UnsupportedOperationException();
9.294 - }
9.295 -
9.296 - @Override
9.297 - public Clipboard getSystemClipboard() throws HeadlessException {
9.298 - throw new UnsupportedOperationException();
9.299 - }
9.300 -
9.301 - @Override
9.302 - protected EventQueue getSystemEventQueueImpl() {
9.303 - throw new UnsupportedOperationException();
9.304 - }
9.305 -
9.306 - @Override
9.307 - public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
9.308 - throw new UnsupportedOperationException();
9.309 - }
9.310 -
9.311 - @Override
9.312 - public boolean isModalityTypeSupported(ModalityType modalityType) {
9.313 - throw new UnsupportedOperationException();
9.314 - }
9.315 -
9.316 - @Override
9.317 - public boolean isModalExclusionTypeSupported(ModalExclusionType modalExclusionType) {
9.318 - throw new UnsupportedOperationException();
9.319 - }
9.320 -
9.321 - @Override
9.322 - public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException {
9.323 - throw new UnsupportedOperationException();
9.324 - }
9.325 - }
9.326 -}
10.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionSlotChangesTest.java Sat Jun 14 10:32:31 2008 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,65 +0,0 @@
10.4 -package org.apidesign.component;
10.5 -
10.6 -import java.util.Iterator;
10.7 -import org.junit.BeforeClass;
10.8 -import org.junit.Test;
10.9 -import org.netbeans.junit.MockServices;
10.10 -import org.openide.util.Lookup;
10.11 -import static org.junit.Assert.*;
10.12 -import org.openide.util.Lookup.Result;
10.13 -import org.openide.util.LookupEvent;
10.14 -import org.openide.util.LookupListener;
10.15 -
10.16 -public class InjectionSlotChangesTest {
10.17 - public InjectionSlotChangesTest() {
10.18 - }
10.19 -
10.20 - @BeforeClass
10.21 - public static void setUpClass() throws Exception {
10.22 - // this is a support for "dynamic" registration of any class
10.23 - // into the global pool of Lookup.getDefault() and java.util.ServiceLoader
10.24 - // either in @BeforeClass or @Before register
10.25 - // classes of the mock instances that you want your code
10.26 - // to find
10.27 - MockServices.setServices(ImplOne.class, ImplTwo.class);
10.28 - }
10.29 -
10.30 - @Test
10.31 - public void multiSlot() {
10.32 - Iterator<? extends InjectionSlot> it = InjectionSlot.multiSlot().iterator();
10.33 - assertTrue("Has at least one", it.hasNext());
10.34 - assertEquals("The first is ImplOne", ImplOne.class, it.next().getClass());
10.35 - assertTrue("Has two", it.hasNext());
10.36 - assertEquals("The second is ImplTwo", ImplTwo.class, it.next().getClass());
10.37 - assertFalse("No other instance registered", it.hasNext());
10.38 -
10.39 - // BEGIN: lookup.listener
10.40 - class Listener implements LookupListener {
10.41 - int cnt;
10.42 - public void resultChanged(LookupEvent arg0) {
10.43 - cnt++;
10.44 - }
10.45 - }
10.46 - Listener listener = new Listener();
10.47 - Lookup.Result<InjectionSlot> res =
10.48 - Lookup.getDefault().lookupResult(InjectionSlot.class);
10.49 - res.addLookupListener(listener);
10.50 - assertEquals("Two services now", 2, res.allInstances().size());
10.51 -
10.52 - MockServices.setServices(ImplTwo.class);
10.53 -
10.54 - assertEquals("One service only", 1, res.allInstances().size());
10.55 - assertEquals("One change in listener", 1, listener.cnt);
10.56 - assertEquals(
10.57 - "The second is ImplTwo",
10.58 - ImplTwo.class,
10.59 - res.allInstances().iterator().next().getClass()
10.60 - );
10.61 - // END: lookup.listener
10.62 - }
10.63 -
10.64 - public static final class ImplOne extends InjectionSlot {
10.65 - }
10.66 - public static final class ImplTwo extends InjectionSlot {
10.67 - }
10.68 -}
11.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionSlotTest.java Sat Jun 14 10:32:31 2008 +0200
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,54 +0,0 @@
11.4 -package org.apidesign.component;
11.5 -
11.6 -import java.util.Iterator;
11.7 -import org.junit.BeforeClass;
11.8 -import org.junit.Test;
11.9 -import org.netbeans.junit.MockServices;
11.10 -import static org.junit.Assert.*;
11.11 -
11.12 -// BEGIN: lookup.mockservices
11.13 -public class InjectionSlotTest {
11.14 - public InjectionSlotTest() {
11.15 - }
11.16 -
11.17 - @BeforeClass
11.18 - public static void setUpClass() throws Exception {
11.19 - // this is a support for "dynamic" registration of any class
11.20 - // into the global pool of Lookup.getDefault() and
11.21 - // java.util.ServiceLoader
11.22 - // either in @BeforeClass or @Before register
11.23 - // classes of the mock instances that you want your code
11.24 - // to find
11.25 - MockServices.setServices(ImplOne.class, ImplTwo.class);
11.26 - }
11.27 -
11.28 - @Test
11.29 - public void singleSlot() {
11.30 - InjectionSlot result = InjectionSlot.singleSlot();
11.31 - assertNotNull("Some result found", result);
11.32 - assertEquals(
11.33 - "The first is ImplOne", ImplOne.class, result.getClass()
11.34 - );
11.35 - }
11.36 -
11.37 - @Test
11.38 - public void multiSlot() {
11.39 - Iterator<? extends InjectionSlot> it =
11.40 - InjectionSlot.multiSlot().iterator();
11.41 - assertTrue("Has at least one", it.hasNext());
11.42 - assertEquals(
11.43 - "The first is ImplOne", ImplOne.class, it.next().getClass()
11.44 - );
11.45 - assertTrue("Has two", it.hasNext());
11.46 - assertEquals(
11.47 - "The second is ImplTwo", ImplTwo.class, it.next().getClass()
11.48 - );
11.49 - assertFalse("No other instance registered", it.hasNext());
11.50 - }
11.51 -
11.52 - public static final class ImplOne extends InjectionSlot {
11.53 - }
11.54 - public static final class ImplTwo extends InjectionSlot {
11.55 - }
11.56 -}
11.57 -// END: lookup.mockservices
12.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionViaServiceLoaderTest.java Sat Jun 14 10:32:31 2008 +0200
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,54 +0,0 @@
12.4 -package org.apidesign.component;
12.5 -
12.6 -import java.util.Iterator;
12.7 -import org.junit.BeforeClass;
12.8 -import org.junit.Test;
12.9 -import org.netbeans.junit.MockServices;
12.10 -import static org.junit.Assert.*;
12.11 -
12.12 -// BEGIN: lookup.mockservices.serviceloader
12.13 -public class InjectionViaServiceLoaderTest {
12.14 - public InjectionViaServiceLoaderTest() {
12.15 - }
12.16 -
12.17 - @BeforeClass
12.18 - public static void setUpClass() throws Exception {
12.19 - // this is a support for "dynamic" registration of any class
12.20 - // into the global pool of Lookup.getDefault() and
12.21 - // java.util.ServiceLoader
12.22 - // either in @BeforeClass or @Before register
12.23 - // classes of the mock instances that you want your code
12.24 - // to find
12.25 - MockServices.setServices(ImplOne.class, ImplTwo.class);
12.26 - }
12.27 -
12.28 - @Test
12.29 - public void singleSlot() {
12.30 - InjectionSlot result = InjectionViaServiceLoader.singleSlot();
12.31 - assertNotNull("Some result found", result);
12.32 - assertEquals(
12.33 - "The first is ImplOne", ImplOne.class, result.getClass()
12.34 - );
12.35 - }
12.36 -
12.37 - @Test
12.38 - public void multiSlot() {
12.39 - Iterator<? extends InjectionSlot> it =
12.40 - InjectionViaServiceLoader.multiSlot().iterator();
12.41 - assertTrue("Has at least one", it.hasNext());
12.42 - assertEquals(
12.43 - "The first is ImplOne", ImplOne.class, it.next().getClass()
12.44 - );
12.45 - assertTrue("Has two", it.hasNext());
12.46 - assertEquals(
12.47 - "The second is ImplTwo", ImplTwo.class, it.next().getClass()
12.48 - );
12.49 - assertFalse("No other instance registered", it.hasNext());
12.50 - }
12.51 -
12.52 - public static final class ImplOne extends InjectionSlot {
12.53 - }
12.54 - public static final class ImplTwo extends InjectionSlot {
12.55 - }
12.56 -}
12.57 -// END: lookup.mockservices.serviceloader
13.1 --- a/samples/composition/nbproject/build-impl.xml Sat Jun 14 10:32:31 2008 +0200
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,627 +0,0 @@
13.4 -<?xml version="1.0" encoding="UTF-8"?>
13.5 -<!--
13.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
13.7 -*** EDIT ../build.xml INSTEAD ***
13.8 -
13.9 -For the purpose of easier reading the script
13.10 -is divided into following sections:
13.11 -
13.12 - - initialization
13.13 - - compilation
13.14 - - jar
13.15 - - execution
13.16 - - debugging
13.17 - - javadoc
13.18 - - junit compilation
13.19 - - junit execution
13.20 - - junit debugging
13.21 - - applet
13.22 - - cleanup
13.23 -
13.24 - -->
13.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="composition-impl">
13.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
13.27 - <!--
13.28 - ======================
13.29 - INITIALIZATION SECTION
13.30 - ======================
13.31 - -->
13.32 - <target name="-pre-init">
13.33 - <!-- Empty placeholder for easier customization. -->
13.34 - <!-- You can override this target in the ../build.xml file. -->
13.35 - </target>
13.36 - <target depends="-pre-init" name="-init-private">
13.37 - <property file="nbproject/private/config.properties"/>
13.38 - <property file="nbproject/private/configs/${config}.properties"/>
13.39 - <property file="nbproject/private/private.properties"/>
13.40 - </target>
13.41 - <target depends="-pre-init,-init-private" name="-init-user">
13.42 - <property file="${user.properties.file}"/>
13.43 - <!-- The two properties below are usually overridden -->
13.44 - <!-- by the active platform. Just a fallback. -->
13.45 - <property name="default.javac.source" value="1.4"/>
13.46 - <property name="default.javac.target" value="1.4"/>
13.47 - </target>
13.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
13.49 - <property file="nbproject/configs/${config}.properties"/>
13.50 - <property file="nbproject/project.properties"/>
13.51 - </target>
13.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
13.53 - <available file="${manifest.file}" property="manifest.available"/>
13.54 - <condition property="manifest.available+main.class">
13.55 - <and>
13.56 - <isset property="manifest.available"/>
13.57 - <isset property="main.class"/>
13.58 - <not>
13.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
13.60 - </not>
13.61 - </and>
13.62 - </condition>
13.63 - <condition property="manifest.available+main.class+mkdist.available">
13.64 - <and>
13.65 - <istrue value="${manifest.available+main.class}"/>
13.66 - <isset property="libs.CopyLibs.classpath"/>
13.67 - </and>
13.68 - </condition>
13.69 - <condition property="have.tests">
13.70 - <or>
13.71 - <available file="${test.src.dir}"/>
13.72 - </or>
13.73 - </condition>
13.74 - <condition property="have.sources">
13.75 - <or>
13.76 - <available file="${src.dir}"/>
13.77 - </or>
13.78 - </condition>
13.79 - <condition property="netbeans.home+have.tests">
13.80 - <and>
13.81 - <isset property="netbeans.home"/>
13.82 - <isset property="have.tests"/>
13.83 - </and>
13.84 - </condition>
13.85 - <condition property="no.javadoc.preview">
13.86 - <and>
13.87 - <isset property="javadoc.preview"/>
13.88 - <isfalse value="${javadoc.preview}"/>
13.89 - </and>
13.90 - </condition>
13.91 - <property name="run.jvmargs" value=""/>
13.92 - <property name="javac.compilerargs" value=""/>
13.93 - <property name="work.dir" value="${basedir}"/>
13.94 - <condition property="no.deps">
13.95 - <and>
13.96 - <istrue value="${no.dependencies}"/>
13.97 - </and>
13.98 - </condition>
13.99 - <property name="javac.debug" value="true"/>
13.100 - <property name="javadoc.preview" value="true"/>
13.101 - <property name="application.args" value=""/>
13.102 - <property name="source.encoding" value="${file.encoding}"/>
13.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
13.104 - <and>
13.105 - <isset property="javadoc.encoding"/>
13.106 - <not>
13.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
13.108 - </not>
13.109 - </and>
13.110 - </condition>
13.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
13.112 - <property name="includes" value="**"/>
13.113 - <property name="excludes" value=""/>
13.114 - <property name="do.depend" value="false"/>
13.115 - <condition property="do.depend.true">
13.116 - <istrue value="${do.depend}"/>
13.117 - </condition>
13.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
13.119 - <and>
13.120 - <isset property="jaxws.endorsed.dir"/>
13.121 - <available file="nbproject/jaxws-build.xml"/>
13.122 - </and>
13.123 - </condition>
13.124 - </target>
13.125 - <target name="-post-init">
13.126 - <!-- Empty placeholder for easier customization. -->
13.127 - <!-- You can override this target in the ../build.xml file. -->
13.128 - </target>
13.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
13.130 - <fail unless="src.dir">Must set src.dir</fail>
13.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
13.132 - <fail unless="build.dir">Must set build.dir</fail>
13.133 - <fail unless="dist.dir">Must set dist.dir</fail>
13.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
13.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
13.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
13.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
13.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
13.139 - <fail unless="dist.jar">Must set dist.jar</fail>
13.140 - </target>
13.141 - <target name="-init-macrodef-property">
13.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
13.143 - <attribute name="name"/>
13.144 - <attribute name="value"/>
13.145 - <sequential>
13.146 - <property name="@{name}" value="${@{value}}"/>
13.147 - </sequential>
13.148 - </macrodef>
13.149 - </target>
13.150 - <target name="-init-macrodef-javac">
13.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
13.152 - <attribute default="${src.dir}" name="srcdir"/>
13.153 - <attribute default="${build.classes.dir}" name="destdir"/>
13.154 - <attribute default="${javac.classpath}" name="classpath"/>
13.155 - <attribute default="${includes}" name="includes"/>
13.156 - <attribute default="${excludes}" name="excludes"/>
13.157 - <attribute default="${javac.debug}" name="debug"/>
13.158 - <attribute default="" name="sourcepath"/>
13.159 - <element name="customize" optional="true"/>
13.160 - <sequential>
13.161 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
13.162 - <classpath>
13.163 - <path path="@{classpath}"/>
13.164 - </classpath>
13.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
13.166 - <customize/>
13.167 - </javac>
13.168 - </sequential>
13.169 - </macrodef>
13.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
13.171 - <attribute default="${src.dir}" name="srcdir"/>
13.172 - <attribute default="${build.classes.dir}" name="destdir"/>
13.173 - <attribute default="${javac.classpath}" name="classpath"/>
13.174 - <sequential>
13.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
13.176 - <classpath>
13.177 - <path path="@{classpath}"/>
13.178 - </classpath>
13.179 - </depend>
13.180 - </sequential>
13.181 - </macrodef>
13.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
13.183 - <attribute default="${build.classes.dir}" name="destdir"/>
13.184 - <sequential>
13.185 - <fail unless="javac.includes">Must set javac.includes</fail>
13.186 - <pathconvert pathsep="," property="javac.includes.binary">
13.187 - <path>
13.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
13.189 - </path>
13.190 - <globmapper from="*.java" to="*.class"/>
13.191 - </pathconvert>
13.192 - <delete>
13.193 - <files includes="${javac.includes.binary}"/>
13.194 - </delete>
13.195 - </sequential>
13.196 - </macrodef>
13.197 - </target>
13.198 - <target name="-init-macrodef-junit">
13.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
13.200 - <attribute default="${includes}" name="includes"/>
13.201 - <attribute default="${excludes}" name="excludes"/>
13.202 - <attribute default="**" name="testincludes"/>
13.203 - <sequential>
13.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
13.205 - <batchtest todir="${build.test.results.dir}">
13.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
13.207 - <filename name="@{testincludes}"/>
13.208 - </fileset>
13.209 - </batchtest>
13.210 - <classpath>
13.211 - <path path="${run.test.classpath}"/>
13.212 - </classpath>
13.213 - <syspropertyset>
13.214 - <propertyref prefix="test-sys-prop."/>
13.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
13.216 - </syspropertyset>
13.217 - <formatter type="brief" usefile="false"/>
13.218 - <formatter type="xml"/>
13.219 - <jvmarg line="${run.jvmargs}"/>
13.220 - </junit>
13.221 - </sequential>
13.222 - </macrodef>
13.223 - </target>
13.224 - <target name="-init-macrodef-nbjpda">
13.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
13.226 - <attribute default="${main.class}" name="name"/>
13.227 - <attribute default="${debug.classpath}" name="classpath"/>
13.228 - <attribute default="" name="stopclassname"/>
13.229 - <sequential>
13.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
13.231 - <classpath>
13.232 - <path path="@{classpath}"/>
13.233 - </classpath>
13.234 - </nbjpdastart>
13.235 - </sequential>
13.236 - </macrodef>
13.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
13.238 - <attribute default="${build.classes.dir}" name="dir"/>
13.239 - <sequential>
13.240 - <nbjpdareload>
13.241 - <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
13.242 - </nbjpdareload>
13.243 - </sequential>
13.244 - </macrodef>
13.245 - </target>
13.246 - <target name="-init-debug-args">
13.247 - <property name="version-output" value="java version "${ant.java.version}"/>
13.248 - <condition property="have-jdk-older-than-1.4">
13.249 - <or>
13.250 - <contains string="${version-output}" substring="java version "1.0"/>
13.251 - <contains string="${version-output}" substring="java version "1.1"/>
13.252 - <contains string="${version-output}" substring="java version "1.2"/>
13.253 - <contains string="${version-output}" substring="java version "1.3"/>
13.254 - </or>
13.255 - </condition>
13.256 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
13.257 - <istrue value="${have-jdk-older-than-1.4}"/>
13.258 - </condition>
13.259 - </target>
13.260 - <target depends="-init-debug-args" name="-init-macrodef-debug">
13.261 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
13.262 - <attribute default="${main.class}" name="classname"/>
13.263 - <attribute default="${debug.classpath}" name="classpath"/>
13.264 - <element name="customize" optional="true"/>
13.265 - <sequential>
13.266 - <java classname="@{classname}" dir="${work.dir}" fork="true">
13.267 - <jvmarg line="${debug-args-line}"/>
13.268 - <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
13.269 - <jvmarg line="${run.jvmargs}"/>
13.270 - <classpath>
13.271 - <path path="@{classpath}"/>
13.272 - </classpath>
13.273 - <syspropertyset>
13.274 - <propertyref prefix="run-sys-prop."/>
13.275 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
13.276 - </syspropertyset>
13.277 - <customize/>
13.278 - </java>
13.279 - </sequential>
13.280 - </macrodef>
13.281 - </target>
13.282 - <target name="-init-macrodef-java">
13.283 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
13.284 - <attribute default="${main.class}" name="classname"/>
13.285 - <element name="customize" optional="true"/>
13.286 - <sequential>
13.287 - <java classname="@{classname}" dir="${work.dir}" fork="true">
13.288 - <jvmarg line="${run.jvmargs}"/>
13.289 - <classpath>
13.290 - <path path="${run.classpath}"/>
13.291 - </classpath>
13.292 - <syspropertyset>
13.293 - <propertyref prefix="run-sys-prop."/>
13.294 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
13.295 - </syspropertyset>
13.296 - <customize/>
13.297 - </java>
13.298 - </sequential>
13.299 - </macrodef>
13.300 - </target>
13.301 - <target name="-init-presetdef-jar">
13.302 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
13.303 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
13.304 - <j2seproject1:fileset dir="${build.classes.dir}"/>
13.305 - </jar>
13.306 - </presetdef>
13.307 - </target>
13.308 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
13.309 - <!--
13.310 - ===================
13.311 - COMPILATION SECTION
13.312 - ===================
13.313 - -->
13.314 - <target depends="init" name="deps-jar" unless="no.deps"/>
13.315 - <target depends="init,deps-jar" name="-pre-pre-compile">
13.316 - <mkdir dir="${build.classes.dir}"/>
13.317 - </target>
13.318 - <target name="-pre-compile">
13.319 - <!-- Empty placeholder for easier customization. -->
13.320 - <!-- You can override this target in the ../build.xml file. -->
13.321 - </target>
13.322 - <target if="do.depend.true" name="-compile-depend">
13.323 - <j2seproject3:depend/>
13.324 - </target>
13.325 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
13.326 - <j2seproject3:javac/>
13.327 - <copy todir="${build.classes.dir}">
13.328 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
13.329 - </copy>
13.330 - </target>
13.331 - <target name="-post-compile">
13.332 - <!-- Empty placeholder for easier customization. -->
13.333 - <!-- You can override this target in the ../build.xml file. -->
13.334 - </target>
13.335 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
13.336 - <target name="-pre-compile-single">
13.337 - <!-- Empty placeholder for easier customization. -->
13.338 - <!-- You can override this target in the ../build.xml file. -->
13.339 - </target>
13.340 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
13.341 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
13.342 - <j2seproject3:force-recompile/>
13.343 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
13.344 - </target>
13.345 - <target name="-post-compile-single">
13.346 - <!-- Empty placeholder for easier customization. -->
13.347 - <!-- You can override this target in the ../build.xml file. -->
13.348 - </target>
13.349 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
13.350 - <!--
13.351 - ====================
13.352 - JAR BUILDING SECTION
13.353 - ====================
13.354 - -->
13.355 - <target depends="init" name="-pre-pre-jar">
13.356 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
13.357 - <mkdir dir="${dist.jar.dir}"/>
13.358 - </target>
13.359 - <target name="-pre-jar">
13.360 - <!-- Empty placeholder for easier customization. -->
13.361 - <!-- You can override this target in the ../build.xml file. -->
13.362 - </target>
13.363 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
13.364 - <j2seproject1:jar/>
13.365 - </target>
13.366 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
13.367 - <j2seproject1:jar manifest="${manifest.file}"/>
13.368 - </target>
13.369 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
13.370 - <j2seproject1:jar manifest="${manifest.file}">
13.371 - <j2seproject1:manifest>
13.372 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
13.373 - </j2seproject1:manifest>
13.374 - </j2seproject1:jar>
13.375 - <echo>To run this application from the command line without Ant, try:</echo>
13.376 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
13.377 - <property location="${dist.jar}" name="dist.jar.resolved"/>
13.378 - <pathconvert property="run.classpath.with.dist.jar">
13.379 - <path path="${run.classpath}"/>
13.380 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
13.381 - </pathconvert>
13.382 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
13.383 - </target>
13.384 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
13.385 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
13.386 - <pathconvert property="run.classpath.without.build.classes.dir">
13.387 - <path path="${run.classpath}"/>
13.388 - <map from="${build.classes.dir.resolved}" to=""/>
13.389 - </pathconvert>
13.390 - <pathconvert pathsep=" " property="jar.classpath">
13.391 - <path path="${run.classpath.without.build.classes.dir}"/>
13.392 - <chainedmapper>
13.393 - <flattenmapper/>
13.394 - <globmapper from="*" to="lib/*"/>
13.395 - </chainedmapper>
13.396 - </pathconvert>
13.397 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
13.398 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
13.399 - <fileset dir="${build.classes.dir}"/>
13.400 - <manifest>
13.401 - <attribute name="Main-Class" value="${main.class}"/>
13.402 - <attribute name="Class-Path" value="${jar.classpath}"/>
13.403 - </manifest>
13.404 - </copylibs>
13.405 - <echo>To run this application from the command line without Ant, try:</echo>
13.406 - <property location="${dist.jar}" name="dist.jar.resolved"/>
13.407 - <echo>java -jar "${dist.jar.resolved}"</echo>
13.408 - </target>
13.409 - <target name="-post-jar">
13.410 - <!-- Empty placeholder for easier customization. -->
13.411 - <!-- You can override this target in the ../build.xml file. -->
13.412 - </target>
13.413 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
13.414 - <!--
13.415 - =================
13.416 - EXECUTION SECTION
13.417 - =================
13.418 - -->
13.419 - <target depends="init,compile" description="Run a main class." name="run">
13.420 - <j2seproject1:java>
13.421 - <customize>
13.422 - <arg line="${application.args}"/>
13.423 - </customize>
13.424 - </j2seproject1:java>
13.425 - </target>
13.426 - <target name="-do-not-recompile">
13.427 - <property name="javac.includes.binary" value=""/>
13.428 - </target>
13.429 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
13.430 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
13.431 - <j2seproject1:java classname="${run.class}"/>
13.432 - </target>
13.433 - <!--
13.434 - =================
13.435 - DEBUGGING SECTION
13.436 - =================
13.437 - -->
13.438 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
13.439 - <j2seproject1:nbjpdastart name="${debug.class}"/>
13.440 - </target>
13.441 - <target depends="init,compile" name="-debug-start-debuggee">
13.442 - <j2seproject3:debug>
13.443 - <customize>
13.444 - <arg line="${application.args}"/>
13.445 - </customize>
13.446 - </j2seproject3:debug>
13.447 - </target>
13.448 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
13.449 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
13.450 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
13.451 - </target>
13.452 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
13.453 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
13.454 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
13.455 - <j2seproject3:debug classname="${debug.class}"/>
13.456 - </target>
13.457 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
13.458 - <target depends="init" name="-pre-debug-fix">
13.459 - <fail unless="fix.includes">Must set fix.includes</fail>
13.460 - <property name="javac.includes" value="${fix.includes}.java"/>
13.461 - </target>
13.462 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
13.463 - <j2seproject1:nbjpdareload/>
13.464 - </target>
13.465 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
13.466 - <!--
13.467 - ===============
13.468 - JAVADOC SECTION
13.469 - ===============
13.470 - -->
13.471 - <target depends="init" name="-javadoc-build">
13.472 - <mkdir dir="${dist.javadoc.dir}"/>
13.473 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
13.474 - <classpath>
13.475 - <path path="${javac.classpath}"/>
13.476 - </classpath>
13.477 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
13.478 - <filename name="**/*.java"/>
13.479 - </fileset>
13.480 - </javadoc>
13.481 - </target>
13.482 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
13.483 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
13.484 - </target>
13.485 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
13.486 - <!--
13.487 - =========================
13.488 - JUNIT COMPILATION SECTION
13.489 - =========================
13.490 - -->
13.491 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
13.492 - <mkdir dir="${build.test.classes.dir}"/>
13.493 - </target>
13.494 - <target name="-pre-compile-test">
13.495 - <!-- Empty placeholder for easier customization. -->
13.496 - <!-- You can override this target in the ../build.xml file. -->
13.497 - </target>
13.498 - <target if="do.depend.true" name="-compile-test-depend">
13.499 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
13.500 - </target>
13.501 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
13.502 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
13.503 - <copy todir="${build.test.classes.dir}">
13.504 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
13.505 - </copy>
13.506 - </target>
13.507 - <target name="-post-compile-test">
13.508 - <!-- Empty placeholder for easier customization. -->
13.509 - <!-- You can override this target in the ../build.xml file. -->
13.510 - </target>
13.511 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
13.512 - <target name="-pre-compile-test-single">
13.513 - <!-- Empty placeholder for easier customization. -->
13.514 - <!-- You can override this target in the ../build.xml file. -->
13.515 - </target>
13.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
13.517 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
13.518 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
13.519 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
13.520 - <copy todir="${build.test.classes.dir}">
13.521 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
13.522 - </copy>
13.523 - </target>
13.524 - <target name="-post-compile-test-single">
13.525 - <!-- Empty placeholder for easier customization. -->
13.526 - <!-- You can override this target in the ../build.xml file. -->
13.527 - </target>
13.528 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
13.529 - <!--
13.530 - =======================
13.531 - JUNIT EXECUTION SECTION
13.532 - =======================
13.533 - -->
13.534 - <target depends="init" if="have.tests" name="-pre-test-run">
13.535 - <mkdir dir="${build.test.results.dir}"/>
13.536 - </target>
13.537 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
13.538 - <j2seproject3:junit testincludes="**/*Test.java"/>
13.539 - </target>
13.540 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
13.541 - <fail if="tests.failed">Some tests failed; see details above.</fail>
13.542 - </target>
13.543 - <target depends="init" if="have.tests" name="test-report"/>
13.544 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
13.545 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
13.546 - <target depends="init" if="have.tests" name="-pre-test-run-single">
13.547 - <mkdir dir="${build.test.results.dir}"/>
13.548 - </target>
13.549 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
13.550 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
13.551 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
13.552 - </target>
13.553 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
13.554 - <fail if="tests.failed">Some tests failed; see details above.</fail>
13.555 - </target>
13.556 - <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
13.557 - <!--
13.558 - =======================
13.559 - JUNIT DEBUGGING SECTION
13.560 - =======================
13.561 - -->
13.562 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
13.563 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
13.564 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
13.565 - <delete file="${test.report.file}"/>
13.566 - <mkdir dir="${build.test.results.dir}"/>
13.567 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
13.568 - <customize>
13.569 - <syspropertyset>
13.570 - <propertyref prefix="test-sys-prop."/>
13.571 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
13.572 - </syspropertyset>
13.573 - <arg value="${test.class}"/>
13.574 - <arg value="showoutput=true"/>
13.575 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
13.576 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
13.577 - </customize>
13.578 - </j2seproject3:debug>
13.579 - </target>
13.580 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
13.581 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
13.582 - </target>
13.583 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
13.584 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
13.585 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
13.586 - </target>
13.587 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
13.588 - <!--
13.589 - =========================
13.590 - APPLET EXECUTION SECTION
13.591 - =========================
13.592 - -->
13.593 - <target depends="init,compile-single" name="run-applet">
13.594 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
13.595 - <j2seproject1:java classname="sun.applet.AppletViewer">
13.596 - <customize>
13.597 - <arg value="${applet.url}"/>
13.598 - </customize>
13.599 - </j2seproject1:java>
13.600 - </target>
13.601 - <!--
13.602 - =========================
13.603 - APPLET DEBUGGING SECTION
13.604 - =========================
13.605 - -->
13.606 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
13.607 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
13.608 - <j2seproject3:debug classname="sun.applet.AppletViewer">
13.609 - <customize>
13.610 - <arg value="${applet.url}"/>
13.611 - </customize>
13.612 - </j2seproject3:debug>
13.613 - </target>
13.614 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
13.615 - <!--
13.616 - ===============
13.617 - CLEANUP SECTION
13.618 - ===============
13.619 - -->
13.620 - <target depends="init" name="deps-clean" unless="no.deps"/>
13.621 - <target depends="init" name="-do-clean">
13.622 - <delete dir="${build.dir}"/>
13.623 - <delete dir="${dist.dir}"/>
13.624 - </target>
13.625 - <target name="-post-clean">
13.626 - <!-- Empty placeholder for easier customization. -->
13.627 - <!-- You can override this target in the ../build.xml file. -->
13.628 - </target>
13.629 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
13.630 -</project>
14.1 --- a/samples/composition/nbproject/genfiles.properties Sat Jun 14 10:32:31 2008 +0200
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,8 +0,0 @@
14.4 -build.xml.data.CRC32=b4c287b9
14.5 -build.xml.script.CRC32=e6adff10
14.6 -build.xml.stylesheet.CRC32=be360661
14.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
14.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
14.9 -nbproject/build-impl.xml.data.CRC32=b4c287b9
14.10 -nbproject/build-impl.xml.script.CRC32=500de1f4
14.11 -nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
15.1 --- a/samples/composition/nbproject/project.properties Sat Jun 14 10:32:31 2008 +0200
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,56 +0,0 @@
15.4 -build.classes.dir=${build.dir}/classes
15.5 -build.classes.excludes=**/*.java,**/*.form
15.6 -# This directory is removed when the project is cleaned:
15.7 -build.dir=build
15.8 -build.generated.dir=${build.dir}/generated
15.9 -# Only compile against the classpath explicitly listed here:
15.10 -build.sysclasspath=ignore
15.11 -build.test.classes.dir=${build.dir}/test/classes
15.12 -build.test.results.dir=${build.dir}/test/results
15.13 -debug.classpath=\
15.14 - ${run.classpath}
15.15 -debug.test.classpath=\
15.16 - ${run.test.classpath}
15.17 -# This directory is removed when the project is cleaned:
15.18 -dist.dir=dist
15.19 -dist.jar=${dist.dir}/composition.jar
15.20 -dist.javadoc.dir=${dist.dir}/javadoc
15.21 -excludes=
15.22 -includes=**
15.23 -jar.compress=false
15.24 -javac.classpath=
15.25 -# Space-separated list of extra javac options
15.26 -javac.compilerargs=
15.27 -javac.deprecation=false
15.28 -javac.source=1.5
15.29 -javac.target=1.5
15.30 -javac.test.classpath=\
15.31 - ${javac.classpath}:\
15.32 - ${build.classes.dir}:\
15.33 - ${libs.junit.classpath}
15.34 -javadoc.additionalparam=
15.35 -javadoc.author=false
15.36 -javadoc.encoding=${source.encoding}
15.37 -javadoc.noindex=false
15.38 -javadoc.nonavbar=false
15.39 -javadoc.notree=false
15.40 -javadoc.private=false
15.41 -javadoc.splitindex=true
15.42 -javadoc.use=true
15.43 -javadoc.version=false
15.44 -javadoc.windowtitle=
15.45 -meta.inf.dir=${src.dir}/META-INF
15.46 -platform.active=default_platform
15.47 -run.classpath=\
15.48 - ${javac.classpath}:\
15.49 - ${build.classes.dir}
15.50 -# Space-separated list of JVM arguments used when running the project
15.51 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
15.52 -# or test-sys-prop.name=value to set system properties for unit tests):
15.53 -run.jvmargs=
15.54 -run.test.classpath=\
15.55 - ${javac.test.classpath}:\
15.56 - ${build.test.classes.dir}
15.57 -source.encoding=UTF-8
15.58 -src.dir=src
15.59 -test.src.dir=test
16.1 --- a/samples/composition/src/api/Arithmetica.java Sat Jun 14 10:32:31 2008 +0200
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,28 +0,0 @@
16.4 -package api;
16.5 -
16.6 -/** Class to simplify arithmetical operations.
16.7 - *
16.8 - * @author Jaroslav Tulach <jtulach@netbeans.org>
16.9 - */
16.10 -public class Arithmetica {
16.11 - public int sumTwo(int one, int second) {
16.12 - return one + second;
16.13 - }
16.14 -
16.15 - public int sumAll(int... numbers) {
16.16 - int sum = numbers[0];
16.17 - for (int i = 1; i < numbers.length; i++) {
16.18 - sum = sumTwo(sum, numbers[i]);
16.19 - }
16.20 - return sum;
16.21 - }
16.22 -
16.23 - public int sumRange(int from, int to) {
16.24 - int len = to - from;
16.25 - int[] array = new int[len + 1];
16.26 - for (int i = 0; i <= len; i++) {
16.27 - array[i] = from + i;
16.28 - }
16.29 - return sumAll(array);
16.30 - }
16.31 -}
17.1 --- a/samples/composition/test/api/ArithmeticaTest.java Sat Jun 14 10:32:31 2008 +0200
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,46 +0,0 @@
17.4 -/*
17.5 - * Žluťoučký kůň je naše hříbátko.
17.6 - * and open the template in the editor.
17.7 - */
17.8 -
17.9 -package api;
17.10 -
17.11 -import junit.framework.TestCase;
17.12 -
17.13 -/**
17.14 - *
17.15 - * @author Jaroslav Tulach <jtulach@netbeans.org>
17.16 - */
17.17 -public class ArithmeticaTest extends TestCase {
17.18 -
17.19 - public ArithmeticaTest(String testName) {
17.20 - super(testName);
17.21 - }
17.22 -
17.23 - @Override
17.24 - protected void setUp() throws Exception {
17.25 - super.setUp();
17.26 - }
17.27 -
17.28 - @Override
17.29 - protected void tearDown() throws Exception {
17.30 - super.tearDown();
17.31 - }
17.32 -
17.33 - public void testSumTwo() {
17.34 - Arithmetica instance = new Arithmetica();
17.35 - assertEquals("+", 5, instance.sumTwo(3, 2));
17.36 - }
17.37 -
17.38 - public void testSumAll() {
17.39 - Arithmetica instance = new Arithmetica();
17.40 - assertEquals("+", 6, instance.sumAll(3, 2, 1));
17.41 - }
17.42 -
17.43 - public void testSumRange() {
17.44 - Arithmetica instance = new Arithmetica();
17.45 - assertEquals("+", 6, instance.sumRange(1, 3));
17.46 - assertEquals("10", 55, instance.sumRange(1, 10));
17.47 - }
17.48 -
17.49 -}
18.1 --- a/samples/composition/test/api/FactorialTest.java Sat Jun 14 10:32:31 2008 +0200
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,53 +0,0 @@
18.4 -/*
18.5 - * Žluťoučký kůň je naše hříbátko.
18.6 - * and open the template in the editor.
18.7 - */
18.8 -
18.9 -package api;
18.10 -
18.11 -import junit.framework.TestCase;
18.12 -
18.13 -/**
18.14 - *
18.15 - * @author Jaroslav Tulach <jtulach@netbeans.org>
18.16 - */
18.17 -public class FactorialTest extends TestCase {
18.18 -
18.19 - public FactorialTest(String testName) {
18.20 - super(testName);
18.21 - }
18.22 -
18.23 - @Override
18.24 - protected void setUp() throws Exception {
18.25 - super.setUp();
18.26 - }
18.27 -
18.28 - @Override
18.29 - protected void tearDown() throws Exception {
18.30 - super.tearDown();
18.31 - }
18.32 -
18.33 - public void testFactorial3() {
18.34 - assertEquals(6, Factorial.factorial(3));
18.35 - }
18.36 -
18.37 - public void testFactorial5() {
18.38 - assertEquals(120, Factorial.factorial(5));
18.39 - }
18.40 -
18.41 - /** Class showing inventive, non-expected use of
18.42 - * Arithmetica methods to do multiplication instead of
18.43 - * addition.
18.44 - */
18.45 - private static class Factorial extends Arithmetica {
18.46 - public static int factorial(int n) {
18.47 - return new Factorial().sumRange(1, n);
18.48 - }
18.49 - @Override
18.50 - public int sumTwo(int one, int second) {
18.51 - return one * second;
18.52 - }
18.53 - }
18.54 -
18.55 -
18.56 -}
19.1 --- a/samples/consistency/src-test/api/ArithmeticaTest.java Sat Jun 14 10:32:31 2008 +0200
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,25 +0,0 @@
19.4 -package api;
19.5 -
19.6 -import junit.framework.TestCase;
19.7 -
19.8 -/**
19.9 - *
19.10 - * @author Jaroslav Tulach <jtulach@netbeans.org>
19.11 - */
19.12 -public class ArithmeticaTest extends TestCase {
19.13 -
19.14 - public ArithmeticaTest(String testName) {
19.15 - super(testName);
19.16 - }
19.17 -
19.18 - @Override
19.19 - protected void setUp() throws Exception {
19.20 - super.setUp();
19.21 - }
19.22 -
19.23 - @Override
19.24 - protected void tearDown() throws Exception {
19.25 - super.tearDown();
19.26 - }
19.27 -
19.28 -}
20.1 --- a/samples/consistency/src-test/api/ConsistencyOfURLTest.java Sat Jun 14 10:32:31 2008 +0200
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,20 +0,0 @@
20.4 -package api;
20.5 -
20.6 -import java.net.URL;
20.7 -import org.junit.Test;
20.8 -import static org.junit.Assert.assertEquals;
20.9 -
20.10 -/**
20.11 - *
20.12 - * @author Jaroslav Tulach <jtulach@netbeans.org>
20.13 - */
20.14 -public class ConsistencyOfURLTest {
20.15 -
20.16 - @Test public void urlToExternalAndToString() throws Exception {
20.17 - // BEGIN: consistency.url
20.18 - URL url = new URL("http://www.apidesign.org");
20.19 - assertEquals(url.toString(), url.toExternalForm());
20.20 - // END: consistency.url
20.21 - }
20.22 -
20.23 -}
21.1 --- a/samples/consistency/src-test/api/FactorialTest.java Sat Jun 14 10:32:31 2008 +0200
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,15 +0,0 @@
21.4 -package api;
21.5 -
21.6 -import junit.framework.TestCase;
21.7 -
21.8 -/**
21.9 - *
21.10 - * @author Jaroslav Tulach <jtulach@netbeans.org>
21.11 - */
21.12 -public class FactorialTest extends TestCase {
21.13 -
21.14 - public FactorialTest(String testName) {
21.15 - super(testName);
21.16 - }
21.17 -
21.18 -}
22.1 --- a/samples/delegatingwriter/src/org/apidesign/delegatingwriter/ExBufferedWriter.java Sat Jun 14 10:32:31 2008 +0200
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,51 +0,0 @@
22.4 -/*
22.5 - * To change this template, choose Tools | Templates
22.6 - * and open the template in the editor.
22.7 - */
22.8 -
22.9 -package org.apidesign.delegatingwriter;
22.10 -
22.11 -import java.io.BufferedWriter;
22.12 -import java.io.IOException;
22.13 -import java.io.Writer;
22.14 -
22.15 -/**
22.16 - * This is a regular {@link BufferedWriter}, just it optimizes for
22.17 - * huge {@link CharSequence} objects set to its {@link #append} method.
22.18 - * Instead of converting them to string, which might required too much
22.19 - * temporary memory, it delegates it directly.
22.20 - * <p>
22.21 - * This class is <q>simulating</q> would would happen if JDK's BufferedWriter
22.22 - * in revision 1.5
22.23 - * was designed to delegate its newly added <code>append</code> methods
22.24 - * instead of calling its already existing <code>write</code> ones.
22.25 - *
22.26 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
22.27 - */
22.28 -public class ExBufferedWriter extends BufferedWriter {
22.29 - private final Writer out;
22.30 -
22.31 - public ExBufferedWriter(Writer out, int sz, boolean optimized) {
22.32 - super(out, sz);
22.33 - this.out = optimized ? out : null;
22.34 - }
22.35 -
22.36 - @Override
22.37 - public Writer append(CharSequence csq) throws IOException {
22.38 - if (out != null) {
22.39 - // efficient, yet dangerous delegation skipping methods known to
22.40 - // subclasses that used version 1.4
22.41 - out.append(csq);
22.42 - return this;
22.43 - } else {
22.44 - // non-efficient variant of delegating via converting to String first
22.45 - // and using one of methods that existed in 1.4
22.46 - if (csq == null) {
22.47 - write("null");
22.48 - } else {
22.49 - write(csq.toString());
22.50 - }
22.51 - return this;
22.52 - }
22.53 - }
22.54 -}
23.1 --- a/samples/delegatingwriterfinal/src-test/api/usage/BufferedWriterCryptoTest.java Sat Jun 14 10:32:31 2008 +0200
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,37 +0,0 @@
23.4 -
23.5 -package api.usage;
23.6 -
23.7 -import api.Writer;
23.8 -import java.io.IOException;
23.9 -import java.io.StringWriter;
23.10 -import java.io.StringWriter;
23.11 -import org.junit.Before;
23.12 -import org.junit.Test;
23.13 -import static org.junit.Assert.*;
23.14 -
23.15 -/** Converting the Crypto example to the APIs that split client and provider
23.16 - * concerns and do not mix delegation and subclassing.
23.17 - *
23.18 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
23.19 - */
23.20 -public class BufferedWriterCryptoTest {
23.21 - private StringWriter writer;
23.22 -
23.23 -
23.24 - public BufferedWriterCryptoTest() {
23.25 - }
23.26 -
23.27 - @Before
23.28 - public void setUp() {
23.29 - writer = new StringWriter();
23.30 - }
23.31 -
23.32 - @Test
23.33 - public void testBehaviourOfRealBufferInJDKWorksFine() throws IOException {
23.34 - Writer bufferedWriter = CryptoWriter.create(Writer.create(writer));
23.35 - bufferedWriter.write("VMS");
23.36 - bufferedWriter.flush();
23.37 - assertEquals("Converted", "WNT", writer.toString());
23.38 - }
23.39 -
23.40 -}
23.41 \ No newline at end of file
24.1 --- a/samples/delegatingwriterfinal/src-test/api/usage/CryptoWriter.java Sat Jun 14 10:32:31 2008 +0200
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,60 +0,0 @@
24.4 -
24.5 -package api.usage;
24.6 -
24.7 -import api.Writer;
24.8 -import java.io.IOException;
24.9 -
24.10 -
24.11 -/** Writer alters each char from 'A' to 'Z' range with next one just like
24.12 - * old Romans did.
24.13 - *
24.14 - * @author Jaroslav Tulach
24.15 - */
24.16 -public class CryptoWriter implements Writer.Impl {
24.17 - private Writer out;
24.18 -
24.19 - private CryptoWriter(Writer out) {
24.20 - this.out = out;
24.21 - }
24.22 -
24.23 -
24.24 - public static Writer create(Writer out) {
24.25 - return Writer.create(new CryptoWriter(out));
24.26 - }
24.27 -
24.28 - @Override
24.29 - public void write(char[] cbuf, int off, int len) throws IOException {
24.30 - char[] arr = new char[len];
24.31 - for (int i = 0; i < len; i++) {
24.32 - arr[i] = convertChar(cbuf[off + i]);
24.33 - }
24.34 - out.write(arr, 0, len);
24.35 - }
24.36 -
24.37 - @Override
24.38 - public void write(String str, int off, int len) throws IOException {
24.39 - StringBuffer sb = new StringBuffer();
24.40 - for (int i = 0; i < len; i++) {
24.41 - sb.append(convertChar(str.charAt(off + i)));
24.42 - }
24.43 - out.write(sb.toString(), 0, len);
24.44 - }
24.45 -
24.46 - private char convertChar(int c) {
24.47 - if (c == 'Z') {
24.48 - return 'A';
24.49 - }
24.50 - if (c == 'z') {
24.51 - return 'a';
24.52 - }
24.53 - return (char)(c + 1);
24.54 - }
24.55 -
24.56 - public void close() throws IOException {
24.57 - out.close();
24.58 - }
24.59 -
24.60 - public void flush() throws IOException {
24.61 - out.flush();
24.62 - }
24.63 -}
25.1 --- a/samples/externalfiles/jdbc-driver-registration.xml Sat Jun 14 10:32:31 2008 +0200
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,15 +0,0 @@
25.4 -<?xml version="1.0" encoding="UTF-8"?>
25.5 -<!-- BEGIN: theory.jdbc.driver.registration -->
25.6 -<!DOCTYPE driver PUBLIC
25.7 - '-//NetBeans//DTD JDBC Driver 1.0//EN'
25.8 - 'http://www.netbeans.org/dtds/jdbc-driver-1_0.dtd'
25.9 ->
25.10 -<driver>
25.11 - <name value='postgresql-7'/>
25.12 - <display-name value='PostgreSQL (v7.0 and later)'/>
25.13 - <class value='org.postgresql.Driver'/>
25.14 - <urls>
25.15 - <url value='file:/folder1/folder2/drivers/pg74.1jdbc3.jar'/>
25.16 - </urls>
25.17 -</driver>
25.18 -<!-- END: theory.jdbc.driver.registration -->
26.1 --- a/samples/messagedigest/nbproject/build-impl.xml Sat Jun 14 10:32:31 2008 +0200
26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26.3 @@ -1,627 +0,0 @@
26.4 -<?xml version="1.0" encoding="UTF-8"?>
26.5 -<!--
26.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
26.7 -*** EDIT ../build.xml INSTEAD ***
26.8 -
26.9 -For the purpose of easier reading the script
26.10 -is divided into following sections:
26.11 -
26.12 - - initialization
26.13 - - compilation
26.14 - - jar
26.15 - - execution
26.16 - - debugging
26.17 - - javadoc
26.18 - - junit compilation
26.19 - - junit execution
26.20 - - junit debugging
26.21 - - applet
26.22 - - cleanup
26.23 -
26.24 - -->
26.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="messagedigest-impl">
26.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
26.27 - <!--
26.28 - ======================
26.29 - INITIALIZATION SECTION
26.30 - ======================
26.31 - -->
26.32 - <target name="-pre-init">
26.33 - <!-- Empty placeholder for easier customization. -->
26.34 - <!-- You can override this target in the ../build.xml file. -->
26.35 - </target>
26.36 - <target depends="-pre-init" name="-init-private">
26.37 - <property file="nbproject/private/config.properties"/>
26.38 - <property file="nbproject/private/configs/${config}.properties"/>
26.39 - <property file="nbproject/private/private.properties"/>
26.40 - </target>
26.41 - <target depends="-pre-init,-init-private" name="-init-user">
26.42 - <property file="${user.properties.file}"/>
26.43 - <!-- The two properties below are usually overridden -->
26.44 - <!-- by the active platform. Just a fallback. -->
26.45 - <property name="default.javac.source" value="1.4"/>
26.46 - <property name="default.javac.target" value="1.4"/>
26.47 - </target>
26.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
26.49 - <property file="nbproject/configs/${config}.properties"/>
26.50 - <property file="nbproject/project.properties"/>
26.51 - </target>
26.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
26.53 - <available file="${manifest.file}" property="manifest.available"/>
26.54 - <condition property="manifest.available+main.class">
26.55 - <and>
26.56 - <isset property="manifest.available"/>
26.57 - <isset property="main.class"/>
26.58 - <not>
26.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
26.60 - </not>
26.61 - </and>
26.62 - </condition>
26.63 - <condition property="manifest.available+main.class+mkdist.available">
26.64 - <and>
26.65 - <istrue value="${manifest.available+main.class}"/>
26.66 - <isset property="libs.CopyLibs.classpath"/>
26.67 - </and>
26.68 - </condition>
26.69 - <condition property="have.tests">
26.70 - <or>
26.71 - <available file="${test.src.dir}"/>
26.72 - </or>
26.73 - </condition>
26.74 - <condition property="have.sources">
26.75 - <or>
26.76 - <available file="${src.dir}"/>
26.77 - </or>
26.78 - </condition>
26.79 - <condition property="netbeans.home+have.tests">
26.80 - <and>
26.81 - <isset property="netbeans.home"/>
26.82 - <isset property="have.tests"/>
26.83 - </and>
26.84 - </condition>
26.85 - <condition property="no.javadoc.preview">
26.86 - <and>
26.87 - <isset property="javadoc.preview"/>
26.88 - <isfalse value="${javadoc.preview}"/>
26.89 - </and>
26.90 - </condition>
26.91 - <property name="run.jvmargs" value=""/>
26.92 - <property name="javac.compilerargs" value=""/>
26.93 - <property name="work.dir" value="${basedir}"/>
26.94 - <condition property="no.deps">
26.95 - <and>
26.96 - <istrue value="${no.dependencies}"/>
26.97 - </and>
26.98 - </condition>
26.99 - <property name="javac.debug" value="true"/>
26.100 - <property name="javadoc.preview" value="true"/>
26.101 - <property name="application.args" value=""/>
26.102 - <property name="source.encoding" value="${file.encoding}"/>
26.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
26.104 - <and>
26.105 - <isset property="javadoc.encoding"/>
26.106 - <not>
26.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
26.108 - </not>
26.109 - </and>
26.110 - </condition>
26.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
26.112 - <property name="includes" value="**"/>
26.113 - <property name="excludes" value=""/>
26.114 - <property name="do.depend" value="false"/>
26.115 - <condition property="do.depend.true">
26.116 - <istrue value="${do.depend}"/>
26.117 - </condition>
26.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
26.119 - <and>
26.120 - <isset property="jaxws.endorsed.dir"/>
26.121 - <available file="nbproject/jaxws-build.xml"/>
26.122 - </and>
26.123 - </condition>
26.124 - </target>
26.125 - <target name="-post-init">
26.126 - <!-- Empty placeholder for easier customization. -->
26.127 - <!-- You can override this target in the ../build.xml file. -->
26.128 - </target>
26.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
26.130 - <fail unless="src.dir">Must set src.dir</fail>
26.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
26.132 - <fail unless="build.dir">Must set build.dir</fail>
26.133 - <fail unless="dist.dir">Must set dist.dir</fail>
26.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
26.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
26.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
26.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
26.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
26.139 - <fail unless="dist.jar">Must set dist.jar</fail>
26.140 - </target>
26.141 - <target name="-init-macrodef-property">
26.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
26.143 - <attribute name="name"/>
26.144 - <attribute name="value"/>
26.145 - <sequential>
26.146 - <property name="@{name}" value="${@{value}}"/>
26.147 - </sequential>
26.148 - </macrodef>
26.149 - </target>
26.150 - <target name="-init-macrodef-javac">
26.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
26.152 - <attribute default="${src.dir}" name="srcdir"/>
26.153 - <attribute default="${build.classes.dir}" name="destdir"/>
26.154 - <attribute default="${javac.classpath}" name="classpath"/>
26.155 - <attribute default="${includes}" name="includes"/>
26.156 - <attribute default="${excludes}" name="excludes"/>
26.157 - <attribute default="${javac.debug}" name="debug"/>
26.158 - <attribute default="" name="sourcepath"/>
26.159 - <element name="customize" optional="true"/>
26.160 - <sequential>
26.161 - <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
26.162 - <classpath>
26.163 - <path path="@{classpath}"/>
26.164 - </classpath>
26.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
26.166 - <customize/>
26.167 - </javac>
26.168 - </sequential>
26.169 - </macrodef>
26.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
26.171 - <attribute default="${src.dir}" name="srcdir"/>
26.172 - <attribute default="${build.classes.dir}" name="destdir"/>
26.173 - <attribute default="${javac.classpath}" name="classpath"/>
26.174 - <sequential>
26.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
26.176 - <classpath>
26.177 - <path path="@{classpath}"/>
26.178 - </classpath>
26.179 - </depend>
26.180 - </sequential>
26.181 - </macrodef>
26.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
26.183 - <attribute default="${build.classes.dir}" name="destdir"/>
26.184 - <sequential>
26.185 - <fail unless="javac.includes">Must set javac.includes</fail>
26.186 - <pathconvert pathsep="," property="javac.includes.binary">
26.187 - <path>
26.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
26.189 - </path>
26.190 - <globmapper from="*.java" to="*.class"/>
26.191 - </pathconvert>
26.192 - <delete>
26.193 - <files includes="${javac.includes.binary}"/>
26.194 - </delete>
26.195 - </sequential>
26.196 - </macrodef>
26.197 - </target>
26.198 - <target name="-init-macrodef-junit">
26.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
26.200 - <attribute default="${includes}" name="includes"/>
26.201 - <attribute default="${excludes}" name="excludes"/>
26.202 - <attribute default="**" name="testincludes"/>
26.203 - <sequential>
26.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
26.205 - <batchtest todir="${build.test.results.dir}">
26.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
26.207 - <filename name="@{testincludes}"/>
26.208 - </fileset>
26.209 - </batchtest>
26.210 - <classpath>
26.211 - <path path="${run.test.classpath}"/>
26.212 - </classpath>
26.213 - <syspropertyset>
26.214 - <propertyref prefix="test-sys-prop."/>
26.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
26.216 - </syspropertyset>
26.217 - <formatter type="brief" usefile="false"/>
26.218 - <formatter type="xml"/>
26.219 - <jvmarg line="${run.jvmargs}"/>
26.220 - </junit>
26.221 - </sequential>
26.222 - </macrodef>
26.223 - </target>
26.224 - <target name="-init-macrodef-nbjpda">
26.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
26.226 - <attribute default="${main.class}" name="name"/>
26.227 - <attribute default="${debug.classpath}" name="classpath"/>
26.228 - <attribute default="" name="stopclassname"/>
26.229 - <sequential>
26.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
26.231 - <classpath>
26.232 - <path path="@{classpath}"/>
26.233 - </classpath>
26.234 - </nbjpdastart>
26.235 - </sequential>
26.236 - </macrodef>
26.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
26.238 - <attribute default="${build.classes.dir}" name="dir"/>
26.239 - <sequential>
26.240 - <nbjpdareload>
26.241 - <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
26.242 - </nbjpdareload>
26.243 - </sequential>
26.244 - </macrodef>
26.245 - </target>
26.246 - <target name="-init-debug-args">
26.247 - <property name="version-output" value="java version "${ant.java.version}"/>
26.248 - <condition property="have-jdk-older-than-1.4">
26.249 - <or>
26.250 - <contains string="${version-output}" substring="java version "1.0"/>
26.251 - <contains string="${version-output}" substring="java version "1.1"/>
26.252 - <contains string="${version-output}" substring="java version "1.2"/>
26.253 - <contains string="${version-output}" substring="java version "1.3"/>
26.254 - </or>
26.255 - </condition>
26.256 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
26.257 - <istrue value="${have-jdk-older-than-1.4}"/>
26.258 - </condition>
26.259 - </target>
26.260 - <target depends="-init-debug-args" name="-init-macrodef-debug">
26.261 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
26.262 - <attribute default="${main.class}" name="classname"/>
26.263 - <attribute default="${debug.classpath}" name="classpath"/>
26.264 - <element name="customize" optional="true"/>
26.265 - <sequential>
26.266 - <java classname="@{classname}" dir="${work.dir}" fork="true">
26.267 - <jvmarg line="${debug-args-line}"/>
26.268 - <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
26.269 - <jvmarg line="${run.jvmargs}"/>
26.270 - <classpath>
26.271 - <path path="@{classpath}"/>
26.272 - </classpath>
26.273 - <syspropertyset>
26.274 - <propertyref prefix="run-sys-prop."/>
26.275 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
26.276 - </syspropertyset>
26.277 - <customize/>
26.278 - </java>
26.279 - </sequential>
26.280 - </macrodef>
26.281 - </target>
26.282 - <target name="-init-macrodef-java">
26.283 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
26.284 - <attribute default="${main.class}" name="classname"/>
26.285 - <element name="customize" optional="true"/>
26.286 - <sequential>
26.287 - <java classname="@{classname}" dir="${work.dir}" fork="true">
26.288 - <jvmarg line="${run.jvmargs}"/>
26.289 - <classpath>
26.290 - <path path="${run.classpath}"/>
26.291 - </classpath>
26.292 - <syspropertyset>
26.293 - <propertyref prefix="run-sys-prop."/>
26.294 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
26.295 - </syspropertyset>
26.296 - <customize/>
26.297 - </java>
26.298 - </sequential>
26.299 - </macrodef>
26.300 - </target>
26.301 - <target name="-init-presetdef-jar">
26.302 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
26.303 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
26.304 - <j2seproject1:fileset dir="${build.classes.dir}"/>
26.305 - </jar>
26.306 - </presetdef>
26.307 - </target>
26.308 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
26.309 - <!--
26.310 - ===================
26.311 - COMPILATION SECTION
26.312 - ===================
26.313 - -->
26.314 - <target depends="init" name="deps-jar" unless="no.deps"/>
26.315 - <target depends="init,deps-jar" name="-pre-pre-compile">
26.316 - <mkdir dir="${build.classes.dir}"/>
26.317 - </target>
26.318 - <target name="-pre-compile">
26.319 - <!-- Empty placeholder for easier customization. -->
26.320 - <!-- You can override this target in the ../build.xml file. -->
26.321 - </target>
26.322 - <target if="do.depend.true" name="-compile-depend">
26.323 - <j2seproject3:depend/>
26.324 - </target>
26.325 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
26.326 - <j2seproject3:javac/>
26.327 - <copy todir="${build.classes.dir}">
26.328 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
26.329 - </copy>
26.330 - </target>
26.331 - <target name="-post-compile">
26.332 - <!-- Empty placeholder for easier customization. -->
26.333 - <!-- You can override this target in the ../build.xml file. -->
26.334 - </target>
26.335 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
26.336 - <target name="-pre-compile-single">
26.337 - <!-- Empty placeholder for easier customization. -->
26.338 - <!-- You can override this target in the ../build.xml file. -->
26.339 - </target>
26.340 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
26.341 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
26.342 - <j2seproject3:force-recompile/>
26.343 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
26.344 - </target>
26.345 - <target name="-post-compile-single">
26.346 - <!-- Empty placeholder for easier customization. -->
26.347 - <!-- You can override this target in the ../build.xml file. -->
26.348 - </target>
26.349 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
26.350 - <!--
26.351 - ====================
26.352 - JAR BUILDING SECTION
26.353 - ====================
26.354 - -->
26.355 - <target depends="init" name="-pre-pre-jar">
26.356 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
26.357 - <mkdir dir="${dist.jar.dir}"/>
26.358 - </target>
26.359 - <target name="-pre-jar">
26.360 - <!-- Empty placeholder for easier customization. -->
26.361 - <!-- You can override this target in the ../build.xml file. -->
26.362 - </target>
26.363 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
26.364 - <j2seproject1:jar/>
26.365 - </target>
26.366 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
26.367 - <j2seproject1:jar manifest="${manifest.file}"/>
26.368 - </target>
26.369 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
26.370 - <j2seproject1:jar manifest="${manifest.file}">
26.371 - <j2seproject1:manifest>
26.372 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
26.373 - </j2seproject1:manifest>
26.374 - </j2seproject1:jar>
26.375 - <echo>To run this application from the command line without Ant, try:</echo>
26.376 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
26.377 - <property location="${dist.jar}" name="dist.jar.resolved"/>
26.378 - <pathconvert property="run.classpath.with.dist.jar">
26.379 - <path path="${run.classpath}"/>
26.380 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
26.381 - </pathconvert>
26.382 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
26.383 - </target>
26.384 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
26.385 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
26.386 - <pathconvert property="run.classpath.without.build.classes.dir">
26.387 - <path path="${run.classpath}"/>
26.388 - <map from="${build.classes.dir.resolved}" to=""/>
26.389 - </pathconvert>
26.390 - <pathconvert pathsep=" " property="jar.classpath">
26.391 - <path path="${run.classpath.without.build.classes.dir}"/>
26.392 - <chainedmapper>
26.393 - <flattenmapper/>
26.394 - <globmapper from="*" to="lib/*"/>
26.395 - </chainedmapper>
26.396 - </pathconvert>
26.397 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
26.398 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
26.399 - <fileset dir="${build.classes.dir}"/>
26.400 - <manifest>
26.401 - <attribute name="Main-Class" value="${main.class}"/>
26.402 - <attribute name="Class-Path" value="${jar.classpath}"/>
26.403 - </manifest>
26.404 - </copylibs>
26.405 - <echo>To run this application from the command line without Ant, try:</echo>
26.406 - <property location="${dist.jar}" name="dist.jar.resolved"/>
26.407 - <echo>java -jar "${dist.jar.resolved}"</echo>
26.408 - </target>
26.409 - <target name="-post-jar">
26.410 - <!-- Empty placeholder for easier customization. -->
26.411 - <!-- You can override this target in the ../build.xml file. -->
26.412 - </target>
26.413 - <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
26.414 - <!--
26.415 - =================
26.416 - EXECUTION SECTION
26.417 - =================
26.418 - -->
26.419 - <target depends="init,compile" description="Run a main class." name="run">
26.420 - <j2seproject1:java>
26.421 - <customize>
26.422 - <arg line="${application.args}"/>
26.423 - </customize>
26.424 - </j2seproject1:java>
26.425 - </target>
26.426 - <target name="-do-not-recompile">
26.427 - <property name="javac.includes.binary" value=""/>
26.428 - </target>
26.429 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
26.430 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
26.431 - <j2seproject1:java classname="${run.class}"/>
26.432 - </target>
26.433 - <!--
26.434 - =================
26.435 - DEBUGGING SECTION
26.436 - =================
26.437 - -->
26.438 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
26.439 - <j2seproject1:nbjpdastart name="${debug.class}"/>
26.440 - </target>
26.441 - <target depends="init,compile" name="-debug-start-debuggee">
26.442 - <j2seproject3:debug>
26.443 - <customize>
26.444 - <arg line="${application.args}"/>
26.445 - </customize>
26.446 - </j2seproject3:debug>
26.447 - </target>
26.448 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
26.449 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
26.450 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
26.451 - </target>
26.452 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
26.453 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
26.454 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
26.455 - <j2seproject3:debug classname="${debug.class}"/>
26.456 - </target>
26.457 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
26.458 - <target depends="init" name="-pre-debug-fix">
26.459 - <fail unless="fix.includes">Must set fix.includes</fail>
26.460 - <property name="javac.includes" value="${fix.includes}.java"/>
26.461 - </target>
26.462 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
26.463 - <j2seproject1:nbjpdareload/>
26.464 - </target>
26.465 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
26.466 - <!--
26.467 - ===============
26.468 - JAVADOC SECTION
26.469 - ===============
26.470 - -->
26.471 - <target depends="init" name="-javadoc-build">
26.472 - <mkdir dir="${dist.javadoc.dir}"/>
26.473 - <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
26.474 - <classpath>
26.475 - <path path="${javac.classpath}"/>
26.476 - </classpath>
26.477 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
26.478 - <filename name="**/*.java"/>
26.479 - </fileset>
26.480 - </javadoc>
26.481 - </target>
26.482 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
26.483 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
26.484 - </target>
26.485 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
26.486 - <!--
26.487 - =========================
26.488 - JUNIT COMPILATION SECTION
26.489 - =========================
26.490 - -->
26.491 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
26.492 - <mkdir dir="${build.test.classes.dir}"/>
26.493 - </target>
26.494 - <target name="-pre-compile-test">
26.495 - <!-- Empty placeholder for easier customization. -->
26.496 - <!-- You can override this target in the ../build.xml file. -->
26.497 - </target>
26.498 - <target if="do.depend.true" name="-compile-test-depend">
26.499 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
26.500 - </target>
26.501 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
26.502 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
26.503 - <copy todir="${build.test.classes.dir}">
26.504 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
26.505 - </copy>
26.506 - </target>
26.507 - <target name="-post-compile-test">
26.508 - <!-- Empty placeholder for easier customization. -->
26.509 - <!-- You can override this target in the ../build.xml file. -->
26.510 - </target>
26.511 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
26.512 - <target name="-pre-compile-test-single">
26.513 - <!-- Empty placeholder for easier customization. -->
26.514 - <!-- You can override this target in the ../build.xml file. -->
26.515 - </target>
26.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
26.517 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
26.518 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
26.519 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
26.520 - <copy todir="${build.test.classes.dir}">
26.521 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
26.522 - </copy>
26.523 - </target>
26.524 - <target name="-post-compile-test-single">
26.525 - <!-- Empty placeholder for easier customization. -->
26.526 - <!-- You can override this target in the ../build.xml file. -->
26.527 - </target>
26.528 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
26.529 - <!--
26.530 - =======================
26.531 - JUNIT EXECUTION SECTION
26.532 - =======================
26.533 - -->
26.534 - <target depends="init" if="have.tests" name="-pre-test-run">
26.535 - <mkdir dir="${build.test.results.dir}"/>
26.536 - </target>
26.537 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
26.538 - <j2seproject3:junit testincludes="**/*Test.java"/>
26.539 - </target>
26.540 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
26.541 - <fail if="tests.failed">Some tests failed; see details above.</fail>
26.542 - </target>
26.543 - <target depends="init" if="have.tests" name="test-report"/>
26.544 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
26.545 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
26.546 - <target depends="init" if="have.tests" name="-pre-test-run-single">
26.547 - <mkdir dir="${build.test.results.dir}"/>
26.548 - </target>
26.549 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
26.550 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
26.551 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
26.552 - </target>
26.553 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
26.554 - <fail if="tests.failed">Some tests failed; see details above.</fail>
26.555 - </target>
26.556 - <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
26.557 - <!--
26.558 - =======================
26.559 - JUNIT DEBUGGING SECTION
26.560 - =======================
26.561 - -->
26.562 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
26.563 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
26.564 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
26.565 - <delete file="${test.report.file}"/>
26.566 - <mkdir dir="${build.test.results.dir}"/>
26.567 - <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
26.568 - <customize>
26.569 - <syspropertyset>
26.570 - <propertyref prefix="test-sys-prop."/>
26.571 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
26.572 - </syspropertyset>
26.573 - <arg value="${test.class}"/>
26.574 - <arg value="showoutput=true"/>
26.575 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
26.576 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
26.577 - </customize>
26.578 - </j2seproject3:debug>
26.579 - </target>
26.580 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
26.581 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
26.582 - </target>
26.583 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
26.584 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
26.585 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
26.586 - </target>
26.587 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
26.588 - <!--
26.589 - =========================
26.590 - APPLET EXECUTION SECTION
26.591 - =========================
26.592 - -->
26.593 - <target depends="init,compile-single" name="run-applet">
26.594 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
26.595 - <j2seproject1:java classname="sun.applet.AppletViewer">
26.596 - <customize>
26.597 - <arg value="${applet.url}"/>
26.598 - </customize>
26.599 - </j2seproject1:java>
26.600 - </target>
26.601 - <!--
26.602 - =========================
26.603 - APPLET DEBUGGING SECTION
26.604 - =========================
26.605 - -->
26.606 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
26.607 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
26.608 - <j2seproject3:debug classname="sun.applet.AppletViewer">
26.609 - <customize>
26.610 - <arg value="${applet.url}"/>
26.611 - </customize>
26.612 - </j2seproject3:debug>
26.613 - </target>
26.614 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
26.615 - <!--
26.616 - ===============
26.617 - CLEANUP SECTION
26.618 - ===============
26.619 - -->
26.620 - <target depends="init" name="deps-clean" unless="no.deps"/>
26.621 - <target depends="init" name="-do-clean">
26.622 - <delete dir="${build.dir}"/>
26.623 - <delete dir="${dist.dir}"/>
26.624 - </target>
26.625 - <target name="-post-clean">
26.626 - <!-- Empty placeholder for easier customization. -->
26.627 - <!-- You can override this target in the ../build.xml file. -->
26.628 - </target>
26.629 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
26.630 -</project>
27.1 --- a/samples/messagedigest/nbproject/genfiles.properties Sat Jun 14 10:32:31 2008 +0200
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,8 +0,0 @@
27.4 -build.xml.data.CRC32=3e547a57
27.5 -build.xml.script.CRC32=caa29e5e
27.6 -build.xml.stylesheet.CRC32=be360661
27.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
27.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
27.9 -nbproject/build-impl.xml.data.CRC32=3e547a57
27.10 -nbproject/build-impl.xml.script.CRC32=75ab765e
27.11 -nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
28.1 --- a/samples/messagedigest/nbproject/project.properties Sat Jun 14 10:32:31 2008 +0200
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,57 +0,0 @@
28.4 -build.classes.dir=${build.dir}/classes
28.5 -build.classes.excludes=**/*.java,**/*.form
28.6 -# This directory is removed when the project is cleaned:
28.7 -build.dir=build
28.8 -build.generated.dir=${build.dir}/generated
28.9 -# Only compile against the classpath explicitly listed here:
28.10 -build.sysclasspath=ignore
28.11 -build.test.classes.dir=${build.dir}/test/classes
28.12 -build.test.results.dir=${build.dir}/test/results
28.13 -debug.classpath=\
28.14 - ${run.classpath}
28.15 -debug.test.classpath=\
28.16 - ${run.test.classpath}
28.17 -# This directory is removed when the project is cleaned:
28.18 -dist.dir=dist
28.19 -dist.jar=${dist.dir}/messagedigest.jar
28.20 -dist.javadoc.dir=${dist.dir}/javadoc
28.21 -excludes=
28.22 -includes=**
28.23 -jar.compress=false
28.24 -javac.classpath=
28.25 -# Space-separated list of extra javac options
28.26 -javac.compilerargs=
28.27 -javac.deprecation=false
28.28 -javac.source=1.5
28.29 -javac.target=1.5
28.30 -javac.test.classpath=\
28.31 - ${javac.classpath}:\
28.32 - ${build.classes.dir}:\
28.33 - ${libs.junit.classpath}:\
28.34 - ${libs.junit_4.classpath}
28.35 -javadoc.additionalparam=
28.36 -javadoc.author=false
28.37 -javadoc.encoding=${source.encoding}
28.38 -javadoc.noindex=false
28.39 -javadoc.nonavbar=false
28.40 -javadoc.notree=false
28.41 -javadoc.private=false
28.42 -javadoc.splitindex=true
28.43 -javadoc.use=true
28.44 -javadoc.version=false
28.45 -javadoc.windowtitle=
28.46 -meta.inf.dir=${src.dir}/META-INF
28.47 -platform.active=default_platform
28.48 -run.classpath=\
28.49 - ${javac.classpath}:\
28.50 - ${build.classes.dir}
28.51 -# Space-separated list of JVM arguments used when running the project
28.52 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
28.53 -# or test-sys-prop.name=value to set system properties for unit tests):
28.54 -run.jvmargs=
28.55 -run.test.classpath=\
28.56 - ${javac.test.classpath}:\
28.57 - ${build.test.classes.dir}
28.58 -source.encoding=UTF-8
28.59 -src.dir=src
28.60 -test.src.dir=test
29.1 --- a/samples/messagedigest/src-bridge/META-INF/services/org.apidesign.impl.security.friendapi.DigestProvider Sat Jun 14 10:32:31 2008 +0200
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,3 +0,0 @@
29.4 -# this shall be in a separate module that provides the "bridge"
29.5 -org.apidesign.impl.security.extension.BridgeToOldAlgorithmsProvider
29.6 -
30.1 --- a/samples/messagedigest/src-bridge/org/apidesign/impl/security/extension/BridgeToOldAlgorithmsProvider.java Sat Jun 14 10:32:31 2008 +0200
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,46 +0,0 @@
30.4 -/*
30.5 - * To change this template, choose Tools | Templates
30.6 - * and open the template in the editor.
30.7 - */
30.8 -
30.9 -package org.apidesign.impl.security.extension;
30.10 -
30.11 -import org.apidesign.impl.security.friendapi.DigestImplementation;
30.12 -import org.apidesign.impl.security.friendapi.DigestProvider;
30.13 -import java.nio.ByteBuffer;
30.14 -import java.security.MessageDigest;
30.15 -import java.security.NoSuchAlgorithmException;
30.16 -import java.util.logging.Level;
30.17 -import java.util.logging.Logger;
30.18 -
30.19 -/**
30.20 - *
30.21 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
30.22 - */
30.23 -public class BridgeToOldAlgorithmsProvider implements DigestProvider {
30.24 -
30.25 - public DigestImplementation create(String algorithm) {
30.26 - try {
30.27 - final MessageDigest md = MessageDigest.getInstance(algorithm);
30.28 - return new DigestImplementation(algorithm) {
30.29 -
30.30 - @Override
30.31 - public void update(ByteBuffer bb) {
30.32 - md.update(bb);
30.33 - }
30.34 -
30.35 - @Override
30.36 - public byte[] digest() {
30.37 - return md.digest();
30.38 - }
30.39 - };
30.40 - } catch (NoSuchAlgorithmException ex) {
30.41 - Logger.getLogger(BridgeToOldAlgorithmsProvider.class.getName()).log(Level.INFO, null, ex);
30.42 - return null;
30.43 - }
30.44 - }
30.45 -
30.46 - static {
30.47 - new BridgeToOld();
30.48 - }
30.49 -}
31.1 --- a/samples/messagedigest/src-new-api/org/apidesign/impl/security/friendapi/DigestImplementation.java Sat Jun 14 10:32:31 2008 +0200
31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
31.3 @@ -1,23 +0,0 @@
31.4 -/*
31.5 - * To change this template, choose Tools | Templates
31.6 - * and open the template in the editor.
31.7 - */
31.8 -
31.9 -package org.apidesign.impl.security.friendapi;
31.10 -
31.11 -import java.nio.ByteBuffer;
31.12 -
31.13 -/**
31.14 - *
31.15 - * @author Jaroslav Tulach
31.16 - */
31.17 -public abstract class DigestImplementation {
31.18 - final String name;
31.19 -
31.20 - protected DigestImplementation(String algorithm) {
31.21 - this.name = algorithm;
31.22 - }
31.23 -
31.24 - public abstract void update(ByteBuffer bb);
31.25 - public abstract byte[] digest();
31.26 -}
32.1 --- a/samples/messagedigest/src-new-api/org/apidesign/impl/security/friendapi/DigestProvider.java Sat Jun 14 10:32:31 2008 +0200
32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
32.3 @@ -1,14 +0,0 @@
32.4 -/*
32.5 - * To change this template, choose Tools | Templates
32.6 - * and open the template in the editor.
32.7 - */
32.8 -
32.9 -package org.apidesign.impl.security.friendapi;
32.10 -
32.11 -/**
32.12 - *
32.13 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
32.14 - */
32.15 -public interface DigestProvider {
32.16 - public abstract DigestImplementation create(String algorithm);
32.17 -}
33.1 --- a/samples/messagedigest/src-new-spi/META-INF/services/org.apidesign.impl.security.friendapi.DigestProvider Sat Jun 14 10:32:31 2008 +0200
33.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
33.3 @@ -1,2 +0,0 @@
33.4 -# this is a provider for the SPI, shall be in the same module as the api & spi
33.5 -org.apidesign.impl.security.spi.DigestorProvider
34.1 --- a/samples/messagedigest/src-new-spi/org/apidesign/impl/security/spi/DigestorAccessor.java Sat Jun 14 10:32:31 2008 +0200
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,35 +0,0 @@
34.4 -/*
34.5 - * To change this template, choose Tools | Templates
34.6 - * and open the template in the editor.
34.7 - */
34.8 -
34.9 -package org.apidesign.impl.security.spi;
34.10 -
34.11 -import java.nio.ByteBuffer;
34.12 -import org.apidesign.spi.security.Digestor;
34.13 -
34.14 -/**
34.15 - *
34.16 - * @author jarda
34.17 - */
34.18 -public abstract class DigestorAccessor {
34.19 - private static DigestorAccessor INSTANCE;
34.20 -
34.21 - protected DigestorAccessor() {
34.22 - assert INSTANCE == null;
34.23 - INSTANCE = this;
34.24 - }
34.25 -
34.26 - public static DigestorAccessor getDefault() {
34.27 - try {
34.28 - Class.forName(Digestor.class.getName(), true, DigestorAccessor.class.getClassLoader());
34.29 - return INSTANCE;
34.30 - } catch (ClassNotFoundException ex) {
34.31 - throw new IllegalStateException(ex);
34.32 - }
34.33 - }
34.34 -
34.35 - protected abstract <Data> byte[] digest(Digestor<Data> dig, Data data);
34.36 - protected abstract <Data> Data create(Digestor<Data> dig, String algorithm);
34.37 - protected abstract <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input);
34.38 -}
35.1 --- a/samples/messagedigest/src-new-spi/org/apidesign/impl/security/spi/DigestorProvider.java Sat Jun 14 10:32:31 2008 +0200
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,61 +0,0 @@
35.4 -/*
35.5 - * To change this template, choose Tools | Templates
35.6 - * and open the template in the editor.
35.7 - */
35.8 -
35.9 -package org.apidesign.impl.security.spi;
35.10 -
35.11 -import org.apidesign.impl.security.friendapi.DigestImplementation;
35.12 -import org.apidesign.impl.security.friendapi.DigestProvider;
35.13 -import java.nio.ByteBuffer;
35.14 -import java.util.ServiceLoader;
35.15 -import org.apidesign.spi.security.Digestor;
35.16 -
35.17 -/**
35.18 - *
35.19 - * @author Jaroslav Tulach
35.20 - */
35.21 -public class DigestorProvider implements DigestProvider {
35.22 -
35.23 - public DigestImplementation create(String algorithm) {
35.24 - for (Digestor<?> d : ServiceLoader.load(Digestor.class)) {
35.25 - Handler<?> h = create(d, algorithm);
35.26 - if (h != null) {
35.27 - return h;
35.28 - }
35.29 - }
35.30 - return null;
35.31 - }
35.32 -
35.33 - private static <Data> Handler<Data> create(Digestor<Data> dig, String algorithm) {
35.34 - Data d = DigestorAccessor.getDefault().create(dig, algorithm);
35.35 - if (d == null) {
35.36 - return null;
35.37 - } else {
35.38 - return new Handler<Data>(algorithm, dig, d);
35.39 - }
35.40 - }
35.41 -
35.42 - private static final class Handler<Data> extends DigestImplementation {
35.43 - private final Digestor dig;
35.44 - private final Data data;
35.45 -
35.46 - public Handler(String algorithm, Digestor dig, Data data) {
35.47 - super(algorithm);
35.48 - this.dig = dig;
35.49 - this.data = data;
35.50 - }
35.51 -
35.52 -
35.53 - @Override
35.54 - public void update(ByteBuffer bb) {
35.55 - DigestorAccessor.getDefault().update(dig, data, bb);
35.56 - }
35.57 -
35.58 - @Override
35.59 - public byte[] digest() {
35.60 - return DigestorAccessor.getDefault().digest(dig, data);
35.61 - }
35.62 -
35.63 - }
35.64 -}
36.1 --- a/samples/messagedigest/src-new-spi/org/apidesign/spi/security/Digestor.java Sat Jun 14 10:32:31 2008 +0200
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,40 +0,0 @@
36.4 -/*
36.5 - * To change this template, choose Tools | Templates
36.6 - * and open the template in the editor.
36.7 - */
36.8 -
36.9 -package org.apidesign.spi.security;
36.10 -
36.11 -import org.apidesign.impl.security.spi.DigestorAccessor;
36.12 -import java.nio.ByteBuffer;
36.13 -
36.14 -/**
36.15 - *
36.16 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
36.17 - */
36.18 -// BEGIN: day.end.bridges.Digestor
36.19 -public abstract class Digestor<Data> {
36.20 - protected abstract byte[] digest(Data data);
36.21 - protected abstract Data create(String algorithm);
36.22 - protected abstract void update(Data data, ByteBuffer input);
36.23 -
36.24 -// END: day.end.bridges.Digestor
36.25 - static {
36.26 - new DigestorAccessor() {
36.27 - @Override
36.28 - protected <Data> byte[] digest(Digestor<Data> dig, Data data) {
36.29 - return dig.digest(data);
36.30 - }
36.31 -
36.32 - @Override
36.33 - protected <Data> Data create(Digestor<Data> dig, String algorithm) {
36.34 - return dig.create(algorithm);
36.35 - }
36.36 -
36.37 - @Override
36.38 - protected <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input) {
36.39 - dig.update(data, input);
36.40 - }
36.41 - };
36.42 - }
36.43 -}
37.1 --- a/samples/messagedigest/src/META-INF/services/impl.friendapi.DigestProvider Sat Jun 14 10:32:31 2008 +0200
37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
37.3 @@ -1,7 +0,0 @@
37.4 -# this is a provider for the SPI, shall be in the same module as the api & spi
37.5 -impl.spi.DigestorProvider
37.6 -
37.7 -
37.8 -# this shall be in a separate module that provides the "bridge"
37.9 -impl.independent.module.BridgeToOldAlgorithmsProvider
37.10 -
38.1 --- a/samples/messagedigest/src/META-INF/services/org.apidesign.impl.security.friendapi.DigestProvider Sat Jun 14 10:32:31 2008 +0200
38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
38.3 @@ -1,7 +0,0 @@
38.4 -# this is a provider for the SPI, shall be in the same module as the api & spi
38.5 -org.apidesign.impl.security.spi.DigestorProvider
38.6 -
38.7 -
38.8 -# this shall be in a separate module that provides the "bridge"
38.9 -org.apidesign.impl.security.extension.BridgeToOldAlgorithmsProvider
38.10 -
39.1 --- a/samples/messagedigest/src/api/Digest.java Sat Jun 14 10:32:31 2008 +0200
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,42 +0,0 @@
39.4 -
39.5 -package api;
39.6 -
39.7 -import java.nio.ByteBuffer;
39.8 -import impl.friendapi.DigestImplementation;
39.9 -import impl.friendapi.DigestProvider;
39.10 -import java.util.ServiceLoader;
39.11 -
39.12 -/** MessageDigest extends MessageDigestSpi, that means the javadoc
39.13 - *
39.14 - * @author Jaroslav Tulach
39.15 - */
39.16 -public final class Digest {
39.17 - private final DigestImplementation impl;
39.18 -
39.19 - /** Factory method is better than constructor */
39.20 - private Digest(DigestImplementation impl) {
39.21 - this.impl = impl;
39.22 - }
39.23 -
39.24 - /** Factory method to create digest for an algorithm.
39.25 - */
39.26 - public static Digest getInstance(String algorithm) {
39.27 - for (DigestProvider dp : ServiceLoader.load(DigestProvider.class)) {
39.28 - DigestImplementation impl = dp.create(algorithm);
39.29 - if (impl != null) {
39.30 - return new Digest(impl);
39.31 - }
39.32 - }
39.33 - throw new IllegalArgumentException(algorithm);
39.34 - }
39.35 -
39.36 - //
39.37 - // these methods are kept the same as in original MessageDigest,
39.38 - // but for simplicity choose just some from the original API
39.39 - //
39.40 -
39.41 - public byte[] digest(ByteBuffer bb) {
39.42 - impl.update(bb);
39.43 - return impl.digest();
39.44 - }
39.45 -}
40.1 --- a/samples/messagedigest/src/impl/friendapi/DigestImplementation.java Sat Jun 14 10:32:31 2008 +0200
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,23 +0,0 @@
40.4 -/*
40.5 - * To change this template, choose Tools | Templates
40.6 - * and open the template in the editor.
40.7 - */
40.8 -
40.9 -package impl.friendapi;
40.10 -
40.11 -import java.nio.ByteBuffer;
40.12 -
40.13 -/**
40.14 - *
40.15 - * @author Jaroslav Tulach
40.16 - */
40.17 -public abstract class DigestImplementation {
40.18 - final String name;
40.19 -
40.20 - protected DigestImplementation(String algorithm) {
40.21 - this.name = algorithm;
40.22 - }
40.23 -
40.24 - public abstract void update(ByteBuffer bb);
40.25 - public abstract byte[] digest();
40.26 -}
41.1 --- a/samples/messagedigest/src/impl/friendapi/DigestProvider.java Sat Jun 14 10:32:31 2008 +0200
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,14 +0,0 @@
41.4 -/*
41.5 - * To change this template, choose Tools | Templates
41.6 - * and open the template in the editor.
41.7 - */
41.8 -
41.9 -package impl.friendapi;
41.10 -
41.11 -/**
41.12 - *
41.13 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
41.14 - */
41.15 -public interface DigestProvider {
41.16 - public abstract DigestImplementation create(String algorithm);
41.17 -}
42.1 --- a/samples/messagedigest/src/impl/independent/module/BridgeToOld.java Sat Jun 14 10:32:31 2008 +0200
42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
42.3 @@ -1,82 +0,0 @@
42.4 -/*
42.5 - * To change this template, choose Tools | Templates
42.6 - * and open the template in the editor.
42.7 - */
42.8 -
42.9 -package impl.independent.module;
42.10 -
42.11 -import api.Digest;
42.12 -import java.nio.ByteBuffer;
42.13 -import java.security.MessageDigest;
42.14 -import java.security.NoSuchAlgorithmException;
42.15 -import java.security.Provider;
42.16 -import java.security.Security;
42.17 -import java.util.Collections;
42.18 -import java.util.List;
42.19 -import java.util.Map;
42.20 -
42.21 -/**
42.22 - *
42.23 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
42.24 - */
42.25 -public class BridgeToOld extends Provider {
42.26 -
42.27 - public BridgeToOld() {
42.28 - super("spi.Digestor", 1.0, "");
42.29 - Security.addProvider(this);
42.30 - }
42.31 -
42.32 - @Override
42.33 - public synchronized Service getService(String type, String algorithm) {
42.34 - if ("MessageDigest".equals(type)) {
42.35 - Digest dig = Digest.getInstance(algorithm);
42.36 - if (dig != null) {
42.37 - return new ServiceImpl(dig, this, type, algorithm, "", Collections.<String>emptyList(), Collections.<String,String>emptyMap());
42.38 - }
42.39 - }
42.40 - return null;
42.41 - }
42.42 -
42.43 - private static class ServiceImpl<Data> extends Service {
42.44 - Digest dig;
42.45 -
42.46 - public ServiceImpl(Digest dig, Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String, String> attributes) {
42.47 - super(provider, type, algorithm, className, aliases, attributes);
42.48 - this.dig = dig;
42.49 - }
42.50 -
42.51 - @Override
42.52 - public Object newInstance(Object constructorParameter) throws NoSuchAlgorithmException {
42.53 - return new MessageDigest(getAlgorithm()) {
42.54 - private byte[] res;
42.55 -
42.56 - @Override
42.57 - protected void engineUpdate(byte input) {
42.58 - ByteBuffer bb = ByteBuffer.wrap(new byte[] { input });
42.59 - res = dig.digest(bb);
42.60 - }
42.61 -
42.62 - @Override
42.63 - protected void engineUpdate(byte[] input, int offset, int len) {
42.64 - ByteBuffer bb = ByteBuffer.wrap(input);
42.65 - bb.position(offset);
42.66 - bb.limit(offset + len);
42.67 - res = dig.digest(bb);
42.68 - }
42.69 -
42.70 - @Override
42.71 - protected byte[] engineDigest() {
42.72 - return res;
42.73 - }
42.74 -
42.75 - @Override
42.76 - protected void engineReset() {
42.77 - dig = Digest.getInstance(getAlgorithm());
42.78 - }
42.79 - };
42.80 - }
42.81 -
42.82 -
42.83 - }
42.84 -
42.85 -}
43.1 --- a/samples/messagedigest/src/impl/independent/module/BridgeToOldAlgorithmsProvider.java Sat Jun 14 10:32:31 2008 +0200
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,46 +0,0 @@
43.4 -/*
43.5 - * To change this template, choose Tools | Templates
43.6 - * and open the template in the editor.
43.7 - */
43.8 -
43.9 -package impl.independent.module;
43.10 -
43.11 -import impl.friendapi.DigestImplementation;
43.12 -import impl.friendapi.DigestProvider;
43.13 -import java.nio.ByteBuffer;
43.14 -import java.security.MessageDigest;
43.15 -import java.security.NoSuchAlgorithmException;
43.16 -import java.util.logging.Level;
43.17 -import java.util.logging.Logger;
43.18 -
43.19 -/**
43.20 - *
43.21 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
43.22 - */
43.23 -public class BridgeToOldAlgorithmsProvider implements DigestProvider {
43.24 -
43.25 - public DigestImplementation create(String algorithm) {
43.26 - try {
43.27 - final MessageDigest md = MessageDigest.getInstance(algorithm);
43.28 - return new DigestImplementation(algorithm) {
43.29 -
43.30 - @Override
43.31 - public void update(ByteBuffer bb) {
43.32 - md.update(bb);
43.33 - }
43.34 -
43.35 - @Override
43.36 - public byte[] digest() {
43.37 - return md.digest();
43.38 - }
43.39 - };
43.40 - } catch (NoSuchAlgorithmException ex) {
43.41 - Logger.getLogger(BridgeToOldAlgorithmsProvider.class.getName()).log(Level.INFO, null, ex);
43.42 - return null;
43.43 - }
43.44 - }
43.45 -
43.46 - static {
43.47 - new BridgeToOld();
43.48 - }
43.49 -}
44.1 --- a/samples/messagedigest/src/impl/spi/DigestorAccessor.java Sat Jun 14 10:32:31 2008 +0200
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,35 +0,0 @@
44.4 -/*
44.5 - * To change this template, choose Tools | Templates
44.6 - * and open the template in the editor.
44.7 - */
44.8 -
44.9 -package impl.spi;
44.10 -
44.11 -import java.nio.ByteBuffer;
44.12 -import spi.Digestor;
44.13 -
44.14 -/**
44.15 - *
44.16 - * @author jarda
44.17 - */
44.18 -public abstract class DigestorAccessor {
44.19 - private static DigestorAccessor INSTANCE;
44.20 -
44.21 - protected DigestorAccessor() {
44.22 - assert INSTANCE == null;
44.23 - INSTANCE = this;
44.24 - }
44.25 -
44.26 - public static DigestorAccessor getDefault() {
44.27 - try {
44.28 - Class.forName(Digestor.class.getName(), true, DigestorAccessor.class.getClassLoader());
44.29 - return INSTANCE;
44.30 - } catch (ClassNotFoundException ex) {
44.31 - throw new IllegalStateException(ex);
44.32 - }
44.33 - }
44.34 -
44.35 - protected abstract <Data> byte[] digest(Digestor<Data> dig, Data data);
44.36 - protected abstract <Data> Data create(Digestor<Data> dig, String algorithm);
44.37 - protected abstract <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input);
44.38 -}
45.1 --- a/samples/messagedigest/src/impl/spi/DigestorProvider.java Sat Jun 14 10:32:31 2008 +0200
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,61 +0,0 @@
45.4 -/*
45.5 - * To change this template, choose Tools | Templates
45.6 - * and open the template in the editor.
45.7 - */
45.8 -
45.9 -package impl.spi;
45.10 -
45.11 -import impl.friendapi.DigestImplementation;
45.12 -import impl.friendapi.DigestProvider;
45.13 -import java.nio.ByteBuffer;
45.14 -import java.util.ServiceLoader;
45.15 -import spi.Digestor;
45.16 -
45.17 -/**
45.18 - *
45.19 - * @author Jaroslav Tulach
45.20 - */
45.21 -public class DigestorProvider implements DigestProvider {
45.22 -
45.23 - public DigestImplementation create(String algorithm) {
45.24 - for (Digestor<?> d : ServiceLoader.load(Digestor.class)) {
45.25 - Handler<?> h = create(d, algorithm);
45.26 - if (h != null) {
45.27 - return h;
45.28 - }
45.29 - }
45.30 - return null;
45.31 - }
45.32 -
45.33 - private static <Data> Handler<Data> create(Digestor<Data> dig, String algorithm) {
45.34 - Data d = DigestorAccessor.getDefault().create(dig, algorithm);
45.35 - if (d == null) {
45.36 - return null;
45.37 - } else {
45.38 - return new Handler<Data>(algorithm, dig, d);
45.39 - }
45.40 - }
45.41 -
45.42 - private static final class Handler<Data> extends DigestImplementation {
45.43 - private final Digestor dig;
45.44 - private final Data data;
45.45 -
45.46 - public Handler(String algorithm, Digestor dig, Data data) {
45.47 - super(algorithm);
45.48 - this.dig = dig;
45.49 - this.data = data;
45.50 - }
45.51 -
45.52 -
45.53 - @Override
45.54 - public void update(ByteBuffer bb) {
45.55 - DigestorAccessor.getDefault().update(dig, data, bb);
45.56 - }
45.57 -
45.58 - @Override
45.59 - public byte[] digest() {
45.60 - return DigestorAccessor.getDefault().digest(dig, data);
45.61 - }
45.62 -
45.63 - }
45.64 -}
46.1 --- a/samples/messagedigest/src/org/apidesign/api/security/Digest.java Sat Jun 14 10:32:31 2008 +0200
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,42 +0,0 @@
46.4 -
46.5 -package org.apidesign.api.security;
46.6 -
46.7 -import java.nio.ByteBuffer;
46.8 -import org.apidesign.impl.security.friendapi.DigestImplementation;
46.9 -import org.apidesign.impl.security.friendapi.DigestProvider;
46.10 -import java.util.ServiceLoader;
46.11 -
46.12 -/** MessageDigest extends MessageDigestSpi, that means the javadoc
46.13 - *
46.14 - * @author Jaroslav Tulach
46.15 - */
46.16 -public final class Digest {
46.17 - private final DigestImplementation impl;
46.18 -
46.19 - /** Factory method is better than constructor */
46.20 - private Digest(DigestImplementation impl) {
46.21 - this.impl = impl;
46.22 - }
46.23 -
46.24 - /** Factory method to create digest for an algorithm.
46.25 - */
46.26 - public static Digest getInstance(String algorithm) {
46.27 - for (DigestProvider dp : ServiceLoader.load(DigestProvider.class)) {
46.28 - DigestImplementation impl = dp.create(algorithm);
46.29 - if (impl != null) {
46.30 - return new Digest(impl);
46.31 - }
46.32 - }
46.33 - throw new IllegalArgumentException(algorithm);
46.34 - }
46.35 -
46.36 - //
46.37 - // these methods are kept the same as in original MessageDigest,
46.38 - // but for simplicity choose just some from the original API
46.39 - //
46.40 -
46.41 - public byte[] digest(ByteBuffer bb) {
46.42 - impl.update(bb);
46.43 - return impl.digest();
46.44 - }
46.45 -}
47.1 --- a/samples/messagedigest/src/org/apidesign/impl/security/extension/BridgeToOld.java Sat Jun 14 10:32:31 2008 +0200
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,82 +0,0 @@
47.4 -/*
47.5 - * To change this template, choose Tools | Templates
47.6 - * and open the template in the editor.
47.7 - */
47.8 -
47.9 -package org.apidesign.impl.security.extension;
47.10 -
47.11 -import org.apidesign.api.security.Digest;
47.12 -import java.nio.ByteBuffer;
47.13 -import java.security.MessageDigest;
47.14 -import java.security.NoSuchAlgorithmException;
47.15 -import java.security.Provider;
47.16 -import java.security.Security;
47.17 -import java.util.Collections;
47.18 -import java.util.List;
47.19 -import java.util.Map;
47.20 -
47.21 -/**
47.22 - *
47.23 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
47.24 - */
47.25 -public class BridgeToOld extends Provider {
47.26 -
47.27 - public BridgeToOld() {
47.28 - super("spi.Digestor", 1.0, "");
47.29 - Security.addProvider(this);
47.30 - }
47.31 -
47.32 - @Override
47.33 - public synchronized Service getService(String type, String algorithm) {
47.34 - if ("MessageDigest".equals(type)) {
47.35 - Digest dig = Digest.getInstance(algorithm);
47.36 - if (dig != null) {
47.37 - return new ServiceImpl(dig, this, type, algorithm, "", Collections.<String>emptyList(), Collections.<String,String>emptyMap());
47.38 - }
47.39 - }
47.40 - return null;
47.41 - }
47.42 -
47.43 - private static class ServiceImpl<Data> extends Service {
47.44 - Digest dig;
47.45 -
47.46 - public ServiceImpl(Digest dig, Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String, String> attributes) {
47.47 - super(provider, type, algorithm, className, aliases, attributes);
47.48 - this.dig = dig;
47.49 - }
47.50 -
47.51 - @Override
47.52 - public Object newInstance(Object constructorParameter) throws NoSuchAlgorithmException {
47.53 - return new MessageDigest(getAlgorithm()) {
47.54 - private byte[] res;
47.55 -
47.56 - @Override
47.57 - protected void engineUpdate(byte input) {
47.58 - ByteBuffer bb = ByteBuffer.wrap(new byte[] { input });
47.59 - res = dig.digest(bb);
47.60 - }
47.61 -
47.62 - @Override
47.63 - protected void engineUpdate(byte[] input, int offset, int len) {
47.64 - ByteBuffer bb = ByteBuffer.wrap(input);
47.65 - bb.position(offset);
47.66 - bb.limit(offset + len);
47.67 - res = dig.digest(bb);
47.68 - }
47.69 -
47.70 - @Override
47.71 - protected byte[] engineDigest() {
47.72 - return res;
47.73 - }
47.74 -
47.75 - @Override
47.76 - protected void engineReset() {
47.77 - dig = Digest.getInstance(getAlgorithm());
47.78 - }
47.79 - };
47.80 - }
47.81 -
47.82 -
47.83 - }
47.84 -
47.85 -}
48.1 --- a/samples/messagedigest/src/org/apidesign/impl/security/extension/BridgeToOldAlgorithmsProvider.java Sat Jun 14 10:32:31 2008 +0200
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,46 +0,0 @@
48.4 -/*
48.5 - * To change this template, choose Tools | Templates
48.6 - * and open the template in the editor.
48.7 - */
48.8 -
48.9 -package org.apidesign.impl.security.extension;
48.10 -
48.11 -import org.apidesign.impl.security.friendapi.DigestImplementation;
48.12 -import org.apidesign.impl.security.friendapi.DigestProvider;
48.13 -import java.nio.ByteBuffer;
48.14 -import java.security.MessageDigest;
48.15 -import java.security.NoSuchAlgorithmException;
48.16 -import java.util.logging.Level;
48.17 -import java.util.logging.Logger;
48.18 -
48.19 -/**
48.20 - *
48.21 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
48.22 - */
48.23 -public class BridgeToOldAlgorithmsProvider implements DigestProvider {
48.24 -
48.25 - public DigestImplementation create(String algorithm) {
48.26 - try {
48.27 - final MessageDigest md = MessageDigest.getInstance(algorithm);
48.28 - return new DigestImplementation(algorithm) {
48.29 -
48.30 - @Override
48.31 - public void update(ByteBuffer bb) {
48.32 - md.update(bb);
48.33 - }
48.34 -
48.35 - @Override
48.36 - public byte[] digest() {
48.37 - return md.digest();
48.38 - }
48.39 - };
48.40 - } catch (NoSuchAlgorithmException ex) {
48.41 - Logger.getLogger(BridgeToOldAlgorithmsProvider.class.getName()).log(Level.INFO, null, ex);
48.42 - return null;
48.43 - }
48.44 - }
48.45 -
48.46 - static {
48.47 - new BridgeToOld();
48.48 - }
48.49 -}
49.1 --- a/samples/messagedigest/src/org/apidesign/impl/security/friendapi/DigestProvider.java Sat Jun 14 10:32:31 2008 +0200
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,14 +0,0 @@
49.4 -/*
49.5 - * To change this template, choose Tools | Templates
49.6 - * and open the template in the editor.
49.7 - */
49.8 -
49.9 -package org.apidesign.impl.security.friendapi;
49.10 -
49.11 -/**
49.12 - *
49.13 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
49.14 - */
49.15 -public interface DigestProvider {
49.16 - public abstract DigestImplementation create(String algorithm);
49.17 -}
50.1 --- a/samples/messagedigest/src/org/apidesign/impl/security/spi/DigestorAccessor.java Sat Jun 14 10:32:31 2008 +0200
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,35 +0,0 @@
50.4 -/*
50.5 - * To change this template, choose Tools | Templates
50.6 - * and open the template in the editor.
50.7 - */
50.8 -
50.9 -package org.apidesign.impl.security.spi;
50.10 -
50.11 -import java.nio.ByteBuffer;
50.12 -import org.apidesign.spi.security.Digestor;
50.13 -
50.14 -/**
50.15 - *
50.16 - * @author jarda
50.17 - */
50.18 -public abstract class DigestorAccessor {
50.19 - private static DigestorAccessor INSTANCE;
50.20 -
50.21 - protected DigestorAccessor() {
50.22 - assert INSTANCE == null;
50.23 - INSTANCE = this;
50.24 - }
50.25 -
50.26 - public static DigestorAccessor getDefault() {
50.27 - try {
50.28 - Class.forName(Digestor.class.getName(), true, DigestorAccessor.class.getClassLoader());
50.29 - return INSTANCE;
50.30 - } catch (ClassNotFoundException ex) {
50.31 - throw new IllegalStateException(ex);
50.32 - }
50.33 - }
50.34 -
50.35 - protected abstract <Data> byte[] digest(Digestor<Data> dig, Data data);
50.36 - protected abstract <Data> Data create(Digestor<Data> dig, String algorithm);
50.37 - protected abstract <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input);
50.38 -}
51.1 --- a/samples/messagedigest/src/org/apidesign/impl/security/spi/DigestorProvider.java Sat Jun 14 10:32:31 2008 +0200
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,61 +0,0 @@
51.4 -/*
51.5 - * To change this template, choose Tools | Templates
51.6 - * and open the template in the editor.
51.7 - */
51.8 -
51.9 -package org.apidesign.impl.security.spi;
51.10 -
51.11 -import org.apidesign.impl.security.friendapi.DigestImplementation;
51.12 -import org.apidesign.impl.security.friendapi.DigestProvider;
51.13 -import java.nio.ByteBuffer;
51.14 -import java.util.ServiceLoader;
51.15 -import org.apidesign.spi.security.Digestor;
51.16 -
51.17 -/**
51.18 - *
51.19 - * @author Jaroslav Tulach
51.20 - */
51.21 -public class DigestorProvider implements DigestProvider {
51.22 -
51.23 - public DigestImplementation create(String algorithm) {
51.24 - for (Digestor<?> d : ServiceLoader.load(Digestor.class)) {
51.25 - Handler<?> h = create(d, algorithm);
51.26 - if (h != null) {
51.27 - return h;
51.28 - }
51.29 - }
51.30 - return null;
51.31 - }
51.32 -
51.33 - private static <Data> Handler<Data> create(Digestor<Data> dig, String algorithm) {
51.34 - Data d = DigestorAccessor.getDefault().create(dig, algorithm);
51.35 - if (d == null) {
51.36 - return null;
51.37 - } else {
51.38 - return new Handler<Data>(algorithm, dig, d);
51.39 - }
51.40 - }
51.41 -
51.42 - private static final class Handler<Data> extends DigestImplementation {
51.43 - private final Digestor dig;
51.44 - private final Data data;
51.45 -
51.46 - public Handler(String algorithm, Digestor dig, Data data) {
51.47 - super(algorithm);
51.48 - this.dig = dig;
51.49 - this.data = data;
51.50 - }
51.51 -
51.52 -
51.53 - @Override
51.54 - public void update(ByteBuffer bb) {
51.55 - DigestorAccessor.getDefault().update(dig, data, bb);
51.56 - }
51.57 -
51.58 - @Override
51.59 - public byte[] digest() {
51.60 - return DigestorAccessor.getDefault().digest(dig, data);
51.61 - }
51.62 -
51.63 - }
51.64 -}
52.1 --- a/samples/messagedigest/src/org/apidesign/spi/security/Digestor.java Sat Jun 14 10:32:31 2008 +0200
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,39 +0,0 @@
52.4 -/*
52.5 - * To change this template, choose Tools | Templates
52.6 - * and open the template in the editor.
52.7 - */
52.8 -
52.9 -package org.apidesign.spi.security;
52.10 -
52.11 -import org.apidesign.impl.security.spi.DigestorAccessor;
52.12 -import java.nio.ByteBuffer;
52.13 -
52.14 -/**
52.15 - *
52.16 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
52.17 - */
52.18 -public abstract class Digestor<Data> {
52.19 - protected abstract byte[] digest(Data data);
52.20 - protected abstract Data create(String algorithm);
52.21 - protected abstract void update(Data data, ByteBuffer input);
52.22 -
52.23 -
52.24 - static {
52.25 - new DigestorAccessor() {
52.26 - @Override
52.27 - protected <Data> byte[] digest(Digestor<Data> dig, Data data) {
52.28 - return dig.digest(data);
52.29 - }
52.30 -
52.31 - @Override
52.32 - protected <Data> Data create(Digestor<Data> dig, String algorithm) {
52.33 - return dig.create(algorithm);
52.34 - }
52.35 -
52.36 - @Override
52.37 - protected <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input) {
52.38 - dig.update(data, input);
52.39 - }
52.40 - };
52.41 - }
52.42 -}
53.1 --- a/samples/messagedigest/src/spi/DigestImplementation.java Sat Jun 14 10:32:31 2008 +0200
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,23 +0,0 @@
53.4 -/*
53.5 - * To change this template, choose Tools | Templates
53.6 - * and open the template in the editor.
53.7 - */
53.8 -
53.9 -package spi;
53.10 -
53.11 -import java.nio.ByteBuffer;
53.12 -
53.13 -/**
53.14 - *
53.15 - * @author Jaroslav Tulach
53.16 - */
53.17 -public abstract class DigestImplementation {
53.18 - final String name;
53.19 -
53.20 - protected DigestImplementation(String algorithm) {
53.21 - this.name = algorithm;
53.22 - }
53.23 -
53.24 - protected abstract void update(ByteBuffer bb);
53.25 - protected abstract byte[] digest();
53.26 -}
54.1 --- a/samples/messagedigest/src/spi/Digestor.java Sat Jun 14 10:32:31 2008 +0200
54.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
54.3 @@ -1,39 +0,0 @@
54.4 -/*
54.5 - * To change this template, choose Tools | Templates
54.6 - * and open the template in the editor.
54.7 - */
54.8 -
54.9 -package spi;
54.10 -
54.11 -import impl.spi.DigestorAccessor;
54.12 -import java.nio.ByteBuffer;
54.13 -
54.14 -/**
54.15 - *
54.16 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
54.17 - */
54.18 -public abstract class Digestor<Data> {
54.19 - protected abstract byte[] digest(Data data);
54.20 - protected abstract Data create(String algorithm);
54.21 - protected abstract void update(Data data, ByteBuffer input);
54.22 -
54.23 -
54.24 - static {
54.25 - new DigestorAccessor() {
54.26 - @Override
54.27 - protected <Data> byte[] digest(Digestor<Data> dig, Data data) {
54.28 - return dig.digest(data);
54.29 - }
54.30 -
54.31 - @Override
54.32 - protected <Data> Data create(Digestor<Data> dig, String algorithm) {
54.33 - return dig.create(algorithm);
54.34 - }
54.35 -
54.36 - @Override
54.37 - protected <Data> void update(Digestor<Data> dig, Data data, ByteBuffer input) {
54.38 - dig.update(data, input);
54.39 - }
54.40 - };
54.41 - }
54.42 -}
55.1 --- a/samples/messagedigest/test/META-INF/services/org.apidesign.spi.security.Digestor Sat Jun 14 10:32:31 2008 +0200
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,3 +0,0 @@
55.4 -# the provider registered from tests
55.5 -test.CountingDigestor
55.6 -
56.1 --- a/samples/messagedigest/test/META-INF/services/spi.Digestor Sat Jun 14 10:32:31 2008 +0200
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,3 +0,0 @@
56.4 -# the provider registered from tests
56.5 -api.CountingDigestor
56.6 -
57.1 --- a/samples/messagedigest/test/api/CountingDigestor.java Sat Jun 14 10:32:31 2008 +0200
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,35 +0,0 @@
57.4 -/*
57.5 - * To change this template, choose Tools | Templates
57.6 - * and open the template in the editor.
57.7 - */
57.8 -
57.9 -package api;
57.10 -
57.11 -import java.nio.ByteBuffer;
57.12 -import spi.Digestor;
57.13 -
57.14 -/**
57.15 - *
57.16 - * @author jarda
57.17 - */
57.18 -public final class CountingDigestor extends Digestor<int[]> {
57.19 -
57.20 - @Override
57.21 - protected byte[] digest(int[] data) {
57.22 - int i = data[0];
57.23 - byte[] arr = { (byte) (i & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255) };
57.24 - return arr;
57.25 - }
57.26 -
57.27 - @Override
57.28 - protected int[] create(String algorithm) {
57.29 - return "cnt".equals(algorithm) ? new int[1] : null; // NOI18N
57.30 - }
57.31 -
57.32 - @Override
57.33 - protected void update(int[] data, ByteBuffer input) {
57.34 - data[0] += input.remaining();
57.35 - input.position(input.position() + input.remaining());
57.36 - }
57.37 -
57.38 -}
58.1 --- a/samples/messagedigest/test/api/DigestTest.java Sat Jun 14 10:32:31 2008 +0200
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,64 +0,0 @@
58.4 -/*
58.5 - * To change this template, choose Tools | Templates
58.6 - * and open the template in the editor.
58.7 - */
58.8 -
58.9 -package api;
58.10 -
58.11 -import java.nio.ByteBuffer;
58.12 -import java.security.MessageDigest;
58.13 -import java.util.Arrays;
58.14 -import java.util.Random;
58.15 -import org.junit.After;
58.16 -import org.junit.BeforeClass;
58.17 -import org.junit.Test;
58.18 -import static org.junit.Assert.*;
58.19 -
58.20 -/** Compares that the MessageDigest and Digest yield the same results for
58.21 - * default provider.
58.22 - *
58.23 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
58.24 - */
58.25 -public class DigestTest {
58.26 - private static byte[] arr;
58.27 - private static long time;
58.28 - private static byte[] resOld;
58.29 - private static byte[] resNew;
58.30 -
58.31 - public DigestTest() {
58.32 - }
58.33 -
58.34 - @BeforeClass
58.35 - public static void setUp() {
58.36 - time = System.currentTimeMillis();
58.37 - Random r = new Random(time);
58.38 - arr = new byte[r.nextInt(1024)];
58.39 - r.nextBytes(arr);
58.40 - }
58.41 -
58.42 - @After
58.43 - public void tearDown() {
58.44 - }
58.45 -
58.46 - @Test
58.47 - public void generateHashUsingMessageDigest() throws Exception {
58.48 - MessageDigest md = MessageDigest.getInstance("MD5");
58.49 - byte[] res = md.digest(arr);
58.50 - resOld = res;
58.51 - }
58.52 -
58.53 - @Test
58.54 - public void generateHashUsingNewDigest() throws Exception {
58.55 - Digest d = Digest.getInstance("MD5");
58.56 - ByteBuffer bb = ByteBuffer.wrap(arr);
58.57 - byte[] res = d.digest(bb);
58.58 - resNew = res;
58.59 - }
58.60 -
58.61 - @Test
58.62 - public void compareTheHashes() throws Exception {
58.63 - if (!Arrays.equals(resOld, resNew)) {
58.64 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
58.65 - }
58.66 - }
58.67 -}
58.68 \ No newline at end of file
59.1 --- a/samples/messagedigest/test/api/DigestorTest.java Sat Jun 14 10:32:31 2008 +0200
59.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
59.3 @@ -1,66 +0,0 @@
59.4 -/*
59.5 - * To change this template, choose Tools | Templates
59.6 - * and open the template in the editor.
59.7 - */
59.8 -
59.9 -package api;
59.10 -
59.11 -import impl.independent.module.BridgeToOld;
59.12 -import java.nio.ByteBuffer;
59.13 -import java.security.MessageDigest;
59.14 -import java.util.Arrays;
59.15 -import java.util.Random;
59.16 -import org.junit.After;
59.17 -import org.junit.BeforeClass;
59.18 -import org.junit.Test;
59.19 -import static org.junit.Assert.*;
59.20 -
59.21 -/** Compares that the MessageDigest and Digest yield the same results for
59.22 - * default provider.
59.23 - *
59.24 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
59.25 - */
59.26 -public class DigestorTest {
59.27 - private static byte[] arr;
59.28 - private static long time;
59.29 - private static byte[] resOld;
59.30 - private static byte[] resNew;
59.31 -
59.32 - public DigestorTest() {
59.33 - }
59.34 -
59.35 - @BeforeClass
59.36 - public static void setUp() {
59.37 - time = System.currentTimeMillis();
59.38 - Random r = new Random(time);
59.39 - arr = new byte[r.nextInt(1024)];
59.40 - r.nextBytes(arr);
59.41 - }
59.42 -
59.43 - @After
59.44 - public void tearDown() {
59.45 - }
59.46 -
59.47 - @Test
59.48 - public void generateHashUsingNewDigest() throws Exception {
59.49 - Digest d = Digest.getInstance("cnt");
59.50 - ByteBuffer bb = ByteBuffer.wrap(arr);
59.51 - byte[] res = d.digest(bb);
59.52 - resNew = res;
59.53 - }
59.54 -
59.55 - @Test
59.56 - public void generateHashUsingMessageDigest() throws Exception {
59.57 - MessageDigest md = MessageDigest.getInstance("cnt");
59.58 - byte[] res = md.digest(arr);
59.59 - resOld = res;
59.60 - }
59.61 -
59.62 -
59.63 - @Test
59.64 - public void compareTheHashes() throws Exception {
59.65 - if (!Arrays.equals(resOld, resNew)) {
59.66 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
59.67 - }
59.68 - }
59.69 -}
59.70 \ No newline at end of file
60.1 --- a/samples/messagedigest/test/api/NewAPIToOldAPITest.java Sat Jun 14 10:32:31 2008 +0200
60.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
60.3 @@ -1,64 +0,0 @@
60.4 -/*
60.5 - * To change this template, choose Tools | Templates
60.6 - * and open the template in the editor.
60.7 - */
60.8 -
60.9 -package api;
60.10 -
60.11 -import java.nio.ByteBuffer;
60.12 -import java.security.MessageDigest;
60.13 -import java.util.Arrays;
60.14 -import java.util.Random;
60.15 -import org.junit.After;
60.16 -import org.junit.BeforeClass;
60.17 -import org.junit.Test;
60.18 -import static org.junit.Assert.*;
60.19 -
60.20 -/** Compares that the MessageDigest and Digest yield the same results for
60.21 - * default provider.
60.22 - *
60.23 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
60.24 - */
60.25 -public class NewAPIToOldAPITest {
60.26 - private static byte[] arr;
60.27 - private static long time;
60.28 - private static byte[] resOld;
60.29 - private static byte[] resNew;
60.30 -
60.31 - public NewAPIToOldAPITest() {
60.32 - }
60.33 -
60.34 - @BeforeClass
60.35 - public static void setUp() {
60.36 - time = System.currentTimeMillis();
60.37 - Random r = new Random(time);
60.38 - arr = new byte[r.nextInt(1024)];
60.39 - r.nextBytes(arr);
60.40 - }
60.41 -
60.42 - @After
60.43 - public void tearDown() {
60.44 - }
60.45 -
60.46 - @Test
60.47 - public void generateHashUsingMessageDigest() throws Exception {
60.48 - MessageDigest md = MessageDigest.getInstance("MD5");
60.49 - byte[] res = md.digest(arr);
60.50 - resOld = res;
60.51 - }
60.52 -
60.53 - @Test
60.54 - public void generateHashUsingNewDigest() throws Exception {
60.55 - Digest d = Digest.getInstance("MD5");
60.56 - ByteBuffer bb = ByteBuffer.wrap(arr);
60.57 - byte[] res = d.digest(bb);
60.58 - resNew = res;
60.59 - }
60.60 -
60.61 - @Test
60.62 - public void compareTheHashes() throws Exception {
60.63 - if (!Arrays.equals(resOld, resNew)) {
60.64 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
60.65 - }
60.66 - }
60.67 -}
60.68 \ No newline at end of file
61.1 --- a/samples/messagedigest/test/api/OldAPIToNewAPITest.java Sat Jun 14 10:32:31 2008 +0200
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,77 +0,0 @@
61.4 -/*
61.5 - * To change this template, choose Tools | Templates
61.6 - * and open the template in the editor.
61.7 - */
61.8 -
61.9 -package api;
61.10 -
61.11 -import impl.independent.module.BridgeToOld;
61.12 -import java.nio.ByteBuffer;
61.13 -import java.security.MessageDigest;
61.14 -import java.util.Arrays;
61.15 -import java.util.Random;
61.16 -import org.junit.After;
61.17 -import org.junit.BeforeClass;
61.18 -import org.junit.Test;
61.19 -import static org.junit.Assert.*;
61.20 -
61.21 -/** Compares that the MessageDigest and Digest yield the same results for
61.22 - * default provider.
61.23 - *
61.24 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
61.25 - */
61.26 -public class OldAPIToNewAPITest {
61.27 - private static byte[] arr;
61.28 - private static long time;
61.29 - private static byte[] resOld;
61.30 - private static byte[] resNew;
61.31 -
61.32 - public OldAPIToNewAPITest() {
61.33 - }
61.34 -
61.35 - @BeforeClass
61.36 - public static void setUp() {
61.37 - time = System.currentTimeMillis();
61.38 - Random r = new Random(time);
61.39 - arr = new byte[r.nextInt(1024)];
61.40 - r.nextBytes(arr);
61.41 - }
61.42 -
61.43 - @After
61.44 - public void tearDown() {
61.45 - }
61.46 -
61.47 - @Test
61.48 - public void generateHashUsingMessageDigest() throws Exception {
61.49 - // The java.security.Providers cannot be registered in META-INF/services
61.50 - // that is why one needs to either configure various properties or
61.51 - // make some dummy call that will initialize our bridge class.
61.52 - // Then the bridge class registers itself as a MessageDigest provider
61.53 - // in its constructor.
61.54 - //
61.55 - // This is the call:
61.56 - Digest initialize = Digest.getInstance("MD5");
61.57 -
61.58 - MessageDigest md = MessageDigest.getInstance("cnt");
61.59 - byte[] res = md.digest(arr);
61.60 - resOld = res;
61.61 - }
61.62 -
61.63 -
61.64 - @Test
61.65 - public void generateHashUsingNewDigest() throws Exception {
61.66 - Digest d = Digest.getInstance("cnt");
61.67 - ByteBuffer bb = ByteBuffer.wrap(arr);
61.68 - byte[] res = d.digest(bb);
61.69 - resNew = res;
61.70 - }
61.71 -
61.72 -
61.73 -
61.74 - @Test
61.75 - public void compareTheHashes() throws Exception {
61.76 - if (!Arrays.equals(resOld, resNew)) {
61.77 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
61.78 - }
61.79 - }
61.80 -}
61.81 \ No newline at end of file
62.1 --- a/samples/messagedigest/test/test/CountingDigestor.java Sat Jun 14 10:32:31 2008 +0200
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,35 +0,0 @@
62.4 -/*
62.5 - * To change this template, choose Tools | Templates
62.6 - * and open the template in the editor.
62.7 - */
62.8 -
62.9 -package test;
62.10 -
62.11 -import java.nio.ByteBuffer;
62.12 -import org.apidesign.spi.security.Digestor;
62.13 -
62.14 -/**
62.15 - *
62.16 - * @author jarda
62.17 - */
62.18 -public final class CountingDigestor extends Digestor<int[]> {
62.19 -
62.20 - @Override
62.21 - protected byte[] digest(int[] data) {
62.22 - int i = data[0];
62.23 - byte[] arr = { (byte) (i & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255) };
62.24 - return arr;
62.25 - }
62.26 -
62.27 - @Override
62.28 - protected int[] create(String algorithm) {
62.29 - return "cnt".equals(algorithm) ? new int[1] : null; // NOI18N
62.30 - }
62.31 -
62.32 - @Override
62.33 - protected void update(int[] data, ByteBuffer input) {
62.34 - data[0] += input.remaining();
62.35 - input.position(input.position() + input.remaining());
62.36 - }
62.37 -
62.38 -}
63.1 --- a/samples/messagedigest/test/test/NewAPIToOldAPITest.java Sat Jun 14 10:32:31 2008 +0200
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,65 +0,0 @@
63.4 -/*
63.5 - * To change this template, choose Tools | Templates
63.6 - * and open the template in the editor.
63.7 - */
63.8 -
63.9 -package test;
63.10 -
63.11 -import java.nio.ByteBuffer;
63.12 -import java.security.MessageDigest;
63.13 -import java.util.Arrays;
63.14 -import java.util.Random;
63.15 -import org.apidesign.api.security.Digest;
63.16 -import org.junit.After;
63.17 -import org.junit.BeforeClass;
63.18 -import org.junit.Test;
63.19 -import static org.junit.Assert.*;
63.20 -
63.21 -/** Compares that the MessageDigest and Digest yield the same results for
63.22 - * default provider.
63.23 - *
63.24 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
63.25 - */
63.26 -public class NewAPIToOldAPITest {
63.27 - private static byte[] arr;
63.28 - private static long time;
63.29 - private static byte[] resOld;
63.30 - private static byte[] resNew;
63.31 -
63.32 - public NewAPIToOldAPITest() {
63.33 - }
63.34 -
63.35 - @BeforeClass
63.36 - public static void setUp() {
63.37 - time = System.currentTimeMillis();
63.38 - Random r = new Random(time);
63.39 - arr = new byte[r.nextInt(1024)];
63.40 - r.nextBytes(arr);
63.41 - }
63.42 -
63.43 - @After
63.44 - public void tearDown() {
63.45 - }
63.46 -
63.47 - @Test
63.48 - public void generateHashUsingMessageDigest() throws Exception {
63.49 - MessageDigest md = MessageDigest.getInstance("MD5");
63.50 - byte[] res = md.digest(arr);
63.51 - resOld = res;
63.52 - }
63.53 -
63.54 - @Test
63.55 - public void generateHashUsingNewDigest() throws Exception {
63.56 - Digest d = Digest.getInstance("MD5");
63.57 - ByteBuffer bb = ByteBuffer.wrap(arr);
63.58 - byte[] res = d.digest(bb);
63.59 - resNew = res;
63.60 - }
63.61 -
63.62 - @Test
63.63 - public void compareTheHashes() throws Exception {
63.64 - if (!Arrays.equals(resOld, resNew)) {
63.65 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
63.66 - }
63.67 - }
63.68 -}
63.69 \ No newline at end of file
64.1 --- a/samples/messagedigest/test/test/OldAPIToNewAPITest.java Sat Jun 14 10:32:31 2008 +0200
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,78 +0,0 @@
64.4 -/*
64.5 - * To change this template, choose Tools | Templates
64.6 - * and open the template in the editor.
64.7 - */
64.8 -
64.9 -package test;
64.10 -
64.11 -import org.apidesign.api.security.*;
64.12 -import org.apidesign.impl.security.extension.BridgeToOld;
64.13 -import java.nio.ByteBuffer;
64.14 -import java.security.MessageDigest;
64.15 -import java.util.Arrays;
64.16 -import java.util.Random;
64.17 -import org.junit.After;
64.18 -import org.junit.BeforeClass;
64.19 -import org.junit.Test;
64.20 -import static org.junit.Assert.*;
64.21 -
64.22 -/** Compares that the MessageDigest and Digest yield the same results for
64.23 - * default provider.
64.24 - *
64.25 - * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
64.26 - */
64.27 -public class OldAPIToNewAPITest {
64.28 - private static byte[] arr;
64.29 - private static long time;
64.30 - private static byte[] resOld;
64.31 - private static byte[] resNew;
64.32 -
64.33 - public OldAPIToNewAPITest() {
64.34 - }
64.35 -
64.36 - @BeforeClass
64.37 - public static void setUp() {
64.38 - time = System.currentTimeMillis();
64.39 - Random r = new Random(time);
64.40 - arr = new byte[r.nextInt(1024)];
64.41 - r.nextBytes(arr);
64.42 - }
64.43 -
64.44 - @After
64.45 - public void tearDown() {
64.46 - }
64.47 -
64.48 - @Test
64.49 - public void generateHashUsingMessageDigest() throws Exception {
64.50 - // The java.security.Providers cannot be registered in META-INF/services
64.51 - // that is why one needs to either configure various properties or
64.52 - // make some dummy call that will initialize our bridge class.
64.53 - // Then the bridge class registers itself as a MessageDigest provider
64.54 - // in its constructor.
64.55 - //
64.56 - // This is the call:
64.57 - Digest initialize = Digest.getInstance("MD5");
64.58 -
64.59 - MessageDigest md = MessageDigest.getInstance("cnt");
64.60 - byte[] res = md.digest(arr);
64.61 - resOld = res;
64.62 - }
64.63 -
64.64 -
64.65 - @Test
64.66 - public void generateHashUsingNewDigest() throws Exception {
64.67 - Digest d = Digest.getInstance("cnt");
64.68 - ByteBuffer bb = ByteBuffer.wrap(arr);
64.69 - byte[] res = d.digest(bb);
64.70 - resNew = res;
64.71 - }
64.72 -
64.73 -
64.74 -
64.75 - @Test
64.76 - public void compareTheHashes() throws Exception {
64.77 - if (!Arrays.equals(resOld, resNew)) {
64.78 - fail("Arrays are different:\n" + Arrays.toString(resOld) + "\n" + Arrays.toString(resNew));
64.79 - }
64.80 - }
64.81 -}
64.82 \ No newline at end of file
65.1 --- a/samples/preventcyclicdependencies/src-acyclic2/META-INF/services/org.apidesign.cycles.array.MutableArray$DoEncode Sat Jun 14 10:32:31 2008 +0200
65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
65.3 @@ -1,1 +0,0 @@
65.4 -org.apidesign.cycles.crypt.DoEncodeImpl
66.1 --- a/samples/privilegedcreator/src/api/Locks.java Sat Jun 14 10:32:31 2008 +0200
66.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
66.3 @@ -1,58 +0,0 @@
66.4 -
66.5 -package api;
66.6 -
66.7 -import java.util.concurrent.Executor;
66.8 -
66.9 -/**
66.10 - *
66.11 - * @author Jaroslav Tulach <jtulach@netbeans.org>
66.12 - */
66.13 -public final class Locks {
66.14 - /** let's prefer factory methods */
66.15 - private Locks() {
66.16 - }
66.17 -
66.18 -
66.19 - public static Executor create() {
66.20 - return new Simple();
66.21 - }
66.22 -
66.23 - public static Executor create(boolean fair) {
66.24 - return new Fair(fair);
66.25 - }
66.26 -
66.27 - // BEGIN: design.less.privileged
66.28 - public static Executor create(Configuration config) {
66.29 - return new Fair(config.fair);
66.30 - }
66.31 -
66.32 - public static final class Configuration {
66.33 - boolean fair;
66.34 - int maxWaiters = -1;
66.35 -
66.36 - public void setFair(boolean fair) {
66.37 - this.fair = fair;
66.38 - }
66.39 - public void setMaxWaiters(int max) {
66.40 - this.maxWaiters = max;
66.41 - }
66.42 - }
66.43 - // END: design.less.privileged
66.44 -
66.45 - private static final class Simple implements Executor {
66.46 - public synchronized void execute(Runnable command) {
66.47 - command.run();
66.48 - }
66.49 - }
66.50 - private static final class Fair implements Executor {
66.51 - private boolean fair;
66.52 -
66.53 - public Fair(boolean fair) {
66.54 - this.fair = fair;
66.55 - }
66.56 -
66.57 - public void execute(Runnable command) {
66.58 - // TBD
66.59 - }
66.60 - }
66.61 -}
67.1 --- a/samples/sidemeanings/src/org/apidesign/sidemeanings/Mixed.java Sat Jun 14 10:32:31 2008 +0200
67.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
67.3 @@ -1,47 +0,0 @@
67.4 -package org.apidesign.sidemeanings;
67.5 -
67.6 -public final class Mixed {
67.7 - private Mixed() {}
67.8 -
67.9 -
67.10 - // BEGIN: sidemeanings.Mixed.Dirty
67.11 - public static abstract class MixedClass {
67.12 - protected MixedClass() { }
67.13 -
67.14 - public final void apiForClients() { /*...*/ }
67.15 - protected abstract void toBeImplementedBySubclass();
67.16 - protected final void toBeCalledBySubclass() { /* ... */ }
67.17 - }
67.18 - // END: sidemeanings.Mixed.Dirty
67.19 -
67.20 - // BEGIN: sidemeanings.Mixed.Clean
67.21 - public static final class NonMixed {
67.22 - private NonMixed() {}
67.23 - public static NonMixed create(NonMixedImpl impl) {
67.24 - NonMixed api = new NonMixed();
67.25 - Callback callback = new Callback(api);
67.26 - impl.initialize(callback);
67.27 - return api;
67.28 - }
67.29 -
67.30 - public final void apiForClients() { /*...*/ }
67.31 - }
67.32 -
67.33 - public static interface NonMixedImpl {
67.34 - public void initialize(Callback c);
67.35 - public void toBeImplementedBySubclass();
67.36 - }
67.37 -
67.38 - public static final class Callback {
67.39 - Callback(NonMixed nomMixed) {
67.40 - }
67.41 - public final void toBeCalledBySubclass() {
67.42 - /*...*/
67.43 - }
67.44 - }
67.45 - // END: sidemeanings.Mixed.Clean
67.46 -
67.47 -
67.48 -}
67.49 -
67.50 -
68.1 --- a/samples/visitor/abstractclass/build.xml Sat Jun 14 10:32:31 2008 +0200
68.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
68.3 @@ -1,94 +0,0 @@
68.4 -<?xml version="1.0" encoding="UTF-8"?>
68.5 -<project name="Build Script" default="test" basedir=".">
68.6 - <target name="clean">
68.7 - <delete dir="build"/>
68.8 - </target>
68.9 -
68.10 - <target name="compile" depends="build"/>
68.11 - <target name="build" depends="-libraries">
68.12 - <antcall target="-build-one">
68.13 - <param name="version" value="api1.0"/>
68.14 - </antcall>
68.15 - <antcall target="-build-one">
68.16 - <param name="version" value="api2.0"/>
68.17 - </antcall>
68.18 -
68.19 - <antcall target="-build-one">
68.20 - <param name="version" value="test"/>
68.21 - <param name="cp" value="build/api1.0/classes:${junit.jar}"/>
68.22 - </antcall>
68.23 -
68.24 - <antcall target="-build-one">
68.25 - <param name="version" value="test"/>
68.26 - <param name="out" value="will-not-compile"/>
68.27 - <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
68.28 - </antcall>
68.29 -
68.30 - <antcall target="-build-one">
68.31 - <param name="version" value="test2.0"/>
68.32 - <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
68.33 - </antcall>
68.34 - </target>
68.35 -
68.36 - <target name="test" depends="build">
68.37 - <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
68.38 - <antcall target="-run-one">
68.39 - <param name="version" value="api1.0"/>
68.40 - </antcall>
68.41 - <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
68.42 - <antcall target="-run-one">
68.43 - <param name="version" value="api2.0"/>
68.44 - </antcall>
68.45 - <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
68.46 - <antcall target="-run-one">
68.47 - <param name="test" value="test2.0"/>
68.48 - <param name="extra.cp" value="build/test/classes"/>
68.49 - <param name="version" value="api2.0"/>
68.50 - </antcall>
68.51 - </target>
68.52 -
68.53 - <!-- support methods -->
68.54 -
68.55 - <target name="-libraries">
68.56 - <ant dir="../../libs/"/>
68.57 -
68.58 - <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
68.59 - </target>
68.60 -
68.61 - <target name="-run-one">
68.62 - <fail message="You need to specify API version number" unless="version"/>
68.63 - <property name="test" value="test"/>
68.64 - <mkdir dir="build/${test}results${version}"/>
68.65 - <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
68.66 - <batchtest todir="build/${test}results${version}">
68.67 - <fileset dir="build/${test}/classes">
68.68 - <filename name="**/*Test.class"/>
68.69 - </fileset>
68.70 - </batchtest>
68.71 - <classpath>
68.72 - <path location="build/${version}/classes"/>
68.73 - <path location="build/${test}/classes"/>
68.74 - <path location="${junit.jar}"/>
68.75 - <path path="${extra.cp}"/>
68.76 - </classpath>
68.77 - <formatter type="brief" usefile="false"/>
68.78 - <formatter type="xml"/>
68.79 - </junit>
68.80 - </target>
68.81 -
68.82 - <target name="-build-one">
68.83 - <fail message="You need to specify version number" unless="version"/>
68.84 -
68.85 - <property name="cp" value=""/>
68.86 - <property name="out" value="${version}"/>
68.87 - <property name="failonerror" value="true"/>
68.88 - <mkdir dir="build/${out}/classes"/>
68.89 - <javac
68.90 - srcdir="src-${version}"
68.91 - destdir="build/${out}/classes"
68.92 - source="1.5" target="1.5"
68.93 - classpath="${cp}"
68.94 - failonerror="${failonerror}"
68.95 - />
68.96 - </target>
68.97 -</project>
69.1 --- a/samples/visitor/abstractclass/nbproject/project.xml Sat Jun 14 10:32:31 2008 +0200
69.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
69.3 @@ -1,107 +0,0 @@
69.4 -<?xml version="1.0" encoding="UTF-8"?>
69.5 -<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
69.6 - <type>org.netbeans.modules.ant.freeform</type>
69.7 - <configuration>
69.8 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
69.9 - <name>abstractclass</name>
69.10 - </general-data>
69.11 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
69.12 - <!-- Do not use Project Properties customizer when editing this file manually. -->
69.13 - <name>abstractclass</name>
69.14 - <properties/>
69.15 - <folders>
69.16 - <source-folder>
69.17 - <label>src-api1.0</label>
69.18 - <type>java</type>
69.19 - <location>src-api1.0</location>
69.20 - <encoding>UTF-8</encoding>
69.21 - </source-folder>
69.22 - <source-folder>
69.23 - <label>src-api2.0</label>
69.24 - <type>java</type>
69.25 - <location>src-api2.0</location>
69.26 - <encoding>UTF-8</encoding>
69.27 - </source-folder>
69.28 - <source-folder>
69.29 - <label>test</label>
69.30 - <type>java</type>
69.31 - <location>src-test</location>
69.32 - <encoding>UTF-8</encoding>
69.33 - </source-folder>
69.34 - <source-folder>
69.35 - <label>test-2.0</label>
69.36 - <type>java</type>
69.37 - <location>src-test2.0</location>
69.38 - <encoding>UTF-8</encoding>
69.39 - </source-folder>
69.40 - </folders>
69.41 - <ide-actions>
69.42 - <action name="build">
69.43 - <target>build</target>
69.44 - </action>
69.45 - <action name="clean">
69.46 - <target>clean</target>
69.47 - </action>
69.48 - <action name="test">
69.49 - <target>test</target>
69.50 - </action>
69.51 - <action name="run">
69.52 - <target>test</target>
69.53 - </action>
69.54 - <action name="rebuild">
69.55 - <target>clean</target>
69.56 - <target>build</target>
69.57 - </action>
69.58 - </ide-actions>
69.59 - <view>
69.60 - <items>
69.61 - <source-folder style="packages">
69.62 - <label>API Version 1.0</label>
69.63 - <location>src-api1.0</location>
69.64 - </source-folder>
69.65 - <source-folder style="packages">
69.66 - <label>API Version 2.0</label>
69.67 - <location>src-api2.0</location>
69.68 - </source-folder>
69.69 - <source-folder style="packages">
69.70 - <label>Usage of the API</label>
69.71 - <location>src-test</location>
69.72 - </source-folder>
69.73 - <source-folder style="packages">
69.74 - <label>Usage of new structures with old visitor</label>
69.75 - <location>src-test2.0</location>
69.76 - </source-folder>
69.77 - <source-file>
69.78 - <location>build.xml</location>
69.79 - </source-file>
69.80 - </items>
69.81 - <context-menu>
69.82 - <ide-action name="build"/>
69.83 - <ide-action name="rebuild"/>
69.84 - <ide-action name="clean"/>
69.85 - <ide-action name="test"/>
69.86 - </context-menu>
69.87 - </view>
69.88 - </general-data>
69.89 - <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
69.90 - <compilation-unit>
69.91 - <package-root>src-api1.0</package-root>
69.92 - <source-level>1.5</source-level>
69.93 - </compilation-unit>
69.94 - <compilation-unit>
69.95 - <package-root>src-api2.0</package-root>
69.96 - <source-level>1.5</source-level>
69.97 - </compilation-unit>
69.98 - <compilation-unit>
69.99 - <package-root>src-test</package-root>
69.100 - <classpath mode="compile">src-api1.0:../../libs/dist/junit-4.4.jar</classpath>
69.101 - <source-level>1.5</source-level>
69.102 - </compilation-unit>
69.103 - <compilation-unit>
69.104 - <package-root>src-test2.0</package-root>
69.105 - <classpath mode="compile">src-api2.0:src-test:../../libs/dist/junit-4.4.jar</classpath>
69.106 - <source-level>1.5</source-level>
69.107 - </compilation-unit>
69.108 - </java-data>
69.109 - </configuration>
69.110 -</project>
70.1 --- a/samples/visitor/abstractclass/src-api1.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
70.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
70.3 @@ -1,34 +0,0 @@
70.4 -package org.apidesign.visitor;
70.5 -
70.6 -public final class Language {
70.7 - private Language() { }
70.8 -
70.9 - public static abstract class Expression {
70.10 - public abstract void visit(Visitor v);
70.11 - }
70.12 - public static final class Plus extends Expression {
70.13 - private final Expression first;
70.14 - private final Expression second;
70.15 -
70.16 - public Plus(Expression first, Expression second) {
70.17 - this.first = first;
70.18 - this.second = second;
70.19 - }
70.20 - public Expression getFirst() { return first; }
70.21 - public Expression getSecond() { return second; }
70.22 - @Override
70.23 - public void visit(Visitor v) { v.visitPlus(this); }
70.24 - }
70.25 - public static final class Number extends Expression {
70.26 - private final int value;
70.27 - public Number(int value) { this.value = value; }
70.28 - public int getValue() { return value; }
70.29 - @Override
70.30 - public void visit(Visitor v) { v.visitNumber(this); }
70.31 - }
70.32 -
70.33 - public static abstract class Visitor {
70.34 - public abstract void visitPlus(Plus s);
70.35 - public abstract void visitNumber(Number n);
70.36 - }
70.37 -}
71.1 --- a/samples/visitor/abstractclass/src-api2.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
71.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
71.3 @@ -1,58 +0,0 @@
71.4 -package org.apidesign.visitor;
71.5 -
71.6 -public final class Language {
71.7 - private Language() { }
71.8 -
71.9 - public static abstract class Expression {
71.10 - public abstract void visit(Visitor v);
71.11 - }
71.12 - public static final class Plus extends Expression {
71.13 - private final Expression first;
71.14 - private final Expression second;
71.15 -
71.16 - public Plus(Expression first, Expression second) {
71.17 - this.first = first;
71.18 - this.second = second;
71.19 - }
71.20 - public Expression getFirst() { return first; }
71.21 - public Expression getSecond() { return second; }
71.22 - @Override
71.23 - public void visit(Visitor v) { v.visitPlus(this); }
71.24 - }
71.25 - public static final class Number extends Expression {
71.26 - private final int value;
71.27 - public Number(int value) { this.value = value; }
71.28 - public int getValue() { return value; }
71.29 - @Override
71.30 - public void visit(Visitor v) { v.visitNumber(this); }
71.31 - }
71.32 - // BEGIN: visitor.abstractclass.v2
71.33 - /** @since 2.0 */
71.34 - public static final class Minus extends Expression {
71.35 - private final Expression first;
71.36 - private final Expression second;
71.37 -
71.38 - public Minus(Expression first, Expression second) {
71.39 - this.first = first;
71.40 - this.second = second;
71.41 - }
71.42 - public Expression getFirst() { return first; }
71.43 - public Expression getSecond() { return second; }
71.44 - public void visit(Visitor v) {
71.45 - v.visitMinus(this);
71.46 - }
71.47 - }
71.48 -
71.49 - public static abstract class Visitor {
71.50 - public abstract void visitPlus(Plus s);
71.51 - public abstract void visitNumber(Number n);
71.52 - /** @since 2.0 */
71.53 - public void visitMinus(Minus s) {
71.54 - throw new IllegalStateException(
71.55 - "Old visitor used on new exceptions"
71.56 - );
71.57 - }
71.58 - }
71.59 - // END: visitor.abstractclass.v2
71.60 -
71.61 -}
72.1 --- a/samples/visitor/abstractclass/src-test/org/apidesign/test/visitor/LanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,48 +0,0 @@
72.4 -package org.apidesign.test.visitor;
72.5 -
72.6 -import static junit.framework.Assert.*;
72.7 -import org.apidesign.visitor.Language.Expression;
72.8 -import org.apidesign.visitor.Language.Number;
72.9 -import org.apidesign.visitor.Language.Plus;
72.10 -import org.apidesign.visitor.Language.Visitor;
72.11 -import org.junit.Test;
72.12 -
72.13 -public class LanguageCheckTest {
72.14 -
72.15 - // BEGIN: visitor.language.check.exception
72.16 - private static class Valid1_0Language extends Visitor/*version1.0*/ {
72.17 - public void visitPlus(Plus s) {
72.18 - s.getFirst().visit(this);
72.19 - s.getSecond().visit(this);
72.20 - }
72.21 - public void visitNumber(Number n) {
72.22 - }
72.23 - }
72.24 -
72.25 - public static boolean isValid1_0Language(Expression expression) {
72.26 - Valid1_0Language valid = new Valid1_0Language();
72.27 - try {
72.28 - expression.visit(valid);
72.29 - return true; // yes, no unknown elements
72.30 - } catch (IllegalStateException ex) {
72.31 - return false; // no, probably from visitMinus of Visitor/*2.0*/
72.32 - }
72.33 - }
72.34 - // END: visitor.language.check.exception
72.35 -
72.36 - @Test public void printOnePlusOne() {
72.37 - Number one = new Number(1);
72.38 - Expression expression = new Plus(one, one);
72.39 -
72.40 - assertTrue("Valid language", isValid1_0Language(expression));
72.41 - }
72.42 -
72.43 - @Test public void printOnePlusTwoPlusThree() {
72.44 - Number one = new Number(1);
72.45 - Number two = new Number(2);
72.46 - Number three = new Number(3);
72.47 - Expression plus = new Plus(one, new Plus(two, three));
72.48 -
72.49 - assertTrue("Valid language", isValid1_0Language(plus));
72.50 - }
72.51 -}
73.1 --- a/samples/visitor/abstractclass/src-test/org/apidesign/test/visitor/PrintTest.java Sat Jun 14 10:32:31 2008 +0200
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,46 +0,0 @@
73.4 -package org.apidesign.test.visitor;
73.5 -
73.6 -import static junit.framework.Assert.*;
73.7 -import org.apidesign.visitor.Language.Expression;
73.8 -import org.apidesign.visitor.Language.Number;
73.9 -import org.apidesign.visitor.Language.Plus;
73.10 -import org.apidesign.visitor.Language.Visitor;
73.11 -import org.junit.Test;
73.12 -
73.13 -public class PrintTest {
73.14 - public static class PrintVisitor extends Visitor {
73.15 - StringBuffer sb = new StringBuffer();
73.16 -
73.17 - public void visitPlus(Plus s) {
73.18 - s.getFirst().visit(this);
73.19 - sb.append(" + ");
73.20 - s.getSecond().visit(this);
73.21 - }
73.22 -
73.23 - public void visitNumber(Number n) {
73.24 - sb.append (n.getValue());
73.25 - }
73.26 - }
73.27 -
73.28 - @Test public void printOnePlusOne() {
73.29 - Number one = new Number(1);
73.30 - Expression plus = new Plus(one, one);
73.31 -
73.32 - PrintVisitor print = new PrintVisitor();
73.33 - plus.visit(print);
73.34 -
73.35 - assertEquals("1 + 1", print.sb.toString());
73.36 - }
73.37 -
73.38 - @Test public void printOnePlusTwoPlusThree() {
73.39 - Number one = new Number(1);
73.40 - Number two = new Number(2);
73.41 - Number three = new Number(3);
73.42 - Expression plus = new Plus(one, new Plus(two, three));
73.43 -
73.44 - PrintVisitor print = new PrintVisitor();
73.45 - plus.visit(print);
73.46 -
73.47 - assertEquals("1 + 2 + 3", print.sb.toString());
73.48 - }
73.49 -}
74.1 --- a/samples/visitor/abstractclass/src-test2.0/org/apidesign/test/visitor/InvalidLanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,17 +0,0 @@
74.4 -package org.apidesign.test.visitor;
74.5 -
74.6 -import static junit.framework.Assert.*;
74.7 -import org.apidesign.visitor.Language.Expression;
74.8 -import org.apidesign.visitor.Language.Minus;
74.9 -import org.apidesign.visitor.Language.Number;
74.10 -import org.junit.Test;
74.11 -
74.12 -public class InvalidLanguageCheckTest {
74.13 - @Test public void printOneMinusTwo() {
74.14 - Number one = new Number(1);
74.15 - Number two = new Number(2);
74.16 - Expression minus = new Minus(one, two);
74.17 -
74.18 - assertFalse("Recognized as invalid 1.0 version of the language", LanguageCheckTest.isValid1_0Language(minus));
74.19 - }
74.20 -}
75.1 --- a/samples/visitor/abstractclass/src-test2.0/org/apidesign/test/visitor/PrintOfMinusStructureTest.java Sat Jun 14 10:32:31 2008 +0200
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,23 +0,0 @@
75.4 -package org.apidesign.test.visitor;
75.5 -
75.6 -import org.apidesign.test.visitor.PrintTest.PrintVisitor;
75.7 -import static junit.framework.Assert.*;
75.8 -import org.apidesign.visitor.Language.Expression;
75.9 -import org.apidesign.visitor.Language.Minus;
75.10 -import org.apidesign.visitor.Language.Number;
75.11 -import org.apidesign.visitor.Language.Plus;
75.12 -import org.apidesign.visitor.Language.Visitor;
75.13 -import org.junit.Test;
75.14 -
75.15 -public class PrintOfMinusStructureTest {
75.16 - @Test public void printOneMinusTwo() {
75.17 - Number one = new Number(1);
75.18 - Number two = new Number(2);
75.19 - Expression minus = new Minus(one, two);
75.20 -
75.21 - PrintVisitor print = new PrintVisitor();
75.22 - minus.visit(print); // fails with IllegalStateException
75.23 -
75.24 - assertEquals("1 - 2", print.sb.toString());
75.25 - }
75.26 -}
76.1 --- a/samples/visitor/notevolutionready/build.xml Sat Jun 14 10:32:31 2008 +0200
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,96 +0,0 @@
76.4 -<?xml version="1.0" encoding="UTF-8"?>
76.5 -<project name="Build Script" default="test" basedir=".">
76.6 - <target name="clean">
76.7 - <delete dir="build"/>
76.8 - </target>
76.9 -
76.10 - <target name="compile" depends="build"/>
76.11 - <target name="build" depends="-libraries">
76.12 - <antcall target="-build-one">
76.13 - <param name="version" value="api1.0"/>
76.14 - </antcall>
76.15 - <antcall target="-build-one">
76.16 - <param name="version" value="api2.0"/>
76.17 - </antcall>
76.18 -
76.19 - <antcall target="-build-one">
76.20 - <param name="version" value="test"/>
76.21 - <param name="cp" value="build/api1.0/classes:${junit.jar}"/>
76.22 - </antcall>
76.23 -
76.24 - <echo level="info" message="Next compilation will fails, as adding methods into interface is not binary compatible"/>
76.25 - <antcall target="-build-one">
76.26 - <param name="version" value="test"/>
76.27 - <param name="out" value="will-not-compile"/>
76.28 - <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
76.29 - <param name="failonerror" value="false"/>
76.30 - </antcall>
76.31 -
76.32 - <antcall target="-build-one">
76.33 - <param name="version" value="test2.0"/>
76.34 - <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
76.35 - </antcall>
76.36 - </target>
76.37 -
76.38 - <target name="test" depends="build">
76.39 - <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
76.40 - <antcall target="-run-one">
76.41 - <param name="version" value="api1.0"/>
76.42 - </antcall>
76.43 - <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
76.44 - <antcall target="-run-one">
76.45 - <param name="version" value="api2.0"/>
76.46 - </antcall>
76.47 - <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
76.48 - <antcall target="-run-one">
76.49 - <param name="test" value="test2.0"/>
76.50 - <param name="extra.cp" value="build/test/classes"/>
76.51 - <param name="version" value="api2.0"/>
76.52 - </antcall>
76.53 - </target>
76.54 -
76.55 - <!-- support methods -->
76.56 -
76.57 - <target name="-libraries">
76.58 - <ant dir="../../libs/"/>
76.59 -
76.60 - <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
76.61 - </target>
76.62 -
76.63 - <target name="-run-one">
76.64 - <fail message="You need to specify API version number" unless="version"/>
76.65 - <property name="test" value="test"/>
76.66 - <mkdir dir="build/${test}results${version}"/>
76.67 - <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
76.68 - <batchtest todir="build/${test}results${version}">
76.69 - <fileset dir="build/${test}/classes">
76.70 - <filename name="**/*Test.class"/>
76.71 - </fileset>
76.72 - </batchtest>
76.73 - <classpath>
76.74 - <path location="build/${version}/classes"/>
76.75 - <path location="build/${test}/classes"/>
76.76 - <path location="${junit.jar}"/>
76.77 - <path path="${extra.cp}"/>
76.78 - </classpath>
76.79 - <formatter type="brief" usefile="false"/>
76.80 - <formatter type="xml"/>
76.81 - </junit>
76.82 - </target>
76.83 -
76.84 - <target name="-build-one">
76.85 - <fail message="You need to specify version number" unless="version"/>
76.86 -
76.87 - <property name="cp" value=""/>
76.88 - <property name="out" value="${version}"/>
76.89 - <property name="failonerror" value="true"/>
76.90 - <mkdir dir="build/${out}/classes"/>
76.91 - <javac
76.92 - srcdir="src-${version}"
76.93 - destdir="build/${out}/classes"
76.94 - source="1.5" target="1.5"
76.95 - classpath="${cp}"
76.96 - failonerror="${failonerror}"
76.97 - />
76.98 - </target>
76.99 -</project>
77.1 --- a/samples/visitor/notevolutionready/nbproject/project.xml Sat Jun 14 10:32:31 2008 +0200
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,107 +0,0 @@
77.4 -<?xml version="1.0" encoding="UTF-8"?>
77.5 -<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
77.6 - <type>org.netbeans.modules.ant.freeform</type>
77.7 - <configuration>
77.8 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
77.9 - <name>notevolutionready</name>
77.10 - </general-data>
77.11 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
77.12 - <!-- Do not use Project Properties customizer when editing this file manually. -->
77.13 - <name>notevolutionready</name>
77.14 - <properties/>
77.15 - <folders>
77.16 - <source-folder>
77.17 - <label>src-api1.0</label>
77.18 - <type>java</type>
77.19 - <location>src-api1.0</location>
77.20 - <encoding>UTF-8</encoding>
77.21 - </source-folder>
77.22 - <source-folder>
77.23 - <label>src-api2.0</label>
77.24 - <type>java</type>
77.25 - <location>src-api2.0</location>
77.26 - <encoding>UTF-8</encoding>
77.27 - </source-folder>
77.28 - <source-folder>
77.29 - <label>test</label>
77.30 - <type>java</type>
77.31 - <location>src-test</location>
77.32 - <encoding>UTF-8</encoding>
77.33 - </source-folder>
77.34 - <source-folder>
77.35 - <label>test-2.0</label>
77.36 - <type>java</type>
77.37 - <location>src-test2.0</location>
77.38 - <encoding>UTF-8</encoding>
77.39 - </source-folder>
77.40 - </folders>
77.41 - <ide-actions>
77.42 - <action name="build">
77.43 - <target>build</target>
77.44 - </action>
77.45 - <action name="clean">
77.46 - <target>clean</target>
77.47 - </action>
77.48 - <action name="test">
77.49 - <target>test</target>
77.50 - </action>
77.51 - <action name="run">
77.52 - <target>test</target>
77.53 - </action>
77.54 - <action name="rebuild">
77.55 - <target>clean</target>
77.56 - <target>build</target>
77.57 - </action>
77.58 - </ide-actions>
77.59 - <view>
77.60 - <items>
77.61 - <source-folder style="packages">
77.62 - <label>API Version 1.0</label>
77.63 - <location>src-api1.0</location>
77.64 - </source-folder>
77.65 - <source-folder style="packages">
77.66 - <label>API Version 2.0</label>
77.67 - <location>src-api2.0</location>
77.68 - </source-folder>
77.69 - <source-folder style="packages">
77.70 - <label>Usage of the API</label>
77.71 - <location>src-test</location>
77.72 - </source-folder>
77.73 - <source-folder style="packages">
77.74 - <label>Usage of new structures with old visitor</label>
77.75 - <location>src-test2.0</location>
77.76 - </source-folder>
77.77 - <source-file>
77.78 - <location>build.xml</location>
77.79 - </source-file>
77.80 - </items>
77.81 - <context-menu>
77.82 - <ide-action name="build"/>
77.83 - <ide-action name="rebuild"/>
77.84 - <ide-action name="clean"/>
77.85 - <ide-action name="test"/>
77.86 - </context-menu>
77.87 - </view>
77.88 - </general-data>
77.89 - <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
77.90 - <compilation-unit>
77.91 - <package-root>src-api1.0</package-root>
77.92 - <source-level>1.5</source-level>
77.93 - </compilation-unit>
77.94 - <compilation-unit>
77.95 - <package-root>src-api2.0</package-root>
77.96 - <source-level>1.5</source-level>
77.97 - </compilation-unit>
77.98 - <compilation-unit>
77.99 - <package-root>src-test</package-root>
77.100 - <classpath mode="compile">src-api1.0:../../libs/dist/junit-4.4.jar</classpath>
77.101 - <source-level>1.5</source-level>
77.102 - </compilation-unit>
77.103 - <compilation-unit>
77.104 - <package-root>src-test2.0</package-root>
77.105 - <classpath mode="compile">src-api2.0:src-test:../../libs/dist/junit-4.4.jar</classpath>
77.106 - <source-level>1.5</source-level>
77.107 - </compilation-unit>
77.108 - </java-data>
77.109 - </configuration>
77.110 -</project>
78.1 --- a/samples/visitor/notevolutionready/src-api1.0/org/apidesign/visitor/notevolutionready/Language.java Sat Jun 14 10:32:31 2008 +0200
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,36 +0,0 @@
78.4 -package org.apidesign.visitor.notevolutionready;
78.5 -
78.6 -public final class Language {
78.7 - private Language() { }
78.8 -
78.9 - // BEGIN: visitor.notevolutionready.v1
78.10 - public static abstract class Expression {
78.11 - public abstract void visit(Visitor v);
78.12 - }
78.13 - public static final class Plus extends Expression {
78.14 - private final Expression first;
78.15 - private final Expression second;
78.16 -
78.17 - public Plus(Expression first, Expression second) {
78.18 - this.first = first;
78.19 - this.second = second;
78.20 - }
78.21 - public Expression getFirst() { return first; }
78.22 - public Expression getSecond() { return second; }
78.23 - @Override
78.24 - public void visit(Visitor v) { v.visitPlus(this); }
78.25 - }
78.26 - public static final class Number extends Expression {
78.27 - private final int value;
78.28 - public Number(int value) { this.value = value; }
78.29 - public int getValue() { return value; }
78.30 - @Override
78.31 - public void visit(Visitor v) { v.visitNumber(this); }
78.32 - }
78.33 -
78.34 - public interface Visitor {
78.35 - public void visitPlus(Plus s);
78.36 - public void visitNumber(Number n);
78.37 - }
78.38 - // END: visitor.notevolutionready.v1
78.39 -}
79.1 --- a/samples/visitor/notevolutionready/src-api2.0/org/apidesign/visitor/notevolutionready/Language.java Sat Jun 14 10:32:31 2008 +0200
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,53 +0,0 @@
79.4 -package org.apidesign.visitor.notevolutionready;
79.5 -
79.6 -public final class Language {
79.7 - private Language() { }
79.8 -
79.9 - public static abstract class Expression {
79.10 - public abstract void visit(Visitor v);
79.11 - }
79.12 - public static final class Plus extends Expression {
79.13 - private final Expression first;
79.14 - private final Expression second;
79.15 -
79.16 - public Plus(Expression first, Expression second) {
79.17 - this.first = first;
79.18 - this.second = second;
79.19 - }
79.20 - public Expression getFirst() { return first; }
79.21 - public Expression getSecond() { return second; }
79.22 - @Override
79.23 - public void visit(Visitor v) { v.visitPlus(this); }
79.24 - }
79.25 - public static final class Number extends Expression {
79.26 - private final int value;
79.27 - public Number(int value) { this.value = value; }
79.28 - public int getValue() { return value; }
79.29 - @Override
79.30 - public void visit(Visitor v) { v.visitNumber(this); }
79.31 - }
79.32 - // BEGIN: visitor.notevolutionready.v2
79.33 - /** @since 2.0 */
79.34 - public static final class Minus extends Expression {
79.35 - private final Expression first;
79.36 - private final Expression second;
79.37 -
79.38 - public Minus(Expression first, Expression second) {
79.39 - this.first = first;
79.40 - this.second = second;
79.41 - }
79.42 - public Expression getFirst() { return first; }
79.43 - public Expression getSecond() { return second; }
79.44 - public void visit(Visitor v) {
79.45 - /* now what? add new method to an interface!? */
79.46 - v.visitMinus(this);
79.47 - }
79.48 - }
79.49 - // END: visitor.notevolutionready.v2
79.50 -
79.51 - public interface Visitor {
79.52 - public void visitPlus(Plus s);
79.53 - public void visitMinus(Minus s);
79.54 - public void visitNumber(Number n);
79.55 - }
79.56 -}
80.1 --- a/samples/visitor/notevolutionready/src-test/org/apidesign/test/visitor/PrintTest.java Sat Jun 14 10:32:31 2008 +0200
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,49 +0,0 @@
80.4 -package org.apidesign.test.visitor;
80.5 -
80.6 -import static junit.framework.Assert.*;
80.7 -import org.apidesign.visitor.notevolutionready.Language.Expression;
80.8 -import org.apidesign.visitor.notevolutionready.Language.Number;
80.9 -import org.apidesign.visitor.notevolutionready.Language.Plus;
80.10 -import org.apidesign.visitor.notevolutionready.Language.Visitor;
80.11 -import org.junit.Test;
80.12 -
80.13 -public class PrintTest {
80.14 -
80.15 - // BEGIN: visitor.notevolutionready.print
80.16 - public static class PrintVisitor implements Visitor {
80.17 - StringBuffer sb = new StringBuffer();
80.18 -
80.19 - public void visitPlus(Plus s) {
80.20 - s.getFirst().visit(this);
80.21 - sb.append(" + ");
80.22 - s.getSecond().visit(this);
80.23 - }
80.24 -
80.25 - public void visitNumber(Number n) {
80.26 - sb.append (n.getValue());
80.27 - }
80.28 - }
80.29 -
80.30 - @Test public void printOnePlusOne() {
80.31 - Number one = new Number(1);
80.32 - Expression plus = new Plus(one, one);
80.33 -
80.34 - PrintVisitor print = new PrintVisitor();
80.35 - plus.visit(print);
80.36 -
80.37 - assertEquals("1 + 1", print.sb.toString());
80.38 - }
80.39 - // END: visitor.notevolutionready.print
80.40 -
80.41 - @Test public void printOnePlusTwoPlusThree() {
80.42 - Number one = new Number(1);
80.43 - Number two = new Number(2);
80.44 - Number three = new Number(3);
80.45 - Expression plus = new Plus(one, new Plus(two, three));
80.46 -
80.47 - PrintVisitor print = new PrintVisitor();
80.48 - plus.visit(print);
80.49 -
80.50 - assertEquals("1 + 2 + 3", print.sb.toString());
80.51 - }
80.52 -}
81.1 --- a/samples/visitor/notevolutionready/src-test2.0/org/apidesign/test/visitor/PrintOfMinusStructureTest.java Sat Jun 14 10:32:31 2008 +0200
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,25 +0,0 @@
81.4 -package org.apidesign.test.visitor;
81.5 -
81.6 -import org.apidesign.test.visitor.PrintTest.PrintVisitor;
81.7 -import static junit.framework.Assert.*;
81.8 -import org.apidesign.visitor.notevolutionready.Language.Expression;
81.9 -import org.apidesign.visitor.notevolutionready.Language.Minus;
81.10 -import org.apidesign.visitor.notevolutionready.Language.Number;
81.11 -import org.apidesign.visitor.notevolutionready.Language.Plus;
81.12 -import org.apidesign.visitor.notevolutionready.Language.Visitor;
81.13 -import org.junit.Test;
81.14 -
81.15 -public class PrintOfMinusStructureTest {
81.16 - @Test public void printOneMinusTwo() {
81.17 - // BEGIN: visitor.notevolutionready.oldwithnew
81.18 - Number one = new Number(1);
81.19 - Number two = new Number(2);
81.20 - Expression plus = new Minus(one, two);
81.21 -
81.22 - PrintVisitor print = new PrintVisitor();
81.23 - plus.visit(print); // fails with AbstractMethodError
81.24 -
81.25 - assertEquals("1 - 2", print.sb.toString());
81.26 - // END: visitor.notevolutionready.oldwithnew
81.27 - }
81.28 -}
82.1 --- a/samples/visitor/traversal/build.xml Sat Jun 14 10:32:31 2008 +0200
82.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
82.3 @@ -1,94 +0,0 @@
82.4 -<?xml version="1.0" encoding="UTF-8"?>
82.5 -<project name="Build Script" default="test" basedir=".">
82.6 - <target name="clean">
82.7 - <delete dir="build"/>
82.8 - </target>
82.9 -
82.10 - <target name="compile" depends="build"/>
82.11 - <target name="build" depends="-libraries">
82.12 - <antcall target="-build-one">
82.13 - <param name="version" value="api1.0"/>
82.14 - </antcall>
82.15 - <antcall target="-build-one">
82.16 - <param name="version" value="api2.0"/>
82.17 - </antcall>
82.18 -
82.19 - <antcall target="-build-one">
82.20 - <param name="version" value="test"/>
82.21 - <param name="cp" value="build/api1.0/classes:${junit.jar}"/>
82.22 - </antcall>
82.23 -
82.24 - <antcall target="-build-one">
82.25 - <param name="version" value="test"/>
82.26 - <param name="out" value="will-not-compile"/>
82.27 - <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
82.28 - </antcall>
82.29 -
82.30 - <antcall target="-build-one">
82.31 - <param name="version" value="test2.0"/>
82.32 - <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
82.33 - </antcall>
82.34 - </target>
82.35 -
82.36 - <target name="test" depends="build">
82.37 - <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
82.38 - <antcall target="-run-one">
82.39 - <param name="version" value="api1.0"/>
82.40 - </antcall>
82.41 - <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
82.42 - <antcall target="-run-one">
82.43 - <param name="version" value="api2.0"/>
82.44 - </antcall>
82.45 - <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
82.46 - <antcall target="-run-one">
82.47 - <param name="test" value="test2.0"/>
82.48 - <param name="extra.cp" value="build/test/classes"/>
82.49 - <param name="version" value="api2.0"/>
82.50 - </antcall>
82.51 - </target>
82.52 -
82.53 - <!-- support methods -->
82.54 -
82.55 - <target name="-libraries">
82.56 - <ant dir="../../libs/"/>
82.57 -
82.58 - <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
82.59 - </target>
82.60 -
82.61 - <target name="-run-one">
82.62 - <fail message="You need to specify API version number" unless="version"/>
82.63 - <property name="test" value="test"/>
82.64 - <mkdir dir="build/${test}results${version}"/>
82.65 - <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
82.66 - <batchtest todir="build/${test}results${version}">
82.67 - <fileset dir="build/${test}/classes">
82.68 - <filename name="**/*Test.class"/>
82.69 - </fileset>
82.70 - </batchtest>
82.71 - <classpath>
82.72 - <path location="build/${version}/classes"/>
82.73 - <path location="build/${test}/classes"/>
82.74 - <path location="${junit.jar}"/>
82.75 - <path path="${extra.cp}"/>
82.76 - </classpath>
82.77 - <formatter type="brief" usefile="false"/>
82.78 - <formatter type="xml"/>
82.79 - </junit>
82.80 - </target>
82.81 -
82.82 - <target name="-build-one">
82.83 - <fail message="You need to specify version number" unless="version"/>
82.84 -
82.85 - <property name="cp" value=""/>
82.86 - <property name="out" value="${version}"/>
82.87 - <property name="failonerror" value="true"/>
82.88 - <mkdir dir="build/${out}/classes"/>
82.89 - <javac
82.90 - srcdir="src-${version}"
82.91 - destdir="build/${out}/classes"
82.92 - source="1.5" target="1.5"
82.93 - classpath="${cp}"
82.94 - failonerror="${failonerror}"
82.95 - />
82.96 - </target>
82.97 -</project>
83.1 --- a/samples/visitor/traversal/nbproject/project.xml Sat Jun 14 10:32:31 2008 +0200
83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
83.3 @@ -1,107 +0,0 @@
83.4 -<?xml version="1.0" encoding="UTF-8"?>
83.5 -<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
83.6 - <type>org.netbeans.modules.ant.freeform</type>
83.7 - <configuration>
83.8 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
83.9 - <name>traversal</name>
83.10 - </general-data>
83.11 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
83.12 - <!-- Do not use Project Properties customizer when editing this file manually. -->
83.13 - <name>traversal</name>
83.14 - <properties/>
83.15 - <folders>
83.16 - <source-folder>
83.17 - <label>src-api1.0</label>
83.18 - <type>java</type>
83.19 - <location>src-api1.0</location>
83.20 - <encoding>UTF-8</encoding>
83.21 - </source-folder>
83.22 - <source-folder>
83.23 - <label>src-api2.0</label>
83.24 - <type>java</type>
83.25 - <location>src-api2.0</location>
83.26 - <encoding>UTF-8</encoding>
83.27 - </source-folder>
83.28 - <source-folder>
83.29 - <label>test</label>
83.30 - <type>java</type>
83.31 - <location>src-test</location>
83.32 - <encoding>UTF-8</encoding>
83.33 - </source-folder>
83.34 - <source-folder>
83.35 - <label>test-2.0</label>
83.36 - <type>java</type>
83.37 - <location>src-test2.0</location>
83.38 - <encoding>UTF-8</encoding>
83.39 - </source-folder>
83.40 - </folders>
83.41 - <ide-actions>
83.42 - <action name="build">
83.43 - <target>build</target>
83.44 - </action>
83.45 - <action name="clean">
83.46 - <target>clean</target>
83.47 - </action>
83.48 - <action name="test">
83.49 - <target>test</target>
83.50 - </action>
83.51 - <action name="run">
83.52 - <target>test</target>
83.53 - </action>
83.54 - <action name="rebuild">
83.55 - <target>clean</target>
83.56 - <target>build</target>
83.57 - </action>
83.58 - </ide-actions>
83.59 - <view>
83.60 - <items>
83.61 - <source-folder style="packages">
83.62 - <label>API Version 1.0</label>
83.63 - <location>src-api1.0</location>
83.64 - </source-folder>
83.65 - <source-folder style="packages">
83.66 - <label>API Version 2.0</label>
83.67 - <location>src-api2.0</location>
83.68 - </source-folder>
83.69 - <source-folder style="packages">
83.70 - <label>Usage of the API</label>
83.71 - <location>src-test</location>
83.72 - </source-folder>
83.73 - <source-folder style="packages">
83.74 - <label>Usage of new structures with old visitor</label>
83.75 - <location>src-test2.0</location>
83.76 - </source-folder>
83.77 - <source-file>
83.78 - <location>build.xml</location>
83.79 - </source-file>
83.80 - </items>
83.81 - <context-menu>
83.82 - <ide-action name="build"/>
83.83 - <ide-action name="rebuild"/>
83.84 - <ide-action name="clean"/>
83.85 - <ide-action name="test"/>
83.86 - </context-menu>
83.87 - </view>
83.88 - </general-data>
83.89 - <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
83.90 - <compilation-unit>
83.91 - <package-root>src-api1.0</package-root>
83.92 - <source-level>1.5</source-level>
83.93 - </compilation-unit>
83.94 - <compilation-unit>
83.95 - <package-root>src-api2.0</package-root>
83.96 - <source-level>1.5</source-level>
83.97 - </compilation-unit>
83.98 - <compilation-unit>
83.99 - <package-root>src-test</package-root>
83.100 - <classpath mode="compile">src-api1.0:../../libs/dist/junit-4.4.jar</classpath>
83.101 - <source-level>1.5</source-level>
83.102 - </compilation-unit>
83.103 - <compilation-unit>
83.104 - <package-root>src-test2.0</package-root>
83.105 - <classpath mode="compile">src-api2.0:src-test:../../libs/dist/junit-4.4.jar</classpath>
83.106 - <source-level>1.5</source-level>
83.107 - </compilation-unit>
83.108 - </java-data>
83.109 - </configuration>
83.110 -</project>
84.1 --- a/samples/visitor/traversal/src-api1.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
84.3 @@ -1,46 +0,0 @@
84.4 -package org.apidesign.visitor;
84.5 -
84.6 -public final class Language {
84.7 - private Language() { }
84.8 -
84.9 - public static abstract class Expression {
84.10 - public abstract void visit(Visitor v);
84.11 - }
84.12 - public static final class Plus extends Expression {
84.13 - private final Expression first;
84.14 - private final Expression second;
84.15 -
84.16 - public Plus(Expression first, Expression second) {
84.17 - this.first = first;
84.18 - this.second = second;
84.19 - }
84.20 - public Expression getFirst() { return first; }
84.21 - public Expression getSecond() { return second; }
84.22 - @Override
84.23 - public void visit(Visitor v) { v.visitPlus(this); }
84.24 - }
84.25 - public static final class Number extends Expression {
84.26 - private final int value;
84.27 - public Number(int value) { this.value = value; }
84.28 - public int getValue() { return value; }
84.29 - @Override
84.30 - public void visit(Visitor v) { v.visitNumber(this); }
84.31 - }
84.32 -
84.33 - // BEGIN: visitor.traversal.v1
84.34 - public static abstract class Visitor/*1.0*/ {
84.35 - public boolean visitUnknown(Expression e) {
84.36 - throw new IllegalStateException("Unknown element faced: " + e);
84.37 - }
84.38 - public void visitPlus(Plus s) {
84.39 - if (visitUnknown(s)) {
84.40 - s.getFirst().visit(this);
84.41 - s.getSecond().visit(this);
84.42 - }
84.43 - }
84.44 - public void visitNumber(Number n) {
84.45 - visitUnknown(n);
84.46 - }
84.47 - }
84.48 - // END: visitor.traversal.v1
84.49 -}
85.1 --- a/samples/visitor/traversal/src-api2.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
85.3 @@ -1,67 +0,0 @@
85.4 -package org.apidesign.visitor;
85.5 -
85.6 -public final class Language {
85.7 - private Language() { }
85.8 -
85.9 - public static abstract class Expression {
85.10 - public abstract void visit(Visitor v);
85.11 - }
85.12 - public static final class Plus extends Expression {
85.13 - private final Expression first;
85.14 - private final Expression second;
85.15 -
85.16 - public Plus(Expression first, Expression second) {
85.17 - this.first = first;
85.18 - this.second = second;
85.19 - }
85.20 - public Expression getFirst() { return first; }
85.21 - public Expression getSecond() { return second; }
85.22 - @Override
85.23 - public void visit(Visitor v) { v.visitPlus(this); }
85.24 - }
85.25 - public static final class Number extends Expression {
85.26 - private final int value;
85.27 - public Number(int value) { this.value = value; }
85.28 - public int getValue() { return value; }
85.29 - @Override
85.30 - public void visit(Visitor v) { v.visitNumber(this); }
85.31 - }
85.32 - /** @since 2.0 */
85.33 - public static final class Minus extends Expression {
85.34 - private final Expression first;
85.35 - private final Expression second;
85.36 -
85.37 - public Minus(Expression first, Expression second) {
85.38 - this.first = first;
85.39 - this.second = second;
85.40 - }
85.41 - public Expression getFirst() { return first; }
85.42 - public Expression getSecond() { return second; }
85.43 - public void visit(Visitor v) {
85.44 - v.visitMinus(this);
85.45 - }
85.46 - }
85.47 -
85.48 - // BEGIN: visitor.traversal.v2
85.49 - public static abstract class Visitor/*2.0*/ {
85.50 - public boolean visitUnknown(Expression e) {
85.51 - throw new IllegalStateException("Unknown element faced: " + e);
85.52 - }
85.53 - public void visitPlus(Plus s) {
85.54 - if (visitUnknown(s)) {
85.55 - s.getFirst().visit(this);
85.56 - s.getSecond().visit(this);
85.57 - }
85.58 - }
85.59 - public void visitMinus(Minus s) {
85.60 - if (visitUnknown(s)) {
85.61 - s.getFirst().visit(this);
85.62 - s.getSecond().visit(this);
85.63 - }
85.64 - }
85.65 - public void visitNumber(Number n) {
85.66 - visitUnknown(n);
85.67 - }
85.68 - }
85.69 - // END: visitor.traversal.v2
85.70 -}
86.1 --- a/samples/visitor/traversal/src-test/org/apidesign/test/visitor/CountNumbersTest.java Sat Jun 14 10:32:31 2008 +0200
86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
86.3 @@ -1,51 +0,0 @@
86.4 -package org.apidesign.test.visitor;
86.5 -
86.6 -import static junit.framework.Assert.*;
86.7 -import org.apidesign.visitor.Language.Expression;
86.8 -import org.apidesign.visitor.Language.Number;
86.9 -import org.apidesign.visitor.Language.Plus;
86.10 -import org.apidesign.visitor.Language.Visitor;
86.11 -import org.junit.Test;
86.12 -
86.13 -public class CountNumbersTest {
86.14 -
86.15 - // BEGIN: visitor.count.numbers.traversal
86.16 - private static class CountNumbers extends Visitor/*version1.0*/ {
86.17 - int cnt;
86.18 -
86.19 - @Override
86.20 - public boolean visitUnknown(Expression exp) {
86.21 - return true;
86.22 - }
86.23 - public void visitPlus(Plus s) {
86.24 - s.getFirst().visit(this);
86.25 - s.getSecond().visit(this);
86.26 - }
86.27 - public void visitNumber(Number n) {
86.28 - cnt++;
86.29 - }
86.30 - }
86.31 -
86.32 - public static int countNumbers(Expression expression) {
86.33 - CountNumbers counter = new CountNumbers();
86.34 - expression.visit(counter);
86.35 - return counter.cnt;
86.36 - }
86.37 - // END: visitor.count.numbers.traversal
86.38 -
86.39 - @Test public void printOnePlusOne() {
86.40 - Number one = new Number(1);
86.41 - Expression expression = new Plus(one, one);
86.42 -
86.43 - assertEquals("Two 1's", 2, countNumbers(expression));
86.44 - }
86.45 -
86.46 - @Test public void printOnePlusTwoPlusThree() {
86.47 - Number one = new Number(1);
86.48 - Number two = new Number(2);
86.49 - Number three = new Number(3);
86.50 - Expression plus = new Plus(one, new Plus(two, three));
86.51 -
86.52 - assertEquals("Three", 3, countNumbers(plus));
86.53 - }
86.54 -}
87.1 --- a/samples/visitor/traversal/src-test/org/apidesign/test/visitor/LanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
87.3 @@ -1,49 +0,0 @@
87.4 -package org.apidesign.test.visitor;
87.5 -
87.6 -import static junit.framework.Assert.*;
87.7 -import org.apidesign.visitor.Language.Expression;
87.8 -import org.apidesign.visitor.Language.Number;
87.9 -import org.apidesign.visitor.Language.Plus;
87.10 -import org.apidesign.visitor.Language.Visitor;
87.11 -import org.junit.Test;
87.12 -
87.13 -public class LanguageCheckTest {
87.14 -
87.15 - private static class Valid1_0Language extends Visitor/*version1.0*/ {
87.16 - boolean invalid;
87.17 -
87.18 - @Override
87.19 - public boolean visitUnknown(Expression exp) {
87.20 - invalid = true;
87.21 - return false;
87.22 - }
87.23 - public void visitPlus(Plus s) {
87.24 - s.getFirst().visit(this);
87.25 - s.getSecond().visit(this);
87.26 - }
87.27 - public void visitNumber(Number n) {
87.28 - }
87.29 - }
87.30 -
87.31 - public static boolean isValid1_0Language(Expression expression) {
87.32 - Valid1_0Language valid = new Valid1_0Language();
87.33 - expression.visit(valid);
87.34 - return !valid.invalid;
87.35 - }
87.36 -
87.37 - @Test public void printOnePlusOne() {
87.38 - Number one = new Number(1);
87.39 - Expression expression = new Plus(one, one);
87.40 -
87.41 - assertTrue("Valid language", isValid1_0Language(expression));
87.42 - }
87.43 -
87.44 - @Test public void printOnePlusTwoPlusThree() {
87.45 - Number one = new Number(1);
87.46 - Number two = new Number(2);
87.47 - Number three = new Number(3);
87.48 - Expression plus = new Plus(one, new Plus(two, three));
87.49 -
87.50 - assertTrue("Valid language", isValid1_0Language(plus));
87.51 - }
87.52 -}
88.1 --- a/samples/visitor/traversal/src-test/org/apidesign/test/visitor/PrintTest.java Sat Jun 14 10:32:31 2008 +0200
88.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
88.3 @@ -1,51 +0,0 @@
88.4 -package org.apidesign.test.visitor;
88.5 -
88.6 -import static junit.framework.Assert.*;
88.7 -import org.apidesign.visitor.Language.Expression;
88.8 -import org.apidesign.visitor.Language.Number;
88.9 -import org.apidesign.visitor.Language.Plus;
88.10 -import org.apidesign.visitor.Language.Visitor;
88.11 -import org.junit.Test;
88.12 -
88.13 -public class PrintTest {
88.14 - public static class PrintVisitor extends Visitor {
88.15 - StringBuffer sb = new StringBuffer();
88.16 -
88.17 - @Override
88.18 - public boolean visitUnknown(Expression exp) {
88.19 - return true;
88.20 - }
88.21 -
88.22 - public void visitPlus(Plus s) {
88.23 - s.getFirst().visit(this);
88.24 - sb.append(" + ");
88.25 - s.getSecond().visit(this);
88.26 - }
88.27 -
88.28 - public void visitNumber(Number n) {
88.29 - sb.append (n.getValue());
88.30 - }
88.31 - }
88.32 -
88.33 - @Test public void printOnePlusOne() {
88.34 - Number one = new Number(1);
88.35 - Expression plus = new Plus(one, one);
88.36 -
88.37 - PrintVisitor print = new PrintVisitor();
88.38 - plus.visit(print);
88.39 -
88.40 - assertEquals("1 + 1", print.sb.toString());
88.41 - }
88.42 -
88.43 - @Test public void printOnePlusTwoPlusThree() {
88.44 - Number one = new Number(1);
88.45 - Number two = new Number(2);
88.46 - Number three = new Number(3);
88.47 - Expression plus = new Plus(one, new Plus(two, three));
88.48 -
88.49 - PrintVisitor print = new PrintVisitor();
88.50 - plus.visit(print);
88.51 -
88.52 - assertEquals("1 + 2 + 3", print.sb.toString());
88.53 - }
88.54 -}
89.1 --- a/samples/visitor/traversal/src-test2.0/org/apidesign/test/visitor/InvalidCountNumbersTest.java Sat Jun 14 10:32:31 2008 +0200
89.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
89.3 @@ -1,23 +0,0 @@
89.4 -package org.apidesign.test.visitor;
89.5 -
89.6 -import static junit.framework.Assert.*;
89.7 -import org.apidesign.visitor.Language.Expression;
89.8 -import org.apidesign.visitor.Language.Minus;
89.9 -import org.apidesign.visitor.Language.Number;
89.10 -import org.apidesign.visitor.Language.Plus;
89.11 -import org.junit.Test;
89.12 -
89.13 -public class InvalidCountNumbersTest {
89.14 - @Test public void printOneMinusTwo() {
89.15 - Number one = new Number(1);
89.16 - Number three = new Number(3);
89.17 - Number four = new Number(4);
89.18 - Expression minus = new Plus(one, new Minus(three, four));
89.19 -
89.20 - assertEquals(
89.21 - "Should have three numbers, but visitor does not " +
89.22 - "know how to go through minus",
89.23 - 3, CountNumbersTest.countNumbers(minus)
89.24 - );
89.25 - }
89.26 -}
90.1 --- a/samples/visitor/traversal/src-test2.0/org/apidesign/test/visitor/InvalidLanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,17 +0,0 @@
90.4 -package org.apidesign.test.visitor;
90.5 -
90.6 -import static junit.framework.Assert.*;
90.7 -import org.apidesign.visitor.Language.Expression;
90.8 -import org.apidesign.visitor.Language.Minus;
90.9 -import org.apidesign.visitor.Language.Number;
90.10 -import org.junit.Test;
90.11 -
90.12 -public class InvalidLanguageCheckTest {
90.13 - @Test public void printOneMinusTwo() {
90.14 - Number one = new Number(1);
90.15 - Number two = new Number(2);
90.16 - Expression minus = new Minus(one, two);
90.17 -
90.18 - assertFalse("Recognized as invalid 1.0 version of the language", LanguageCheckTest.isValid1_0Language(minus));
90.19 - }
90.20 -}
91.1 --- a/samples/visitor/traversal/src-test2.0/org/apidesign/test/visitor/PrintOfMinusStructureTest.java Sat Jun 14 10:32:31 2008 +0200
91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
91.3 @@ -1,23 +0,0 @@
91.4 -package org.apidesign.test.visitor;
91.5 -
91.6 -import org.apidesign.test.visitor.PrintTest.PrintVisitor;
91.7 -import static junit.framework.Assert.*;
91.8 -import org.apidesign.visitor.Language.Expression;
91.9 -import org.apidesign.visitor.Language.Minus;
91.10 -import org.apidesign.visitor.Language.Number;
91.11 -import org.apidesign.visitor.Language.Plus;
91.12 -import org.apidesign.visitor.Language.Visitor;
91.13 -import org.junit.Test;
91.14 -
91.15 -public class PrintOfMinusStructureTest {
91.16 - @Test public void printOneMinusTwo() {
91.17 - Number one = new Number(1);
91.18 - Number two = new Number(2);
91.19 - Expression minus = new Minus(one, two);
91.20 -
91.21 - PrintVisitor print = new PrintVisitor();
91.22 - minus.visit(print); // fails with IllegalStateException
91.23 -
91.24 - assertEquals("1 - 2", print.sb.toString());
91.25 - }
91.26 -}
92.1 --- a/samples/visitor/visitunknown/build.xml Sat Jun 14 10:32:31 2008 +0200
92.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
92.3 @@ -1,94 +0,0 @@
92.4 -<?xml version="1.0" encoding="UTF-8"?>
92.5 -<project name="Build Script" default="test" basedir=".">
92.6 - <target name="clean">
92.7 - <delete dir="build"/>
92.8 - </target>
92.9 -
92.10 - <target name="compile" depends="build"/>
92.11 - <target name="build" depends="-libraries">
92.12 - <antcall target="-build-one">
92.13 - <param name="version" value="api1.0"/>
92.14 - </antcall>
92.15 - <antcall target="-build-one">
92.16 - <param name="version" value="api2.0"/>
92.17 - </antcall>
92.18 -
92.19 - <antcall target="-build-one">
92.20 - <param name="version" value="test"/>
92.21 - <param name="cp" value="build/api1.0/classes:${junit.jar}"/>
92.22 - </antcall>
92.23 -
92.24 - <antcall target="-build-one">
92.25 - <param name="version" value="test"/>
92.26 - <param name="out" value="will-not-compile"/>
92.27 - <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
92.28 - </antcall>
92.29 -
92.30 - <antcall target="-build-one">
92.31 - <param name="version" value="test2.0"/>
92.32 - <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
92.33 - </antcall>
92.34 - </target>
92.35 -
92.36 - <target name="test" depends="build">
92.37 - <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
92.38 - <antcall target="-run-one">
92.39 - <param name="version" value="api1.0"/>
92.40 - </antcall>
92.41 - <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
92.42 - <antcall target="-run-one">
92.43 - <param name="version" value="api2.0"/>
92.44 - </antcall>
92.45 - <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
92.46 - <antcall target="-run-one">
92.47 - <param name="test" value="test2.0"/>
92.48 - <param name="extra.cp" value="build/test/classes"/>
92.49 - <param name="version" value="api2.0"/>
92.50 - </antcall>
92.51 - </target>
92.52 -
92.53 - <!-- support methods -->
92.54 -
92.55 - <target name="-libraries">
92.56 - <ant dir="../../libs/"/>
92.57 -
92.58 - <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
92.59 - </target>
92.60 -
92.61 - <target name="-run-one">
92.62 - <fail message="You need to specify API version number" unless="version"/>
92.63 - <property name="test" value="test"/>
92.64 - <mkdir dir="build/${test}results${version}"/>
92.65 - <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
92.66 - <batchtest todir="build/${test}results${version}">
92.67 - <fileset dir="build/${test}/classes">
92.68 - <filename name="**/*Test.class"/>
92.69 - </fileset>
92.70 - </batchtest>
92.71 - <classpath>
92.72 - <path location="build/${version}/classes"/>
92.73 - <path location="build/${test}/classes"/>
92.74 - <path location="${junit.jar}"/>
92.75 - <path path="${extra.cp}"/>
92.76 - </classpath>
92.77 - <formatter type="brief" usefile="false"/>
92.78 - <formatter type="xml"/>
92.79 - </junit>
92.80 - </target>
92.81 -
92.82 - <target name="-build-one">
92.83 - <fail message="You need to specify version number" unless="version"/>
92.84 -
92.85 - <property name="cp" value=""/>
92.86 - <property name="out" value="${version}"/>
92.87 - <property name="failonerror" value="true"/>
92.88 - <mkdir dir="build/${out}/classes"/>
92.89 - <javac
92.90 - srcdir="src-${version}"
92.91 - destdir="build/${out}/classes"
92.92 - source="1.5" target="1.5"
92.93 - classpath="${cp}"
92.94 - failonerror="${failonerror}"
92.95 - />
92.96 - </target>
92.97 -</project>
93.1 --- a/samples/visitor/visitunknown/nbproject/project.xml Sat Jun 14 10:32:31 2008 +0200
93.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
93.3 @@ -1,107 +0,0 @@
93.4 -<?xml version="1.0" encoding="UTF-8"?>
93.5 -<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
93.6 - <type>org.netbeans.modules.ant.freeform</type>
93.7 - <configuration>
93.8 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
93.9 - <name>visitunknown</name>
93.10 - </general-data>
93.11 - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
93.12 - <!-- Do not use Project Properties customizer when editing this file manually. -->
93.13 - <name>visitunknown</name>
93.14 - <properties/>
93.15 - <folders>
93.16 - <source-folder>
93.17 - <label>src-api1.0</label>
93.18 - <type>java</type>
93.19 - <location>src-api1.0</location>
93.20 - <encoding>UTF-8</encoding>
93.21 - </source-folder>
93.22 - <source-folder>
93.23 - <label>src-api2.0</label>
93.24 - <type>java</type>
93.25 - <location>src-api2.0</location>
93.26 - <encoding>UTF-8</encoding>
93.27 - </source-folder>
93.28 - <source-folder>
93.29 - <label>test</label>
93.30 - <type>java</type>
93.31 - <location>src-test</location>
93.32 - <encoding>UTF-8</encoding>
93.33 - </source-folder>
93.34 - <source-folder>
93.35 - <label>test-2.0</label>
93.36 - <type>java</type>
93.37 - <location>src-test2.0</location>
93.38 - <encoding>UTF-8</encoding>
93.39 - </source-folder>
93.40 - </folders>
93.41 - <ide-actions>
93.42 - <action name="build">
93.43 - <target>build</target>
93.44 - </action>
93.45 - <action name="clean">
93.46 - <target>clean</target>
93.47 - </action>
93.48 - <action name="test">
93.49 - <target>test</target>
93.50 - </action>
93.51 - <action name="run">
93.52 - <target>test</target>
93.53 - </action>
93.54 - <action name="rebuild">
93.55 - <target>clean</target>
93.56 - <target>build</target>
93.57 - </action>
93.58 - </ide-actions>
93.59 - <view>
93.60 - <items>
93.61 - <source-folder style="packages">
93.62 - <label>API Version 1.0</label>
93.63 - <location>src-api1.0</location>
93.64 - </source-folder>
93.65 - <source-folder style="packages">
93.66 - <label>API Version 2.0</label>
93.67 - <location>src-api2.0</location>
93.68 - </source-folder>
93.69 - <source-folder style="packages">
93.70 - <label>Usage of the API</label>
93.71 - <location>src-test</location>
93.72 - </source-folder>
93.73 - <source-folder style="packages">
93.74 - <label>Usage of new structures with old visitor</label>
93.75 - <location>src-test2.0</location>
93.76 - </source-folder>
93.77 - <source-file>
93.78 - <location>build.xml</location>
93.79 - </source-file>
93.80 - </items>
93.81 - <context-menu>
93.82 - <ide-action name="build"/>
93.83 - <ide-action name="rebuild"/>
93.84 - <ide-action name="clean"/>
93.85 - <ide-action name="test"/>
93.86 - </context-menu>
93.87 - </view>
93.88 - </general-data>
93.89 - <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
93.90 - <compilation-unit>
93.91 - <package-root>src-api1.0</package-root>
93.92 - <source-level>1.5</source-level>
93.93 - </compilation-unit>
93.94 - <compilation-unit>
93.95 - <package-root>src-api2.0</package-root>
93.96 - <source-level>1.5</source-level>
93.97 - </compilation-unit>
93.98 - <compilation-unit>
93.99 - <package-root>src-test</package-root>
93.100 - <classpath mode="compile">src-api1.0:../../libs/dist/junit-4.4.jar</classpath>
93.101 - <source-level>1.5</source-level>
93.102 - </compilation-unit>
93.103 - <compilation-unit>
93.104 - <package-root>src-test2.0</package-root>
93.105 - <classpath mode="compile">src-api2.0:src-test:../../libs/dist/junit-4.4.jar</classpath>
93.106 - <source-level>1.5</source-level>
93.107 - </compilation-unit>
93.108 - </java-data>
93.109 - </configuration>
93.110 -</project>
94.1 --- a/samples/visitor/visitunknown/src-api1.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
94.3 @@ -1,39 +0,0 @@
94.4 -package org.apidesign.visitor;
94.5 -
94.6 -public final class Language {
94.7 - private Language() { }
94.8 -
94.9 - public static abstract class Expression {
94.10 - public abstract void visit(Visitor v);
94.11 - }
94.12 - public static final class Plus extends Expression {
94.13 - private final Expression first;
94.14 - private final Expression second;
94.15 -
94.16 - public Plus(Expression first, Expression second) {
94.17 - this.first = first;
94.18 - this.second = second;
94.19 - }
94.20 - public Expression getFirst() { return first; }
94.21 - public Expression getSecond() { return second; }
94.22 - @Override
94.23 - public void visit(Visitor v) { v.visitPlus(this); }
94.24 - }
94.25 - public static final class Number extends Expression {
94.26 - private final int value;
94.27 - public Number(int value) { this.value = value; }
94.28 - public int getValue() { return value; }
94.29 - @Override
94.30 - public void visit(Visitor v) { v.visitNumber(this); }
94.31 - }
94.32 -
94.33 - // BEGIN: visitor.visitunknown.v1
94.34 - public static abstract class Visitor/*1.0*/ {
94.35 - public void visitUnknown(Expression exp) {
94.36 - throw new IllegalStateException("Unknown element faced: " + exp);
94.37 - }
94.38 - public abstract void visitPlus(Plus s);
94.39 - public abstract void visitNumber(Number n);
94.40 - }
94.41 - // END: visitor.visitunknown.v1
94.42 -}
95.1 --- a/samples/visitor/visitunknown/src-api2.0/org/apidesign/visitor/Language.java Sat Jun 14 10:32:31 2008 +0200
95.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
95.3 @@ -1,57 +0,0 @@
95.4 -package org.apidesign.visitor;
95.5 -
95.6 -public final class Language {
95.7 - private Language() { }
95.8 -
95.9 - public static abstract class Expression {
95.10 - public abstract void visit(Visitor v);
95.11 - }
95.12 - public static final class Plus extends Expression {
95.13 - private final Expression first;
95.14 - private final Expression second;
95.15 -
95.16 - public Plus(Expression first, Expression second) {
95.17 - this.first = first;
95.18 - this.second = second;
95.19 - }
95.20 - public Expression getFirst() { return first; }
95.21 - public Expression getSecond() { return second; }
95.22 - @Override
95.23 - public void visit(Visitor v) { v.visitPlus(this); }
95.24 - }
95.25 - public static final class Number extends Expression {
95.26 - private final int value;
95.27 - public Number(int value) { this.value = value; }
95.28 - public int getValue() { return value; }
95.29 - @Override
95.30 - public void visit(Visitor v) { v.visitNumber(this); }
95.31 - }
95.32 - /** @since 2.0 */
95.33 - public static final class Minus extends Expression {
95.34 - private final Expression first;
95.35 - private final Expression second;
95.36 -
95.37 - public Minus(Expression first, Expression second) {
95.38 - this.first = first;
95.39 - this.second = second;
95.40 - }
95.41 - public Expression getFirst() { return first; }
95.42 - public Expression getSecond() { return second; }
95.43 - public void visit(Visitor v) {
95.44 - v.visitMinus(this);
95.45 - }
95.46 - }
95.47 - // BEGIN: visitor.visitunknown.v2
95.48 - public static abstract class Visitor/*2.0*/ {
95.49 - public void visitUnknown(Expression exp) {
95.50 - throw new IllegalStateException("Unknown element faced: " + exp);
95.51 - }
95.52 - public abstract void visitPlus(Plus s);
95.53 - public abstract void visitNumber(Number n);
95.54 - /** @since 2.0 */
95.55 - public void visitMinus(Minus s) {
95.56 - visitUnknown(s);
95.57 - }
95.58 - }
95.59 - // END: visitor.visitunknown.v2
95.60 -}
96.1 --- a/samples/visitor/visitunknown/src-test/org/apidesign/test/visitor/CountNumbersTest.java Sat Jun 14 10:32:31 2008 +0200
96.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
96.3 @@ -1,51 +0,0 @@
96.4 -package org.apidesign.test.visitor;
96.5 -
96.6 -import static junit.framework.Assert.*;
96.7 -import org.apidesign.visitor.Language.Expression;
96.8 -import org.apidesign.visitor.Language.Number;
96.9 -import org.apidesign.visitor.Language.Plus;
96.10 -import org.apidesign.visitor.Language.Visitor;
96.11 -import org.junit.Test;
96.12 -
96.13 -public class CountNumbersTest {
96.14 -
96.15 - // BEGIN: visitor.count.numbers.visitunknown
96.16 - private static class CountNumbers extends Visitor/*version1.0*/ {
96.17 - int cnt;
96.18 -
96.19 - @Override
96.20 - public void visitUnknown(Expression exp) {
96.21 - // not a number
96.22 - }
96.23 - public void visitPlus(Plus s) {
96.24 - s.getFirst().visit(this);
96.25 - s.getSecond().visit(this);
96.26 - }
96.27 - public void visitNumber(Number n) {
96.28 - cnt++;
96.29 - }
96.30 - }
96.31 -
96.32 - public static int countNumbers(Expression expression) {
96.33 - CountNumbers counter = new CountNumbers();
96.34 - expression.visit(counter);
96.35 - return counter.cnt;
96.36 - }
96.37 - // END: visitor.count.numbers.visitunknown
96.38 -
96.39 - @Test public void printOnePlusOne() {
96.40 - Number one = new Number(1);
96.41 - Expression expression = new Plus(one, one);
96.42 -
96.43 - assertEquals("Two 1's", 2, countNumbers(expression));
96.44 - }
96.45 -
96.46 - @Test public void printOnePlusTwoPlusThree() {
96.47 - Number one = new Number(1);
96.48 - Number two = new Number(2);
96.49 - Number three = new Number(3);
96.50 - Expression plus = new Plus(one, new Plus(two, three));
96.51 -
96.52 - assertEquals("Three", 3, countNumbers(plus));
96.53 - }
96.54 -}
97.1 --- a/samples/visitor/visitunknown/src-test/org/apidesign/test/visitor/LanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
97.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
97.3 @@ -1,50 +0,0 @@
97.4 -package org.apidesign.test.visitor;
97.5 -
97.6 -import static junit.framework.Assert.*;
97.7 -import org.apidesign.visitor.Language.Expression;
97.8 -import org.apidesign.visitor.Language.Number;
97.9 -import org.apidesign.visitor.Language.Plus;
97.10 -import org.apidesign.visitor.Language.Visitor;
97.11 -import org.junit.Test;
97.12 -
97.13 -public class LanguageCheckTest {
97.14 -
97.15 - // BEGIN: visitor.language.check.visitunknown
97.16 - private static class Valid1_0Language extends Visitor/*version1.0*/ {
97.17 - boolean invalid;
97.18 -
97.19 - @Override
97.20 - public void visitUnknown(Expression exp) {
97.21 - invalid = true;
97.22 - }
97.23 - public void visitPlus(Plus s) {
97.24 - s.getFirst().visit(this);
97.25 - s.getSecond().visit(this);
97.26 - }
97.27 - public void visitNumber(Number n) {
97.28 - }
97.29 - }
97.30 -
97.31 - public static boolean isValid1_0Language(Expression expression) {
97.32 - Valid1_0Language valid = new Valid1_0Language();
97.33 - expression.visit(valid);
97.34 - return !valid.invalid;
97.35 - }
97.36 - // END: visitor.language.check.visitunknown
97.37 -
97.38 - @Test public void printOnePlusOne() {
97.39 - Number one = new Number(1);
97.40 - Expression expression = new Plus(one, one);
97.41 -
97.42 - assertTrue("Valid language", isValid1_0Language(expression));
97.43 - }
97.44 -
97.45 - @Test public void printOnePlusTwoPlusThree() {
97.46 - Number one = new Number(1);
97.47 - Number two = new Number(2);
97.48 - Number three = new Number(3);
97.49 - Expression plus = new Plus(one, new Plus(two, three));
97.50 -
97.51 - assertTrue("Valid language", isValid1_0Language(plus));
97.52 - }
97.53 -}
98.1 --- a/samples/visitor/visitunknown/src-test/org/apidesign/test/visitor/PrintTest.java Sat Jun 14 10:32:31 2008 +0200
98.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
98.3 @@ -1,51 +0,0 @@
98.4 -package org.apidesign.test.visitor;
98.5 -
98.6 -import static junit.framework.Assert.*;
98.7 -import org.apidesign.visitor.Language.Expression;
98.8 -import org.apidesign.visitor.Language.Number;
98.9 -import org.apidesign.visitor.Language.Plus;
98.10 -import org.apidesign.visitor.Language.Visitor;
98.11 -import org.junit.Test;
98.12 -
98.13 -public class PrintTest {
98.14 - public static class PrintVisitor extends Visitor {
98.15 - StringBuffer sb = new StringBuffer();
98.16 -
98.17 - @Override
98.18 - public void visitUnknown(Expression exp) {
98.19 - sb.append("unknown");
98.20 - }
98.21 -
98.22 - public void visitPlus(Plus s) {
98.23 - s.getFirst().visit(this);
98.24 - sb.append(" + ");
98.25 - s.getSecond().visit(this);
98.26 - }
98.27 -
98.28 - public void visitNumber(Number n) {
98.29 - sb.append (n.getValue());
98.30 - }
98.31 - }
98.32 -
98.33 - @Test public void printOnePlusOne() {
98.34 - Number one = new Number(1);
98.35 - Expression plus = new Plus(one, one);
98.36 -
98.37 - PrintVisitor print = new PrintVisitor();
98.38 - plus.visit(print);
98.39 -
98.40 - assertEquals("1 + 1", print.sb.toString());
98.41 - }
98.42 -
98.43 - @Test public void printOnePlusTwoPlusThree() {
98.44 - Number one = new Number(1);
98.45 - Number two = new Number(2);
98.46 - Number three = new Number(3);
98.47 - Expression plus = new Plus(one, new Plus(two, three));
98.48 -
98.49 - PrintVisitor print = new PrintVisitor();
98.50 - plus.visit(print);
98.51 -
98.52 - assertEquals("1 + 2 + 3", print.sb.toString());
98.53 - }
98.54 -}
99.1 --- a/samples/visitor/visitunknown/src-test2.0/org/apidesign/test/visitor/InvalidCountNumbersTest.java Sat Jun 14 10:32:31 2008 +0200
99.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
99.3 @@ -1,25 +0,0 @@
99.4 -package org.apidesign.test.visitor;
99.5 -
99.6 -import static junit.framework.Assert.*;
99.7 -import org.apidesign.visitor.Language.Expression;
99.8 -import org.apidesign.visitor.Language.Minus;
99.9 -import org.apidesign.visitor.Language.Number;
99.10 -import org.apidesign.visitor.Language.Plus;
99.11 -import org.junit.Test;
99.12 -
99.13 -public class InvalidCountNumbersTest {
99.14 - @Test public void printOneMinusTwo() {
99.15 - // BEGIN: visitor.visitunknown.traversal
99.16 - Number one = new Number(1);
99.17 - Number three = new Number(3);
99.18 - Number four = new Number(4);
99.19 - Expression minus = new Plus(one, new Minus(three, four));
99.20 -
99.21 - assertEquals(
99.22 - "Should have three numbers, but visitor does not " +
99.23 - "know how to go through minus",
99.24 - 3, CountNumbersTest.countNumbers(minus)
99.25 - );
99.26 - // END: visitor.visitunknown.traversal
99.27 - }
99.28 -}
100.1 --- a/samples/visitor/visitunknown/src-test2.0/org/apidesign/test/visitor/InvalidLanguageCheckTest.java Sat Jun 14 10:32:31 2008 +0200
100.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
100.3 @@ -1,17 +0,0 @@
100.4 -package org.apidesign.test.visitor;
100.5 -
100.6 -import static junit.framework.Assert.*;
100.7 -import org.apidesign.visitor.Language.Expression;
100.8 -import org.apidesign.visitor.Language.Minus;
100.9 -import org.apidesign.visitor.Language.Number;
100.10 -import org.junit.Test;
100.11 -
100.12 -public class InvalidLanguageCheckTest {
100.13 - @Test public void printOneMinusTwo() {
100.14 - Number one = new Number(1);
100.15 - Number two = new Number(2);
100.16 - Expression minus = new Minus(one, two);
100.17 -
100.18 - assertFalse("Recognized as invalid 1.0 version of the language", LanguageCheckTest.isValid1_0Language(minus));
100.19 - }
100.20 -}
101.1 --- a/samples/visitor/visitunknown/src-test2.0/org/apidesign/test/visitor/PrintOfMinusStructureTest.java Sat Jun 14 10:32:31 2008 +0200
101.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
101.3 @@ -1,23 +0,0 @@
101.4 -package org.apidesign.test.visitor;
101.5 -
101.6 -import org.apidesign.test.visitor.PrintTest.PrintVisitor;
101.7 -import static junit.framework.Assert.*;
101.8 -import org.apidesign.visitor.Language.Expression;
101.9 -import org.apidesign.visitor.Language.Minus;
101.10 -import org.apidesign.visitor.Language.Number;
101.11 -import org.apidesign.visitor.Language.Plus;
101.12 -import org.apidesign.visitor.Language.Visitor;
101.13 -import org.junit.Test;
101.14 -
101.15 -public class PrintOfMinusStructureTest {
101.16 - @Test public void printOneMinusTwo() {
101.17 - Number one = new Number(1);
101.18 - Number two = new Number(2);
101.19 - Expression minus = new Minus(one, two);
101.20 -
101.21 - PrintVisitor print = new PrintVisitor();
101.22 - minus.visit(print); // fails with IllegalStateException
101.23 -
101.24 - assertEquals("1 - 2", print.sb.toString());
101.25 - }
101.26 -}