1.1 --- a/task2/solution01/build.xml Tue Oct 07 01:18:23 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="currency" default="default" basedir=".">
1.9 - <description>Builds, tests, and runs the project.</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="currency-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/task2/solution01/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,642 +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:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Currency_Convertor_Solution_01-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 depends="-init-debug-args" 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="${debug-transport}">
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.classes}">
2.242 - <include name="${fix.includes}*.class"/>
2.243 - </fileset>
2.244 - </nbjpdareload>
2.245 - </sequential>
2.246 - </macrodef>
2.247 - </target>
2.248 - <target name="-init-debug-args">
2.249 - <property name="version-output" value="java version "${ant.java.version}"/>
2.250 - <condition property="have-jdk-older-than-1.4">
2.251 - <or>
2.252 - <contains string="${version-output}" substring="java version "1.0"/>
2.253 - <contains string="${version-output}" substring="java version "1.1"/>
2.254 - <contains string="${version-output}" substring="java version "1.2"/>
2.255 - <contains string="${version-output}" substring="java version "1.3"/>
2.256 - </or>
2.257 - </condition>
2.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
2.259 - <istrue value="${have-jdk-older-than-1.4}"/>
2.260 - </condition>
2.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
2.262 - <os family="windows"/>
2.263 - </condition>
2.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
2.265 - <isset property="debug.transport"/>
2.266 - </condition>
2.267 - </target>
2.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
2.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
2.270 - <attribute default="${main.class}" name="classname"/>
2.271 - <attribute default="${debug.classpath}" name="classpath"/>
2.272 - <element name="customize" optional="true"/>
2.273 - <sequential>
2.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.275 - <jvmarg line="${debug-args-line}"/>
2.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
2.277 - <jvmarg line="${run.jvmargs}"/>
2.278 - <classpath>
2.279 - <path path="@{classpath}"/>
2.280 - </classpath>
2.281 - <syspropertyset>
2.282 - <propertyref prefix="run-sys-prop."/>
2.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.284 - </syspropertyset>
2.285 - <customize/>
2.286 - </java>
2.287 - </sequential>
2.288 - </macrodef>
2.289 - </target>
2.290 - <target name="-init-macrodef-java">
2.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
2.292 - <attribute default="${main.class}" name="classname"/>
2.293 - <element name="customize" optional="true"/>
2.294 - <sequential>
2.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
2.296 - <jvmarg line="${run.jvmargs}"/>
2.297 - <classpath>
2.298 - <path path="${run.classpath}"/>
2.299 - </classpath>
2.300 - <syspropertyset>
2.301 - <propertyref prefix="run-sys-prop."/>
2.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
2.303 - </syspropertyset>
2.304 - <customize/>
2.305 - </java>
2.306 - </sequential>
2.307 - </macrodef>
2.308 - </target>
2.309 - <target name="-init-presetdef-jar">
2.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
2.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
2.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
2.313 - </jar>
2.314 - </presetdef>
2.315 - </target>
2.316 - <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.317 - <!--
2.318 - ===================
2.319 - COMPILATION SECTION
2.320 - ===================
2.321 - -->
2.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
2.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
2.324 - <target depends="init" name="-check-automatic-build">
2.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
2.326 - </target>
2.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
2.328 - <antcall target="clean"/>
2.329 - </target>
2.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
2.331 - <mkdir dir="${build.classes.dir}"/>
2.332 - </target>
2.333 - <target name="-pre-compile">
2.334 - <!-- Empty placeholder for easier customization. -->
2.335 - <!-- You can override this target in the ../build.xml file. -->
2.336 - </target>
2.337 - <target if="do.depend.true" name="-compile-depend">
2.338 - <j2seproject3:depend/>
2.339 - </target>
2.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
2.341 - <j2seproject3:javac/>
2.342 - <copy todir="${build.classes.dir}">
2.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.344 - </copy>
2.345 - </target>
2.346 - <target name="-post-compile">
2.347 - <!-- Empty placeholder for easier customization. -->
2.348 - <!-- You can override this target in the ../build.xml file. -->
2.349 - </target>
2.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
2.351 - <target name="-pre-compile-single">
2.352 - <!-- Empty placeholder for easier customization. -->
2.353 - <!-- You can override this target in the ../build.xml file. -->
2.354 - </target>
2.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
2.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.357 - <j2seproject3:force-recompile/>
2.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
2.359 - </target>
2.360 - <target name="-post-compile-single">
2.361 - <!-- Empty placeholder for easier customization. -->
2.362 - <!-- You can override this target in the ../build.xml file. -->
2.363 - </target>
2.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
2.365 - <!--
2.366 - ====================
2.367 - JAR BUILDING SECTION
2.368 - ====================
2.369 - -->
2.370 - <target depends="init" name="-pre-pre-jar">
2.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
2.372 - <mkdir dir="${dist.jar.dir}"/>
2.373 - </target>
2.374 - <target name="-pre-jar">
2.375 - <!-- Empty placeholder for easier customization. -->
2.376 - <!-- You can override this target in the ../build.xml file. -->
2.377 - </target>
2.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
2.379 - <j2seproject1:jar/>
2.380 - </target>
2.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
2.382 - <j2seproject1:jar manifest="${manifest.file}"/>
2.383 - </target>
2.384 - <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.385 - <j2seproject1:jar manifest="${manifest.file}">
2.386 - <j2seproject1:manifest>
2.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
2.388 - </j2seproject1:manifest>
2.389 - </j2seproject1:jar>
2.390 - <echo>To run this application from the command line without Ant, try:</echo>
2.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.393 - <pathconvert property="run.classpath.with.dist.jar">
2.394 - <path path="${run.classpath}"/>
2.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
2.396 - </pathconvert>
2.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
2.398 - </target>
2.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
2.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
2.401 - <pathconvert property="run.classpath.without.build.classes.dir">
2.402 - <path path="${run.classpath}"/>
2.403 - <map from="${build.classes.dir.resolved}" to=""/>
2.404 - </pathconvert>
2.405 - <pathconvert pathsep=" " property="jar.classpath">
2.406 - <path path="${run.classpath.without.build.classes.dir}"/>
2.407 - <chainedmapper>
2.408 - <flattenmapper/>
2.409 - <globmapper from="*" to="lib/*"/>
2.410 - </chainedmapper>
2.411 - </pathconvert>
2.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
2.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
2.414 - <fileset dir="${build.classes.dir}"/>
2.415 - <manifest>
2.416 - <attribute name="Main-Class" value="${main.class}"/>
2.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
2.418 - </manifest>
2.419 - </copylibs>
2.420 - <echo>To run this application from the command line without Ant, try:</echo>
2.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
2.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
2.423 - </target>
2.424 - <target name="-post-jar">
2.425 - <!-- Empty placeholder for easier customization. -->
2.426 - <!-- You can override this target in the ../build.xml file. -->
2.427 - </target>
2.428 - <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.429 - <!--
2.430 - =================
2.431 - EXECUTION SECTION
2.432 - =================
2.433 - -->
2.434 - <target depends="init,compile" description="Run a main class." name="run">
2.435 - <j2seproject1:java>
2.436 - <customize>
2.437 - <arg line="${application.args}"/>
2.438 - </customize>
2.439 - </j2seproject1:java>
2.440 - </target>
2.441 - <target name="-do-not-recompile">
2.442 - <property name="javac.includes.binary" value=""/>
2.443 - </target>
2.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
2.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
2.446 - <j2seproject1:java classname="${run.class}"/>
2.447 - </target>
2.448 - <!--
2.449 - =================
2.450 - DEBUGGING SECTION
2.451 - =================
2.452 - -->
2.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
2.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
2.455 - </target>
2.456 - <target depends="init,compile" name="-debug-start-debuggee">
2.457 - <j2seproject3:debug>
2.458 - <customize>
2.459 - <arg line="${application.args}"/>
2.460 - </customize>
2.461 - </j2seproject3:debug>
2.462 - </target>
2.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
2.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
2.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
2.466 - </target>
2.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
2.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
2.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
2.470 - <j2seproject3:debug classname="${debug.class}"/>
2.471 - </target>
2.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
2.473 - <target depends="init" name="-pre-debug-fix">
2.474 - <fail unless="fix.includes">Must set fix.includes</fail>
2.475 - <property name="javac.includes" value="${fix.includes}.java"/>
2.476 - </target>
2.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
2.478 - <j2seproject1:nbjpdareload/>
2.479 - </target>
2.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
2.481 - <!--
2.482 - ===============
2.483 - JAVADOC SECTION
2.484 - ===============
2.485 - -->
2.486 - <target depends="init" name="-javadoc-build">
2.487 - <mkdir dir="${dist.javadoc.dir}"/>
2.488 - <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.489 - <classpath>
2.490 - <path path="${javac.classpath}"/>
2.491 - </classpath>
2.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
2.493 - <filename name="**/*.java"/>
2.494 - </fileset>
2.495 - </javadoc>
2.496 - </target>
2.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
2.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
2.499 - </target>
2.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
2.501 - <!--
2.502 - =========================
2.503 - JUNIT COMPILATION SECTION
2.504 - =========================
2.505 - -->
2.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
2.507 - <mkdir dir="${build.test.classes.dir}"/>
2.508 - </target>
2.509 - <target name="-pre-compile-test">
2.510 - <!-- Empty placeholder for easier customization. -->
2.511 - <!-- You can override this target in the ../build.xml file. -->
2.512 - </target>
2.513 - <target if="do.depend.true" name="-compile-test-depend">
2.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.515 - </target>
2.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
2.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
2.518 - <copy todir="${build.test.classes.dir}">
2.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.520 - </copy>
2.521 - </target>
2.522 - <target name="-post-compile-test">
2.523 - <!-- Empty placeholder for easier customization. -->
2.524 - <!-- You can override this target in the ../build.xml file. -->
2.525 - </target>
2.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
2.527 - <target name="-pre-compile-test-single">
2.528 - <!-- Empty placeholder for easier customization. -->
2.529 - <!-- You can override this target in the ../build.xml file. -->
2.530 - </target>
2.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
2.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
2.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
2.534 - <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.535 - <copy todir="${build.test.classes.dir}">
2.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
2.537 - </copy>
2.538 - </target>
2.539 - <target name="-post-compile-test-single">
2.540 - <!-- Empty placeholder for easier customization. -->
2.541 - <!-- You can override this target in the ../build.xml file. -->
2.542 - </target>
2.543 - <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.544 - <!--
2.545 - =======================
2.546 - JUNIT EXECUTION SECTION
2.547 - =======================
2.548 - -->
2.549 - <target depends="init" if="have.tests" name="-pre-test-run">
2.550 - <mkdir dir="${build.test.results.dir}"/>
2.551 - </target>
2.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
2.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
2.554 - </target>
2.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
2.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.557 - </target>
2.558 - <target depends="init" if="have.tests" name="test-report"/>
2.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
2.560 - <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.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
2.562 - <mkdir dir="${build.test.results.dir}"/>
2.563 - </target>
2.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
2.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
2.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
2.567 - </target>
2.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
2.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
2.570 - </target>
2.571 - <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.572 - <!--
2.573 - =======================
2.574 - JUNIT DEBUGGING SECTION
2.575 - =======================
2.576 - -->
2.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
2.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
2.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
2.580 - <delete file="${test.report.file}"/>
2.581 - <mkdir dir="${build.test.results.dir}"/>
2.582 - <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.583 - <customize>
2.584 - <syspropertyset>
2.585 - <propertyref prefix="test-sys-prop."/>
2.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
2.587 - </syspropertyset>
2.588 - <arg value="${test.class}"/>
2.589 - <arg value="showoutput=true"/>
2.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
2.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
2.592 - </customize>
2.593 - </j2seproject3:debug>
2.594 - </target>
2.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
2.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
2.597 - </target>
2.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
2.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
2.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
2.601 - </target>
2.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
2.603 - <!--
2.604 - =========================
2.605 - APPLET EXECUTION SECTION
2.606 - =========================
2.607 - -->
2.608 - <target depends="init,compile-single" name="run-applet">
2.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
2.611 - <customize>
2.612 - <arg value="${applet.url}"/>
2.613 - </customize>
2.614 - </j2seproject1:java>
2.615 - </target>
2.616 - <!--
2.617 - =========================
2.618 - APPLET DEBUGGING SECTION
2.619 - =========================
2.620 - -->
2.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
2.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
2.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
2.624 - <customize>
2.625 - <arg value="${applet.url}"/>
2.626 - </customize>
2.627 - </j2seproject3:debug>
2.628 - </target>
2.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
2.630 - <!--
2.631 - ===============
2.632 - CLEANUP SECTION
2.633 - ===============
2.634 - -->
2.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
2.636 - <target depends="init" name="-do-clean">
2.637 - <delete dir="${build.dir}"/>
2.638 - <delete dir="${dist.dir}"/>
2.639 - </target>
2.640 - <target name="-post-clean">
2.641 - <!-- Empty placeholder for easier customization. -->
2.642 - <!-- You can override this target in the ../build.xml file. -->
2.643 - </target>
2.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
2.645 -</project>
3.1 --- a/task2/solution01/nbproject/genfiles.properties Tue Oct 07 01:18:23 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=2ab820eb
3.5 -build.xml.script.CRC32=58a52595
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=3cae0313
3.10 -nbproject/build-impl.xml.script.CRC32=3c8caa17
3.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
4.1 --- a/task2/solution01/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,68 +0,0 @@
4.4 -application.title=currency
4.5 -application.vendor=apidesign.org
4.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
4.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
4.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
4.9 -build.classes.dir=${build.dir}/classes
4.10 -build.classes.excludes=**/*.java,**/*.form
4.11 -# This directory is removed when the project is cleaned:
4.12 -build.dir=build
4.13 -build.generated.dir=${build.dir}/generated
4.14 -# Only compile against the classpath explicitly listed here:
4.15 -build.sysclasspath=ignore
4.16 -build.test.classes.dir=${build.dir}/test/classes
4.17 -build.test.results.dir=${build.dir}/test/results
4.18 -debug.classpath=\
4.19 - ${run.classpath}
4.20 -debug.test.classpath=\
4.21 - ${run.test.classpath}
4.22 -# This directory is removed when the project is cleaned:
4.23 -dist.dir=dist
4.24 -dist.jar=${dist.dir}/currency.jar
4.25 -dist.javadoc.dir=${dist.dir}/javadoc
4.26 -excludes=
4.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
4.28 -file.reference.src-apifest08=..
4.29 -includes=**
4.30 -jar.compress=false
4.31 -javac.classpath=
4.32 -# Space-separated list of extra javac options
4.33 -javac.compilerargs=
4.34 -javac.deprecation=false
4.35 -javac.source=1.5
4.36 -javac.target=1.5
4.37 -javac.test.classpath=\
4.38 - ${javac.classpath}:\
4.39 - ${build.classes.dir}:\
4.40 - ${file.reference.junit-4.4.jar}
4.41 -javadoc.additionalparam=
4.42 -javadoc.author=false
4.43 -javadoc.encoding=
4.44 -javadoc.noindex=false
4.45 -javadoc.nonavbar=false
4.46 -javadoc.notree=false
4.47 -javadoc.private=false
4.48 -javadoc.splitindex=true
4.49 -javadoc.use=true
4.50 -javadoc.version=false
4.51 -javadoc.windowtitle=
4.52 -jnlp.codebase.type=local
4.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
4.54 -jnlp.descriptor=application
4.55 -jnlp.enabled=false
4.56 -jnlp.offline-allowed=false
4.57 -jnlp.signed=false
4.58 -meta.inf.dir=${src.dir}/META-INF
4.59 -platform.active=default_platform
4.60 -run.classpath=\
4.61 - ${javac.classpath}:\
4.62 - ${build.classes.dir}
4.63 -# Space-separated list of JVM arguments used when running the project
4.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
4.65 -# or test-sys-prop.name=value to set system properties for unit tests):
4.66 -run.jvmargs=
4.67 -run.test.classpath=\
4.68 - ${javac.test.classpath}:\
4.69 - ${build.test.classes.dir}
4.70 -src.dir=src
4.71 -test.src.dir=test
5.1 --- a/task2/solution01/nbproject/project.xml Tue Oct 07 01:18:23 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>Currency Convertor Solution 01</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/task2/solution01/src/org/apidesign/apifest08/currency/AbstractConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,12 +0,0 @@
6.4 -package org.apidesign.apifest08.currency;
6.5 -
6.6 -/**
6.7 - * Abstract class for future possible purposes
6.8 - * @author Ladislav Vitasek
6.9 - */
6.10 -abstract class AbstractConvertorFactory implements CurrencyConvertorFactory{
6.11 -
6.12 - AbstractConvertorFactory() {
6.13 - }
6.14 -
6.15 -}
7.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/AbstractCurrencyConvertor.java Tue Oct 07 01:18:23 2008 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,64 +0,0 @@
7.4 -package org.apidesign.apifest08.currency;
7.5 -
7.6 -import java.util.Currency;
7.7 -
7.8 -/**
7.9 - * Abstract convertor implementation.
7.10 - * This class provide necessary stuff for creating any CurrencyConvertor
7.11 - * Convert value can be get by different way. Conversion should be made in its subclass.
7.12 - * @author Ladislav Vitasek
7.13 - */
7.14 -abstract class AbstractCurrencyConvertor implements Convertor {
7.15 - protected final ConversionRatioProvider conversionRatioProvider;
7.16 - protected final Currency currency1;
7.17 - protected final Currency currency2;
7.18 -
7.19 - public AbstractCurrencyConvertor(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider) {
7.20 - this.currency1 = currency1;
7.21 - this.currency2 = currency2;
7.22 - this.conversionRatioProvider = conversionRatioProvider;
7.23 - }
7.24 -
7.25 -
7.26 - public Currency getCurrency1() {
7.27 - return currency1;
7.28 - }
7.29 -
7.30 -
7.31 - public Currency getCurrency2() {
7.32 - return currency2;
7.33 - }
7.34 -
7.35 -// /**
7.36 -// * Conversion value can be get by Different way. Let's decide subclass where to get actual value
7.37 -// * @return current value of conversion constant
7.38 -// */
7.39 -// protected abstract BigDecimal getConversionValue();
7.40 -
7.41 - @SuppressWarnings({"RedundantIfStatement"})
7.42 - public boolean equals(Object o) {
7.43 - if (this == o) return true;
7.44 - if (o == null || getClass() != o.getClass()) return false;
7.45 -
7.46 - AbstractCurrencyConvertor that = (AbstractCurrencyConvertor) o;
7.47 -
7.48 - if (!conversionRatioProvider.equals(that.conversionRatioProvider)) return false;
7.49 - if (!currency1.equals(that.currency1)) return false;
7.50 - if (!currency2.equals(that.currency2)) return false;
7.51 -
7.52 - return true;
7.53 - }
7.54 -
7.55 - public int hashCode() {
7.56 - int result;
7.57 - result = conversionRatioProvider.hashCode();
7.58 - result = 31 * result + currency1.hashCode();
7.59 - result = 31 * result + currency2.hashCode();
7.60 - return result;
7.61 - }
7.62 -
7.63 - ConversionRatioProvider getConversionRatioProvider() {
7.64 - return conversionRatioProvider;
7.65 - }
7.66 -
7.67 -}
8.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotConvertException.java Tue Oct 07 01:18:23 2008 +0200
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,26 +0,0 @@
8.4 -package org.apidesign.apifest08.currency;
8.5 -
8.6 -/**
8.7 - * If something was wrong during converting currencies...
8.8 - * Eg. when the convertor is outdated
8.9 - * Should be a descendant of RuntimeException? Hmmms...
8.10 - * @author Ladislav Vitasek
8.11 - */
8.12 -public class CannotConvertException extends RuntimeException {
8.13 -
8.14 - public CannotConvertException() {
8.15 -
8.16 - }
8.17 -
8.18 - public CannotConvertException(String message) {
8.19 - super(message);
8.20 - }
8.21 -
8.22 - public CannotConvertException(Throwable e) {
8.23 - super(e);
8.24 - }
8.25 -
8.26 - public CannotConvertException(String message, Throwable cause) {
8.27 - super(message, cause);
8.28 - }
8.29 -}
9.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotInstantiateFactoryException.java Tue Oct 07 01:18:23 2008 +0200
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,23 +0,0 @@
9.4 -package org.apidesign.apifest08.currency;
9.5 -
9.6 -/**
9.7 - * Failed to instantiate class for factory
9.8 - * @author Ladislav Vitasek
9.9 - */
9.10 -public class CannotInstantiateFactoryException extends Exception {
9.11 - public CannotInstantiateFactoryException(Throwable e) {
9.12 - super(e);
9.13 - }
9.14 -
9.15 - public CannotInstantiateFactoryException(String message) {
9.16 - super(message);
9.17 - }
9.18 -
9.19 - public CannotInstantiateFactoryException() {
9.20 - super();
9.21 - }
9.22 -
9.23 - public CannotInstantiateFactoryException(String message, Throwable cause) {
9.24 - super(message, cause);
9.25 - }
9.26 -}
10.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotProvideValueException.java Tue Oct 07 01:18:23 2008 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,24 +0,0 @@
10.4 -package org.apidesign.apifest08.currency;
10.5 -
10.6 -/**
10.7 - * Used when value cannot be get from the source
10.8 - * @author Ladislav Vitasek
10.9 - */
10.10 -public class CannotProvideValueException extends RuntimeException {
10.11 -
10.12 - public CannotProvideValueException() {
10.13 - super();
10.14 - }
10.15 -
10.16 - public CannotProvideValueException(String message) {
10.17 - super(message);
10.18 - }
10.19 -
10.20 - public CannotProvideValueException(String message, Throwable cause) {
10.21 - super(message, cause);
10.22 - }
10.23 -
10.24 - public CannotProvideValueException(Throwable cause) {
10.25 - super(cause);
10.26 - }
10.27 -}
11.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/ConversionProperties.java Tue Oct 07 01:18:23 2008 +0200
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,101 +0,0 @@
11.4 -package org.apidesign.apifest08.currency;
11.5 -
11.6 -import java.math.BigDecimal;
11.7 -import java.math.RoundingMode;
11.8 -
11.9 -/**
11.10 - * This class encapsulates settings for currency conversion
11.11 - * We can use it eg. for uptime options etc. in future versions
11.12 - *
11.13 - * @author Ladislav Vitasek
11.14 - */
11.15 -final public class ConversionProperties {
11.16 -
11.17 - private final ConversionRatioProvider conversionRatioProvider;
11.18 - private final RoundingMode roundingMode;
11.19 -
11.20 - /**
11.21 - * Returns conversion constants - conversion operation is invertable
11.22 - * Default
11.23 - */
11.24 - private final static class FixedBidirectionalRatioConversion implements ConversionRatioProvider {
11.25 - private final BigDecimal currency1ToCurrency2Constant;
11.26 - private final BigDecimal currency2ToCurrency1Constant;
11.27 - private static final int SCALE_MAX_DEFAULT = 20;
11.28 -
11.29 - /**
11.30 - * Constructor
11.31 - * @param ratioConstant fixed ratio constant
11.32 - * @param mode math rounding mode
11.33 - * @throws IllegalArgumentException if conversion value is <= 0
11.34 - */
11.35 - private FixedBidirectionalRatioConversion(BigDecimal ratioConstant, RoundingMode mode) {
11.36 - if (ratioConstant.compareTo(BigDecimal.ZERO) <= 0)
11.37 - throw new IllegalArgumentException("Conversion value cannot be <= 0");
11.38 - this.currency1ToCurrency2Constant = ratioConstant;
11.39 - this.currency2ToCurrency1Constant = BigDecimal.ONE.setScale(SCALE_MAX_DEFAULT).divide(ratioConstant, mode);
11.40 - }
11.41 -
11.42 - public BigDecimal getCurrency1ToCurrency2Constant() {
11.43 - return currency1ToCurrency2Constant;
11.44 - }
11.45 -
11.46 - public BigDecimal getCurrency2ToCurrency1Constant() {
11.47 - return currency2ToCurrency1Constant;
11.48 - }
11.49 - }
11.50 -
11.51 -
11.52 - /**
11.53 - * Returns new instance Conversion properties - fixed conversion ratio - both directions
11.54 - * Default max scale is set to 20
11.55 - *
11.56 - * @param conversionConstant value of constant for conversion
11.57 - * @param roundingMode math rounding mode
11.58 - * @return new instance of ConversionProperties class
11.59 - * @throws IllegalArgumentException if conversion constant is <= 0
11.60 - * @see org.apidesign.apifest08.currency.ConversionProperties.FixedBidirectionalRatioConversion
11.61 - */
11.62 - public static ConversionProperties create(BigDecimal conversionConstant, RoundingMode roundingMode) {
11.63 - return create(new FixedBidirectionalRatioConversion(conversionConstant, roundingMode), roundingMode);
11.64 - }
11.65 -
11.66 - /**
11.67 - * Returns new instance Conversion properties
11.68 - *
11.69 - * @param conversionRatioProvider provider for conversion constants
11.70 - * @param roundingMode math rounding mode
11.71 - * @return new instance of ConversionProperties class
11.72 - */
11.73 - public static ConversionProperties create(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
11.74 - if (conversionRatioProvider == null || roundingMode == null)
11.75 - throw new NullPointerException();
11.76 - return new ConversionProperties(conversionRatioProvider, roundingMode);
11.77 - }
11.78 -
11.79 - /**
11.80 - * Returns new instance Conversion properties with values set to conversionConstant=BigDecimal.ONE
11.81 - * and roundingMode=RoundingMode.HALF_EVEN
11.82 - *
11.83 - * Conversion is bidirectional.
11.84 - *
11.85 - * @return
11.86 - */
11.87 - public static ConversionProperties createDefault() {
11.88 - return create(BigDecimal.ONE, RoundingMode.HALF_EVEN);
11.89 - }
11.90 -
11.91 - private ConversionProperties(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
11.92 - this.conversionRatioProvider = conversionRatioProvider;
11.93 - this.roundingMode = roundingMode;
11.94 - }
11.95 -
11.96 -
11.97 - public RoundingMode getRoundingMode() {
11.98 - return roundingMode;
11.99 - }
11.100 -
11.101 - public ConversionRatioProvider getConversionRatioProvider() {
11.102 - return conversionRatioProvider;
11.103 - }
11.104 -}
12.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/ConversionRatioProvider.java Tue Oct 07 01:18:23 2008 +0200
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,12 +0,0 @@
12.4 -package org.apidesign.apifest08.currency;
12.5 -
12.6 -import java.math.BigDecimal;
12.7 -
12.8 -/**
12.9 - * Provider for conversion constant from any source
12.10 - * @author Ladislav Vitasek
12.11 - */
12.12 -public interface ConversionRatioProvider {
12.13 - public BigDecimal getCurrency1ToCurrency2Constant() throws CannotProvideValueException;
12.14 - public BigDecimal getCurrency2ToCurrency1Constant() throws CannotProvideValueException;
12.15 -}
13.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,51 +0,0 @@
13.4 -package org.apidesign.apifest08.currency;
13.5 -
13.6 -import java.math.BigDecimal;
13.7 -import java.util.Currency;
13.8 -
13.9 -/** This is the skeleton class for your API. You need to make it public, so
13.10 - * it is accessible to your client code (currently in Task1Test.java) file.
13.11 - * <p>
13.12 - * Feel free to create additional classes or rename this one, just keep all
13.13 - * the API and its implementation in this package. Do not spread it outside
13.14 - * to other packages.
13.15 - */
13.16 -public interface Convertor {
13.17 - /**
13.18 - * Methods converts some pounds
13.19 - * API design question - what kind of parameters?
13.20 - * I decided to use BigDecimal based on experience on Java conf ;-)
13.21 - * @param amountOfMoney
13.22 - * @return converted amount of money
13.23 - * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
13.24 - */
13.25 -
13.26 - BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException;
13.27 -
13.28 - /**
13.29 - * Methods converts some pounds
13.30 - * API design question - what kind of parameters?
13.31 - * @param amountOfMoney
13.32 - * @return converted amount of money
13.33 - * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
13.34 - */
13.35 -
13.36 - BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException;
13.37 -
13.38 - //handy getters
13.39 -
13.40 - /**
13.41 - * Getter - Returns Currency 1 of this convertor
13.42 - * @return money code
13.43 - */
13.44 - Currency getCurrency1();
13.45 -
13.46 - /**
13.47 - * Getter - Returns Currency 2 of this convertor
13.48 - * @return money code
13.49 - */
13.50 - Currency getCurrency2();
13.51 -
13.52 - // For Future purposes...? - it was not as a requirement in TestCase
13.53 - //BigDecimal getConversionValue();
13.54 -}
14.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorNotAvailableException.java Tue Oct 07 01:18:23 2008 +0200
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,23 +0,0 @@
14.4 -package org.apidesign.apifest08.currency;
14.5 -
14.6 -/**
14.7 - * No convertor is available for current conversion settings
14.8 - * @author Ladislav Vitasek
14.9 - */
14.10 -public class ConvertorNotAvailableException extends Exception {
14.11 - public ConvertorNotAvailableException() {
14.12 -
14.13 - }
14.14 -
14.15 - public ConvertorNotAvailableException(String message) {
14.16 - super(message);
14.17 - }
14.18 -
14.19 - public ConvertorNotAvailableException(String message, Throwable cause) {
14.20 - super(message, cause);
14.21 - }
14.22 -
14.23 - public ConvertorNotAvailableException(Throwable cause) {
14.24 - super(cause);
14.25 - }
14.26 -}
15.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorsFactory.java Tue Oct 07 01:18:23 2008 +0200
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,43 +0,0 @@
15.4 -package org.apidesign.apifest08.currency;
15.5 -
15.6 -/**
15.7 - * Some Factory for Factories :-)
15.8 - * Depends on the whole application design...
15.9 - * @author Ladislav Vitasek
15.10 - */
15.11 -final public class ConvertorsFactory {
15.12 - private CurrencyConvertorFactory currencyConvertorFactoryInstance = null;
15.13 - private final static ConvertorsFactory instance = new ConvertorsFactory();
15.14 -
15.15 -
15.16 - private ConvertorsFactory() {
15.17 -
15.18 - }
15.19 -
15.20 - public static CurrencyConvertorFactory getCurrencyConvertorFactoryInstance() throws CannotInstantiateFactoryException {
15.21 - return getInstance().getCurrencyConvertor();
15.22 - }
15.23 -
15.24 - /**
15.25 - * Returns instance of CurrencyConvertorFactory
15.26 - * @return new instance of CurrencyConvertorFactory
15.27 - * @throws CannotInstantiateFactoryException
15.28 - */
15.29 - private synchronized CurrencyConvertorFactory getCurrencyConvertor() throws CannotInstantiateFactoryException {
15.30 - if (currencyConvertorFactoryInstance == null) {//intern implementation
15.31 -// String className = System.getProperty("currencyFactory", CurrencyConvertorFactoryImpl.class.getName());
15.32 -// try {
15.33 -// currencyConvertorFactoryInstance = (CurrencyConvertorFactory) Class.forName(className).newInstance();
15.34 -// } catch (Exception e) {
15.35 -// throw new CannotInstantiateFactoryException(e);
15.36 -// }
15.37 - //without reflection
15.38 - currencyConvertorFactoryInstance = new CurrencyConvertorFactoryImpl();
15.39 - }
15.40 - return currencyConvertorFactoryInstance;
15.41 - }
15.42 -
15.43 - public static ConvertorsFactory getInstance() {
15.44 - return instance;
15.45 - }
15.46 -}
16.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,22 +0,0 @@
16.4 -package org.apidesign.apifest08.currency;
16.5 -
16.6 -import java.util.Currency;
16.7 -
16.8 -/**
16.9 - * @author Ladislav Vitasek
16.10 - */
16.11 -public interface CurrencyConvertorFactory {
16.12 -
16.13 - /**
16.14 - * Instantiate a new instance convertor
16.15 - * @param currency1 a code currency you want to convert between
16.16 - * @param currency2 a code currency you want to convert between
16.17 - * @param conversionProperties settings for conversion
16.18 - * @return converter for currency converting
16.19 - * @throws ConvertorNotAvailableException throws if there is no available convertor for selected currencies
16.20 - */
16.21 - Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException;
16.22 -
16.23 -
16.24 -
16.25 -}
17.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactoryImpl.java Tue Oct 07 01:18:23 2008 +0200
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,29 +0,0 @@
17.4 -package org.apidesign.apifest08.currency;
17.5 -
17.6 -import java.util.Currency;
17.7 -
17.8 -/**
17.9 - * Convertor Factory implementation
17.10 - * In the real-time world this code should be optimized - convertors caching etc.
17.11 - * @author Ladislav Vitasek
17.12 - */
17.13 -class CurrencyConvertorFactoryImpl extends AbstractConvertorFactory {
17.14 -
17.15 -
17.16 - CurrencyConvertorFactoryImpl() {
17.17 - super();
17.18 - }
17.19 -
17.20 - // Note - implementation of this method is dummy
17.21 -
17.22 - public Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException {
17.23 - if (currency1 == null || currency2 == null || conversionProperties == null)
17.24 - throw new NullPointerException();
17.25 -
17.26 - try {
17.27 - return new CurrencyConvertorImpl(currency1, currency2, conversionProperties.getConversionRatioProvider(), conversionProperties.getRoundingMode());//can be cached somehow
17.28 - } catch (Exception e) {
17.29 - throw new ConvertorNotAvailableException(e);
17.30 - }
17.31 - }
17.32 -}
18.1 --- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorImpl.java Tue Oct 07 01:18:23 2008 +0200
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,108 +0,0 @@
18.4 -package org.apidesign.apifest08.currency;
18.5 -
18.6 -import java.math.BigDecimal;
18.7 -import java.math.RoundingMode;
18.8 -import java.util.Currency;
18.9 -
18.10 -/**
18.11 - * Intern implementation of Bidirectional Convertor - this class is only for internal purposes only.
18.12 - * This implementation uses BigDecimals to count result value
18.13 - * Scale is set by ISO 4217 as default
18.14 - *
18.15 - * @author Ladislav Vitasek
18.16 - */
18.17 -class CurrencyConvertorImpl extends AbstractCurrencyConvertor {
18.18 -
18.19 - protected RoundingMode roundingMode;
18.20 - protected int currency1Scale;
18.21 - protected int currency2Scale;
18.22 -
18.23 - /**
18.24 - * Constructor
18.25 - * By default it creates convertor with conversion value 1
18.26 - *
18.27 - * @param currency1 currency for conversion
18.28 - * @param currency2 currency for conversion
18.29 - * @param provider constants provider
18.30 - * @param roundingMode math rounding mode
18.31 - */
18.32 - CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider provider, RoundingMode roundingMode) {
18.33 - this(currency1, currency2, provider, roundingMode, currency1.getDefaultFractionDigits(), currency2.getDefaultFractionDigits());
18.34 - }
18.35 -
18.36 - /**
18.37 - * Constructor
18.38 - *
18.39 - * @param currency1 currency for conversion
18.40 - * @param currency2 currency for conversion
18.41 - * @param conversionRatioProvider conversion constants provider
18.42 - * @param roundingMode math rounding mode
18.43 - * @param conversionRatioProvider constants provider
18.44 - * @param currency2Scale
18.45 - */
18.46 - CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode, int currency1Scale, int currency2Scale) {
18.47 - super(currency1, currency2, conversionRatioProvider);
18.48 - this.roundingMode = roundingMode;
18.49 - this.currency1Scale = currency1Scale;
18.50 - this.currency2Scale = currency2Scale;
18.51 - }
18.52 -
18.53 -
18.54 - public BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException {
18.55 - try {
18.56 - final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency1ToCurrency2Constant());
18.57 - return result.setScale(getCurrency2Scale(), getRoundingMode());
18.58 - } catch (CannotProvideValueException e) {
18.59 - throw new CannotConvertException(e);
18.60 - } catch (ArithmeticException e) {
18.61 - throw new CannotConvertException(e);
18.62 - }
18.63 - }
18.64 -
18.65 -
18.66 - public BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException {
18.67 - try {
18.68 - final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency2ToCurrency1Constant());
18.69 - return result.setScale(getCurrency1Scale(), getRoundingMode());
18.70 - } catch (CannotProvideValueException e) {
18.71 - throw new CannotConvertException(e);
18.72 - } catch (ArithmeticException e) {
18.73 - throw new CannotConvertException(e);
18.74 - }
18.75 - }
18.76 -
18.77 - public String toString() {
18.78 - return "CurrencyConvertorImpl{" +
18.79 - "currency1=" + getCurrency1() +
18.80 - ",currency2=" + getCurrency2() +
18.81 - ", roundingMode=" + roundingMode +
18.82 - ", currency1Scale=" + currency1Scale +
18.83 - ", currency2Scale=" + currency2Scale +
18.84 - '}';
18.85 - }
18.86 -
18.87 - RoundingMode getRoundingMode() {
18.88 - return roundingMode;
18.89 - }
18.90 -
18.91 - int getCurrency1Scale() {
18.92 - return currency1Scale;
18.93 - }
18.94 -
18.95 - int getCurrency2Scale() {
18.96 - return currency2Scale;
18.97 - }
18.98 -
18.99 - void setRoundingMode(RoundingMode roundingMode) {
18.100 - this.roundingMode = roundingMode;
18.101 - }
18.102 -
18.103 - void setCurrency1Scale(int currency1Scale) {
18.104 - this.currency1Scale = currency1Scale;
18.105 - }
18.106 -
18.107 - void setCurrency2Scale(int currency2Scale) {
18.108 - this.currency2Scale = currency2Scale;
18.109 - }
18.110 -
18.111 -}
19.1 --- a/task2/solution01/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,104 +0,0 @@
19.4 -package org.apidesign.apifest08.test;
19.5 -
19.6 -import junit.framework.TestCase;
19.7 -import org.apidesign.apifest08.currency.*;
19.8 -
19.9 -import java.math.BigDecimal;
19.10 -import java.math.RoundingMode;
19.11 -import java.util.Currency;
19.12 -
19.13 -/**
19.14 - * Finish the Convertor API, and then write bodies of methods inside
19.15 - * of this class to match the given tasks. To fullfil your task, use the
19.16 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
19.17 - * Do not you reflection, or other hacks as your code
19.18 - * shall run without any runtime permissions.
19.19 - */
19.20 -public class Task1Test extends TestCase {
19.21 - private static CurrencyConvertorFactory currencyConvertorFactoryInstance;
19.22 -
19.23 - public Task1Test(String testName) {
19.24 - super(testName);
19.25 - }
19.26 -
19.27 - @Override
19.28 - protected void setUp() throws Exception {
19.29 - currencyConvertorFactoryInstance = ConvertorsFactory.getCurrencyConvertorFactoryInstance();
19.30 - }
19.31 -
19.32 - @Override
19.33 - protected void tearDown() throws Exception {
19.34 - currencyConvertorFactoryInstance = null;
19.35 - }
19.36 -
19.37 - /**
19.38 - * Create convertor that understands two currencies, CZK and
19.39 - * USD. Make 1 USD == 17 CZK.
19.40 - * <p/>
19.41 - * Creation of the convertor shall not require subclassing of any class
19.42 - * or interface on the client side.
19.43 - *
19.44 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
19.45 - */
19.46 - public static Convertor createCZKtoUSD() throws ConvertorNotAvailableException {
19.47 - final Currency czk = Currency.getInstance("CZK");
19.48 - final Currency usd = Currency.getInstance("USD");
19.49 - final BigDecimal constant = BigDecimal.ONE.divide(BigDecimal.valueOf(17), 10, RoundingMode.HALF_EVEN);
19.50 - return currencyConvertorFactoryInstance.createConvertor(czk, usd, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
19.51 - }
19.52 -
19.53 - /**
19.54 - * Create convertor that understands two currencies, CZK and
19.55 - * SKK. Make 100 SKK == 80 CZK.
19.56 - * <p/>
19.57 - * Creation of the convertor shall not require subclassing of any class
19.58 - * or interface on the client side.
19.59 - *
19.60 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
19.61 - */
19.62 - public static Convertor createSKKtoCZK() throws ConvertorNotAvailableException {
19.63 - final Currency skk = Currency.getInstance("SKK");
19.64 - final Currency czk = Currency.getInstance("CZK");
19.65 - final BigDecimal constant = new BigDecimal("0.8");
19.66 - return currencyConvertorFactoryInstance.createConvertor(skk, czk, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
19.67 - }
19.68 -
19.69 - /**
19.70 - * Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
19.71 - * with it.
19.72 - */
19.73 - public void testCurrencyCZKUSD() throws Exception {
19.74 - Convertor c = createCZKtoUSD();
19.75 - // convert $5 to CZK using c:
19.76 -
19.77 - final int czkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
19.78 - final int usdDigitsScale = c.getCurrency2().getDefaultFractionDigits();
19.79 -
19.80 - assertEquals("Result is 85 CZK", BigDecimal.valueOf(85).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(5)));
19.81 -
19.82 - // convert $8 to CZK
19.83 - assertEquals("Result is 136 CZK", BigDecimal.valueOf(136).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(8)));
19.84 -
19.85 - // convert 1003CZK to USD
19.86 - assertEquals("Result is 59 USD", BigDecimal.valueOf(59).setScale(usdDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(1003)));
19.87 - }
19.88 -
19.89 - /**
19.90 - * Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
19.91 - * with it.
19.92 - */
19.93 - public void testCurrencySKKCZK() throws Exception {
19.94 - Convertor c = createSKKtoCZK();
19.95 - // convert 16CZK using c:
19.96 -
19.97 - final int skkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
19.98 - final int czkDigitsScale = c.getCurrency2().getDefaultFractionDigits();
19.99 -
19.100 - assertEquals("Result is 20 SKK", BigDecimal.valueOf(20).setScale(skkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(16)));
19.101 -
19.102 - // convert 500SKK to CZK
19.103 - assertEquals("Result is 400 CZK", BigDecimal.valueOf(400).setScale(czkDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(500)));
19.104 - }
19.105 -
19.106 -}
19.107 -
20.1 --- a/task2/solution03/build.xml Tue Oct 07 01:18:23 2008 +0200
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,69 +0,0 @@
20.4 -<?xml version="1.0" encoding="UTF-8"?>
20.5 -<!-- You may freely edit this file. See commented blocks below for -->
20.6 -<!-- some examples of how to customize the build. -->
20.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
20.8 -<project name="currency" default="default" basedir=".">
20.9 - <description>Builds, tests, and runs the project.</description>
20.10 - <import file="nbproject/build-impl.xml"/>
20.11 - <!--
20.12 -
20.13 - There exist several targets which are by default empty and which can be
20.14 - used for execution of your tasks. These targets are usually executed
20.15 - before and after some main targets. They are:
20.16 -
20.17 - -pre-init: called before initialization of project properties
20.18 - -post-init: called after initialization of project properties
20.19 - -pre-compile: called before javac compilation
20.20 - -post-compile: called after javac compilation
20.21 - -pre-compile-single: called before javac compilation of single file
20.22 - -post-compile-single: called after javac compilation of single file
20.23 - -pre-compile-test: called before javac compilation of JUnit tests
20.24 - -post-compile-test: called after javac compilation of JUnit tests
20.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
20.26 - -post-compile-test-single: called after javac compilation of single JUunit test
20.27 - -pre-jar: called before JAR building
20.28 - -post-jar: called after JAR building
20.29 - -post-clean: called after cleaning build products
20.30 -
20.31 - (Targets beginning with '-' are not intended to be called on their own.)
20.32 -
20.33 - Example of inserting an obfuscator after compilation could look like this:
20.34 -
20.35 - <target name="-post-compile">
20.36 - <obfuscate>
20.37 - <fileset dir="${build.classes.dir}"/>
20.38 - </obfuscate>
20.39 - </target>
20.40 -
20.41 - For list of available properties check the imported
20.42 - nbproject/build-impl.xml file.
20.43 -
20.44 -
20.45 - Another way to customize the build is by overriding existing main targets.
20.46 - The targets of interest are:
20.47 -
20.48 - -init-macrodef-javac: defines macro for javac compilation
20.49 - -init-macrodef-junit: defines macro for junit execution
20.50 - -init-macrodef-debug: defines macro for class debugging
20.51 - -init-macrodef-java: defines macro for class execution
20.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
20.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
20.54 - run: execution of project
20.55 - -javadoc-build: Javadoc generation
20.56 - test-report: JUnit report generation
20.57 -
20.58 - An example of overriding the target for project execution could look like this:
20.59 -
20.60 - <target name="run" depends="currency-impl.jar">
20.61 - <exec dir="bin" executable="launcher.exe">
20.62 - <arg file="${dist.jar}"/>
20.63 - </exec>
20.64 - </target>
20.65 -
20.66 - Notice that the overridden target depends on the jar target and not only on
20.67 - the compile target as the regular run target does. Again, for a list of available
20.68 - properties which you can use, check the target you are overriding in the
20.69 - nbproject/build-impl.xml file.
20.70 -
20.71 - -->
20.72 -</project>
21.1 --- a/task2/solution03/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,642 +0,0 @@
21.4 -<?xml version="1.0" encoding="UTF-8"?>
21.5 -<!--
21.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
21.7 -*** EDIT ../build.xml INSTEAD ***
21.8 -
21.9 -For the purpose of easier reading the script
21.10 -is divided into following sections:
21.11 -
21.12 - - initialization
21.13 - - compilation
21.14 - - jar
21.15 - - execution
21.16 - - debugging
21.17 - - javadoc
21.18 - - junit compilation
21.19 - - junit execution
21.20 - - junit debugging
21.21 - - applet
21.22 - - cleanup
21.23 -
21.24 - -->
21.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" 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="Currency_Convertor_Solution_03-impl">
21.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
21.27 - <!--
21.28 - ======================
21.29 - INITIALIZATION SECTION
21.30 - ======================
21.31 - -->
21.32 - <target name="-pre-init">
21.33 - <!-- Empty placeholder for easier customization. -->
21.34 - <!-- You can override this target in the ../build.xml file. -->
21.35 - </target>
21.36 - <target depends="-pre-init" name="-init-private">
21.37 - <property file="nbproject/private/config.properties"/>
21.38 - <property file="nbproject/private/configs/${config}.properties"/>
21.39 - <property file="nbproject/private/private.properties"/>
21.40 - </target>
21.41 - <target depends="-pre-init,-init-private" name="-init-user">
21.42 - <property file="${user.properties.file}"/>
21.43 - <!-- The two properties below are usually overridden -->
21.44 - <!-- by the active platform. Just a fallback. -->
21.45 - <property name="default.javac.source" value="1.4"/>
21.46 - <property name="default.javac.target" value="1.4"/>
21.47 - </target>
21.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
21.49 - <property file="nbproject/configs/${config}.properties"/>
21.50 - <property file="nbproject/project.properties"/>
21.51 - </target>
21.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
21.53 - <available file="${manifest.file}" property="manifest.available"/>
21.54 - <condition property="manifest.available+main.class">
21.55 - <and>
21.56 - <isset property="manifest.available"/>
21.57 - <isset property="main.class"/>
21.58 - <not>
21.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
21.60 - </not>
21.61 - </and>
21.62 - </condition>
21.63 - <condition property="manifest.available+main.class+mkdist.available">
21.64 - <and>
21.65 - <istrue value="${manifest.available+main.class}"/>
21.66 - <isset property="libs.CopyLibs.classpath"/>
21.67 - </and>
21.68 - </condition>
21.69 - <condition property="have.tests">
21.70 - <or>
21.71 - <available file="${test.src.dir}"/>
21.72 - </or>
21.73 - </condition>
21.74 - <condition property="have.sources">
21.75 - <or>
21.76 - <available file="${src.dir}"/>
21.77 - </or>
21.78 - </condition>
21.79 - <condition property="netbeans.home+have.tests">
21.80 - <and>
21.81 - <isset property="netbeans.home"/>
21.82 - <isset property="have.tests"/>
21.83 - </and>
21.84 - </condition>
21.85 - <condition property="no.javadoc.preview">
21.86 - <and>
21.87 - <isset property="javadoc.preview"/>
21.88 - <isfalse value="${javadoc.preview}"/>
21.89 - </and>
21.90 - </condition>
21.91 - <property name="run.jvmargs" value=""/>
21.92 - <property name="javac.compilerargs" value=""/>
21.93 - <property name="work.dir" value="${basedir}"/>
21.94 - <condition property="no.deps">
21.95 - <and>
21.96 - <istrue value="${no.dependencies}"/>
21.97 - </and>
21.98 - </condition>
21.99 - <property name="javac.debug" value="true"/>
21.100 - <property name="javadoc.preview" value="true"/>
21.101 - <property name="application.args" value=""/>
21.102 - <property name="source.encoding" value="${file.encoding}"/>
21.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
21.104 - <and>
21.105 - <isset property="javadoc.encoding"/>
21.106 - <not>
21.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
21.108 - </not>
21.109 - </and>
21.110 - </condition>
21.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
21.112 - <property name="includes" value="**"/>
21.113 - <property name="excludes" value=""/>
21.114 - <property name="do.depend" value="false"/>
21.115 - <condition property="do.depend.true">
21.116 - <istrue value="${do.depend}"/>
21.117 - </condition>
21.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
21.119 - <and>
21.120 - <isset property="jaxws.endorsed.dir"/>
21.121 - <available file="nbproject/jaxws-build.xml"/>
21.122 - </and>
21.123 - </condition>
21.124 - </target>
21.125 - <target name="-post-init">
21.126 - <!-- Empty placeholder for easier customization. -->
21.127 - <!-- You can override this target in the ../build.xml file. -->
21.128 - </target>
21.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
21.130 - <fail unless="src.dir">Must set src.dir</fail>
21.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
21.132 - <fail unless="build.dir">Must set build.dir</fail>
21.133 - <fail unless="dist.dir">Must set dist.dir</fail>
21.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
21.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
21.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
21.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
21.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
21.139 - <fail unless="dist.jar">Must set dist.jar</fail>
21.140 - </target>
21.141 - <target name="-init-macrodef-property">
21.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
21.143 - <attribute name="name"/>
21.144 - <attribute name="value"/>
21.145 - <sequential>
21.146 - <property name="@{name}" value="${@{value}}"/>
21.147 - </sequential>
21.148 - </macrodef>
21.149 - </target>
21.150 - <target name="-init-macrodef-javac">
21.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
21.152 - <attribute default="${src.dir}" name="srcdir"/>
21.153 - <attribute default="${build.classes.dir}" name="destdir"/>
21.154 - <attribute default="${javac.classpath}" name="classpath"/>
21.155 - <attribute default="${includes}" name="includes"/>
21.156 - <attribute default="${excludes}" name="excludes"/>
21.157 - <attribute default="${javac.debug}" name="debug"/>
21.158 - <attribute default="" name="sourcepath"/>
21.159 - <element name="customize" optional="true"/>
21.160 - <sequential>
21.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}">
21.162 - <classpath>
21.163 - <path path="@{classpath}"/>
21.164 - </classpath>
21.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
21.166 - <customize/>
21.167 - </javac>
21.168 - </sequential>
21.169 - </macrodef>
21.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
21.171 - <attribute default="${src.dir}" name="srcdir"/>
21.172 - <attribute default="${build.classes.dir}" name="destdir"/>
21.173 - <attribute default="${javac.classpath}" name="classpath"/>
21.174 - <sequential>
21.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
21.176 - <classpath>
21.177 - <path path="@{classpath}"/>
21.178 - </classpath>
21.179 - </depend>
21.180 - </sequential>
21.181 - </macrodef>
21.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
21.183 - <attribute default="${build.classes.dir}" name="destdir"/>
21.184 - <sequential>
21.185 - <fail unless="javac.includes">Must set javac.includes</fail>
21.186 - <pathconvert pathsep="," property="javac.includes.binary">
21.187 - <path>
21.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
21.189 - </path>
21.190 - <globmapper from="*.java" to="*.class"/>
21.191 - </pathconvert>
21.192 - <delete>
21.193 - <files includes="${javac.includes.binary}"/>
21.194 - </delete>
21.195 - </sequential>
21.196 - </macrodef>
21.197 - </target>
21.198 - <target name="-init-macrodef-junit">
21.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
21.200 - <attribute default="${includes}" name="includes"/>
21.201 - <attribute default="${excludes}" name="excludes"/>
21.202 - <attribute default="**" name="testincludes"/>
21.203 - <sequential>
21.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
21.205 - <batchtest todir="${build.test.results.dir}">
21.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
21.207 - <filename name="@{testincludes}"/>
21.208 - </fileset>
21.209 - </batchtest>
21.210 - <classpath>
21.211 - <path path="${run.test.classpath}"/>
21.212 - </classpath>
21.213 - <syspropertyset>
21.214 - <propertyref prefix="test-sys-prop."/>
21.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
21.216 - </syspropertyset>
21.217 - <formatter type="brief" usefile="false"/>
21.218 - <formatter type="xml"/>
21.219 - <jvmarg line="${run.jvmargs}"/>
21.220 - </junit>
21.221 - </sequential>
21.222 - </macrodef>
21.223 - </target>
21.224 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
21.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
21.226 - <attribute default="${main.class}" name="name"/>
21.227 - <attribute default="${debug.classpath}" name="classpath"/>
21.228 - <attribute default="" name="stopclassname"/>
21.229 - <sequential>
21.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
21.231 - <classpath>
21.232 - <path path="@{classpath}"/>
21.233 - </classpath>
21.234 - </nbjpdastart>
21.235 - </sequential>
21.236 - </macrodef>
21.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
21.238 - <attribute default="${build.classes.dir}" name="dir"/>
21.239 - <sequential>
21.240 - <nbjpdareload>
21.241 - <fileset dir="@{dir}" includes="${fix.classes}">
21.242 - <include name="${fix.includes}*.class"/>
21.243 - </fileset>
21.244 - </nbjpdareload>
21.245 - </sequential>
21.246 - </macrodef>
21.247 - </target>
21.248 - <target name="-init-debug-args">
21.249 - <property name="version-output" value="java version "${ant.java.version}"/>
21.250 - <condition property="have-jdk-older-than-1.4">
21.251 - <or>
21.252 - <contains string="${version-output}" substring="java version "1.0"/>
21.253 - <contains string="${version-output}" substring="java version "1.1"/>
21.254 - <contains string="${version-output}" substring="java version "1.2"/>
21.255 - <contains string="${version-output}" substring="java version "1.3"/>
21.256 - </or>
21.257 - </condition>
21.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
21.259 - <istrue value="${have-jdk-older-than-1.4}"/>
21.260 - </condition>
21.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
21.262 - <os family="windows"/>
21.263 - </condition>
21.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
21.265 - <isset property="debug.transport"/>
21.266 - </condition>
21.267 - </target>
21.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
21.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
21.270 - <attribute default="${main.class}" name="classname"/>
21.271 - <attribute default="${debug.classpath}" name="classpath"/>
21.272 - <element name="customize" optional="true"/>
21.273 - <sequential>
21.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
21.275 - <jvmarg line="${debug-args-line}"/>
21.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
21.277 - <jvmarg line="${run.jvmargs}"/>
21.278 - <classpath>
21.279 - <path path="@{classpath}"/>
21.280 - </classpath>
21.281 - <syspropertyset>
21.282 - <propertyref prefix="run-sys-prop."/>
21.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
21.284 - </syspropertyset>
21.285 - <customize/>
21.286 - </java>
21.287 - </sequential>
21.288 - </macrodef>
21.289 - </target>
21.290 - <target name="-init-macrodef-java">
21.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
21.292 - <attribute default="${main.class}" name="classname"/>
21.293 - <element name="customize" optional="true"/>
21.294 - <sequential>
21.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
21.296 - <jvmarg line="${run.jvmargs}"/>
21.297 - <classpath>
21.298 - <path path="${run.classpath}"/>
21.299 - </classpath>
21.300 - <syspropertyset>
21.301 - <propertyref prefix="run-sys-prop."/>
21.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
21.303 - </syspropertyset>
21.304 - <customize/>
21.305 - </java>
21.306 - </sequential>
21.307 - </macrodef>
21.308 - </target>
21.309 - <target name="-init-presetdef-jar">
21.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
21.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
21.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
21.313 - </jar>
21.314 - </presetdef>
21.315 - </target>
21.316 - <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"/>
21.317 - <!--
21.318 - ===================
21.319 - COMPILATION SECTION
21.320 - ===================
21.321 - -->
21.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
21.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
21.324 - <target depends="init" name="-check-automatic-build">
21.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
21.326 - </target>
21.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
21.328 - <antcall target="clean"/>
21.329 - </target>
21.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
21.331 - <mkdir dir="${build.classes.dir}"/>
21.332 - </target>
21.333 - <target name="-pre-compile">
21.334 - <!-- Empty placeholder for easier customization. -->
21.335 - <!-- You can override this target in the ../build.xml file. -->
21.336 - </target>
21.337 - <target if="do.depend.true" name="-compile-depend">
21.338 - <j2seproject3:depend/>
21.339 - </target>
21.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
21.341 - <j2seproject3:javac/>
21.342 - <copy todir="${build.classes.dir}">
21.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
21.344 - </copy>
21.345 - </target>
21.346 - <target name="-post-compile">
21.347 - <!-- Empty placeholder for easier customization. -->
21.348 - <!-- You can override this target in the ../build.xml file. -->
21.349 - </target>
21.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
21.351 - <target name="-pre-compile-single">
21.352 - <!-- Empty placeholder for easier customization. -->
21.353 - <!-- You can override this target in the ../build.xml file. -->
21.354 - </target>
21.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
21.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
21.357 - <j2seproject3:force-recompile/>
21.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
21.359 - </target>
21.360 - <target name="-post-compile-single">
21.361 - <!-- Empty placeholder for easier customization. -->
21.362 - <!-- You can override this target in the ../build.xml file. -->
21.363 - </target>
21.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
21.365 - <!--
21.366 - ====================
21.367 - JAR BUILDING SECTION
21.368 - ====================
21.369 - -->
21.370 - <target depends="init" name="-pre-pre-jar">
21.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
21.372 - <mkdir dir="${dist.jar.dir}"/>
21.373 - </target>
21.374 - <target name="-pre-jar">
21.375 - <!-- Empty placeholder for easier customization. -->
21.376 - <!-- You can override this target in the ../build.xml file. -->
21.377 - </target>
21.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
21.379 - <j2seproject1:jar/>
21.380 - </target>
21.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
21.382 - <j2seproject1:jar manifest="${manifest.file}"/>
21.383 - </target>
21.384 - <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">
21.385 - <j2seproject1:jar manifest="${manifest.file}">
21.386 - <j2seproject1:manifest>
21.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
21.388 - </j2seproject1:manifest>
21.389 - </j2seproject1:jar>
21.390 - <echo>To run this application from the command line without Ant, try:</echo>
21.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
21.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
21.393 - <pathconvert property="run.classpath.with.dist.jar">
21.394 - <path path="${run.classpath}"/>
21.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
21.396 - </pathconvert>
21.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
21.398 - </target>
21.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
21.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
21.401 - <pathconvert property="run.classpath.without.build.classes.dir">
21.402 - <path path="${run.classpath}"/>
21.403 - <map from="${build.classes.dir.resolved}" to=""/>
21.404 - </pathconvert>
21.405 - <pathconvert pathsep=" " property="jar.classpath">
21.406 - <path path="${run.classpath.without.build.classes.dir}"/>
21.407 - <chainedmapper>
21.408 - <flattenmapper/>
21.409 - <globmapper from="*" to="lib/*"/>
21.410 - </chainedmapper>
21.411 - </pathconvert>
21.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
21.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
21.414 - <fileset dir="${build.classes.dir}"/>
21.415 - <manifest>
21.416 - <attribute name="Main-Class" value="${main.class}"/>
21.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
21.418 - </manifest>
21.419 - </copylibs>
21.420 - <echo>To run this application from the command line without Ant, try:</echo>
21.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
21.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
21.423 - </target>
21.424 - <target name="-post-jar">
21.425 - <!-- Empty placeholder for easier customization. -->
21.426 - <!-- You can override this target in the ../build.xml file. -->
21.427 - </target>
21.428 - <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"/>
21.429 - <!--
21.430 - =================
21.431 - EXECUTION SECTION
21.432 - =================
21.433 - -->
21.434 - <target depends="init,compile" description="Run a main class." name="run">
21.435 - <j2seproject1:java>
21.436 - <customize>
21.437 - <arg line="${application.args}"/>
21.438 - </customize>
21.439 - </j2seproject1:java>
21.440 - </target>
21.441 - <target name="-do-not-recompile">
21.442 - <property name="javac.includes.binary" value=""/>
21.443 - </target>
21.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
21.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
21.446 - <j2seproject1:java classname="${run.class}"/>
21.447 - </target>
21.448 - <!--
21.449 - =================
21.450 - DEBUGGING SECTION
21.451 - =================
21.452 - -->
21.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
21.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
21.455 - </target>
21.456 - <target depends="init,compile" name="-debug-start-debuggee">
21.457 - <j2seproject3:debug>
21.458 - <customize>
21.459 - <arg line="${application.args}"/>
21.460 - </customize>
21.461 - </j2seproject3:debug>
21.462 - </target>
21.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
21.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
21.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
21.466 - </target>
21.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
21.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
21.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
21.470 - <j2seproject3:debug classname="${debug.class}"/>
21.471 - </target>
21.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
21.473 - <target depends="init" name="-pre-debug-fix">
21.474 - <fail unless="fix.includes">Must set fix.includes</fail>
21.475 - <property name="javac.includes" value="${fix.includes}.java"/>
21.476 - </target>
21.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
21.478 - <j2seproject1:nbjpdareload/>
21.479 - </target>
21.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
21.481 - <!--
21.482 - ===============
21.483 - JAVADOC SECTION
21.484 - ===============
21.485 - -->
21.486 - <target depends="init" name="-javadoc-build">
21.487 - <mkdir dir="${dist.javadoc.dir}"/>
21.488 - <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}">
21.489 - <classpath>
21.490 - <path path="${javac.classpath}"/>
21.491 - </classpath>
21.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
21.493 - <filename name="**/*.java"/>
21.494 - </fileset>
21.495 - </javadoc>
21.496 - </target>
21.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
21.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
21.499 - </target>
21.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
21.501 - <!--
21.502 - =========================
21.503 - JUNIT COMPILATION SECTION
21.504 - =========================
21.505 - -->
21.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
21.507 - <mkdir dir="${build.test.classes.dir}"/>
21.508 - </target>
21.509 - <target name="-pre-compile-test">
21.510 - <!-- Empty placeholder for easier customization. -->
21.511 - <!-- You can override this target in the ../build.xml file. -->
21.512 - </target>
21.513 - <target if="do.depend.true" name="-compile-test-depend">
21.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
21.515 - </target>
21.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
21.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
21.518 - <copy todir="${build.test.classes.dir}">
21.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
21.520 - </copy>
21.521 - </target>
21.522 - <target name="-post-compile-test">
21.523 - <!-- Empty placeholder for easier customization. -->
21.524 - <!-- You can override this target in the ../build.xml file. -->
21.525 - </target>
21.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
21.527 - <target name="-pre-compile-test-single">
21.528 - <!-- Empty placeholder for easier customization. -->
21.529 - <!-- You can override this target in the ../build.xml file. -->
21.530 - </target>
21.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
21.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
21.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
21.534 - <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}"/>
21.535 - <copy todir="${build.test.classes.dir}">
21.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
21.537 - </copy>
21.538 - </target>
21.539 - <target name="-post-compile-test-single">
21.540 - <!-- Empty placeholder for easier customization. -->
21.541 - <!-- You can override this target in the ../build.xml file. -->
21.542 - </target>
21.543 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
21.544 - <!--
21.545 - =======================
21.546 - JUNIT EXECUTION SECTION
21.547 - =======================
21.548 - -->
21.549 - <target depends="init" if="have.tests" name="-pre-test-run">
21.550 - <mkdir dir="${build.test.results.dir}"/>
21.551 - </target>
21.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
21.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
21.554 - </target>
21.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
21.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
21.557 - </target>
21.558 - <target depends="init" if="have.tests" name="test-report"/>
21.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
21.560 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
21.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
21.562 - <mkdir dir="${build.test.results.dir}"/>
21.563 - </target>
21.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
21.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
21.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
21.567 - </target>
21.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
21.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
21.570 - </target>
21.571 - <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"/>
21.572 - <!--
21.573 - =======================
21.574 - JUNIT DEBUGGING SECTION
21.575 - =======================
21.576 - -->
21.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
21.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
21.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
21.580 - <delete file="${test.report.file}"/>
21.581 - <mkdir dir="${build.test.results.dir}"/>
21.582 - <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}">
21.583 - <customize>
21.584 - <syspropertyset>
21.585 - <propertyref prefix="test-sys-prop."/>
21.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
21.587 - </syspropertyset>
21.588 - <arg value="${test.class}"/>
21.589 - <arg value="showoutput=true"/>
21.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
21.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
21.592 - </customize>
21.593 - </j2seproject3:debug>
21.594 - </target>
21.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
21.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
21.597 - </target>
21.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
21.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
21.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
21.601 - </target>
21.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
21.603 - <!--
21.604 - =========================
21.605 - APPLET EXECUTION SECTION
21.606 - =========================
21.607 - -->
21.608 - <target depends="init,compile-single" name="run-applet">
21.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
21.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
21.611 - <customize>
21.612 - <arg value="${applet.url}"/>
21.613 - </customize>
21.614 - </j2seproject1:java>
21.615 - </target>
21.616 - <!--
21.617 - =========================
21.618 - APPLET DEBUGGING SECTION
21.619 - =========================
21.620 - -->
21.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
21.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
21.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
21.624 - <customize>
21.625 - <arg value="${applet.url}"/>
21.626 - </customize>
21.627 - </j2seproject3:debug>
21.628 - </target>
21.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
21.630 - <!--
21.631 - ===============
21.632 - CLEANUP SECTION
21.633 - ===============
21.634 - -->
21.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
21.636 - <target depends="init" name="-do-clean">
21.637 - <delete dir="${build.dir}"/>
21.638 - <delete dir="${dist.dir}"/>
21.639 - </target>
21.640 - <target name="-post-clean">
21.641 - <!-- Empty placeholder for easier customization. -->
21.642 - <!-- You can override this target in the ../build.xml file. -->
21.643 - </target>
21.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
21.645 -</project>
22.1 --- a/task2/solution03/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,8 +0,0 @@
22.4 -build.xml.data.CRC32=2ab820eb
22.5 -build.xml.script.CRC32=58a52595
22.6 -build.xml.stylesheet.CRC32=be360661
22.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
22.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
22.9 -nbproject/build-impl.xml.data.CRC32=ec91bd4b
22.10 -nbproject/build-impl.xml.script.CRC32=593428f7
22.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
23.1 --- a/task2/solution03/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,68 +0,0 @@
23.4 -application.title=currency
23.5 -application.vendor=apidesign.org
23.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
23.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
23.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
23.9 -build.classes.dir=${build.dir}/classes
23.10 -build.classes.excludes=**/*.java,**/*.form
23.11 -# This directory is removed when the project is cleaned:
23.12 -build.dir=build
23.13 -build.generated.dir=${build.dir}/generated
23.14 -# Only compile against the classpath explicitly listed here:
23.15 -build.sysclasspath=ignore
23.16 -build.test.classes.dir=${build.dir}/test/classes
23.17 -build.test.results.dir=${build.dir}/test/results
23.18 -debug.classpath=\
23.19 - ${run.classpath}
23.20 -debug.test.classpath=\
23.21 - ${run.test.classpath}
23.22 -# This directory is removed when the project is cleaned:
23.23 -dist.dir=dist
23.24 -dist.jar=${dist.dir}/currency.jar
23.25 -dist.javadoc.dir=${dist.dir}/javadoc
23.26 -excludes=
23.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
23.28 -file.reference.src-apifest08=..
23.29 -includes=**
23.30 -jar.compress=false
23.31 -javac.classpath=
23.32 -# Space-separated list of extra javac options
23.33 -javac.compilerargs=
23.34 -javac.deprecation=false
23.35 -javac.source=1.5
23.36 -javac.target=1.5
23.37 -javac.test.classpath=\
23.38 - ${javac.classpath}:\
23.39 - ${build.classes.dir}:\
23.40 - ${file.reference.junit-4.4.jar}
23.41 -javadoc.additionalparam=
23.42 -javadoc.author=false
23.43 -javadoc.encoding=
23.44 -javadoc.noindex=false
23.45 -javadoc.nonavbar=false
23.46 -javadoc.notree=false
23.47 -javadoc.private=false
23.48 -javadoc.splitindex=true
23.49 -javadoc.use=true
23.50 -javadoc.version=false
23.51 -javadoc.windowtitle=
23.52 -jnlp.codebase.type=local
23.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
23.54 -jnlp.descriptor=application
23.55 -jnlp.enabled=false
23.56 -jnlp.offline-allowed=false
23.57 -jnlp.signed=false
23.58 -meta.inf.dir=${src.dir}/META-INF
23.59 -platform.active=default_platform
23.60 -run.classpath=\
23.61 - ${javac.classpath}:\
23.62 - ${build.classes.dir}
23.63 -# Space-separated list of JVM arguments used when running the project
23.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
23.65 -# or test-sys-prop.name=value to set system properties for unit tests):
23.66 -run.jvmargs=
23.67 -run.test.classpath=\
23.68 - ${javac.test.classpath}:\
23.69 - ${build.test.classes.dir}
23.70 -src.dir=src
23.71 -test.src.dir=test
24.1 --- a/task2/solution03/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,16 +0,0 @@
24.4 -<?xml version="1.0" encoding="UTF-8"?>
24.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
24.6 - <type>org.netbeans.modules.java.j2seproject</type>
24.7 - <configuration>
24.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
24.9 - <name>Currency Convertor Solution 03</name>
24.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
24.11 - <source-roots>
24.12 - <root id="src.dir"/>
24.13 - </source-roots>
24.14 - <test-roots>
24.15 - <root id="test.src.dir"/>
24.16 - </test-roots>
24.17 - </data>
24.18 - </configuration>
24.19 -</project>
25.1 --- a/task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,41 +0,0 @@
25.4 -package org.apidesign.apifest08.currency;
25.5 -
25.6 -/** This is the skeleton class for your API. You need to make it public, so
25.7 - * it is accessible to your client code (currently in Task1Test.java) file.
25.8 - * <p>
25.9 - * Feel free to create additional classes or rename this one, just keep all
25.10 - * the API and its implementation in this package. Do not spread it outside
25.11 - * to other packages.
25.12 - */
25.13 -public class Convertor {
25.14 -
25.15 - public static final int FIRST_TO_SECOND = 1;
25.16 -
25.17 - public static final int SECOND_TO_FIRST = 2;
25.18 -
25.19 - private double first;
25.20 -
25.21 - private double second;
25.22 -
25.23 - public Convertor(double first, double second) {
25.24 - this.first = first;
25.25 - this.second = second;
25.26 - }
25.27 -
25.28 - public double convertFirstToSecond(double value) {
25.29 - return (second / first) * value;
25.30 - }
25.31 -
25.32 - public double convertSecondToFirst(double value) {
25.33 - return (first / second) * value;
25.34 - }
25.35 -
25.36 - public double convert(double value, int typeOfConvert) {
25.37 - if (FIRST_TO_SECOND == typeOfConvert) {
25.38 - return convertFirstToSecond(value);
25.39 - } else if (SECOND_TO_FIRST == typeOfConvert) {
25.40 - return convertSecondToFirst(value);
25.41 - }
25.42 - throw new IllegalArgumentException("Unkown type of convert.");
25.43 - }
25.44 -}
26.1 --- a/task2/solution03/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26.3 @@ -1,82 +0,0 @@
26.4 -package org.apidesign.apifest08.test;
26.5 -
26.6 -import junit.framework.TestCase;
26.7 -import org.apidesign.apifest08.currency.Convertor;
26.8 -
26.9 -/** Finish the Convertor API, and then write bodies of methods inside
26.10 - * of this class to match the given tasks. To fullfil your task, use the
26.11 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
26.12 - * Do not you reflection, or other hacks as your code
26.13 - * shall run without any runtime permissions.
26.14 - */
26.15 -public class Task1Test extends TestCase {
26.16 -
26.17 - public Task1Test(String testName) {
26.18 - super(testName);
26.19 - }
26.20 -
26.21 - @Override
26.22 - protected void setUp() throws Exception {
26.23 - }
26.24 -
26.25 - @Override
26.26 - protected void tearDown() throws Exception {
26.27 - }
26.28 -
26.29 - /** Create convertor that understands two currencies, CZK and
26.30 - * USD. Make 1 USD == 17 CZK.
26.31 - *
26.32 - * Creation of the convertor shall not require subclassing of any class
26.33 - * or interface on the client side.
26.34 - *
26.35 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
26.36 - */
26.37 - public static Convertor createCZKtoUSD() {
26.38 - return new Convertor(17, 1);
26.39 - }
26.40 -
26.41 - /** Create convertor that understands two currencies, CZK and
26.42 - * SKK. Make 100 SKK == 80 CZK.
26.43 - *
26.44 - * Creation of the convertor shall not require subclassing of any class
26.45 - * or interface on the client side.
26.46 - *
26.47 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
26.48 - */
26.49 - public static Convertor createSKKtoCZK() {
26.50 - return new Convertor(100, 80);
26.51 - }
26.52 -
26.53 - /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
26.54 - * with it.
26.55 - */
26.56 - public void testCurrencyCZKUSD() throws Exception {
26.57 - Convertor c = createCZKtoUSD();
26.58 - // convert $5 to CZK using c:
26.59 - // assertEquals("Result is 85 CZK");
26.60 - assertEquals(c.convert(5, Convertor.SECOND_TO_FIRST), (double) 85);
26.61 -
26.62 - // convert $8 to CZK
26.63 - // assertEquals("Result is 136 CZK");
26.64 - assertEquals(c.convert(8, Convertor.SECOND_TO_FIRST), (double) 136);
26.65 -
26.66 - // convert 1003CZK to USD
26.67 - // assertEquals("Result is 59 USD");
26.68 - assertEquals(c.convert(1003, Convertor.FIRST_TO_SECOND), (double) 59);
26.69 - }
26.70 -
26.71 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
26.72 - * with it.
26.73 - */
26.74 - public void testCurrencySKKCZK() throws Exception {
26.75 - Convertor c = createSKKtoCZK();
26.76 - // convert 16CZK using c:
26.77 - // assertEquals("Result is 20 SKK");
26.78 - assertEquals(c.convert(16, Convertor.SECOND_TO_FIRST), (double) 20);
26.79 -
26.80 - // convert 500SKK to CZK
26.81 - // assertEquals("Result is 400 CZK");
26.82 - assertEquals(c.convert(500, Convertor.FIRST_TO_SECOND), (double) 400);
26.83 - }
26.84 -}
26.85 -
27.1 --- a/task2/solution05/build.xml Tue Oct 07 01:18:23 2008 +0200
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,69 +0,0 @@
27.4 -<?xml version="1.0" encoding="UTF-8"?>
27.5 -<!-- You may freely edit this file. See commented blocks below for -->
27.6 -<!-- some examples of how to customize the build. -->
27.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
27.8 -<project name="currency" default="default" basedir=".">
27.9 - <description>Builds, tests, and runs the project.</description>
27.10 - <import file="nbproject/build-impl.xml"/>
27.11 - <!--
27.12 -
27.13 - There exist several targets which are by default empty and which can be
27.14 - used for execution of your tasks. These targets are usually executed
27.15 - before and after some main targets. They are:
27.16 -
27.17 - -pre-init: called before initialization of project properties
27.18 - -post-init: called after initialization of project properties
27.19 - -pre-compile: called before javac compilation
27.20 - -post-compile: called after javac compilation
27.21 - -pre-compile-single: called before javac compilation of single file
27.22 - -post-compile-single: called after javac compilation of single file
27.23 - -pre-compile-test: called before javac compilation of JUnit tests
27.24 - -post-compile-test: called after javac compilation of JUnit tests
27.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
27.26 - -post-compile-test-single: called after javac compilation of single JUunit test
27.27 - -pre-jar: called before JAR building
27.28 - -post-jar: called after JAR building
27.29 - -post-clean: called after cleaning build products
27.30 -
27.31 - (Targets beginning with '-' are not intended to be called on their own.)
27.32 -
27.33 - Example of inserting an obfuscator after compilation could look like this:
27.34 -
27.35 - <target name="-post-compile">
27.36 - <obfuscate>
27.37 - <fileset dir="${build.classes.dir}"/>
27.38 - </obfuscate>
27.39 - </target>
27.40 -
27.41 - For list of available properties check the imported
27.42 - nbproject/build-impl.xml file.
27.43 -
27.44 -
27.45 - Another way to customize the build is by overriding existing main targets.
27.46 - The targets of interest are:
27.47 -
27.48 - -init-macrodef-javac: defines macro for javac compilation
27.49 - -init-macrodef-junit: defines macro for junit execution
27.50 - -init-macrodef-debug: defines macro for class debugging
27.51 - -init-macrodef-java: defines macro for class execution
27.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
27.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
27.54 - run: execution of project
27.55 - -javadoc-build: Javadoc generation
27.56 - test-report: JUnit report generation
27.57 -
27.58 - An example of overriding the target for project execution could look like this:
27.59 -
27.60 - <target name="run" depends="currency-impl.jar">
27.61 - <exec dir="bin" executable="launcher.exe">
27.62 - <arg file="${dist.jar}"/>
27.63 - </exec>
27.64 - </target>
27.65 -
27.66 - Notice that the overridden target depends on the jar target and not only on
27.67 - the compile target as the regular run target does. Again, for a list of available
27.68 - properties which you can use, check the target you are overriding in the
27.69 - nbproject/build-impl.xml file.
27.70 -
27.71 - -->
27.72 -</project>
28.1 --- a/task2/solution05/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,642 +0,0 @@
28.4 -<?xml version="1.0" encoding="UTF-8"?>
28.5 -<!--
28.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
28.7 -*** EDIT ../build.xml INSTEAD ***
28.8 -
28.9 -For the purpose of easier reading the script
28.10 -is divided into following sections:
28.11 -
28.12 - - initialization
28.13 - - compilation
28.14 - - jar
28.15 - - execution
28.16 - - debugging
28.17 - - javadoc
28.18 - - junit compilation
28.19 - - junit execution
28.20 - - junit debugging
28.21 - - applet
28.22 - - cleanup
28.23 -
28.24 - -->
28.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" 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="Currency_Convertor_Solution_05-impl">
28.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
28.27 - <!--
28.28 - ======================
28.29 - INITIALIZATION SECTION
28.30 - ======================
28.31 - -->
28.32 - <target name="-pre-init">
28.33 - <!-- Empty placeholder for easier customization. -->
28.34 - <!-- You can override this target in the ../build.xml file. -->
28.35 - </target>
28.36 - <target depends="-pre-init" name="-init-private">
28.37 - <property file="nbproject/private/config.properties"/>
28.38 - <property file="nbproject/private/configs/${config}.properties"/>
28.39 - <property file="nbproject/private/private.properties"/>
28.40 - </target>
28.41 - <target depends="-pre-init,-init-private" name="-init-user">
28.42 - <property file="${user.properties.file}"/>
28.43 - <!-- The two properties below are usually overridden -->
28.44 - <!-- by the active platform. Just a fallback. -->
28.45 - <property name="default.javac.source" value="1.4"/>
28.46 - <property name="default.javac.target" value="1.4"/>
28.47 - </target>
28.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
28.49 - <property file="nbproject/configs/${config}.properties"/>
28.50 - <property file="nbproject/project.properties"/>
28.51 - </target>
28.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
28.53 - <available file="${manifest.file}" property="manifest.available"/>
28.54 - <condition property="manifest.available+main.class">
28.55 - <and>
28.56 - <isset property="manifest.available"/>
28.57 - <isset property="main.class"/>
28.58 - <not>
28.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
28.60 - </not>
28.61 - </and>
28.62 - </condition>
28.63 - <condition property="manifest.available+main.class+mkdist.available">
28.64 - <and>
28.65 - <istrue value="${manifest.available+main.class}"/>
28.66 - <isset property="libs.CopyLibs.classpath"/>
28.67 - </and>
28.68 - </condition>
28.69 - <condition property="have.tests">
28.70 - <or>
28.71 - <available file="${test.src.dir}"/>
28.72 - </or>
28.73 - </condition>
28.74 - <condition property="have.sources">
28.75 - <or>
28.76 - <available file="${src.dir}"/>
28.77 - </or>
28.78 - </condition>
28.79 - <condition property="netbeans.home+have.tests">
28.80 - <and>
28.81 - <isset property="netbeans.home"/>
28.82 - <isset property="have.tests"/>
28.83 - </and>
28.84 - </condition>
28.85 - <condition property="no.javadoc.preview">
28.86 - <and>
28.87 - <isset property="javadoc.preview"/>
28.88 - <isfalse value="${javadoc.preview}"/>
28.89 - </and>
28.90 - </condition>
28.91 - <property name="run.jvmargs" value=""/>
28.92 - <property name="javac.compilerargs" value=""/>
28.93 - <property name="work.dir" value="${basedir}"/>
28.94 - <condition property="no.deps">
28.95 - <and>
28.96 - <istrue value="${no.dependencies}"/>
28.97 - </and>
28.98 - </condition>
28.99 - <property name="javac.debug" value="true"/>
28.100 - <property name="javadoc.preview" value="true"/>
28.101 - <property name="application.args" value=""/>
28.102 - <property name="source.encoding" value="${file.encoding}"/>
28.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
28.104 - <and>
28.105 - <isset property="javadoc.encoding"/>
28.106 - <not>
28.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
28.108 - </not>
28.109 - </and>
28.110 - </condition>
28.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
28.112 - <property name="includes" value="**"/>
28.113 - <property name="excludes" value=""/>
28.114 - <property name="do.depend" value="false"/>
28.115 - <condition property="do.depend.true">
28.116 - <istrue value="${do.depend}"/>
28.117 - </condition>
28.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
28.119 - <and>
28.120 - <isset property="jaxws.endorsed.dir"/>
28.121 - <available file="nbproject/jaxws-build.xml"/>
28.122 - </and>
28.123 - </condition>
28.124 - </target>
28.125 - <target name="-post-init">
28.126 - <!-- Empty placeholder for easier customization. -->
28.127 - <!-- You can override this target in the ../build.xml file. -->
28.128 - </target>
28.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
28.130 - <fail unless="src.dir">Must set src.dir</fail>
28.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
28.132 - <fail unless="build.dir">Must set build.dir</fail>
28.133 - <fail unless="dist.dir">Must set dist.dir</fail>
28.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
28.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
28.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
28.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
28.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
28.139 - <fail unless="dist.jar">Must set dist.jar</fail>
28.140 - </target>
28.141 - <target name="-init-macrodef-property">
28.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
28.143 - <attribute name="name"/>
28.144 - <attribute name="value"/>
28.145 - <sequential>
28.146 - <property name="@{name}" value="${@{value}}"/>
28.147 - </sequential>
28.148 - </macrodef>
28.149 - </target>
28.150 - <target name="-init-macrodef-javac">
28.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
28.152 - <attribute default="${src.dir}" name="srcdir"/>
28.153 - <attribute default="${build.classes.dir}" name="destdir"/>
28.154 - <attribute default="${javac.classpath}" name="classpath"/>
28.155 - <attribute default="${includes}" name="includes"/>
28.156 - <attribute default="${excludes}" name="excludes"/>
28.157 - <attribute default="${javac.debug}" name="debug"/>
28.158 - <attribute default="" name="sourcepath"/>
28.159 - <element name="customize" optional="true"/>
28.160 - <sequential>
28.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}">
28.162 - <classpath>
28.163 - <path path="@{classpath}"/>
28.164 - </classpath>
28.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
28.166 - <customize/>
28.167 - </javac>
28.168 - </sequential>
28.169 - </macrodef>
28.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
28.171 - <attribute default="${src.dir}" name="srcdir"/>
28.172 - <attribute default="${build.classes.dir}" name="destdir"/>
28.173 - <attribute default="${javac.classpath}" name="classpath"/>
28.174 - <sequential>
28.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
28.176 - <classpath>
28.177 - <path path="@{classpath}"/>
28.178 - </classpath>
28.179 - </depend>
28.180 - </sequential>
28.181 - </macrodef>
28.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
28.183 - <attribute default="${build.classes.dir}" name="destdir"/>
28.184 - <sequential>
28.185 - <fail unless="javac.includes">Must set javac.includes</fail>
28.186 - <pathconvert pathsep="," property="javac.includes.binary">
28.187 - <path>
28.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
28.189 - </path>
28.190 - <globmapper from="*.java" to="*.class"/>
28.191 - </pathconvert>
28.192 - <delete>
28.193 - <files includes="${javac.includes.binary}"/>
28.194 - </delete>
28.195 - </sequential>
28.196 - </macrodef>
28.197 - </target>
28.198 - <target name="-init-macrodef-junit">
28.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
28.200 - <attribute default="${includes}" name="includes"/>
28.201 - <attribute default="${excludes}" name="excludes"/>
28.202 - <attribute default="**" name="testincludes"/>
28.203 - <sequential>
28.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
28.205 - <batchtest todir="${build.test.results.dir}">
28.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
28.207 - <filename name="@{testincludes}"/>
28.208 - </fileset>
28.209 - </batchtest>
28.210 - <classpath>
28.211 - <path path="${run.test.classpath}"/>
28.212 - </classpath>
28.213 - <syspropertyset>
28.214 - <propertyref prefix="test-sys-prop."/>
28.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
28.216 - </syspropertyset>
28.217 - <formatter type="brief" usefile="false"/>
28.218 - <formatter type="xml"/>
28.219 - <jvmarg line="${run.jvmargs}"/>
28.220 - </junit>
28.221 - </sequential>
28.222 - </macrodef>
28.223 - </target>
28.224 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
28.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
28.226 - <attribute default="${main.class}" name="name"/>
28.227 - <attribute default="${debug.classpath}" name="classpath"/>
28.228 - <attribute default="" name="stopclassname"/>
28.229 - <sequential>
28.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
28.231 - <classpath>
28.232 - <path path="@{classpath}"/>
28.233 - </classpath>
28.234 - </nbjpdastart>
28.235 - </sequential>
28.236 - </macrodef>
28.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
28.238 - <attribute default="${build.classes.dir}" name="dir"/>
28.239 - <sequential>
28.240 - <nbjpdareload>
28.241 - <fileset dir="@{dir}" includes="${fix.classes}">
28.242 - <include name="${fix.includes}*.class"/>
28.243 - </fileset>
28.244 - </nbjpdareload>
28.245 - </sequential>
28.246 - </macrodef>
28.247 - </target>
28.248 - <target name="-init-debug-args">
28.249 - <property name="version-output" value="java version "${ant.java.version}"/>
28.250 - <condition property="have-jdk-older-than-1.4">
28.251 - <or>
28.252 - <contains string="${version-output}" substring="java version "1.0"/>
28.253 - <contains string="${version-output}" substring="java version "1.1"/>
28.254 - <contains string="${version-output}" substring="java version "1.2"/>
28.255 - <contains string="${version-output}" substring="java version "1.3"/>
28.256 - </or>
28.257 - </condition>
28.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
28.259 - <istrue value="${have-jdk-older-than-1.4}"/>
28.260 - </condition>
28.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
28.262 - <os family="windows"/>
28.263 - </condition>
28.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
28.265 - <isset property="debug.transport"/>
28.266 - </condition>
28.267 - </target>
28.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
28.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
28.270 - <attribute default="${main.class}" name="classname"/>
28.271 - <attribute default="${debug.classpath}" name="classpath"/>
28.272 - <element name="customize" optional="true"/>
28.273 - <sequential>
28.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
28.275 - <jvmarg line="${debug-args-line}"/>
28.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
28.277 - <jvmarg line="${run.jvmargs}"/>
28.278 - <classpath>
28.279 - <path path="@{classpath}"/>
28.280 - </classpath>
28.281 - <syspropertyset>
28.282 - <propertyref prefix="run-sys-prop."/>
28.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
28.284 - </syspropertyset>
28.285 - <customize/>
28.286 - </java>
28.287 - </sequential>
28.288 - </macrodef>
28.289 - </target>
28.290 - <target name="-init-macrodef-java">
28.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
28.292 - <attribute default="${main.class}" name="classname"/>
28.293 - <element name="customize" optional="true"/>
28.294 - <sequential>
28.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
28.296 - <jvmarg line="${run.jvmargs}"/>
28.297 - <classpath>
28.298 - <path path="${run.classpath}"/>
28.299 - </classpath>
28.300 - <syspropertyset>
28.301 - <propertyref prefix="run-sys-prop."/>
28.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
28.303 - </syspropertyset>
28.304 - <customize/>
28.305 - </java>
28.306 - </sequential>
28.307 - </macrodef>
28.308 - </target>
28.309 - <target name="-init-presetdef-jar">
28.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
28.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
28.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
28.313 - </jar>
28.314 - </presetdef>
28.315 - </target>
28.316 - <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"/>
28.317 - <!--
28.318 - ===================
28.319 - COMPILATION SECTION
28.320 - ===================
28.321 - -->
28.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
28.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
28.324 - <target depends="init" name="-check-automatic-build">
28.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
28.326 - </target>
28.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
28.328 - <antcall target="clean"/>
28.329 - </target>
28.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
28.331 - <mkdir dir="${build.classes.dir}"/>
28.332 - </target>
28.333 - <target name="-pre-compile">
28.334 - <!-- Empty placeholder for easier customization. -->
28.335 - <!-- You can override this target in the ../build.xml file. -->
28.336 - </target>
28.337 - <target if="do.depend.true" name="-compile-depend">
28.338 - <j2seproject3:depend/>
28.339 - </target>
28.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
28.341 - <j2seproject3:javac/>
28.342 - <copy todir="${build.classes.dir}">
28.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
28.344 - </copy>
28.345 - </target>
28.346 - <target name="-post-compile">
28.347 - <!-- Empty placeholder for easier customization. -->
28.348 - <!-- You can override this target in the ../build.xml file. -->
28.349 - </target>
28.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
28.351 - <target name="-pre-compile-single">
28.352 - <!-- Empty placeholder for easier customization. -->
28.353 - <!-- You can override this target in the ../build.xml file. -->
28.354 - </target>
28.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
28.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
28.357 - <j2seproject3:force-recompile/>
28.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
28.359 - </target>
28.360 - <target name="-post-compile-single">
28.361 - <!-- Empty placeholder for easier customization. -->
28.362 - <!-- You can override this target in the ../build.xml file. -->
28.363 - </target>
28.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
28.365 - <!--
28.366 - ====================
28.367 - JAR BUILDING SECTION
28.368 - ====================
28.369 - -->
28.370 - <target depends="init" name="-pre-pre-jar">
28.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
28.372 - <mkdir dir="${dist.jar.dir}"/>
28.373 - </target>
28.374 - <target name="-pre-jar">
28.375 - <!-- Empty placeholder for easier customization. -->
28.376 - <!-- You can override this target in the ../build.xml file. -->
28.377 - </target>
28.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
28.379 - <j2seproject1:jar/>
28.380 - </target>
28.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
28.382 - <j2seproject1:jar manifest="${manifest.file}"/>
28.383 - </target>
28.384 - <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">
28.385 - <j2seproject1:jar manifest="${manifest.file}">
28.386 - <j2seproject1:manifest>
28.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
28.388 - </j2seproject1:manifest>
28.389 - </j2seproject1:jar>
28.390 - <echo>To run this application from the command line without Ant, try:</echo>
28.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
28.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
28.393 - <pathconvert property="run.classpath.with.dist.jar">
28.394 - <path path="${run.classpath}"/>
28.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
28.396 - </pathconvert>
28.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
28.398 - </target>
28.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
28.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
28.401 - <pathconvert property="run.classpath.without.build.classes.dir">
28.402 - <path path="${run.classpath}"/>
28.403 - <map from="${build.classes.dir.resolved}" to=""/>
28.404 - </pathconvert>
28.405 - <pathconvert pathsep=" " property="jar.classpath">
28.406 - <path path="${run.classpath.without.build.classes.dir}"/>
28.407 - <chainedmapper>
28.408 - <flattenmapper/>
28.409 - <globmapper from="*" to="lib/*"/>
28.410 - </chainedmapper>
28.411 - </pathconvert>
28.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
28.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
28.414 - <fileset dir="${build.classes.dir}"/>
28.415 - <manifest>
28.416 - <attribute name="Main-Class" value="${main.class}"/>
28.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
28.418 - </manifest>
28.419 - </copylibs>
28.420 - <echo>To run this application from the command line without Ant, try:</echo>
28.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
28.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
28.423 - </target>
28.424 - <target name="-post-jar">
28.425 - <!-- Empty placeholder for easier customization. -->
28.426 - <!-- You can override this target in the ../build.xml file. -->
28.427 - </target>
28.428 - <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"/>
28.429 - <!--
28.430 - =================
28.431 - EXECUTION SECTION
28.432 - =================
28.433 - -->
28.434 - <target depends="init,compile" description="Run a main class." name="run">
28.435 - <j2seproject1:java>
28.436 - <customize>
28.437 - <arg line="${application.args}"/>
28.438 - </customize>
28.439 - </j2seproject1:java>
28.440 - </target>
28.441 - <target name="-do-not-recompile">
28.442 - <property name="javac.includes.binary" value=""/>
28.443 - </target>
28.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
28.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
28.446 - <j2seproject1:java classname="${run.class}"/>
28.447 - </target>
28.448 - <!--
28.449 - =================
28.450 - DEBUGGING SECTION
28.451 - =================
28.452 - -->
28.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
28.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
28.455 - </target>
28.456 - <target depends="init,compile" name="-debug-start-debuggee">
28.457 - <j2seproject3:debug>
28.458 - <customize>
28.459 - <arg line="${application.args}"/>
28.460 - </customize>
28.461 - </j2seproject3:debug>
28.462 - </target>
28.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
28.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
28.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
28.466 - </target>
28.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
28.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
28.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
28.470 - <j2seproject3:debug classname="${debug.class}"/>
28.471 - </target>
28.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
28.473 - <target depends="init" name="-pre-debug-fix">
28.474 - <fail unless="fix.includes">Must set fix.includes</fail>
28.475 - <property name="javac.includes" value="${fix.includes}.java"/>
28.476 - </target>
28.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
28.478 - <j2seproject1:nbjpdareload/>
28.479 - </target>
28.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
28.481 - <!--
28.482 - ===============
28.483 - JAVADOC SECTION
28.484 - ===============
28.485 - -->
28.486 - <target depends="init" name="-javadoc-build">
28.487 - <mkdir dir="${dist.javadoc.dir}"/>
28.488 - <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}">
28.489 - <classpath>
28.490 - <path path="${javac.classpath}"/>
28.491 - </classpath>
28.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
28.493 - <filename name="**/*.java"/>
28.494 - </fileset>
28.495 - </javadoc>
28.496 - </target>
28.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
28.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
28.499 - </target>
28.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
28.501 - <!--
28.502 - =========================
28.503 - JUNIT COMPILATION SECTION
28.504 - =========================
28.505 - -->
28.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
28.507 - <mkdir dir="${build.test.classes.dir}"/>
28.508 - </target>
28.509 - <target name="-pre-compile-test">
28.510 - <!-- Empty placeholder for easier customization. -->
28.511 - <!-- You can override this target in the ../build.xml file. -->
28.512 - </target>
28.513 - <target if="do.depend.true" name="-compile-test-depend">
28.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
28.515 - </target>
28.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
28.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
28.518 - <copy todir="${build.test.classes.dir}">
28.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
28.520 - </copy>
28.521 - </target>
28.522 - <target name="-post-compile-test">
28.523 - <!-- Empty placeholder for easier customization. -->
28.524 - <!-- You can override this target in the ../build.xml file. -->
28.525 - </target>
28.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
28.527 - <target name="-pre-compile-test-single">
28.528 - <!-- Empty placeholder for easier customization. -->
28.529 - <!-- You can override this target in the ../build.xml file. -->
28.530 - </target>
28.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
28.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
28.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
28.534 - <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}"/>
28.535 - <copy todir="${build.test.classes.dir}">
28.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
28.537 - </copy>
28.538 - </target>
28.539 - <target name="-post-compile-test-single">
28.540 - <!-- Empty placeholder for easier customization. -->
28.541 - <!-- You can override this target in the ../build.xml file. -->
28.542 - </target>
28.543 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
28.544 - <!--
28.545 - =======================
28.546 - JUNIT EXECUTION SECTION
28.547 - =======================
28.548 - -->
28.549 - <target depends="init" if="have.tests" name="-pre-test-run">
28.550 - <mkdir dir="${build.test.results.dir}"/>
28.551 - </target>
28.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
28.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
28.554 - </target>
28.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
28.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
28.557 - </target>
28.558 - <target depends="init" if="have.tests" name="test-report"/>
28.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
28.560 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
28.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
28.562 - <mkdir dir="${build.test.results.dir}"/>
28.563 - </target>
28.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
28.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
28.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
28.567 - </target>
28.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
28.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
28.570 - </target>
28.571 - <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"/>
28.572 - <!--
28.573 - =======================
28.574 - JUNIT DEBUGGING SECTION
28.575 - =======================
28.576 - -->
28.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
28.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
28.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
28.580 - <delete file="${test.report.file}"/>
28.581 - <mkdir dir="${build.test.results.dir}"/>
28.582 - <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}">
28.583 - <customize>
28.584 - <syspropertyset>
28.585 - <propertyref prefix="test-sys-prop."/>
28.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
28.587 - </syspropertyset>
28.588 - <arg value="${test.class}"/>
28.589 - <arg value="showoutput=true"/>
28.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
28.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
28.592 - </customize>
28.593 - </j2seproject3:debug>
28.594 - </target>
28.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
28.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
28.597 - </target>
28.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
28.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
28.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
28.601 - </target>
28.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
28.603 - <!--
28.604 - =========================
28.605 - APPLET EXECUTION SECTION
28.606 - =========================
28.607 - -->
28.608 - <target depends="init,compile-single" name="run-applet">
28.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
28.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
28.611 - <customize>
28.612 - <arg value="${applet.url}"/>
28.613 - </customize>
28.614 - </j2seproject1:java>
28.615 - </target>
28.616 - <!--
28.617 - =========================
28.618 - APPLET DEBUGGING SECTION
28.619 - =========================
28.620 - -->
28.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
28.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
28.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
28.624 - <customize>
28.625 - <arg value="${applet.url}"/>
28.626 - </customize>
28.627 - </j2seproject3:debug>
28.628 - </target>
28.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
28.630 - <!--
28.631 - ===============
28.632 - CLEANUP SECTION
28.633 - ===============
28.634 - -->
28.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
28.636 - <target depends="init" name="-do-clean">
28.637 - <delete dir="${build.dir}"/>
28.638 - <delete dir="${dist.dir}"/>
28.639 - </target>
28.640 - <target name="-post-clean">
28.641 - <!-- Empty placeholder for easier customization. -->
28.642 - <!-- You can override this target in the ../build.xml file. -->
28.643 - </target>
28.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
28.645 -</project>
29.1 --- a/task2/solution05/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,8 +0,0 @@
29.4 -build.xml.data.CRC32=2ab820eb
29.5 -build.xml.script.CRC32=58a52595
29.6 -build.xml.stylesheet.CRC32=be360661
29.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
29.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
29.9 -nbproject/build-impl.xml.data.CRC32=47a079e2
29.10 -nbproject/build-impl.xml.script.CRC32=f7fdafd7
29.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
30.1 --- a/task2/solution05/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,68 +0,0 @@
30.4 -application.title=currency
30.5 -application.vendor=apidesign.org
30.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
30.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
30.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
30.9 -build.classes.dir=${build.dir}/classes
30.10 -build.classes.excludes=**/*.java,**/*.form
30.11 -# This directory is removed when the project is cleaned:
30.12 -build.dir=build
30.13 -build.generated.dir=${build.dir}/generated
30.14 -# Only compile against the classpath explicitly listed here:
30.15 -build.sysclasspath=ignore
30.16 -build.test.classes.dir=${build.dir}/test/classes
30.17 -build.test.results.dir=${build.dir}/test/results
30.18 -debug.classpath=\
30.19 - ${run.classpath}
30.20 -debug.test.classpath=\
30.21 - ${run.test.classpath}
30.22 -# This directory is removed when the project is cleaned:
30.23 -dist.dir=dist
30.24 -dist.jar=${dist.dir}/currency.jar
30.25 -dist.javadoc.dir=${dist.dir}/javadoc
30.26 -excludes=
30.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
30.28 -file.reference.src-apifest08=..
30.29 -includes=**
30.30 -jar.compress=false
30.31 -javac.classpath=
30.32 -# Space-separated list of extra javac options
30.33 -javac.compilerargs=
30.34 -javac.deprecation=false
30.35 -javac.source=1.5
30.36 -javac.target=1.5
30.37 -javac.test.classpath=\
30.38 - ${javac.classpath}:\
30.39 - ${build.classes.dir}:\
30.40 - ${file.reference.junit-4.4.jar}
30.41 -javadoc.additionalparam=
30.42 -javadoc.author=false
30.43 -javadoc.encoding=
30.44 -javadoc.noindex=false
30.45 -javadoc.nonavbar=false
30.46 -javadoc.notree=false
30.47 -javadoc.private=false
30.48 -javadoc.splitindex=true
30.49 -javadoc.use=true
30.50 -javadoc.version=false
30.51 -javadoc.windowtitle=
30.52 -jnlp.codebase.type=local
30.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
30.54 -jnlp.descriptor=application
30.55 -jnlp.enabled=false
30.56 -jnlp.offline-allowed=false
30.57 -jnlp.signed=false
30.58 -meta.inf.dir=${src.dir}/META-INF
30.59 -platform.active=default_platform
30.60 -run.classpath=\
30.61 - ${javac.classpath}:\
30.62 - ${build.classes.dir}
30.63 -# Space-separated list of JVM arguments used when running the project
30.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
30.65 -# or test-sys-prop.name=value to set system properties for unit tests):
30.66 -run.jvmargs=
30.67 -run.test.classpath=\
30.68 - ${javac.test.classpath}:\
30.69 - ${build.test.classes.dir}
30.70 -src.dir=src
30.71 -test.src.dir=test
31.1 --- a/task2/solution05/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
31.3 @@ -1,16 +0,0 @@
31.4 -<?xml version="1.0" encoding="UTF-8"?>
31.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
31.6 - <type>org.netbeans.modules.java.j2seproject</type>
31.7 - <configuration>
31.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
31.9 - <name>Currency Convertor Solution 05</name>
31.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
31.11 - <source-roots>
31.12 - <root id="src.dir"/>
31.13 - </source-roots>
31.14 - <test-roots>
31.15 - <root id="test.src.dir"/>
31.16 - </test-roots>
31.17 - </data>
31.18 - </configuration>
31.19 -</project>
32.1 --- a/task2/solution05/src/org/apidesign/apifest08/currency/Amount.java Tue Oct 07 01:18:23 2008 +0200
32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
32.3 @@ -1,92 +0,0 @@
32.4 -package org.apidesign.apifest08.currency;
32.5 -
32.6 -/**
32.7 - * Amount is a class reprezenting an amount of many. It consist of
32.8 - * whole currency amount and of pence amount. Both items are long values
32.9 - * and it's not defined that the 100 pences = 1 amount. It's up to the converter
32.10 - * to verify such invariants.
32.11 - *
32.12 - * @author jindra
32.13 - */
32.14 -public final class Amount {
32.15 -
32.16 - private long amount;
32.17 - private long pence;
32.18 -
32.19 - /**
32.20 - * Construct Amount with no pences.
32.21 - *
32.22 - * @param amount the amount in some currency
32.23 - *
32.24 - */
32.25 - public Amount(long amount) {
32.26 - this.amount = amount;
32.27 - this.pence = 0;
32.28 - }
32.29 -
32.30 - /**
32.31 - * Construct Amount with the pences.
32.32 - *
32.33 - * @param amount the amount in some currency
32.34 - * @param pence the pence count
32.35 - */
32.36 - public Amount(long amount, long pence) {
32.37 - this.amount = amount;
32.38 - this.pence = pence;
32.39 - }
32.40 -
32.41 - /**
32.42 - * @return the amount
32.43 - */
32.44 - public long getAmount() {
32.45 - return amount;
32.46 - }
32.47 -
32.48 - /**
32.49 - * @param amount the amount to set
32.50 - */
32.51 - public void setAmount(long amount) {
32.52 - this.amount = amount;
32.53 - }
32.54 -
32.55 - /**
32.56 - * @return the pence
32.57 - */
32.58 - public long getPence() {
32.59 - return pence;
32.60 - }
32.61 -
32.62 - /**
32.63 - * @param pence the pence to set
32.64 - */
32.65 - public void setPence(long pence) {
32.66 - this.pence = pence;
32.67 - }
32.68 -
32.69 - @Override
32.70 - public boolean equals(Object obj) {
32.71 - if (obj == null) {
32.72 - return false;
32.73 - }
32.74 - if (!(obj instanceof Amount)) {
32.75 - return false;
32.76 - }
32.77 - Amount other = (Amount) obj;
32.78 - return (amount == other.amount) && (pence == other.pence);
32.79 - }
32.80 -
32.81 - @Override
32.82 - public int hashCode() {
32.83 - int hash = 7;
32.84 - hash = 79 * hash + (int) (this.amount ^ (this.amount >>> 32));
32.85 - hash = 79 * hash + (int) (this.pence ^ (this.pence >>> 32));
32.86 - return hash;
32.87 - }
32.88 -
32.89 - @Override
32.90 - public String toString() {
32.91 - return amount + "." + pence;
32.92 - }
32.93 -
32.94 -
32.95 -}
33.1 --- a/task2/solution05/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
33.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
33.3 @@ -1,25 +0,0 @@
33.4 -package org.apidesign.apifest08.currency;
33.5 -
33.6 -/**
33.7 - * Convertor is an interface reprezenting a convertor between currencies.
33.8 - * It's able to convert one currency to the second one and back from the second one
33.9 - * to the primary.
33.10 - */
33.11 -public interface Convertor {
33.12 -
33.13 - /**
33.14 - * Convert amount of primary currency into secondary currency
33.15 - *
33.16 - * @param amount the amount in the primary currency
33.17 - * @return an amount in the secondary currency
33.18 - */
33.19 - Amount convert(Amount primaryAmount);
33.20 -
33.21 - /**
33.22 - * Convert amount of secondary currency back into primary currency
33.23 - *
33.24 - * @param amount the amount in the secondary currency
33.25 - * @return an amount in the primary currency
33.26 - */
33.27 - Amount convertBack(Amount secondaryAmount);
33.28 -}
34.1 --- a/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,30 +0,0 @@
34.4 -package org.apidesign.apifest08.currency;
34.5 -
34.6 -/**
34.7 - * Convertor factory is a factory class for creating {@link Convertor Convertor}
34.8 - * instances.
34.9 - *
34.10 - * @author jindra
34.11 - */
34.12 -public final class ConvertorFactory {
34.13 -
34.14 - // this class needs no instances
34.15 - private ConvertorFactory() {
34.16 - }
34.17 -
34.18 -
34.19 - /**
34.20 - * Create a {@link Convertor Convertor} with given exchange rate
34.21 - *
34.22 - * @param exchangeRate double reprezenting the exchange rate from primary currency into
34.23 - * the secundary currecny
34.24 - * @return {@link Convertor Convertor} instance with given exchange rate
34.25 - */
34.26 - public static Convertor createConvertor(double exchangeRate) {
34.27 - if (exchangeRate == 0) {
34.28 - throw new IllegalArgumentException("Zero exchange rate is not allowed.");
34.29 - }
34.30 - return new ConvertorImpl(exchangeRate);
34.31 -
34.32 - }
34.33 -}
35.1 --- a/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorImpl.java Tue Oct 07 01:18:23 2008 +0200
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,56 +0,0 @@
35.4 -package org.apidesign.apifest08.currency;
35.5 -
35.6 -/**
35.7 - * ConvetorImpl it the basic implementaion of Convertor interface.
35.8 - * @see Convertor Convertor for more details.
35.9 - * The 100 pences makes 1 amount of the currency.
35.10 - *
35.11 - * @author jindra
35.12 - */
35.13 -final class ConvertorImpl implements Convertor {
35.14 -
35.15 - private static final double P_TO_AM = 100;
35.16 - private double exchangeRate;
35.17 -
35.18 - ConvertorImpl(double exchangeRate) {
35.19 - this.exchangeRate = exchangeRate;
35.20 - }
35.21 -
35.22 - public Amount convert(Amount amount) {
35.23 - verifyInput(amount);
35.24 - double result = convertToDouble(amount) * exchangeRate;
35.25 - return convertToAmount(result);
35.26 - }
35.27 -
35.28 - public Amount convertBack(Amount amount) {
35.29 - if (amount == null) {
35.30 - throw new IllegalArgumentException("Amount must be not null");
35.31 - }
35.32 - double result = convertToDouble(amount) / exchangeRate;
35.33 - return convertToAmount(result);
35.34 - }
35.35 -
35.36 - private double convertToDouble(Amount amount) {
35.37 - double am = amount.getAmount();
35.38 - double pc = amount.getPence();
35.39 - return am + (pc / P_TO_AM);
35.40 - }
35.41 -
35.42 - private Amount convertToAmount(double result) {
35.43 - long resultAm = Math.round(Math.floor(result));
35.44 - long resultPc = Math.round(Math.floor((result * P_TO_AM - resultAm * P_TO_AM)));
35.45 - return new Amount(resultAm, resultPc);
35.46 - }
35.47 -
35.48 - private void verifyInput(Amount amount) {
35.49 - if (amount == null) {
35.50 - throw new IllegalArgumentException("Amount must be not null");
35.51 - }
35.52 - if (amount.getPence() < 0) {
35.53 - throw new IllegalArgumentException("Pences must not be negative");
35.54 - }
35.55 - if (amount.getPence() > P_TO_AM) {
35.56 - throw new IllegalArgumentException("Pences must not be over P_TO_AM");
35.57 - }
35.58 - }
35.59 -}
36.1 --- a/task2/solution05/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,104 +0,0 @@
36.4 -package org.apidesign.apifest08.test;
36.5 -
36.6 -import junit.framework.TestCase;
36.7 -import org.apidesign.apifest08.currency.Amount;
36.8 -import org.apidesign.apifest08.currency.Convertor;
36.9 -import org.apidesign.apifest08.currency.ConvertorFactory;
36.10 -
36.11 -/** Finish the Convertor API, and then write bodies of methods inside
36.12 - * of this class to match the given tasks. To fullfil your task, use the
36.13 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
36.14 - * Do not you reflection, or other hacks as your code
36.15 - * shall run without any runtime permissions.
36.16 - */
36.17 -public class Task1Test extends TestCase {
36.18 - public Task1Test(String testName) {
36.19 - super(testName);
36.20 - }
36.21 -
36.22 - @Override
36.23 - protected void setUp() throws Exception {
36.24 - }
36.25 -
36.26 - @Override
36.27 - protected void tearDown() throws Exception {
36.28 - }
36.29 -
36.30 - /** Create convertor that understands two currencies, CZK and
36.31 - * USD. Make 1 USD == 17 CZK.
36.32 - *
36.33 - * Creation of the convertor shall not require subclassing of any class
36.34 - * or interface on the client side.
36.35 - *
36.36 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
36.37 - */
36.38 - public static Convertor createCZKtoUSD() {
36.39 - return ConvertorFactory.createConvertor(17);
36.40 - }
36.41 -
36.42 - /** Create convertor that understands two currencies, CZK and
36.43 - * SKK. Make 100 SKK == 80 CZK.
36.44 - *
36.45 - * Creation of the convertor shall not require subclassing of any class
36.46 - * or interface on the client side.
36.47 - *
36.48 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
36.49 - */
36.50 - public static Convertor createSKKtoCZK() {
36.51 - return ConvertorFactory.createConvertor(0.8);
36.52 - }
36.53 -
36.54 - /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
36.55 - * with it.
36.56 - */
36.57 - public void testCurrencyCZKUSD() throws Exception {
36.58 - Convertor c = createCZKtoUSD();
36.59 - // convert $5 to CZK using c:
36.60 - assertEquals("Result is 85 CZK", 85l, c.convert(new Amount(5)).getAmount());
36.61 -
36.62 - // convert $8 to CZK
36.63 - assertEquals("Result is 136 CZK", 136l, c.convert(new Amount(8)).getAmount());
36.64 -
36.65 - // convert 1003CZK to USD
36.66 - assertEquals("Result is 136 CZK", 59l, c.convertBack(new Amount(1003)).getAmount());
36.67 - // assertEquals("Result is 59 USD");
36.68 - }
36.69 -
36.70 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
36.71 - * with it.
36.72 - */
36.73 - public void testCurrencySKKCZK() throws Exception {
36.74 - Convertor c = createSKKtoCZK();
36.75 - // convert 16CZK using c:
36.76 - assertEquals("Result is 20 SKK", 20l, c.convertBack(new Amount(16)).getAmount());
36.77 -
36.78 - // convert 500SKK to CZK
36.79 - assertEquals("Result is 400 CZK", 400l, c.convert(new Amount(500)).getAmount());
36.80 - }
36.81 -
36.82 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
36.83 - * with it.
36.84 - */
36.85 - public void testCurrencySKKCZKwithPences() throws Exception {
36.86 - Convertor c = createSKKtoCZK();
36.87 - // convert 16CZK 16h using c:
36.88 - assertEquals("Result is 20 SKK 20h", new Amount(20, 20), c.convertBack(new Amount(16, 16)));
36.89 -
36.90 - // convert 500SKK 80h to CZK
36.91 - assertEquals("Result is 400 CZK 64h", new Amount(400, 64), c.convert(new Amount(500, 80)));
36.92 -
36.93 - // convert 400CZK 80h to SKK
36.94 - assertEquals("Result is 501 CZK", new Amount(501), c.convertBack(new Amount(400, 80)));
36.95 - }
36.96 -
36.97 - public void testNegativeSKKCZ() throws Exception{
36.98 - Convertor c = createSKKtoCZK();
36.99 - // convert -16CZK using c:
36.100 - assertEquals("Result is -20", new Amount(-20), c.convertBack(new Amount(-16)));
36.101 -
36.102 - // convert -500SKK 80h to CZK
36.103 - assertEquals("Result is -400CZK 64h", new Amount(-400, 64), c.convert(new Amount(-500, 80)));
36.104 -
36.105 - }
36.106 -}
36.107 -
37.1 --- a/task2/solution08/build.xml Tue Oct 07 01:18:23 2008 +0200
37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
37.3 @@ -1,69 +0,0 @@
37.4 -<?xml version="1.0" encoding="UTF-8"?>
37.5 -<!-- You may freely edit this file. See commented blocks below for -->
37.6 -<!-- some examples of how to customize the build. -->
37.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
37.8 -<project name="currency" default="default" basedir=".">
37.9 - <description>Builds, tests, and runs the project.</description>
37.10 - <import file="nbproject/build-impl.xml"/>
37.11 - <!--
37.12 -
37.13 - There exist several targets which are by default empty and which can be
37.14 - used for execution of your tasks. These targets are usually executed
37.15 - before and after some main targets. They are:
37.16 -
37.17 - -pre-init: called before initialization of project properties
37.18 - -post-init: called after initialization of project properties
37.19 - -pre-compile: called before javac compilation
37.20 - -post-compile: called after javac compilation
37.21 - -pre-compile-single: called before javac compilation of single file
37.22 - -post-compile-single: called after javac compilation of single file
37.23 - -pre-compile-test: called before javac compilation of JUnit tests
37.24 - -post-compile-test: called after javac compilation of JUnit tests
37.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
37.26 - -post-compile-test-single: called after javac compilation of single JUunit test
37.27 - -pre-jar: called before JAR building
37.28 - -post-jar: called after JAR building
37.29 - -post-clean: called after cleaning build products
37.30 -
37.31 - (Targets beginning with '-' are not intended to be called on their own.)
37.32 -
37.33 - Example of inserting an obfuscator after compilation could look like this:
37.34 -
37.35 - <target name="-post-compile">
37.36 - <obfuscate>
37.37 - <fileset dir="${build.classes.dir}"/>
37.38 - </obfuscate>
37.39 - </target>
37.40 -
37.41 - For list of available properties check the imported
37.42 - nbproject/build-impl.xml file.
37.43 -
37.44 -
37.45 - Another way to customize the build is by overriding existing main targets.
37.46 - The targets of interest are:
37.47 -
37.48 - -init-macrodef-javac: defines macro for javac compilation
37.49 - -init-macrodef-junit: defines macro for junit execution
37.50 - -init-macrodef-debug: defines macro for class debugging
37.51 - -init-macrodef-java: defines macro for class execution
37.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
37.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
37.54 - run: execution of project
37.55 - -javadoc-build: Javadoc generation
37.56 - test-report: JUnit report generation
37.57 -
37.58 - An example of overriding the target for project execution could look like this:
37.59 -
37.60 - <target name="run" depends="currency-impl.jar">
37.61 - <exec dir="bin" executable="launcher.exe">
37.62 - <arg file="${dist.jar}"/>
37.63 - </exec>
37.64 - </target>
37.65 -
37.66 - Notice that the overridden target depends on the jar target and not only on
37.67 - the compile target as the regular run target does. Again, for a list of available
37.68 - properties which you can use, check the target you are overriding in the
37.69 - nbproject/build-impl.xml file.
37.70 -
37.71 - -->
37.72 -</project>
38.1 --- a/task2/solution08/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
38.3 @@ -1,642 +0,0 @@
38.4 -<?xml version="1.0" encoding="UTF-8"?>
38.5 -<!--
38.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
38.7 -*** EDIT ../build.xml INSTEAD ***
38.8 -
38.9 -For the purpose of easier reading the script
38.10 -is divided into following sections:
38.11 -
38.12 - - initialization
38.13 - - compilation
38.14 - - jar
38.15 - - execution
38.16 - - debugging
38.17 - - javadoc
38.18 - - junit compilation
38.19 - - junit execution
38.20 - - junit debugging
38.21 - - applet
38.22 - - cleanup
38.23 -
38.24 - -->
38.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" 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="Currency_Convertor_Solution_08-impl">
38.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
38.27 - <!--
38.28 - ======================
38.29 - INITIALIZATION SECTION
38.30 - ======================
38.31 - -->
38.32 - <target name="-pre-init">
38.33 - <!-- Empty placeholder for easier customization. -->
38.34 - <!-- You can override this target in the ../build.xml file. -->
38.35 - </target>
38.36 - <target depends="-pre-init" name="-init-private">
38.37 - <property file="nbproject/private/config.properties"/>
38.38 - <property file="nbproject/private/configs/${config}.properties"/>
38.39 - <property file="nbproject/private/private.properties"/>
38.40 - </target>
38.41 - <target depends="-pre-init,-init-private" name="-init-user">
38.42 - <property file="${user.properties.file}"/>
38.43 - <!-- The two properties below are usually overridden -->
38.44 - <!-- by the active platform. Just a fallback. -->
38.45 - <property name="default.javac.source" value="1.4"/>
38.46 - <property name="default.javac.target" value="1.4"/>
38.47 - </target>
38.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
38.49 - <property file="nbproject/configs/${config}.properties"/>
38.50 - <property file="nbproject/project.properties"/>
38.51 - </target>
38.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
38.53 - <available file="${manifest.file}" property="manifest.available"/>
38.54 - <condition property="manifest.available+main.class">
38.55 - <and>
38.56 - <isset property="manifest.available"/>
38.57 - <isset property="main.class"/>
38.58 - <not>
38.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
38.60 - </not>
38.61 - </and>
38.62 - </condition>
38.63 - <condition property="manifest.available+main.class+mkdist.available">
38.64 - <and>
38.65 - <istrue value="${manifest.available+main.class}"/>
38.66 - <isset property="libs.CopyLibs.classpath"/>
38.67 - </and>
38.68 - </condition>
38.69 - <condition property="have.tests">
38.70 - <or>
38.71 - <available file="${test.src.dir}"/>
38.72 - </or>
38.73 - </condition>
38.74 - <condition property="have.sources">
38.75 - <or>
38.76 - <available file="${src.dir}"/>
38.77 - </or>
38.78 - </condition>
38.79 - <condition property="netbeans.home+have.tests">
38.80 - <and>
38.81 - <isset property="netbeans.home"/>
38.82 - <isset property="have.tests"/>
38.83 - </and>
38.84 - </condition>
38.85 - <condition property="no.javadoc.preview">
38.86 - <and>
38.87 - <isset property="javadoc.preview"/>
38.88 - <isfalse value="${javadoc.preview}"/>
38.89 - </and>
38.90 - </condition>
38.91 - <property name="run.jvmargs" value=""/>
38.92 - <property name="javac.compilerargs" value=""/>
38.93 - <property name="work.dir" value="${basedir}"/>
38.94 - <condition property="no.deps">
38.95 - <and>
38.96 - <istrue value="${no.dependencies}"/>
38.97 - </and>
38.98 - </condition>
38.99 - <property name="javac.debug" value="true"/>
38.100 - <property name="javadoc.preview" value="true"/>
38.101 - <property name="application.args" value=""/>
38.102 - <property name="source.encoding" value="${file.encoding}"/>
38.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
38.104 - <and>
38.105 - <isset property="javadoc.encoding"/>
38.106 - <not>
38.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
38.108 - </not>
38.109 - </and>
38.110 - </condition>
38.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
38.112 - <property name="includes" value="**"/>
38.113 - <property name="excludes" value=""/>
38.114 - <property name="do.depend" value="false"/>
38.115 - <condition property="do.depend.true">
38.116 - <istrue value="${do.depend}"/>
38.117 - </condition>
38.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
38.119 - <and>
38.120 - <isset property="jaxws.endorsed.dir"/>
38.121 - <available file="nbproject/jaxws-build.xml"/>
38.122 - </and>
38.123 - </condition>
38.124 - </target>
38.125 - <target name="-post-init">
38.126 - <!-- Empty placeholder for easier customization. -->
38.127 - <!-- You can override this target in the ../build.xml file. -->
38.128 - </target>
38.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
38.130 - <fail unless="src.dir">Must set src.dir</fail>
38.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
38.132 - <fail unless="build.dir">Must set build.dir</fail>
38.133 - <fail unless="dist.dir">Must set dist.dir</fail>
38.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
38.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
38.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
38.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
38.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
38.139 - <fail unless="dist.jar">Must set dist.jar</fail>
38.140 - </target>
38.141 - <target name="-init-macrodef-property">
38.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
38.143 - <attribute name="name"/>
38.144 - <attribute name="value"/>
38.145 - <sequential>
38.146 - <property name="@{name}" value="${@{value}}"/>
38.147 - </sequential>
38.148 - </macrodef>
38.149 - </target>
38.150 - <target name="-init-macrodef-javac">
38.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
38.152 - <attribute default="${src.dir}" name="srcdir"/>
38.153 - <attribute default="${build.classes.dir}" name="destdir"/>
38.154 - <attribute default="${javac.classpath}" name="classpath"/>
38.155 - <attribute default="${includes}" name="includes"/>
38.156 - <attribute default="${excludes}" name="excludes"/>
38.157 - <attribute default="${javac.debug}" name="debug"/>
38.158 - <attribute default="" name="sourcepath"/>
38.159 - <element name="customize" optional="true"/>
38.160 - <sequential>
38.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}">
38.162 - <classpath>
38.163 - <path path="@{classpath}"/>
38.164 - </classpath>
38.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
38.166 - <customize/>
38.167 - </javac>
38.168 - </sequential>
38.169 - </macrodef>
38.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
38.171 - <attribute default="${src.dir}" name="srcdir"/>
38.172 - <attribute default="${build.classes.dir}" name="destdir"/>
38.173 - <attribute default="${javac.classpath}" name="classpath"/>
38.174 - <sequential>
38.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
38.176 - <classpath>
38.177 - <path path="@{classpath}"/>
38.178 - </classpath>
38.179 - </depend>
38.180 - </sequential>
38.181 - </macrodef>
38.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
38.183 - <attribute default="${build.classes.dir}" name="destdir"/>
38.184 - <sequential>
38.185 - <fail unless="javac.includes">Must set javac.includes</fail>
38.186 - <pathconvert pathsep="," property="javac.includes.binary">
38.187 - <path>
38.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
38.189 - </path>
38.190 - <globmapper from="*.java" to="*.class"/>
38.191 - </pathconvert>
38.192 - <delete>
38.193 - <files includes="${javac.includes.binary}"/>
38.194 - </delete>
38.195 - </sequential>
38.196 - </macrodef>
38.197 - </target>
38.198 - <target name="-init-macrodef-junit">
38.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
38.200 - <attribute default="${includes}" name="includes"/>
38.201 - <attribute default="${excludes}" name="excludes"/>
38.202 - <attribute default="**" name="testincludes"/>
38.203 - <sequential>
38.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
38.205 - <batchtest todir="${build.test.results.dir}">
38.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
38.207 - <filename name="@{testincludes}"/>
38.208 - </fileset>
38.209 - </batchtest>
38.210 - <classpath>
38.211 - <path path="${run.test.classpath}"/>
38.212 - </classpath>
38.213 - <syspropertyset>
38.214 - <propertyref prefix="test-sys-prop."/>
38.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
38.216 - </syspropertyset>
38.217 - <formatter type="brief" usefile="false"/>
38.218 - <formatter type="xml"/>
38.219 - <jvmarg line="${run.jvmargs}"/>
38.220 - </junit>
38.221 - </sequential>
38.222 - </macrodef>
38.223 - </target>
38.224 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
38.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
38.226 - <attribute default="${main.class}" name="name"/>
38.227 - <attribute default="${debug.classpath}" name="classpath"/>
38.228 - <attribute default="" name="stopclassname"/>
38.229 - <sequential>
38.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
38.231 - <classpath>
38.232 - <path path="@{classpath}"/>
38.233 - </classpath>
38.234 - </nbjpdastart>
38.235 - </sequential>
38.236 - </macrodef>
38.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
38.238 - <attribute default="${build.classes.dir}" name="dir"/>
38.239 - <sequential>
38.240 - <nbjpdareload>
38.241 - <fileset dir="@{dir}" includes="${fix.classes}">
38.242 - <include name="${fix.includes}*.class"/>
38.243 - </fileset>
38.244 - </nbjpdareload>
38.245 - </sequential>
38.246 - </macrodef>
38.247 - </target>
38.248 - <target name="-init-debug-args">
38.249 - <property name="version-output" value="java version "${ant.java.version}"/>
38.250 - <condition property="have-jdk-older-than-1.4">
38.251 - <or>
38.252 - <contains string="${version-output}" substring="java version "1.0"/>
38.253 - <contains string="${version-output}" substring="java version "1.1"/>
38.254 - <contains string="${version-output}" substring="java version "1.2"/>
38.255 - <contains string="${version-output}" substring="java version "1.3"/>
38.256 - </or>
38.257 - </condition>
38.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
38.259 - <istrue value="${have-jdk-older-than-1.4}"/>
38.260 - </condition>
38.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
38.262 - <os family="windows"/>
38.263 - </condition>
38.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
38.265 - <isset property="debug.transport"/>
38.266 - </condition>
38.267 - </target>
38.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
38.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
38.270 - <attribute default="${main.class}" name="classname"/>
38.271 - <attribute default="${debug.classpath}" name="classpath"/>
38.272 - <element name="customize" optional="true"/>
38.273 - <sequential>
38.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
38.275 - <jvmarg line="${debug-args-line}"/>
38.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
38.277 - <jvmarg line="${run.jvmargs}"/>
38.278 - <classpath>
38.279 - <path path="@{classpath}"/>
38.280 - </classpath>
38.281 - <syspropertyset>
38.282 - <propertyref prefix="run-sys-prop."/>
38.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
38.284 - </syspropertyset>
38.285 - <customize/>
38.286 - </java>
38.287 - </sequential>
38.288 - </macrodef>
38.289 - </target>
38.290 - <target name="-init-macrodef-java">
38.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
38.292 - <attribute default="${main.class}" name="classname"/>
38.293 - <element name="customize" optional="true"/>
38.294 - <sequential>
38.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
38.296 - <jvmarg line="${run.jvmargs}"/>
38.297 - <classpath>
38.298 - <path path="${run.classpath}"/>
38.299 - </classpath>
38.300 - <syspropertyset>
38.301 - <propertyref prefix="run-sys-prop."/>
38.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
38.303 - </syspropertyset>
38.304 - <customize/>
38.305 - </java>
38.306 - </sequential>
38.307 - </macrodef>
38.308 - </target>
38.309 - <target name="-init-presetdef-jar">
38.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
38.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
38.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
38.313 - </jar>
38.314 - </presetdef>
38.315 - </target>
38.316 - <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"/>
38.317 - <!--
38.318 - ===================
38.319 - COMPILATION SECTION
38.320 - ===================
38.321 - -->
38.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
38.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
38.324 - <target depends="init" name="-check-automatic-build">
38.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
38.326 - </target>
38.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
38.328 - <antcall target="clean"/>
38.329 - </target>
38.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
38.331 - <mkdir dir="${build.classes.dir}"/>
38.332 - </target>
38.333 - <target name="-pre-compile">
38.334 - <!-- Empty placeholder for easier customization. -->
38.335 - <!-- You can override this target in the ../build.xml file. -->
38.336 - </target>
38.337 - <target if="do.depend.true" name="-compile-depend">
38.338 - <j2seproject3:depend/>
38.339 - </target>
38.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
38.341 - <j2seproject3:javac/>
38.342 - <copy todir="${build.classes.dir}">
38.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
38.344 - </copy>
38.345 - </target>
38.346 - <target name="-post-compile">
38.347 - <!-- Empty placeholder for easier customization. -->
38.348 - <!-- You can override this target in the ../build.xml file. -->
38.349 - </target>
38.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
38.351 - <target name="-pre-compile-single">
38.352 - <!-- Empty placeholder for easier customization. -->
38.353 - <!-- You can override this target in the ../build.xml file. -->
38.354 - </target>
38.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
38.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
38.357 - <j2seproject3:force-recompile/>
38.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
38.359 - </target>
38.360 - <target name="-post-compile-single">
38.361 - <!-- Empty placeholder for easier customization. -->
38.362 - <!-- You can override this target in the ../build.xml file. -->
38.363 - </target>
38.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
38.365 - <!--
38.366 - ====================
38.367 - JAR BUILDING SECTION
38.368 - ====================
38.369 - -->
38.370 - <target depends="init" name="-pre-pre-jar">
38.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
38.372 - <mkdir dir="${dist.jar.dir}"/>
38.373 - </target>
38.374 - <target name="-pre-jar">
38.375 - <!-- Empty placeholder for easier customization. -->
38.376 - <!-- You can override this target in the ../build.xml file. -->
38.377 - </target>
38.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
38.379 - <j2seproject1:jar/>
38.380 - </target>
38.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
38.382 - <j2seproject1:jar manifest="${manifest.file}"/>
38.383 - </target>
38.384 - <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">
38.385 - <j2seproject1:jar manifest="${manifest.file}">
38.386 - <j2seproject1:manifest>
38.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
38.388 - </j2seproject1:manifest>
38.389 - </j2seproject1:jar>
38.390 - <echo>To run this application from the command line without Ant, try:</echo>
38.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
38.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
38.393 - <pathconvert property="run.classpath.with.dist.jar">
38.394 - <path path="${run.classpath}"/>
38.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
38.396 - </pathconvert>
38.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
38.398 - </target>
38.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
38.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
38.401 - <pathconvert property="run.classpath.without.build.classes.dir">
38.402 - <path path="${run.classpath}"/>
38.403 - <map from="${build.classes.dir.resolved}" to=""/>
38.404 - </pathconvert>
38.405 - <pathconvert pathsep=" " property="jar.classpath">
38.406 - <path path="${run.classpath.without.build.classes.dir}"/>
38.407 - <chainedmapper>
38.408 - <flattenmapper/>
38.409 - <globmapper from="*" to="lib/*"/>
38.410 - </chainedmapper>
38.411 - </pathconvert>
38.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
38.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
38.414 - <fileset dir="${build.classes.dir}"/>
38.415 - <manifest>
38.416 - <attribute name="Main-Class" value="${main.class}"/>
38.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
38.418 - </manifest>
38.419 - </copylibs>
38.420 - <echo>To run this application from the command line without Ant, try:</echo>
38.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
38.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
38.423 - </target>
38.424 - <target name="-post-jar">
38.425 - <!-- Empty placeholder for easier customization. -->
38.426 - <!-- You can override this target in the ../build.xml file. -->
38.427 - </target>
38.428 - <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"/>
38.429 - <!--
38.430 - =================
38.431 - EXECUTION SECTION
38.432 - =================
38.433 - -->
38.434 - <target depends="init,compile" description="Run a main class." name="run">
38.435 - <j2seproject1:java>
38.436 - <customize>
38.437 - <arg line="${application.args}"/>
38.438 - </customize>
38.439 - </j2seproject1:java>
38.440 - </target>
38.441 - <target name="-do-not-recompile">
38.442 - <property name="javac.includes.binary" value=""/>
38.443 - </target>
38.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
38.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
38.446 - <j2seproject1:java classname="${run.class}"/>
38.447 - </target>
38.448 - <!--
38.449 - =================
38.450 - DEBUGGING SECTION
38.451 - =================
38.452 - -->
38.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
38.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
38.455 - </target>
38.456 - <target depends="init,compile" name="-debug-start-debuggee">
38.457 - <j2seproject3:debug>
38.458 - <customize>
38.459 - <arg line="${application.args}"/>
38.460 - </customize>
38.461 - </j2seproject3:debug>
38.462 - </target>
38.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
38.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
38.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
38.466 - </target>
38.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
38.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
38.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
38.470 - <j2seproject3:debug classname="${debug.class}"/>
38.471 - </target>
38.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
38.473 - <target depends="init" name="-pre-debug-fix">
38.474 - <fail unless="fix.includes">Must set fix.includes</fail>
38.475 - <property name="javac.includes" value="${fix.includes}.java"/>
38.476 - </target>
38.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
38.478 - <j2seproject1:nbjpdareload/>
38.479 - </target>
38.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
38.481 - <!--
38.482 - ===============
38.483 - JAVADOC SECTION
38.484 - ===============
38.485 - -->
38.486 - <target depends="init" name="-javadoc-build">
38.487 - <mkdir dir="${dist.javadoc.dir}"/>
38.488 - <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}">
38.489 - <classpath>
38.490 - <path path="${javac.classpath}"/>
38.491 - </classpath>
38.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
38.493 - <filename name="**/*.java"/>
38.494 - </fileset>
38.495 - </javadoc>
38.496 - </target>
38.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
38.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
38.499 - </target>
38.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
38.501 - <!--
38.502 - =========================
38.503 - JUNIT COMPILATION SECTION
38.504 - =========================
38.505 - -->
38.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
38.507 - <mkdir dir="${build.test.classes.dir}"/>
38.508 - </target>
38.509 - <target name="-pre-compile-test">
38.510 - <!-- Empty placeholder for easier customization. -->
38.511 - <!-- You can override this target in the ../build.xml file. -->
38.512 - </target>
38.513 - <target if="do.depend.true" name="-compile-test-depend">
38.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
38.515 - </target>
38.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
38.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
38.518 - <copy todir="${build.test.classes.dir}">
38.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
38.520 - </copy>
38.521 - </target>
38.522 - <target name="-post-compile-test">
38.523 - <!-- Empty placeholder for easier customization. -->
38.524 - <!-- You can override this target in the ../build.xml file. -->
38.525 - </target>
38.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
38.527 - <target name="-pre-compile-test-single">
38.528 - <!-- Empty placeholder for easier customization. -->
38.529 - <!-- You can override this target in the ../build.xml file. -->
38.530 - </target>
38.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
38.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
38.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
38.534 - <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}"/>
38.535 - <copy todir="${build.test.classes.dir}">
38.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
38.537 - </copy>
38.538 - </target>
38.539 - <target name="-post-compile-test-single">
38.540 - <!-- Empty placeholder for easier customization. -->
38.541 - <!-- You can override this target in the ../build.xml file. -->
38.542 - </target>
38.543 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
38.544 - <!--
38.545 - =======================
38.546 - JUNIT EXECUTION SECTION
38.547 - =======================
38.548 - -->
38.549 - <target depends="init" if="have.tests" name="-pre-test-run">
38.550 - <mkdir dir="${build.test.results.dir}"/>
38.551 - </target>
38.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
38.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
38.554 - </target>
38.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
38.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
38.557 - </target>
38.558 - <target depends="init" if="have.tests" name="test-report"/>
38.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
38.560 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
38.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
38.562 - <mkdir dir="${build.test.results.dir}"/>
38.563 - </target>
38.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
38.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
38.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
38.567 - </target>
38.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
38.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
38.570 - </target>
38.571 - <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"/>
38.572 - <!--
38.573 - =======================
38.574 - JUNIT DEBUGGING SECTION
38.575 - =======================
38.576 - -->
38.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
38.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
38.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
38.580 - <delete file="${test.report.file}"/>
38.581 - <mkdir dir="${build.test.results.dir}"/>
38.582 - <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}">
38.583 - <customize>
38.584 - <syspropertyset>
38.585 - <propertyref prefix="test-sys-prop."/>
38.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
38.587 - </syspropertyset>
38.588 - <arg value="${test.class}"/>
38.589 - <arg value="showoutput=true"/>
38.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
38.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
38.592 - </customize>
38.593 - </j2seproject3:debug>
38.594 - </target>
38.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
38.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
38.597 - </target>
38.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
38.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
38.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
38.601 - </target>
38.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
38.603 - <!--
38.604 - =========================
38.605 - APPLET EXECUTION SECTION
38.606 - =========================
38.607 - -->
38.608 - <target depends="init,compile-single" name="run-applet">
38.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
38.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
38.611 - <customize>
38.612 - <arg value="${applet.url}"/>
38.613 - </customize>
38.614 - </j2seproject1:java>
38.615 - </target>
38.616 - <!--
38.617 - =========================
38.618 - APPLET DEBUGGING SECTION
38.619 - =========================
38.620 - -->
38.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
38.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
38.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
38.624 - <customize>
38.625 - <arg value="${applet.url}"/>
38.626 - </customize>
38.627 - </j2seproject3:debug>
38.628 - </target>
38.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
38.630 - <!--
38.631 - ===============
38.632 - CLEANUP SECTION
38.633 - ===============
38.634 - -->
38.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
38.636 - <target depends="init" name="-do-clean">
38.637 - <delete dir="${build.dir}"/>
38.638 - <delete dir="${dist.dir}"/>
38.639 - </target>
38.640 - <target name="-post-clean">
38.641 - <!-- Empty placeholder for easier customization. -->
38.642 - <!-- You can override this target in the ../build.xml file. -->
38.643 - </target>
38.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
38.645 -</project>
39.1 --- a/task2/solution08/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,8 +0,0 @@
39.4 -build.xml.data.CRC32=2ab820eb
39.5 -build.xml.script.CRC32=58a52595
39.6 -build.xml.stylesheet.CRC32=be360661
39.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
39.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
39.9 -nbproject/build-impl.xml.data.CRC32=a2ad29dd
39.10 -nbproject/build-impl.xml.script.CRC32=43c3e6a6
39.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
40.1 --- a/task2/solution08/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,68 +0,0 @@
40.4 -application.title=currency
40.5 -application.vendor=apidesign.org
40.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
40.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
40.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
40.9 -build.classes.dir=${build.dir}/classes
40.10 -build.classes.excludes=**/*.java,**/*.form
40.11 -# This directory is removed when the project is cleaned:
40.12 -build.dir=build
40.13 -build.generated.dir=${build.dir}/generated
40.14 -# Only compile against the classpath explicitly listed here:
40.15 -build.sysclasspath=ignore
40.16 -build.test.classes.dir=${build.dir}/test/classes
40.17 -build.test.results.dir=${build.dir}/test/results
40.18 -debug.classpath=\
40.19 - ${run.classpath}
40.20 -debug.test.classpath=\
40.21 - ${run.test.classpath}
40.22 -# This directory is removed when the project is cleaned:
40.23 -dist.dir=dist
40.24 -dist.jar=${dist.dir}/currency.jar
40.25 -dist.javadoc.dir=${dist.dir}/javadoc
40.26 -excludes=
40.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
40.28 -file.reference.src-apifest08=..
40.29 -includes=**
40.30 -jar.compress=false
40.31 -javac.classpath=
40.32 -# Space-separated list of extra javac options
40.33 -javac.compilerargs=
40.34 -javac.deprecation=false
40.35 -javac.source=1.5
40.36 -javac.target=1.5
40.37 -javac.test.classpath=\
40.38 - ${javac.classpath}:\
40.39 - ${build.classes.dir}:\
40.40 - ${file.reference.junit-4.4.jar}
40.41 -javadoc.additionalparam=
40.42 -javadoc.author=false
40.43 -javadoc.encoding=
40.44 -javadoc.noindex=false
40.45 -javadoc.nonavbar=false
40.46 -javadoc.notree=false
40.47 -javadoc.private=false
40.48 -javadoc.splitindex=true
40.49 -javadoc.use=true
40.50 -javadoc.version=false
40.51 -javadoc.windowtitle=
40.52 -jnlp.codebase.type=local
40.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
40.54 -jnlp.descriptor=application
40.55 -jnlp.enabled=false
40.56 -jnlp.offline-allowed=false
40.57 -jnlp.signed=false
40.58 -meta.inf.dir=${src.dir}/META-INF
40.59 -platform.active=default_platform
40.60 -run.classpath=\
40.61 - ${javac.classpath}:\
40.62 - ${build.classes.dir}
40.63 -# Space-separated list of JVM arguments used when running the project
40.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
40.65 -# or test-sys-prop.name=value to set system properties for unit tests):
40.66 -run.jvmargs=
40.67 -run.test.classpath=\
40.68 - ${javac.test.classpath}:\
40.69 - ${build.test.classes.dir}
40.70 -src.dir=src
40.71 -test.src.dir=test
41.1 --- a/task2/solution08/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,16 +0,0 @@
41.4 -<?xml version="1.0" encoding="UTF-8"?>
41.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
41.6 - <type>org.netbeans.modules.java.j2seproject</type>
41.7 - <configuration>
41.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
41.9 - <name>Currency Convertor Solution 08</name>
41.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
41.11 - <source-roots>
41.12 - <root id="src.dir"/>
41.13 - </source-roots>
41.14 - <test-roots>
41.15 - <root id="test.src.dir"/>
41.16 - </test-roots>
41.17 - </data>
41.18 - </configuration>
41.19 -</project>
42.1 --- a/task2/solution08/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
42.3 @@ -1,55 +0,0 @@
42.4 -package org.apidesign.apifest08.currency;
42.5 -
42.6 -import java.util.Currency;
42.7 -import java.util.Hashtable;
42.8 -import java.util.Map;
42.9 -
42.10 -/** This is the skeleton class for your API. You need to make it public, so
42.11 - * it is accessible to your client code (currently in Task1Test.java) file.
42.12 - * <p>
42.13 - * Feel free to create additional classes or rename this one, just keep all
42.14 - * the API and its implementation in this package. Do not spread it outside
42.15 - * to other packages.
42.16 - */
42.17 -public class Convertor {
42.18 -
42.19 - private static final Map<String, Float> EXCHANGE_RATES = new Hashtable<String, Float>() { {
42.20 - put("CZKUSD", 1/17F);
42.21 - put("USDCZK", 17F);
42.22 - put("SKKCZK", 100/80F);
42.23 - put("CZKSKK", 80/100F);
42.24 - }
42.25 - };
42.26 -
42.27 - private Currency currencyFirst;
42.28 - private Currency currencySecond;
42.29 -
42.30 - private Convertor(Currency currencyFirst, Currency currencySecond) {
42.31 - this.currencyFirst = currencyFirst;
42.32 - this.currencySecond = currencySecond;
42.33 - }
42.34 -
42.35 - public static Convertor getInstanceFor(Currency currencyFirst, Currency currencySecond) {
42.36 - return new Convertor(currencyFirst, currencySecond);
42.37 - }
42.38 -
42.39 - public float convert(float value, Currency toCurrency) {
42.40 - if (!toCurrency.equals(currencyFirst) && !toCurrency.equals(currencySecond)) {
42.41 - throw new IllegalArgumentException("Unsupported currency for this convertor!: " + toCurrency.getCurrencyCode());
42.42 - }
42.43 -
42.44 - Float rate = null;
42.45 - if (toCurrency.equals(currencyFirst)) {
42.46 - rate = EXCHANGE_RATES.get(currencyFirst.getCurrencyCode() + currencySecond.getCurrencyCode());
42.47 - }
42.48 - if (toCurrency.equals(currencySecond)) {
42.49 - rate = EXCHANGE_RATES.get(currencySecond.getCurrencyCode() + currencyFirst.getCurrencyCode());
42.50 - }
42.51 -
42.52 - if (rate == null) {
42.53 - throw new IllegalStateException("Undefinied conversion!");
42.54 - }
42.55 -
42.56 - return rate*value;
42.57 - }
42.58 -}
43.1 --- a/task2/solution08/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,86 +0,0 @@
43.4 -package org.apidesign.apifest08.test;
43.5 -
43.6 -import java.util.Currency;
43.7 -import junit.framework.TestCase;
43.8 -import org.apidesign.apifest08.currency.Convertor;
43.9 -
43.10 -/** Finish the Convertor API, and then write bodies of methods inside
43.11 - * of this class to match the given tasks. To fullfil your task, use the
43.12 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
43.13 - * Do not you reflection, or other hacks as your code
43.14 - * shall run without any runtime permissions.
43.15 - */
43.16 -public class Task1Test extends TestCase {
43.17 - public Task1Test(String testName) {
43.18 - super(testName);
43.19 - }
43.20 -
43.21 - @Override
43.22 - protected void setUp() throws Exception {
43.23 - }
43.24 -
43.25 - @Override
43.26 - protected void tearDown() throws Exception {
43.27 - }
43.28 -
43.29 - /** Create convertor that understands two currencies, CZK and
43.30 - * USD. Make 1 USD == 17 CZK.
43.31 - *
43.32 - * Creation of the convertor shall not require subclassing of any class
43.33 - * or interface on the client side.
43.34 - *
43.35 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
43.36 - */
43.37 - public static Convertor createCZKtoUSD() {
43.38 - return Convertor.getInstanceFor(Currency.getInstance("CZK"), Currency.getInstance("USD"));
43.39 - }
43.40 -
43.41 - /** Create convertor that understands two currencies, CZK and
43.42 - * SKK. Make 100 SKK == 80 CZK.
43.43 - *
43.44 - * Creation of the convertor shall not require subclassing of any class
43.45 - * or interface on the client side.
43.46 - *
43.47 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
43.48 - */
43.49 - public static Convertor createSKKtoCZK() {
43.50 - return Convertor.getInstanceFor(Currency.getInstance("SKK"), Currency.getInstance("CZK"));
43.51 - }
43.52 -
43.53 - /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
43.54 - * with it.
43.55 - */
43.56 - public void testCurrencyCZKUSD() throws Exception {
43.57 - Convertor c = createCZKtoUSD();
43.58 - Currency usd = Currency.getInstance("USD");
43.59 - Currency czk = Currency.getInstance("CZK");
43.60 - // convert $5 to CZK using c:
43.61 - // assertEquals("Result is 85 CZK");
43.62 - assertEquals(85F, c.convert(5, usd));
43.63 -
43.64 - // convert $8 to CZK
43.65 - // assertEquals("Result is 136 CZK");
43.66 - assertEquals(136F, c.convert(8, usd));
43.67 -
43.68 - // convert 1003CZK to USD
43.69 - // assertEquals("Result is 59 USD");
43.70 - assertEquals(59F, c.convert(1003, czk));
43.71 - }
43.72 -
43.73 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
43.74 - * with it.
43.75 - */
43.76 - public void testCurrencySKKCZK() throws Exception {
43.77 - Convertor c = createSKKtoCZK();
43.78 - Currency skk = Currency.getInstance("SKK");
43.79 - Currency czk = Currency.getInstance("CZK");
43.80 - // convert 16CZK using c:
43.81 - // assertEquals("Result is 20 SKK");
43.82 - assertEquals(20F, c.convert(16, skk));
43.83 -
43.84 - // convert 500SKK to CZK
43.85 - // assertEquals("Result is 400 CZK");
43.86 - assertEquals(400F, c.convert(500, czk));
43.87 - }
43.88 -}
43.89 -
44.1 --- a/task2/solution09/build.xml Tue Oct 07 01:18:23 2008 +0200
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,69 +0,0 @@
44.4 -<?xml version="1.0" encoding="UTF-8"?>
44.5 -<!-- You may freely edit this file. See commented blocks below for -->
44.6 -<!-- some examples of how to customize the build. -->
44.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
44.8 -<project name="currency" default="default" basedir=".">
44.9 - <description>Builds, tests, and runs the project.</description>
44.10 - <import file="nbproject/build-impl.xml"/>
44.11 - <!--
44.12 -
44.13 - There exist several targets which are by default empty and which can be
44.14 - used for execution of your tasks. These targets are usually executed
44.15 - before and after some main targets. They are:
44.16 -
44.17 - -pre-init: called before initialization of project properties
44.18 - -post-init: called after initialization of project properties
44.19 - -pre-compile: called before javac compilation
44.20 - -post-compile: called after javac compilation
44.21 - -pre-compile-single: called before javac compilation of single file
44.22 - -post-compile-single: called after javac compilation of single file
44.23 - -pre-compile-test: called before javac compilation of JUnit tests
44.24 - -post-compile-test: called after javac compilation of JUnit tests
44.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
44.26 - -post-compile-test-single: called after javac compilation of single JUunit test
44.27 - -pre-jar: called before JAR building
44.28 - -post-jar: called after JAR building
44.29 - -post-clean: called after cleaning build products
44.30 -
44.31 - (Targets beginning with '-' are not intended to be called on their own.)
44.32 -
44.33 - Example of inserting an obfuscator after compilation could look like this:
44.34 -
44.35 - <target name="-post-compile">
44.36 - <obfuscate>
44.37 - <fileset dir="${build.classes.dir}"/>
44.38 - </obfuscate>
44.39 - </target>
44.40 -
44.41 - For list of available properties check the imported
44.42 - nbproject/build-impl.xml file.
44.43 -
44.44 -
44.45 - Another way to customize the build is by overriding existing main targets.
44.46 - The targets of interest are:
44.47 -
44.48 - -init-macrodef-javac: defines macro for javac compilation
44.49 - -init-macrodef-junit: defines macro for junit execution
44.50 - -init-macrodef-debug: defines macro for class debugging
44.51 - -init-macrodef-java: defines macro for class execution
44.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
44.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
44.54 - run: execution of project
44.55 - -javadoc-build: Javadoc generation
44.56 - test-report: JUnit report generation
44.57 -
44.58 - An example of overriding the target for project execution could look like this:
44.59 -
44.60 - <target name="run" depends="currency-impl.jar">
44.61 - <exec dir="bin" executable="launcher.exe">
44.62 - <arg file="${dist.jar}"/>
44.63 - </exec>
44.64 - </target>
44.65 -
44.66 - Notice that the overridden target depends on the jar target and not only on
44.67 - the compile target as the regular run target does. Again, for a list of available
44.68 - properties which you can use, check the target you are overriding in the
44.69 - nbproject/build-impl.xml file.
44.70 -
44.71 - -->
44.72 -</project>
45.1 --- a/task2/solution09/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,642 +0,0 @@
45.4 -<?xml version="1.0" encoding="UTF-8"?>
45.5 -<!--
45.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
45.7 -*** EDIT ../build.xml INSTEAD ***
45.8 -
45.9 -For the purpose of easier reading the script
45.10 -is divided into following sections:
45.11 -
45.12 - - initialization
45.13 - - compilation
45.14 - - jar
45.15 - - execution
45.16 - - debugging
45.17 - - javadoc
45.18 - - junit compilation
45.19 - - junit execution
45.20 - - junit debugging
45.21 - - applet
45.22 - - cleanup
45.23 -
45.24 - -->
45.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" 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="Currency_Convertor_Solution_09-impl">
45.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
45.27 - <!--
45.28 - ======================
45.29 - INITIALIZATION SECTION
45.30 - ======================
45.31 - -->
45.32 - <target name="-pre-init">
45.33 - <!-- Empty placeholder for easier customization. -->
45.34 - <!-- You can override this target in the ../build.xml file. -->
45.35 - </target>
45.36 - <target depends="-pre-init" name="-init-private">
45.37 - <property file="nbproject/private/config.properties"/>
45.38 - <property file="nbproject/private/configs/${config}.properties"/>
45.39 - <property file="nbproject/private/private.properties"/>
45.40 - </target>
45.41 - <target depends="-pre-init,-init-private" name="-init-user">
45.42 - <property file="${user.properties.file}"/>
45.43 - <!-- The two properties below are usually overridden -->
45.44 - <!-- by the active platform. Just a fallback. -->
45.45 - <property name="default.javac.source" value="1.4"/>
45.46 - <property name="default.javac.target" value="1.4"/>
45.47 - </target>
45.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
45.49 - <property file="nbproject/configs/${config}.properties"/>
45.50 - <property file="nbproject/project.properties"/>
45.51 - </target>
45.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
45.53 - <available file="${manifest.file}" property="manifest.available"/>
45.54 - <condition property="manifest.available+main.class">
45.55 - <and>
45.56 - <isset property="manifest.available"/>
45.57 - <isset property="main.class"/>
45.58 - <not>
45.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
45.60 - </not>
45.61 - </and>
45.62 - </condition>
45.63 - <condition property="manifest.available+main.class+mkdist.available">
45.64 - <and>
45.65 - <istrue value="${manifest.available+main.class}"/>
45.66 - <isset property="libs.CopyLibs.classpath"/>
45.67 - </and>
45.68 - </condition>
45.69 - <condition property="have.tests">
45.70 - <or>
45.71 - <available file="${test.src.dir}"/>
45.72 - </or>
45.73 - </condition>
45.74 - <condition property="have.sources">
45.75 - <or>
45.76 - <available file="${src.dir}"/>
45.77 - </or>
45.78 - </condition>
45.79 - <condition property="netbeans.home+have.tests">
45.80 - <and>
45.81 - <isset property="netbeans.home"/>
45.82 - <isset property="have.tests"/>
45.83 - </and>
45.84 - </condition>
45.85 - <condition property="no.javadoc.preview">
45.86 - <and>
45.87 - <isset property="javadoc.preview"/>
45.88 - <isfalse value="${javadoc.preview}"/>
45.89 - </and>
45.90 - </condition>
45.91 - <property name="run.jvmargs" value=""/>
45.92 - <property name="javac.compilerargs" value=""/>
45.93 - <property name="work.dir" value="${basedir}"/>
45.94 - <condition property="no.deps">
45.95 - <and>
45.96 - <istrue value="${no.dependencies}"/>
45.97 - </and>
45.98 - </condition>
45.99 - <property name="javac.debug" value="true"/>
45.100 - <property name="javadoc.preview" value="true"/>
45.101 - <property name="application.args" value=""/>
45.102 - <property name="source.encoding" value="${file.encoding}"/>
45.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
45.104 - <and>
45.105 - <isset property="javadoc.encoding"/>
45.106 - <not>
45.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
45.108 - </not>
45.109 - </and>
45.110 - </condition>
45.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
45.112 - <property name="includes" value="**"/>
45.113 - <property name="excludes" value=""/>
45.114 - <property name="do.depend" value="false"/>
45.115 - <condition property="do.depend.true">
45.116 - <istrue value="${do.depend}"/>
45.117 - </condition>
45.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
45.119 - <and>
45.120 - <isset property="jaxws.endorsed.dir"/>
45.121 - <available file="nbproject/jaxws-build.xml"/>
45.122 - </and>
45.123 - </condition>
45.124 - </target>
45.125 - <target name="-post-init">
45.126 - <!-- Empty placeholder for easier customization. -->
45.127 - <!-- You can override this target in the ../build.xml file. -->
45.128 - </target>
45.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
45.130 - <fail unless="src.dir">Must set src.dir</fail>
45.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
45.132 - <fail unless="build.dir">Must set build.dir</fail>
45.133 - <fail unless="dist.dir">Must set dist.dir</fail>
45.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
45.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
45.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
45.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
45.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
45.139 - <fail unless="dist.jar">Must set dist.jar</fail>
45.140 - </target>
45.141 - <target name="-init-macrodef-property">
45.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
45.143 - <attribute name="name"/>
45.144 - <attribute name="value"/>
45.145 - <sequential>
45.146 - <property name="@{name}" value="${@{value}}"/>
45.147 - </sequential>
45.148 - </macrodef>
45.149 - </target>
45.150 - <target name="-init-macrodef-javac">
45.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
45.152 - <attribute default="${src.dir}" name="srcdir"/>
45.153 - <attribute default="${build.classes.dir}" name="destdir"/>
45.154 - <attribute default="${javac.classpath}" name="classpath"/>
45.155 - <attribute default="${includes}" name="includes"/>
45.156 - <attribute default="${excludes}" name="excludes"/>
45.157 - <attribute default="${javac.debug}" name="debug"/>
45.158 - <attribute default="" name="sourcepath"/>
45.159 - <element name="customize" optional="true"/>
45.160 - <sequential>
45.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}">
45.162 - <classpath>
45.163 - <path path="@{classpath}"/>
45.164 - </classpath>
45.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
45.166 - <customize/>
45.167 - </javac>
45.168 - </sequential>
45.169 - </macrodef>
45.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
45.171 - <attribute default="${src.dir}" name="srcdir"/>
45.172 - <attribute default="${build.classes.dir}" name="destdir"/>
45.173 - <attribute default="${javac.classpath}" name="classpath"/>
45.174 - <sequential>
45.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
45.176 - <classpath>
45.177 - <path path="@{classpath}"/>
45.178 - </classpath>
45.179 - </depend>
45.180 - </sequential>
45.181 - </macrodef>
45.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
45.183 - <attribute default="${build.classes.dir}" name="destdir"/>
45.184 - <sequential>
45.185 - <fail unless="javac.includes">Must set javac.includes</fail>
45.186 - <pathconvert pathsep="," property="javac.includes.binary">
45.187 - <path>
45.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
45.189 - </path>
45.190 - <globmapper from="*.java" to="*.class"/>
45.191 - </pathconvert>
45.192 - <delete>
45.193 - <files includes="${javac.includes.binary}"/>
45.194 - </delete>
45.195 - </sequential>
45.196 - </macrodef>
45.197 - </target>
45.198 - <target name="-init-macrodef-junit">
45.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
45.200 - <attribute default="${includes}" name="includes"/>
45.201 - <attribute default="${excludes}" name="excludes"/>
45.202 - <attribute default="**" name="testincludes"/>
45.203 - <sequential>
45.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
45.205 - <batchtest todir="${build.test.results.dir}">
45.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
45.207 - <filename name="@{testincludes}"/>
45.208 - </fileset>
45.209 - </batchtest>
45.210 - <classpath>
45.211 - <path path="${run.test.classpath}"/>
45.212 - </classpath>
45.213 - <syspropertyset>
45.214 - <propertyref prefix="test-sys-prop."/>
45.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
45.216 - </syspropertyset>
45.217 - <formatter type="brief" usefile="false"/>
45.218 - <formatter type="xml"/>
45.219 - <jvmarg line="${run.jvmargs}"/>
45.220 - </junit>
45.221 - </sequential>
45.222 - </macrodef>
45.223 - </target>
45.224 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
45.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
45.226 - <attribute default="${main.class}" name="name"/>
45.227 - <attribute default="${debug.classpath}" name="classpath"/>
45.228 - <attribute default="" name="stopclassname"/>
45.229 - <sequential>
45.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
45.231 - <classpath>
45.232 - <path path="@{classpath}"/>
45.233 - </classpath>
45.234 - </nbjpdastart>
45.235 - </sequential>
45.236 - </macrodef>
45.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
45.238 - <attribute default="${build.classes.dir}" name="dir"/>
45.239 - <sequential>
45.240 - <nbjpdareload>
45.241 - <fileset dir="@{dir}" includes="${fix.classes}">
45.242 - <include name="${fix.includes}*.class"/>
45.243 - </fileset>
45.244 - </nbjpdareload>
45.245 - </sequential>
45.246 - </macrodef>
45.247 - </target>
45.248 - <target name="-init-debug-args">
45.249 - <property name="version-output" value="java version "${ant.java.version}"/>
45.250 - <condition property="have-jdk-older-than-1.4">
45.251 - <or>
45.252 - <contains string="${version-output}" substring="java version "1.0"/>
45.253 - <contains string="${version-output}" substring="java version "1.1"/>
45.254 - <contains string="${version-output}" substring="java version "1.2"/>
45.255 - <contains string="${version-output}" substring="java version "1.3"/>
45.256 - </or>
45.257 - </condition>
45.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
45.259 - <istrue value="${have-jdk-older-than-1.4}"/>
45.260 - </condition>
45.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
45.262 - <os family="windows"/>
45.263 - </condition>
45.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
45.265 - <isset property="debug.transport"/>
45.266 - </condition>
45.267 - </target>
45.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
45.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
45.270 - <attribute default="${main.class}" name="classname"/>
45.271 - <attribute default="${debug.classpath}" name="classpath"/>
45.272 - <element name="customize" optional="true"/>
45.273 - <sequential>
45.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
45.275 - <jvmarg line="${debug-args-line}"/>
45.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
45.277 - <jvmarg line="${run.jvmargs}"/>
45.278 - <classpath>
45.279 - <path path="@{classpath}"/>
45.280 - </classpath>
45.281 - <syspropertyset>
45.282 - <propertyref prefix="run-sys-prop."/>
45.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
45.284 - </syspropertyset>
45.285 - <customize/>
45.286 - </java>
45.287 - </sequential>
45.288 - </macrodef>
45.289 - </target>
45.290 - <target name="-init-macrodef-java">
45.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
45.292 - <attribute default="${main.class}" name="classname"/>
45.293 - <element name="customize" optional="true"/>
45.294 - <sequential>
45.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
45.296 - <jvmarg line="${run.jvmargs}"/>
45.297 - <classpath>
45.298 - <path path="${run.classpath}"/>
45.299 - </classpath>
45.300 - <syspropertyset>
45.301 - <propertyref prefix="run-sys-prop."/>
45.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
45.303 - </syspropertyset>
45.304 - <customize/>
45.305 - </java>
45.306 - </sequential>
45.307 - </macrodef>
45.308 - </target>
45.309 - <target name="-init-presetdef-jar">
45.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
45.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
45.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
45.313 - </jar>
45.314 - </presetdef>
45.315 - </target>
45.316 - <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"/>
45.317 - <!--
45.318 - ===================
45.319 - COMPILATION SECTION
45.320 - ===================
45.321 - -->
45.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
45.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
45.324 - <target depends="init" name="-check-automatic-build">
45.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
45.326 - </target>
45.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
45.328 - <antcall target="clean"/>
45.329 - </target>
45.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
45.331 - <mkdir dir="${build.classes.dir}"/>
45.332 - </target>
45.333 - <target name="-pre-compile">
45.334 - <!-- Empty placeholder for easier customization. -->
45.335 - <!-- You can override this target in the ../build.xml file. -->
45.336 - </target>
45.337 - <target if="do.depend.true" name="-compile-depend">
45.338 - <j2seproject3:depend/>
45.339 - </target>
45.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
45.341 - <j2seproject3:javac/>
45.342 - <copy todir="${build.classes.dir}">
45.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
45.344 - </copy>
45.345 - </target>
45.346 - <target name="-post-compile">
45.347 - <!-- Empty placeholder for easier customization. -->
45.348 - <!-- You can override this target in the ../build.xml file. -->
45.349 - </target>
45.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
45.351 - <target name="-pre-compile-single">
45.352 - <!-- Empty placeholder for easier customization. -->
45.353 - <!-- You can override this target in the ../build.xml file. -->
45.354 - </target>
45.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
45.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
45.357 - <j2seproject3:force-recompile/>
45.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
45.359 - </target>
45.360 - <target name="-post-compile-single">
45.361 - <!-- Empty placeholder for easier customization. -->
45.362 - <!-- You can override this target in the ../build.xml file. -->
45.363 - </target>
45.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
45.365 - <!--
45.366 - ====================
45.367 - JAR BUILDING SECTION
45.368 - ====================
45.369 - -->
45.370 - <target depends="init" name="-pre-pre-jar">
45.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
45.372 - <mkdir dir="${dist.jar.dir}"/>
45.373 - </target>
45.374 - <target name="-pre-jar">
45.375 - <!-- Empty placeholder for easier customization. -->
45.376 - <!-- You can override this target in the ../build.xml file. -->
45.377 - </target>
45.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
45.379 - <j2seproject1:jar/>
45.380 - </target>
45.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
45.382 - <j2seproject1:jar manifest="${manifest.file}"/>
45.383 - </target>
45.384 - <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">
45.385 - <j2seproject1:jar manifest="${manifest.file}">
45.386 - <j2seproject1:manifest>
45.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
45.388 - </j2seproject1:manifest>
45.389 - </j2seproject1:jar>
45.390 - <echo>To run this application from the command line without Ant, try:</echo>
45.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
45.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
45.393 - <pathconvert property="run.classpath.with.dist.jar">
45.394 - <path path="${run.classpath}"/>
45.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
45.396 - </pathconvert>
45.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
45.398 - </target>
45.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
45.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
45.401 - <pathconvert property="run.classpath.without.build.classes.dir">
45.402 - <path path="${run.classpath}"/>
45.403 - <map from="${build.classes.dir.resolved}" to=""/>
45.404 - </pathconvert>
45.405 - <pathconvert pathsep=" " property="jar.classpath">
45.406 - <path path="${run.classpath.without.build.classes.dir}"/>
45.407 - <chainedmapper>
45.408 - <flattenmapper/>
45.409 - <globmapper from="*" to="lib/*"/>
45.410 - </chainedmapper>
45.411 - </pathconvert>
45.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
45.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
45.414 - <fileset dir="${build.classes.dir}"/>
45.415 - <manifest>
45.416 - <attribute name="Main-Class" value="${main.class}"/>
45.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
45.418 - </manifest>
45.419 - </copylibs>
45.420 - <echo>To run this application from the command line without Ant, try:</echo>
45.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
45.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
45.423 - </target>
45.424 - <target name="-post-jar">
45.425 - <!-- Empty placeholder for easier customization. -->
45.426 - <!-- You can override this target in the ../build.xml file. -->
45.427 - </target>
45.428 - <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"/>
45.429 - <!--
45.430 - =================
45.431 - EXECUTION SECTION
45.432 - =================
45.433 - -->
45.434 - <target depends="init,compile" description="Run a main class." name="run">
45.435 - <j2seproject1:java>
45.436 - <customize>
45.437 - <arg line="${application.args}"/>
45.438 - </customize>
45.439 - </j2seproject1:java>
45.440 - </target>
45.441 - <target name="-do-not-recompile">
45.442 - <property name="javac.includes.binary" value=""/>
45.443 - </target>
45.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
45.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
45.446 - <j2seproject1:java classname="${run.class}"/>
45.447 - </target>
45.448 - <!--
45.449 - =================
45.450 - DEBUGGING SECTION
45.451 - =================
45.452 - -->
45.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
45.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
45.455 - </target>
45.456 - <target depends="init,compile" name="-debug-start-debuggee">
45.457 - <j2seproject3:debug>
45.458 - <customize>
45.459 - <arg line="${application.args}"/>
45.460 - </customize>
45.461 - </j2seproject3:debug>
45.462 - </target>
45.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
45.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
45.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
45.466 - </target>
45.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
45.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
45.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
45.470 - <j2seproject3:debug classname="${debug.class}"/>
45.471 - </target>
45.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
45.473 - <target depends="init" name="-pre-debug-fix">
45.474 - <fail unless="fix.includes">Must set fix.includes</fail>
45.475 - <property name="javac.includes" value="${fix.includes}.java"/>
45.476 - </target>
45.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
45.478 - <j2seproject1:nbjpdareload/>
45.479 - </target>
45.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
45.481 - <!--
45.482 - ===============
45.483 - JAVADOC SECTION
45.484 - ===============
45.485 - -->
45.486 - <target depends="init" name="-javadoc-build">
45.487 - <mkdir dir="${dist.javadoc.dir}"/>
45.488 - <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}">
45.489 - <classpath>
45.490 - <path path="${javac.classpath}"/>
45.491 - </classpath>
45.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
45.493 - <filename name="**/*.java"/>
45.494 - </fileset>
45.495 - </javadoc>
45.496 - </target>
45.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
45.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
45.499 - </target>
45.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
45.501 - <!--
45.502 - =========================
45.503 - JUNIT COMPILATION SECTION
45.504 - =========================
45.505 - -->
45.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
45.507 - <mkdir dir="${build.test.classes.dir}"/>
45.508 - </target>
45.509 - <target name="-pre-compile-test">
45.510 - <!-- Empty placeholder for easier customization. -->
45.511 - <!-- You can override this target in the ../build.xml file. -->
45.512 - </target>
45.513 - <target if="do.depend.true" name="-compile-test-depend">
45.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
45.515 - </target>
45.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
45.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
45.518 - <copy todir="${build.test.classes.dir}">
45.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
45.520 - </copy>
45.521 - </target>
45.522 - <target name="-post-compile-test">
45.523 - <!-- Empty placeholder for easier customization. -->
45.524 - <!-- You can override this target in the ../build.xml file. -->
45.525 - </target>
45.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
45.527 - <target name="-pre-compile-test-single">
45.528 - <!-- Empty placeholder for easier customization. -->
45.529 - <!-- You can override this target in the ../build.xml file. -->
45.530 - </target>
45.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
45.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
45.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
45.534 - <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}"/>
45.535 - <copy todir="${build.test.classes.dir}">
45.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
45.537 - </copy>
45.538 - </target>
45.539 - <target name="-post-compile-test-single">
45.540 - <!-- Empty placeholder for easier customization. -->
45.541 - <!-- You can override this target in the ../build.xml file. -->
45.542 - </target>
45.543 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
45.544 - <!--
45.545 - =======================
45.546 - JUNIT EXECUTION SECTION
45.547 - =======================
45.548 - -->
45.549 - <target depends="init" if="have.tests" name="-pre-test-run">
45.550 - <mkdir dir="${build.test.results.dir}"/>
45.551 - </target>
45.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
45.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
45.554 - </target>
45.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
45.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
45.557 - </target>
45.558 - <target depends="init" if="have.tests" name="test-report"/>
45.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
45.560 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
45.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
45.562 - <mkdir dir="${build.test.results.dir}"/>
45.563 - </target>
45.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
45.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
45.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
45.567 - </target>
45.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
45.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
45.570 - </target>
45.571 - <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"/>
45.572 - <!--
45.573 - =======================
45.574 - JUNIT DEBUGGING SECTION
45.575 - =======================
45.576 - -->
45.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
45.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
45.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
45.580 - <delete file="${test.report.file}"/>
45.581 - <mkdir dir="${build.test.results.dir}"/>
45.582 - <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}">
45.583 - <customize>
45.584 - <syspropertyset>
45.585 - <propertyref prefix="test-sys-prop."/>
45.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
45.587 - </syspropertyset>
45.588 - <arg value="${test.class}"/>
45.589 - <arg value="showoutput=true"/>
45.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
45.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
45.592 - </customize>
45.593 - </j2seproject3:debug>
45.594 - </target>
45.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
45.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
45.597 - </target>
45.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
45.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
45.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
45.601 - </target>
45.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
45.603 - <!--
45.604 - =========================
45.605 - APPLET EXECUTION SECTION
45.606 - =========================
45.607 - -->
45.608 - <target depends="init,compile-single" name="run-applet">
45.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
45.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
45.611 - <customize>
45.612 - <arg value="${applet.url}"/>
45.613 - </customize>
45.614 - </j2seproject1:java>
45.615 - </target>
45.616 - <!--
45.617 - =========================
45.618 - APPLET DEBUGGING SECTION
45.619 - =========================
45.620 - -->
45.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
45.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
45.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
45.624 - <customize>
45.625 - <arg value="${applet.url}"/>
45.626 - </customize>
45.627 - </j2seproject3:debug>
45.628 - </target>
45.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
45.630 - <!--
45.631 - ===============
45.632 - CLEANUP SECTION
45.633 - ===============
45.634 - -->
45.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
45.636 - <target depends="init" name="-do-clean">
45.637 - <delete dir="${build.dir}"/>
45.638 - <delete dir="${dist.dir}"/>
45.639 - </target>
45.640 - <target name="-post-clean">
45.641 - <!-- Empty placeholder for easier customization. -->
45.642 - <!-- You can override this target in the ../build.xml file. -->
45.643 - </target>
45.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
45.645 -</project>
46.1 --- a/task2/solution09/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,8 +0,0 @@
46.4 -build.xml.data.CRC32=2ab820eb
46.5 -build.xml.script.CRC32=58a52595
46.6 -build.xml.stylesheet.CRC32=be360661
46.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
46.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
46.9 -nbproject/build-impl.xml.data.CRC32=cab2f6f1
46.10 -nbproject/build-impl.xml.script.CRC32=711fa7d6
46.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
47.1 --- a/task2/solution09/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,68 +0,0 @@
47.4 -application.title=currency
47.5 -application.vendor=apidesign.org
47.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
47.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
47.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
47.9 -build.classes.dir=${build.dir}/classes
47.10 -build.classes.excludes=**/*.java,**/*.form
47.11 -# This directory is removed when the project is cleaned:
47.12 -build.dir=build
47.13 -build.generated.dir=${build.dir}/generated
47.14 -# Only compile against the classpath explicitly listed here:
47.15 -build.sysclasspath=ignore
47.16 -build.test.classes.dir=${build.dir}/test/classes
47.17 -build.test.results.dir=${build.dir}/test/results
47.18 -debug.classpath=\
47.19 - ${run.classpath}
47.20 -debug.test.classpath=\
47.21 - ${run.test.classpath}
47.22 -# This directory is removed when the project is cleaned:
47.23 -dist.dir=dist
47.24 -dist.jar=${dist.dir}/currency.jar
47.25 -dist.javadoc.dir=${dist.dir}/javadoc
47.26 -excludes=
47.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
47.28 -file.reference.src-apifest08=..
47.29 -includes=**
47.30 -jar.compress=false
47.31 -javac.classpath=
47.32 -# Space-separated list of extra javac options
47.33 -javac.compilerargs=
47.34 -javac.deprecation=false
47.35 -javac.source=1.5
47.36 -javac.target=1.5
47.37 -javac.test.classpath=\
47.38 - ${javac.classpath}:\
47.39 - ${build.classes.dir}:\
47.40 - ${file.reference.junit-4.4.jar}
47.41 -javadoc.additionalparam=
47.42 -javadoc.author=false
47.43 -javadoc.encoding=
47.44 -javadoc.noindex=false
47.45 -javadoc.nonavbar=false
47.46 -javadoc.notree=false
47.47 -javadoc.private=false
47.48 -javadoc.splitindex=true
47.49 -javadoc.use=true
47.50 -javadoc.version=false
47.51 -javadoc.windowtitle=
47.52 -jnlp.codebase.type=local
47.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
47.54 -jnlp.descriptor=application
47.55 -jnlp.enabled=false
47.56 -jnlp.offline-allowed=false
47.57 -jnlp.signed=false
47.58 -meta.inf.dir=${src.dir}/META-INF
47.59 -platform.active=default_platform
47.60 -run.classpath=\
47.61 - ${javac.classpath}:\
47.62 - ${build.classes.dir}
47.63 -# Space-separated list of JVM arguments used when running the project
47.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
47.65 -# or test-sys-prop.name=value to set system properties for unit tests):
47.66 -run.jvmargs=
47.67 -run.test.classpath=\
47.68 - ${javac.test.classpath}:\
47.69 - ${build.test.classes.dir}
47.70 -src.dir=src
47.71 -test.src.dir=test
48.1 --- a/task2/solution09/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,16 +0,0 @@
48.4 -<?xml version="1.0" encoding="UTF-8"?>
48.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
48.6 - <type>org.netbeans.modules.java.j2seproject</type>
48.7 - <configuration>
48.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
48.9 - <name>Currency Convertor Solution 09</name>
48.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
48.11 - <source-roots>
48.12 - <root id="src.dir"/>
48.13 - </source-roots>
48.14 - <test-roots>
48.15 - <root id="test.src.dir"/>
48.16 - </test-roots>
48.17 - </data>
48.18 - </configuration>
48.19 -</project>
49.1 --- a/task2/solution09/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,26 +0,0 @@
49.4 -package org.apidesign.apifest08.currency;
49.5 -
49.6 -/** This is the skeleton class for your API. You need to make it public, so
49.7 - * it is accessible to your client code (currently in Task1Test.java) file.
49.8 - * <p>
49.9 - * Feel free to create additional classes or rename this one, just keep all
49.10 - * the API and its implementation in this package. Do not spread it outside
49.11 - * to other packages.
49.12 - */
49.13 -public interface Convertor {
49.14 -
49.15 - /**
49.16 - * converts amount in first currency to amount second currency.
49.17 - * @param amountInCents the amount of first currency in cents (or equivalent)
49.18 - * @return the amount in the second currency in cents (or equivalent)
49.19 - */
49.20 - public long convertTo(long amountInCents);
49.21 -
49.22 -
49.23 - /**
49.24 - * converts from second currency amount to first currency amount.
49.25 - * @param amountInCents the amount of second currency in cents (or equivalent)
49.26 - * @return the amount in the first currency in cents (or equivalent)
49.27 - */
49.28 - public long convertFrom(long amountInCents);
49.29 -}
50.1 --- a/task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,38 +0,0 @@
50.4 -package org.apidesign.apifest08.currency;
50.5 -
50.6 -import java.math.BigDecimal;
50.7 -
50.8 -
50.9 -public class ConvertorFactory {
50.10 -
50.11 - public static Convertor getConvertor(CurrencyType from, CurrencyType to) {
50.12 - if (from == CurrencyType.CZK && to == CurrencyType.USD) {
50.13 - return new BasicConvertor(new BigDecimal(17));
50.14 - } else if (from == CurrencyType.SKK && to == CurrencyType.CZK) {
50.15 - double rate = 0.8d;
50.16 - return new BasicConvertor(new BigDecimal(rate));
50.17 - }
50.18 -
50.19 -
50.20 - throw new UnsupportedOperationException("Conversion not supported now");
50.21 - }
50.22 -
50.23 - private static class BasicConvertor implements Convertor {
50.24 -
50.25 - private final BigDecimal conversionRate;
50.26 -
50.27 - BasicConvertor(BigDecimal conversionRate) {
50.28 - this.conversionRate = conversionRate;
50.29 - }
50.30 -
50.31 - @Override
50.32 - public long convertTo(long amount) {
50.33 - return (long) (conversionRate.doubleValue() * amount);
50.34 - }
50.35 -
50.36 - @Override
50.37 - public long convertFrom(long amount) {
50.38 - return (long) (amount / conversionRate.doubleValue());
50.39 - }
50.40 - }
50.41 -}
51.1 --- a/task2/solution09/src/org/apidesign/apifest08/currency/CurrencyType.java Tue Oct 07 01:18:23 2008 +0200
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,7 +0,0 @@
51.4 -package org.apidesign.apifest08.currency;
51.5 -
51.6 -public enum CurrencyType {
51.7 -
51.8 - CZK, SKK, USD;
51.9 -
51.10 -}
52.1 --- a/task2/solution09/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,77 +0,0 @@
52.4 -package org.apidesign.apifest08.test;
52.5 -
52.6 -import junit.framework.TestCase;
52.7 -import org.apidesign.apifest08.currency.Convertor;
52.8 -import org.apidesign.apifest08.currency.ConvertorFactory;
52.9 -import org.apidesign.apifest08.currency.CurrencyType;
52.10 -
52.11 -/** Finish the Convertor API, and then write bodies of methods inside
52.12 - * of this class to match the given tasks. To fullfil your task, use the
52.13 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
52.14 - * Do not you reflection, or other hacks as your code
52.15 - * shall run without any runtime permissions.
52.16 - */
52.17 -public class Task1Test extends TestCase {
52.18 - public Task1Test(String testName) {
52.19 - super(testName);
52.20 - }
52.21 -
52.22 -
52.23 - /** Create convertor that understands two currencies, CZK and
52.24 - * USD. Make 1 USD == 17 CZK.
52.25 - *
52.26 - * Creation of the convertor shall not require subclassing of any class
52.27 - * or interface on the client side.
52.28 - *
52.29 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
52.30 - */
52.31 - public static Convertor createCZKtoUSD() {
52.32 - return ConvertorFactory.getConvertor(CurrencyType.CZK, CurrencyType.USD);
52.33 - }
52.34 -
52.35 - /** Create convertor that understands two currencies, CZK and
52.36 - * SKK. Make 100 SKK == 80 CZK.
52.37 - *
52.38 - * Creation of the convertor shall not require subclassing of any class
52.39 - * or interface on the client side.
52.40 - *
52.41 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
52.42 - */
52.43 - public static Convertor createSKKtoCZK() {
52.44 - return ConvertorFactory.getConvertor(CurrencyType.SKK, CurrencyType.CZK);
52.45 - }
52.46 -
52.47 - /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
52.48 - * with it.
52.49 - */
52.50 - public void testCurrencyCZKUSD() throws Exception {
52.51 - Convertor c = createCZKtoUSD();
52.52 -
52.53 - // convert $5 to CZK using c:
52.54 - // assertEquals("Result is 85 CZK");
52.55 - assertEquals(85, c.convertTo(5));
52.56 -
52.57 - // convert $8 to CZK
52.58 - // assertEquals("Result is 136 CZK");
52.59 - assertEquals(136, c.convertTo(8));
52.60 -
52.61 - // convert 1003CZK to USD
52.62 - // assertEquals("Result is 59 USD");
52.63 - assertEquals(59, c.convertFrom(1003));
52.64 - }
52.65 -
52.66 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
52.67 - * with it.
52.68 - */
52.69 - public void testCurrencySKKCZK() throws Exception {
52.70 - Convertor c = createSKKtoCZK();
52.71 - // convert 16CZK using c:
52.72 - // assertEquals("Result is 20 SKK");
52.73 - assertEquals(20, c.convertFrom(16));
52.74 -
52.75 - // convert 500SKK to CZK
52.76 - // assertEquals("Result is 400 CZK");
52.77 - assertEquals(400, c.convertTo(500));
52.78 - }
52.79 -}
52.80 -
53.1 --- a/task2/solution10/build.xml Tue Oct 07 01:18:23 2008 +0200
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,69 +0,0 @@
53.4 -<?xml version="1.0" encoding="UTF-8"?>
53.5 -<!-- You may freely edit this file. See commented blocks below for -->
53.6 -<!-- some examples of how to customize the build. -->
53.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
53.8 -<project name="Currency_Convertor_Solution_10" default="default" basedir=".">
53.9 - <description>Builds, tests, and runs the project Currency Convertor Solution 10.</description>
53.10 - <import file="nbproject/build-impl.xml"/>
53.11 - <!--
53.12 -
53.13 - There exist several targets which are by default empty and which can be
53.14 - used for execution of your tasks. These targets are usually executed
53.15 - before and after some main targets. They are:
53.16 -
53.17 - -pre-init: called before initialization of project properties
53.18 - -post-init: called after initialization of project properties
53.19 - -pre-compile: called before javac compilation
53.20 - -post-compile: called after javac compilation
53.21 - -pre-compile-single: called before javac compilation of single file
53.22 - -post-compile-single: called after javac compilation of single file
53.23 - -pre-compile-test: called before javac compilation of JUnit tests
53.24 - -post-compile-test: called after javac compilation of JUnit tests
53.25 - -pre-compile-test-single: called before javac compilation of single JUnit test
53.26 - -post-compile-test-single: called after javac compilation of single JUunit test
53.27 - -pre-jar: called before JAR building
53.28 - -post-jar: called after JAR building
53.29 - -post-clean: called after cleaning build products
53.30 -
53.31 - (Targets beginning with '-' are not intended to be called on their own.)
53.32 -
53.33 - Example of inserting an obfuscator after compilation could look like this:
53.34 -
53.35 - <target name="-post-compile">
53.36 - <obfuscate>
53.37 - <fileset dir="${build.classes.dir}"/>
53.38 - </obfuscate>
53.39 - </target>
53.40 -
53.41 - For list of available properties check the imported
53.42 - nbproject/build-impl.xml file.
53.43 -
53.44 -
53.45 - Another way to customize the build is by overriding existing main targets.
53.46 - The targets of interest are:
53.47 -
53.48 - -init-macrodef-javac: defines macro for javac compilation
53.49 - -init-macrodef-junit: defines macro for junit execution
53.50 - -init-macrodef-debug: defines macro for class debugging
53.51 - -init-macrodef-java: defines macro for class execution
53.52 - -do-jar-with-manifest: JAR building (if you are using a manifest)
53.53 - -do-jar-without-manifest: JAR building (if you are not using a manifest)
53.54 - run: execution of project
53.55 - -javadoc-build: Javadoc generation
53.56 - test-report: JUnit report generation
53.57 -
53.58 - An example of overriding the target for project execution could look like this:
53.59 -
53.60 - <target name="run" depends="Currency_Convertor_Solution_10-impl.jar">
53.61 - <exec dir="bin" executable="launcher.exe">
53.62 - <arg file="${dist.jar}"/>
53.63 - </exec>
53.64 - </target>
53.65 -
53.66 - Notice that the overridden target depends on the jar target and not only on
53.67 - the compile target as the regular run target does. Again, for a list of available
53.68 - properties which you can use, check the target you are overriding in the
53.69 - nbproject/build-impl.xml file.
53.70 -
53.71 - -->
53.72 -</project>
54.1 Binary file task2/solution10/nbproject/.DS_Store has changed
55.1 --- a/task2/solution10/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,642 +0,0 @@
55.4 -<?xml version="1.0" encoding="UTF-8"?>
55.5 -<!--
55.6 -*** GENERATED FROM project.xml - DO NOT EDIT ***
55.7 -*** EDIT ../build.xml INSTEAD ***
55.8 -
55.9 -For the purpose of easier reading the script
55.10 -is divided into following sections:
55.11 -
55.12 - - initialization
55.13 - - compilation
55.14 - - jar
55.15 - - execution
55.16 - - debugging
55.17 - - javadoc
55.18 - - junit compilation
55.19 - - junit execution
55.20 - - junit debugging
55.21 - - applet
55.22 - - cleanup
55.23 -
55.24 - -->
55.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" 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="Currency_Convertor_Solution_10-impl">
55.26 - <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
55.27 - <!--
55.28 - ======================
55.29 - INITIALIZATION SECTION
55.30 - ======================
55.31 - -->
55.32 - <target name="-pre-init">
55.33 - <!-- Empty placeholder for easier customization. -->
55.34 - <!-- You can override this target in the ../build.xml file. -->
55.35 - </target>
55.36 - <target depends="-pre-init" name="-init-private">
55.37 - <property file="nbproject/private/config.properties"/>
55.38 - <property file="nbproject/private/configs/${config}.properties"/>
55.39 - <property file="nbproject/private/private.properties"/>
55.40 - </target>
55.41 - <target depends="-pre-init,-init-private" name="-init-user">
55.42 - <property file="${user.properties.file}"/>
55.43 - <!-- The two properties below are usually overridden -->
55.44 - <!-- by the active platform. Just a fallback. -->
55.45 - <property name="default.javac.source" value="1.4"/>
55.46 - <property name="default.javac.target" value="1.4"/>
55.47 - </target>
55.48 - <target depends="-pre-init,-init-private,-init-user" name="-init-project">
55.49 - <property file="nbproject/configs/${config}.properties"/>
55.50 - <property file="nbproject/project.properties"/>
55.51 - </target>
55.52 - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
55.53 - <available file="${manifest.file}" property="manifest.available"/>
55.54 - <condition property="manifest.available+main.class">
55.55 - <and>
55.56 - <isset property="manifest.available"/>
55.57 - <isset property="main.class"/>
55.58 - <not>
55.59 - <equals arg1="${main.class}" arg2="" trim="true"/>
55.60 - </not>
55.61 - </and>
55.62 - </condition>
55.63 - <condition property="manifest.available+main.class+mkdist.available">
55.64 - <and>
55.65 - <istrue value="${manifest.available+main.class}"/>
55.66 - <isset property="libs.CopyLibs.classpath"/>
55.67 - </and>
55.68 - </condition>
55.69 - <condition property="have.tests">
55.70 - <or>
55.71 - <available file="${test.src.dir}"/>
55.72 - </or>
55.73 - </condition>
55.74 - <condition property="have.sources">
55.75 - <or>
55.76 - <available file="${src.dir}"/>
55.77 - </or>
55.78 - </condition>
55.79 - <condition property="netbeans.home+have.tests">
55.80 - <and>
55.81 - <isset property="netbeans.home"/>
55.82 - <isset property="have.tests"/>
55.83 - </and>
55.84 - </condition>
55.85 - <condition property="no.javadoc.preview">
55.86 - <and>
55.87 - <isset property="javadoc.preview"/>
55.88 - <isfalse value="${javadoc.preview}"/>
55.89 - </and>
55.90 - </condition>
55.91 - <property name="run.jvmargs" value=""/>
55.92 - <property name="javac.compilerargs" value=""/>
55.93 - <property name="work.dir" value="${basedir}"/>
55.94 - <condition property="no.deps">
55.95 - <and>
55.96 - <istrue value="${no.dependencies}"/>
55.97 - </and>
55.98 - </condition>
55.99 - <property name="javac.debug" value="true"/>
55.100 - <property name="javadoc.preview" value="true"/>
55.101 - <property name="application.args" value=""/>
55.102 - <property name="source.encoding" value="${file.encoding}"/>
55.103 - <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
55.104 - <and>
55.105 - <isset property="javadoc.encoding"/>
55.106 - <not>
55.107 - <equals arg1="${javadoc.encoding}" arg2=""/>
55.108 - </not>
55.109 - </and>
55.110 - </condition>
55.111 - <property name="javadoc.encoding.used" value="${source.encoding}"/>
55.112 - <property name="includes" value="**"/>
55.113 - <property name="excludes" value=""/>
55.114 - <property name="do.depend" value="false"/>
55.115 - <condition property="do.depend.true">
55.116 - <istrue value="${do.depend}"/>
55.117 - </condition>
55.118 - <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
55.119 - <and>
55.120 - <isset property="jaxws.endorsed.dir"/>
55.121 - <available file="nbproject/jaxws-build.xml"/>
55.122 - </and>
55.123 - </condition>
55.124 - </target>
55.125 - <target name="-post-init">
55.126 - <!-- Empty placeholder for easier customization. -->
55.127 - <!-- You can override this target in the ../build.xml file. -->
55.128 - </target>
55.129 - <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
55.130 - <fail unless="src.dir">Must set src.dir</fail>
55.131 - <fail unless="test.src.dir">Must set test.src.dir</fail>
55.132 - <fail unless="build.dir">Must set build.dir</fail>
55.133 - <fail unless="dist.dir">Must set dist.dir</fail>
55.134 - <fail unless="build.classes.dir">Must set build.classes.dir</fail>
55.135 - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
55.136 - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
55.137 - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
55.138 - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
55.139 - <fail unless="dist.jar">Must set dist.jar</fail>
55.140 - </target>
55.141 - <target name="-init-macrodef-property">
55.142 - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
55.143 - <attribute name="name"/>
55.144 - <attribute name="value"/>
55.145 - <sequential>
55.146 - <property name="@{name}" value="${@{value}}"/>
55.147 - </sequential>
55.148 - </macrodef>
55.149 - </target>
55.150 - <target name="-init-macrodef-javac">
55.151 - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
55.152 - <attribute default="${src.dir}" name="srcdir"/>
55.153 - <attribute default="${build.classes.dir}" name="destdir"/>
55.154 - <attribute default="${javac.classpath}" name="classpath"/>
55.155 - <attribute default="${includes}" name="includes"/>
55.156 - <attribute default="${excludes}" name="excludes"/>
55.157 - <attribute default="${javac.debug}" name="debug"/>
55.158 - <attribute default="" name="sourcepath"/>
55.159 - <element name="customize" optional="true"/>
55.160 - <sequential>
55.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}">
55.162 - <classpath>
55.163 - <path path="@{classpath}"/>
55.164 - </classpath>
55.165 - <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
55.166 - <customize/>
55.167 - </javac>
55.168 - </sequential>
55.169 - </macrodef>
55.170 - <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
55.171 - <attribute default="${src.dir}" name="srcdir"/>
55.172 - <attribute default="${build.classes.dir}" name="destdir"/>
55.173 - <attribute default="${javac.classpath}" name="classpath"/>
55.174 - <sequential>
55.175 - <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
55.176 - <classpath>
55.177 - <path path="@{classpath}"/>
55.178 - </classpath>
55.179 - </depend>
55.180 - </sequential>
55.181 - </macrodef>
55.182 - <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
55.183 - <attribute default="${build.classes.dir}" name="destdir"/>
55.184 - <sequential>
55.185 - <fail unless="javac.includes">Must set javac.includes</fail>
55.186 - <pathconvert pathsep="," property="javac.includes.binary">
55.187 - <path>
55.188 - <filelist dir="@{destdir}" files="${javac.includes}"/>
55.189 - </path>
55.190 - <globmapper from="*.java" to="*.class"/>
55.191 - </pathconvert>
55.192 - <delete>
55.193 - <files includes="${javac.includes.binary}"/>
55.194 - </delete>
55.195 - </sequential>
55.196 - </macrodef>
55.197 - </target>
55.198 - <target name="-init-macrodef-junit">
55.199 - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
55.200 - <attribute default="${includes}" name="includes"/>
55.201 - <attribute default="${excludes}" name="excludes"/>
55.202 - <attribute default="**" name="testincludes"/>
55.203 - <sequential>
55.204 - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
55.205 - <batchtest todir="${build.test.results.dir}">
55.206 - <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
55.207 - <filename name="@{testincludes}"/>
55.208 - </fileset>
55.209 - </batchtest>
55.210 - <classpath>
55.211 - <path path="${run.test.classpath}"/>
55.212 - </classpath>
55.213 - <syspropertyset>
55.214 - <propertyref prefix="test-sys-prop."/>
55.215 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
55.216 - </syspropertyset>
55.217 - <formatter type="brief" usefile="false"/>
55.218 - <formatter type="xml"/>
55.219 - <jvmarg line="${run.jvmargs}"/>
55.220 - </junit>
55.221 - </sequential>
55.222 - </macrodef>
55.223 - </target>
55.224 - <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
55.225 - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
55.226 - <attribute default="${main.class}" name="name"/>
55.227 - <attribute default="${debug.classpath}" name="classpath"/>
55.228 - <attribute default="" name="stopclassname"/>
55.229 - <sequential>
55.230 - <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
55.231 - <classpath>
55.232 - <path path="@{classpath}"/>
55.233 - </classpath>
55.234 - </nbjpdastart>
55.235 - </sequential>
55.236 - </macrodef>
55.237 - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
55.238 - <attribute default="${build.classes.dir}" name="dir"/>
55.239 - <sequential>
55.240 - <nbjpdareload>
55.241 - <fileset dir="@{dir}" includes="${fix.classes}">
55.242 - <include name="${fix.includes}*.class"/>
55.243 - </fileset>
55.244 - </nbjpdareload>
55.245 - </sequential>
55.246 - </macrodef>
55.247 - </target>
55.248 - <target name="-init-debug-args">
55.249 - <property name="version-output" value="java version "${ant.java.version}"/>
55.250 - <condition property="have-jdk-older-than-1.4">
55.251 - <or>
55.252 - <contains string="${version-output}" substring="java version "1.0"/>
55.253 - <contains string="${version-output}" substring="java version "1.1"/>
55.254 - <contains string="${version-output}" substring="java version "1.2"/>
55.255 - <contains string="${version-output}" substring="java version "1.3"/>
55.256 - </or>
55.257 - </condition>
55.258 - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
55.259 - <istrue value="${have-jdk-older-than-1.4}"/>
55.260 - </condition>
55.261 - <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
55.262 - <os family="windows"/>
55.263 - </condition>
55.264 - <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
55.265 - <isset property="debug.transport"/>
55.266 - </condition>
55.267 - </target>
55.268 - <target depends="-init-debug-args" name="-init-macrodef-debug">
55.269 - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
55.270 - <attribute default="${main.class}" name="classname"/>
55.271 - <attribute default="${debug.classpath}" name="classpath"/>
55.272 - <element name="customize" optional="true"/>
55.273 - <sequential>
55.274 - <java classname="@{classname}" dir="${work.dir}" fork="true">
55.275 - <jvmarg line="${debug-args-line}"/>
55.276 - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
55.277 - <jvmarg line="${run.jvmargs}"/>
55.278 - <classpath>
55.279 - <path path="@{classpath}"/>
55.280 - </classpath>
55.281 - <syspropertyset>
55.282 - <propertyref prefix="run-sys-prop."/>
55.283 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
55.284 - </syspropertyset>
55.285 - <customize/>
55.286 - </java>
55.287 - </sequential>
55.288 - </macrodef>
55.289 - </target>
55.290 - <target name="-init-macrodef-java">
55.291 - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
55.292 - <attribute default="${main.class}" name="classname"/>
55.293 - <element name="customize" optional="true"/>
55.294 - <sequential>
55.295 - <java classname="@{classname}" dir="${work.dir}" fork="true">
55.296 - <jvmarg line="${run.jvmargs}"/>
55.297 - <classpath>
55.298 - <path path="${run.classpath}"/>
55.299 - </classpath>
55.300 - <syspropertyset>
55.301 - <propertyref prefix="run-sys-prop."/>
55.302 - <mapper from="run-sys-prop.*" to="*" type="glob"/>
55.303 - </syspropertyset>
55.304 - <customize/>
55.305 - </java>
55.306 - </sequential>
55.307 - </macrodef>
55.308 - </target>
55.309 - <target name="-init-presetdef-jar">
55.310 - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
55.311 - <jar compress="${jar.compress}" jarfile="${dist.jar}">
55.312 - <j2seproject1:fileset dir="${build.classes.dir}"/>
55.313 - </jar>
55.314 - </presetdef>
55.315 - </target>
55.316 - <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"/>
55.317 - <!--
55.318 - ===================
55.319 - COMPILATION SECTION
55.320 - ===================
55.321 - -->
55.322 - <target depends="init" name="deps-jar" unless="no.deps"/>
55.323 - <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
55.324 - <target depends="init" name="-check-automatic-build">
55.325 - <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
55.326 - </target>
55.327 - <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
55.328 - <antcall target="clean"/>
55.329 - </target>
55.330 - <target depends="init,deps-jar" name="-pre-pre-compile">
55.331 - <mkdir dir="${build.classes.dir}"/>
55.332 - </target>
55.333 - <target name="-pre-compile">
55.334 - <!-- Empty placeholder for easier customization. -->
55.335 - <!-- You can override this target in the ../build.xml file. -->
55.336 - </target>
55.337 - <target if="do.depend.true" name="-compile-depend">
55.338 - <j2seproject3:depend/>
55.339 - </target>
55.340 - <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
55.341 - <j2seproject3:javac/>
55.342 - <copy todir="${build.classes.dir}">
55.343 - <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
55.344 - </copy>
55.345 - </target>
55.346 - <target name="-post-compile">
55.347 - <!-- Empty placeholder for easier customization. -->
55.348 - <!-- You can override this target in the ../build.xml file. -->
55.349 - </target>
55.350 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
55.351 - <target name="-pre-compile-single">
55.352 - <!-- Empty placeholder for easier customization. -->
55.353 - <!-- You can override this target in the ../build.xml file. -->
55.354 - </target>
55.355 - <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
55.356 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
55.357 - <j2seproject3:force-recompile/>
55.358 - <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
55.359 - </target>
55.360 - <target name="-post-compile-single">
55.361 - <!-- Empty placeholder for easier customization. -->
55.362 - <!-- You can override this target in the ../build.xml file. -->
55.363 - </target>
55.364 - <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
55.365 - <!--
55.366 - ====================
55.367 - JAR BUILDING SECTION
55.368 - ====================
55.369 - -->
55.370 - <target depends="init" name="-pre-pre-jar">
55.371 - <dirname file="${dist.jar}" property="dist.jar.dir"/>
55.372 - <mkdir dir="${dist.jar.dir}"/>
55.373 - </target>
55.374 - <target name="-pre-jar">
55.375 - <!-- Empty placeholder for easier customization. -->
55.376 - <!-- You can override this target in the ../build.xml file. -->
55.377 - </target>
55.378 - <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
55.379 - <j2seproject1:jar/>
55.380 - </target>
55.381 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
55.382 - <j2seproject1:jar manifest="${manifest.file}"/>
55.383 - </target>
55.384 - <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">
55.385 - <j2seproject1:jar manifest="${manifest.file}">
55.386 - <j2seproject1:manifest>
55.387 - <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
55.388 - </j2seproject1:manifest>
55.389 - </j2seproject1:jar>
55.390 - <echo>To run this application from the command line without Ant, try:</echo>
55.391 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
55.392 - <property location="${dist.jar}" name="dist.jar.resolved"/>
55.393 - <pathconvert property="run.classpath.with.dist.jar">
55.394 - <path path="${run.classpath}"/>
55.395 - <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
55.396 - </pathconvert>
55.397 - <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
55.398 - </target>
55.399 - <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
55.400 - <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
55.401 - <pathconvert property="run.classpath.without.build.classes.dir">
55.402 - <path path="${run.classpath}"/>
55.403 - <map from="${build.classes.dir.resolved}" to=""/>
55.404 - </pathconvert>
55.405 - <pathconvert pathsep=" " property="jar.classpath">
55.406 - <path path="${run.classpath.without.build.classes.dir}"/>
55.407 - <chainedmapper>
55.408 - <flattenmapper/>
55.409 - <globmapper from="*" to="lib/*"/>
55.410 - </chainedmapper>
55.411 - </pathconvert>
55.412 - <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
55.413 - <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
55.414 - <fileset dir="${build.classes.dir}"/>
55.415 - <manifest>
55.416 - <attribute name="Main-Class" value="${main.class}"/>
55.417 - <attribute name="Class-Path" value="${jar.classpath}"/>
55.418 - </manifest>
55.419 - </copylibs>
55.420 - <echo>To run this application from the command line without Ant, try:</echo>
55.421 - <property location="${dist.jar}" name="dist.jar.resolved"/>
55.422 - <echo>java -jar "${dist.jar.resolved}"</echo>
55.423 - </target>
55.424 - <target name="-post-jar">
55.425 - <!-- Empty placeholder for easier customization. -->
55.426 - <!-- You can override this target in the ../build.xml file. -->
55.427 - </target>
55.428 - <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"/>
55.429 - <!--
55.430 - =================
55.431 - EXECUTION SECTION
55.432 - =================
55.433 - -->
55.434 - <target depends="init,compile" description="Run a main class." name="run">
55.435 - <j2seproject1:java>
55.436 - <customize>
55.437 - <arg line="${application.args}"/>
55.438 - </customize>
55.439 - </j2seproject1:java>
55.440 - </target>
55.441 - <target name="-do-not-recompile">
55.442 - <property name="javac.includes.binary" value=""/>
55.443 - </target>
55.444 - <target depends="init,-do-not-recompile,compile-single" name="run-single">
55.445 - <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
55.446 - <j2seproject1:java classname="${run.class}"/>
55.447 - </target>
55.448 - <!--
55.449 - =================
55.450 - DEBUGGING SECTION
55.451 - =================
55.452 - -->
55.453 - <target depends="init" if="netbeans.home" name="-debug-start-debugger">
55.454 - <j2seproject1:nbjpdastart name="${debug.class}"/>
55.455 - </target>
55.456 - <target depends="init,compile" name="-debug-start-debuggee">
55.457 - <j2seproject3:debug>
55.458 - <customize>
55.459 - <arg line="${application.args}"/>
55.460 - </customize>
55.461 - </j2seproject3:debug>
55.462 - </target>
55.463 - <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
55.464 - <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
55.465 - <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
55.466 - </target>
55.467 - <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
55.468 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
55.469 - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
55.470 - <j2seproject3:debug classname="${debug.class}"/>
55.471 - </target>
55.472 - <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
55.473 - <target depends="init" name="-pre-debug-fix">
55.474 - <fail unless="fix.includes">Must set fix.includes</fail>
55.475 - <property name="javac.includes" value="${fix.includes}.java"/>
55.476 - </target>
55.477 - <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
55.478 - <j2seproject1:nbjpdareload/>
55.479 - </target>
55.480 - <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
55.481 - <!--
55.482 - ===============
55.483 - JAVADOC SECTION
55.484 - ===============
55.485 - -->
55.486 - <target depends="init" name="-javadoc-build">
55.487 - <mkdir dir="${dist.javadoc.dir}"/>
55.488 - <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}">
55.489 - <classpath>
55.490 - <path path="${javac.classpath}"/>
55.491 - </classpath>
55.492 - <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
55.493 - <filename name="**/*.java"/>
55.494 - </fileset>
55.495 - </javadoc>
55.496 - </target>
55.497 - <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
55.498 - <nbbrowse file="${dist.javadoc.dir}/index.html"/>
55.499 - </target>
55.500 - <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
55.501 - <!--
55.502 - =========================
55.503 - JUNIT COMPILATION SECTION
55.504 - =========================
55.505 - -->
55.506 - <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
55.507 - <mkdir dir="${build.test.classes.dir}"/>
55.508 - </target>
55.509 - <target name="-pre-compile-test">
55.510 - <!-- Empty placeholder for easier customization. -->
55.511 - <!-- You can override this target in the ../build.xml file. -->
55.512 - </target>
55.513 - <target if="do.depend.true" name="-compile-test-depend">
55.514 - <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
55.515 - </target>
55.516 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
55.517 - <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
55.518 - <copy todir="${build.test.classes.dir}">
55.519 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
55.520 - </copy>
55.521 - </target>
55.522 - <target name="-post-compile-test">
55.523 - <!-- Empty placeholder for easier customization. -->
55.524 - <!-- You can override this target in the ../build.xml file. -->
55.525 - </target>
55.526 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
55.527 - <target name="-pre-compile-test-single">
55.528 - <!-- Empty placeholder for easier customization. -->
55.529 - <!-- You can override this target in the ../build.xml file. -->
55.530 - </target>
55.531 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
55.532 - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
55.533 - <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
55.534 - <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}"/>
55.535 - <copy todir="${build.test.classes.dir}">
55.536 - <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
55.537 - </copy>
55.538 - </target>
55.539 - <target name="-post-compile-test-single">
55.540 - <!-- Empty placeholder for easier customization. -->
55.541 - <!-- You can override this target in the ../build.xml file. -->
55.542 - </target>
55.543 - <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
55.544 - <!--
55.545 - =======================
55.546 - JUNIT EXECUTION SECTION
55.547 - =======================
55.548 - -->
55.549 - <target depends="init" if="have.tests" name="-pre-test-run">
55.550 - <mkdir dir="${build.test.results.dir}"/>
55.551 - </target>
55.552 - <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
55.553 - <j2seproject3:junit testincludes="**/*Test.java"/>
55.554 - </target>
55.555 - <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
55.556 - <fail if="tests.failed">Some tests failed; see details above.</fail>
55.557 - </target>
55.558 - <target depends="init" if="have.tests" name="test-report"/>
55.559 - <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
55.560 - <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
55.561 - <target depends="init" if="have.tests" name="-pre-test-run-single">
55.562 - <mkdir dir="${build.test.results.dir}"/>
55.563 - </target>
55.564 - <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
55.565 - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
55.566 - <j2seproject3:junit excludes="" includes="${test.includes}"/>
55.567 - </target>
55.568 - <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
55.569 - <fail if="tests.failed">Some tests failed; see details above.</fail>
55.570 - </target>
55.571 - <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"/>
55.572 - <!--
55.573 - =======================
55.574 - JUNIT DEBUGGING SECTION
55.575 - =======================
55.576 - -->
55.577 - <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
55.578 - <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
55.579 - <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
55.580 - <delete file="${test.report.file}"/>
55.581 - <mkdir dir="${build.test.results.dir}"/>
55.582 - <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}">
55.583 - <customize>
55.584 - <syspropertyset>
55.585 - <propertyref prefix="test-sys-prop."/>
55.586 - <mapper from="test-sys-prop.*" to="*" type="glob"/>
55.587 - </syspropertyset>
55.588 - <arg value="${test.class}"/>
55.589 - <arg value="showoutput=true"/>
55.590 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
55.591 - <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
55.592 - </customize>
55.593 - </j2seproject3:debug>
55.594 - </target>
55.595 - <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
55.596 - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
55.597 - </target>
55.598 - <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
55.599 - <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
55.600 - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
55.601 - </target>
55.602 - <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
55.603 - <!--
55.604 - =========================
55.605 - APPLET EXECUTION SECTION
55.606 - =========================
55.607 - -->
55.608 - <target depends="init,compile-single" name="run-applet">
55.609 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
55.610 - <j2seproject1:java classname="sun.applet.AppletViewer">
55.611 - <customize>
55.612 - <arg value="${applet.url}"/>
55.613 - </customize>
55.614 - </j2seproject1:java>
55.615 - </target>
55.616 - <!--
55.617 - =========================
55.618 - APPLET DEBUGGING SECTION
55.619 - =========================
55.620 - -->
55.621 - <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
55.622 - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
55.623 - <j2seproject3:debug classname="sun.applet.AppletViewer">
55.624 - <customize>
55.625 - <arg value="${applet.url}"/>
55.626 - </customize>
55.627 - </j2seproject3:debug>
55.628 - </target>
55.629 - <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
55.630 - <!--
55.631 - ===============
55.632 - CLEANUP SECTION
55.633 - ===============
55.634 - -->
55.635 - <target depends="init" name="deps-clean" unless="no.deps"/>
55.636 - <target depends="init" name="-do-clean">
55.637 - <delete dir="${build.dir}"/>
55.638 - <delete dir="${dist.dir}"/>
55.639 - </target>
55.640 - <target name="-post-clean">
55.641 - <!-- Empty placeholder for easier customization. -->
55.642 - <!-- You can override this target in the ../build.xml file. -->
55.643 - </target>
55.644 - <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
55.645 -</project>
56.1 --- a/task2/solution10/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,8 +0,0 @@
56.4 -build.xml.data.CRC32=6601af03
56.5 -build.xml.script.CRC32=2c84d7b2
56.6 -build.xml.stylesheet.CRC32=be360661
56.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
56.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
56.9 -nbproject/build-impl.xml.data.CRC32=6601af03
56.10 -nbproject/build-impl.xml.script.CRC32=5e67461a
56.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
57.1 --- a/task2/solution10/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,59 +0,0 @@
57.4 -application.title=basic
57.5 -application.vendor=vvessan
57.6 -build.classes.dir=${build.dir}/classes
57.7 -build.classes.excludes=**/*.java,**/*.form
57.8 -# This directory is removed when the project is cleaned:
57.9 -build.dir=build
57.10 -build.generated.dir=${build.dir}/generated
57.11 -# Only compile against the classpath explicitly listed here:
57.12 -build.sysclasspath=ignore
57.13 -build.test.classes.dir=${build.dir}/test/classes
57.14 -build.test.results.dir=${build.dir}/test/results
57.15 -debug.classpath=\
57.16 - ${run.classpath}
57.17 -debug.test.classpath=\
57.18 - ${run.test.classpath}
57.19 -# This directory is removed when the project is cleaned:
57.20 -dist.dir=dist
57.21 -dist.jar=${dist.dir}/Currency_Convertor_Solution_10.jar
57.22 -dist.javadoc.dir=${dist.dir}/javadoc
57.23 -excludes=
57.24 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
57.25 -includes=**
57.26 -jar.compress=false
57.27 -javac.classpath=
57.28 -# Space-separated list of extra javac options
57.29 -javac.compilerargs=
57.30 -javac.deprecation=false
57.31 -javac.source=1.5
57.32 -javac.target=1.5
57.33 -javac.test.classpath=\
57.34 - ${javac.classpath}:\
57.35 - ${build.classes.dir}:\
57.36 - ${file.reference.junit-4.4.jar}
57.37 -javadoc.additionalparam=
57.38 -javadoc.author=false
57.39 -javadoc.encoding=${source.encoding}
57.40 -javadoc.noindex=false
57.41 -javadoc.nonavbar=false
57.42 -javadoc.notree=false
57.43 -javadoc.private=false
57.44 -javadoc.splitindex=true
57.45 -javadoc.use=true
57.46 -javadoc.version=false
57.47 -javadoc.windowtitle=
57.48 -meta.inf.dir=${src.dir}/META-INF
57.49 -platform.active=default_platform
57.50 -run.classpath=\
57.51 - ${javac.classpath}:\
57.52 - ${build.classes.dir}
57.53 -# Space-separated list of JVM arguments used when running the project
57.54 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
57.55 -# or test-sys-prop.name=value to set system properties for unit tests):
57.56 -run.jvmargs=
57.57 -run.test.classpath=\
57.58 - ${javac.test.classpath}:\
57.59 - ${build.test.classes.dir}
57.60 -source.encoding=UTF-8
57.61 -src.dir=src
57.62 -test.src.dir=test
58.1 --- a/task2/solution10/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,16 +0,0 @@
58.4 -<?xml version="1.0" encoding="UTF-8"?>
58.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
58.6 - <type>org.netbeans.modules.java.j2seproject</type>
58.7 - <configuration>
58.8 - <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
58.9 - <name>Currency Convertor Solution 10</name>
58.10 - <minimum-ant-version>1.6.5</minimum-ant-version>
58.11 - <source-roots>
58.12 - <root id="src.dir"/>
58.13 - </source-roots>
58.14 - <test-roots>
58.15 - <root id="test.src.dir"/>
58.16 - </test-roots>
58.17 - </data>
58.18 - </configuration>
58.19 -</project>
59.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/ConstantRateConverter.java Tue Oct 07 01:18:23 2008 +0200
59.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
59.3 @@ -1,44 +0,0 @@
59.4 -package org.apidesign.apifest08.currency;
59.5 -
59.6 -import java.util.*;
59.7 -
59.8 -final class ConstantRateConverter implements CurrencyConverter {
59.9 -
59.10 - private final Currency from;
59.11 - private final Currency to;
59.12 -
59.13 - private final double rate;
59.14 -
59.15 - public ConstantRateConverter(Currency from, Currency to, double rate) throws IllegalArgumentException {
59.16 - if (from == null || to == null)
59.17 - throw new NullPointerException("None of the currencies can be null");
59.18 - if (from.equals(to))
59.19 - throw new IllegalArgumentException("Cannot create converter with two equal currencies");
59.20 - this.from = from;
59.21 - this.to = to;
59.22 - this.rate = rate;
59.23 - }
59.24 -
59.25 - @Override
59.26 - public double convert(double value, String from, String to)
59.27 - throws CurrencyConversionException, NullPointerException {
59.28 - return convert(value, Currency.getInstance(from), Currency.getInstance(to));
59.29 - }
59.30 -
59.31 - @Override
59.32 - public double convert(double value, Currency from, Currency to)
59.33 - throws NullPointerException, CurrencyConversionException {
59.34 -
59.35 - if (this.from.equals(from)) {
59.36 - if (!this.to.equals(to))
59.37 - throw new CurrencyConversionException(from, to, "Unsupported currency");
59.38 - return value * rate;
59.39 - }
59.40 - if (this.from.equals(to)) {
59.41 - if (!this.to.equals(from))
59.42 - throw new CurrencyConversionException(from, to, "Unsupported currency");
59.43 - return value / rate;
59.44 - }
59.45 - throw new CurrencyConversionException(from, to, "Unsupported currency");
59.46 - }
59.47 -}
60.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java Tue Oct 07 01:18:23 2008 +0200
60.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
60.3 @@ -1,42 +0,0 @@
60.4 -package org.apidesign.apifest08.currency;
60.5 -
60.6 -import java.util.*;
60.7 -
60.8 -/**
60.9 - * Exception thrown in cases that a CurrencyConverter is unable ensure requested accuracy of conversion.
60.10 - * Such situation may occur in cases that the client is not on-line, or the exchange rates are older than
60.11 - * requested etc. This exception is defined as RuntimeException to enable simple usage in simple applications,
60.12 - * but enable other applications to be informed about possible problems and prevent them from using
60.13 - * inaccurate data.
60.14 - */
60.15 -public final class CurrencyConversionException extends RuntimeException {
60.16 -
60.17 - private final Currency from;
60.18 - private final Currency to;
60.19 -
60.20 - CurrencyConversionException(Currency from, Currency to) {
60.21 - this(from, to, (Throwable) null);
60.22 - }
60.23 -
60.24 - CurrencyConversionException(Currency from, Currency to, Throwable throwable) {
60.25 - this(from, to, String.format("Failed to convert curency from %1$s to %2$s", from, to), throwable);
60.26 - }
60.27 -
60.28 - CurrencyConversionException(Currency from, Currency to, String message) {
60.29 - this(from, to, message, null);
60.30 - }
60.31 -
60.32 - CurrencyConversionException(Currency from, Currency to, String message, Throwable throwable) {
60.33 - super(message, throwable);
60.34 - this.from = from;
60.35 - this.to = to;
60.36 - }
60.37 -
60.38 - public Currency getFromCurrency() {
60.39 - return from;
60.40 - }
60.41 -
60.42 - public Currency getToCurrency() {
60.43 - return to;
60.44 - }
60.45 -}
61.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java Tue Oct 07 01:18:23 2008 +0200
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,48 +0,0 @@
61.4 -package org.apidesign.apifest08.currency;
61.5 -
61.6 -import java.util.*;
61.7 -
61.8 -/** This is the skeleton class for your API. You need to make it public, so
61.9 - * it is accessible to your client code (currently in Task1Test.java) file.
61.10 - * <p>
61.11 - * Feel free to create additional classes or rename this one, just keep all
61.12 - * the API and its implementation in this package. Do not spread it outside
61.13 - * to other packages.
61.14 - *
61.15 - * The converter will usually work internally with Currency class, to be more type-safe as String can be used
61.16 - * for almost anything. But methods taking strings as parameters are provided for convenience.
61.17 - */
61.18 -public interface CurrencyConverter {
61.19 -
61.20 - /**
61.21 - * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
61.22 - *
61.23 - * @param value that should be converted form one currency to the other
61.24 - * @param from ISO-4217 code of the currency of the value provided
61.25 - * @param to ISO-4212 code of the currency to which the value should be converted
61.26 - * @return value expressed in the target value
61.27 - * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
61.28 - * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
61.29 - * for example the exchange rates are not current, connection to exchange rates provider is not available
61.30 - * @throws NullPointerException if any of the specified currency ISO codes is null
61.31 - */
61.32 - // this method is provided to ensure future compatibility for converters supporting more than 2 currencies
61.33 - // - simpler methods with fewer arguments would make using such converters less intuitive
61.34 - double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
61.35 - throws CurrencyConversionException, NullPointerException, IllegalArgumentException;
61.36 -
61.37 - /**
61.38 - * Converts the specified value from one currency (from) to target currency (to).
61.39 - *
61.40 - * @param value that should be converted form one currency to the other
61.41 - * @param from ISO-4217 code of the currency of the value provided
61.42 - * @param to ISO-4212 code of the currency to which the value should be converted
61.43 - * @return value expressed in the target value
61.44 - * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
61.45 - * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
61.46 - * for example the exchange rates are not current, connection to exchange rates provider is not available
61.47 - * @throws NullPointerException if any of the specified currency ISO codes is null
61.48 - */
61.49 - double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
61.50 - throws CurrencyConversionException, NullPointerException;
61.51 -}
62.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java Tue Oct 07 01:18:23 2008 +0200
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,68 +0,0 @@
62.4 -package org.apidesign.apifest08.currency;
62.5 -
62.6 -import java.util.*;
62.7 -
62.8 -/**
62.9 - * CurrencyConversionService provides methods necessary for construction all necessary currency
62.10 - * conversion-related classes.
62.11 - */
62.12 -public interface CurrencyConverterProvider {
62.13 -
62.14 - /**
62.15 - * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
62.16 - *
62.17 - * @param amount1 amount of the money in the currency1
62.18 - * @param currency1 one of the supported currencies
62.19 - * @param amount2 amount of the money in the currency2
62.20 - * @param currency2 one of the supported currencies
62.21 - * @return converter able to convert between the two specified currencies
62.22 - * @throws IllegalArgumentException if any of the amount values is not positive
62.23 - * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
62.24 - */
62.25 - CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
62.26 - double amount2, /*@NotNull*/ String currency2)
62.27 - throws IllegalArgumentException, CurrencyNotAvailableException;
62.28 -
62.29 - /**
62.30 - * Retrieves converter that is capable of converting values between currency1 and currency2.
62.31 - * The exchange is specified in easy to understand way. By specifying values in two currencies that
62.32 - * are equal. For example CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR.
62.33 - * This enables user to use this method without having to calculate anything. In general this can be
62.34 - * expressed by formula amount1[currency1] = amount2[currency2].
62.35 - *
62.36 - * @param amount1 amount of the money in the currency1
62.37 - * @param currency1 one of the supported currencies
62.38 - * @param amount2 amount of the money in the currency2
62.39 - * @param currency2 one of the supported currencies
62.40 - * @return converter able to convert between the two specified currencies
62.41 - * @throws IllegalArgumentException if any of the amount values is not positive
62.42 - * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
62.43 - */
62.44 - CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
62.45 - double amount2, /*@NotNull*/ Currency currency2)
62.46 - throws IllegalArgumentException, CurrencyNotAvailableException;
62.47 -
62.48 - /**
62.49 - * Creates a new converter that is able to convert between all specified currencies. The converter
62.50 - * may optionally support additional currencies that were not specified.
62.51 - *
62.52 - * @param currencies that the converter should be created for
62.53 - * @return converter able to convert between all specified currencies
62.54 - * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
62.55 - * @throws NullPointerException if any of the specified currencies is null of the array is null
62.56 - */
62.57 - CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
62.58 - throws CurrencyNotAvailableException, NullPointerException;
62.59 -
62.60 - /**
62.61 - * Convenient method for getConverter(Currency...)
62.62 - *
62.63 - * @param currencies that the converter should be created for
62.64 - * @return converter able to convert between all specified currencies
62.65 - * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
62.66 - * @throws NullPointerException if any of the specified currencies is null, or the array is null
62.67 - * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
62.68 - */
62.69 - CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
62.70 - throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;
62.71 -}
62.72 \ No newline at end of file
63.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyNotAvailableException.java Tue Oct 07 01:18:23 2008 +0200
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,21 +0,0 @@
63.4 -package org.apidesign.apifest08.currency;
63.5 -
63.6 -import java.util.*;
63.7 -
63.8 -public final class CurrencyNotAvailableException extends RuntimeException {
63.9 -
63.10 - private final Currency currency;
63.11 -
63.12 - CurrencyNotAvailableException(Currency currency) {
63.13 - this(currency, String.format("Currency %1$s not available", currency));
63.14 - }
63.15 -
63.16 - CurrencyNotAvailableException(Currency currency, String message) {
63.17 - super(message);
63.18 - this.currency = currency;
63.19 - }
63.20 -
63.21 - public Currency getCurrency() {
63.22 - return currency;
63.23 - }
63.24 -}
64.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/MultiCurrencyConstantRateConverter.java Tue Oct 07 01:18:23 2008 +0200
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,71 +0,0 @@
64.4 -package org.apidesign.apifest08.currency;
64.5 -
64.6 -import java.util.*;
64.7 -
64.8 -final class MultiCurrencyConstantRateConverter implements CurrencyConverter {
64.9 -
64.10 - private final Map<Currency, Double> rates;
64.11 -
64.12 - public MultiCurrencyConstantRateConverter(Map<Currency, Double> rates) {
64.13 - this.rates = rates;
64.14 - }
64.15 -
64.16 - /**
64.17 - * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
64.18 - *
64.19 - * @param value that should be converted form one currency to the other
64.20 - * @param from ISO-4217 code of the currency of the value provided
64.21 - * @param to ISO-4212 code of the currency to which the value should be converted
64.22 - *
64.23 - * @return value expressed in the target value
64.24 - *
64.25 - * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
64.26 - * @throws CurrencyConversionException
64.27 - * if the conversion cannot be performed with desired parameters, for
64.28 - * example the exchange rates are not current, connection to exchange rates
64.29 - * provider is not available
64.30 - * @throws NullPointerException if any of the specified currency ISO codes is null
64.31 - */
64.32 - // this method is provided to ensure future compatibility for converters supporting more than 2 currencies
64.33 - // - simpler methods with fewer arguments would make using such converters less intuitive
64.34 - @Override
64.35 - public double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
64.36 - throws CurrencyConversionException, NullPointerException, IllegalArgumentException {
64.37 - return convert(value, Currency.getInstance(from), Currency.getInstance(to));
64.38 - }
64.39 -
64.40 - /**
64.41 - * Converts the specified value from one currency (from) to target currency (to).
64.42 - *
64.43 - * @param value that should be converted form one currency to the other
64.44 - * @param from ISO-4217 code of the currency of the value provided
64.45 - * @param to ISO-4212 code of the currency to which the value should be converted
64.46 - *
64.47 - * @return value expressed in the target value
64.48 - *
64.49 - * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
64.50 - * @throws CurrencyConversionException
64.51 - * if the conversion cannot be performed with desired parameters, for
64.52 - * example the exchange rates are not current, connection to exchange rates
64.53 - * provider is not available
64.54 - * @throws NullPointerException if any of the specified currency ISO codes is null
64.55 - */
64.56 - @Override
64.57 - public double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
64.58 - throws CurrencyConversionException, NullPointerException {
64.59 -
64.60 - // this is not necessary, but we let users know that nulls are not allowed here - should be handled by annotations
64.61 - if (from == null || to == null)
64.62 - throw new NullPointerException("One of the specified currencies in null");
64.63 -
64.64 - Double fromRate = rates.get(from);
64.65 - Double toRate = rates.get(to);
64.66 -
64.67 - if (fromRate == null)
64.68 - throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", from));
64.69 - if (toRate == null)
64.70 - throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", to));
64.71 -
64.72 - return (value / fromRate) * toRate;
64.73 - }
64.74 -}
65.1 --- a/task2/solution10/src/org/apidesign/apifest08/currency/OfflineConverterProvider.java Tue Oct 07 01:18:23 2008 +0200
65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
65.3 @@ -1,120 +0,0 @@
65.4 -package org.apidesign.apifest08.currency;
65.5 -
65.6 -import java.util.*;
65.7 -
65.8 -/**
65.9 - * ConvertorProvider class is introduced to handle
65.10 - */
65.11 -public final class OfflineConverterProvider implements CurrencyConverterProvider {
65.12 -
65.13 -
65.14 - // we can't synchronize on DEFAULT as it's not final and can even be null in synchronized section
65.15 - private static final Object LOCK = new Object();
65.16 - private static CurrencyConverterProvider DEFAULT;
65.17 -
65.18 - // this is not nice and could be static, but future usage is uncertain and it's pretty easy to create
65.19 - private final Map<Currency, Double> rates;
65.20 -
65.21 - private OfflineConverterProvider() {
65.22 - rates = new HashMap<Currency, Double>();
65.23 - // simple initialization just for Task1Test
65.24 - rates.put(Currency.getInstance("USD"), 100.0);
65.25 - rates.put(Currency.getInstance("CZK"), 1700.0);
65.26 - rates.put(Currency.getInstance("SKK"), 2125.0);
65.27 - }
65.28 -
65.29 - /**
65.30 - * Provides default implementation of ConvertorProvider. This Converter does nos not ensure accuracy
65.31 - * of exchange rates, but should be functional at any circumstances including being offline.
65.32 - *
65.33 - * @return
65.34 - */
65.35 - public static CurrencyConverterProvider getInstance() {
65.36 - // should be necessary in current implementation as creating CurrencyConverterProvider is cheap, but for future
65.37 - if (DEFAULT == null)
65.38 - synchronized (LOCK) {
65.39 - if (DEFAULT == null)
65.40 - DEFAULT = new OfflineConverterProvider();
65.41 - }
65.42 - return DEFAULT;
65.43 - }
65.44 -
65.45 - @Override
65.46 - public CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
65.47 - double amount2, /*@NotNull*/ String currency2)
65.48 - throws IllegalArgumentException {
65.49 -
65.50 - return getConverter(amount1, Currency.getInstance(currency2), amount2, Currency.getInstance(currency1));
65.51 - }
65.52 -
65.53 - /**
65.54 - * Retrieves converter that is capable of converting values between currency1 and currency2. The exchange is
65.55 - * specified in easy to understand way. By specifying values in two currencies that are equal. For example
65.56 - * CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR. This enables user to
65.57 - * use this method without having to calculate anything. In general this can be expressed by formula
65.58 - * amount1[currency1] = amount2[currency2].
65.59 - *
65.60 - * @param amount1
65.61 - * @param currency1
65.62 - * @param amount2
65.63 - * @param currency2
65.64 - *
65.65 - * @return
65.66 - *
65.67 - * @throws IllegalArgumentException
65.68 - * @throws CurrencyNotAvailableException
65.69 - *
65.70 - */
65.71 - @Override
65.72 - public CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
65.73 - double amount2, /*@NotNull*/ Currency currency2)
65.74 - throws IllegalArgumentException, CurrencyNotAvailableException {
65.75 - if (amount1 <= 0.0 || amount2 <= 0.0)
65.76 - throw new IllegalArgumentException(
65.77 - String.format("The specified currency values (%1$s, %2$s)", amount1, amount2));
65.78 - return new ConstantRateConverter(currency2, currency1, amount2 / amount1);
65.79 - }
65.80 -
65.81 - /**
65.82 - * Creates a new converter that is able to convert between all specified currencies.
65.83 - *
65.84 - * @param currencies that the converter should be created for
65.85 - *
65.86 - * @return converter able to convert between all specified currencies
65.87 - *
65.88 - * @throws CurrencyNotAvailableException
65.89 - * thrown when one of the currencies is not available
65.90 - */
65.91 - @Override
65.92 - public CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies) throws CurrencyNotAvailableException {
65.93 - for (Currency c : currencies) {
65.94 - if (c == null)
65.95 - throw new NullPointerException("One of the specified currencies is null");
65.96 - if (!rates.containsKey(c))
65.97 - throw new CurrencyNotAvailableException(c);
65.98 - }
65.99 - return new MultiCurrencyConstantRateConverter(rates);
65.100 - }
65.101 -
65.102 - /**
65.103 - * Creates a new converter that is able to convert between all specified currencies.
65.104 - *
65.105 - * @param currencies that the converter should be created for
65.106 - *
65.107 - * @return converter able to convert between all specified currencies
65.108 - *
65.109 - * @throws CurrencyNotAvailableException
65.110 - * thrown when one of the currencies is not available
65.111 - * @throws NullPointerException if any of the specified currencies is null
65.112 - * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
65.113 - */
65.114 - @Override
65.115 - public CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
65.116 - throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException {
65.117 -
65.118 - Currency[] c2 = new Currency[currencies.length];
65.119 - for (int i = 0; i < c2.length; i++)
65.120 - c2[i] = Currency.getInstance(currencies[i]);
65.121 - return getConverter(c2);
65.122 - }
65.123 -}
66.1 --- a/task2/solution10/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
66.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
66.3 @@ -1,134 +0,0 @@
66.4 -package org.apidesign.apifest08.test;
66.5 -
66.6 -import junit.framework.*;
66.7 -import org.apidesign.apifest08.currency.*;
66.8 -
66.9 -import java.util.*;
66.10 -
66.11 -/** Finish the Convertor API, and then write bodies of methods inside
66.12 - * of this class to match the given tasks. To fullfil your task, use the
66.13 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
66.14 - * Do not you reflection, or other hacks as your code
66.15 - * shall run without any runtime permissions.
66.16 - */
66.17 -public class Task1Test extends TestCase {
66.18 -
66.19 - private static final String
66.20 - USD = "USD",
66.21 - CZK = "CZK",
66.22 - SKK = "SKK";
66.23 -
66.24 - private static final Currency
66.25 - USD2 = Currency.getInstance(USD),
66.26 - CZK2 = Currency.getInstance(CZK),
66.27 - SKK2 = Currency.getInstance(SKK);
66.28 -
66.29 - public Task1Test(String testName) {
66.30 - super(testName);
66.31 - }
66.32 -
66.33 - @Override
66.34 - protected void setUp() throws Exception {
66.35 - }
66.36 -
66.37 - @Override
66.38 - protected void tearDown() throws Exception {
66.39 - }
66.40 -
66.41 - /** Create convertor that understands two currencies, CZK and
66.42 - * USD. Make 1 USD == 17 CZK.
66.43 - *
66.44 - * Creation of the convertor shall not require subclassing of any class
66.45 - * or interface on the client side.
66.46 - *
66.47 - * @return prepared convertor ready for converting USD to CZK and CZK to USD
66.48 - */
66.49 - public static CurrencyConverter createCZKtoUSD() {
66.50 - return OfflineConverterProvider.getInstance().getConverter(17, CZK, 1, USD);
66.51 - }
66.52 -
66.53 - public static CurrencyConverter createCZKtoUSD2() {
66.54 - return OfflineConverterProvider.getInstance().getConverter(CZK, USD);
66.55 - }
66.56 -
66.57 - /** Create convertor that understands two currencies, CZK and
66.58 - * SKK. Make 100 SKK == 80 CZK.
66.59 - *
66.60 - * Creation of the convertor shall not require subclassing of any class
66.61 - * or interface on the client side.
66.62 - *
66.63 - * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
66.64 - */
66.65 - public static CurrencyConverter createSKKtoCZK() {
66.66 - return OfflineConverterProvider.getInstance().getConverter(100, SKK, 80, CZK);
66.67 - }
66.68 -
66.69 - public static CurrencyConverter createSKKtoCZK2() {
66.70 - return OfflineConverterProvider.getInstance().getConverter(SKK, CZK);
66.71 - }
66.72 -
66.73 - /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
66.74 - * with it.
66.75 - */
66.76 - public void testCurrencyCZKUSD() throws Exception {
66.77 - CurrencyConverter c = createCZKtoUSD();
66.78 - testCZKUSD(c);
66.79 -
66.80 - // test without specifying rates
66.81 - c = createCZKtoUSD2();
66.82 - testCZKUSD(c);
66.83 - }
66.84 -
66.85 - private void testCZKUSD(CurrencyConverter c) {
66.86 - double czk, usd;
66.87 - // convert $5 to CZK using c:
66.88 - // assertEquals("Result is 85 CZK");
66.89 - czk = c.convert(5, USD, CZK);
66.90 - assertEquals(85.0, czk, 0.0);
66.91 - czk = c.convert(5, USD2, CZK2);
66.92 - assertEquals(85.0, czk, 0.0);
66.93 -
66.94 - // convert $8 to CZK
66.95 - // assertEquals("Result is 136 CZK");
66.96 - czk = c.convert(8, USD, CZK);
66.97 - assertEquals(136.0, czk, 0.0);
66.98 - czk = c.convert(8, USD2, CZK2);
66.99 - assertEquals(136.0, czk, 0.0);
66.100 -
66.101 - // convert 1003CZK to USD
66.102 - // assertEquals("Result is 59 USD");
66.103 - usd = c.convert(1003, CZK, USD);
66.104 - assertEquals(59.0, usd, 0.0);
66.105 - usd = c.convert(1003, CZK2, USD2);
66.106 - assertEquals(59.0, usd, 0.0);
66.107 - }
66.108 -
66.109 - /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
66.110 - * with it.
66.111 - */
66.112 - public void testCurrencySKKCZK() throws Exception {
66.113 - CurrencyConverter c = createSKKtoCZK();
66.114 - testCZKSKK(c);
66.115 -
66.116 - // test without specifying rates
66.117 - c = createSKKtoCZK2();
66.118 - testCZKSKK(c);
66.119 - }
66.120 -
66.121 - private void testCZKSKK(CurrencyConverter c) {
66.122 - double czk, skk;
66.123 - // convert 16CZK using c:
66.124 - // assertEquals("Result is 20 SKK");
66.125 - skk = c.convert(16, CZK, SKK);
66.126 - assertEquals(20.0, skk, 0.0);
66.127 - skk = c.convert(16, CZK2, SKK2);
66.128 - assertEquals(20.0, skk, 0.0);
66.129 -
66.130 - // convert 500SKK to CZK
66.131 - // assertEquals("Result is 400 CZK");
66.132 - czk = c.convert(500, SKK, CZK);
66.133 - assertEquals(400.0, czk, 0.0);
66.134 - czk = c.convert(500, SKK2, CZK2);
66.135 - assertEquals(400.0, czk, 0.0);
66.136 - }
66.137 -}
66.138 \ No newline at end of file