Getting ready for task2: copying all solutions to new locations
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 01 Oct 2008 10:43:05 +0200
changeset 29f6073056b9fe
parent 28 36331f7244bd
child 30 87751527ce97
Getting ready for task2: copying all solutions to new locations
task1/README
task2/solution01/build.xml
task2/solution01/nbproject/build-impl.xml
task2/solution01/nbproject/genfiles.properties
task2/solution01/nbproject/project.properties
task2/solution01/nbproject/project.xml
task2/solution01/src/org/apidesign/apifest08/currency/AbstractConvertorFactory.java
task2/solution01/src/org/apidesign/apifest08/currency/AbstractCurrencyConvertor.java
task2/solution01/src/org/apidesign/apifest08/currency/CannotConvertException.java
task2/solution01/src/org/apidesign/apifest08/currency/CannotInstantiateFactoryException.java
task2/solution01/src/org/apidesign/apifest08/currency/CannotProvideValueException.java
task2/solution01/src/org/apidesign/apifest08/currency/ConversionProperties.java
task2/solution01/src/org/apidesign/apifest08/currency/ConversionRatioProvider.java
task2/solution01/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution01/src/org/apidesign/apifest08/currency/ConvertorNotAvailableException.java
task2/solution01/src/org/apidesign/apifest08/currency/ConvertorsFactory.java
task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactory.java
task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactoryImpl.java
task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorImpl.java
task2/solution01/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution02/build.xml
task2/solution02/nbproject/build-impl.xml
task2/solution02/nbproject/genfiles.properties
task2/solution02/nbproject/project.properties
task2/solution02/nbproject/project.xml
task2/solution02/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task2/solution02/src/org/apidesign/apifest08/currency/DefaultConvertor.java
task2/solution02/src/org/apidesign/apifest08/currency/Money.java
task2/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java
task2/solution02/test/org/apidesign/apifest08/test/ConvertorFactoryTest.java
task2/solution02/test/org/apidesign/apifest08/test/ConvertorTest.java
task2/solution02/test/org/apidesign/apifest08/test/MoneyTest.java
task2/solution02/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution03/build.xml
task2/solution03/nbproject/build-impl.xml
task2/solution03/nbproject/genfiles.properties
task2/solution03/nbproject/project.properties
task2/solution03/nbproject/project.xml
task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution03/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution04/build.xml
task2/solution04/nbproject/build-impl.xml
task2/solution04/nbproject/genfiles.properties
task2/solution04/nbproject/project.properties
task2/solution04/nbproject/project.xml
task2/solution04/src/org/apidesign/apifest08/currency/ConverterImpl.java
task2/solution04/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution04/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task2/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java
task2/solution04/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution05/build.xml
task2/solution05/nbproject/build-impl.xml
task2/solution05/nbproject/genfiles.properties
task2/solution05/nbproject/project.properties
task2/solution05/nbproject/project.xml
task2/solution05/src/org/apidesign/apifest08/currency/Amount.java
task2/solution05/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task2/solution05/src/org/apidesign/apifest08/currency/ConvertorImpl.java
task2/solution05/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution06/build.xml
task2/solution06/nbproject/build-impl.xml
task2/solution06/nbproject/genfiles.properties
task2/solution06/nbproject/project.properties
task2/solution06/nbproject/project.xml
task2/solution06/src/org/apidesign/apifest08/currency/Amount.java
task2/solution06/src/org/apidesign/apifest08/currency/Assert.java
task2/solution06/src/org/apidesign/apifest08/currency/ConversionException.java
task2/solution06/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution06/src/org/apidesign/apifest08/currency/CurrencyException.java
task2/solution06/src/org/apidesign/apifest08/currency/UnsupportedConversionException.java
task2/solution06/test/org/apidesign/apifest08/test/Currencies.java
task2/solution06/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution07/build.xml
task2/solution07/nbproject/build-impl.xml
task2/solution07/nbproject/genfiles.properties
task2/solution07/nbproject/project.properties
task2/solution07/nbproject/project.xml
task2/solution07/src/org/apidesign/apifest08/currency/ConversionRate.java
task2/solution07/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution07/src/org/apidesign/apifest08/currency/DelegatingConvertor.java
task2/solution07/src/org/apidesign/apifest08/currency/IllegalRequestSubtypeException.java
task2/solution07/src/org/apidesign/apifest08/currency/MonetaryAmount.java
task2/solution07/src/org/apidesign/apifest08/currency/TableConvertor.java
task2/solution07/test/org/apidesign/apifest08/test/ContractImposingDelegatingConvertor.java
task2/solution07/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution08/build.xml
task2/solution08/nbproject/build-impl.xml
task2/solution08/nbproject/genfiles.properties
task2/solution08/nbproject/project.properties
task2/solution08/nbproject/project.xml
task2/solution08/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution08/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution09/build.xml
task2/solution09/nbproject/build-impl.xml
task2/solution09/nbproject/genfiles.properties
task2/solution09/nbproject/project.properties
task2/solution09/nbproject/project.xml
task2/solution09/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task2/solution09/src/org/apidesign/apifest08/currency/CurrencyType.java
task2/solution09/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution10/build.xml
task2/solution10/nbproject/.DS_Store
task2/solution10/nbproject/build-impl.xml
task2/solution10/nbproject/genfiles.properties
task2/solution10/nbproject/project.properties
task2/solution10/nbproject/project.xml
task2/solution10/src/org/apidesign/apifest08/currency/ConstantRateConverter.java
task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java
task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java
task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java
task2/solution10/src/org/apidesign/apifest08/currency/CurrencyNotAvailableException.java
task2/solution10/src/org/apidesign/apifest08/currency/MultiCurrencyConstantRateConverter.java
task2/solution10/src/org/apidesign/apifest08/currency/OfflineConverterProvider.java
task2/solution10/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution11/build.xml
task2/solution11/nbproject/build-impl.xml
task2/solution11/nbproject/genfiles.properties
task2/solution11/nbproject/project.properties
task2/solution11/nbproject/project.xml
task2/solution11/src/org/apidesign/apifest08/currency/Computer.java
task2/solution11/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution11/src/org/apidesign/apifest08/currency/CurrencyValue.java
task2/solution11/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution12/build.xml
task2/solution12/nbproject/build-impl.xml
task2/solution12/nbproject/genfiles.properties
task2/solution12/nbproject/project.properties
task2/solution12/nbproject/project.xml
task2/solution12/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution12/src/org/apidesign/apifest08/currency/ExchangeRate.java
task2/solution12/src/org/apidesign/apifest08/currency/exceptions/ConvertorException.java
task2/solution12/src/org/apidesign/apifest08/currency/exceptions/InvalidCurrencyException.java
task2/solution12/src/org/apidesign/apifest08/currency/exceptions/UnknownConvertorException.java
task2/solution12/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution13/build.xml
task2/solution13/nbproject/build-impl.xml
task2/solution13/nbproject/genfiles.properties
task2/solution13/nbproject/project.properties
task2/solution13/nbproject/project.xml
task2/solution13/src/org/apidesign/apifest08/currency/ConversionResult.java
task2/solution13/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution13/src/org/apidesign/apifest08/currency/ConvertorCurrency.java
task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java
task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRateProvider.java
task2/solution13/test/org/apidesign/apifest08/test/Task1Test.java
task2/solution14/build.xml
task2/solution14/nbproject/build-impl.xml
task2/solution14/nbproject/genfiles.properties
task2/solution14/nbproject/project.properties
task2/solution14/nbproject/project.xml
task2/solution14/src/org/apidesign/apifest08/currency/Convertor.java
task2/solution14/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task2/solution14/src/org/apidesign/apifest08/currency/Rate.java
task2/solution14/test/org/apidesign/apifest08/test/Task1Test.java
     1.1 --- a/task1/README	Tue Sep 30 16:11:32 2008 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,9 +0,0 @@
     1.4 -This directory shall contain solutions for the task1.
     1.5 -Each solution is NetBeans Java SE project, in its own
     1.6 -directory solution<id>. The id is a number of the solution.
     1.7 -A README file in a solution<id> dir can contain
     1.8 -detailed information on the solution and
     1.9 -shall somehow reflect the internals and be based on
    1.10 -some significant aspect used in the solution. For
    1.11 -example: welltested, delegating, verbose, etc.
    1.12 -
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/task2/solution01/build.xml	Wed Oct 01 10:43:05 2008 +0200
     2.3 @@ -0,0 +1,69 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<!-- You may freely edit this file. See commented blocks below for -->
     2.6 +<!-- some examples of how to customize the build. -->
     2.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
     2.8 +<project name="currency" default="default" basedir=".">
     2.9 +    <description>Builds, tests, and runs the project.</description>
    2.10 +    <import file="nbproject/build-impl.xml"/>
    2.11 +    <!--
    2.12 +
    2.13 +    There exist several targets which are by default empty and which can be 
    2.14 +    used for execution of your tasks. These targets are usually executed 
    2.15 +    before and after some main targets. They are: 
    2.16 +
    2.17 +      -pre-init:                 called before initialization of project properties
    2.18 +      -post-init:                called after initialization of project properties
    2.19 +      -pre-compile:              called before javac compilation
    2.20 +      -post-compile:             called after javac compilation
    2.21 +      -pre-compile-single:       called before javac compilation of single file
    2.22 +      -post-compile-single:      called after javac compilation of single file
    2.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
    2.24 +      -post-compile-test:        called after javac compilation of JUnit tests
    2.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
    2.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
    2.27 +      -pre-jar:                  called before JAR building
    2.28 +      -post-jar:                 called after JAR building
    2.29 +      -post-clean:               called after cleaning build products
    2.30 +
    2.31 +    (Targets beginning with '-' are not intended to be called on their own.)
    2.32 +
    2.33 +    Example of inserting an obfuscator after compilation could look like this:
    2.34 +
    2.35 +        <target name="-post-compile">
    2.36 +            <obfuscate>
    2.37 +                <fileset dir="${build.classes.dir}"/>
    2.38 +            </obfuscate>
    2.39 +        </target>
    2.40 +
    2.41 +    For list of available properties check the imported 
    2.42 +    nbproject/build-impl.xml file. 
    2.43 +
    2.44 +
    2.45 +    Another way to customize the build is by overriding existing main targets.
    2.46 +    The targets of interest are: 
    2.47 +
    2.48 +      -init-macrodef-javac:     defines macro for javac compilation
    2.49 +      -init-macrodef-junit:     defines macro for junit execution
    2.50 +      -init-macrodef-debug:     defines macro for class debugging
    2.51 +      -init-macrodef-java:      defines macro for class execution
    2.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
    2.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
    2.54 +      run:                      execution of project 
    2.55 +      -javadoc-build:           Javadoc generation
    2.56 +      test-report:              JUnit report generation
    2.57 +
    2.58 +    An example of overriding the target for project execution could look like this:
    2.59 +
    2.60 +        <target name="run" depends="currency-impl.jar">
    2.61 +            <exec dir="bin" executable="launcher.exe">
    2.62 +                <arg file="${dist.jar}"/>
    2.63 +            </exec>
    2.64 +        </target>
    2.65 +
    2.66 +    Notice that the overridden target depends on the jar target and not only on 
    2.67 +    the compile target as the regular run target does. Again, for a list of available 
    2.68 +    properties which you can use, check the target you are overriding in the
    2.69 +    nbproject/build-impl.xml file. 
    2.70 +
    2.71 +    -->
    2.72 +</project>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/task2/solution01/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
     3.3 @@ -0,0 +1,642 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<!--
     3.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
     3.7 +***         EDIT ../build.xml INSTEAD         ***
     3.8 +
     3.9 +For the purpose of easier reading the script
    3.10 +is divided into following sections:
    3.11 +
    3.12 +  - initialization
    3.13 +  - compilation
    3.14 +  - jar
    3.15 +  - execution
    3.16 +  - debugging
    3.17 +  - javadoc
    3.18 +  - junit compilation
    3.19 +  - junit execution
    3.20 +  - junit debugging
    3.21 +  - applet
    3.22 +  - cleanup
    3.23 +
    3.24 +        -->
    3.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">
    3.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
    3.27 +    <!-- 
    3.28 +                ======================
    3.29 +                INITIALIZATION SECTION 
    3.30 +                ======================
    3.31 +            -->
    3.32 +    <target name="-pre-init">
    3.33 +        <!-- Empty placeholder for easier customization. -->
    3.34 +        <!-- You can override this target in the ../build.xml file. -->
    3.35 +    </target>
    3.36 +    <target depends="-pre-init" name="-init-private">
    3.37 +        <property file="nbproject/private/config.properties"/>
    3.38 +        <property file="nbproject/private/configs/${config}.properties"/>
    3.39 +        <property file="nbproject/private/private.properties"/>
    3.40 +    </target>
    3.41 +    <target depends="-pre-init,-init-private" name="-init-user">
    3.42 +        <property file="${user.properties.file}"/>
    3.43 +        <!-- The two properties below are usually overridden -->
    3.44 +        <!-- by the active platform. Just a fallback. -->
    3.45 +        <property name="default.javac.source" value="1.4"/>
    3.46 +        <property name="default.javac.target" value="1.4"/>
    3.47 +    </target>
    3.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
    3.49 +        <property file="nbproject/configs/${config}.properties"/>
    3.50 +        <property file="nbproject/project.properties"/>
    3.51 +    </target>
    3.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
    3.53 +        <available file="${manifest.file}" property="manifest.available"/>
    3.54 +        <condition property="manifest.available+main.class">
    3.55 +            <and>
    3.56 +                <isset property="manifest.available"/>
    3.57 +                <isset property="main.class"/>
    3.58 +                <not>
    3.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
    3.60 +                </not>
    3.61 +            </and>
    3.62 +        </condition>
    3.63 +        <condition property="manifest.available+main.class+mkdist.available">
    3.64 +            <and>
    3.65 +                <istrue value="${manifest.available+main.class}"/>
    3.66 +                <isset property="libs.CopyLibs.classpath"/>
    3.67 +            </and>
    3.68 +        </condition>
    3.69 +        <condition property="have.tests">
    3.70 +            <or>
    3.71 +                <available file="${test.src.dir}"/>
    3.72 +            </or>
    3.73 +        </condition>
    3.74 +        <condition property="have.sources">
    3.75 +            <or>
    3.76 +                <available file="${src.dir}"/>
    3.77 +            </or>
    3.78 +        </condition>
    3.79 +        <condition property="netbeans.home+have.tests">
    3.80 +            <and>
    3.81 +                <isset property="netbeans.home"/>
    3.82 +                <isset property="have.tests"/>
    3.83 +            </and>
    3.84 +        </condition>
    3.85 +        <condition property="no.javadoc.preview">
    3.86 +            <and>
    3.87 +                <isset property="javadoc.preview"/>
    3.88 +                <isfalse value="${javadoc.preview}"/>
    3.89 +            </and>
    3.90 +        </condition>
    3.91 +        <property name="run.jvmargs" value=""/>
    3.92 +        <property name="javac.compilerargs" value=""/>
    3.93 +        <property name="work.dir" value="${basedir}"/>
    3.94 +        <condition property="no.deps">
    3.95 +            <and>
    3.96 +                <istrue value="${no.dependencies}"/>
    3.97 +            </and>
    3.98 +        </condition>
    3.99 +        <property name="javac.debug" value="true"/>
   3.100 +        <property name="javadoc.preview" value="true"/>
   3.101 +        <property name="application.args" value=""/>
   3.102 +        <property name="source.encoding" value="${file.encoding}"/>
   3.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
   3.104 +            <and>
   3.105 +                <isset property="javadoc.encoding"/>
   3.106 +                <not>
   3.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
   3.108 +                </not>
   3.109 +            </and>
   3.110 +        </condition>
   3.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
   3.112 +        <property name="includes" value="**"/>
   3.113 +        <property name="excludes" value=""/>
   3.114 +        <property name="do.depend" value="false"/>
   3.115 +        <condition property="do.depend.true">
   3.116 +            <istrue value="${do.depend}"/>
   3.117 +        </condition>
   3.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
   3.119 +            <and>
   3.120 +                <isset property="jaxws.endorsed.dir"/>
   3.121 +                <available file="nbproject/jaxws-build.xml"/>
   3.122 +            </and>
   3.123 +        </condition>
   3.124 +    </target>
   3.125 +    <target name="-post-init">
   3.126 +        <!-- Empty placeholder for easier customization. -->
   3.127 +        <!-- You can override this target in the ../build.xml file. -->
   3.128 +    </target>
   3.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
   3.130 +        <fail unless="src.dir">Must set src.dir</fail>
   3.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
   3.132 +        <fail unless="build.dir">Must set build.dir</fail>
   3.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
   3.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
   3.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
   3.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
   3.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
   3.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
   3.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
   3.140 +    </target>
   3.141 +    <target name="-init-macrodef-property">
   3.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.143 +            <attribute name="name"/>
   3.144 +            <attribute name="value"/>
   3.145 +            <sequential>
   3.146 +                <property name="@{name}" value="${@{value}}"/>
   3.147 +            </sequential>
   3.148 +        </macrodef>
   3.149 +    </target>
   3.150 +    <target name="-init-macrodef-javac">
   3.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.152 +            <attribute default="${src.dir}" name="srcdir"/>
   3.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.154 +            <attribute default="${javac.classpath}" name="classpath"/>
   3.155 +            <attribute default="${includes}" name="includes"/>
   3.156 +            <attribute default="${excludes}" name="excludes"/>
   3.157 +            <attribute default="${javac.debug}" name="debug"/>
   3.158 +            <attribute default="" name="sourcepath"/>
   3.159 +            <element name="customize" optional="true"/>
   3.160 +            <sequential>
   3.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}">
   3.162 +                    <classpath>
   3.163 +                        <path path="@{classpath}"/>
   3.164 +                    </classpath>
   3.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
   3.166 +                    <customize/>
   3.167 +                </javac>
   3.168 +            </sequential>
   3.169 +        </macrodef>
   3.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.171 +            <attribute default="${src.dir}" name="srcdir"/>
   3.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.173 +            <attribute default="${javac.classpath}" name="classpath"/>
   3.174 +            <sequential>
   3.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
   3.176 +                    <classpath>
   3.177 +                        <path path="@{classpath}"/>
   3.178 +                    </classpath>
   3.179 +                </depend>
   3.180 +            </sequential>
   3.181 +        </macrodef>
   3.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.184 +            <sequential>
   3.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
   3.186 +                <pathconvert pathsep="," property="javac.includes.binary">
   3.187 +                    <path>
   3.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
   3.189 +                    </path>
   3.190 +                    <globmapper from="*.java" to="*.class"/>
   3.191 +                </pathconvert>
   3.192 +                <delete>
   3.193 +                    <files includes="${javac.includes.binary}"/>
   3.194 +                </delete>
   3.195 +            </sequential>
   3.196 +        </macrodef>
   3.197 +    </target>
   3.198 +    <target name="-init-macrodef-junit">
   3.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.200 +            <attribute default="${includes}" name="includes"/>
   3.201 +            <attribute default="${excludes}" name="excludes"/>
   3.202 +            <attribute default="**" name="testincludes"/>
   3.203 +            <sequential>
   3.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
   3.205 +                    <batchtest todir="${build.test.results.dir}">
   3.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
   3.207 +                            <filename name="@{testincludes}"/>
   3.208 +                        </fileset>
   3.209 +                    </batchtest>
   3.210 +                    <classpath>
   3.211 +                        <path path="${run.test.classpath}"/>
   3.212 +                    </classpath>
   3.213 +                    <syspropertyset>
   3.214 +                        <propertyref prefix="test-sys-prop."/>
   3.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
   3.216 +                    </syspropertyset>
   3.217 +                    <formatter type="brief" usefile="false"/>
   3.218 +                    <formatter type="xml"/>
   3.219 +                    <jvmarg line="${run.jvmargs}"/>
   3.220 +                </junit>
   3.221 +            </sequential>
   3.222 +        </macrodef>
   3.223 +    </target>
   3.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
   3.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.226 +            <attribute default="${main.class}" name="name"/>
   3.227 +            <attribute default="${debug.classpath}" name="classpath"/>
   3.228 +            <attribute default="" name="stopclassname"/>
   3.229 +            <sequential>
   3.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
   3.231 +                    <classpath>
   3.232 +                        <path path="@{classpath}"/>
   3.233 +                    </classpath>
   3.234 +                </nbjpdastart>
   3.235 +            </sequential>
   3.236 +        </macrodef>
   3.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.238 +            <attribute default="${build.classes.dir}" name="dir"/>
   3.239 +            <sequential>
   3.240 +                <nbjpdareload>
   3.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
   3.242 +                        <include name="${fix.includes}*.class"/>
   3.243 +                    </fileset>
   3.244 +                </nbjpdareload>
   3.245 +            </sequential>
   3.246 +        </macrodef>
   3.247 +    </target>
   3.248 +    <target name="-init-debug-args">
   3.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
   3.250 +        <condition property="have-jdk-older-than-1.4">
   3.251 +            <or>
   3.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
   3.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
   3.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
   3.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
   3.256 +            </or>
   3.257 +        </condition>
   3.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
   3.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
   3.260 +        </condition>
   3.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
   3.262 +            <os family="windows"/>
   3.263 +        </condition>
   3.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
   3.265 +            <isset property="debug.transport"/>
   3.266 +        </condition>
   3.267 +    </target>
   3.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
   3.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.270 +            <attribute default="${main.class}" name="classname"/>
   3.271 +            <attribute default="${debug.classpath}" name="classpath"/>
   3.272 +            <element name="customize" optional="true"/>
   3.273 +            <sequential>
   3.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
   3.275 +                    <jvmarg line="${debug-args-line}"/>
   3.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
   3.277 +                    <jvmarg line="${run.jvmargs}"/>
   3.278 +                    <classpath>
   3.279 +                        <path path="@{classpath}"/>
   3.280 +                    </classpath>
   3.281 +                    <syspropertyset>
   3.282 +                        <propertyref prefix="run-sys-prop."/>
   3.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   3.284 +                    </syspropertyset>
   3.285 +                    <customize/>
   3.286 +                </java>
   3.287 +            </sequential>
   3.288 +        </macrodef>
   3.289 +    </target>
   3.290 +    <target name="-init-macrodef-java">
   3.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.292 +            <attribute default="${main.class}" name="classname"/>
   3.293 +            <element name="customize" optional="true"/>
   3.294 +            <sequential>
   3.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
   3.296 +                    <jvmarg line="${run.jvmargs}"/>
   3.297 +                    <classpath>
   3.298 +                        <path path="${run.classpath}"/>
   3.299 +                    </classpath>
   3.300 +                    <syspropertyset>
   3.301 +                        <propertyref prefix="run-sys-prop."/>
   3.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   3.303 +                    </syspropertyset>
   3.304 +                    <customize/>
   3.305 +                </java>
   3.306 +            </sequential>
   3.307 +        </macrodef>
   3.308 +    </target>
   3.309 +    <target name="-init-presetdef-jar">
   3.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
   3.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
   3.313 +            </jar>
   3.314 +        </presetdef>
   3.315 +    </target>
   3.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"/>
   3.317 +    <!--
   3.318 +                ===================
   3.319 +                COMPILATION SECTION
   3.320 +                ===================
   3.321 +            -->
   3.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
   3.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
   3.324 +    <target depends="init" name="-check-automatic-build">
   3.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
   3.326 +    </target>
   3.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
   3.328 +        <antcall target="clean"/>
   3.329 +    </target>
   3.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
   3.331 +        <mkdir dir="${build.classes.dir}"/>
   3.332 +    </target>
   3.333 +    <target name="-pre-compile">
   3.334 +        <!-- Empty placeholder for easier customization. -->
   3.335 +        <!-- You can override this target in the ../build.xml file. -->
   3.336 +    </target>
   3.337 +    <target if="do.depend.true" name="-compile-depend">
   3.338 +        <j2seproject3:depend/>
   3.339 +    </target>
   3.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
   3.341 +        <j2seproject3:javac/>
   3.342 +        <copy todir="${build.classes.dir}">
   3.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.344 +        </copy>
   3.345 +    </target>
   3.346 +    <target name="-post-compile">
   3.347 +        <!-- Empty placeholder for easier customization. -->
   3.348 +        <!-- You can override this target in the ../build.xml file. -->
   3.349 +    </target>
   3.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
   3.351 +    <target name="-pre-compile-single">
   3.352 +        <!-- Empty placeholder for easier customization. -->
   3.353 +        <!-- You can override this target in the ../build.xml file. -->
   3.354 +    </target>
   3.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
   3.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   3.357 +        <j2seproject3:force-recompile/>
   3.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
   3.359 +    </target>
   3.360 +    <target name="-post-compile-single">
   3.361 +        <!-- Empty placeholder for easier customization. -->
   3.362 +        <!-- You can override this target in the ../build.xml file. -->
   3.363 +    </target>
   3.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
   3.365 +    <!--
   3.366 +                ====================
   3.367 +                JAR BUILDING SECTION
   3.368 +                ====================
   3.369 +            -->
   3.370 +    <target depends="init" name="-pre-pre-jar">
   3.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
   3.372 +        <mkdir dir="${dist.jar.dir}"/>
   3.373 +    </target>
   3.374 +    <target name="-pre-jar">
   3.375 +        <!-- Empty placeholder for easier customization. -->
   3.376 +        <!-- You can override this target in the ../build.xml file. -->
   3.377 +    </target>
   3.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
   3.379 +        <j2seproject1:jar/>
   3.380 +    </target>
   3.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
   3.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
   3.383 +    </target>
   3.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">
   3.385 +        <j2seproject1:jar manifest="${manifest.file}">
   3.386 +            <j2seproject1:manifest>
   3.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
   3.388 +            </j2seproject1:manifest>
   3.389 +        </j2seproject1:jar>
   3.390 +        <echo>To run this application from the command line without Ant, try:</echo>
   3.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   3.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
   3.393 +        <pathconvert property="run.classpath.with.dist.jar">
   3.394 +            <path path="${run.classpath}"/>
   3.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
   3.396 +        </pathconvert>
   3.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
   3.398 +    </target>
   3.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
   3.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   3.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
   3.402 +            <path path="${run.classpath}"/>
   3.403 +            <map from="${build.classes.dir.resolved}" to=""/>
   3.404 +        </pathconvert>
   3.405 +        <pathconvert pathsep=" " property="jar.classpath">
   3.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
   3.407 +            <chainedmapper>
   3.408 +                <flattenmapper/>
   3.409 +                <globmapper from="*" to="lib/*"/>
   3.410 +            </chainedmapper>
   3.411 +        </pathconvert>
   3.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
   3.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
   3.414 +            <fileset dir="${build.classes.dir}"/>
   3.415 +            <manifest>
   3.416 +                <attribute name="Main-Class" value="${main.class}"/>
   3.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
   3.418 +            </manifest>
   3.419 +        </copylibs>
   3.420 +        <echo>To run this application from the command line without Ant, try:</echo>
   3.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
   3.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
   3.423 +    </target>
   3.424 +    <target name="-post-jar">
   3.425 +        <!-- Empty placeholder for easier customization. -->
   3.426 +        <!-- You can override this target in the ../build.xml file. -->
   3.427 +    </target>
   3.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"/>
   3.429 +    <!--
   3.430 +                =================
   3.431 +                EXECUTION SECTION
   3.432 +                =================
   3.433 +            -->
   3.434 +    <target depends="init,compile" description="Run a main class." name="run">
   3.435 +        <j2seproject1:java>
   3.436 +            <customize>
   3.437 +                <arg line="${application.args}"/>
   3.438 +            </customize>
   3.439 +        </j2seproject1:java>
   3.440 +    </target>
   3.441 +    <target name="-do-not-recompile">
   3.442 +        <property name="javac.includes.binary" value=""/>
   3.443 +    </target>
   3.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
   3.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
   3.446 +        <j2seproject1:java classname="${run.class}"/>
   3.447 +    </target>
   3.448 +    <!--
   3.449 +                =================
   3.450 +                DEBUGGING SECTION
   3.451 +                =================
   3.452 +            -->
   3.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
   3.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
   3.455 +    </target>
   3.456 +    <target depends="init,compile" name="-debug-start-debuggee">
   3.457 +        <j2seproject3:debug>
   3.458 +            <customize>
   3.459 +                <arg line="${application.args}"/>
   3.460 +            </customize>
   3.461 +        </j2seproject3:debug>
   3.462 +    </target>
   3.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
   3.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
   3.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
   3.466 +    </target>
   3.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
   3.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
   3.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
   3.470 +        <j2seproject3:debug classname="${debug.class}"/>
   3.471 +    </target>
   3.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
   3.473 +    <target depends="init" name="-pre-debug-fix">
   3.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
   3.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
   3.476 +    </target>
   3.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
   3.478 +        <j2seproject1:nbjpdareload/>
   3.479 +    </target>
   3.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
   3.481 +    <!--
   3.482 +                ===============
   3.483 +                JAVADOC SECTION
   3.484 +                ===============
   3.485 +            -->
   3.486 +    <target depends="init" name="-javadoc-build">
   3.487 +        <mkdir dir="${dist.javadoc.dir}"/>
   3.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}">
   3.489 +            <classpath>
   3.490 +                <path path="${javac.classpath}"/>
   3.491 +            </classpath>
   3.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
   3.493 +                <filename name="**/*.java"/>
   3.494 +            </fileset>
   3.495 +        </javadoc>
   3.496 +    </target>
   3.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
   3.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
   3.499 +    </target>
   3.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
   3.501 +    <!--
   3.502 +                =========================
   3.503 +                JUNIT COMPILATION SECTION
   3.504 +                =========================
   3.505 +            -->
   3.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
   3.507 +        <mkdir dir="${build.test.classes.dir}"/>
   3.508 +    </target>
   3.509 +    <target name="-pre-compile-test">
   3.510 +        <!-- Empty placeholder for easier customization. -->
   3.511 +        <!-- You can override this target in the ../build.xml file. -->
   3.512 +    </target>
   3.513 +    <target if="do.depend.true" name="-compile-test-depend">
   3.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   3.515 +    </target>
   3.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
   3.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   3.518 +        <copy todir="${build.test.classes.dir}">
   3.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.520 +        </copy>
   3.521 +    </target>
   3.522 +    <target name="-post-compile-test">
   3.523 +        <!-- Empty placeholder for easier customization. -->
   3.524 +        <!-- You can override this target in the ../build.xml file. -->
   3.525 +    </target>
   3.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
   3.527 +    <target name="-pre-compile-test-single">
   3.528 +        <!-- Empty placeholder for easier customization. -->
   3.529 +        <!-- You can override this target in the ../build.xml file. -->
   3.530 +    </target>
   3.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
   3.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   3.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
   3.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}"/>
   3.535 +        <copy todir="${build.test.classes.dir}">
   3.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.537 +        </copy>
   3.538 +    </target>
   3.539 +    <target name="-post-compile-test-single">
   3.540 +        <!-- Empty placeholder for easier customization. -->
   3.541 +        <!-- You can override this target in the ../build.xml file. -->
   3.542 +    </target>
   3.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"/>
   3.544 +    <!--
   3.545 +                =======================
   3.546 +                JUNIT EXECUTION SECTION
   3.547 +                =======================
   3.548 +            -->
   3.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
   3.550 +        <mkdir dir="${build.test.results.dir}"/>
   3.551 +    </target>
   3.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
   3.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
   3.554 +    </target>
   3.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
   3.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
   3.557 +    </target>
   3.558 +    <target depends="init" if="have.tests" name="test-report"/>
   3.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
   3.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"/>
   3.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
   3.562 +        <mkdir dir="${build.test.results.dir}"/>
   3.563 +    </target>
   3.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
   3.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
   3.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
   3.567 +    </target>
   3.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
   3.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
   3.570 +    </target>
   3.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"/>
   3.572 +    <!--
   3.573 +                =======================
   3.574 +                JUNIT DEBUGGING SECTION
   3.575 +                =======================
   3.576 +            -->
   3.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
   3.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
   3.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
   3.580 +        <delete file="${test.report.file}"/>
   3.581 +        <mkdir dir="${build.test.results.dir}"/>
   3.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}">
   3.583 +            <customize>
   3.584 +                <syspropertyset>
   3.585 +                    <propertyref prefix="test-sys-prop."/>
   3.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
   3.587 +                </syspropertyset>
   3.588 +                <arg value="${test.class}"/>
   3.589 +                <arg value="showoutput=true"/>
   3.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
   3.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
   3.592 +            </customize>
   3.593 +        </j2seproject3:debug>
   3.594 +    </target>
   3.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
   3.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
   3.597 +    </target>
   3.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
   3.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
   3.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
   3.601 +    </target>
   3.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
   3.603 +    <!--
   3.604 +                =========================
   3.605 +                APPLET EXECUTION SECTION
   3.606 +                =========================
   3.607 +            -->
   3.608 +    <target depends="init,compile-single" name="run-applet">
   3.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   3.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
   3.611 +            <customize>
   3.612 +                <arg value="${applet.url}"/>
   3.613 +            </customize>
   3.614 +        </j2seproject1:java>
   3.615 +    </target>
   3.616 +    <!--
   3.617 +                =========================
   3.618 +                APPLET DEBUGGING  SECTION
   3.619 +                =========================
   3.620 +            -->
   3.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
   3.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   3.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
   3.624 +            <customize>
   3.625 +                <arg value="${applet.url}"/>
   3.626 +            </customize>
   3.627 +        </j2seproject3:debug>
   3.628 +    </target>
   3.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
   3.630 +    <!--
   3.631 +                ===============
   3.632 +                CLEANUP SECTION
   3.633 +                ===============
   3.634 +            -->
   3.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
   3.636 +    <target depends="init" name="-do-clean">
   3.637 +        <delete dir="${build.dir}"/>
   3.638 +        <delete dir="${dist.dir}"/>
   3.639 +    </target>
   3.640 +    <target name="-post-clean">
   3.641 +        <!-- Empty placeholder for easier customization. -->
   3.642 +        <!-- You can override this target in the ../build.xml file. -->
   3.643 +    </target>
   3.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
   3.645 +</project>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/task2/solution01/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
     4.3 @@ -0,0 +1,8 @@
     4.4 +build.xml.data.CRC32=2ab820eb
     4.5 +build.xml.script.CRC32=58a52595
     4.6 +build.xml.stylesheet.CRC32=be360661
     4.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     4.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     4.9 +nbproject/build-impl.xml.data.CRC32=3cae0313
    4.10 +nbproject/build-impl.xml.script.CRC32=3c8caa17
    4.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/task2/solution01/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
     5.3 @@ -0,0 +1,68 @@
     5.4 +application.title=currency
     5.5 +application.vendor=apidesign.org
     5.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
     5.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
     5.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
     5.9 +build.classes.dir=${build.dir}/classes
    5.10 +build.classes.excludes=**/*.java,**/*.form
    5.11 +# This directory is removed when the project is cleaned:
    5.12 +build.dir=build
    5.13 +build.generated.dir=${build.dir}/generated
    5.14 +# Only compile against the classpath explicitly listed here:
    5.15 +build.sysclasspath=ignore
    5.16 +build.test.classes.dir=${build.dir}/test/classes
    5.17 +build.test.results.dir=${build.dir}/test/results
    5.18 +debug.classpath=\
    5.19 +    ${run.classpath}
    5.20 +debug.test.classpath=\
    5.21 +    ${run.test.classpath}
    5.22 +# This directory is removed when the project is cleaned:
    5.23 +dist.dir=dist
    5.24 +dist.jar=${dist.dir}/currency.jar
    5.25 +dist.javadoc.dir=${dist.dir}/javadoc
    5.26 +excludes=
    5.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
    5.28 +file.reference.src-apifest08=..
    5.29 +includes=**
    5.30 +jar.compress=false
    5.31 +javac.classpath=
    5.32 +# Space-separated list of extra javac options
    5.33 +javac.compilerargs=
    5.34 +javac.deprecation=false
    5.35 +javac.source=1.5
    5.36 +javac.target=1.5
    5.37 +javac.test.classpath=\
    5.38 +    ${javac.classpath}:\
    5.39 +    ${build.classes.dir}:\
    5.40 +    ${file.reference.junit-4.4.jar}
    5.41 +javadoc.additionalparam=
    5.42 +javadoc.author=false
    5.43 +javadoc.encoding=
    5.44 +javadoc.noindex=false
    5.45 +javadoc.nonavbar=false
    5.46 +javadoc.notree=false
    5.47 +javadoc.private=false
    5.48 +javadoc.splitindex=true
    5.49 +javadoc.use=true
    5.50 +javadoc.version=false
    5.51 +javadoc.windowtitle=
    5.52 +jnlp.codebase.type=local
    5.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
    5.54 +jnlp.descriptor=application
    5.55 +jnlp.enabled=false
    5.56 +jnlp.offline-allowed=false
    5.57 +jnlp.signed=false
    5.58 +meta.inf.dir=${src.dir}/META-INF
    5.59 +platform.active=default_platform
    5.60 +run.classpath=\
    5.61 +    ${javac.classpath}:\
    5.62 +    ${build.classes.dir}
    5.63 +# Space-separated list of JVM arguments used when running the project
    5.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    5.65 +# or test-sys-prop.name=value to set system properties for unit tests):
    5.66 +run.jvmargs=
    5.67 +run.test.classpath=\
    5.68 +    ${javac.test.classpath}:\
    5.69 +    ${build.test.classes.dir}
    5.70 +src.dir=src
    5.71 +test.src.dir=test
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/task2/solution01/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
     6.3 @@ -0,0 +1,16 @@
     6.4 +<?xml version="1.0" encoding="UTF-8"?>
     6.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
     6.6 +    <type>org.netbeans.modules.java.j2seproject</type>
     6.7 +    <configuration>
     6.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
     6.9 +            <name>Currency Convertor Solution 01</name>
    6.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
    6.11 +            <source-roots>
    6.12 +                <root id="src.dir"/>
    6.13 +            </source-roots>
    6.14 +            <test-roots>
    6.15 +                <root id="test.src.dir"/>
    6.16 +            </test-roots>
    6.17 +        </data>
    6.18 +    </configuration>
    6.19 +</project>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/AbstractConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
     7.3 @@ -0,0 +1,12 @@
     7.4 +package org.apidesign.apifest08.currency;
     7.5 +
     7.6 +/**
     7.7 + * Abstract class for future possible purposes
     7.8 + * @author Ladislav Vitasek
     7.9 + */
    7.10 +abstract class AbstractConvertorFactory implements CurrencyConvertorFactory{
    7.11 +
    7.12 +    AbstractConvertorFactory() {
    7.13 +    }
    7.14 +
    7.15 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/AbstractCurrencyConvertor.java	Wed Oct 01 10:43:05 2008 +0200
     8.3 @@ -0,0 +1,64 @@
     8.4 +package org.apidesign.apifest08.currency;
     8.5 +
     8.6 +import java.util.Currency;
     8.7 +
     8.8 +/**
     8.9 + * Abstract convertor implementation.
    8.10 + * This class provide necessary stuff for creating any CurrencyConvertor
    8.11 + * Convert value can be get by different way. Conversion should be made in its subclass.
    8.12 + * @author Ladislav Vitasek
    8.13 + */
    8.14 +abstract class AbstractCurrencyConvertor implements Convertor {
    8.15 +    protected final ConversionRatioProvider conversionRatioProvider;
    8.16 +    protected final Currency currency1;
    8.17 +    protected final Currency currency2;
    8.18 +
    8.19 +    public AbstractCurrencyConvertor(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider) {
    8.20 +        this.currency1 = currency1;
    8.21 +        this.currency2 = currency2;
    8.22 +        this.conversionRatioProvider = conversionRatioProvider;
    8.23 +    }
    8.24 +
    8.25 +    
    8.26 +    public Currency getCurrency1() {
    8.27 +        return currency1;
    8.28 +    }
    8.29 +
    8.30 +
    8.31 +    public Currency getCurrency2() {
    8.32 +        return currency2;
    8.33 +    }
    8.34 +
    8.35 +//    /**
    8.36 +//     * Conversion value can be get by Different way. Let's decide subclass where to get actual value
    8.37 +//     * @return current value of conversion constant
    8.38 +//     */
    8.39 +//    protected abstract BigDecimal getConversionValue();
    8.40 +
    8.41 +    @SuppressWarnings({"RedundantIfStatement"})
    8.42 +    public boolean equals(Object o) {
    8.43 +        if (this == o) return true;
    8.44 +        if (o == null || getClass() != o.getClass()) return false;
    8.45 +
    8.46 +        AbstractCurrencyConvertor that = (AbstractCurrencyConvertor) o;
    8.47 +
    8.48 +        if (!conversionRatioProvider.equals(that.conversionRatioProvider)) return false;
    8.49 +        if (!currency1.equals(that.currency1)) return false;
    8.50 +        if (!currency2.equals(that.currency2)) return false;
    8.51 +
    8.52 +        return true;
    8.53 +    }
    8.54 +
    8.55 +    public int hashCode() {
    8.56 +        int result;
    8.57 +        result = conversionRatioProvider.hashCode();
    8.58 +        result = 31 * result + currency1.hashCode();
    8.59 +        result = 31 * result + currency2.hashCode();
    8.60 +        return result;
    8.61 +    }
    8.62 +
    8.63 +    ConversionRatioProvider getConversionRatioProvider() {
    8.64 +        return conversionRatioProvider;
    8.65 +    }    
    8.66 +
    8.67 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CannotConvertException.java	Wed Oct 01 10:43:05 2008 +0200
     9.3 @@ -0,0 +1,26 @@
     9.4 +package org.apidesign.apifest08.currency;
     9.5 +
     9.6 +/**
     9.7 + * If something was wrong during converting currencies...
     9.8 + * Eg. when the convertor is outdated
     9.9 + * Should be a descendant of RuntimeException? Hmmms...
    9.10 + * @author Ladislav Vitasek
    9.11 + */
    9.12 +public class CannotConvertException extends RuntimeException {
    9.13 +    
    9.14 +    public CannotConvertException() {
    9.15 +
    9.16 +    }
    9.17 +
    9.18 +    public CannotConvertException(String message) {
    9.19 +        super(message);
    9.20 +    }
    9.21 +
    9.22 +    public CannotConvertException(Throwable e) {
    9.23 +        super(e);
    9.24 +    }
    9.25 +
    9.26 +    public CannotConvertException(String message, Throwable cause) {
    9.27 +        super(message, cause);
    9.28 +    }
    9.29 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CannotInstantiateFactoryException.java	Wed Oct 01 10:43:05 2008 +0200
    10.3 @@ -0,0 +1,23 @@
    10.4 +package org.apidesign.apifest08.currency;
    10.5 +
    10.6 +/**
    10.7 + * Failed to instantiate class for factory
    10.8 + * @author Ladislav Vitasek
    10.9 + */
   10.10 +public class CannotInstantiateFactoryException extends Exception {
   10.11 +    public CannotInstantiateFactoryException(Throwable e) {
   10.12 +        super(e);
   10.13 +    }
   10.14 +
   10.15 +    public CannotInstantiateFactoryException(String message) {
   10.16 +        super(message);
   10.17 +    }
   10.18 +
   10.19 +    public CannotInstantiateFactoryException() {
   10.20 +        super();
   10.21 +    }
   10.22 +
   10.23 +    public CannotInstantiateFactoryException(String message, Throwable cause) {
   10.24 +        super(message, cause);
   10.25 +    }
   10.26 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CannotProvideValueException.java	Wed Oct 01 10:43:05 2008 +0200
    11.3 @@ -0,0 +1,24 @@
    11.4 +package org.apidesign.apifest08.currency;
    11.5 +
    11.6 +/**
    11.7 + * Used when value cannot be get from the source
    11.8 + * @author Ladislav Vitasek
    11.9 + */
   11.10 +public class CannotProvideValueException extends RuntimeException {
   11.11 +
   11.12 +    public CannotProvideValueException() {
   11.13 +        super();
   11.14 +    }
   11.15 +
   11.16 +    public CannotProvideValueException(String message) {
   11.17 +        super(message);
   11.18 +    }
   11.19 +
   11.20 +    public CannotProvideValueException(String message, Throwable cause) {
   11.21 +        super(message, cause);
   11.22 +    }
   11.23 +
   11.24 +    public CannotProvideValueException(Throwable cause) {
   11.25 +        super(cause);
   11.26 +    }
   11.27 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/ConversionProperties.java	Wed Oct 01 10:43:05 2008 +0200
    12.3 @@ -0,0 +1,101 @@
    12.4 +package org.apidesign.apifest08.currency;
    12.5 +
    12.6 +import java.math.BigDecimal;
    12.7 +import java.math.RoundingMode;
    12.8 +
    12.9 +/**
   12.10 + * This class encapsulates settings for currency conversion
   12.11 + * We can use it eg. for uptime options etc. in future versions
   12.12 + *
   12.13 + * @author Ladislav Vitasek
   12.14 + */
   12.15 +final public class ConversionProperties {
   12.16 +
   12.17 +    private final ConversionRatioProvider conversionRatioProvider;
   12.18 +    private final RoundingMode roundingMode;
   12.19 +
   12.20 +    /**
   12.21 +     * Returns conversion constants - conversion operation is invertable
   12.22 +     * Default
   12.23 +     */
   12.24 +    private final static class FixedBidirectionalRatioConversion implements ConversionRatioProvider {
   12.25 +        private final BigDecimal currency1ToCurrency2Constant;
   12.26 +        private final BigDecimal currency2ToCurrency1Constant;
   12.27 +        private static final int SCALE_MAX_DEFAULT = 20;
   12.28 +
   12.29 +        /**
   12.30 +         * Constructor
   12.31 +         * @param ratioConstant fixed ratio constant
   12.32 +         * @param mode math rounding mode
   12.33 +         * @throws IllegalArgumentException if conversion value is <= 0
   12.34 +         */
   12.35 +        private FixedBidirectionalRatioConversion(BigDecimal ratioConstant, RoundingMode mode) {
   12.36 +            if (ratioConstant.compareTo(BigDecimal.ZERO) <= 0)
   12.37 +                throw new IllegalArgumentException("Conversion value cannot be <= 0");
   12.38 +            this.currency1ToCurrency2Constant = ratioConstant;
   12.39 +            this.currency2ToCurrency1Constant = BigDecimal.ONE.setScale(SCALE_MAX_DEFAULT).divide(ratioConstant, mode);
   12.40 +        }
   12.41 +
   12.42 +        public BigDecimal getCurrency1ToCurrency2Constant() {
   12.43 +            return currency1ToCurrency2Constant;
   12.44 +        }
   12.45 +
   12.46 +        public BigDecimal getCurrency2ToCurrency1Constant() {
   12.47 +            return currency2ToCurrency1Constant;
   12.48 +        }
   12.49 +    }
   12.50 +
   12.51 +
   12.52 +    /**
   12.53 +     * Returns new instance Conversion properties - fixed conversion ratio - both directions
   12.54 +     * Default max scale is set to 20
   12.55 +     *
   12.56 +     * @param conversionConstant value of constant for conversion
   12.57 +     * @param roundingMode       math rounding mode
   12.58 +     * @return new instance of ConversionProperties class
   12.59 +     * @throws IllegalArgumentException if conversion constant is <= 0 
   12.60 +     * @see org.apidesign.apifest08.currency.ConversionProperties.FixedBidirectionalRatioConversion
   12.61 +     */
   12.62 +    public static ConversionProperties create(BigDecimal conversionConstant, RoundingMode roundingMode) {
   12.63 +        return create(new FixedBidirectionalRatioConversion(conversionConstant, roundingMode), roundingMode);
   12.64 +    }
   12.65 +
   12.66 +    /**
   12.67 +     * Returns new instance Conversion properties
   12.68 +     *
   12.69 +     * @param conversionRatioProvider provider for conversion constants
   12.70 +     * @param roundingMode       math rounding mode
   12.71 +     * @return new instance of ConversionProperties class
   12.72 +     */
   12.73 +    public static ConversionProperties create(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
   12.74 +        if (conversionRatioProvider == null || roundingMode == null)
   12.75 +            throw new NullPointerException();
   12.76 +        return new ConversionProperties(conversionRatioProvider, roundingMode);
   12.77 +    }
   12.78 +
   12.79 +    /**
   12.80 +     * Returns new instance Conversion properties with values set to conversionConstant=BigDecimal.ONE
   12.81 +     * and roundingMode=RoundingMode.HALF_EVEN
   12.82 +     * 
   12.83 +     * Conversion is bidirectional.
   12.84 +     *
   12.85 +     * @return
   12.86 +     */
   12.87 +    public static ConversionProperties createDefault() {
   12.88 +        return create(BigDecimal.ONE, RoundingMode.HALF_EVEN);
   12.89 +    }
   12.90 +
   12.91 +    private ConversionProperties(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
   12.92 +        this.conversionRatioProvider = conversionRatioProvider;
   12.93 +        this.roundingMode = roundingMode;
   12.94 +    }
   12.95 +
   12.96 +
   12.97 +    public RoundingMode getRoundingMode() {
   12.98 +        return roundingMode;
   12.99 +    }
  12.100 +
  12.101 +    public ConversionRatioProvider getConversionRatioProvider() {
  12.102 +        return conversionRatioProvider;
  12.103 +    }
  12.104 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/ConversionRatioProvider.java	Wed Oct 01 10:43:05 2008 +0200
    13.3 @@ -0,0 +1,12 @@
    13.4 +package org.apidesign.apifest08.currency;
    13.5 +
    13.6 +import java.math.BigDecimal;
    13.7 +
    13.8 +/**
    13.9 + * Provider for conversion constant from any source
   13.10 + * @author Ladislav Vitasek
   13.11 + */
   13.12 +public interface ConversionRatioProvider {
   13.13 +    public BigDecimal getCurrency1ToCurrency2Constant() throws CannotProvideValueException;
   13.14 +    public BigDecimal getCurrency2ToCurrency1Constant() throws CannotProvideValueException;
   13.15 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    14.3 @@ -0,0 +1,51 @@
    14.4 +package org.apidesign.apifest08.currency;
    14.5 +
    14.6 +import java.math.BigDecimal;
    14.7 +import java.util.Currency;
    14.8 +
    14.9 +/** This is the skeleton class for your API. You need to make it public, so
   14.10 + * it is accessible to your client code (currently in Task1Test.java) file.
   14.11 + * <p>
   14.12 + * Feel free to create additional classes or rename this one, just keep all
   14.13 + * the API and its implementation in this package. Do not spread it outside
   14.14 + * to other packages.
   14.15 + */
   14.16 +public interface Convertor {
   14.17 +    /**
   14.18 +     * Methods converts some pounds
   14.19 +     * API design question - what kind of parameters?
   14.20 +     * I decided to use BigDecimal based on experience on Java conf ;-)
   14.21 +     * @param amountOfMoney
   14.22 +     * @return converted amount of money
   14.23 +     * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
   14.24 +     */
   14.25 +
   14.26 +    BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException;
   14.27 +
   14.28 +    /**
   14.29 +     * Methods converts some pounds
   14.30 +     * API design question - what kind of parameters?
   14.31 +     * @param amountOfMoney
   14.32 +     * @return converted amount of money
   14.33 +     * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
   14.34 +     */
   14.35 +
   14.36 +    BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException;
   14.37 +
   14.38 +    //handy getters
   14.39 +
   14.40 +    /**
   14.41 +     * Getter - Returns Currency 1 of this convertor
   14.42 +     * @return money code
   14.43 +     */
   14.44 +    Currency getCurrency1();
   14.45 +
   14.46 +    /**
   14.47 +     * Getter - Returns Currency 2 of this convertor
   14.48 +     * @return money code
   14.49 +     */
   14.50 +    Currency getCurrency2();
   14.51 +
   14.52 +    // For Future purposes...? - it was not as a requirement in TestCase
   14.53 +    //BigDecimal getConversionValue();
   14.54 +}
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorNotAvailableException.java	Wed Oct 01 10:43:05 2008 +0200
    15.3 @@ -0,0 +1,23 @@
    15.4 +package org.apidesign.apifest08.currency;
    15.5 +
    15.6 +/**
    15.7 + * No convertor is available for current conversion settings
    15.8 + * @author Ladislav Vitasek
    15.9 + */
   15.10 +public class ConvertorNotAvailableException extends Exception {
   15.11 +    public ConvertorNotAvailableException() {
   15.12 +
   15.13 +    }
   15.14 +
   15.15 +    public ConvertorNotAvailableException(String message) {
   15.16 +        super(message);
   15.17 +    }
   15.18 +
   15.19 +    public ConvertorNotAvailableException(String message, Throwable cause) {
   15.20 +        super(message, cause);
   15.21 +    }
   15.22 +
   15.23 +    public ConvertorNotAvailableException(Throwable cause) {
   15.24 +        super(cause);
   15.25 +    }
   15.26 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorsFactory.java	Wed Oct 01 10:43:05 2008 +0200
    16.3 @@ -0,0 +1,43 @@
    16.4 +package org.apidesign.apifest08.currency;
    16.5 +
    16.6 +/**
    16.7 + * Some Factory for Factories :-)
    16.8 + * Depends on the whole application design...
    16.9 + * @author Ladislav Vitasek
   16.10 + */
   16.11 +final public class ConvertorsFactory {
   16.12 +    private CurrencyConvertorFactory currencyConvertorFactoryInstance = null;
   16.13 +    private final static ConvertorsFactory instance = new ConvertorsFactory();
   16.14 +
   16.15 +
   16.16 +    private ConvertorsFactory() {
   16.17 +
   16.18 +    }
   16.19 +
   16.20 +    public static CurrencyConvertorFactory getCurrencyConvertorFactoryInstance() throws CannotInstantiateFactoryException {
   16.21 +        return getInstance().getCurrencyConvertor();
   16.22 +    }
   16.23 +
   16.24 +    /**
   16.25 +     * Returns instance of CurrencyConvertorFactory 
   16.26 +     * @return new instance of CurrencyConvertorFactory
   16.27 +     * @throws CannotInstantiateFactoryException
   16.28 +     */
   16.29 +    private synchronized CurrencyConvertorFactory getCurrencyConvertor() throws CannotInstantiateFactoryException {
   16.30 +        if (currencyConvertorFactoryInstance == null) {//intern implementation
   16.31 +//            String className = System.getProperty("currencyFactory", CurrencyConvertorFactoryImpl.class.getName());
   16.32 +//            try {
   16.33 +//                currencyConvertorFactoryInstance = (CurrencyConvertorFactory) Class.forName(className).newInstance();
   16.34 +//            } catch (Exception e) {
   16.35 +//                throw new CannotInstantiateFactoryException(e);
   16.36 +//            }
   16.37 +            //without reflection
   16.38 +            currencyConvertorFactoryInstance = new CurrencyConvertorFactoryImpl();
   16.39 +        }
   16.40 +        return currencyConvertorFactoryInstance;
   16.41 +    }
   16.42 +
   16.43 +    public static ConvertorsFactory getInstance() {
   16.44 +        return instance;
   16.45 +    }
   16.46 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
    17.3 @@ -0,0 +1,22 @@
    17.4 +package org.apidesign.apifest08.currency;
    17.5 +
    17.6 +import java.util.Currency;
    17.7 +
    17.8 +/**
    17.9 + * @author Ladislav Vitasek
   17.10 + */
   17.11 +public interface CurrencyConvertorFactory {
   17.12 +
   17.13 +    /**
   17.14 +     * Instantiate a new instance convertor      
   17.15 +     * @param currency1 a code currency you want to convert between
   17.16 +     * @param currency2 a code currency you want to convert between
   17.17 +     * @param conversionProperties settings for conversion
   17.18 +     * @return converter for currency converting
   17.19 +     * @throws ConvertorNotAvailableException throws if there is no available convertor for selected currencies
   17.20 +     */
   17.21 +    Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException;
   17.22 +
   17.23 +
   17.24 +
   17.25 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactoryImpl.java	Wed Oct 01 10:43:05 2008 +0200
    18.3 @@ -0,0 +1,29 @@
    18.4 +package org.apidesign.apifest08.currency;
    18.5 +
    18.6 +import java.util.Currency;
    18.7 +
    18.8 +/**
    18.9 + * Convertor Factory implementation
   18.10 + * In the real-time world this code should be optimized - convertors caching etc.
   18.11 + * @author Ladislav Vitasek
   18.12 + */
   18.13 +class CurrencyConvertorFactoryImpl extends AbstractConvertorFactory  {
   18.14 +    
   18.15 +
   18.16 +    CurrencyConvertorFactoryImpl() {
   18.17 +        super();
   18.18 +    }
   18.19 +
   18.20 +    // Note - implementation of this method is dummy
   18.21 +    
   18.22 +    public Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException {
   18.23 +        if (currency1 == null || currency2 == null || conversionProperties == null)
   18.24 +            throw new NullPointerException();
   18.25 +
   18.26 +        try {
   18.27 +            return new CurrencyConvertorImpl(currency1, currency2, conversionProperties.getConversionRatioProvider(), conversionProperties.getRoundingMode());//can be cached somehow
   18.28 +        } catch (Exception e) {
   18.29 +            throw new ConvertorNotAvailableException(e);
   18.30 +        }
   18.31 +    }
   18.32 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorImpl.java	Wed Oct 01 10:43:05 2008 +0200
    19.3 @@ -0,0 +1,108 @@
    19.4 +package org.apidesign.apifest08.currency;
    19.5 +
    19.6 +import java.math.BigDecimal;
    19.7 +import java.math.RoundingMode;
    19.8 +import java.util.Currency;
    19.9 +
   19.10 +/**
   19.11 + * Intern implementation of Bidirectional Convertor - this class is only for internal purposes only.
   19.12 + * This implementation uses BigDecimals to count result value
   19.13 + * Scale is set by ISO 4217 as default
   19.14 + *
   19.15 + * @author Ladislav Vitasek
   19.16 + */
   19.17 +class CurrencyConvertorImpl extends AbstractCurrencyConvertor {
   19.18 +
   19.19 +    protected RoundingMode roundingMode;
   19.20 +    protected int currency1Scale;
   19.21 +    protected int currency2Scale;
   19.22 +
   19.23 +    /**
   19.24 +     * Constructor
   19.25 +     * By default it creates convertor with conversion value 1
   19.26 +     *
   19.27 +     * @param currency1       currency for conversion
   19.28 +     * @param currency2       currency for conversion
   19.29 +     * @param provider constants provider
   19.30 +     * @param roundingMode    math rounding mode
   19.31 +     */
   19.32 +    CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider provider, RoundingMode roundingMode) {
   19.33 +        this(currency1, currency2, provider, roundingMode, currency1.getDefaultFractionDigits(), currency2.getDefaultFractionDigits());
   19.34 +    }
   19.35 +
   19.36 +    /**
   19.37 +     * Constructor
   19.38 +     *
   19.39 +     * @param currency1       currency for conversion
   19.40 +     * @param currency2       currency for conversion
   19.41 +     * @param conversionRatioProvider conversion constants provider
   19.42 +     * @param roundingMode    math rounding mode
   19.43 +     * @param conversionRatioProvider constants provider
   19.44 +     * @param currency2Scale
   19.45 +     */
   19.46 +    CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode, int currency1Scale, int currency2Scale) {
   19.47 +        super(currency1, currency2, conversionRatioProvider);
   19.48 +        this.roundingMode = roundingMode;
   19.49 +        this.currency1Scale = currency1Scale;
   19.50 +        this.currency2Scale = currency2Scale;
   19.51 +    }
   19.52 +
   19.53 +
   19.54 +    public BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException {
   19.55 +        try {
   19.56 +            final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency1ToCurrency2Constant());
   19.57 +            return result.setScale(getCurrency2Scale(), getRoundingMode());
   19.58 +        } catch (CannotProvideValueException e) {
   19.59 +            throw new CannotConvertException(e);            
   19.60 +        } catch (ArithmeticException e) {
   19.61 +            throw new CannotConvertException(e);
   19.62 +        }
   19.63 +    }
   19.64 +
   19.65 +
   19.66 +    public BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException {
   19.67 +        try {
   19.68 +            final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency2ToCurrency1Constant());
   19.69 +            return result.setScale(getCurrency1Scale(), getRoundingMode());
   19.70 +        } catch (CannotProvideValueException e) {
   19.71 +            throw new CannotConvertException(e);
   19.72 +        } catch (ArithmeticException e) {
   19.73 +            throw new CannotConvertException(e);
   19.74 +        }
   19.75 +    }
   19.76 +  
   19.77 +    public String toString() {
   19.78 +        return "CurrencyConvertorImpl{" +
   19.79 +                "currency1=" + getCurrency1() +
   19.80 +                ",currency2=" + getCurrency2() +
   19.81 +                ", roundingMode=" + roundingMode +
   19.82 +                ", currency1Scale=" + currency1Scale +
   19.83 +                ", currency2Scale=" + currency2Scale +
   19.84 +                '}';
   19.85 +    }
   19.86 +
   19.87 +    RoundingMode getRoundingMode() {
   19.88 +        return roundingMode;
   19.89 +    }    
   19.90 +
   19.91 +    int getCurrency1Scale() {
   19.92 +        return currency1Scale;
   19.93 +    }
   19.94 +
   19.95 +    int getCurrency2Scale() {
   19.96 +        return currency2Scale;
   19.97 +    }
   19.98 +
   19.99 +    void setRoundingMode(RoundingMode roundingMode) {
  19.100 +        this.roundingMode = roundingMode;
  19.101 +    }
  19.102 +
  19.103 +    void setCurrency1Scale(int currency1Scale) {
  19.104 +        this.currency1Scale = currency1Scale;
  19.105 +    }
  19.106 +
  19.107 +    void setCurrency2Scale(int currency2Scale) {
  19.108 +        this.currency2Scale = currency2Scale;
  19.109 +    }
  19.110 +
  19.111 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/task2/solution01/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    20.3 @@ -0,0 +1,104 @@
    20.4 +package org.apidesign.apifest08.test;
    20.5 +
    20.6 +import junit.framework.TestCase;
    20.7 +import org.apidesign.apifest08.currency.*;
    20.8 +
    20.9 +import java.math.BigDecimal;
   20.10 +import java.math.RoundingMode;
   20.11 +import java.util.Currency;
   20.12 +
   20.13 +/**
   20.14 + * Finish the Convertor API, and then write bodies of methods inside
   20.15 + * of this class to match the given tasks. To fullfil your task, use the
   20.16 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   20.17 + * Do not you reflection, or other hacks as your code
   20.18 + * shall run without any runtime permissions.
   20.19 + */
   20.20 +public class Task1Test extends TestCase {
   20.21 +    private static CurrencyConvertorFactory currencyConvertorFactoryInstance;
   20.22 +
   20.23 +    public Task1Test(String testName) {
   20.24 +        super(testName);
   20.25 +    }
   20.26 +
   20.27 +    @Override
   20.28 +    protected void setUp() throws Exception {
   20.29 +        currencyConvertorFactoryInstance = ConvertorsFactory.getCurrencyConvertorFactoryInstance();
   20.30 +    }
   20.31 +
   20.32 +    @Override
   20.33 +    protected void tearDown() throws Exception {
   20.34 +        currencyConvertorFactoryInstance = null;
   20.35 +    }
   20.36 +
   20.37 +    /**
   20.38 +     * Create convertor that understands two currencies, CZK and
   20.39 +     * USD. Make 1 USD == 17 CZK.
   20.40 +     * <p/>
   20.41 +     * Creation of the convertor shall not require subclassing of any class
   20.42 +     * or interface on the client side.
   20.43 +     *
   20.44 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   20.45 +     */
   20.46 +    public static Convertor createCZKtoUSD() throws ConvertorNotAvailableException {
   20.47 +        final Currency czk = Currency.getInstance("CZK");
   20.48 +        final Currency usd = Currency.getInstance("USD");
   20.49 +        final BigDecimal constant = BigDecimal.ONE.divide(BigDecimal.valueOf(17), 10, RoundingMode.HALF_EVEN);
   20.50 +        return currencyConvertorFactoryInstance.createConvertor(czk, usd, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
   20.51 +    }
   20.52 +
   20.53 +    /**
   20.54 +     * Create convertor that understands two currencies, CZK and
   20.55 +     * SKK. Make 100 SKK == 80 CZK.
   20.56 +     * <p/>
   20.57 +     * Creation of the convertor shall not require subclassing of any class
   20.58 +     * or interface on the client side.
   20.59 +     *
   20.60 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   20.61 +     */
   20.62 +    public static Convertor createSKKtoCZK() throws ConvertorNotAvailableException {
   20.63 +        final Currency skk = Currency.getInstance("SKK");
   20.64 +        final Currency czk = Currency.getInstance("CZK");
   20.65 +        final BigDecimal constant = new BigDecimal("0.8");
   20.66 +        return currencyConvertorFactoryInstance.createConvertor(skk, czk, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
   20.67 +    }
   20.68 +
   20.69 +    /**
   20.70 +     * Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   20.71 +     * with it.
   20.72 +     */
   20.73 +    public void testCurrencyCZKUSD() throws Exception {
   20.74 +        Convertor c = createCZKtoUSD();
   20.75 +        // convert $5 to CZK using c:
   20.76 +
   20.77 +        final int czkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
   20.78 +        final int usdDigitsScale = c.getCurrency2().getDefaultFractionDigits();
   20.79 +
   20.80 +        assertEquals("Result is 85 CZK", BigDecimal.valueOf(85).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(5)));
   20.81 +
   20.82 +        // convert $8 to CZK
   20.83 +        assertEquals("Result is 136 CZK", BigDecimal.valueOf(136).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(8)));
   20.84 +
   20.85 +        // convert 1003CZK to USD
   20.86 +        assertEquals("Result is 59 USD", BigDecimal.valueOf(59).setScale(usdDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(1003)));
   20.87 +    }
   20.88 +
   20.89 +    /**
   20.90 +     * Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   20.91 +     * with it.
   20.92 +     */
   20.93 +    public void testCurrencySKKCZK() throws Exception {
   20.94 +        Convertor c = createSKKtoCZK();
   20.95 +        // convert 16CZK using c:
   20.96 +
   20.97 +        final int skkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
   20.98 +        final int czkDigitsScale = c.getCurrency2().getDefaultFractionDigits();
   20.99 +        
  20.100 +        assertEquals("Result is 20 SKK", BigDecimal.valueOf(20).setScale(skkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(16)));
  20.101 +
  20.102 +        // convert 500SKK to CZK
  20.103 +        assertEquals("Result is 400 CZK", BigDecimal.valueOf(400).setScale(czkDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(500)));
  20.104 +    }
  20.105 +
  20.106 +}
  20.107 +
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/task2/solution02/build.xml	Wed Oct 01 10:43:05 2008 +0200
    21.3 @@ -0,0 +1,69 @@
    21.4 +<?xml version="1.0" encoding="UTF-8"?>
    21.5 +<!-- You may freely edit this file. See commented blocks below for -->
    21.6 +<!-- some examples of how to customize the build. -->
    21.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    21.8 +<project name="currency" default="default" basedir=".">
    21.9 +    <description>Builds, tests, and runs the project.</description>
   21.10 +    <import file="nbproject/build-impl.xml"/>
   21.11 +    <!--
   21.12 +
   21.13 +    There exist several targets which are by default empty and which can be 
   21.14 +    used for execution of your tasks. These targets are usually executed 
   21.15 +    before and after some main targets. They are: 
   21.16 +
   21.17 +      -pre-init:                 called before initialization of project properties
   21.18 +      -post-init:                called after initialization of project properties
   21.19 +      -pre-compile:              called before javac compilation
   21.20 +      -post-compile:             called after javac compilation
   21.21 +      -pre-compile-single:       called before javac compilation of single file
   21.22 +      -post-compile-single:      called after javac compilation of single file
   21.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   21.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   21.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   21.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   21.27 +      -pre-jar:                  called before JAR building
   21.28 +      -post-jar:                 called after JAR building
   21.29 +      -post-clean:               called after cleaning build products
   21.30 +
   21.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   21.32 +
   21.33 +    Example of inserting an obfuscator after compilation could look like this:
   21.34 +
   21.35 +        <target name="-post-compile">
   21.36 +            <obfuscate>
   21.37 +                <fileset dir="${build.classes.dir}"/>
   21.38 +            </obfuscate>
   21.39 +        </target>
   21.40 +
   21.41 +    For list of available properties check the imported 
   21.42 +    nbproject/build-impl.xml file. 
   21.43 +
   21.44 +
   21.45 +    Another way to customize the build is by overriding existing main targets.
   21.46 +    The targets of interest are: 
   21.47 +
   21.48 +      -init-macrodef-javac:     defines macro for javac compilation
   21.49 +      -init-macrodef-junit:     defines macro for junit execution
   21.50 +      -init-macrodef-debug:     defines macro for class debugging
   21.51 +      -init-macrodef-java:      defines macro for class execution
   21.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   21.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   21.54 +      run:                      execution of project 
   21.55 +      -javadoc-build:           Javadoc generation
   21.56 +      test-report:              JUnit report generation
   21.57 +
   21.58 +    An example of overriding the target for project execution could look like this:
   21.59 +
   21.60 +        <target name="run" depends="currency-impl.jar">
   21.61 +            <exec dir="bin" executable="launcher.exe">
   21.62 +                <arg file="${dist.jar}"/>
   21.63 +            </exec>
   21.64 +        </target>
   21.65 +
   21.66 +    Notice that the overridden target depends on the jar target and not only on 
   21.67 +    the compile target as the regular run target does. Again, for a list of available 
   21.68 +    properties which you can use, check the target you are overriding in the
   21.69 +    nbproject/build-impl.xml file. 
   21.70 +
   21.71 +    -->
   21.72 +</project>
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/task2/solution02/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    22.3 @@ -0,0 +1,642 @@
    22.4 +<?xml version="1.0" encoding="UTF-8"?>
    22.5 +<!--
    22.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    22.7 +***         EDIT ../build.xml INSTEAD         ***
    22.8 +
    22.9 +For the purpose of easier reading the script
   22.10 +is divided into following sections:
   22.11 +
   22.12 +  - initialization
   22.13 +  - compilation
   22.14 +  - jar
   22.15 +  - execution
   22.16 +  - debugging
   22.17 +  - javadoc
   22.18 +  - junit compilation
   22.19 +  - junit execution
   22.20 +  - junit debugging
   22.21 +  - applet
   22.22 +  - cleanup
   22.23 +
   22.24 +        -->
   22.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_02-impl">
   22.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   22.27 +    <!-- 
   22.28 +                ======================
   22.29 +                INITIALIZATION SECTION 
   22.30 +                ======================
   22.31 +            -->
   22.32 +    <target name="-pre-init">
   22.33 +        <!-- Empty placeholder for easier customization. -->
   22.34 +        <!-- You can override this target in the ../build.xml file. -->
   22.35 +    </target>
   22.36 +    <target depends="-pre-init" name="-init-private">
   22.37 +        <property file="nbproject/private/config.properties"/>
   22.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   22.39 +        <property file="nbproject/private/private.properties"/>
   22.40 +    </target>
   22.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   22.42 +        <property file="${user.properties.file}"/>
   22.43 +        <!-- The two properties below are usually overridden -->
   22.44 +        <!-- by the active platform. Just a fallback. -->
   22.45 +        <property name="default.javac.source" value="1.4"/>
   22.46 +        <property name="default.javac.target" value="1.4"/>
   22.47 +    </target>
   22.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   22.49 +        <property file="nbproject/configs/${config}.properties"/>
   22.50 +        <property file="nbproject/project.properties"/>
   22.51 +    </target>
   22.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   22.53 +        <available file="${manifest.file}" property="manifest.available"/>
   22.54 +        <condition property="manifest.available+main.class">
   22.55 +            <and>
   22.56 +                <isset property="manifest.available"/>
   22.57 +                <isset property="main.class"/>
   22.58 +                <not>
   22.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   22.60 +                </not>
   22.61 +            </and>
   22.62 +        </condition>
   22.63 +        <condition property="manifest.available+main.class+mkdist.available">
   22.64 +            <and>
   22.65 +                <istrue value="${manifest.available+main.class}"/>
   22.66 +                <isset property="libs.CopyLibs.classpath"/>
   22.67 +            </and>
   22.68 +        </condition>
   22.69 +        <condition property="have.tests">
   22.70 +            <or>
   22.71 +                <available file="${test.src.dir}"/>
   22.72 +            </or>
   22.73 +        </condition>
   22.74 +        <condition property="have.sources">
   22.75 +            <or>
   22.76 +                <available file="${src.dir}"/>
   22.77 +            </or>
   22.78 +        </condition>
   22.79 +        <condition property="netbeans.home+have.tests">
   22.80 +            <and>
   22.81 +                <isset property="netbeans.home"/>
   22.82 +                <isset property="have.tests"/>
   22.83 +            </and>
   22.84 +        </condition>
   22.85 +        <condition property="no.javadoc.preview">
   22.86 +            <and>
   22.87 +                <isset property="javadoc.preview"/>
   22.88 +                <isfalse value="${javadoc.preview}"/>
   22.89 +            </and>
   22.90 +        </condition>
   22.91 +        <property name="run.jvmargs" value=""/>
   22.92 +        <property name="javac.compilerargs" value=""/>
   22.93 +        <property name="work.dir" value="${basedir}"/>
   22.94 +        <condition property="no.deps">
   22.95 +            <and>
   22.96 +                <istrue value="${no.dependencies}"/>
   22.97 +            </and>
   22.98 +        </condition>
   22.99 +        <property name="javac.debug" value="true"/>
  22.100 +        <property name="javadoc.preview" value="true"/>
  22.101 +        <property name="application.args" value=""/>
  22.102 +        <property name="source.encoding" value="${file.encoding}"/>
  22.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  22.104 +            <and>
  22.105 +                <isset property="javadoc.encoding"/>
  22.106 +                <not>
  22.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  22.108 +                </not>
  22.109 +            </and>
  22.110 +        </condition>
  22.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  22.112 +        <property name="includes" value="**"/>
  22.113 +        <property name="excludes" value=""/>
  22.114 +        <property name="do.depend" value="false"/>
  22.115 +        <condition property="do.depend.true">
  22.116 +            <istrue value="${do.depend}"/>
  22.117 +        </condition>
  22.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  22.119 +            <and>
  22.120 +                <isset property="jaxws.endorsed.dir"/>
  22.121 +                <available file="nbproject/jaxws-build.xml"/>
  22.122 +            </and>
  22.123 +        </condition>
  22.124 +    </target>
  22.125 +    <target name="-post-init">
  22.126 +        <!-- Empty placeholder for easier customization. -->
  22.127 +        <!-- You can override this target in the ../build.xml file. -->
  22.128 +    </target>
  22.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  22.130 +        <fail unless="src.dir">Must set src.dir</fail>
  22.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  22.132 +        <fail unless="build.dir">Must set build.dir</fail>
  22.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  22.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  22.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  22.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  22.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  22.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  22.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  22.140 +    </target>
  22.141 +    <target name="-init-macrodef-property">
  22.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  22.143 +            <attribute name="name"/>
  22.144 +            <attribute name="value"/>
  22.145 +            <sequential>
  22.146 +                <property name="@{name}" value="${@{value}}"/>
  22.147 +            </sequential>
  22.148 +        </macrodef>
  22.149 +    </target>
  22.150 +    <target name="-init-macrodef-javac">
  22.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  22.152 +            <attribute default="${src.dir}" name="srcdir"/>
  22.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  22.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  22.155 +            <attribute default="${includes}" name="includes"/>
  22.156 +            <attribute default="${excludes}" name="excludes"/>
  22.157 +            <attribute default="${javac.debug}" name="debug"/>
  22.158 +            <attribute default="" name="sourcepath"/>
  22.159 +            <element name="customize" optional="true"/>
  22.160 +            <sequential>
  22.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}">
  22.162 +                    <classpath>
  22.163 +                        <path path="@{classpath}"/>
  22.164 +                    </classpath>
  22.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  22.166 +                    <customize/>
  22.167 +                </javac>
  22.168 +            </sequential>
  22.169 +        </macrodef>
  22.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  22.171 +            <attribute default="${src.dir}" name="srcdir"/>
  22.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  22.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  22.174 +            <sequential>
  22.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  22.176 +                    <classpath>
  22.177 +                        <path path="@{classpath}"/>
  22.178 +                    </classpath>
  22.179 +                </depend>
  22.180 +            </sequential>
  22.181 +        </macrodef>
  22.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  22.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  22.184 +            <sequential>
  22.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  22.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  22.187 +                    <path>
  22.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  22.189 +                    </path>
  22.190 +                    <globmapper from="*.java" to="*.class"/>
  22.191 +                </pathconvert>
  22.192 +                <delete>
  22.193 +                    <files includes="${javac.includes.binary}"/>
  22.194 +                </delete>
  22.195 +            </sequential>
  22.196 +        </macrodef>
  22.197 +    </target>
  22.198 +    <target name="-init-macrodef-junit">
  22.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  22.200 +            <attribute default="${includes}" name="includes"/>
  22.201 +            <attribute default="${excludes}" name="excludes"/>
  22.202 +            <attribute default="**" name="testincludes"/>
  22.203 +            <sequential>
  22.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  22.205 +                    <batchtest todir="${build.test.results.dir}">
  22.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  22.207 +                            <filename name="@{testincludes}"/>
  22.208 +                        </fileset>
  22.209 +                    </batchtest>
  22.210 +                    <classpath>
  22.211 +                        <path path="${run.test.classpath}"/>
  22.212 +                    </classpath>
  22.213 +                    <syspropertyset>
  22.214 +                        <propertyref prefix="test-sys-prop."/>
  22.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  22.216 +                    </syspropertyset>
  22.217 +                    <formatter type="brief" usefile="false"/>
  22.218 +                    <formatter type="xml"/>
  22.219 +                    <jvmarg line="${run.jvmargs}"/>
  22.220 +                </junit>
  22.221 +            </sequential>
  22.222 +        </macrodef>
  22.223 +    </target>
  22.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  22.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  22.226 +            <attribute default="${main.class}" name="name"/>
  22.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  22.228 +            <attribute default="" name="stopclassname"/>
  22.229 +            <sequential>
  22.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  22.231 +                    <classpath>
  22.232 +                        <path path="@{classpath}"/>
  22.233 +                    </classpath>
  22.234 +                </nbjpdastart>
  22.235 +            </sequential>
  22.236 +        </macrodef>
  22.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  22.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  22.239 +            <sequential>
  22.240 +                <nbjpdareload>
  22.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  22.242 +                        <include name="${fix.includes}*.class"/>
  22.243 +                    </fileset>
  22.244 +                </nbjpdareload>
  22.245 +            </sequential>
  22.246 +        </macrodef>
  22.247 +    </target>
  22.248 +    <target name="-init-debug-args">
  22.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  22.250 +        <condition property="have-jdk-older-than-1.4">
  22.251 +            <or>
  22.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  22.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  22.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  22.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  22.256 +            </or>
  22.257 +        </condition>
  22.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  22.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  22.260 +        </condition>
  22.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  22.262 +            <os family="windows"/>
  22.263 +        </condition>
  22.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  22.265 +            <isset property="debug.transport"/>
  22.266 +        </condition>
  22.267 +    </target>
  22.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  22.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  22.270 +            <attribute default="${main.class}" name="classname"/>
  22.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  22.272 +            <element name="customize" optional="true"/>
  22.273 +            <sequential>
  22.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  22.275 +                    <jvmarg line="${debug-args-line}"/>
  22.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  22.277 +                    <jvmarg line="${run.jvmargs}"/>
  22.278 +                    <classpath>
  22.279 +                        <path path="@{classpath}"/>
  22.280 +                    </classpath>
  22.281 +                    <syspropertyset>
  22.282 +                        <propertyref prefix="run-sys-prop."/>
  22.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  22.284 +                    </syspropertyset>
  22.285 +                    <customize/>
  22.286 +                </java>
  22.287 +            </sequential>
  22.288 +        </macrodef>
  22.289 +    </target>
  22.290 +    <target name="-init-macrodef-java">
  22.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  22.292 +            <attribute default="${main.class}" name="classname"/>
  22.293 +            <element name="customize" optional="true"/>
  22.294 +            <sequential>
  22.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  22.296 +                    <jvmarg line="${run.jvmargs}"/>
  22.297 +                    <classpath>
  22.298 +                        <path path="${run.classpath}"/>
  22.299 +                    </classpath>
  22.300 +                    <syspropertyset>
  22.301 +                        <propertyref prefix="run-sys-prop."/>
  22.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  22.303 +                    </syspropertyset>
  22.304 +                    <customize/>
  22.305 +                </java>
  22.306 +            </sequential>
  22.307 +        </macrodef>
  22.308 +    </target>
  22.309 +    <target name="-init-presetdef-jar">
  22.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  22.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  22.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  22.313 +            </jar>
  22.314 +        </presetdef>
  22.315 +    </target>
  22.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"/>
  22.317 +    <!--
  22.318 +                ===================
  22.319 +                COMPILATION SECTION
  22.320 +                ===================
  22.321 +            -->
  22.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  22.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  22.324 +    <target depends="init" name="-check-automatic-build">
  22.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  22.326 +    </target>
  22.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  22.328 +        <antcall target="clean"/>
  22.329 +    </target>
  22.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  22.331 +        <mkdir dir="${build.classes.dir}"/>
  22.332 +    </target>
  22.333 +    <target name="-pre-compile">
  22.334 +        <!-- Empty placeholder for easier customization. -->
  22.335 +        <!-- You can override this target in the ../build.xml file. -->
  22.336 +    </target>
  22.337 +    <target if="do.depend.true" name="-compile-depend">
  22.338 +        <j2seproject3:depend/>
  22.339 +    </target>
  22.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  22.341 +        <j2seproject3:javac/>
  22.342 +        <copy todir="${build.classes.dir}">
  22.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  22.344 +        </copy>
  22.345 +    </target>
  22.346 +    <target name="-post-compile">
  22.347 +        <!-- Empty placeholder for easier customization. -->
  22.348 +        <!-- You can override this target in the ../build.xml file. -->
  22.349 +    </target>
  22.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  22.351 +    <target name="-pre-compile-single">
  22.352 +        <!-- Empty placeholder for easier customization. -->
  22.353 +        <!-- You can override this target in the ../build.xml file. -->
  22.354 +    </target>
  22.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  22.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  22.357 +        <j2seproject3:force-recompile/>
  22.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  22.359 +    </target>
  22.360 +    <target name="-post-compile-single">
  22.361 +        <!-- Empty placeholder for easier customization. -->
  22.362 +        <!-- You can override this target in the ../build.xml file. -->
  22.363 +    </target>
  22.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  22.365 +    <!--
  22.366 +                ====================
  22.367 +                JAR BUILDING SECTION
  22.368 +                ====================
  22.369 +            -->
  22.370 +    <target depends="init" name="-pre-pre-jar">
  22.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  22.372 +        <mkdir dir="${dist.jar.dir}"/>
  22.373 +    </target>
  22.374 +    <target name="-pre-jar">
  22.375 +        <!-- Empty placeholder for easier customization. -->
  22.376 +        <!-- You can override this target in the ../build.xml file. -->
  22.377 +    </target>
  22.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  22.379 +        <j2seproject1:jar/>
  22.380 +    </target>
  22.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  22.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  22.383 +    </target>
  22.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">
  22.385 +        <j2seproject1:jar manifest="${manifest.file}">
  22.386 +            <j2seproject1:manifest>
  22.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  22.388 +            </j2seproject1:manifest>
  22.389 +        </j2seproject1:jar>
  22.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  22.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  22.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  22.393 +        <pathconvert property="run.classpath.with.dist.jar">
  22.394 +            <path path="${run.classpath}"/>
  22.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  22.396 +        </pathconvert>
  22.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  22.398 +    </target>
  22.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  22.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  22.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  22.402 +            <path path="${run.classpath}"/>
  22.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  22.404 +        </pathconvert>
  22.405 +        <pathconvert pathsep=" " property="jar.classpath">
  22.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  22.407 +            <chainedmapper>
  22.408 +                <flattenmapper/>
  22.409 +                <globmapper from="*" to="lib/*"/>
  22.410 +            </chainedmapper>
  22.411 +        </pathconvert>
  22.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  22.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  22.414 +            <fileset dir="${build.classes.dir}"/>
  22.415 +            <manifest>
  22.416 +                <attribute name="Main-Class" value="${main.class}"/>
  22.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  22.418 +            </manifest>
  22.419 +        </copylibs>
  22.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  22.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  22.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  22.423 +    </target>
  22.424 +    <target name="-post-jar">
  22.425 +        <!-- Empty placeholder for easier customization. -->
  22.426 +        <!-- You can override this target in the ../build.xml file. -->
  22.427 +    </target>
  22.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"/>
  22.429 +    <!--
  22.430 +                =================
  22.431 +                EXECUTION SECTION
  22.432 +                =================
  22.433 +            -->
  22.434 +    <target depends="init,compile" description="Run a main class." name="run">
  22.435 +        <j2seproject1:java>
  22.436 +            <customize>
  22.437 +                <arg line="${application.args}"/>
  22.438 +            </customize>
  22.439 +        </j2seproject1:java>
  22.440 +    </target>
  22.441 +    <target name="-do-not-recompile">
  22.442 +        <property name="javac.includes.binary" value=""/>
  22.443 +    </target>
  22.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  22.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  22.446 +        <j2seproject1:java classname="${run.class}"/>
  22.447 +    </target>
  22.448 +    <!--
  22.449 +                =================
  22.450 +                DEBUGGING SECTION
  22.451 +                =================
  22.452 +            -->
  22.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  22.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  22.455 +    </target>
  22.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  22.457 +        <j2seproject3:debug>
  22.458 +            <customize>
  22.459 +                <arg line="${application.args}"/>
  22.460 +            </customize>
  22.461 +        </j2seproject3:debug>
  22.462 +    </target>
  22.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  22.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  22.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  22.466 +    </target>
  22.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  22.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  22.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  22.470 +        <j2seproject3:debug classname="${debug.class}"/>
  22.471 +    </target>
  22.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  22.473 +    <target depends="init" name="-pre-debug-fix">
  22.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  22.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  22.476 +    </target>
  22.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  22.478 +        <j2seproject1:nbjpdareload/>
  22.479 +    </target>
  22.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  22.481 +    <!--
  22.482 +                ===============
  22.483 +                JAVADOC SECTION
  22.484 +                ===============
  22.485 +            -->
  22.486 +    <target depends="init" name="-javadoc-build">
  22.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  22.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}">
  22.489 +            <classpath>
  22.490 +                <path path="${javac.classpath}"/>
  22.491 +            </classpath>
  22.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  22.493 +                <filename name="**/*.java"/>
  22.494 +            </fileset>
  22.495 +        </javadoc>
  22.496 +    </target>
  22.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  22.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  22.499 +    </target>
  22.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  22.501 +    <!--
  22.502 +                =========================
  22.503 +                JUNIT COMPILATION SECTION
  22.504 +                =========================
  22.505 +            -->
  22.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  22.507 +        <mkdir dir="${build.test.classes.dir}"/>
  22.508 +    </target>
  22.509 +    <target name="-pre-compile-test">
  22.510 +        <!-- Empty placeholder for easier customization. -->
  22.511 +        <!-- You can override this target in the ../build.xml file. -->
  22.512 +    </target>
  22.513 +    <target if="do.depend.true" name="-compile-test-depend">
  22.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  22.515 +    </target>
  22.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  22.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  22.518 +        <copy todir="${build.test.classes.dir}">
  22.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  22.520 +        </copy>
  22.521 +    </target>
  22.522 +    <target name="-post-compile-test">
  22.523 +        <!-- Empty placeholder for easier customization. -->
  22.524 +        <!-- You can override this target in the ../build.xml file. -->
  22.525 +    </target>
  22.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  22.527 +    <target name="-pre-compile-test-single">
  22.528 +        <!-- Empty placeholder for easier customization. -->
  22.529 +        <!-- You can override this target in the ../build.xml file. -->
  22.530 +    </target>
  22.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  22.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  22.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  22.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}"/>
  22.535 +        <copy todir="${build.test.classes.dir}">
  22.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  22.537 +        </copy>
  22.538 +    </target>
  22.539 +    <target name="-post-compile-test-single">
  22.540 +        <!-- Empty placeholder for easier customization. -->
  22.541 +        <!-- You can override this target in the ../build.xml file. -->
  22.542 +    </target>
  22.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"/>
  22.544 +    <!--
  22.545 +                =======================
  22.546 +                JUNIT EXECUTION SECTION
  22.547 +                =======================
  22.548 +            -->
  22.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  22.550 +        <mkdir dir="${build.test.results.dir}"/>
  22.551 +    </target>
  22.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  22.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  22.554 +    </target>
  22.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  22.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  22.557 +    </target>
  22.558 +    <target depends="init" if="have.tests" name="test-report"/>
  22.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  22.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"/>
  22.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  22.562 +        <mkdir dir="${build.test.results.dir}"/>
  22.563 +    </target>
  22.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  22.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  22.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  22.567 +    </target>
  22.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  22.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  22.570 +    </target>
  22.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"/>
  22.572 +    <!--
  22.573 +                =======================
  22.574 +                JUNIT DEBUGGING SECTION
  22.575 +                =======================
  22.576 +            -->
  22.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  22.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  22.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  22.580 +        <delete file="${test.report.file}"/>
  22.581 +        <mkdir dir="${build.test.results.dir}"/>
  22.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}">
  22.583 +            <customize>
  22.584 +                <syspropertyset>
  22.585 +                    <propertyref prefix="test-sys-prop."/>
  22.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  22.587 +                </syspropertyset>
  22.588 +                <arg value="${test.class}"/>
  22.589 +                <arg value="showoutput=true"/>
  22.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  22.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  22.592 +            </customize>
  22.593 +        </j2seproject3:debug>
  22.594 +    </target>
  22.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  22.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  22.597 +    </target>
  22.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  22.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  22.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  22.601 +    </target>
  22.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  22.603 +    <!--
  22.604 +                =========================
  22.605 +                APPLET EXECUTION SECTION
  22.606 +                =========================
  22.607 +            -->
  22.608 +    <target depends="init,compile-single" name="run-applet">
  22.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  22.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  22.611 +            <customize>
  22.612 +                <arg value="${applet.url}"/>
  22.613 +            </customize>
  22.614 +        </j2seproject1:java>
  22.615 +    </target>
  22.616 +    <!--
  22.617 +                =========================
  22.618 +                APPLET DEBUGGING  SECTION
  22.619 +                =========================
  22.620 +            -->
  22.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  22.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  22.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  22.624 +            <customize>
  22.625 +                <arg value="${applet.url}"/>
  22.626 +            </customize>
  22.627 +        </j2seproject3:debug>
  22.628 +    </target>
  22.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  22.630 +    <!--
  22.631 +                ===============
  22.632 +                CLEANUP SECTION
  22.633 +                ===============
  22.634 +            -->
  22.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  22.636 +    <target depends="init" name="-do-clean">
  22.637 +        <delete dir="${build.dir}"/>
  22.638 +        <delete dir="${dist.dir}"/>
  22.639 +    </target>
  22.640 +    <target name="-post-clean">
  22.641 +        <!-- Empty placeholder for easier customization. -->
  22.642 +        <!-- You can override this target in the ../build.xml file. -->
  22.643 +    </target>
  22.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  22.645 +</project>
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/task2/solution02/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    23.3 @@ -0,0 +1,8 @@
    23.4 +build.xml.data.CRC32=2ab820eb
    23.5 +build.xml.script.CRC32=58a52595
    23.6 +build.xml.stylesheet.CRC32=be360661
    23.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    23.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    23.9 +nbproject/build-impl.xml.data.CRC32=848e6267
   23.10 +nbproject/build-impl.xml.script.CRC32=6be86987
   23.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/task2/solution02/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    24.3 @@ -0,0 +1,68 @@
    24.4 +application.title=currency
    24.5 +application.vendor=apidesign.org
    24.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    24.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    24.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    24.9 +build.classes.dir=${build.dir}/classes
   24.10 +build.classes.excludes=**/*.java,**/*.form
   24.11 +# This directory is removed when the project is cleaned:
   24.12 +build.dir=build
   24.13 +build.generated.dir=${build.dir}/generated
   24.14 +# Only compile against the classpath explicitly listed here:
   24.15 +build.sysclasspath=ignore
   24.16 +build.test.classes.dir=${build.dir}/test/classes
   24.17 +build.test.results.dir=${build.dir}/test/results
   24.18 +debug.classpath=\
   24.19 +    ${run.classpath}
   24.20 +debug.test.classpath=\
   24.21 +    ${run.test.classpath}
   24.22 +# This directory is removed when the project is cleaned:
   24.23 +dist.dir=dist
   24.24 +dist.jar=${dist.dir}/currency.jar
   24.25 +dist.javadoc.dir=${dist.dir}/javadoc
   24.26 +excludes=
   24.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   24.28 +file.reference.src-apifest08=..
   24.29 +includes=**
   24.30 +jar.compress=false
   24.31 +javac.classpath=
   24.32 +# Space-separated list of extra javac options
   24.33 +javac.compilerargs=
   24.34 +javac.deprecation=false
   24.35 +javac.source=1.5
   24.36 +javac.target=1.5
   24.37 +javac.test.classpath=\
   24.38 +    ${javac.classpath}:\
   24.39 +    ${build.classes.dir}:\
   24.40 +    ${file.reference.junit-4.4.jar}
   24.41 +javadoc.additionalparam=
   24.42 +javadoc.author=false
   24.43 +javadoc.encoding=
   24.44 +javadoc.noindex=false
   24.45 +javadoc.nonavbar=false
   24.46 +javadoc.notree=false
   24.47 +javadoc.private=false
   24.48 +javadoc.splitindex=true
   24.49 +javadoc.use=true
   24.50 +javadoc.version=false
   24.51 +javadoc.windowtitle=
   24.52 +jnlp.codebase.type=local
   24.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   24.54 +jnlp.descriptor=application
   24.55 +jnlp.enabled=false
   24.56 +jnlp.offline-allowed=false
   24.57 +jnlp.signed=false
   24.58 +meta.inf.dir=${src.dir}/META-INF
   24.59 +platform.active=default_platform
   24.60 +run.classpath=\
   24.61 +    ${javac.classpath}:\
   24.62 +    ${build.classes.dir}
   24.63 +# Space-separated list of JVM arguments used when running the project
   24.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   24.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   24.66 +run.jvmargs=
   24.67 +run.test.classpath=\
   24.68 +    ${javac.test.classpath}:\
   24.69 +    ${build.test.classes.dir}
   24.70 +src.dir=src
   24.71 +test.src.dir=test
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/task2/solution02/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    25.3 @@ -0,0 +1,16 @@
    25.4 +<?xml version="1.0" encoding="UTF-8"?>
    25.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    25.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    25.7 +    <configuration>
    25.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    25.9 +            <name>Currency Convertor Solution 02</name>
   25.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   25.11 +            <source-roots>
   25.12 +                <root id="src.dir"/>
   25.13 +            </source-roots>
   25.14 +            <test-roots>
   25.15 +                <root id="test.src.dir"/>
   25.16 +            </test-roots>
   25.17 +        </data>
   25.18 +    </configuration>
   25.19 +</project>
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    26.3 @@ -0,0 +1,18 @@
    26.4 +package org.apidesign.apifest08.currency;
    26.5 +
    26.6 +import java.util.Currency;
    26.7 +
    26.8 +
    26.9 +/** 
   26.10 + * Converts currencies. To create an instance call {@link ConvertorFactory#createConvertor(Money, Money)}.
   26.11 + */
   26.12 +public interface Convertor {
   26.13 +	/**
   26.14 +	 * Converts amount to its equivalent in the destination currency. 
   26.15 +	 * @param amount 
   26.16 +	 * @param destinationCurrency
   26.17 +	 * @return
   26.18 +	 * @throws IllegalArgumentException if currency of the amount is not supported or if it is not possible to convert it to the destination currency.
   26.19 +	 */
   26.20 +	public Money convert(Money amount, Currency destinationCurrency) throws IllegalArgumentException;
   26.21 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
    27.3 @@ -0,0 +1,31 @@
    27.4 +package org.apidesign.apifest08.currency;
    27.5 +
    27.6 +
    27.7 +
    27.8 +/**
    27.9 + * Creates {@link Convertor} implementations.
   27.10 + * @author lukas
   27.11 + *
   27.12 + */
   27.13 +public class ConvertorFactory {
   27.14 +	private ConvertorFactory()
   27.15 +	{
   27.16 +		//nothing
   27.17 +	}
   27.18 +		
   27.19 +	/**
   27.20 +	 * Creates {@link Convertor} that converts from sourceEquivalent.currency to destinationEquivalent.currency. 
   27.21 +	 * Exchange rate is set as equivalents. It means if you want to create USD to CZK convertor where USD1 = CZK17 
   27.22 +     * call createConvertor(new MoneyImpl(1, USD), new MoneyImpl(17, CZK)). Convertor created by this method 
   27.23 +     * rounds the result to two decimal places.
   27.24 +	 * @param sourceEquivalent
   27.25 +	 * @param destinationEquivalent
   27.26 +	 * @return
   27.27 +	 */
   27.28 +	public static final Convertor createConvertor(Money sourceEquivalent, Money destinationEquivalent)
   27.29 +	{
   27.30 +		return new DefaultConvertor(sourceEquivalent.getAmount(), destinationEquivalent.getAmount(), sourceEquivalent.getCurrency(), destinationEquivalent.getCurrency());
   27.31 +	}
   27.32 +	
   27.33 +
   27.34 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/DefaultConvertor.java	Wed Oct 01 10:43:05 2008 +0200
    28.3 @@ -0,0 +1,164 @@
    28.4 +package org.apidesign.apifest08.currency;
    28.5 +
    28.6 +import java.io.Serializable;
    28.7 +import java.math.BigDecimal;
    28.8 +import java.math.RoundingMode;
    28.9 +import java.util.Currency;
   28.10 +
   28.11 +/**
   28.12 + * Default {@link Convertor} implementation. Exchange rate is stored as equivalents. It means if we have USD to CZK convertor and USD1 = CZK17 
   28.13 + * we store 1 in sourceEquivalent and 17 in destinationEquivalent. This class is immutable.
   28.14 + * @author lukas
   28.15 + *
   28.16 + */
   28.17 +class DefaultConvertor implements Convertor, Serializable {
   28.18 +
   28.19 +	private static final long serialVersionUID = -1754789142402148099L;
   28.20 +
   28.21 +	/**
   28.22 +	 * Equivalent in source currency.
   28.23 +	 */
   28.24 +	private final BigDecimal sourceEquivalent;
   28.25 +	
   28.26 +	/**
   28.27 +	 * Equivalent in destination currency.
   28.28 +	 */
   28.29 +	private final BigDecimal destinationEquivalent;
   28.30 +	
   28.31 +	private final Currency sourceCurrency;
   28.32 +	
   28.33 +	private final Currency destinationCurrency;
   28.34 +	
   28.35 +	public DefaultConvertor(BigDecimal sourceEquivalent, BigDecimal destinationEquivalent, Currency sourceCurrency, Currency destinationCurrency) {
   28.36 +		super();
   28.37 +		if (BigDecimal.ZERO.compareTo(sourceEquivalent)==0)
   28.38 +		{
   28.39 +			throw new IllegalArgumentException("Source equivalent amount can not be 0.");
   28.40 +		}
   28.41 +		if (BigDecimal.ZERO.compareTo(destinationEquivalent)==0)
   28.42 +		{
   28.43 +			throw new IllegalArgumentException("Destination equivalent amount can not be 0.");
   28.44 +		}
   28.45 +		this.sourceEquivalent = sourceEquivalent;
   28.46 +		this.destinationEquivalent = destinationEquivalent;
   28.47 +		this.sourceCurrency = sourceCurrency;
   28.48 +		this.destinationCurrency = destinationCurrency;
   28.49 +	}
   28.50 +	
   28.51 +	public Money convert(Money amount, Currency destinationCurrency) {
   28.52 +		if (amount==null)
   28.53 +		{
   28.54 +			throw new NullPointerException("Money is null");
   28.55 +		}
   28.56 +		if (destinationCurrency==null)
   28.57 +		{
   28.58 +			throw new NullPointerException("destionationCurrency is null");
   28.59 +		}
   28.60 +		if (isConversionInOpositeDirection(amount, destinationCurrency))
   28.61 +		{
   28.62 +			return revert().convert(amount, destinationCurrency);
   28.63 +		}
   28.64 +		if (!amount.getCurrency().equals(getSourceCurrency()))
   28.65 +		{
   28.66 +			throw new IllegalArgumentException("Can not convert from "+amount.getCurrency()+". Converts between "+getSourceCurrency()+" and "+getDestinationCurrency());
   28.67 +		}
   28.68 +		if (!getDestinationCurrency().equals(destinationCurrency))
   28.69 +		{
   28.70 +			throw new IllegalArgumentException("Can not convert to "+destinationCurrency+". Converts between "+getSourceCurrency()+" and "+getDestinationCurrency());
   28.71 +		}
   28.72 +		BigDecimal sourceAmount = amount.getAmount();
   28.73 +		BigDecimal destinationAmount = sourceAmount.multiply(destinationEquivalent).divide(sourceEquivalent, 2, RoundingMode.HALF_UP);
   28.74 +		return new MoneyImpl(destinationAmount, getDestinationCurrency());
   28.75 +	}
   28.76 +
   28.77 +	/**
   28.78 +	 * Returns true, if the conversion is in oposit direction.
   28.79 +	 * @param amount
   28.80 +	 * @param destinationCurrency
   28.81 +	 * @return
   28.82 +	 */
   28.83 +	private boolean isConversionInOpositeDirection(Money amount,	Currency destinationCurrency) {
   28.84 +		return amount.getCurrency().equals(getDestinationCurrency()) && destinationCurrency.equals(getSourceCurrency());
   28.85 +	}
   28.86 +
   28.87 +
   28.88 +	public Convertor revert() {
   28.89 +		return new DefaultConvertor(destinationEquivalent, sourceEquivalent, destinationCurrency, sourceCurrency);
   28.90 +	}
   28.91 +
   28.92 +	public BigDecimal getSourceEquivalent() {
   28.93 +		return sourceEquivalent;
   28.94 +	}
   28.95 +
   28.96 +	public BigDecimal getDestinationEquivalent() {
   28.97 +		return destinationEquivalent;
   28.98 +	}
   28.99 +
  28.100 +	public Currency getSourceCurrency() {
  28.101 +		return sourceCurrency;
  28.102 +	}
  28.103 +
  28.104 +	public Currency getDestinationCurrency() {
  28.105 +		return destinationCurrency;
  28.106 +	}
  28.107 +	
  28.108 +	@Override
  28.109 +	public String toString() {
  28.110 +		return getClass().getName()+" converts "+getSourceCurrency()+" to "+getDestinationCurrency()+" "
  28.111 +			+getSourceCurrency()+getSourceEquivalent()+"="+getDestinationCurrency()+getDestinationEquivalent();
  28.112 +	}
  28.113 +
  28.114 +	@Override
  28.115 +	public int hashCode() {
  28.116 +		final int prime = 31;
  28.117 +		int result = 1;
  28.118 +		result = prime
  28.119 +				* result
  28.120 +				+ ((destinationCurrency == null) ? 0 : destinationCurrency
  28.121 +						.hashCode());
  28.122 +		result = prime
  28.123 +				* result
  28.124 +				+ ((destinationEquivalent == null) ? 0 : destinationEquivalent
  28.125 +						.hashCode());
  28.126 +		result = prime * result
  28.127 +				+ ((sourceCurrency == null) ? 0 : sourceCurrency.hashCode());
  28.128 +		result = prime
  28.129 +				* result
  28.130 +				+ ((sourceEquivalent == null) ? 0 : sourceEquivalent.hashCode());
  28.131 +		return result;
  28.132 +	}
  28.133 +
  28.134 +	@Override
  28.135 +	public boolean equals(Object obj) {
  28.136 +		if (this == obj)
  28.137 +			return true;
  28.138 +		if (obj == null)
  28.139 +			return false;
  28.140 +		if (!(obj instanceof DefaultConvertor))
  28.141 +			return false;
  28.142 +		DefaultConvertor other = (DefaultConvertor) obj;
  28.143 +		if (destinationCurrency == null) {
  28.144 +			if (other.destinationCurrency != null)
  28.145 +				return false;
  28.146 +		} else if (!destinationCurrency.equals(other.destinationCurrency))
  28.147 +			return false;
  28.148 +		if (destinationEquivalent == null) {
  28.149 +			if (other.destinationEquivalent != null)
  28.150 +				return false;
  28.151 +		} else if (!destinationEquivalent.equals(other.destinationEquivalent))
  28.152 +			return false;
  28.153 +		if (sourceCurrency == null) {
  28.154 +			if (other.sourceCurrency != null)
  28.155 +				return false;
  28.156 +		} else if (!sourceCurrency.equals(other.sourceCurrency))
  28.157 +			return false;
  28.158 +		if (sourceEquivalent == null) {
  28.159 +			if (other.sourceEquivalent != null)
  28.160 +				return false;
  28.161 +		} else if (!sourceEquivalent.equals(other.sourceEquivalent))
  28.162 +			return false;
  28.163 +		return true;
  28.164 +	}
  28.165 +
  28.166 +
  28.167 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/Money.java	Wed Oct 01 10:43:05 2008 +0200
    29.3 @@ -0,0 +1,29 @@
    29.4 +package org.apidesign.apifest08.currency;
    29.5 +
    29.6 +import java.math.BigDecimal;
    29.7 +import java.util.Currency;
    29.8 +
    29.9 +/**
   29.10 + * Money representation. Default implementation {@link MoneyImpl} is provided. This interface can
   29.11 + * be implemented by a DTO used in client application.
   29.12 + * @author lukas
   29.13 + *
   29.14 + */
   29.15 +/*
   29.16 + * Whether we need such interface depends on the context. I can imagine than in a desktop application this interface 
   29.17 + * would be useless, Money could be a class. In J2EE environment it can be useful.
   29.18 + */
   29.19 +public interface Money {
   29.20 +
   29.21 +	/**
   29.22 +	 * Returns amount.
   29.23 +	 * @return
   29.24 +	 */
   29.25 +	public BigDecimal getAmount();
   29.26 +
   29.27 +	/**
   29.28 +	 * Returns currency.
   29.29 +	 */
   29.30 +	public Currency getCurrency();
   29.31 +
   29.32 +}
   29.33 \ No newline at end of file
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/task2/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java	Wed Oct 01 10:43:05 2008 +0200
    30.3 @@ -0,0 +1,88 @@
    30.4 +package org.apidesign.apifest08.currency;
    30.5 +
    30.6 +import java.io.Serializable;
    30.7 +import java.math.BigDecimal;
    30.8 +import java.util.Currency;
    30.9 +
   30.10 +/**
   30.11 + * Default implementation of {@link Money} interface. This class is immutable.
   30.12 + * @author lukas
   30.13 + *
   30.14 + */
   30.15 +public final class MoneyImpl implements Serializable, Money{
   30.16 +	private static final long serialVersionUID = -6091808475616516136L;
   30.17 +
   30.18 +	private final BigDecimal amount;
   30.19 +	
   30.20 +	private final Currency currency;
   30.21 +
   30.22 +	public MoneyImpl(BigDecimal amount, Currency currency) {
   30.23 +		if (amount==null) throw new NullPointerException("Amount is null");
   30.24 +		if (currency==null) throw new NullPointerException("Currency is null"+currency);
   30.25 +		this.amount = amount;
   30.26 +		this.currency = currency;
   30.27 +	}
   30.28 +	
   30.29 +	public MoneyImpl(long amount, Currency currency) {
   30.30 +		this(BigDecimal.valueOf(amount), currency);
   30.31 +	}
   30.32 +	
   30.33 +	public MoneyImpl(double amount, Currency currency) {
   30.34 +		this(BigDecimal.valueOf(amount), currency);
   30.35 +	}
   30.36 +
   30.37 +	/**
   30.38 +	 * Returns amount.
   30.39 +	 * @return
   30.40 +	 */
   30.41 +	public BigDecimal getAmount() {
   30.42 +		return amount;
   30.43 +	}
   30.44 +	
   30.45 +	/**
   30.46 +	 * Returns currency.
   30.47 +	 */
   30.48 +	public Currency getCurrency() {
   30.49 +		return currency;
   30.50 +	}
   30.51 +
   30.52 +	@Override
   30.53 +	public int hashCode() {
   30.54 +		final int prime = 31;
   30.55 +		int result = 1;
   30.56 +		result = prime * result + ((amount == null) ? 0 : amount.hashCode());
   30.57 +		result = prime * result
   30.58 +				+ ((currency == null) ? 0 : currency.hashCode());
   30.59 +		return result;
   30.60 +	}
   30.61 +
   30.62 +	@Override
   30.63 +	public boolean equals(Object obj) {
   30.64 +		if (this == obj)
   30.65 +			return true;
   30.66 +		if (obj == null)
   30.67 +			return false;
   30.68 +		if (!(obj instanceof MoneyImpl))
   30.69 +			return false;
   30.70 +		MoneyImpl other = (MoneyImpl) obj;
   30.71 +		if (amount == null) {
   30.72 +			if (other.amount != null)
   30.73 +				return false;
   30.74 +		} else if (amount.compareTo(other.amount)!=0)
   30.75 +			return false;
   30.76 +		if (currency == null) {
   30.77 +			if (other.currency != null)
   30.78 +				return false;
   30.79 +		} else if (!currency.equals(other.currency))
   30.80 +			return false;
   30.81 +		return true;
   30.82 +	}
   30.83 +	
   30.84 +	@Override
   30.85 +	public String toString() {
   30.86 +		return getClass().getName()+"["+currency+amount+"]";
   30.87 +	}
   30.88 +
   30.89 +	
   30.90 +	
   30.91 +}
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/task2/solution02/test/org/apidesign/apifest08/test/ConvertorFactoryTest.java	Wed Oct 01 10:43:05 2008 +0200
    31.3 @@ -0,0 +1,52 @@
    31.4 +package org.apidesign.apifest08.test;
    31.5 +
    31.6 +import static junit.framework.Assert.assertNotNull;
    31.7 +import static org.apidesign.apifest08.test.Task1Test.CZK;
    31.8 +import static org.apidesign.apifest08.test.Task1Test.USD;
    31.9 +import static org.junit.Assert.assertEquals;
   31.10 +import static org.junit.Assert.assertTrue;
   31.11 +import static org.junit.Assert.fail;
   31.12 +
   31.13 +import org.apidesign.apifest08.currency.Convertor;
   31.14 +import org.apidesign.apifest08.currency.ConvertorFactory;
   31.15 +import org.apidesign.apifest08.currency.MoneyImpl;
   31.16 +import org.junit.Test;
   31.17 +
   31.18 +
   31.19 +public class ConvertorFactoryTest {
   31.20 +	@Test(expected=NullPointerException.class)
   31.21 +	public void testNullSource()
   31.22 +	{
   31.23 +		ConvertorFactory.createConvertor(null, new MoneyImpl(1,USD));
   31.24 +	}
   31.25 +	@Test(expected=NullPointerException.class)
   31.26 +	public void testNullDestination()
   31.27 +	{
   31.28 +		ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), null);
   31.29 +	}
   31.30 +	@Test
   31.31 +	public void testOk()
   31.32 +	{
   31.33 +		assertNotNull(ConvertorFactory.createConvertor(new MoneyImpl(17,CZK),  new MoneyImpl(1,USD)));
   31.34 +	}
   31.35 +	@Test
   31.36 +	public void testOkDecimalRate()
   31.37 +	{
   31.38 +		Convertor c = ConvertorFactory.createConvertor(new MoneyImpl(1,CZK),  new MoneyImpl(1d/17d,USD));
   31.39 +		assertNotNull(c);
   31.40 +		assertEquals(new MoneyImpl(17,CZK),c.convert(new MoneyImpl(1,USD), CZK));
   31.41 +	}
   31.42 +	@Test
   31.43 +	public void testZeroEquivalentRate()
   31.44 +	{
   31.45 +		try
   31.46 +		{
   31.47 +			ConvertorFactory.createConvertor(new MoneyImpl(1,CZK),  new MoneyImpl(0,USD));
   31.48 +			fail("Exception expected");
   31.49 +		}
   31.50 +		catch(IllegalArgumentException e)
   31.51 +		{
   31.52 +			assertTrue("OK",true);
   31.53 +		}
   31.54 +	}
   31.55 +}
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/task2/solution02/test/org/apidesign/apifest08/test/ConvertorTest.java	Wed Oct 01 10:43:05 2008 +0200
    32.3 @@ -0,0 +1,32 @@
    32.4 +package org.apidesign.apifest08.test;
    32.5 +
    32.6 +import static org.apidesign.apifest08.test.Task1Test.CZK;
    32.7 +import static org.apidesign.apifest08.test.Task1Test.USD;
    32.8 +import static org.junit.Assert.assertEquals;
    32.9 +
   32.10 +import java.math.BigDecimal;
   32.11 +
   32.12 +import org.apidesign.apifest08.currency.Convertor;
   32.13 +import org.apidesign.apifest08.currency.ConvertorFactory;
   32.14 +import org.apidesign.apifest08.currency.Money;
   32.15 +import org.apidesign.apifest08.currency.MoneyImpl;
   32.16 +import org.junit.Test;
   32.17 +
   32.18 +
   32.19 +public class ConvertorTest {
   32.20 +
   32.21 +	private static final Convertor CZK_TO_USD_CONVERTOR = ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), new MoneyImpl(1,USD));
   32.22 +	@Test
   32.23 +	public void testConvertSmall()
   32.24 +	{
   32.25 +		Money converted = CZK_TO_USD_CONVERTOR.convert(new MoneyImpl(0.17,CZK),USD);
   32.26 +		assertEquals(new MoneyImpl(new BigDecimal("0.01"),USD),converted);
   32.27 +		assertEquals(USD,converted.getCurrency());
   32.28 +	}
   32.29 +	@Test
   32.30 +	public void testConvertSmallReverse()
   32.31 +	{
   32.32 +		Money converted = CZK_TO_USD_CONVERTOR.convert(new MoneyImpl(0.01,USD),CZK);
   32.33 +		assertEquals(new MoneyImpl(new BigDecimal("0.17"),CZK),converted);
   32.34 +	}
   32.35 +}
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/task2/solution02/test/org/apidesign/apifest08/test/MoneyTest.java	Wed Oct 01 10:43:05 2008 +0200
    33.3 @@ -0,0 +1,24 @@
    33.4 +package org.apidesign.apifest08.test;
    33.5 +
    33.6 +import static junit.framework.Assert.assertEquals;
    33.7 +import static org.apidesign.apifest08.test.Task1Test.CZK;
    33.8 +
    33.9 +import java.math.BigDecimal;
   33.10 +
   33.11 +import org.apidesign.apifest08.currency.MoneyImpl;
   33.12 +import org.junit.Test;
   33.13 +
   33.14 +public class MoneyTest {
   33.15 +	@Test(expected=NullPointerException.class)
   33.16 +	public void testNullAmount(){
   33.17 +		new MoneyImpl(null,CZK);
   33.18 +	}
   33.19 +	@Test(expected=NullPointerException.class)
   33.20 +	public void testNullCurrency(){
   33.21 +		new MoneyImpl(1,null);
   33.22 +	}
   33.23 +	@Test
   33.24 +	public void testOk(){
   33.25 +		assertEquals(0,new MoneyImpl(123,CZK).getAmount().compareTo(new BigDecimal("123")));
   33.26 +	}
   33.27 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/task2/solution02/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    34.3 @@ -0,0 +1,160 @@
    34.4 +package org.apidesign.apifest08.test;
    34.5 +
    34.6 +import java.util.Currency;
    34.7 +
    34.8 +import junit.framework.TestCase;
    34.9 +
   34.10 +import org.apidesign.apifest08.currency.Convertor;
   34.11 +import org.apidesign.apifest08.currency.ConvertorFactory;
   34.12 +import org.apidesign.apifest08.currency.MoneyImpl;
   34.13 +
   34.14 +/** Finish the Convertor API, and then write bodies of methods inside
   34.15 + * of this class to match the given tasks. To fullfil your task, use the
   34.16 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   34.17 + * Do not you reflection, or other hacks as your code
   34.18 + * shall run without any runtime permissions.
   34.19 + */
   34.20 +public class Task1Test extends TestCase {
   34.21 +	
   34.22 +	public static final Currency USD = Currency.getInstance("USD");
   34.23 +	public static final Currency CZK = Currency.getInstance("CZK");
   34.24 +	public static final Currency SKK = Currency.getInstance("SKK");
   34.25 +	
   34.26 +    public Task1Test(String testName) {
   34.27 +        super(testName);
   34.28 +    }
   34.29 +
   34.30 +    @Override
   34.31 +    protected void setUp() throws Exception {
   34.32 +    }
   34.33 +
   34.34 +    @Override
   34.35 +    protected void tearDown() throws Exception {
   34.36 +    }
   34.37 +
   34.38 +    //
   34.39 +    // Imagine that there are three parts of the whole system:
   34.40 +    // 1. there is someone who knows the current exchange rate
   34.41 +    // 2. there is someone who wants to do the conversion
   34.42 +    // 3. there is the API between 1. and 2. which allows them to communicate
   34.43 +    // Please design such API
   34.44 +    //
   34.45 +
   34.46 +    /** Create convertor that understands two currencies, CZK and
   34.47 +     *  USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
   34.48 +     *  e.g. those that know the exchange rate. They somehow need to create
   34.49 +     *  the objects from the API and tell them the exchange rate. The API itself
   34.50 +     *  knows nothing about any rates, before the createCZKtoUSD method is called.
   34.51 +     *
   34.52 +     * Creation of the convertor shall not require subclassing of any class
   34.53 +     * or interface on the client side.
   34.54 +     *
   34.55 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   34.56 +     */
   34.57 +    public static Convertor createCZKtoUSD() {
   34.58 +    	return ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), new MoneyImpl(1,USD));
   34.59 +    }
   34.60 +
   34.61 +    /** Create convertor that understands two currencies, CZK and
   34.62 +     *  SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
   34.63 +     *  it knows the exchange rate, and needs to use the API to create objects
   34.64 +     *  with the exchange rate. Anyone shall be ready to call this method without
   34.65 +     *  any other method being called previously. The API itself shall know
   34.66 +     *  nothing about any rates, before this method is called.
   34.67 +     *
   34.68 +     * Creation of the convertor shall not require subclassing of any class
   34.69 +     * or interface on the client side.
   34.70 +     * 
   34.71 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   34.72 +     */
   34.73 +    public static Convertor createSKKtoCZK() {
   34.74 +    	return ConvertorFactory.createConvertor(new MoneyImpl(100,SKK), new MoneyImpl(80,CZK));
   34.75 +    }
   34.76 +
   34.77 +    //
   34.78 +    // now the methods for group #2 follow:
   34.79 +    // this group knows nothing about exchange rates, but knows how to use
   34.80 +    // the API to do conversions. It somehow (by calling one of the factory
   34.81 +    // methods) gets objects from the API and uses them to do the conversions.
   34.82 +    //
   34.83 +    
   34.84 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   34.85 +     * with it.
   34.86 +     */
   34.87 +    public void testCurrencyCZKUSD() throws Exception {
   34.88 +    	Convertor c = createCZKtoUSD();
   34.89 +        // convert $5 to CZK using c:
   34.90 +        assertEquals("Result is 85 CZK",new MoneyImpl(85,CZK), c.convert(new MoneyImpl(5,USD),CZK));
   34.91 +
   34.92 +        // convert $8 to CZK
   34.93 +        assertEquals("Result is 136 CZK",new MoneyImpl(136,CZK), c.convert(new MoneyImpl(8,USD),CZK));
   34.94 +
   34.95 +        // convert 1003CZK to USD
   34.96 +        assertEquals("Result is 59 USD", new MoneyImpl(59,USD), c.convert(new MoneyImpl(1003,CZK),USD));
   34.97 +        
   34.98 +    }
   34.99 +
  34.100 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
  34.101 +     * with it.
  34.102 +     */
  34.103 +    public void testCurrencySKKCZK() throws Exception {
  34.104 +        Convertor c = createSKKtoCZK();
  34.105 +        // convert 16CZK using c:
  34.106 +        assertEquals("Result is 20 SKK", new MoneyImpl(20,SKK), c.convert(new MoneyImpl(16,CZK),SKK));
  34.107 +
  34.108 +        // convert 500SKK to CZK
  34.109 +        assertEquals("Result is 400 CZK", new MoneyImpl(400,CZK), c.convert(new MoneyImpl(500,SKK),CZK));
  34.110 +    }
  34.111 +
  34.112 +    /** Verify that the CZK to USD convertor knows nothing about SKK.
  34.113 +     */
  34.114 +    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
  34.115 +        Convertor c = createCZKtoUSD();
  34.116 +        // convert $5 to SKK, the API shall say this is not possible
  34.117 +        try
  34.118 +        {
  34.119 +        	c.convert(new MoneyImpl(5, USD), SKK);
  34.120 +        	fail("Exception expected");
  34.121 +        }
  34.122 +        catch(IllegalArgumentException e)
  34.123 +        {
  34.124 +        	assertTrue("Ok",true);
  34.125 +        }
  34.126 +        // convert 500 SKK to CZK, the API shall say this is not possible
  34.127 +        try
  34.128 +        {
  34.129 +        	c.convert(new MoneyImpl(500, SKK), CZK);
  34.130 +        	fail("Exception expected");
  34.131 +        }
  34.132 +        catch(IllegalArgumentException e)
  34.133 +        {
  34.134 +        	assertTrue("Ok",true);
  34.135 +        }
  34.136 +    }
  34.137 +
  34.138 +    /** Verify that the CZK to SKK convertor knows nothing about USD.
  34.139 +     */
  34.140 +    public void testCannotConvertToUSDwithCZKSKKConvertor() throws Exception {
  34.141 +        Convertor c = createSKKtoCZK();
  34.142 +        // convert $5 to SKK, the API shall say this is not possible
  34.143 +        try
  34.144 +        {
  34.145 +        	c.convert(new MoneyImpl(5, USD), SKK);
  34.146 +        	fail("Exception expected");
  34.147 +        }
  34.148 +        catch(IllegalArgumentException e)
  34.149 +        {
  34.150 +        	assertTrue("Ok",true);
  34.151 +        }
  34.152 +        // convert 500 CZK to USD, the API shall say this is not possible
  34.153 +        try
  34.154 +        {
  34.155 +        	c.convert(new MoneyImpl(500, CZK), USD);
  34.156 +        	fail("Exception expected");
  34.157 +        }
  34.158 +        catch(IllegalArgumentException e)
  34.159 +        {
  34.160 +        	assertTrue("Ok",true);
  34.161 +        }
  34.162 +    }
  34.163 +}
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/task2/solution03/build.xml	Wed Oct 01 10:43:05 2008 +0200
    35.3 @@ -0,0 +1,69 @@
    35.4 +<?xml version="1.0" encoding="UTF-8"?>
    35.5 +<!-- You may freely edit this file. See commented blocks below for -->
    35.6 +<!-- some examples of how to customize the build. -->
    35.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    35.8 +<project name="currency" default="default" basedir=".">
    35.9 +    <description>Builds, tests, and runs the project.</description>
   35.10 +    <import file="nbproject/build-impl.xml"/>
   35.11 +    <!--
   35.12 +
   35.13 +    There exist several targets which are by default empty and which can be 
   35.14 +    used for execution of your tasks. These targets are usually executed 
   35.15 +    before and after some main targets. They are: 
   35.16 +
   35.17 +      -pre-init:                 called before initialization of project properties
   35.18 +      -post-init:                called after initialization of project properties
   35.19 +      -pre-compile:              called before javac compilation
   35.20 +      -post-compile:             called after javac compilation
   35.21 +      -pre-compile-single:       called before javac compilation of single file
   35.22 +      -post-compile-single:      called after javac compilation of single file
   35.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   35.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   35.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   35.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   35.27 +      -pre-jar:                  called before JAR building
   35.28 +      -post-jar:                 called after JAR building
   35.29 +      -post-clean:               called after cleaning build products
   35.30 +
   35.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   35.32 +
   35.33 +    Example of inserting an obfuscator after compilation could look like this:
   35.34 +
   35.35 +        <target name="-post-compile">
   35.36 +            <obfuscate>
   35.37 +                <fileset dir="${build.classes.dir}"/>
   35.38 +            </obfuscate>
   35.39 +        </target>
   35.40 +
   35.41 +    For list of available properties check the imported 
   35.42 +    nbproject/build-impl.xml file. 
   35.43 +
   35.44 +
   35.45 +    Another way to customize the build is by overriding existing main targets.
   35.46 +    The targets of interest are: 
   35.47 +
   35.48 +      -init-macrodef-javac:     defines macro for javac compilation
   35.49 +      -init-macrodef-junit:     defines macro for junit execution
   35.50 +      -init-macrodef-debug:     defines macro for class debugging
   35.51 +      -init-macrodef-java:      defines macro for class execution
   35.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   35.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   35.54 +      run:                      execution of project 
   35.55 +      -javadoc-build:           Javadoc generation
   35.56 +      test-report:              JUnit report generation
   35.57 +
   35.58 +    An example of overriding the target for project execution could look like this:
   35.59 +
   35.60 +        <target name="run" depends="currency-impl.jar">
   35.61 +            <exec dir="bin" executable="launcher.exe">
   35.62 +                <arg file="${dist.jar}"/>
   35.63 +            </exec>
   35.64 +        </target>
   35.65 +
   35.66 +    Notice that the overridden target depends on the jar target and not only on 
   35.67 +    the compile target as the regular run target does. Again, for a list of available 
   35.68 +    properties which you can use, check the target you are overriding in the
   35.69 +    nbproject/build-impl.xml file. 
   35.70 +
   35.71 +    -->
   35.72 +</project>
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/task2/solution03/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    36.3 @@ -0,0 +1,642 @@
    36.4 +<?xml version="1.0" encoding="UTF-8"?>
    36.5 +<!--
    36.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    36.7 +***         EDIT ../build.xml INSTEAD         ***
    36.8 +
    36.9 +For the purpose of easier reading the script
   36.10 +is divided into following sections:
   36.11 +
   36.12 +  - initialization
   36.13 +  - compilation
   36.14 +  - jar
   36.15 +  - execution
   36.16 +  - debugging
   36.17 +  - javadoc
   36.18 +  - junit compilation
   36.19 +  - junit execution
   36.20 +  - junit debugging
   36.21 +  - applet
   36.22 +  - cleanup
   36.23 +
   36.24 +        -->
   36.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">
   36.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   36.27 +    <!-- 
   36.28 +                ======================
   36.29 +                INITIALIZATION SECTION 
   36.30 +                ======================
   36.31 +            -->
   36.32 +    <target name="-pre-init">
   36.33 +        <!-- Empty placeholder for easier customization. -->
   36.34 +        <!-- You can override this target in the ../build.xml file. -->
   36.35 +    </target>
   36.36 +    <target depends="-pre-init" name="-init-private">
   36.37 +        <property file="nbproject/private/config.properties"/>
   36.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   36.39 +        <property file="nbproject/private/private.properties"/>
   36.40 +    </target>
   36.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   36.42 +        <property file="${user.properties.file}"/>
   36.43 +        <!-- The two properties below are usually overridden -->
   36.44 +        <!-- by the active platform. Just a fallback. -->
   36.45 +        <property name="default.javac.source" value="1.4"/>
   36.46 +        <property name="default.javac.target" value="1.4"/>
   36.47 +    </target>
   36.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   36.49 +        <property file="nbproject/configs/${config}.properties"/>
   36.50 +        <property file="nbproject/project.properties"/>
   36.51 +    </target>
   36.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   36.53 +        <available file="${manifest.file}" property="manifest.available"/>
   36.54 +        <condition property="manifest.available+main.class">
   36.55 +            <and>
   36.56 +                <isset property="manifest.available"/>
   36.57 +                <isset property="main.class"/>
   36.58 +                <not>
   36.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   36.60 +                </not>
   36.61 +            </and>
   36.62 +        </condition>
   36.63 +        <condition property="manifest.available+main.class+mkdist.available">
   36.64 +            <and>
   36.65 +                <istrue value="${manifest.available+main.class}"/>
   36.66 +                <isset property="libs.CopyLibs.classpath"/>
   36.67 +            </and>
   36.68 +        </condition>
   36.69 +        <condition property="have.tests">
   36.70 +            <or>
   36.71 +                <available file="${test.src.dir}"/>
   36.72 +            </or>
   36.73 +        </condition>
   36.74 +        <condition property="have.sources">
   36.75 +            <or>
   36.76 +                <available file="${src.dir}"/>
   36.77 +            </or>
   36.78 +        </condition>
   36.79 +        <condition property="netbeans.home+have.tests">
   36.80 +            <and>
   36.81 +                <isset property="netbeans.home"/>
   36.82 +                <isset property="have.tests"/>
   36.83 +            </and>
   36.84 +        </condition>
   36.85 +        <condition property="no.javadoc.preview">
   36.86 +            <and>
   36.87 +                <isset property="javadoc.preview"/>
   36.88 +                <isfalse value="${javadoc.preview}"/>
   36.89 +            </and>
   36.90 +        </condition>
   36.91 +        <property name="run.jvmargs" value=""/>
   36.92 +        <property name="javac.compilerargs" value=""/>
   36.93 +        <property name="work.dir" value="${basedir}"/>
   36.94 +        <condition property="no.deps">
   36.95 +            <and>
   36.96 +                <istrue value="${no.dependencies}"/>
   36.97 +            </and>
   36.98 +        </condition>
   36.99 +        <property name="javac.debug" value="true"/>
  36.100 +        <property name="javadoc.preview" value="true"/>
  36.101 +        <property name="application.args" value=""/>
  36.102 +        <property name="source.encoding" value="${file.encoding}"/>
  36.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  36.104 +            <and>
  36.105 +                <isset property="javadoc.encoding"/>
  36.106 +                <not>
  36.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  36.108 +                </not>
  36.109 +            </and>
  36.110 +        </condition>
  36.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  36.112 +        <property name="includes" value="**"/>
  36.113 +        <property name="excludes" value=""/>
  36.114 +        <property name="do.depend" value="false"/>
  36.115 +        <condition property="do.depend.true">
  36.116 +            <istrue value="${do.depend}"/>
  36.117 +        </condition>
  36.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  36.119 +            <and>
  36.120 +                <isset property="jaxws.endorsed.dir"/>
  36.121 +                <available file="nbproject/jaxws-build.xml"/>
  36.122 +            </and>
  36.123 +        </condition>
  36.124 +    </target>
  36.125 +    <target name="-post-init">
  36.126 +        <!-- Empty placeholder for easier customization. -->
  36.127 +        <!-- You can override this target in the ../build.xml file. -->
  36.128 +    </target>
  36.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  36.130 +        <fail unless="src.dir">Must set src.dir</fail>
  36.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  36.132 +        <fail unless="build.dir">Must set build.dir</fail>
  36.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  36.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  36.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  36.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  36.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  36.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  36.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  36.140 +    </target>
  36.141 +    <target name="-init-macrodef-property">
  36.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  36.143 +            <attribute name="name"/>
  36.144 +            <attribute name="value"/>
  36.145 +            <sequential>
  36.146 +                <property name="@{name}" value="${@{value}}"/>
  36.147 +            </sequential>
  36.148 +        </macrodef>
  36.149 +    </target>
  36.150 +    <target name="-init-macrodef-javac">
  36.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  36.152 +            <attribute default="${src.dir}" name="srcdir"/>
  36.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  36.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  36.155 +            <attribute default="${includes}" name="includes"/>
  36.156 +            <attribute default="${excludes}" name="excludes"/>
  36.157 +            <attribute default="${javac.debug}" name="debug"/>
  36.158 +            <attribute default="" name="sourcepath"/>
  36.159 +            <element name="customize" optional="true"/>
  36.160 +            <sequential>
  36.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}">
  36.162 +                    <classpath>
  36.163 +                        <path path="@{classpath}"/>
  36.164 +                    </classpath>
  36.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  36.166 +                    <customize/>
  36.167 +                </javac>
  36.168 +            </sequential>
  36.169 +        </macrodef>
  36.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  36.171 +            <attribute default="${src.dir}" name="srcdir"/>
  36.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  36.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  36.174 +            <sequential>
  36.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  36.176 +                    <classpath>
  36.177 +                        <path path="@{classpath}"/>
  36.178 +                    </classpath>
  36.179 +                </depend>
  36.180 +            </sequential>
  36.181 +        </macrodef>
  36.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  36.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  36.184 +            <sequential>
  36.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  36.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  36.187 +                    <path>
  36.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  36.189 +                    </path>
  36.190 +                    <globmapper from="*.java" to="*.class"/>
  36.191 +                </pathconvert>
  36.192 +                <delete>
  36.193 +                    <files includes="${javac.includes.binary}"/>
  36.194 +                </delete>
  36.195 +            </sequential>
  36.196 +        </macrodef>
  36.197 +    </target>
  36.198 +    <target name="-init-macrodef-junit">
  36.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  36.200 +            <attribute default="${includes}" name="includes"/>
  36.201 +            <attribute default="${excludes}" name="excludes"/>
  36.202 +            <attribute default="**" name="testincludes"/>
  36.203 +            <sequential>
  36.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  36.205 +                    <batchtest todir="${build.test.results.dir}">
  36.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  36.207 +                            <filename name="@{testincludes}"/>
  36.208 +                        </fileset>
  36.209 +                    </batchtest>
  36.210 +                    <classpath>
  36.211 +                        <path path="${run.test.classpath}"/>
  36.212 +                    </classpath>
  36.213 +                    <syspropertyset>
  36.214 +                        <propertyref prefix="test-sys-prop."/>
  36.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  36.216 +                    </syspropertyset>
  36.217 +                    <formatter type="brief" usefile="false"/>
  36.218 +                    <formatter type="xml"/>
  36.219 +                    <jvmarg line="${run.jvmargs}"/>
  36.220 +                </junit>
  36.221 +            </sequential>
  36.222 +        </macrodef>
  36.223 +    </target>
  36.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  36.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  36.226 +            <attribute default="${main.class}" name="name"/>
  36.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  36.228 +            <attribute default="" name="stopclassname"/>
  36.229 +            <sequential>
  36.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  36.231 +                    <classpath>
  36.232 +                        <path path="@{classpath}"/>
  36.233 +                    </classpath>
  36.234 +                </nbjpdastart>
  36.235 +            </sequential>
  36.236 +        </macrodef>
  36.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  36.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  36.239 +            <sequential>
  36.240 +                <nbjpdareload>
  36.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  36.242 +                        <include name="${fix.includes}*.class"/>
  36.243 +                    </fileset>
  36.244 +                </nbjpdareload>
  36.245 +            </sequential>
  36.246 +        </macrodef>
  36.247 +    </target>
  36.248 +    <target name="-init-debug-args">
  36.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  36.250 +        <condition property="have-jdk-older-than-1.4">
  36.251 +            <or>
  36.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  36.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  36.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  36.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  36.256 +            </or>
  36.257 +        </condition>
  36.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  36.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  36.260 +        </condition>
  36.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  36.262 +            <os family="windows"/>
  36.263 +        </condition>
  36.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  36.265 +            <isset property="debug.transport"/>
  36.266 +        </condition>
  36.267 +    </target>
  36.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  36.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  36.270 +            <attribute default="${main.class}" name="classname"/>
  36.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  36.272 +            <element name="customize" optional="true"/>
  36.273 +            <sequential>
  36.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  36.275 +                    <jvmarg line="${debug-args-line}"/>
  36.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  36.277 +                    <jvmarg line="${run.jvmargs}"/>
  36.278 +                    <classpath>
  36.279 +                        <path path="@{classpath}"/>
  36.280 +                    </classpath>
  36.281 +                    <syspropertyset>
  36.282 +                        <propertyref prefix="run-sys-prop."/>
  36.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  36.284 +                    </syspropertyset>
  36.285 +                    <customize/>
  36.286 +                </java>
  36.287 +            </sequential>
  36.288 +        </macrodef>
  36.289 +    </target>
  36.290 +    <target name="-init-macrodef-java">
  36.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  36.292 +            <attribute default="${main.class}" name="classname"/>
  36.293 +            <element name="customize" optional="true"/>
  36.294 +            <sequential>
  36.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  36.296 +                    <jvmarg line="${run.jvmargs}"/>
  36.297 +                    <classpath>
  36.298 +                        <path path="${run.classpath}"/>
  36.299 +                    </classpath>
  36.300 +                    <syspropertyset>
  36.301 +                        <propertyref prefix="run-sys-prop."/>
  36.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  36.303 +                    </syspropertyset>
  36.304 +                    <customize/>
  36.305 +                </java>
  36.306 +            </sequential>
  36.307 +        </macrodef>
  36.308 +    </target>
  36.309 +    <target name="-init-presetdef-jar">
  36.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  36.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  36.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  36.313 +            </jar>
  36.314 +        </presetdef>
  36.315 +    </target>
  36.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"/>
  36.317 +    <!--
  36.318 +                ===================
  36.319 +                COMPILATION SECTION
  36.320 +                ===================
  36.321 +            -->
  36.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  36.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  36.324 +    <target depends="init" name="-check-automatic-build">
  36.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  36.326 +    </target>
  36.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  36.328 +        <antcall target="clean"/>
  36.329 +    </target>
  36.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  36.331 +        <mkdir dir="${build.classes.dir}"/>
  36.332 +    </target>
  36.333 +    <target name="-pre-compile">
  36.334 +        <!-- Empty placeholder for easier customization. -->
  36.335 +        <!-- You can override this target in the ../build.xml file. -->
  36.336 +    </target>
  36.337 +    <target if="do.depend.true" name="-compile-depend">
  36.338 +        <j2seproject3:depend/>
  36.339 +    </target>
  36.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  36.341 +        <j2seproject3:javac/>
  36.342 +        <copy todir="${build.classes.dir}">
  36.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  36.344 +        </copy>
  36.345 +    </target>
  36.346 +    <target name="-post-compile">
  36.347 +        <!-- Empty placeholder for easier customization. -->
  36.348 +        <!-- You can override this target in the ../build.xml file. -->
  36.349 +    </target>
  36.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  36.351 +    <target name="-pre-compile-single">
  36.352 +        <!-- Empty placeholder for easier customization. -->
  36.353 +        <!-- You can override this target in the ../build.xml file. -->
  36.354 +    </target>
  36.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  36.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  36.357 +        <j2seproject3:force-recompile/>
  36.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  36.359 +    </target>
  36.360 +    <target name="-post-compile-single">
  36.361 +        <!-- Empty placeholder for easier customization. -->
  36.362 +        <!-- You can override this target in the ../build.xml file. -->
  36.363 +    </target>
  36.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  36.365 +    <!--
  36.366 +                ====================
  36.367 +                JAR BUILDING SECTION
  36.368 +                ====================
  36.369 +            -->
  36.370 +    <target depends="init" name="-pre-pre-jar">
  36.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  36.372 +        <mkdir dir="${dist.jar.dir}"/>
  36.373 +    </target>
  36.374 +    <target name="-pre-jar">
  36.375 +        <!-- Empty placeholder for easier customization. -->
  36.376 +        <!-- You can override this target in the ../build.xml file. -->
  36.377 +    </target>
  36.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  36.379 +        <j2seproject1:jar/>
  36.380 +    </target>
  36.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  36.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  36.383 +    </target>
  36.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">
  36.385 +        <j2seproject1:jar manifest="${manifest.file}">
  36.386 +            <j2seproject1:manifest>
  36.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  36.388 +            </j2seproject1:manifest>
  36.389 +        </j2seproject1:jar>
  36.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  36.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  36.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  36.393 +        <pathconvert property="run.classpath.with.dist.jar">
  36.394 +            <path path="${run.classpath}"/>
  36.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  36.396 +        </pathconvert>
  36.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  36.398 +    </target>
  36.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  36.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  36.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  36.402 +            <path path="${run.classpath}"/>
  36.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  36.404 +        </pathconvert>
  36.405 +        <pathconvert pathsep=" " property="jar.classpath">
  36.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  36.407 +            <chainedmapper>
  36.408 +                <flattenmapper/>
  36.409 +                <globmapper from="*" to="lib/*"/>
  36.410 +            </chainedmapper>
  36.411 +        </pathconvert>
  36.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  36.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  36.414 +            <fileset dir="${build.classes.dir}"/>
  36.415 +            <manifest>
  36.416 +                <attribute name="Main-Class" value="${main.class}"/>
  36.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  36.418 +            </manifest>
  36.419 +        </copylibs>
  36.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  36.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  36.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  36.423 +    </target>
  36.424 +    <target name="-post-jar">
  36.425 +        <!-- Empty placeholder for easier customization. -->
  36.426 +        <!-- You can override this target in the ../build.xml file. -->
  36.427 +    </target>
  36.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"/>
  36.429 +    <!--
  36.430 +                =================
  36.431 +                EXECUTION SECTION
  36.432 +                =================
  36.433 +            -->
  36.434 +    <target depends="init,compile" description="Run a main class." name="run">
  36.435 +        <j2seproject1:java>
  36.436 +            <customize>
  36.437 +                <arg line="${application.args}"/>
  36.438 +            </customize>
  36.439 +        </j2seproject1:java>
  36.440 +    </target>
  36.441 +    <target name="-do-not-recompile">
  36.442 +        <property name="javac.includes.binary" value=""/>
  36.443 +    </target>
  36.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  36.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  36.446 +        <j2seproject1:java classname="${run.class}"/>
  36.447 +    </target>
  36.448 +    <!--
  36.449 +                =================
  36.450 +                DEBUGGING SECTION
  36.451 +                =================
  36.452 +            -->
  36.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  36.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  36.455 +    </target>
  36.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  36.457 +        <j2seproject3:debug>
  36.458 +            <customize>
  36.459 +                <arg line="${application.args}"/>
  36.460 +            </customize>
  36.461 +        </j2seproject3:debug>
  36.462 +    </target>
  36.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  36.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  36.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  36.466 +    </target>
  36.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  36.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  36.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  36.470 +        <j2seproject3:debug classname="${debug.class}"/>
  36.471 +    </target>
  36.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  36.473 +    <target depends="init" name="-pre-debug-fix">
  36.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  36.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  36.476 +    </target>
  36.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  36.478 +        <j2seproject1:nbjpdareload/>
  36.479 +    </target>
  36.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  36.481 +    <!--
  36.482 +                ===============
  36.483 +                JAVADOC SECTION
  36.484 +                ===============
  36.485 +            -->
  36.486 +    <target depends="init" name="-javadoc-build">
  36.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  36.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}">
  36.489 +            <classpath>
  36.490 +                <path path="${javac.classpath}"/>
  36.491 +            </classpath>
  36.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  36.493 +                <filename name="**/*.java"/>
  36.494 +            </fileset>
  36.495 +        </javadoc>
  36.496 +    </target>
  36.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  36.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  36.499 +    </target>
  36.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  36.501 +    <!--
  36.502 +                =========================
  36.503 +                JUNIT COMPILATION SECTION
  36.504 +                =========================
  36.505 +            -->
  36.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  36.507 +        <mkdir dir="${build.test.classes.dir}"/>
  36.508 +    </target>
  36.509 +    <target name="-pre-compile-test">
  36.510 +        <!-- Empty placeholder for easier customization. -->
  36.511 +        <!-- You can override this target in the ../build.xml file. -->
  36.512 +    </target>
  36.513 +    <target if="do.depend.true" name="-compile-test-depend">
  36.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  36.515 +    </target>
  36.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  36.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  36.518 +        <copy todir="${build.test.classes.dir}">
  36.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  36.520 +        </copy>
  36.521 +    </target>
  36.522 +    <target name="-post-compile-test">
  36.523 +        <!-- Empty placeholder for easier customization. -->
  36.524 +        <!-- You can override this target in the ../build.xml file. -->
  36.525 +    </target>
  36.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  36.527 +    <target name="-pre-compile-test-single">
  36.528 +        <!-- Empty placeholder for easier customization. -->
  36.529 +        <!-- You can override this target in the ../build.xml file. -->
  36.530 +    </target>
  36.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  36.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  36.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  36.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}"/>
  36.535 +        <copy todir="${build.test.classes.dir}">
  36.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  36.537 +        </copy>
  36.538 +    </target>
  36.539 +    <target name="-post-compile-test-single">
  36.540 +        <!-- Empty placeholder for easier customization. -->
  36.541 +        <!-- You can override this target in the ../build.xml file. -->
  36.542 +    </target>
  36.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"/>
  36.544 +    <!--
  36.545 +                =======================
  36.546 +                JUNIT EXECUTION SECTION
  36.547 +                =======================
  36.548 +            -->
  36.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  36.550 +        <mkdir dir="${build.test.results.dir}"/>
  36.551 +    </target>
  36.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  36.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  36.554 +    </target>
  36.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  36.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  36.557 +    </target>
  36.558 +    <target depends="init" if="have.tests" name="test-report"/>
  36.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  36.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"/>
  36.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  36.562 +        <mkdir dir="${build.test.results.dir}"/>
  36.563 +    </target>
  36.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  36.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  36.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  36.567 +    </target>
  36.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  36.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  36.570 +    </target>
  36.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"/>
  36.572 +    <!--
  36.573 +                =======================
  36.574 +                JUNIT DEBUGGING SECTION
  36.575 +                =======================
  36.576 +            -->
  36.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  36.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  36.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  36.580 +        <delete file="${test.report.file}"/>
  36.581 +        <mkdir dir="${build.test.results.dir}"/>
  36.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}">
  36.583 +            <customize>
  36.584 +                <syspropertyset>
  36.585 +                    <propertyref prefix="test-sys-prop."/>
  36.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  36.587 +                </syspropertyset>
  36.588 +                <arg value="${test.class}"/>
  36.589 +                <arg value="showoutput=true"/>
  36.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  36.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  36.592 +            </customize>
  36.593 +        </j2seproject3:debug>
  36.594 +    </target>
  36.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  36.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  36.597 +    </target>
  36.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  36.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  36.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  36.601 +    </target>
  36.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  36.603 +    <!--
  36.604 +                =========================
  36.605 +                APPLET EXECUTION SECTION
  36.606 +                =========================
  36.607 +            -->
  36.608 +    <target depends="init,compile-single" name="run-applet">
  36.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  36.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  36.611 +            <customize>
  36.612 +                <arg value="${applet.url}"/>
  36.613 +            </customize>
  36.614 +        </j2seproject1:java>
  36.615 +    </target>
  36.616 +    <!--
  36.617 +                =========================
  36.618 +                APPLET DEBUGGING  SECTION
  36.619 +                =========================
  36.620 +            -->
  36.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  36.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  36.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  36.624 +            <customize>
  36.625 +                <arg value="${applet.url}"/>
  36.626 +            </customize>
  36.627 +        </j2seproject3:debug>
  36.628 +    </target>
  36.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  36.630 +    <!--
  36.631 +                ===============
  36.632 +                CLEANUP SECTION
  36.633 +                ===============
  36.634 +            -->
  36.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  36.636 +    <target depends="init" name="-do-clean">
  36.637 +        <delete dir="${build.dir}"/>
  36.638 +        <delete dir="${dist.dir}"/>
  36.639 +    </target>
  36.640 +    <target name="-post-clean">
  36.641 +        <!-- Empty placeholder for easier customization. -->
  36.642 +        <!-- You can override this target in the ../build.xml file. -->
  36.643 +    </target>
  36.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  36.645 +</project>
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/task2/solution03/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    37.3 @@ -0,0 +1,8 @@
    37.4 +build.xml.data.CRC32=2ab820eb
    37.5 +build.xml.script.CRC32=58a52595
    37.6 +build.xml.stylesheet.CRC32=be360661
    37.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    37.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    37.9 +nbproject/build-impl.xml.data.CRC32=ec91bd4b
   37.10 +nbproject/build-impl.xml.script.CRC32=593428f7
   37.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/task2/solution03/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    38.3 @@ -0,0 +1,68 @@
    38.4 +application.title=currency
    38.5 +application.vendor=apidesign.org
    38.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    38.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    38.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    38.9 +build.classes.dir=${build.dir}/classes
   38.10 +build.classes.excludes=**/*.java,**/*.form
   38.11 +# This directory is removed when the project is cleaned:
   38.12 +build.dir=build
   38.13 +build.generated.dir=${build.dir}/generated
   38.14 +# Only compile against the classpath explicitly listed here:
   38.15 +build.sysclasspath=ignore
   38.16 +build.test.classes.dir=${build.dir}/test/classes
   38.17 +build.test.results.dir=${build.dir}/test/results
   38.18 +debug.classpath=\
   38.19 +    ${run.classpath}
   38.20 +debug.test.classpath=\
   38.21 +    ${run.test.classpath}
   38.22 +# This directory is removed when the project is cleaned:
   38.23 +dist.dir=dist
   38.24 +dist.jar=${dist.dir}/currency.jar
   38.25 +dist.javadoc.dir=${dist.dir}/javadoc
   38.26 +excludes=
   38.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   38.28 +file.reference.src-apifest08=..
   38.29 +includes=**
   38.30 +jar.compress=false
   38.31 +javac.classpath=
   38.32 +# Space-separated list of extra javac options
   38.33 +javac.compilerargs=
   38.34 +javac.deprecation=false
   38.35 +javac.source=1.5
   38.36 +javac.target=1.5
   38.37 +javac.test.classpath=\
   38.38 +    ${javac.classpath}:\
   38.39 +    ${build.classes.dir}:\
   38.40 +    ${file.reference.junit-4.4.jar}
   38.41 +javadoc.additionalparam=
   38.42 +javadoc.author=false
   38.43 +javadoc.encoding=
   38.44 +javadoc.noindex=false
   38.45 +javadoc.nonavbar=false
   38.46 +javadoc.notree=false
   38.47 +javadoc.private=false
   38.48 +javadoc.splitindex=true
   38.49 +javadoc.use=true
   38.50 +javadoc.version=false
   38.51 +javadoc.windowtitle=
   38.52 +jnlp.codebase.type=local
   38.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   38.54 +jnlp.descriptor=application
   38.55 +jnlp.enabled=false
   38.56 +jnlp.offline-allowed=false
   38.57 +jnlp.signed=false
   38.58 +meta.inf.dir=${src.dir}/META-INF
   38.59 +platform.active=default_platform
   38.60 +run.classpath=\
   38.61 +    ${javac.classpath}:\
   38.62 +    ${build.classes.dir}
   38.63 +# Space-separated list of JVM arguments used when running the project
   38.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   38.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   38.66 +run.jvmargs=
   38.67 +run.test.classpath=\
   38.68 +    ${javac.test.classpath}:\
   38.69 +    ${build.test.classes.dir}
   38.70 +src.dir=src
   38.71 +test.src.dir=test
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/task2/solution03/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    39.3 @@ -0,0 +1,16 @@
    39.4 +<?xml version="1.0" encoding="UTF-8"?>
    39.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    39.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    39.7 +    <configuration>
    39.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    39.9 +            <name>Currency Convertor Solution 03</name>
   39.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   39.11 +            <source-roots>
   39.12 +                <root id="src.dir"/>
   39.13 +            </source-roots>
   39.14 +            <test-roots>
   39.15 +                <root id="test.src.dir"/>
   39.16 +            </test-roots>
   39.17 +        </data>
   39.18 +    </configuration>
   39.19 +</project>
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    40.3 @@ -0,0 +1,41 @@
    40.4 +package org.apidesign.apifest08.currency;
    40.5 +
    40.6 +/** This is the skeleton class for your API. You need to make it public, so
    40.7 + * it is accessible to your client code (currently in Task1Test.java) file.
    40.8 + * <p>
    40.9 + * Feel free to create additional classes or rename this one, just keep all
   40.10 + * the API and its implementation in this package. Do not spread it outside
   40.11 + * to other packages.
   40.12 + */
   40.13 +public class Convertor {
   40.14 +
   40.15 +    public static final int FIRST_TO_SECOND = 1;
   40.16 +
   40.17 +    public static final int SECOND_TO_FIRST = 2;
   40.18 +
   40.19 +    private double first;
   40.20 +
   40.21 +    private double second;
   40.22 +
   40.23 +    public Convertor(double first, double second) {
   40.24 +        this.first = first;
   40.25 +        this.second = second;
   40.26 +    }
   40.27 +
   40.28 +    public double convertFirstToSecond(double value) {
   40.29 +        return (second / first) * value;
   40.30 +    }
   40.31 +
   40.32 +    public double convertSecondToFirst(double value) {
   40.33 +        return (first / second) * value;
   40.34 +    }
   40.35 +
   40.36 +    public double convert(double value, int typeOfConvert) {
   40.37 +        if (FIRST_TO_SECOND == typeOfConvert) {
   40.38 +            return convertFirstToSecond(value);
   40.39 +        } else if (SECOND_TO_FIRST == typeOfConvert) {
   40.40 +            return convertSecondToFirst(value);
   40.41 +        }
   40.42 +        throw new IllegalArgumentException("Unkown type of convert.");
   40.43 +    }
   40.44 +}
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/task2/solution03/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    41.3 @@ -0,0 +1,82 @@
    41.4 +package org.apidesign.apifest08.test;
    41.5 +
    41.6 +import junit.framework.TestCase;
    41.7 +import org.apidesign.apifest08.currency.Convertor;
    41.8 +
    41.9 +/** Finish the Convertor API, and then write bodies of methods inside
   41.10 + * of this class to match the given tasks. To fullfil your task, use the
   41.11 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   41.12 + * Do not you reflection, or other hacks as your code
   41.13 + * shall run without any runtime permissions.
   41.14 + */
   41.15 +public class Task1Test extends TestCase {
   41.16 +
   41.17 +    public Task1Test(String testName) {
   41.18 +        super(testName);
   41.19 +    }
   41.20 +
   41.21 +    @Override
   41.22 +    protected void setUp() throws Exception {
   41.23 +    }
   41.24 +
   41.25 +    @Override
   41.26 +    protected void tearDown() throws Exception {
   41.27 +    }
   41.28 +
   41.29 +    /** Create convertor that understands two currencies, CZK and
   41.30 +     *  USD. Make 1 USD == 17 CZK.
   41.31 +     *
   41.32 +     * Creation of the convertor shall not require subclassing of any class
   41.33 +     * or interface on the client side.
   41.34 +     *
   41.35 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   41.36 +     */
   41.37 +    public static Convertor createCZKtoUSD() {
   41.38 +        return new Convertor(17, 1);
   41.39 +    }
   41.40 +
   41.41 +    /** Create convertor that understands two currencies, CZK and
   41.42 +     *  SKK. Make 100 SKK == 80 CZK.
   41.43 +     *
   41.44 +     * Creation of the convertor shall not require subclassing of any class
   41.45 +     * or interface on the client side.
   41.46 +     * 
   41.47 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   41.48 +     */
   41.49 +    public static Convertor createSKKtoCZK() {
   41.50 +        return new Convertor(100, 80);
   41.51 +    }
   41.52 +
   41.53 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   41.54 +     * with it.
   41.55 +     */
   41.56 +    public void testCurrencyCZKUSD() throws Exception {
   41.57 +        Convertor c = createCZKtoUSD();
   41.58 +        // convert $5 to CZK using c:
   41.59 +        // assertEquals("Result is 85 CZK");
   41.60 +        assertEquals(c.convert(5, Convertor.SECOND_TO_FIRST), (double) 85);
   41.61 +
   41.62 +        // convert $8 to CZK
   41.63 +        // assertEquals("Result is 136 CZK");
   41.64 +        assertEquals(c.convert(8, Convertor.SECOND_TO_FIRST), (double) 136);
   41.65 +
   41.66 +        // convert 1003CZK to USD
   41.67 +        // assertEquals("Result is 59 USD");
   41.68 +        assertEquals(c.convert(1003, Convertor.FIRST_TO_SECOND), (double) 59);
   41.69 +    }
   41.70 +
   41.71 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   41.72 +     * with it.
   41.73 +     */
   41.74 +    public void testCurrencySKKCZK() throws Exception {
   41.75 +        Convertor c = createSKKtoCZK();
   41.76 +        // convert 16CZK using c:
   41.77 +        // assertEquals("Result is 20 SKK");
   41.78 +        assertEquals(c.convert(16, Convertor.SECOND_TO_FIRST), (double) 20);
   41.79 +
   41.80 +        // convert 500SKK to CZK
   41.81 +        // assertEquals("Result is 400 CZK");
   41.82 +        assertEquals(c.convert(500, Convertor.FIRST_TO_SECOND), (double) 400);
   41.83 +    }
   41.84 +}
   41.85 +
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/task2/solution04/build.xml	Wed Oct 01 10:43:05 2008 +0200
    42.3 @@ -0,0 +1,69 @@
    42.4 +<?xml version="1.0" encoding="UTF-8"?>
    42.5 +<!-- You may freely edit this file. See commented blocks below for -->
    42.6 +<!-- some examples of how to customize the build. -->
    42.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    42.8 +<project name="currency" default="default" basedir=".">
    42.9 +    <description>Builds, tests, and runs the project.</description>
   42.10 +    <import file="nbproject/build-impl.xml"/>
   42.11 +    <!--
   42.12 +
   42.13 +    There exist several targets which are by default empty and which can be 
   42.14 +    used for execution of your tasks. These targets are usually executed 
   42.15 +    before and after some main targets. They are: 
   42.16 +
   42.17 +      -pre-init:                 called before initialization of project properties
   42.18 +      -post-init:                called after initialization of project properties
   42.19 +      -pre-compile:              called before javac compilation
   42.20 +      -post-compile:             called after javac compilation
   42.21 +      -pre-compile-single:       called before javac compilation of single file
   42.22 +      -post-compile-single:      called after javac compilation of single file
   42.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   42.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   42.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   42.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   42.27 +      -pre-jar:                  called before JAR building
   42.28 +      -post-jar:                 called after JAR building
   42.29 +      -post-clean:               called after cleaning build products
   42.30 +
   42.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   42.32 +
   42.33 +    Example of inserting an obfuscator after compilation could look like this:
   42.34 +
   42.35 +        <target name="-post-compile">
   42.36 +            <obfuscate>
   42.37 +                <fileset dir="${build.classes.dir}"/>
   42.38 +            </obfuscate>
   42.39 +        </target>
   42.40 +
   42.41 +    For list of available properties check the imported 
   42.42 +    nbproject/build-impl.xml file. 
   42.43 +
   42.44 +
   42.45 +    Another way to customize the build is by overriding existing main targets.
   42.46 +    The targets of interest are: 
   42.47 +
   42.48 +      -init-macrodef-javac:     defines macro for javac compilation
   42.49 +      -init-macrodef-junit:     defines macro for junit execution
   42.50 +      -init-macrodef-debug:     defines macro for class debugging
   42.51 +      -init-macrodef-java:      defines macro for class execution
   42.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   42.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   42.54 +      run:                      execution of project 
   42.55 +      -javadoc-build:           Javadoc generation
   42.56 +      test-report:              JUnit report generation
   42.57 +
   42.58 +    An example of overriding the target for project execution could look like this:
   42.59 +
   42.60 +        <target name="run" depends="currency-impl.jar">
   42.61 +            <exec dir="bin" executable="launcher.exe">
   42.62 +                <arg file="${dist.jar}"/>
   42.63 +            </exec>
   42.64 +        </target>
   42.65 +
   42.66 +    Notice that the overridden target depends on the jar target and not only on 
   42.67 +    the compile target as the regular run target does. Again, for a list of available 
   42.68 +    properties which you can use, check the target you are overriding in the
   42.69 +    nbproject/build-impl.xml file. 
   42.70 +
   42.71 +    -->
   42.72 +</project>
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/task2/solution04/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    43.3 @@ -0,0 +1,642 @@
    43.4 +<?xml version="1.0" encoding="UTF-8"?>
    43.5 +<!--
    43.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    43.7 +***         EDIT ../build.xml INSTEAD         ***
    43.8 +
    43.9 +For the purpose of easier reading the script
   43.10 +is divided into following sections:
   43.11 +
   43.12 +  - initialization
   43.13 +  - compilation
   43.14 +  - jar
   43.15 +  - execution
   43.16 +  - debugging
   43.17 +  - javadoc
   43.18 +  - junit compilation
   43.19 +  - junit execution
   43.20 +  - junit debugging
   43.21 +  - applet
   43.22 +  - cleanup
   43.23 +
   43.24 +        -->
   43.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_04-impl">
   43.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   43.27 +    <!-- 
   43.28 +                ======================
   43.29 +                INITIALIZATION SECTION 
   43.30 +                ======================
   43.31 +            -->
   43.32 +    <target name="-pre-init">
   43.33 +        <!-- Empty placeholder for easier customization. -->
   43.34 +        <!-- You can override this target in the ../build.xml file. -->
   43.35 +    </target>
   43.36 +    <target depends="-pre-init" name="-init-private">
   43.37 +        <property file="nbproject/private/config.properties"/>
   43.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   43.39 +        <property file="nbproject/private/private.properties"/>
   43.40 +    </target>
   43.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   43.42 +        <property file="${user.properties.file}"/>
   43.43 +        <!-- The two properties below are usually overridden -->
   43.44 +        <!-- by the active platform. Just a fallback. -->
   43.45 +        <property name="default.javac.source" value="1.4"/>
   43.46 +        <property name="default.javac.target" value="1.4"/>
   43.47 +    </target>
   43.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   43.49 +        <property file="nbproject/configs/${config}.properties"/>
   43.50 +        <property file="nbproject/project.properties"/>
   43.51 +    </target>
   43.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   43.53 +        <available file="${manifest.file}" property="manifest.available"/>
   43.54 +        <condition property="manifest.available+main.class">
   43.55 +            <and>
   43.56 +                <isset property="manifest.available"/>
   43.57 +                <isset property="main.class"/>
   43.58 +                <not>
   43.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   43.60 +                </not>
   43.61 +            </and>
   43.62 +        </condition>
   43.63 +        <condition property="manifest.available+main.class+mkdist.available">
   43.64 +            <and>
   43.65 +                <istrue value="${manifest.available+main.class}"/>
   43.66 +                <isset property="libs.CopyLibs.classpath"/>
   43.67 +            </and>
   43.68 +        </condition>
   43.69 +        <condition property="have.tests">
   43.70 +            <or>
   43.71 +                <available file="${test.src.dir}"/>
   43.72 +            </or>
   43.73 +        </condition>
   43.74 +        <condition property="have.sources">
   43.75 +            <or>
   43.76 +                <available file="${src.dir}"/>
   43.77 +            </or>
   43.78 +        </condition>
   43.79 +        <condition property="netbeans.home+have.tests">
   43.80 +            <and>
   43.81 +                <isset property="netbeans.home"/>
   43.82 +                <isset property="have.tests"/>
   43.83 +            </and>
   43.84 +        </condition>
   43.85 +        <condition property="no.javadoc.preview">
   43.86 +            <and>
   43.87 +                <isset property="javadoc.preview"/>
   43.88 +                <isfalse value="${javadoc.preview}"/>
   43.89 +            </and>
   43.90 +        </condition>
   43.91 +        <property name="run.jvmargs" value=""/>
   43.92 +        <property name="javac.compilerargs" value=""/>
   43.93 +        <property name="work.dir" value="${basedir}"/>
   43.94 +        <condition property="no.deps">
   43.95 +            <and>
   43.96 +                <istrue value="${no.dependencies}"/>
   43.97 +            </and>
   43.98 +        </condition>
   43.99 +        <property name="javac.debug" value="true"/>
  43.100 +        <property name="javadoc.preview" value="true"/>
  43.101 +        <property name="application.args" value=""/>
  43.102 +        <property name="source.encoding" value="${file.encoding}"/>
  43.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  43.104 +            <and>
  43.105 +                <isset property="javadoc.encoding"/>
  43.106 +                <not>
  43.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  43.108 +                </not>
  43.109 +            </and>
  43.110 +        </condition>
  43.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  43.112 +        <property name="includes" value="**"/>
  43.113 +        <property name="excludes" value=""/>
  43.114 +        <property name="do.depend" value="false"/>
  43.115 +        <condition property="do.depend.true">
  43.116 +            <istrue value="${do.depend}"/>
  43.117 +        </condition>
  43.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  43.119 +            <and>
  43.120 +                <isset property="jaxws.endorsed.dir"/>
  43.121 +                <available file="nbproject/jaxws-build.xml"/>
  43.122 +            </and>
  43.123 +        </condition>
  43.124 +    </target>
  43.125 +    <target name="-post-init">
  43.126 +        <!-- Empty placeholder for easier customization. -->
  43.127 +        <!-- You can override this target in the ../build.xml file. -->
  43.128 +    </target>
  43.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  43.130 +        <fail unless="src.dir">Must set src.dir</fail>
  43.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  43.132 +        <fail unless="build.dir">Must set build.dir</fail>
  43.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  43.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  43.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  43.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  43.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  43.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  43.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  43.140 +    </target>
  43.141 +    <target name="-init-macrodef-property">
  43.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  43.143 +            <attribute name="name"/>
  43.144 +            <attribute name="value"/>
  43.145 +            <sequential>
  43.146 +                <property name="@{name}" value="${@{value}}"/>
  43.147 +            </sequential>
  43.148 +        </macrodef>
  43.149 +    </target>
  43.150 +    <target name="-init-macrodef-javac">
  43.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  43.152 +            <attribute default="${src.dir}" name="srcdir"/>
  43.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  43.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  43.155 +            <attribute default="${includes}" name="includes"/>
  43.156 +            <attribute default="${excludes}" name="excludes"/>
  43.157 +            <attribute default="${javac.debug}" name="debug"/>
  43.158 +            <attribute default="" name="sourcepath"/>
  43.159 +            <element name="customize" optional="true"/>
  43.160 +            <sequential>
  43.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}">
  43.162 +                    <classpath>
  43.163 +                        <path path="@{classpath}"/>
  43.164 +                    </classpath>
  43.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  43.166 +                    <customize/>
  43.167 +                </javac>
  43.168 +            </sequential>
  43.169 +        </macrodef>
  43.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  43.171 +            <attribute default="${src.dir}" name="srcdir"/>
  43.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  43.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  43.174 +            <sequential>
  43.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  43.176 +                    <classpath>
  43.177 +                        <path path="@{classpath}"/>
  43.178 +                    </classpath>
  43.179 +                </depend>
  43.180 +            </sequential>
  43.181 +        </macrodef>
  43.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  43.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  43.184 +            <sequential>
  43.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  43.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  43.187 +                    <path>
  43.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  43.189 +                    </path>
  43.190 +                    <globmapper from="*.java" to="*.class"/>
  43.191 +                </pathconvert>
  43.192 +                <delete>
  43.193 +                    <files includes="${javac.includes.binary}"/>
  43.194 +                </delete>
  43.195 +            </sequential>
  43.196 +        </macrodef>
  43.197 +    </target>
  43.198 +    <target name="-init-macrodef-junit">
  43.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  43.200 +            <attribute default="${includes}" name="includes"/>
  43.201 +            <attribute default="${excludes}" name="excludes"/>
  43.202 +            <attribute default="**" name="testincludes"/>
  43.203 +            <sequential>
  43.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  43.205 +                    <batchtest todir="${build.test.results.dir}">
  43.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  43.207 +                            <filename name="@{testincludes}"/>
  43.208 +                        </fileset>
  43.209 +                    </batchtest>
  43.210 +                    <classpath>
  43.211 +                        <path path="${run.test.classpath}"/>
  43.212 +                    </classpath>
  43.213 +                    <syspropertyset>
  43.214 +                        <propertyref prefix="test-sys-prop."/>
  43.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  43.216 +                    </syspropertyset>
  43.217 +                    <formatter type="brief" usefile="false"/>
  43.218 +                    <formatter type="xml"/>
  43.219 +                    <jvmarg line="${run.jvmargs}"/>
  43.220 +                </junit>
  43.221 +            </sequential>
  43.222 +        </macrodef>
  43.223 +    </target>
  43.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  43.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  43.226 +            <attribute default="${main.class}" name="name"/>
  43.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  43.228 +            <attribute default="" name="stopclassname"/>
  43.229 +            <sequential>
  43.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  43.231 +                    <classpath>
  43.232 +                        <path path="@{classpath}"/>
  43.233 +                    </classpath>
  43.234 +                </nbjpdastart>
  43.235 +            </sequential>
  43.236 +        </macrodef>
  43.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  43.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  43.239 +            <sequential>
  43.240 +                <nbjpdareload>
  43.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  43.242 +                        <include name="${fix.includes}*.class"/>
  43.243 +                    </fileset>
  43.244 +                </nbjpdareload>
  43.245 +            </sequential>
  43.246 +        </macrodef>
  43.247 +    </target>
  43.248 +    <target name="-init-debug-args">
  43.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  43.250 +        <condition property="have-jdk-older-than-1.4">
  43.251 +            <or>
  43.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  43.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  43.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  43.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  43.256 +            </or>
  43.257 +        </condition>
  43.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  43.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  43.260 +        </condition>
  43.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  43.262 +            <os family="windows"/>
  43.263 +        </condition>
  43.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  43.265 +            <isset property="debug.transport"/>
  43.266 +        </condition>
  43.267 +    </target>
  43.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  43.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  43.270 +            <attribute default="${main.class}" name="classname"/>
  43.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  43.272 +            <element name="customize" optional="true"/>
  43.273 +            <sequential>
  43.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  43.275 +                    <jvmarg line="${debug-args-line}"/>
  43.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  43.277 +                    <jvmarg line="${run.jvmargs}"/>
  43.278 +                    <classpath>
  43.279 +                        <path path="@{classpath}"/>
  43.280 +                    </classpath>
  43.281 +                    <syspropertyset>
  43.282 +                        <propertyref prefix="run-sys-prop."/>
  43.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  43.284 +                    </syspropertyset>
  43.285 +                    <customize/>
  43.286 +                </java>
  43.287 +            </sequential>
  43.288 +        </macrodef>
  43.289 +    </target>
  43.290 +    <target name="-init-macrodef-java">
  43.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  43.292 +            <attribute default="${main.class}" name="classname"/>
  43.293 +            <element name="customize" optional="true"/>
  43.294 +            <sequential>
  43.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  43.296 +                    <jvmarg line="${run.jvmargs}"/>
  43.297 +                    <classpath>
  43.298 +                        <path path="${run.classpath}"/>
  43.299 +                    </classpath>
  43.300 +                    <syspropertyset>
  43.301 +                        <propertyref prefix="run-sys-prop."/>
  43.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  43.303 +                    </syspropertyset>
  43.304 +                    <customize/>
  43.305 +                </java>
  43.306 +            </sequential>
  43.307 +        </macrodef>
  43.308 +    </target>
  43.309 +    <target name="-init-presetdef-jar">
  43.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  43.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  43.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  43.313 +            </jar>
  43.314 +        </presetdef>
  43.315 +    </target>
  43.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"/>
  43.317 +    <!--
  43.318 +                ===================
  43.319 +                COMPILATION SECTION
  43.320 +                ===================
  43.321 +            -->
  43.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  43.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  43.324 +    <target depends="init" name="-check-automatic-build">
  43.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  43.326 +    </target>
  43.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  43.328 +        <antcall target="clean"/>
  43.329 +    </target>
  43.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  43.331 +        <mkdir dir="${build.classes.dir}"/>
  43.332 +    </target>
  43.333 +    <target name="-pre-compile">
  43.334 +        <!-- Empty placeholder for easier customization. -->
  43.335 +        <!-- You can override this target in the ../build.xml file. -->
  43.336 +    </target>
  43.337 +    <target if="do.depend.true" name="-compile-depend">
  43.338 +        <j2seproject3:depend/>
  43.339 +    </target>
  43.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  43.341 +        <j2seproject3:javac/>
  43.342 +        <copy todir="${build.classes.dir}">
  43.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  43.344 +        </copy>
  43.345 +    </target>
  43.346 +    <target name="-post-compile">
  43.347 +        <!-- Empty placeholder for easier customization. -->
  43.348 +        <!-- You can override this target in the ../build.xml file. -->
  43.349 +    </target>
  43.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  43.351 +    <target name="-pre-compile-single">
  43.352 +        <!-- Empty placeholder for easier customization. -->
  43.353 +        <!-- You can override this target in the ../build.xml file. -->
  43.354 +    </target>
  43.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  43.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  43.357 +        <j2seproject3:force-recompile/>
  43.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  43.359 +    </target>
  43.360 +    <target name="-post-compile-single">
  43.361 +        <!-- Empty placeholder for easier customization. -->
  43.362 +        <!-- You can override this target in the ../build.xml file. -->
  43.363 +    </target>
  43.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  43.365 +    <!--
  43.366 +                ====================
  43.367 +                JAR BUILDING SECTION
  43.368 +                ====================
  43.369 +            -->
  43.370 +    <target depends="init" name="-pre-pre-jar">
  43.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  43.372 +        <mkdir dir="${dist.jar.dir}"/>
  43.373 +    </target>
  43.374 +    <target name="-pre-jar">
  43.375 +        <!-- Empty placeholder for easier customization. -->
  43.376 +        <!-- You can override this target in the ../build.xml file. -->
  43.377 +    </target>
  43.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  43.379 +        <j2seproject1:jar/>
  43.380 +    </target>
  43.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  43.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  43.383 +    </target>
  43.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">
  43.385 +        <j2seproject1:jar manifest="${manifest.file}">
  43.386 +            <j2seproject1:manifest>
  43.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  43.388 +            </j2seproject1:manifest>
  43.389 +        </j2seproject1:jar>
  43.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  43.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  43.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  43.393 +        <pathconvert property="run.classpath.with.dist.jar">
  43.394 +            <path path="${run.classpath}"/>
  43.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  43.396 +        </pathconvert>
  43.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  43.398 +    </target>
  43.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  43.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  43.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  43.402 +            <path path="${run.classpath}"/>
  43.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  43.404 +        </pathconvert>
  43.405 +        <pathconvert pathsep=" " property="jar.classpath">
  43.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  43.407 +            <chainedmapper>
  43.408 +                <flattenmapper/>
  43.409 +                <globmapper from="*" to="lib/*"/>
  43.410 +            </chainedmapper>
  43.411 +        </pathconvert>
  43.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  43.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  43.414 +            <fileset dir="${build.classes.dir}"/>
  43.415 +            <manifest>
  43.416 +                <attribute name="Main-Class" value="${main.class}"/>
  43.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  43.418 +            </manifest>
  43.419 +        </copylibs>
  43.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  43.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  43.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  43.423 +    </target>
  43.424 +    <target name="-post-jar">
  43.425 +        <!-- Empty placeholder for easier customization. -->
  43.426 +        <!-- You can override this target in the ../build.xml file. -->
  43.427 +    </target>
  43.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"/>
  43.429 +    <!--
  43.430 +                =================
  43.431 +                EXECUTION SECTION
  43.432 +                =================
  43.433 +            -->
  43.434 +    <target depends="init,compile" description="Run a main class." name="run">
  43.435 +        <j2seproject1:java>
  43.436 +            <customize>
  43.437 +                <arg line="${application.args}"/>
  43.438 +            </customize>
  43.439 +        </j2seproject1:java>
  43.440 +    </target>
  43.441 +    <target name="-do-not-recompile">
  43.442 +        <property name="javac.includes.binary" value=""/>
  43.443 +    </target>
  43.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  43.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  43.446 +        <j2seproject1:java classname="${run.class}"/>
  43.447 +    </target>
  43.448 +    <!--
  43.449 +                =================
  43.450 +                DEBUGGING SECTION
  43.451 +                =================
  43.452 +            -->
  43.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  43.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  43.455 +    </target>
  43.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  43.457 +        <j2seproject3:debug>
  43.458 +            <customize>
  43.459 +                <arg line="${application.args}"/>
  43.460 +            </customize>
  43.461 +        </j2seproject3:debug>
  43.462 +    </target>
  43.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  43.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  43.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  43.466 +    </target>
  43.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  43.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  43.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  43.470 +        <j2seproject3:debug classname="${debug.class}"/>
  43.471 +    </target>
  43.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  43.473 +    <target depends="init" name="-pre-debug-fix">
  43.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  43.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  43.476 +    </target>
  43.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  43.478 +        <j2seproject1:nbjpdareload/>
  43.479 +    </target>
  43.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  43.481 +    <!--
  43.482 +                ===============
  43.483 +                JAVADOC SECTION
  43.484 +                ===============
  43.485 +            -->
  43.486 +    <target depends="init" name="-javadoc-build">
  43.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  43.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}">
  43.489 +            <classpath>
  43.490 +                <path path="${javac.classpath}"/>
  43.491 +            </classpath>
  43.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  43.493 +                <filename name="**/*.java"/>
  43.494 +            </fileset>
  43.495 +        </javadoc>
  43.496 +    </target>
  43.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  43.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  43.499 +    </target>
  43.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  43.501 +    <!--
  43.502 +                =========================
  43.503 +                JUNIT COMPILATION SECTION
  43.504 +                =========================
  43.505 +            -->
  43.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  43.507 +        <mkdir dir="${build.test.classes.dir}"/>
  43.508 +    </target>
  43.509 +    <target name="-pre-compile-test">
  43.510 +        <!-- Empty placeholder for easier customization. -->
  43.511 +        <!-- You can override this target in the ../build.xml file. -->
  43.512 +    </target>
  43.513 +    <target if="do.depend.true" name="-compile-test-depend">
  43.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  43.515 +    </target>
  43.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  43.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  43.518 +        <copy todir="${build.test.classes.dir}">
  43.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  43.520 +        </copy>
  43.521 +    </target>
  43.522 +    <target name="-post-compile-test">
  43.523 +        <!-- Empty placeholder for easier customization. -->
  43.524 +        <!-- You can override this target in the ../build.xml file. -->
  43.525 +    </target>
  43.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  43.527 +    <target name="-pre-compile-test-single">
  43.528 +        <!-- Empty placeholder for easier customization. -->
  43.529 +        <!-- You can override this target in the ../build.xml file. -->
  43.530 +    </target>
  43.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  43.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  43.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  43.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}"/>
  43.535 +        <copy todir="${build.test.classes.dir}">
  43.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  43.537 +        </copy>
  43.538 +    </target>
  43.539 +    <target name="-post-compile-test-single">
  43.540 +        <!-- Empty placeholder for easier customization. -->
  43.541 +        <!-- You can override this target in the ../build.xml file. -->
  43.542 +    </target>
  43.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"/>
  43.544 +    <!--
  43.545 +                =======================
  43.546 +                JUNIT EXECUTION SECTION
  43.547 +                =======================
  43.548 +            -->
  43.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  43.550 +        <mkdir dir="${build.test.results.dir}"/>
  43.551 +    </target>
  43.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  43.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  43.554 +    </target>
  43.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  43.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  43.557 +    </target>
  43.558 +    <target depends="init" if="have.tests" name="test-report"/>
  43.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  43.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"/>
  43.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  43.562 +        <mkdir dir="${build.test.results.dir}"/>
  43.563 +    </target>
  43.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  43.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  43.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  43.567 +    </target>
  43.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  43.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  43.570 +    </target>
  43.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"/>
  43.572 +    <!--
  43.573 +                =======================
  43.574 +                JUNIT DEBUGGING SECTION
  43.575 +                =======================
  43.576 +            -->
  43.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  43.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  43.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  43.580 +        <delete file="${test.report.file}"/>
  43.581 +        <mkdir dir="${build.test.results.dir}"/>
  43.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}">
  43.583 +            <customize>
  43.584 +                <syspropertyset>
  43.585 +                    <propertyref prefix="test-sys-prop."/>
  43.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  43.587 +                </syspropertyset>
  43.588 +                <arg value="${test.class}"/>
  43.589 +                <arg value="showoutput=true"/>
  43.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  43.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  43.592 +            </customize>
  43.593 +        </j2seproject3:debug>
  43.594 +    </target>
  43.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  43.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  43.597 +    </target>
  43.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  43.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  43.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  43.601 +    </target>
  43.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  43.603 +    <!--
  43.604 +                =========================
  43.605 +                APPLET EXECUTION SECTION
  43.606 +                =========================
  43.607 +            -->
  43.608 +    <target depends="init,compile-single" name="run-applet">
  43.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  43.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  43.611 +            <customize>
  43.612 +                <arg value="${applet.url}"/>
  43.613 +            </customize>
  43.614 +        </j2seproject1:java>
  43.615 +    </target>
  43.616 +    <!--
  43.617 +                =========================
  43.618 +                APPLET DEBUGGING  SECTION
  43.619 +                =========================
  43.620 +            -->
  43.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  43.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  43.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  43.624 +            <customize>
  43.625 +                <arg value="${applet.url}"/>
  43.626 +            </customize>
  43.627 +        </j2seproject3:debug>
  43.628 +    </target>
  43.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  43.630 +    <!--
  43.631 +                ===============
  43.632 +                CLEANUP SECTION
  43.633 +                ===============
  43.634 +            -->
  43.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  43.636 +    <target depends="init" name="-do-clean">
  43.637 +        <delete dir="${build.dir}"/>
  43.638 +        <delete dir="${dist.dir}"/>
  43.639 +    </target>
  43.640 +    <target name="-post-clean">
  43.641 +        <!-- Empty placeholder for easier customization. -->
  43.642 +        <!-- You can override this target in the ../build.xml file. -->
  43.643 +    </target>
  43.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  43.645 +</project>
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/task2/solution04/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    44.3 @@ -0,0 +1,8 @@
    44.4 +build.xml.data.CRC32=2ab820eb
    44.5 +build.xml.script.CRC32=58a52595
    44.6 +build.xml.stylesheet.CRC32=be360661
    44.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    44.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    44.9 +nbproject/build-impl.xml.data.CRC32=2fbfa6ce
   44.10 +nbproject/build-impl.xml.script.CRC32=c521eea7
   44.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/task2/solution04/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    45.3 @@ -0,0 +1,68 @@
    45.4 +application.title=currency
    45.5 +application.vendor=apidesign.org
    45.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    45.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    45.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    45.9 +build.classes.dir=${build.dir}/classes
   45.10 +build.classes.excludes=**/*.java,**/*.form
   45.11 +# This directory is removed when the project is cleaned:
   45.12 +build.dir=build
   45.13 +build.generated.dir=${build.dir}/generated
   45.14 +# Only compile against the classpath explicitly listed here:
   45.15 +build.sysclasspath=ignore
   45.16 +build.test.classes.dir=${build.dir}/test/classes
   45.17 +build.test.results.dir=${build.dir}/test/results
   45.18 +debug.classpath=\
   45.19 +    ${run.classpath}
   45.20 +debug.test.classpath=\
   45.21 +    ${run.test.classpath}
   45.22 +# This directory is removed when the project is cleaned:
   45.23 +dist.dir=dist
   45.24 +dist.jar=${dist.dir}/currency.jar
   45.25 +dist.javadoc.dir=${dist.dir}/javadoc
   45.26 +excludes=
   45.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   45.28 +file.reference.src-apifest08=..
   45.29 +includes=**
   45.30 +jar.compress=false
   45.31 +javac.classpath=
   45.32 +# Space-separated list of extra javac options
   45.33 +javac.compilerargs=
   45.34 +javac.deprecation=false
   45.35 +javac.source=1.5
   45.36 +javac.target=1.5
   45.37 +javac.test.classpath=\
   45.38 +    ${javac.classpath}:\
   45.39 +    ${build.classes.dir}:\
   45.40 +    ${file.reference.junit-4.4.jar}
   45.41 +javadoc.additionalparam=
   45.42 +javadoc.author=false
   45.43 +javadoc.encoding=
   45.44 +javadoc.noindex=false
   45.45 +javadoc.nonavbar=false
   45.46 +javadoc.notree=false
   45.47 +javadoc.private=false
   45.48 +javadoc.splitindex=true
   45.49 +javadoc.use=true
   45.50 +javadoc.version=false
   45.51 +javadoc.windowtitle=
   45.52 +jnlp.codebase.type=local
   45.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   45.54 +jnlp.descriptor=application
   45.55 +jnlp.enabled=false
   45.56 +jnlp.offline-allowed=false
   45.57 +jnlp.signed=false
   45.58 +meta.inf.dir=${src.dir}/META-INF
   45.59 +platform.active=default_platform
   45.60 +run.classpath=\
   45.61 +    ${javac.classpath}:\
   45.62 +    ${build.classes.dir}
   45.63 +# Space-separated list of JVM arguments used when running the project
   45.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   45.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   45.66 +run.jvmargs=
   45.67 +run.test.classpath=\
   45.68 +    ${javac.test.classpath}:\
   45.69 +    ${build.test.classes.dir}
   45.70 +src.dir=src
   45.71 +test.src.dir=test
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/task2/solution04/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    46.3 @@ -0,0 +1,16 @@
    46.4 +<?xml version="1.0" encoding="UTF-8"?>
    46.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    46.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    46.7 +    <configuration>
    46.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    46.9 +            <name>Currency Convertor Solution 04</name>
   46.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   46.11 +            <source-roots>
   46.12 +                <root id="src.dir"/>
   46.13 +            </source-roots>
   46.14 +            <test-roots>
   46.15 +                <root id="test.src.dir"/>
   46.16 +            </test-roots>
   46.17 +        </data>
   46.18 +    </configuration>
   46.19 +</project>
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/task2/solution04/src/org/apidesign/apifest08/currency/ConverterImpl.java	Wed Oct 01 10:43:05 2008 +0200
    47.3 @@ -0,0 +1,159 @@
    47.4 +package org.apidesign.apifest08.currency;
    47.5 +
    47.6 +
    47.7 +import java.math.BigDecimal;
    47.8 +import java.math.MathContext;
    47.9 +import java.math.RoundingMode;
   47.10 +import java.util.Currency;
   47.11 +
   47.12 +
   47.13 +/**
   47.14 + * Convert between two currencies.
   47.15 + *
   47.16 + * @author D'Arcy Smith
   47.17 + * @version 1.0
   47.18 + */
   47.19 +final class ConvertorImpl
   47.20 +    implements Convertor
   47.21 +{
   47.22 +    /**
   47.23 +     * The currency to cvonvert from.
   47.24 +     */
   47.25 +    private final Currency currencyA;
   47.26 +
   47.27 +    /**
   47.28 +     * The currency to cvonvert from.
   47.29 +     */
   47.30 +    private final Currency currencyB;
   47.31 +
   47.32 +    /**
   47.33 +     * The echange rate between a and b.
   47.34 +     */
   47.35 +    private final BigDecimal currencyARate;
   47.36 +
   47.37 +    /**
   47.38 +     * The echange rate between b and a.
   47.39 +     */
   47.40 +    private final BigDecimal currencyBRate;
   47.41 +    
   47.42 +    /**
   47.43 +     * Constructs a convertor with the specified currencies.
   47.44 +     * 
   47.45 +     * @param a the currency to convert from.
   47.46 +     * @param aRate the exchage rage between from and to.
   47.47 +     * @param b the currency to convert to.
   47.48 +     * @param bRate the exchage rage between to and from.
   47.49 +     * @throws IllegalArgumentException if either any of the arguments are null or if either rate <= 0.
   47.50 +     */
   47.51 +    public ConvertorImpl(final Currency   a,
   47.52 +                         final BigDecimal aRate,
   47.53 +                         final Currency   b,
   47.54 +                         final BigDecimal bRate)
   47.55 +    {
   47.56 +        if(a == null)
   47.57 +        {
   47.58 +            throw new IllegalArgumentException("a cannot be null");
   47.59 +        }
   47.60 +
   47.61 +        if(b == null)
   47.62 +        {
   47.63 +            throw new IllegalArgumentException("b cannot be null");
   47.64 +        }
   47.65 +
   47.66 +        if(aRate == null)
   47.67 +        {
   47.68 +            throw new IllegalArgumentException("aRate cannot be null");
   47.69 +        }
   47.70 +
   47.71 +        if(bRate == null)
   47.72 +        {
   47.73 +            throw new IllegalArgumentException("bRate cannot be null");
   47.74 +        }
   47.75 +                
   47.76 +        if(aRate.compareTo(BigDecimal.ZERO) <= 0)
   47.77 +        {
   47.78 +            throw new IllegalArgumentException("aRate must be > 0, was: " + aRate);
   47.79 +        }
   47.80 +                
   47.81 +        if(bRate.compareTo(BigDecimal.ZERO) <= 0)
   47.82 +        {
   47.83 +            throw new IllegalArgumentException("bRate must be > 0, was: " + bRate);
   47.84 +        }
   47.85 +        
   47.86 +        currencyA     = a;
   47.87 +        currencyB     = b;
   47.88 +        currencyARate = aRate;
   47.89 +        currencyBRate = bRate;
   47.90 +    }
   47.91 +    
   47.92 +    /**
   47.93 +     * Convert an amount from one currency to another.
   47.94 +     * 
   47.95 +     * @param from the currency to convert from.
   47.96 +     * @param to the currency to convert to.
   47.97 +     * @param amount the amount to convert.
   47.98 +     * @return the converted amount.
   47.99 +     * @throws IllegalArgumentException if any of the arguments are null.
  47.100 +     * @throws InvalidConversionException if either from or to are not equal to the currencies passed to the constructor.
  47.101 +     */
  47.102 +    public BigDecimal convert(final Currency   from,
  47.103 +                              final Currency   to,
  47.104 +                              final BigDecimal amount)
  47.105 +        throws InvalidConversionException
  47.106 +    {
  47.107 +        final BigDecimal result;
  47.108 +        
  47.109 +        if(amount == null)
  47.110 +        {
  47.111 +            throw new IllegalArgumentException("amount cannot be null");
  47.112 +        }
  47.113 +        
  47.114 +        if(from == null)
  47.115 +        {
  47.116 +            throw new IllegalArgumentException("from cannot be null");
  47.117 +        }
  47.118 +        
  47.119 +        if(to == null)
  47.120 +        {
  47.121 +            throw new IllegalArgumentException("to cannot be null");
  47.122 +        }
  47.123 +        
  47.124 +        if(!(from.equals(currencyA)) && (!(from.equals(currencyB))))
  47.125 +        {
  47.126 +            throw new InvalidConversionException("cannot convert from: " + from.getCurrencyCode(), from, currencyA, currencyB);
  47.127 +        }
  47.128 +        
  47.129 +        if(!(to.equals(currencyA)) && (!(to.equals(currencyB))))
  47.130 +        {
  47.131 +            throw new InvalidConversionException("cannot convert to: " + to.getCurrencyCode(), to, currencyA, currencyB);
  47.132 +        }
  47.133 +
  47.134 +        // converting between the same currency is no converstion at all.
  47.135 +        if(from.equals(to))
  47.136 +        {
  47.137 +            result = amount;
  47.138 +        }
  47.139 +        else
  47.140 +        {
  47.141 +            final BigDecimal rateX;
  47.142 +            final BigDecimal rateY;
  47.143 +            final BigDecimal temp;
  47.144 +            
  47.145 +            if(from.equals(currencyA))
  47.146 +            {
  47.147 +                rateX = currencyARate;
  47.148 +                rateY = currencyBRate;
  47.149 +            }
  47.150 +            else
  47.151 +            {
  47.152 +                rateX = currencyBRate;
  47.153 +                rateY = currencyARate;
  47.154 +            }
  47.155 +
  47.156 +            temp   = amount.divide(rateX, MathContext.DECIMAL32);
  47.157 +            result = temp.multiply(rateY);
  47.158 +        }
  47.159 +
  47.160 +        return (result.setScale(2, RoundingMode.HALF_DOWN));
  47.161 +    }
  47.162 +}
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/task2/solution04/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    48.3 @@ -0,0 +1,30 @@
    48.4 +package org.apidesign.apifest08.currency;
    48.5 +
    48.6 +
    48.7 +import java.math.BigDecimal;
    48.8 +import java.util.Currency;
    48.9 +
   48.10 +
   48.11 +/**
   48.12 + * Convert between two currencies.
   48.13 + *
   48.14 + * @author D'Arcy Smith
   48.15 + * @version 1.0
   48.16 + */
   48.17 +public interface Convertor
   48.18 +{
   48.19 +    /**
   48.20 +     * Convert an amount from one currency to another.
   48.21 +     * 
   48.22 +     * @param from the currency to convert from.
   48.23 +     * @param to the currency to convert to.
   48.24 +     * @param amount the amount to convert.
   48.25 +     * @return the converted amount.
   48.26 +     * @throws IllegalArgumentException if any of the arguments are null.
   48.27 +     * @throws InvalidConversionException if either from or to are not valid for the convertor.
   48.28 +     */
   48.29 +    BigDecimal convert(Currency   from, 
   48.30 +                       Currency   to, 
   48.31 +                       BigDecimal amount)
   48.32 +        throws InvalidConversionException;
   48.33 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/task2/solution04/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
    49.3 @@ -0,0 +1,116 @@
    49.4 +package org.apidesign.apifest08.currency;
    49.5 +
    49.6 +import java.lang.ref.WeakReference;
    49.7 +import java.math.BigDecimal;
    49.8 +import java.util.Currency;
    49.9 +import java.util.Map;
   49.10 +import java.util.WeakHashMap;
   49.11 +
   49.12 +
   49.13 +/**
   49.14 + * Create convertors using a flyweight to reduce the number of repetative creations of the same convertor.
   49.15 + * 
   49.16 + * @author D'Arcy Smith
   49.17 + * @version 1.0
   49.18 + */
   49.19 +public final class ConvertorFactory
   49.20 +{
   49.21 +    /**
   49.22 +     * flyweight so that only one vestion of each converter is created at a time.
   49.23 +     */
   49.24 +    private final static Map<String, WeakReference<Convertor>> convertors;
   49.25 +    
   49.26 +    static
   49.27 +    {
   49.28 +        convertors = new WeakHashMap<String, WeakReference<Convertor>>();
   49.29 +    }
   49.30 +    
   49.31 +    /** 
   49.32 +     * Prevent accidental construction.
   49.33 +     */
   49.34 +    private ConvertorFactory()
   49.35 +    {        
   49.36 +    }
   49.37 +    
   49.38 +    /**
   49.39 +     * Get the convertor for the specified currencies.  The currency name format
   49.40 +     * must be acceptable to java.util.Currency.getInstance(String)
   49.41 +     * 
   49.42 +     * @param a the currency to convert from.
   49.43 +     * @param aRate the exchange rate for a to b.
   49.44 +     * @param b the currency to convert to.
   49.45 +     * @param bRate the echante rate for b to a.
   49.46 +     * @return the convertor for the specified currencies.
   49.47 +     * @throws IllegalArgumentException if any of the arguments are null.
   49.48 +     */
   49.49 +    public static Convertor getConvertor(final String     a,
   49.50 +                                         final BigDecimal aRate,
   49.51 +                                         final String     b,
   49.52 +                                         final BigDecimal bRate)
   49.53 +    {
   49.54 +        final Currency  currencyA;
   49.55 +        final Currency  currencyB;
   49.56 +        final Convertor convertor;
   49.57 +        
   49.58 +        currencyA = Currency.getInstance(a);
   49.59 +        currencyB = Currency.getInstance(b);        
   49.60 +        convertor = getConvertor(currencyA, aRate, currencyB, bRate);
   49.61 +        
   49.62 +        return (convertor);
   49.63 +    }
   49.64 +    
   49.65 +    /**
   49.66 +     * Get the convertor for the specified currencies.
   49.67 +     * 
   49.68 +     * @param a the currency to convert from.
   49.69 +     * @param aRate the exchange rate for a to b.
   49.70 +     * @param b the currency to convert to.
   49.71 +     * @param bRate the echante rate for b to a.
   49.72 +     * @return the convertor for the specified currencies.
   49.73 +     * @throws IllegalArgumentException if either any of the arguments are null or if either rate <= 0.
   49.74 +     */
   49.75 +    public static Convertor getConvertor(final Currency   a,
   49.76 +                                         final BigDecimal aRate,
   49.77 +                                         final Currency   b,
   49.78 +                                         final BigDecimal bRate)
   49.79 +    {
   49.80 +        final String key;        
   49.81 +        Convertor    convertor;
   49.82 +
   49.83 +        if(a == null)
   49.84 +        {
   49.85 +            throw new IllegalArgumentException("a cannot be null");
   49.86 +        }
   49.87 +
   49.88 +        if(b == null)
   49.89 +        {
   49.90 +            throw new IllegalArgumentException("b cannot be null");
   49.91 +        }
   49.92 +        
   49.93 +        if(aRate == null)
   49.94 +        {
   49.95 +            throw new IllegalArgumentException("aRate cannot be null");
   49.96 +        }
   49.97 +        
   49.98 +        if(bRate == null)
   49.99 +        {
  49.100 +            throw new IllegalArgumentException("bRate cannot be null");
  49.101 +        }
  49.102 +
  49.103 +        key = a.getCurrencyCode() + aRate + b.getCurrencyCode() + bRate;
  49.104 +
  49.105 +        // make sure that we don't try to overwrite one
  49.106 +        synchronized(convertors)
  49.107 +        {
  49.108 +            if(!(convertors.containsKey(key)))
  49.109 +            {        
  49.110 +                convertor = new ConvertorImpl(a, aRate, b, bRate);
  49.111 +                convertors.put(key, new WeakReference(convertor));
  49.112 +            }
  49.113 +        }
  49.114 +
  49.115 +        convertor = convertors.get(key).get();
  49.116 +        
  49.117 +        return (convertor);
  49.118 +    }
  49.119 +}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/task2/solution04/src/org/apidesign/apifest08/currency/InvalidConversionException.java	Wed Oct 01 10:43:05 2008 +0200
    50.3 @@ -0,0 +1,82 @@
    50.4 +package org.apidesign.apifest08.currency;
    50.5 +
    50.6 +      
    50.7 +import java.util.Currency;
    50.8 +
    50.9 +
   50.10 +/**
   50.11 + * Thrown when a currency is invalid for a given Convertor.
   50.12 + * 
   50.13 + * @author D'Arcy Smith
   50.14 + * @version 1.0
   50.15 + */
   50.16 +public class InvalidConversionException
   50.17 +    extends Exception
   50.18 +{
   50.19 +    /**
   50.20 +     * The currency that was tried.
   50.21 +     */
   50.22 +    private final Currency badCurrency;
   50.23 +    
   50.24 +    /**
   50.25 +     * A currency that is valid for the Convertor.
   50.26 +     */
   50.27 +    private final Currency currencyA;
   50.28 +
   50.29 +    /**
   50.30 +     * A currency that is valid for the Convertor.
   50.31 +     */
   50.32 +    private final Currency currencyB;
   50.33 +    
   50.34 +    /**
   50.35 +     * Construct a new InvalidConversionException wit the specified message.
   50.36 +     * 
   50.37 +     * @param msg the message for getMessage.
   50.38 +     * @param bad the currency that is not valid.
   50.39 +     * @param a a valid currency.
   50.40 +     * @param b a valid currency.
   50.41 +     */
   50.42 +    public InvalidConversionException(final String    msg,
   50.43 +                                       final Currency bad,
   50.44 +                                       final Currency a,
   50.45 +                                       final Currency b)
   50.46 +    {
   50.47 +        super(msg);
   50.48 +
   50.49 +        badCurrency = bad;
   50.50 +        currencyA   = a;
   50.51 +        currencyB   = b;
   50.52 +    }
   50.53 +
   50.54 +    /**
   50.55 +     * Get the currency that is not valid.
   50.56 +     * 
   50.57 +     * @return the badCurrency
   50.58 +     */
   50.59 +    public Currency getBadCurrency()
   50.60 +    {
   50.61 +        return (badCurrency);
   50.62 +    }
   50.63 +
   50.64 +    /**
   50.65 +     * Get a currency that is valid.
   50.66 +     * 
   50.67 +     * @return the currencyA passed to the constructor.
   50.68 +     */
   50.69 +    public Currency getCurrencyA()
   50.70 +    {
   50.71 +        return (currencyA);
   50.72 +    }
   50.73 +
   50.74 +    /**
   50.75 +     * Get a currency that is valid.
   50.76 +     * 
   50.77 +     * @return the currencyB passed to the constructor.
   50.78 +     */
   50.79 +    public Currency getCurrencyB()
   50.80 +    {
   50.81 +        return (currencyB);
   50.82 +    }
   50.83 +
   50.84 +
   50.85 +}
   50.86 \ No newline at end of file
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/task2/solution04/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    51.3 @@ -0,0 +1,184 @@
    51.4 +package org.apidesign.apifest08.test;
    51.5 +
    51.6 +
    51.7 +import java.math.BigDecimal;
    51.8 +import java.util.Currency;
    51.9 +import junit.framework.TestCase;
   51.10 +import org.apidesign.apifest08.currency.Convertor;
   51.11 +import org.apidesign.apifest08.currency.ConvertorFactory;
   51.12 +import org.apidesign.apifest08.currency.InvalidConversionException;
   51.13 +
   51.14 +
   51.15 +/** Finish the Convertor API, and then write bodies of methods inside
   51.16 + * of this class to match the given tasks. To fullfil your task, use the
   51.17 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   51.18 + * Do not you reflection, or other hacks as your code
   51.19 + * shall run without any runtime permissions.
   51.20 + */
   51.21 +public class Task1Test extends TestCase {
   51.22 +    
   51.23 +    private final static Currency CZK;
   51.24 +    private final static Currency SKK;
   51.25 +    private final static Currency USD;
   51.26 +
   51.27 +    static
   51.28 +    {
   51.29 +        CZK = Currency.getInstance("CZK");
   51.30 +        SKK = Currency.getInstance("SKK");
   51.31 +        USD = Currency.getInstance("USD");
   51.32 +    }
   51.33 +    
   51.34 +    public Task1Test(String testName) {
   51.35 +        super(testName);
   51.36 +    }
   51.37 +
   51.38 +    @Override
   51.39 +    protected void setUp() throws Exception {
   51.40 +    }
   51.41 +
   51.42 +    @Override
   51.43 +    protected void tearDown() throws Exception {
   51.44 +    }
   51.45 +
   51.46 +    /** Create convertor that understands two currencies, CZK and
   51.47 +     *  USD. Make 1 USD == 17 CZK.
   51.48 +     *
   51.49 +     * Creation of the convertor shall not require subclassing of any class
   51.50 +     * or interface on the client side.
   51.51 +     *
   51.52 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   51.53 +     */
   51.54 +    public static Convertor createCZKtoUSD()
   51.55 +    {
   51.56 +        return (ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1)));
   51.57 +    }
   51.58 +
   51.59 +    /** Create convertor that understands two currencies, CZK and
   51.60 +     *  SKK. Make 100 SKK == 80 CZK.
   51.61 +     *
   51.62 +     * Creation of the convertor shall not require subclassing of any class
   51.63 +     * or interface on the client side.
   51.64 +     * 
   51.65 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   51.66 +     */
   51.67 +    public static Convertor createSKKtoCZK()
   51.68 +    {
   51.69 +        return (ConvertorFactory.getConvertor(Currency.getInstance("SKK"), BigDecimal.valueOf(100), Currency.getInstance("CZK"), BigDecimal.valueOf(80)));
   51.70 +    }
   51.71 +    
   51.72 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   51.73 +     * with it.
   51.74 +     */
   51.75 +    public void testCurrencyCZKUSD() throws Exception {
   51.76 +        Convertor  c = createCZKtoUSD();
   51.77 +        BigDecimal result;
   51.78 +        
   51.79 +        // convert $5 to CZK using c:
   51.80 +        // assertEquals("Result is 85 CZK");
   51.81 +        result = c.convert(USD, CZK, BigDecimal.valueOf(5));
   51.82 +        assertEquals(new BigDecimal("85.00"), result);
   51.83 +
   51.84 +        // convert $8 to CZK
   51.85 +        // assertEquals("Result is 136 CZK");
   51.86 +        result = c.convert(USD, CZK, BigDecimal.valueOf(8));
   51.87 +        assertEquals(new BigDecimal("136.00"), result);
   51.88 +
   51.89 +        // convert 1003CZK to USD
   51.90 +        // assertEquals("Result is 59 USD");
   51.91 +        result = c.convert(CZK, USD, BigDecimal.valueOf(1003));
   51.92 +        assertEquals(new BigDecimal("59.00"), result);
   51.93 +    }
   51.94 +
   51.95 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   51.96 +     * with it.
   51.97 +     */
   51.98 +    public void testCurrencySKKCZK() throws Exception {
   51.99 +        Convertor c = createSKKtoCZK();
  51.100 +        BigDecimal result;
  51.101 +        
  51.102 +        // convert 16CZK using c:
  51.103 +        // assertEquals("Result is 20 SKK");
  51.104 +        result = c.convert(CZK, SKK, BigDecimal.valueOf(16));
  51.105 +        assertEquals(new BigDecimal("20.00"), result);
  51.106 +                        
  51.107 +        // convert 500SKK to CZK
  51.108 +        // assertEquals("Result is 400 CZK");
  51.109 +        result = c.convert(SKK, CZK, BigDecimal.valueOf(500));
  51.110 +        assertEquals(new BigDecimal("400.00"), result);
  51.111 +   }
  51.112 +
  51.113 +    /** 
  51.114 +     * Verify that the CZK to USD convertor knows nothing about SKK.
  51.115 +     */
  51.116 +    public void testCannotConvertToSKKwithCZKUSDConvertor() 
  51.117 +        throws Exception 
  51.118 +    {
  51.119 +        Convertor c = createCZKtoUSD();
  51.120 +        
  51.121 +        try
  51.122 +        {
  51.123 +            // convert $5 to SKK, the API shall say this is not possible
  51.124 +            c.convert(USD, SKK, BigDecimal.valueOf(5));
  51.125 +            fail("cannot use the CZKtoUSD converter to convert to SKK");
  51.126 +        }
  51.127 +        catch(InvalidConversionException ex)
  51.128 +        {       
  51.129 +            assertEquals("cannot convert to: SKK", ex.getMessage());
  51.130 +            assertEquals(SKK, ex.getBadCurrency());
  51.131 +            assertEquals(CZK, ex.getCurrencyA());
  51.132 +            assertEquals(USD, ex.getCurrencyB());
  51.133 +        }
  51.134 +
  51.135 +        try
  51.136 +        {
  51.137 +            // convert 500 SKK to CZK, the API shall say this is not possible
  51.138 +            c.convert(SKK, CZK, BigDecimal.valueOf(5));
  51.139 +            fail("cannot use the CZKtoUSD converter to convert from SKK");
  51.140 +        }
  51.141 +        catch(InvalidConversionException ex)
  51.142 +        {            
  51.143 +            assertEquals("cannot convert from: SKK", ex.getMessage());
  51.144 +            assertEquals(SKK, ex.getBadCurrency());
  51.145 +            assertEquals(CZK, ex.getCurrencyA());
  51.146 +            assertEquals(USD, ex.getCurrencyB());
  51.147 +        }
  51.148 +    }
  51.149 +    
  51.150 +    /** 
  51.151 +     * Verify that the CZK to SKK convertor knows nothing about USD.
  51.152 +     */
  51.153 +    public void testCannotConvertToUSDwithSKKCZKConvertor() 
  51.154 +        throws Exception 
  51.155 +    {
  51.156 +        Convertor c = createSKKtoCZK();
  51.157 +        
  51.158 +        try
  51.159 +        {
  51.160 +            // convert $5 to SKK, the API shall say this is not possible
  51.161 +            c.convert(USD, SKK, BigDecimal.valueOf(5));
  51.162 +            fail("cannot use the CZKtoUSD converter to convert to SKK");
  51.163 +        }
  51.164 +        catch(InvalidConversionException ex)
  51.165 +        {       
  51.166 +            assertEquals("cannot convert from: USD", ex.getMessage());
  51.167 +            assertEquals(USD, ex.getBadCurrency());
  51.168 +            assertEquals(SKK, ex.getCurrencyA());
  51.169 +            assertEquals(CZK, ex.getCurrencyB());
  51.170 +        }
  51.171 +
  51.172 +        try
  51.173 +        {
  51.174 +            // convert 500 CZK to USD, the API shall say this is not possible
  51.175 +            c.convert(CZK, USD, BigDecimal.valueOf(500));
  51.176 +            fail("cannot use the CZKtoUSD converter to convert from SKK");
  51.177 +        }
  51.178 +        catch(InvalidConversionException ex)
  51.179 +        {            
  51.180 +            assertEquals("cannot convert to: USD", ex.getMessage());
  51.181 +            assertEquals(USD, ex.getBadCurrency());
  51.182 +            assertEquals(SKK, ex.getCurrencyA());
  51.183 +            assertEquals(CZK, ex.getCurrencyB());
  51.184 +        }
  51.185 +    }
  51.186 +}
  51.187 +
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/task2/solution05/build.xml	Wed Oct 01 10:43:05 2008 +0200
    52.3 @@ -0,0 +1,69 @@
    52.4 +<?xml version="1.0" encoding="UTF-8"?>
    52.5 +<!-- You may freely edit this file. See commented blocks below for -->
    52.6 +<!-- some examples of how to customize the build. -->
    52.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    52.8 +<project name="currency" default="default" basedir=".">
    52.9 +    <description>Builds, tests, and runs the project.</description>
   52.10 +    <import file="nbproject/build-impl.xml"/>
   52.11 +    <!--
   52.12 +
   52.13 +    There exist several targets which are by default empty and which can be 
   52.14 +    used for execution of your tasks. These targets are usually executed 
   52.15 +    before and after some main targets. They are: 
   52.16 +
   52.17 +      -pre-init:                 called before initialization of project properties
   52.18 +      -post-init:                called after initialization of project properties
   52.19 +      -pre-compile:              called before javac compilation
   52.20 +      -post-compile:             called after javac compilation
   52.21 +      -pre-compile-single:       called before javac compilation of single file
   52.22 +      -post-compile-single:      called after javac compilation of single file
   52.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   52.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   52.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   52.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   52.27 +      -pre-jar:                  called before JAR building
   52.28 +      -post-jar:                 called after JAR building
   52.29 +      -post-clean:               called after cleaning build products
   52.30 +
   52.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   52.32 +
   52.33 +    Example of inserting an obfuscator after compilation could look like this:
   52.34 +
   52.35 +        <target name="-post-compile">
   52.36 +            <obfuscate>
   52.37 +                <fileset dir="${build.classes.dir}"/>
   52.38 +            </obfuscate>
   52.39 +        </target>
   52.40 +
   52.41 +    For list of available properties check the imported 
   52.42 +    nbproject/build-impl.xml file. 
   52.43 +
   52.44 +
   52.45 +    Another way to customize the build is by overriding existing main targets.
   52.46 +    The targets of interest are: 
   52.47 +
   52.48 +      -init-macrodef-javac:     defines macro for javac compilation
   52.49 +      -init-macrodef-junit:     defines macro for junit execution
   52.50 +      -init-macrodef-debug:     defines macro for class debugging
   52.51 +      -init-macrodef-java:      defines macro for class execution
   52.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   52.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   52.54 +      run:                      execution of project 
   52.55 +      -javadoc-build:           Javadoc generation
   52.56 +      test-report:              JUnit report generation
   52.57 +
   52.58 +    An example of overriding the target for project execution could look like this:
   52.59 +
   52.60 +        <target name="run" depends="currency-impl.jar">
   52.61 +            <exec dir="bin" executable="launcher.exe">
   52.62 +                <arg file="${dist.jar}"/>
   52.63 +            </exec>
   52.64 +        </target>
   52.65 +
   52.66 +    Notice that the overridden target depends on the jar target and not only on 
   52.67 +    the compile target as the regular run target does. Again, for a list of available 
   52.68 +    properties which you can use, check the target you are overriding in the
   52.69 +    nbproject/build-impl.xml file. 
   52.70 +
   52.71 +    -->
   52.72 +</project>
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/task2/solution05/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    53.3 @@ -0,0 +1,642 @@
    53.4 +<?xml version="1.0" encoding="UTF-8"?>
    53.5 +<!--
    53.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    53.7 +***         EDIT ../build.xml INSTEAD         ***
    53.8 +
    53.9 +For the purpose of easier reading the script
   53.10 +is divided into following sections:
   53.11 +
   53.12 +  - initialization
   53.13 +  - compilation
   53.14 +  - jar
   53.15 +  - execution
   53.16 +  - debugging
   53.17 +  - javadoc
   53.18 +  - junit compilation
   53.19 +  - junit execution
   53.20 +  - junit debugging
   53.21 +  - applet
   53.22 +  - cleanup
   53.23 +
   53.24 +        -->
   53.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">
   53.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   53.27 +    <!-- 
   53.28 +                ======================
   53.29 +                INITIALIZATION SECTION 
   53.30 +                ======================
   53.31 +            -->
   53.32 +    <target name="-pre-init">
   53.33 +        <!-- Empty placeholder for easier customization. -->
   53.34 +        <!-- You can override this target in the ../build.xml file. -->
   53.35 +    </target>
   53.36 +    <target depends="-pre-init" name="-init-private">
   53.37 +        <property file="nbproject/private/config.properties"/>
   53.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   53.39 +        <property file="nbproject/private/private.properties"/>
   53.40 +    </target>
   53.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   53.42 +        <property file="${user.properties.file}"/>
   53.43 +        <!-- The two properties below are usually overridden -->
   53.44 +        <!-- by the active platform. Just a fallback. -->
   53.45 +        <property name="default.javac.source" value="1.4"/>
   53.46 +        <property name="default.javac.target" value="1.4"/>
   53.47 +    </target>
   53.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   53.49 +        <property file="nbproject/configs/${config}.properties"/>
   53.50 +        <property file="nbproject/project.properties"/>
   53.51 +    </target>
   53.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   53.53 +        <available file="${manifest.file}" property="manifest.available"/>
   53.54 +        <condition property="manifest.available+main.class">
   53.55 +            <and>
   53.56 +                <isset property="manifest.available"/>
   53.57 +                <isset property="main.class"/>
   53.58 +                <not>
   53.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   53.60 +                </not>
   53.61 +            </and>
   53.62 +        </condition>
   53.63 +        <condition property="manifest.available+main.class+mkdist.available">
   53.64 +            <and>
   53.65 +                <istrue value="${manifest.available+main.class}"/>
   53.66 +                <isset property="libs.CopyLibs.classpath"/>
   53.67 +            </and>
   53.68 +        </condition>
   53.69 +        <condition property="have.tests">
   53.70 +            <or>
   53.71 +                <available file="${test.src.dir}"/>
   53.72 +            </or>
   53.73 +        </condition>
   53.74 +        <condition property="have.sources">
   53.75 +            <or>
   53.76 +                <available file="${src.dir}"/>
   53.77 +            </or>
   53.78 +        </condition>
   53.79 +        <condition property="netbeans.home+have.tests">
   53.80 +            <and>
   53.81 +                <isset property="netbeans.home"/>
   53.82 +                <isset property="have.tests"/>
   53.83 +            </and>
   53.84 +        </condition>
   53.85 +        <condition property="no.javadoc.preview">
   53.86 +            <and>
   53.87 +                <isset property="javadoc.preview"/>
   53.88 +                <isfalse value="${javadoc.preview}"/>
   53.89 +            </and>
   53.90 +        </condition>
   53.91 +        <property name="run.jvmargs" value=""/>
   53.92 +        <property name="javac.compilerargs" value=""/>
   53.93 +        <property name="work.dir" value="${basedir}"/>
   53.94 +        <condition property="no.deps">
   53.95 +            <and>
   53.96 +                <istrue value="${no.dependencies}"/>
   53.97 +            </and>
   53.98 +        </condition>
   53.99 +        <property name="javac.debug" value="true"/>
  53.100 +        <property name="javadoc.preview" value="true"/>
  53.101 +        <property name="application.args" value=""/>
  53.102 +        <property name="source.encoding" value="${file.encoding}"/>
  53.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  53.104 +            <and>
  53.105 +                <isset property="javadoc.encoding"/>
  53.106 +                <not>
  53.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  53.108 +                </not>
  53.109 +            </and>
  53.110 +        </condition>
  53.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  53.112 +        <property name="includes" value="**"/>
  53.113 +        <property name="excludes" value=""/>
  53.114 +        <property name="do.depend" value="false"/>
  53.115 +        <condition property="do.depend.true">
  53.116 +            <istrue value="${do.depend}"/>
  53.117 +        </condition>
  53.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  53.119 +            <and>
  53.120 +                <isset property="jaxws.endorsed.dir"/>
  53.121 +                <available file="nbproject/jaxws-build.xml"/>
  53.122 +            </and>
  53.123 +        </condition>
  53.124 +    </target>
  53.125 +    <target name="-post-init">
  53.126 +        <!-- Empty placeholder for easier customization. -->
  53.127 +        <!-- You can override this target in the ../build.xml file. -->
  53.128 +    </target>
  53.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  53.130 +        <fail unless="src.dir">Must set src.dir</fail>
  53.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  53.132 +        <fail unless="build.dir">Must set build.dir</fail>
  53.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  53.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  53.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  53.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  53.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  53.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  53.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  53.140 +    </target>
  53.141 +    <target name="-init-macrodef-property">
  53.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  53.143 +            <attribute name="name"/>
  53.144 +            <attribute name="value"/>
  53.145 +            <sequential>
  53.146 +                <property name="@{name}" value="${@{value}}"/>
  53.147 +            </sequential>
  53.148 +        </macrodef>
  53.149 +    </target>
  53.150 +    <target name="-init-macrodef-javac">
  53.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  53.152 +            <attribute default="${src.dir}" name="srcdir"/>
  53.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  53.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  53.155 +            <attribute default="${includes}" name="includes"/>
  53.156 +            <attribute default="${excludes}" name="excludes"/>
  53.157 +            <attribute default="${javac.debug}" name="debug"/>
  53.158 +            <attribute default="" name="sourcepath"/>
  53.159 +            <element name="customize" optional="true"/>
  53.160 +            <sequential>
  53.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}">
  53.162 +                    <classpath>
  53.163 +                        <path path="@{classpath}"/>
  53.164 +                    </classpath>
  53.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  53.166 +                    <customize/>
  53.167 +                </javac>
  53.168 +            </sequential>
  53.169 +        </macrodef>
  53.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  53.171 +            <attribute default="${src.dir}" name="srcdir"/>
  53.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  53.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  53.174 +            <sequential>
  53.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  53.176 +                    <classpath>
  53.177 +                        <path path="@{classpath}"/>
  53.178 +                    </classpath>
  53.179 +                </depend>
  53.180 +            </sequential>
  53.181 +        </macrodef>
  53.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  53.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  53.184 +            <sequential>
  53.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  53.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  53.187 +                    <path>
  53.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  53.189 +                    </path>
  53.190 +                    <globmapper from="*.java" to="*.class"/>
  53.191 +                </pathconvert>
  53.192 +                <delete>
  53.193 +                    <files includes="${javac.includes.binary}"/>
  53.194 +                </delete>
  53.195 +            </sequential>
  53.196 +        </macrodef>
  53.197 +    </target>
  53.198 +    <target name="-init-macrodef-junit">
  53.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  53.200 +            <attribute default="${includes}" name="includes"/>
  53.201 +            <attribute default="${excludes}" name="excludes"/>
  53.202 +            <attribute default="**" name="testincludes"/>
  53.203 +            <sequential>
  53.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  53.205 +                    <batchtest todir="${build.test.results.dir}">
  53.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  53.207 +                            <filename name="@{testincludes}"/>
  53.208 +                        </fileset>
  53.209 +                    </batchtest>
  53.210 +                    <classpath>
  53.211 +                        <path path="${run.test.classpath}"/>
  53.212 +                    </classpath>
  53.213 +                    <syspropertyset>
  53.214 +                        <propertyref prefix="test-sys-prop."/>
  53.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  53.216 +                    </syspropertyset>
  53.217 +                    <formatter type="brief" usefile="false"/>
  53.218 +                    <formatter type="xml"/>
  53.219 +                    <jvmarg line="${run.jvmargs}"/>
  53.220 +                </junit>
  53.221 +            </sequential>
  53.222 +        </macrodef>
  53.223 +    </target>
  53.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  53.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  53.226 +            <attribute default="${main.class}" name="name"/>
  53.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  53.228 +            <attribute default="" name="stopclassname"/>
  53.229 +            <sequential>
  53.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  53.231 +                    <classpath>
  53.232 +                        <path path="@{classpath}"/>
  53.233 +                    </classpath>
  53.234 +                </nbjpdastart>
  53.235 +            </sequential>
  53.236 +        </macrodef>
  53.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  53.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  53.239 +            <sequential>
  53.240 +                <nbjpdareload>
  53.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  53.242 +                        <include name="${fix.includes}*.class"/>
  53.243 +                    </fileset>
  53.244 +                </nbjpdareload>
  53.245 +            </sequential>
  53.246 +        </macrodef>
  53.247 +    </target>
  53.248 +    <target name="-init-debug-args">
  53.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  53.250 +        <condition property="have-jdk-older-than-1.4">
  53.251 +            <or>
  53.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  53.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  53.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  53.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  53.256 +            </or>
  53.257 +        </condition>
  53.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  53.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  53.260 +        </condition>
  53.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  53.262 +            <os family="windows"/>
  53.263 +        </condition>
  53.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  53.265 +            <isset property="debug.transport"/>
  53.266 +        </condition>
  53.267 +    </target>
  53.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  53.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  53.270 +            <attribute default="${main.class}" name="classname"/>
  53.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  53.272 +            <element name="customize" optional="true"/>
  53.273 +            <sequential>
  53.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  53.275 +                    <jvmarg line="${debug-args-line}"/>
  53.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  53.277 +                    <jvmarg line="${run.jvmargs}"/>
  53.278 +                    <classpath>
  53.279 +                        <path path="@{classpath}"/>
  53.280 +                    </classpath>
  53.281 +                    <syspropertyset>
  53.282 +                        <propertyref prefix="run-sys-prop."/>
  53.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  53.284 +                    </syspropertyset>
  53.285 +                    <customize/>
  53.286 +                </java>
  53.287 +            </sequential>
  53.288 +        </macrodef>
  53.289 +    </target>
  53.290 +    <target name="-init-macrodef-java">
  53.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  53.292 +            <attribute default="${main.class}" name="classname"/>
  53.293 +            <element name="customize" optional="true"/>
  53.294 +            <sequential>
  53.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  53.296 +                    <jvmarg line="${run.jvmargs}"/>
  53.297 +                    <classpath>
  53.298 +                        <path path="${run.classpath}"/>
  53.299 +                    </classpath>
  53.300 +                    <syspropertyset>
  53.301 +                        <propertyref prefix="run-sys-prop."/>
  53.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  53.303 +                    </syspropertyset>
  53.304 +                    <customize/>
  53.305 +                </java>
  53.306 +            </sequential>
  53.307 +        </macrodef>
  53.308 +    </target>
  53.309 +    <target name="-init-presetdef-jar">
  53.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  53.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  53.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  53.313 +            </jar>
  53.314 +        </presetdef>
  53.315 +    </target>
  53.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"/>
  53.317 +    <!--
  53.318 +                ===================
  53.319 +                COMPILATION SECTION
  53.320 +                ===================
  53.321 +            -->
  53.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  53.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  53.324 +    <target depends="init" name="-check-automatic-build">
  53.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  53.326 +    </target>
  53.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  53.328 +        <antcall target="clean"/>
  53.329 +    </target>
  53.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  53.331 +        <mkdir dir="${build.classes.dir}"/>
  53.332 +    </target>
  53.333 +    <target name="-pre-compile">
  53.334 +        <!-- Empty placeholder for easier customization. -->
  53.335 +        <!-- You can override this target in the ../build.xml file. -->
  53.336 +    </target>
  53.337 +    <target if="do.depend.true" name="-compile-depend">
  53.338 +        <j2seproject3:depend/>
  53.339 +    </target>
  53.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  53.341 +        <j2seproject3:javac/>
  53.342 +        <copy todir="${build.classes.dir}">
  53.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  53.344 +        </copy>
  53.345 +    </target>
  53.346 +    <target name="-post-compile">
  53.347 +        <!-- Empty placeholder for easier customization. -->
  53.348 +        <!-- You can override this target in the ../build.xml file. -->
  53.349 +    </target>
  53.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  53.351 +    <target name="-pre-compile-single">
  53.352 +        <!-- Empty placeholder for easier customization. -->
  53.353 +        <!-- You can override this target in the ../build.xml file. -->
  53.354 +    </target>
  53.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  53.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  53.357 +        <j2seproject3:force-recompile/>
  53.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  53.359 +    </target>
  53.360 +    <target name="-post-compile-single">
  53.361 +        <!-- Empty placeholder for easier customization. -->
  53.362 +        <!-- You can override this target in the ../build.xml file. -->
  53.363 +    </target>
  53.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  53.365 +    <!--
  53.366 +                ====================
  53.367 +                JAR BUILDING SECTION
  53.368 +                ====================
  53.369 +            -->
  53.370 +    <target depends="init" name="-pre-pre-jar">
  53.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  53.372 +        <mkdir dir="${dist.jar.dir}"/>
  53.373 +    </target>
  53.374 +    <target name="-pre-jar">
  53.375 +        <!-- Empty placeholder for easier customization. -->
  53.376 +        <!-- You can override this target in the ../build.xml file. -->
  53.377 +    </target>
  53.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  53.379 +        <j2seproject1:jar/>
  53.380 +    </target>
  53.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  53.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  53.383 +    </target>
  53.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">
  53.385 +        <j2seproject1:jar manifest="${manifest.file}">
  53.386 +            <j2seproject1:manifest>
  53.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  53.388 +            </j2seproject1:manifest>
  53.389 +        </j2seproject1:jar>
  53.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  53.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  53.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  53.393 +        <pathconvert property="run.classpath.with.dist.jar">
  53.394 +            <path path="${run.classpath}"/>
  53.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  53.396 +        </pathconvert>
  53.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  53.398 +    </target>
  53.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  53.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  53.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  53.402 +            <path path="${run.classpath}"/>
  53.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  53.404 +        </pathconvert>
  53.405 +        <pathconvert pathsep=" " property="jar.classpath">
  53.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  53.407 +            <chainedmapper>
  53.408 +                <flattenmapper/>
  53.409 +                <globmapper from="*" to="lib/*"/>
  53.410 +            </chainedmapper>
  53.411 +        </pathconvert>
  53.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  53.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  53.414 +            <fileset dir="${build.classes.dir}"/>
  53.415 +            <manifest>
  53.416 +                <attribute name="Main-Class" value="${main.class}"/>
  53.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  53.418 +            </manifest>
  53.419 +        </copylibs>
  53.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  53.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  53.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  53.423 +    </target>
  53.424 +    <target name="-post-jar">
  53.425 +        <!-- Empty placeholder for easier customization. -->
  53.426 +        <!-- You can override this target in the ../build.xml file. -->
  53.427 +    </target>
  53.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"/>
  53.429 +    <!--
  53.430 +                =================
  53.431 +                EXECUTION SECTION
  53.432 +                =================
  53.433 +            -->
  53.434 +    <target depends="init,compile" description="Run a main class." name="run">
  53.435 +        <j2seproject1:java>
  53.436 +            <customize>
  53.437 +                <arg line="${application.args}"/>
  53.438 +            </customize>
  53.439 +        </j2seproject1:java>
  53.440 +    </target>
  53.441 +    <target name="-do-not-recompile">
  53.442 +        <property name="javac.includes.binary" value=""/>
  53.443 +    </target>
  53.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  53.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  53.446 +        <j2seproject1:java classname="${run.class}"/>
  53.447 +    </target>
  53.448 +    <!--
  53.449 +                =================
  53.450 +                DEBUGGING SECTION
  53.451 +                =================
  53.452 +            -->
  53.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  53.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  53.455 +    </target>
  53.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  53.457 +        <j2seproject3:debug>
  53.458 +            <customize>
  53.459 +                <arg line="${application.args}"/>
  53.460 +            </customize>
  53.461 +        </j2seproject3:debug>
  53.462 +    </target>
  53.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  53.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  53.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  53.466 +    </target>
  53.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  53.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  53.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  53.470 +        <j2seproject3:debug classname="${debug.class}"/>
  53.471 +    </target>
  53.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  53.473 +    <target depends="init" name="-pre-debug-fix">
  53.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  53.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  53.476 +    </target>
  53.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  53.478 +        <j2seproject1:nbjpdareload/>
  53.479 +    </target>
  53.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  53.481 +    <!--
  53.482 +                ===============
  53.483 +                JAVADOC SECTION
  53.484 +                ===============
  53.485 +            -->
  53.486 +    <target depends="init" name="-javadoc-build">
  53.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  53.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}">
  53.489 +            <classpath>
  53.490 +                <path path="${javac.classpath}"/>
  53.491 +            </classpath>
  53.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  53.493 +                <filename name="**/*.java"/>
  53.494 +            </fileset>
  53.495 +        </javadoc>
  53.496 +    </target>
  53.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  53.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  53.499 +    </target>
  53.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  53.501 +    <!--
  53.502 +                =========================
  53.503 +                JUNIT COMPILATION SECTION
  53.504 +                =========================
  53.505 +            -->
  53.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  53.507 +        <mkdir dir="${build.test.classes.dir}"/>
  53.508 +    </target>
  53.509 +    <target name="-pre-compile-test">
  53.510 +        <!-- Empty placeholder for easier customization. -->
  53.511 +        <!-- You can override this target in the ../build.xml file. -->
  53.512 +    </target>
  53.513 +    <target if="do.depend.true" name="-compile-test-depend">
  53.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  53.515 +    </target>
  53.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  53.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  53.518 +        <copy todir="${build.test.classes.dir}">
  53.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  53.520 +        </copy>
  53.521 +    </target>
  53.522 +    <target name="-post-compile-test">
  53.523 +        <!-- Empty placeholder for easier customization. -->
  53.524 +        <!-- You can override this target in the ../build.xml file. -->
  53.525 +    </target>
  53.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  53.527 +    <target name="-pre-compile-test-single">
  53.528 +        <!-- Empty placeholder for easier customization. -->
  53.529 +        <!-- You can override this target in the ../build.xml file. -->
  53.530 +    </target>
  53.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  53.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  53.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  53.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}"/>
  53.535 +        <copy todir="${build.test.classes.dir}">
  53.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  53.537 +        </copy>
  53.538 +    </target>
  53.539 +    <target name="-post-compile-test-single">
  53.540 +        <!-- Empty placeholder for easier customization. -->
  53.541 +        <!-- You can override this target in the ../build.xml file. -->
  53.542 +    </target>
  53.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"/>
  53.544 +    <!--
  53.545 +                =======================
  53.546 +                JUNIT EXECUTION SECTION
  53.547 +                =======================
  53.548 +            -->
  53.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  53.550 +        <mkdir dir="${build.test.results.dir}"/>
  53.551 +    </target>
  53.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  53.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  53.554 +    </target>
  53.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  53.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  53.557 +    </target>
  53.558 +    <target depends="init" if="have.tests" name="test-report"/>
  53.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  53.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"/>
  53.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  53.562 +        <mkdir dir="${build.test.results.dir}"/>
  53.563 +    </target>
  53.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  53.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  53.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  53.567 +    </target>
  53.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  53.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  53.570 +    </target>
  53.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"/>
  53.572 +    <!--
  53.573 +                =======================
  53.574 +                JUNIT DEBUGGING SECTION
  53.575 +                =======================
  53.576 +            -->
  53.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  53.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  53.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  53.580 +        <delete file="${test.report.file}"/>
  53.581 +        <mkdir dir="${build.test.results.dir}"/>
  53.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}">
  53.583 +            <customize>
  53.584 +                <syspropertyset>
  53.585 +                    <propertyref prefix="test-sys-prop."/>
  53.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  53.587 +                </syspropertyset>
  53.588 +                <arg value="${test.class}"/>
  53.589 +                <arg value="showoutput=true"/>
  53.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  53.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  53.592 +            </customize>
  53.593 +        </j2seproject3:debug>
  53.594 +    </target>
  53.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  53.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  53.597 +    </target>
  53.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  53.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  53.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  53.601 +    </target>
  53.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  53.603 +    <!--
  53.604 +                =========================
  53.605 +                APPLET EXECUTION SECTION
  53.606 +                =========================
  53.607 +            -->
  53.608 +    <target depends="init,compile-single" name="run-applet">
  53.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  53.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  53.611 +            <customize>
  53.612 +                <arg value="${applet.url}"/>
  53.613 +            </customize>
  53.614 +        </j2seproject1:java>
  53.615 +    </target>
  53.616 +    <!--
  53.617 +                =========================
  53.618 +                APPLET DEBUGGING  SECTION
  53.619 +                =========================
  53.620 +            -->
  53.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  53.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  53.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  53.624 +            <customize>
  53.625 +                <arg value="${applet.url}"/>
  53.626 +            </customize>
  53.627 +        </j2seproject3:debug>
  53.628 +    </target>
  53.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  53.630 +    <!--
  53.631 +                ===============
  53.632 +                CLEANUP SECTION
  53.633 +                ===============
  53.634 +            -->
  53.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  53.636 +    <target depends="init" name="-do-clean">
  53.637 +        <delete dir="${build.dir}"/>
  53.638 +        <delete dir="${dist.dir}"/>
  53.639 +    </target>
  53.640 +    <target name="-post-clean">
  53.641 +        <!-- Empty placeholder for easier customization. -->
  53.642 +        <!-- You can override this target in the ../build.xml file. -->
  53.643 +    </target>
  53.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  53.645 +</project>
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/task2/solution05/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    54.3 @@ -0,0 +1,8 @@
    54.4 +build.xml.data.CRC32=2ab820eb
    54.5 +build.xml.script.CRC32=58a52595
    54.6 +build.xml.stylesheet.CRC32=be360661
    54.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    54.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    54.9 +nbproject/build-impl.xml.data.CRC32=47a079e2
   54.10 +nbproject/build-impl.xml.script.CRC32=f7fdafd7
   54.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/task2/solution05/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    55.3 @@ -0,0 +1,68 @@
    55.4 +application.title=currency
    55.5 +application.vendor=apidesign.org
    55.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    55.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    55.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    55.9 +build.classes.dir=${build.dir}/classes
   55.10 +build.classes.excludes=**/*.java,**/*.form
   55.11 +# This directory is removed when the project is cleaned:
   55.12 +build.dir=build
   55.13 +build.generated.dir=${build.dir}/generated
   55.14 +# Only compile against the classpath explicitly listed here:
   55.15 +build.sysclasspath=ignore
   55.16 +build.test.classes.dir=${build.dir}/test/classes
   55.17 +build.test.results.dir=${build.dir}/test/results
   55.18 +debug.classpath=\
   55.19 +    ${run.classpath}
   55.20 +debug.test.classpath=\
   55.21 +    ${run.test.classpath}
   55.22 +# This directory is removed when the project is cleaned:
   55.23 +dist.dir=dist
   55.24 +dist.jar=${dist.dir}/currency.jar
   55.25 +dist.javadoc.dir=${dist.dir}/javadoc
   55.26 +excludes=
   55.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   55.28 +file.reference.src-apifest08=..
   55.29 +includes=**
   55.30 +jar.compress=false
   55.31 +javac.classpath=
   55.32 +# Space-separated list of extra javac options
   55.33 +javac.compilerargs=
   55.34 +javac.deprecation=false
   55.35 +javac.source=1.5
   55.36 +javac.target=1.5
   55.37 +javac.test.classpath=\
   55.38 +    ${javac.classpath}:\
   55.39 +    ${build.classes.dir}:\
   55.40 +    ${file.reference.junit-4.4.jar}
   55.41 +javadoc.additionalparam=
   55.42 +javadoc.author=false
   55.43 +javadoc.encoding=
   55.44 +javadoc.noindex=false
   55.45 +javadoc.nonavbar=false
   55.46 +javadoc.notree=false
   55.47 +javadoc.private=false
   55.48 +javadoc.splitindex=true
   55.49 +javadoc.use=true
   55.50 +javadoc.version=false
   55.51 +javadoc.windowtitle=
   55.52 +jnlp.codebase.type=local
   55.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   55.54 +jnlp.descriptor=application
   55.55 +jnlp.enabled=false
   55.56 +jnlp.offline-allowed=false
   55.57 +jnlp.signed=false
   55.58 +meta.inf.dir=${src.dir}/META-INF
   55.59 +platform.active=default_platform
   55.60 +run.classpath=\
   55.61 +    ${javac.classpath}:\
   55.62 +    ${build.classes.dir}
   55.63 +# Space-separated list of JVM arguments used when running the project
   55.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   55.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   55.66 +run.jvmargs=
   55.67 +run.test.classpath=\
   55.68 +    ${javac.test.classpath}:\
   55.69 +    ${build.test.classes.dir}
   55.70 +src.dir=src
   55.71 +test.src.dir=test
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/task2/solution05/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    56.3 @@ -0,0 +1,16 @@
    56.4 +<?xml version="1.0" encoding="UTF-8"?>
    56.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    56.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    56.7 +    <configuration>
    56.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    56.9 +            <name>Currency Convertor Solution 05</name>
   56.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   56.11 +            <source-roots>
   56.12 +                <root id="src.dir"/>
   56.13 +            </source-roots>
   56.14 +            <test-roots>
   56.15 +                <root id="test.src.dir"/>
   56.16 +            </test-roots>
   56.17 +        </data>
   56.18 +    </configuration>
   56.19 +</project>
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/task2/solution05/src/org/apidesign/apifest08/currency/Amount.java	Wed Oct 01 10:43:05 2008 +0200
    57.3 @@ -0,0 +1,92 @@
    57.4 +package org.apidesign.apifest08.currency;
    57.5 +
    57.6 +/**
    57.7 + * Amount is a class reprezenting an amount of many. It consist of
    57.8 + * whole currency amount and of pence amount. Both items are long values
    57.9 + * and it's not defined that the 100 pences = 1 amount. It's up to the converter
   57.10 + * to verify such invariants.
   57.11 + *
   57.12 + * @author jindra
   57.13 + */
   57.14 +public final class Amount {
   57.15 +
   57.16 +    private long amount;
   57.17 +    private long pence;
   57.18 +
   57.19 +    /**
   57.20 +     * Construct Amount with no pences.
   57.21 +     *
   57.22 +     * @param amount the amount in some currency
   57.23 +     *
   57.24 +     */
   57.25 +    public Amount(long amount) {
   57.26 +        this.amount = amount;
   57.27 +        this.pence = 0;
   57.28 +    }
   57.29 +
   57.30 +    /**
   57.31 +     * Construct Amount with the pences.
   57.32 +     *
   57.33 +     * @param amount the amount in some currency
   57.34 +     * @param pence the pence count
   57.35 +     */
   57.36 +    public Amount(long amount, long pence) {
   57.37 +        this.amount = amount;
   57.38 +        this.pence = pence;
   57.39 +    }
   57.40 +
   57.41 +    /**
   57.42 +     * @return the amount
   57.43 +     */
   57.44 +    public long getAmount() {
   57.45 +        return amount;
   57.46 +    }
   57.47 +
   57.48 +    /**
   57.49 +     * @param amount the amount to set
   57.50 +     */
   57.51 +    public void setAmount(long amount) {
   57.52 +        this.amount = amount;
   57.53 +    }
   57.54 +
   57.55 +    /**
   57.56 +     * @return the pence
   57.57 +     */
   57.58 +    public long getPence() {
   57.59 +        return pence;
   57.60 +    }
   57.61 +
   57.62 +    /**
   57.63 +     * @param pence the pence to set
   57.64 +     */
   57.65 +    public void setPence(long pence) {
   57.66 +        this.pence = pence;
   57.67 +    }
   57.68 +
   57.69 +    @Override
   57.70 +    public boolean equals(Object obj) {
   57.71 +        if (obj == null) {
   57.72 +            return false;
   57.73 +        }
   57.74 +        if (!(obj instanceof Amount)) {
   57.75 +            return false;
   57.76 +        }
   57.77 +        Amount other = (Amount) obj;
   57.78 +        return (amount == other.amount) && (pence == other.pence);
   57.79 +    }
   57.80 +
   57.81 +    @Override
   57.82 +    public int hashCode() {
   57.83 +        int hash = 7;
   57.84 +        hash = 79 * hash + (int) (this.amount ^ (this.amount >>> 32));
   57.85 +        hash = 79 * hash + (int) (this.pence ^ (this.pence >>> 32));
   57.86 +        return hash;
   57.87 +    }
   57.88 +
   57.89 +    @Override
   57.90 +    public String toString() {
   57.91 +        return amount + "." + pence;
   57.92 +    }
   57.93 +
   57.94 +
   57.95 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/task2/solution05/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    58.3 @@ -0,0 +1,25 @@
    58.4 +package org.apidesign.apifest08.currency;
    58.5 +
    58.6 +/**
    58.7 + * Convertor is an interface reprezenting a convertor between currencies.
    58.8 + * It's able to convert one currency to the second one and back from the second one
    58.9 + * to the primary.
   58.10 + */
   58.11 +public interface Convertor {
   58.12 +
   58.13 +    /**
   58.14 +     * Convert amount of primary currency into secondary currency
   58.15 +     *
   58.16 +     * @param amount the amount in the primary currency
   58.17 +     * @return an amount in the secondary currency
   58.18 +     */
   58.19 +    Amount convert(Amount primaryAmount);
   58.20 +
   58.21 +    /**
   58.22 +     * Convert amount of secondary currency back into primary currency
   58.23 +     *
   58.24 +     * @param amount the amount in the secondary currency
   58.25 +     * @return an amount in the primary currency
   58.26 +     */
   58.27 +    Amount convertBack(Amount secondaryAmount);
   58.28 +}
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
    59.3 @@ -0,0 +1,30 @@
    59.4 +package org.apidesign.apifest08.currency;
    59.5 +
    59.6 +/**
    59.7 + * Convertor factory is a factory class for creating {@link Convertor Convertor}
    59.8 + * instances.
    59.9 + *
   59.10 + * @author jindra
   59.11 + */
   59.12 +public final class ConvertorFactory {
   59.13 +
   59.14 +    // this class needs no instances
   59.15 +    private ConvertorFactory() {
   59.16 +    }
   59.17 +
   59.18 +
   59.19 +    /**
   59.20 +     * Create a {@link Convertor Convertor} with given exchange rate
   59.21 +     *
   59.22 +     * @param exchangeRate double reprezenting the exchange rate from primary currency into
   59.23 +     * the secundary currecny
   59.24 +     * @return {@link Convertor Convertor} instance with given exchange rate
   59.25 +     */
   59.26 +    public static Convertor createConvertor(double exchangeRate) {
   59.27 +        if (exchangeRate == 0) {
   59.28 +            throw new IllegalArgumentException("Zero exchange rate is not allowed.");
   59.29 +        }
   59.30 +        return new ConvertorImpl(exchangeRate);
   59.31 +
   59.32 +    }
   59.33 +}
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorImpl.java	Wed Oct 01 10:43:05 2008 +0200
    60.3 @@ -0,0 +1,56 @@
    60.4 +package org.apidesign.apifest08.currency;
    60.5 +
    60.6 +/**
    60.7 + * ConvetorImpl it the basic implementaion of Convertor interface.
    60.8 + * @see Convertor Convertor for more details.
    60.9 + * The 100 pences makes 1 amount of the currency.
   60.10 + *
   60.11 + * @author jindra
   60.12 + */
   60.13 +final class ConvertorImpl implements Convertor {
   60.14 +
   60.15 +    private static final double P_TO_AM = 100;
   60.16 +    private double exchangeRate;
   60.17 +
   60.18 +    ConvertorImpl(double exchangeRate) {
   60.19 +        this.exchangeRate = exchangeRate;
   60.20 +    }
   60.21 +
   60.22 +    public Amount convert(Amount amount) {
   60.23 +        verifyInput(amount);
   60.24 +        double result = convertToDouble(amount) * exchangeRate;
   60.25 +        return convertToAmount(result);
   60.26 +    }
   60.27 +
   60.28 +    public Amount convertBack(Amount amount) {
   60.29 +        if (amount == null) {
   60.30 +            throw new IllegalArgumentException("Amount must be not null");
   60.31 +        }
   60.32 +        double result = convertToDouble(amount) / exchangeRate;
   60.33 +        return convertToAmount(result);
   60.34 +    }
   60.35 +
   60.36 +    private double convertToDouble(Amount amount) {
   60.37 +        double am = amount.getAmount();
   60.38 +        double pc = amount.getPence();
   60.39 +        return am + (pc / P_TO_AM);
   60.40 +    }
   60.41 +
   60.42 +    private Amount convertToAmount(double result) {
   60.43 +        long resultAm = Math.round(Math.floor(result));
   60.44 +        long resultPc = Math.round(Math.floor((result * P_TO_AM - resultAm * P_TO_AM)));
   60.45 +        return new Amount(resultAm, resultPc);
   60.46 +    }
   60.47 +
   60.48 +    private void verifyInput(Amount amount) {
   60.49 +        if (amount == null) {
   60.50 +            throw new IllegalArgumentException("Amount must be not null");
   60.51 +        }
   60.52 +        if (amount.getPence() < 0) {
   60.53 +            throw new IllegalArgumentException("Pences must not be negative");
   60.54 +        }
   60.55 +        if (amount.getPence() > P_TO_AM) {
   60.56 +            throw new IllegalArgumentException("Pences must not be over P_TO_AM");
   60.57 +        }
   60.58 +    }
   60.59 +}
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/task2/solution05/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    61.3 @@ -0,0 +1,104 @@
    61.4 +package org.apidesign.apifest08.test;
    61.5 +
    61.6 +import junit.framework.TestCase;
    61.7 +import org.apidesign.apifest08.currency.Amount;
    61.8 +import org.apidesign.apifest08.currency.Convertor;
    61.9 +import org.apidesign.apifest08.currency.ConvertorFactory;
   61.10 +
   61.11 +/** Finish the Convertor API, and then write bodies of methods inside
   61.12 + * of this class to match the given tasks. To fullfil your task, use the
   61.13 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   61.14 + * Do not you reflection, or other hacks as your code
   61.15 + * shall run without any runtime permissions.
   61.16 + */
   61.17 +public class Task1Test extends TestCase {
   61.18 +    public Task1Test(String testName) {
   61.19 +        super(testName);
   61.20 +    }
   61.21 +
   61.22 +    @Override
   61.23 +    protected void setUp() throws Exception {
   61.24 +    }
   61.25 +
   61.26 +    @Override
   61.27 +    protected void tearDown() throws Exception {
   61.28 +    }
   61.29 +
   61.30 +    /** Create convertor that understands two currencies, CZK and
   61.31 +     *  USD. Make 1 USD == 17 CZK.
   61.32 +     *
   61.33 +     * Creation of the convertor shall not require subclassing of any class
   61.34 +     * or interface on the client side.
   61.35 +     *
   61.36 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   61.37 +     */
   61.38 +    public static Convertor createCZKtoUSD() {
   61.39 +        return ConvertorFactory.createConvertor(17);
   61.40 +    }
   61.41 +
   61.42 +    /** Create convertor that understands two currencies, CZK and
   61.43 +     *  SKK. Make 100 SKK == 80 CZK.
   61.44 +     *
   61.45 +     * Creation of the convertor shall not require subclassing of any class
   61.46 +     * or interface on the client side.
   61.47 +     * 
   61.48 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   61.49 +     */
   61.50 +    public static Convertor createSKKtoCZK() {
   61.51 +        return ConvertorFactory.createConvertor(0.8);
   61.52 +    }
   61.53 +    
   61.54 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   61.55 +     * with it.
   61.56 +     */
   61.57 +    public void testCurrencyCZKUSD() throws Exception {
   61.58 +        Convertor c = createCZKtoUSD();
   61.59 +        // convert $5 to CZK using c:
   61.60 +        assertEquals("Result is 85 CZK", 85l, c.convert(new Amount(5)).getAmount());
   61.61 +
   61.62 +        // convert $8 to CZK
   61.63 +        assertEquals("Result is 136 CZK", 136l, c.convert(new Amount(8)).getAmount());
   61.64 +
   61.65 +        // convert 1003CZK to USD
   61.66 +        assertEquals("Result is 136 CZK", 59l, c.convertBack(new Amount(1003)).getAmount());
   61.67 +        // assertEquals("Result is 59 USD");
   61.68 +    }
   61.69 +
   61.70 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   61.71 +     * with it.
   61.72 +     */
   61.73 +    public void testCurrencySKKCZK() throws Exception {
   61.74 +        Convertor c = createSKKtoCZK();
   61.75 +        // convert 16CZK using c:
   61.76 +        assertEquals("Result is 20 SKK", 20l, c.convertBack(new Amount(16)).getAmount());
   61.77 +
   61.78 +        // convert 500SKK to CZK
   61.79 +        assertEquals("Result is 400 CZK", 400l, c.convert(new Amount(500)).getAmount());
   61.80 +    }
   61.81 +
   61.82 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   61.83 +     * with it.
   61.84 +     */
   61.85 +    public void testCurrencySKKCZKwithPences() throws Exception {
   61.86 +        Convertor c = createSKKtoCZK();
   61.87 +        // convert 16CZK 16h using c:
   61.88 +        assertEquals("Result is 20 SKK 20h", new Amount(20, 20), c.convertBack(new Amount(16, 16)));
   61.89 +
   61.90 +        // convert 500SKK 80h to CZK
   61.91 +        assertEquals("Result is 400 CZK 64h", new Amount(400, 64), c.convert(new Amount(500, 80)));
   61.92 +
   61.93 +        // convert 400CZK 80h to SKK
   61.94 +        assertEquals("Result is 501 CZK", new Amount(501), c.convertBack(new Amount(400, 80)));
   61.95 +    }
   61.96 +
   61.97 +    public void testNegativeSKKCZ() throws Exception{
   61.98 +        Convertor c = createSKKtoCZK();
   61.99 +        // convert -16CZK using c:
  61.100 +        assertEquals("Result is -20", new Amount(-20), c.convertBack(new Amount(-16)));
  61.101 +
  61.102 +        // convert -500SKK 80h to CZK
  61.103 +        assertEquals("Result is -400CZK 64h", new Amount(-400, 64), c.convert(new Amount(-500, 80)));
  61.104 +
  61.105 +    }
  61.106 +}
  61.107 +
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/task2/solution06/build.xml	Wed Oct 01 10:43:05 2008 +0200
    62.3 @@ -0,0 +1,69 @@
    62.4 +<?xml version="1.0" encoding="UTF-8"?>
    62.5 +<!-- You may freely edit this file. See commented blocks below for -->
    62.6 +<!-- some examples of how to customize the build. -->
    62.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    62.8 +<project name="currency" default="default" basedir=".">
    62.9 +    <description>Builds, tests, and runs the project.</description>
   62.10 +    <import file="nbproject/build-impl.xml"/>
   62.11 +    <!--
   62.12 +
   62.13 +    There exist several targets which are by default empty and which can be 
   62.14 +    used for execution of your tasks. These targets are usually executed 
   62.15 +    before and after some main targets. They are: 
   62.16 +
   62.17 +      -pre-init:                 called before initialization of project properties
   62.18 +      -post-init:                called after initialization of project properties
   62.19 +      -pre-compile:              called before javac compilation
   62.20 +      -post-compile:             called after javac compilation
   62.21 +      -pre-compile-single:       called before javac compilation of single file
   62.22 +      -post-compile-single:      called after javac compilation of single file
   62.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   62.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   62.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   62.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   62.27 +      -pre-jar:                  called before JAR building
   62.28 +      -post-jar:                 called after JAR building
   62.29 +      -post-clean:               called after cleaning build products
   62.30 +
   62.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   62.32 +
   62.33 +    Example of inserting an obfuscator after compilation could look like this:
   62.34 +
   62.35 +        <target name="-post-compile">
   62.36 +            <obfuscate>
   62.37 +                <fileset dir="${build.classes.dir}"/>
   62.38 +            </obfuscate>
   62.39 +        </target>
   62.40 +
   62.41 +    For list of available properties check the imported 
   62.42 +    nbproject/build-impl.xml file. 
   62.43 +
   62.44 +
   62.45 +    Another way to customize the build is by overriding existing main targets.
   62.46 +    The targets of interest are: 
   62.47 +
   62.48 +      -init-macrodef-javac:     defines macro for javac compilation
   62.49 +      -init-macrodef-junit:     defines macro for junit execution
   62.50 +      -init-macrodef-debug:     defines macro for class debugging
   62.51 +      -init-macrodef-java:      defines macro for class execution
   62.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   62.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   62.54 +      run:                      execution of project 
   62.55 +      -javadoc-build:           Javadoc generation
   62.56 +      test-report:              JUnit report generation
   62.57 +
   62.58 +    An example of overriding the target for project execution could look like this:
   62.59 +
   62.60 +        <target name="run" depends="currency-impl.jar">
   62.61 +            <exec dir="bin" executable="launcher.exe">
   62.62 +                <arg file="${dist.jar}"/>
   62.63 +            </exec>
   62.64 +        </target>
   62.65 +
   62.66 +    Notice that the overridden target depends on the jar target and not only on 
   62.67 +    the compile target as the regular run target does. Again, for a list of available 
   62.68 +    properties which you can use, check the target you are overriding in the
   62.69 +    nbproject/build-impl.xml file. 
   62.70 +
   62.71 +    -->
   62.72 +</project>
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/task2/solution06/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    63.3 @@ -0,0 +1,642 @@
    63.4 +<?xml version="1.0" encoding="UTF-8"?>
    63.5 +<!--
    63.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    63.7 +***         EDIT ../build.xml INSTEAD         ***
    63.8 +
    63.9 +For the purpose of easier reading the script
   63.10 +is divided into following sections:
   63.11 +
   63.12 +  - initialization
   63.13 +  - compilation
   63.14 +  - jar
   63.15 +  - execution
   63.16 +  - debugging
   63.17 +  - javadoc
   63.18 +  - junit compilation
   63.19 +  - junit execution
   63.20 +  - junit debugging
   63.21 +  - applet
   63.22 +  - cleanup
   63.23 +
   63.24 +        -->
   63.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_06-impl">
   63.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   63.27 +    <!-- 
   63.28 +                ======================
   63.29 +                INITIALIZATION SECTION 
   63.30 +                ======================
   63.31 +            -->
   63.32 +    <target name="-pre-init">
   63.33 +        <!-- Empty placeholder for easier customization. -->
   63.34 +        <!-- You can override this target in the ../build.xml file. -->
   63.35 +    </target>
   63.36 +    <target depends="-pre-init" name="-init-private">
   63.37 +        <property file="nbproject/private/config.properties"/>
   63.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   63.39 +        <property file="nbproject/private/private.properties"/>
   63.40 +    </target>
   63.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   63.42 +        <property file="${user.properties.file}"/>
   63.43 +        <!-- The two properties below are usually overridden -->
   63.44 +        <!-- by the active platform. Just a fallback. -->
   63.45 +        <property name="default.javac.source" value="1.4"/>
   63.46 +        <property name="default.javac.target" value="1.4"/>
   63.47 +    </target>
   63.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   63.49 +        <property file="nbproject/configs/${config}.properties"/>
   63.50 +        <property file="nbproject/project.properties"/>
   63.51 +    </target>
   63.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   63.53 +        <available file="${manifest.file}" property="manifest.available"/>
   63.54 +        <condition property="manifest.available+main.class">
   63.55 +            <and>
   63.56 +                <isset property="manifest.available"/>
   63.57 +                <isset property="main.class"/>
   63.58 +                <not>
   63.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   63.60 +                </not>
   63.61 +            </and>
   63.62 +        </condition>
   63.63 +        <condition property="manifest.available+main.class+mkdist.available">
   63.64 +            <and>
   63.65 +                <istrue value="${manifest.available+main.class}"/>
   63.66 +                <isset property="libs.CopyLibs.classpath"/>
   63.67 +            </and>
   63.68 +        </condition>
   63.69 +        <condition property="have.tests">
   63.70 +            <or>
   63.71 +                <available file="${test.src.dir}"/>
   63.72 +            </or>
   63.73 +        </condition>
   63.74 +        <condition property="have.sources">
   63.75 +            <or>
   63.76 +                <available file="${src.dir}"/>
   63.77 +            </or>
   63.78 +        </condition>
   63.79 +        <condition property="netbeans.home+have.tests">
   63.80 +            <and>
   63.81 +                <isset property="netbeans.home"/>
   63.82 +                <isset property="have.tests"/>
   63.83 +            </and>
   63.84 +        </condition>
   63.85 +        <condition property="no.javadoc.preview">
   63.86 +            <and>
   63.87 +                <isset property="javadoc.preview"/>
   63.88 +                <isfalse value="${javadoc.preview}"/>
   63.89 +            </and>
   63.90 +        </condition>
   63.91 +        <property name="run.jvmargs" value=""/>
   63.92 +        <property name="javac.compilerargs" value=""/>
   63.93 +        <property name="work.dir" value="${basedir}"/>
   63.94 +        <condition property="no.deps">
   63.95 +            <and>
   63.96 +                <istrue value="${no.dependencies}"/>
   63.97 +            </and>
   63.98 +        </condition>
   63.99 +        <property name="javac.debug" value="true"/>
  63.100 +        <property name="javadoc.preview" value="true"/>
  63.101 +        <property name="application.args" value=""/>
  63.102 +        <property name="source.encoding" value="${file.encoding}"/>
  63.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  63.104 +            <and>
  63.105 +                <isset property="javadoc.encoding"/>
  63.106 +                <not>
  63.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  63.108 +                </not>
  63.109 +            </and>
  63.110 +        </condition>
  63.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  63.112 +        <property name="includes" value="**"/>
  63.113 +        <property name="excludes" value=""/>
  63.114 +        <property name="do.depend" value="false"/>
  63.115 +        <condition property="do.depend.true">
  63.116 +            <istrue value="${do.depend}"/>
  63.117 +        </condition>
  63.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  63.119 +            <and>
  63.120 +                <isset property="jaxws.endorsed.dir"/>
  63.121 +                <available file="nbproject/jaxws-build.xml"/>
  63.122 +            </and>
  63.123 +        </condition>
  63.124 +    </target>
  63.125 +    <target name="-post-init">
  63.126 +        <!-- Empty placeholder for easier customization. -->
  63.127 +        <!-- You can override this target in the ../build.xml file. -->
  63.128 +    </target>
  63.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  63.130 +        <fail unless="src.dir">Must set src.dir</fail>
  63.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  63.132 +        <fail unless="build.dir">Must set build.dir</fail>
  63.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  63.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  63.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  63.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  63.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  63.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  63.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  63.140 +    </target>
  63.141 +    <target name="-init-macrodef-property">
  63.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  63.143 +            <attribute name="name"/>
  63.144 +            <attribute name="value"/>
  63.145 +            <sequential>
  63.146 +                <property name="@{name}" value="${@{value}}"/>
  63.147 +            </sequential>
  63.148 +        </macrodef>
  63.149 +    </target>
  63.150 +    <target name="-init-macrodef-javac">
  63.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  63.152 +            <attribute default="${src.dir}" name="srcdir"/>
  63.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  63.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  63.155 +            <attribute default="${includes}" name="includes"/>
  63.156 +            <attribute default="${excludes}" name="excludes"/>
  63.157 +            <attribute default="${javac.debug}" name="debug"/>
  63.158 +            <attribute default="" name="sourcepath"/>
  63.159 +            <element name="customize" optional="true"/>
  63.160 +            <sequential>
  63.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}">
  63.162 +                    <classpath>
  63.163 +                        <path path="@{classpath}"/>
  63.164 +                    </classpath>
  63.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  63.166 +                    <customize/>
  63.167 +                </javac>
  63.168 +            </sequential>
  63.169 +        </macrodef>
  63.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  63.171 +            <attribute default="${src.dir}" name="srcdir"/>
  63.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  63.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  63.174 +            <sequential>
  63.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  63.176 +                    <classpath>
  63.177 +                        <path path="@{classpath}"/>
  63.178 +                    </classpath>
  63.179 +                </depend>
  63.180 +            </sequential>
  63.181 +        </macrodef>
  63.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  63.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  63.184 +            <sequential>
  63.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  63.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  63.187 +                    <path>
  63.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  63.189 +                    </path>
  63.190 +                    <globmapper from="*.java" to="*.class"/>
  63.191 +                </pathconvert>
  63.192 +                <delete>
  63.193 +                    <files includes="${javac.includes.binary}"/>
  63.194 +                </delete>
  63.195 +            </sequential>
  63.196 +        </macrodef>
  63.197 +    </target>
  63.198 +    <target name="-init-macrodef-junit">
  63.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  63.200 +            <attribute default="${includes}" name="includes"/>
  63.201 +            <attribute default="${excludes}" name="excludes"/>
  63.202 +            <attribute default="**" name="testincludes"/>
  63.203 +            <sequential>
  63.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  63.205 +                    <batchtest todir="${build.test.results.dir}">
  63.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  63.207 +                            <filename name="@{testincludes}"/>
  63.208 +                        </fileset>
  63.209 +                    </batchtest>
  63.210 +                    <classpath>
  63.211 +                        <path path="${run.test.classpath}"/>
  63.212 +                    </classpath>
  63.213 +                    <syspropertyset>
  63.214 +                        <propertyref prefix="test-sys-prop."/>
  63.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  63.216 +                    </syspropertyset>
  63.217 +                    <formatter type="brief" usefile="false"/>
  63.218 +                    <formatter type="xml"/>
  63.219 +                    <jvmarg line="${run.jvmargs}"/>
  63.220 +                </junit>
  63.221 +            </sequential>
  63.222 +        </macrodef>
  63.223 +    </target>
  63.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  63.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  63.226 +            <attribute default="${main.class}" name="name"/>
  63.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  63.228 +            <attribute default="" name="stopclassname"/>
  63.229 +            <sequential>
  63.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  63.231 +                    <classpath>
  63.232 +                        <path path="@{classpath}"/>
  63.233 +                    </classpath>
  63.234 +                </nbjpdastart>
  63.235 +            </sequential>
  63.236 +        </macrodef>
  63.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  63.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  63.239 +            <sequential>
  63.240 +                <nbjpdareload>
  63.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  63.242 +                        <include name="${fix.includes}*.class"/>
  63.243 +                    </fileset>
  63.244 +                </nbjpdareload>
  63.245 +            </sequential>
  63.246 +        </macrodef>
  63.247 +    </target>
  63.248 +    <target name="-init-debug-args">
  63.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  63.250 +        <condition property="have-jdk-older-than-1.4">
  63.251 +            <or>
  63.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  63.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  63.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  63.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  63.256 +            </or>
  63.257 +        </condition>
  63.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  63.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  63.260 +        </condition>
  63.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  63.262 +            <os family="windows"/>
  63.263 +        </condition>
  63.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  63.265 +            <isset property="debug.transport"/>
  63.266 +        </condition>
  63.267 +    </target>
  63.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  63.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  63.270 +            <attribute default="${main.class}" name="classname"/>
  63.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  63.272 +            <element name="customize" optional="true"/>
  63.273 +            <sequential>
  63.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  63.275 +                    <jvmarg line="${debug-args-line}"/>
  63.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  63.277 +                    <jvmarg line="${run.jvmargs}"/>
  63.278 +                    <classpath>
  63.279 +                        <path path="@{classpath}"/>
  63.280 +                    </classpath>
  63.281 +                    <syspropertyset>
  63.282 +                        <propertyref prefix="run-sys-prop."/>
  63.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  63.284 +                    </syspropertyset>
  63.285 +                    <customize/>
  63.286 +                </java>
  63.287 +            </sequential>
  63.288 +        </macrodef>
  63.289 +    </target>
  63.290 +    <target name="-init-macrodef-java">
  63.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  63.292 +            <attribute default="${main.class}" name="classname"/>
  63.293 +            <element name="customize" optional="true"/>
  63.294 +            <sequential>
  63.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  63.296 +                    <jvmarg line="${run.jvmargs}"/>
  63.297 +                    <classpath>
  63.298 +                        <path path="${run.classpath}"/>
  63.299 +                    </classpath>
  63.300 +                    <syspropertyset>
  63.301 +                        <propertyref prefix="run-sys-prop."/>
  63.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  63.303 +                    </syspropertyset>
  63.304 +                    <customize/>
  63.305 +                </java>
  63.306 +            </sequential>
  63.307 +        </macrodef>
  63.308 +    </target>
  63.309 +    <target name="-init-presetdef-jar">
  63.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  63.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  63.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  63.313 +            </jar>
  63.314 +        </presetdef>
  63.315 +    </target>
  63.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"/>
  63.317 +    <!--
  63.318 +                ===================
  63.319 +                COMPILATION SECTION
  63.320 +                ===================
  63.321 +            -->
  63.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  63.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  63.324 +    <target depends="init" name="-check-automatic-build">
  63.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  63.326 +    </target>
  63.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  63.328 +        <antcall target="clean"/>
  63.329 +    </target>
  63.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  63.331 +        <mkdir dir="${build.classes.dir}"/>
  63.332 +    </target>
  63.333 +    <target name="-pre-compile">
  63.334 +        <!-- Empty placeholder for easier customization. -->
  63.335 +        <!-- You can override this target in the ../build.xml file. -->
  63.336 +    </target>
  63.337 +    <target if="do.depend.true" name="-compile-depend">
  63.338 +        <j2seproject3:depend/>
  63.339 +    </target>
  63.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  63.341 +        <j2seproject3:javac/>
  63.342 +        <copy todir="${build.classes.dir}">
  63.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  63.344 +        </copy>
  63.345 +    </target>
  63.346 +    <target name="-post-compile">
  63.347 +        <!-- Empty placeholder for easier customization. -->
  63.348 +        <!-- You can override this target in the ../build.xml file. -->
  63.349 +    </target>
  63.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  63.351 +    <target name="-pre-compile-single">
  63.352 +        <!-- Empty placeholder for easier customization. -->
  63.353 +        <!-- You can override this target in the ../build.xml file. -->
  63.354 +    </target>
  63.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  63.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  63.357 +        <j2seproject3:force-recompile/>
  63.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  63.359 +    </target>
  63.360 +    <target name="-post-compile-single">
  63.361 +        <!-- Empty placeholder for easier customization. -->
  63.362 +        <!-- You can override this target in the ../build.xml file. -->
  63.363 +    </target>
  63.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  63.365 +    <!--
  63.366 +                ====================
  63.367 +                JAR BUILDING SECTION
  63.368 +                ====================
  63.369 +            -->
  63.370 +    <target depends="init" name="-pre-pre-jar">
  63.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  63.372 +        <mkdir dir="${dist.jar.dir}"/>
  63.373 +    </target>
  63.374 +    <target name="-pre-jar">
  63.375 +        <!-- Empty placeholder for easier customization. -->
  63.376 +        <!-- You can override this target in the ../build.xml file. -->
  63.377 +    </target>
  63.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  63.379 +        <j2seproject1:jar/>
  63.380 +    </target>
  63.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  63.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  63.383 +    </target>
  63.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">
  63.385 +        <j2seproject1:jar manifest="${manifest.file}">
  63.386 +            <j2seproject1:manifest>
  63.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  63.388 +            </j2seproject1:manifest>
  63.389 +        </j2seproject1:jar>
  63.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  63.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  63.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  63.393 +        <pathconvert property="run.classpath.with.dist.jar">
  63.394 +            <path path="${run.classpath}"/>
  63.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  63.396 +        </pathconvert>
  63.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  63.398 +    </target>
  63.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  63.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  63.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  63.402 +            <path path="${run.classpath}"/>
  63.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  63.404 +        </pathconvert>
  63.405 +        <pathconvert pathsep=" " property="jar.classpath">
  63.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  63.407 +            <chainedmapper>
  63.408 +                <flattenmapper/>
  63.409 +                <globmapper from="*" to="lib/*"/>
  63.410 +            </chainedmapper>
  63.411 +        </pathconvert>
  63.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  63.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  63.414 +            <fileset dir="${build.classes.dir}"/>
  63.415 +            <manifest>
  63.416 +                <attribute name="Main-Class" value="${main.class}"/>
  63.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  63.418 +            </manifest>
  63.419 +        </copylibs>
  63.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  63.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  63.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  63.423 +    </target>
  63.424 +    <target name="-post-jar">
  63.425 +        <!-- Empty placeholder for easier customization. -->
  63.426 +        <!-- You can override this target in the ../build.xml file. -->
  63.427 +    </target>
  63.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"/>
  63.429 +    <!--
  63.430 +                =================
  63.431 +                EXECUTION SECTION
  63.432 +                =================
  63.433 +            -->
  63.434 +    <target depends="init,compile" description="Run a main class." name="run">
  63.435 +        <j2seproject1:java>
  63.436 +            <customize>
  63.437 +                <arg line="${application.args}"/>
  63.438 +            </customize>
  63.439 +        </j2seproject1:java>
  63.440 +    </target>
  63.441 +    <target name="-do-not-recompile">
  63.442 +        <property name="javac.includes.binary" value=""/>
  63.443 +    </target>
  63.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  63.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  63.446 +        <j2seproject1:java classname="${run.class}"/>
  63.447 +    </target>
  63.448 +    <!--
  63.449 +                =================
  63.450 +                DEBUGGING SECTION
  63.451 +                =================
  63.452 +            -->
  63.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  63.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  63.455 +    </target>
  63.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  63.457 +        <j2seproject3:debug>
  63.458 +            <customize>
  63.459 +                <arg line="${application.args}"/>
  63.460 +            </customize>
  63.461 +        </j2seproject3:debug>
  63.462 +    </target>
  63.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  63.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  63.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  63.466 +    </target>
  63.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  63.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  63.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  63.470 +        <j2seproject3:debug classname="${debug.class}"/>
  63.471 +    </target>
  63.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  63.473 +    <target depends="init" name="-pre-debug-fix">
  63.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  63.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  63.476 +    </target>
  63.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  63.478 +        <j2seproject1:nbjpdareload/>
  63.479 +    </target>
  63.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  63.481 +    <!--
  63.482 +                ===============
  63.483 +                JAVADOC SECTION
  63.484 +                ===============
  63.485 +            -->
  63.486 +    <target depends="init" name="-javadoc-build">
  63.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  63.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}">
  63.489 +            <classpath>
  63.490 +                <path path="${javac.classpath}"/>
  63.491 +            </classpath>
  63.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  63.493 +                <filename name="**/*.java"/>
  63.494 +            </fileset>
  63.495 +        </javadoc>
  63.496 +    </target>
  63.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  63.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  63.499 +    </target>
  63.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  63.501 +    <!--
  63.502 +                =========================
  63.503 +                JUNIT COMPILATION SECTION
  63.504 +                =========================
  63.505 +            -->
  63.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  63.507 +        <mkdir dir="${build.test.classes.dir}"/>
  63.508 +    </target>
  63.509 +    <target name="-pre-compile-test">
  63.510 +        <!-- Empty placeholder for easier customization. -->
  63.511 +        <!-- You can override this target in the ../build.xml file. -->
  63.512 +    </target>
  63.513 +    <target if="do.depend.true" name="-compile-test-depend">
  63.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  63.515 +    </target>
  63.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  63.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  63.518 +        <copy todir="${build.test.classes.dir}">
  63.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  63.520 +        </copy>
  63.521 +    </target>
  63.522 +    <target name="-post-compile-test">
  63.523 +        <!-- Empty placeholder for easier customization. -->
  63.524 +        <!-- You can override this target in the ../build.xml file. -->
  63.525 +    </target>
  63.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  63.527 +    <target name="-pre-compile-test-single">
  63.528 +        <!-- Empty placeholder for easier customization. -->
  63.529 +        <!-- You can override this target in the ../build.xml file. -->
  63.530 +    </target>
  63.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  63.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  63.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  63.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}"/>
  63.535 +        <copy todir="${build.test.classes.dir}">
  63.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  63.537 +        </copy>
  63.538 +    </target>
  63.539 +    <target name="-post-compile-test-single">
  63.540 +        <!-- Empty placeholder for easier customization. -->
  63.541 +        <!-- You can override this target in the ../build.xml file. -->
  63.542 +    </target>
  63.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"/>
  63.544 +    <!--
  63.545 +                =======================
  63.546 +                JUNIT EXECUTION SECTION
  63.547 +                =======================
  63.548 +            -->
  63.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  63.550 +        <mkdir dir="${build.test.results.dir}"/>
  63.551 +    </target>
  63.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  63.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  63.554 +    </target>
  63.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  63.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  63.557 +    </target>
  63.558 +    <target depends="init" if="have.tests" name="test-report"/>
  63.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  63.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"/>
  63.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  63.562 +        <mkdir dir="${build.test.results.dir}"/>
  63.563 +    </target>
  63.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  63.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  63.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  63.567 +    </target>
  63.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  63.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  63.570 +    </target>
  63.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"/>
  63.572 +    <!--
  63.573 +                =======================
  63.574 +                JUNIT DEBUGGING SECTION
  63.575 +                =======================
  63.576 +            -->
  63.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  63.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  63.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  63.580 +        <delete file="${test.report.file}"/>
  63.581 +        <mkdir dir="${build.test.results.dir}"/>
  63.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}">
  63.583 +            <customize>
  63.584 +                <syspropertyset>
  63.585 +                    <propertyref prefix="test-sys-prop."/>
  63.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  63.587 +                </syspropertyset>
  63.588 +                <arg value="${test.class}"/>
  63.589 +                <arg value="showoutput=true"/>
  63.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  63.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  63.592 +            </customize>
  63.593 +        </j2seproject3:debug>
  63.594 +    </target>
  63.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  63.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  63.597 +    </target>
  63.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  63.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  63.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  63.601 +    </target>
  63.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  63.603 +    <!--
  63.604 +                =========================
  63.605 +                APPLET EXECUTION SECTION
  63.606 +                =========================
  63.607 +            -->
  63.608 +    <target depends="init,compile-single" name="run-applet">
  63.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  63.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  63.611 +            <customize>
  63.612 +                <arg value="${applet.url}"/>
  63.613 +            </customize>
  63.614 +        </j2seproject1:java>
  63.615 +    </target>
  63.616 +    <!--
  63.617 +                =========================
  63.618 +                APPLET DEBUGGING  SECTION
  63.619 +                =========================
  63.620 +            -->
  63.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  63.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  63.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  63.624 +            <customize>
  63.625 +                <arg value="${applet.url}"/>
  63.626 +            </customize>
  63.627 +        </j2seproject3:debug>
  63.628 +    </target>
  63.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  63.630 +    <!--
  63.631 +                ===============
  63.632 +                CLEANUP SECTION
  63.633 +                ===============
  63.634 +            -->
  63.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  63.636 +    <target depends="init" name="-do-clean">
  63.637 +        <delete dir="${build.dir}"/>
  63.638 +        <delete dir="${dist.dir}"/>
  63.639 +    </target>
  63.640 +    <target name="-post-clean">
  63.641 +        <!-- Empty placeholder for easier customization. -->
  63.642 +        <!-- You can override this target in the ../build.xml file. -->
  63.643 +    </target>
  63.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  63.645 +</project>
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/task2/solution06/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    64.3 @@ -0,0 +1,8 @@
    64.4 +build.xml.data.CRC32=2ab820eb
    64.5 +build.xml.script.CRC32=58a52595
    64.6 +build.xml.stylesheet.CRC32=be360661
    64.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    64.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    64.9 +nbproject/build-impl.xml.data.CRC32=ff801896
   64.10 +nbproject/build-impl.xml.script.CRC32=a0996c47
   64.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/task2/solution06/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    65.3 @@ -0,0 +1,68 @@
    65.4 +application.title=currency
    65.5 +application.vendor=apidesign.org
    65.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    65.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    65.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    65.9 +build.classes.dir=${build.dir}/classes
   65.10 +build.classes.excludes=**/*.java,**/*.form
   65.11 +# This directory is removed when the project is cleaned:
   65.12 +build.dir=build
   65.13 +build.generated.dir=${build.dir}/generated
   65.14 +# Only compile against the classpath explicitly listed here:
   65.15 +build.sysclasspath=ignore
   65.16 +build.test.classes.dir=${build.dir}/test/classes
   65.17 +build.test.results.dir=${build.dir}/test/results
   65.18 +debug.classpath=\
   65.19 +    ${run.classpath}
   65.20 +debug.test.classpath=\
   65.21 +    ${run.test.classpath}
   65.22 +# This directory is removed when the project is cleaned:
   65.23 +dist.dir=dist
   65.24 +dist.jar=${dist.dir}/currency.jar
   65.25 +dist.javadoc.dir=${dist.dir}/javadoc
   65.26 +excludes=
   65.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   65.28 +file.reference.src-apifest08=..
   65.29 +includes=**
   65.30 +jar.compress=false
   65.31 +javac.classpath=
   65.32 +# Space-separated list of extra javac options
   65.33 +javac.compilerargs=
   65.34 +javac.deprecation=false
   65.35 +javac.source=1.5
   65.36 +javac.target=1.5
   65.37 +javac.test.classpath=\
   65.38 +    ${javac.classpath}:\
   65.39 +    ${build.classes.dir}:\
   65.40 +    ${file.reference.junit-4.4.jar}
   65.41 +javadoc.additionalparam=
   65.42 +javadoc.author=false
   65.43 +javadoc.encoding=
   65.44 +javadoc.noindex=false
   65.45 +javadoc.nonavbar=false
   65.46 +javadoc.notree=false
   65.47 +javadoc.private=false
   65.48 +javadoc.splitindex=true
   65.49 +javadoc.use=true
   65.50 +javadoc.version=false
   65.51 +javadoc.windowtitle=
   65.52 +jnlp.codebase.type=local
   65.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   65.54 +jnlp.descriptor=application
   65.55 +jnlp.enabled=false
   65.56 +jnlp.offline-allowed=false
   65.57 +jnlp.signed=false
   65.58 +meta.inf.dir=${src.dir}/META-INF
   65.59 +platform.active=default_platform
   65.60 +run.classpath=\
   65.61 +    ${javac.classpath}:\
   65.62 +    ${build.classes.dir}
   65.63 +# Space-separated list of JVM arguments used when running the project
   65.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   65.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   65.66 +run.jvmargs=
   65.67 +run.test.classpath=\
   65.68 +    ${javac.test.classpath}:\
   65.69 +    ${build.test.classes.dir}
   65.70 +src.dir=src
   65.71 +test.src.dir=test
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/task2/solution06/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    66.3 @@ -0,0 +1,16 @@
    66.4 +<?xml version="1.0" encoding="UTF-8"?>
    66.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    66.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    66.7 +    <configuration>
    66.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    66.9 +            <name>Currency Convertor Solution 06</name>
   66.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   66.11 +            <source-roots>
   66.12 +                <root id="src.dir"/>
   66.13 +            </source-roots>
   66.14 +            <test-roots>
   66.15 +                <root id="test.src.dir"/>
   66.16 +            </test-roots>
   66.17 +        </data>
   66.18 +    </configuration>
   66.19 +</project>
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/Amount.java	Wed Oct 01 10:43:05 2008 +0200
    67.3 @@ -0,0 +1,81 @@
    67.4 +package org.apidesign.apifest08.currency;
    67.5 +
    67.6 +import static org.apidesign.apifest08.currency.Assert.notNull;
    67.7 +
    67.8 +import java.math.BigDecimal;
    67.9 +import java.math.RoundingMode;
   67.10 +import java.util.Currency;
   67.11 +
   67.12 +/**
   67.13 + * An amount representation. Amount is represented as composition of a value and 
   67.14 + * a currency.
   67.15 + */
   67.16 +public final class Amount {
   67.17 +	
   67.18 +	private final BigDecimal value;
   67.19 +	private final Currency currency;
   67.20 +	private final int scale;
   67.21 +	private final RoundingMode roundingMode;
   67.22 +	
   67.23 +	public static final RoundingMode DEFAULT_ROUNDING = RoundingMode.HALF_EVEN; 
   67.24 +	
   67.25 +	public Amount(final BigDecimal value, final Currency currency) {
   67.26 +		notNull(value, "value");
   67.27 +		notNull(currency, "currency");
   67.28 +		this.value = value;
   67.29 +		this.currency = currency;
   67.30 +		this.scale = currency.getDefaultFractionDigits();
   67.31 +		this.roundingMode = DEFAULT_ROUNDING;
   67.32 +	}
   67.33 +	
   67.34 +	public Amount(final BigDecimal value, final Currency currency, final RoundingMode roundingMode) {
   67.35 +		notNull(value, "value");
   67.36 +		notNull(currency, "currency");
   67.37 +		notNull(roundingMode, "roundingMode");
   67.38 +		
   67.39 +		this.value = value;
   67.40 +		this.currency = currency;
   67.41 +		this.scale = currency.getDefaultFractionDigits();
   67.42 +		this.roundingMode = roundingMode;
   67.43 +	}
   67.44 +	
   67.45 +	public Amount(final long value, final Currency currency) {
   67.46 +		this(BigDecimal.valueOf(value), currency);
   67.47 +	}
   67.48 +	
   67.49 +	public Amount(final String value, final Currency currency) {
   67.50 +		this(new BigDecimal(value), currency);
   67.51 +	}
   67.52 +	
   67.53 +	/**
   67.54 +	 * @return the value with scale of the associated currency and rounded by 
   67.55 +	 * the rounding mode. 
   67.56 +	 */
   67.57 +	public BigDecimal getValue() {
   67.58 +		return value.setScale(scale, roundingMode);
   67.59 +	}
   67.60 +	
   67.61 +	/**
   67.62 +	 * @return the raw (no explicit scale, no explicit rounding) value 
   67.63 +	 */
   67.64 +	public BigDecimal getRawValue() {
   67.65 +		return value;
   67.66 +	}
   67.67 +	
   67.68 +	public Currency getCurrency() {
   67.69 +		return currency;
   67.70 +	}
   67.71 +
   67.72 +	public int getScale() {
   67.73 +		return scale;
   67.74 +	}
   67.75 +
   67.76 +	public RoundingMode getRoundingMode() {
   67.77 +		return roundingMode;
   67.78 +	}
   67.79 +
   67.80 +	@Override
   67.81 +	public String toString() {
   67.82 +		return value + ",- " + currency.toString();
   67.83 +	}	
   67.84 +}
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/Assert.java	Wed Oct 01 10:43:05 2008 +0200
    68.3 @@ -0,0 +1,11 @@
    68.4 +package org.apidesign.apifest08.currency;
    68.5 +
    68.6 +public final class Assert {
    68.7 +	static void notNull(Object value, String argumentName) {
    68.8 +		if(value == null) {
    68.9 +			throw new IllegalArgumentException("The argument '" + argumentName + "' connot not be null");
   68.10 +		}
   68.11 +	}
   68.12 +}
   68.13 +
   68.14 +
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/ConversionException.java	Wed Oct 01 10:43:05 2008 +0200
    69.3 @@ -0,0 +1,26 @@
    69.4 +package org.apidesign.apifest08.currency;
    69.5 +
    69.6 +/**
    69.7 + * Indicates that a desired conversion cannot be performed.
    69.8 + */
    69.9 +public class ConversionException extends CurrencyException {
   69.10 +	
   69.11 +	private static final long serialVersionUID = 1L;
   69.12 +
   69.13 +	public ConversionException() {
   69.14 +		super();
   69.15 +	}
   69.16 +
   69.17 +	public ConversionException(String message, Throwable cause) {
   69.18 +		super(message, cause);		
   69.19 +	}
   69.20 +
   69.21 +	public ConversionException(String message) {
   69.22 +		super(message);
   69.23 +	}
   69.24 +
   69.25 +	public ConversionException(Throwable cause) {
   69.26 +		super(cause);
   69.27 +	}
   69.28 +	
   69.29 +}
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    70.3 @@ -0,0 +1,64 @@
    70.4 +package org.apidesign.apifest08.currency;
    70.5 +
    70.6 +import static org.apidesign.apifest08.currency.Assert.notNull;
    70.7 +
    70.8 +import java.math.BigDecimal;
    70.9 +import java.math.RoundingMode;
   70.10 +import java.util.Currency;
   70.11 +
   70.12 +public final class Convertor {
   70.13 +	
   70.14 +	private final Currency first;
   70.15 +	private final Currency second;
   70.16 +	private final BigDecimal rateValue; // a rate between the first currency and the second currency
   70.17 +	public static final BigDecimal one = new BigDecimal(1);	
   70.18 +	
   70.19 +	public Convertor(BigDecimal rateValue, Currency currencyFirst, Currency currencySecond) {
   70.20 +		notNull(currencyFirst, "currencyFirst");
   70.21 +		notNull(currencySecond, "currencySecond");		
   70.22 +		notNull(rateValue, "rateValue");
   70.23 +		
   70.24 +		this.rateValue = rateValue;
   70.25 +		this.first = currencyFirst;
   70.26 +		this.second = currencySecond;
   70.27 +	}
   70.28 +    	
   70.29 +	/**
   70.30 +	 * Converts an amount value between the two currencies of this converter.
   70.31 +	 *  
   70.32 +	 * @param amount an amount
   70.33 +	 * @param fromCurrency an amount currency
   70.34 +	 * @param toCurrency to a target currency
   70.35 +	 * @return a converted amount value
   70.36 +	 * 
   70.37 +	 * @throws ConversionException if the conversion fails
   70.38 +	 * @throws UnsupportedConversionException if the conversion between a given currencies is not supported.
   70.39 +	 */
   70.40 +	public Amount convert(BigDecimal amount, Currency fromCurrency, Currency toCurrency) throws ConversionException {
   70.41 +		notNull(amount, "amount");
   70.42 +		notNull(fromCurrency, "fromCurrency");
   70.43 +		notNull(toCurrency, "toCurrency");
   70.44 +		
   70.45 +		if((fromCurrency != first && fromCurrency != second) || (toCurrency != first && toCurrency != second)) {
   70.46 +			throw new UnsupportedConversionException(fromCurrency, toCurrency);
   70.47 +		}		
   70.48 +
   70.49 +		BigDecimal rateValue = getRateValue(fromCurrency, toCurrency);
   70.50 +		BigDecimal result = rateValue.multiply(amount);			
   70.51 +		return new Amount(result, toCurrency);	
   70.52 +	}
   70.53 +	
   70.54 +	private BigDecimal getRateValue(Currency fromCurrency, Currency toCurrency) {		
   70.55 +		
   70.56 +		BigDecimal retVal;
   70.57 +		
   70.58 +		if(first == fromCurrency) {
   70.59 +			retVal = rateValue;
   70.60 +		} else {	
   70.61 +			//reverse rate	
   70.62 +			retVal = one.divide(rateValue, 10 ,RoundingMode.HALF_UP);
   70.63 +		}
   70.64 +		
   70.65 +		return retVal;
   70.66 +	}
   70.67 +}
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/CurrencyException.java	Wed Oct 01 10:43:05 2008 +0200
    71.3 @@ -0,0 +1,25 @@
    71.4 +package org.apidesign.apifest08.currency;
    71.5 +
    71.6 +/**
    71.7 + * Top level runtime exception for 'currency' API.
    71.8 + */
    71.9 +public class CurrencyException extends RuntimeException{
   71.10 +
   71.11 +	private static final long serialVersionUID = 1L;
   71.12 +
   71.13 +	public CurrencyException() {
   71.14 +		super();		
   71.15 +	}
   71.16 +
   71.17 +	public CurrencyException(String message, Throwable cause) {
   71.18 +		super(message, cause);		
   71.19 +	}
   71.20 +
   71.21 +	public CurrencyException(String message) {
   71.22 +		super(message);		
   71.23 +	}
   71.24 +
   71.25 +	public CurrencyException(Throwable cause) {
   71.26 +		super(cause);		
   71.27 +	}
   71.28 +}
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/task2/solution06/src/org/apidesign/apifest08/currency/UnsupportedConversionException.java	Wed Oct 01 10:43:05 2008 +0200
    72.3 @@ -0,0 +1,27 @@
    72.4 +package org.apidesign.apifest08.currency;
    72.5 +
    72.6 +import java.util.Currency;
    72.7 +
    72.8 +public final class UnsupportedConversionException extends ConversionException{
    72.9 +
   72.10 +	private static final long serialVersionUID = 1L; 
   72.11 +	
   72.12 +	private Currency from;
   72.13 +	private Currency to;
   72.14 +
   72.15 +	public UnsupportedConversionException(Currency from, Currency to) {
   72.16 +		super("Conversion from  the currency " + from + " to the currency " + to + " or vice versa in not supported.");
   72.17 +		this.from = from;
   72.18 +		this.to = to;
   72.19 +	}
   72.20 +
   72.21 +	public Currency getFrom() {
   72.22 +		return from;
   72.23 +	}
   72.24 +
   72.25 +	public Currency getTo() {
   72.26 +		return to;
   72.27 +	}
   72.28 +	
   72.29 +	
   72.30 +}
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/task2/solution06/test/org/apidesign/apifest08/test/Currencies.java	Wed Oct 01 10:43:05 2008 +0200
    73.3 @@ -0,0 +1,9 @@
    73.4 +package org.apidesign.apifest08.test;
    73.5 +
    73.6 +import java.util.Currency;
    73.7 +
    73.8 +public class Currencies {
    73.9 +	public static final Currency CZK = Currency.getInstance("CZK");
   73.10 +	public static final Currency SKK = Currency.getInstance("SKK");
   73.11 +	public static final Currency USD = Currency.getInstance("USD");
   73.12 +}
    74.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.2 +++ b/task2/solution06/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    74.3 @@ -0,0 +1,136 @@
    74.4 +package org.apidesign.apifest08.test;
    74.5 +
    74.6 +import static org.apidesign.apifest08.test.Currencies.CZK;
    74.7 +import static org.apidesign.apifest08.test.Currencies.SKK;
    74.8 +import static org.apidesign.apifest08.test.Currencies.USD;
    74.9 +
   74.10 +import java.math.BigDecimal;
   74.11 +
   74.12 +import junit.framework.TestCase;
   74.13 +
   74.14 +import org.apidesign.apifest08.currency.Amount;
   74.15 +import org.apidesign.apifest08.currency.ConversionException;
   74.16 +import org.apidesign.apifest08.currency.Convertor;
   74.17 +import org.apidesign.apifest08.currency.UnsupportedConversionException;
   74.18 +
   74.19 +/** Finish the Convertor API, and then write bodies of methods inside
   74.20 + * of this class to match the given tasks. To fullfil your task, use the
   74.21 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   74.22 + * Do not you reflection, or other hacks as your code
   74.23 + * shall run without any runtime permissions.
   74.24 + */
   74.25 +public class Task1Test extends TestCase {
   74.26 +    public Task1Test(String testName) {
   74.27 +        super(testName);
   74.28 +    }
   74.29 +
   74.30 +    @Override
   74.31 +    protected void setUp() throws Exception {
   74.32 +    }
   74.33 +
   74.34 +    @Override
   74.35 +    protected void tearDown() throws Exception {
   74.36 +    }
   74.37 +
   74.38 +    /** Create convertor that understands two currencies, CZK and
   74.39 +     *  USD. Make 1 USD == 17 CZK.
   74.40 +     *
   74.41 +     * Creation of the convertor shall not require subclassing of any class
   74.42 +     * or interface on the client side.
   74.43 +     *
   74.44 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   74.45 +     */
   74.46 +    public static Convertor createCZKtoUSD() {
   74.47 +        return new Convertor(new BigDecimal(17), USD, CZK);
   74.48 +    }
   74.49 +
   74.50 +    /** Create convertor that understands two currencies, CZK and
   74.51 +     *  SKK. Make 100 SKK == 80 CZK.
   74.52 +     *
   74.53 +     * Creation of the convertor shall not require subclassing of any class
   74.54 +     * or interface on the client side.
   74.55 +     * 
   74.56 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   74.57 +     */
   74.58 +    public static Convertor createSKKtoCZK() {
   74.59 +    	return new Convertor(new BigDecimal("0.8"), SKK, CZK);
   74.60 +    }
   74.61 +    
   74.62 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   74.63 +     * with it.
   74.64 +     */
   74.65 +    public void testCurrencyCZKUSD() throws Exception {
   74.66 +        Convertor c = createCZKtoUSD();
   74.67 +        // convert $5 to CZK using c:
   74.68 +        Amount result =  c.convert(new BigDecimal(5), USD, CZK);
   74.69 +        assertEquals("Result is 85 CZK", 85, result.getValue().intValue());
   74.70 +
   74.71 +        // convert $8 to CZK
   74.72 +        result =  c.convert(new BigDecimal(8), USD, CZK);        
   74.73 +        assertEquals("Result is 136 CZK", 136, result.getValue().intValue());
   74.74 +
   74.75 +        // convert 1003CZK to USD
   74.76 +        result =  c.convert(new BigDecimal(1003), CZK, USD);
   74.77 +        assertEquals("Result is 59 USD", 59, result.getValue().intValue());
   74.78 +    }
   74.79 +
   74.80 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   74.81 +     * with it.
   74.82 +     */
   74.83 +    public void testCurrencySKKCZK() throws Exception {
   74.84 +        Convertor c = createSKKtoCZK();
   74.85 +        // convert 16CZK using c:
   74.86 +        Amount result =  c.convert(new BigDecimal(16), CZK, SKK);
   74.87 +        assertEquals("Result is 20 SKK", 20, result.getValue().intValue());
   74.88 +
   74.89 +        // convert 500SKK to CZK
   74.90 +        result =  c.convert(new BigDecimal(500), SKK, CZK);
   74.91 +        assertEquals("Result is 400 CZK", 400, result.getValue().intValue());
   74.92 +    }
   74.93 +    
   74.94 +    
   74.95 +    /**
   74.96 +     *  Verify that the CZK to USD convertor knows nothing about SKK.
   74.97 +     */
   74.98 +     public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
   74.99 +    	 Convertor c = createCZKtoUSD();
  74.100 +    	 // convert $5 to SKK, the API shall say this is not possible
  74.101 +    	 try {
  74.102 +    		 c.convert(new BigDecimal(5), USD, SKK);
  74.103 +    		 fail("convert $5 to SKK, the API shall say this is not possible");
  74.104 +    	 } catch (ConversionException e) {
  74.105 +    		 //expected
  74.106 +    	 }
  74.107 +    	 
  74.108 +    	 // convert 500 SKK to CZK, the API shall say this is not possible
  74.109 +    	 
  74.110 +    	 try {
  74.111 +    		 c.convert(new BigDecimal("500"), SKK, CZK);
  74.112 +    		 fail("convert 500 SKK to CZK, the API shall say this is not possible");
  74.113 +    	 } catch (ConversionException e) {
  74.114 +    		 //expected
  74.115 +    	 }
  74.116 +     }
  74.117 +    
  74.118 +    /** 
  74.119 +     * Verify that the CZK to SKK convertor knows nothing about USD.
  74.120 +     */
  74.121 +    public void testCannotConvertToSKKwithCZKSKKConvertor() throws Exception {
  74.122 +    	Convertor c = createSKKtoCZK();
  74.123 +    	// convert $5 to SKK, the API shall say this is not possible
  74.124 +    	try {
  74.125 +    		c.convert(new BigDecimal(5), USD, SKK);
  74.126 +    		fail("convert $5 to SKK, the API shall say this is not possible");
  74.127 +    	} catch(ConversionException e) {
  74.128 +    		//expected
  74.129 +    	}
  74.130 +    	
  74.131 +    	try {
  74.132 +    		c.convert(new BigDecimal(500), CZK, USD);	
  74.133 +    		fail("convert 500 CZK to USD, the API shall say this is not possible");
  74.134 +    	} catch(ConversionException e) {
  74.135 +    		//expected
  74.136 +    	}
  74.137 +    } 
  74.138 +}
  74.139 +
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/task2/solution07/build.xml	Wed Oct 01 10:43:05 2008 +0200
    75.3 @@ -0,0 +1,69 @@
    75.4 +<?xml version="1.0" encoding="UTF-8"?>
    75.5 +<!-- You may freely edit this file. See commented blocks below for -->
    75.6 +<!-- some examples of how to customize the build. -->
    75.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    75.8 +<project name="currency" default="default" basedir=".">
    75.9 +    <description>Builds, tests, and runs the project.</description>
   75.10 +    <import file="nbproject/build-impl.xml"/>
   75.11 +    <!--
   75.12 +
   75.13 +    There exist several targets which are by default empty and which can be 
   75.14 +    used for execution of your tasks. These targets are usually executed 
   75.15 +    before and after some main targets. They are: 
   75.16 +
   75.17 +      -pre-init:                 called before initialization of project properties
   75.18 +      -post-init:                called after initialization of project properties
   75.19 +      -pre-compile:              called before javac compilation
   75.20 +      -post-compile:             called after javac compilation
   75.21 +      -pre-compile-single:       called before javac compilation of single file
   75.22 +      -post-compile-single:      called after javac compilation of single file
   75.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   75.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   75.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   75.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   75.27 +      -pre-jar:                  called before JAR building
   75.28 +      -post-jar:                 called after JAR building
   75.29 +      -post-clean:               called after cleaning build products
   75.30 +
   75.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   75.32 +
   75.33 +    Example of inserting an obfuscator after compilation could look like this:
   75.34 +
   75.35 +        <target name="-post-compile">
   75.36 +            <obfuscate>
   75.37 +                <fileset dir="${build.classes.dir}"/>
   75.38 +            </obfuscate>
   75.39 +        </target>
   75.40 +
   75.41 +    For list of available properties check the imported 
   75.42 +    nbproject/build-impl.xml file. 
   75.43 +
   75.44 +
   75.45 +    Another way to customize the build is by overriding existing main targets.
   75.46 +    The targets of interest are: 
   75.47 +
   75.48 +      -init-macrodef-javac:     defines macro for javac compilation
   75.49 +      -init-macrodef-junit:     defines macro for junit execution
   75.50 +      -init-macrodef-debug:     defines macro for class debugging
   75.51 +      -init-macrodef-java:      defines macro for class execution
   75.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   75.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   75.54 +      run:                      execution of project 
   75.55 +      -javadoc-build:           Javadoc generation
   75.56 +      test-report:              JUnit report generation
   75.57 +
   75.58 +    An example of overriding the target for project execution could look like this:
   75.59 +
   75.60 +        <target name="run" depends="currency-impl.jar">
   75.61 +            <exec dir="bin" executable="launcher.exe">
   75.62 +                <arg file="${dist.jar}"/>
   75.63 +            </exec>
   75.64 +        </target>
   75.65 +
   75.66 +    Notice that the overridden target depends on the jar target and not only on 
   75.67 +    the compile target as the regular run target does. Again, for a list of available 
   75.68 +    properties which you can use, check the target you are overriding in the
   75.69 +    nbproject/build-impl.xml file. 
   75.70 +
   75.71 +    -->
   75.72 +</project>
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/task2/solution07/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    76.3 @@ -0,0 +1,642 @@
    76.4 +<?xml version="1.0" encoding="UTF-8"?>
    76.5 +<!--
    76.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    76.7 +***         EDIT ../build.xml INSTEAD         ***
    76.8 +
    76.9 +For the purpose of easier reading the script
   76.10 +is divided into following sections:
   76.11 +
   76.12 +  - initialization
   76.13 +  - compilation
   76.14 +  - jar
   76.15 +  - execution
   76.16 +  - debugging
   76.17 +  - javadoc
   76.18 +  - junit compilation
   76.19 +  - junit execution
   76.20 +  - junit debugging
   76.21 +  - applet
   76.22 +  - cleanup
   76.23 +
   76.24 +        -->
   76.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_07-impl">
   76.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   76.27 +    <!-- 
   76.28 +                ======================
   76.29 +                INITIALIZATION SECTION 
   76.30 +                ======================
   76.31 +            -->
   76.32 +    <target name="-pre-init">
   76.33 +        <!-- Empty placeholder for easier customization. -->
   76.34 +        <!-- You can override this target in the ../build.xml file. -->
   76.35 +    </target>
   76.36 +    <target depends="-pre-init" name="-init-private">
   76.37 +        <property file="nbproject/private/config.properties"/>
   76.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   76.39 +        <property file="nbproject/private/private.properties"/>
   76.40 +    </target>
   76.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   76.42 +        <property file="${user.properties.file}"/>
   76.43 +        <!-- The two properties below are usually overridden -->
   76.44 +        <!-- by the active platform. Just a fallback. -->
   76.45 +        <property name="default.javac.source" value="1.4"/>
   76.46 +        <property name="default.javac.target" value="1.4"/>
   76.47 +    </target>
   76.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   76.49 +        <property file="nbproject/configs/${config}.properties"/>
   76.50 +        <property file="nbproject/project.properties"/>
   76.51 +    </target>
   76.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   76.53 +        <available file="${manifest.file}" property="manifest.available"/>
   76.54 +        <condition property="manifest.available+main.class">
   76.55 +            <and>
   76.56 +                <isset property="manifest.available"/>
   76.57 +                <isset property="main.class"/>
   76.58 +                <not>
   76.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   76.60 +                </not>
   76.61 +            </and>
   76.62 +        </condition>
   76.63 +        <condition property="manifest.available+main.class+mkdist.available">
   76.64 +            <and>
   76.65 +                <istrue value="${manifest.available+main.class}"/>
   76.66 +                <isset property="libs.CopyLibs.classpath"/>
   76.67 +            </and>
   76.68 +        </condition>
   76.69 +        <condition property="have.tests">
   76.70 +            <or>
   76.71 +                <available file="${test.src.dir}"/>
   76.72 +            </or>
   76.73 +        </condition>
   76.74 +        <condition property="have.sources">
   76.75 +            <or>
   76.76 +                <available file="${src.dir}"/>
   76.77 +            </or>
   76.78 +        </condition>
   76.79 +        <condition property="netbeans.home+have.tests">
   76.80 +            <and>
   76.81 +                <isset property="netbeans.home"/>
   76.82 +                <isset property="have.tests"/>
   76.83 +            </and>
   76.84 +        </condition>
   76.85 +        <condition property="no.javadoc.preview">
   76.86 +            <and>
   76.87 +                <isset property="javadoc.preview"/>
   76.88 +                <isfalse value="${javadoc.preview}"/>
   76.89 +            </and>
   76.90 +        </condition>
   76.91 +        <property name="run.jvmargs" value=""/>
   76.92 +        <property name="javac.compilerargs" value=""/>
   76.93 +        <property name="work.dir" value="${basedir}"/>
   76.94 +        <condition property="no.deps">
   76.95 +            <and>
   76.96 +                <istrue value="${no.dependencies}"/>
   76.97 +            </and>
   76.98 +        </condition>
   76.99 +        <property name="javac.debug" value="true"/>
  76.100 +        <property name="javadoc.preview" value="true"/>
  76.101 +        <property name="application.args" value=""/>
  76.102 +        <property name="source.encoding" value="${file.encoding}"/>
  76.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  76.104 +            <and>
  76.105 +                <isset property="javadoc.encoding"/>
  76.106 +                <not>
  76.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  76.108 +                </not>
  76.109 +            </and>
  76.110 +        </condition>
  76.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  76.112 +        <property name="includes" value="**"/>
  76.113 +        <property name="excludes" value=""/>
  76.114 +        <property name="do.depend" value="false"/>
  76.115 +        <condition property="do.depend.true">
  76.116 +            <istrue value="${do.depend}"/>
  76.117 +        </condition>
  76.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  76.119 +            <and>
  76.120 +                <isset property="jaxws.endorsed.dir"/>
  76.121 +                <available file="nbproject/jaxws-build.xml"/>
  76.122 +            </and>
  76.123 +        </condition>
  76.124 +    </target>
  76.125 +    <target name="-post-init">
  76.126 +        <!-- Empty placeholder for easier customization. -->
  76.127 +        <!-- You can override this target in the ../build.xml file. -->
  76.128 +    </target>
  76.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  76.130 +        <fail unless="src.dir">Must set src.dir</fail>
  76.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  76.132 +        <fail unless="build.dir">Must set build.dir</fail>
  76.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  76.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  76.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  76.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  76.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  76.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  76.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  76.140 +    </target>
  76.141 +    <target name="-init-macrodef-property">
  76.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  76.143 +            <attribute name="name"/>
  76.144 +            <attribute name="value"/>
  76.145 +            <sequential>
  76.146 +                <property name="@{name}" value="${@{value}}"/>
  76.147 +            </sequential>
  76.148 +        </macrodef>
  76.149 +    </target>
  76.150 +    <target name="-init-macrodef-javac">
  76.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  76.152 +            <attribute default="${src.dir}" name="srcdir"/>
  76.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  76.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  76.155 +            <attribute default="${includes}" name="includes"/>
  76.156 +            <attribute default="${excludes}" name="excludes"/>
  76.157 +            <attribute default="${javac.debug}" name="debug"/>
  76.158 +            <attribute default="" name="sourcepath"/>
  76.159 +            <element name="customize" optional="true"/>
  76.160 +            <sequential>
  76.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}">
  76.162 +                    <classpath>
  76.163 +                        <path path="@{classpath}"/>
  76.164 +                    </classpath>
  76.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  76.166 +                    <customize/>
  76.167 +                </javac>
  76.168 +            </sequential>
  76.169 +        </macrodef>
  76.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  76.171 +            <attribute default="${src.dir}" name="srcdir"/>
  76.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  76.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  76.174 +            <sequential>
  76.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  76.176 +                    <classpath>
  76.177 +                        <path path="@{classpath}"/>
  76.178 +                    </classpath>
  76.179 +                </depend>
  76.180 +            </sequential>
  76.181 +        </macrodef>
  76.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  76.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  76.184 +            <sequential>
  76.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  76.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  76.187 +                    <path>
  76.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  76.189 +                    </path>
  76.190 +                    <globmapper from="*.java" to="*.class"/>
  76.191 +                </pathconvert>
  76.192 +                <delete>
  76.193 +                    <files includes="${javac.includes.binary}"/>
  76.194 +                </delete>
  76.195 +            </sequential>
  76.196 +        </macrodef>
  76.197 +    </target>
  76.198 +    <target name="-init-macrodef-junit">
  76.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  76.200 +            <attribute default="${includes}" name="includes"/>
  76.201 +            <attribute default="${excludes}" name="excludes"/>
  76.202 +            <attribute default="**" name="testincludes"/>
  76.203 +            <sequential>
  76.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  76.205 +                    <batchtest todir="${build.test.results.dir}">
  76.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  76.207 +                            <filename name="@{testincludes}"/>
  76.208 +                        </fileset>
  76.209 +                    </batchtest>
  76.210 +                    <classpath>
  76.211 +                        <path path="${run.test.classpath}"/>
  76.212 +                    </classpath>
  76.213 +                    <syspropertyset>
  76.214 +                        <propertyref prefix="test-sys-prop."/>
  76.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  76.216 +                    </syspropertyset>
  76.217 +                    <formatter type="brief" usefile="false"/>
  76.218 +                    <formatter type="xml"/>
  76.219 +                    <jvmarg line="${run.jvmargs}"/>
  76.220 +                </junit>
  76.221 +            </sequential>
  76.222 +        </macrodef>
  76.223 +    </target>
  76.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  76.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  76.226 +            <attribute default="${main.class}" name="name"/>
  76.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  76.228 +            <attribute default="" name="stopclassname"/>
  76.229 +            <sequential>
  76.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  76.231 +                    <classpath>
  76.232 +                        <path path="@{classpath}"/>
  76.233 +                    </classpath>
  76.234 +                </nbjpdastart>
  76.235 +            </sequential>
  76.236 +        </macrodef>
  76.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  76.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  76.239 +            <sequential>
  76.240 +                <nbjpdareload>
  76.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  76.242 +                        <include name="${fix.includes}*.class"/>
  76.243 +                    </fileset>
  76.244 +                </nbjpdareload>
  76.245 +            </sequential>
  76.246 +        </macrodef>
  76.247 +    </target>
  76.248 +    <target name="-init-debug-args">
  76.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  76.250 +        <condition property="have-jdk-older-than-1.4">
  76.251 +            <or>
  76.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  76.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  76.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  76.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  76.256 +            </or>
  76.257 +        </condition>
  76.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  76.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  76.260 +        </condition>
  76.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  76.262 +            <os family="windows"/>
  76.263 +        </condition>
  76.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  76.265 +            <isset property="debug.transport"/>
  76.266 +        </condition>
  76.267 +    </target>
  76.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  76.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  76.270 +            <attribute default="${main.class}" name="classname"/>
  76.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  76.272 +            <element name="customize" optional="true"/>
  76.273 +            <sequential>
  76.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  76.275 +                    <jvmarg line="${debug-args-line}"/>
  76.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  76.277 +                    <jvmarg line="${run.jvmargs}"/>
  76.278 +                    <classpath>
  76.279 +                        <path path="@{classpath}"/>
  76.280 +                    </classpath>
  76.281 +                    <syspropertyset>
  76.282 +                        <propertyref prefix="run-sys-prop."/>
  76.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  76.284 +                    </syspropertyset>
  76.285 +                    <customize/>
  76.286 +                </java>
  76.287 +            </sequential>
  76.288 +        </macrodef>
  76.289 +    </target>
  76.290 +    <target name="-init-macrodef-java">
  76.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  76.292 +            <attribute default="${main.class}" name="classname"/>
  76.293 +            <element name="customize" optional="true"/>
  76.294 +            <sequential>
  76.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  76.296 +                    <jvmarg line="${run.jvmargs}"/>
  76.297 +                    <classpath>
  76.298 +                        <path path="${run.classpath}"/>
  76.299 +                    </classpath>
  76.300 +                    <syspropertyset>
  76.301 +                        <propertyref prefix="run-sys-prop."/>
  76.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  76.303 +                    </syspropertyset>
  76.304 +                    <customize/>
  76.305 +                </java>
  76.306 +            </sequential>
  76.307 +        </macrodef>
  76.308 +    </target>
  76.309 +    <target name="-init-presetdef-jar">
  76.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  76.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  76.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  76.313 +            </jar>
  76.314 +        </presetdef>
  76.315 +    </target>
  76.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"/>
  76.317 +    <!--
  76.318 +                ===================
  76.319 +                COMPILATION SECTION
  76.320 +                ===================
  76.321 +            -->
  76.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  76.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  76.324 +    <target depends="init" name="-check-automatic-build">
  76.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  76.326 +    </target>
  76.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  76.328 +        <antcall target="clean"/>
  76.329 +    </target>
  76.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  76.331 +        <mkdir dir="${build.classes.dir}"/>
  76.332 +    </target>
  76.333 +    <target name="-pre-compile">
  76.334 +        <!-- Empty placeholder for easier customization. -->
  76.335 +        <!-- You can override this target in the ../build.xml file. -->
  76.336 +    </target>
  76.337 +    <target if="do.depend.true" name="-compile-depend">
  76.338 +        <j2seproject3:depend/>
  76.339 +    </target>
  76.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  76.341 +        <j2seproject3:javac/>
  76.342 +        <copy todir="${build.classes.dir}">
  76.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  76.344 +        </copy>
  76.345 +    </target>
  76.346 +    <target name="-post-compile">
  76.347 +        <!-- Empty placeholder for easier customization. -->
  76.348 +        <!-- You can override this target in the ../build.xml file. -->
  76.349 +    </target>
  76.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  76.351 +    <target name="-pre-compile-single">
  76.352 +        <!-- Empty placeholder for easier customization. -->
  76.353 +        <!-- You can override this target in the ../build.xml file. -->
  76.354 +    </target>
  76.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  76.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  76.357 +        <j2seproject3:force-recompile/>
  76.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  76.359 +    </target>
  76.360 +    <target name="-post-compile-single">
  76.361 +        <!-- Empty placeholder for easier customization. -->
  76.362 +        <!-- You can override this target in the ../build.xml file. -->
  76.363 +    </target>
  76.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  76.365 +    <!--
  76.366 +                ====================
  76.367 +                JAR BUILDING SECTION
  76.368 +                ====================
  76.369 +            -->
  76.370 +    <target depends="init" name="-pre-pre-jar">
  76.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  76.372 +        <mkdir dir="${dist.jar.dir}"/>
  76.373 +    </target>
  76.374 +    <target name="-pre-jar">
  76.375 +        <!-- Empty placeholder for easier customization. -->
  76.376 +        <!-- You can override this target in the ../build.xml file. -->
  76.377 +    </target>
  76.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  76.379 +        <j2seproject1:jar/>
  76.380 +    </target>
  76.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  76.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  76.383 +    </target>
  76.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">
  76.385 +        <j2seproject1:jar manifest="${manifest.file}">
  76.386 +            <j2seproject1:manifest>
  76.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  76.388 +            </j2seproject1:manifest>
  76.389 +        </j2seproject1:jar>
  76.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  76.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  76.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  76.393 +        <pathconvert property="run.classpath.with.dist.jar">
  76.394 +            <path path="${run.classpath}"/>
  76.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  76.396 +        </pathconvert>
  76.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  76.398 +    </target>
  76.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  76.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  76.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  76.402 +            <path path="${run.classpath}"/>
  76.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  76.404 +        </pathconvert>
  76.405 +        <pathconvert pathsep=" " property="jar.classpath">
  76.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  76.407 +            <chainedmapper>
  76.408 +                <flattenmapper/>
  76.409 +                <globmapper from="*" to="lib/*"/>
  76.410 +            </chainedmapper>
  76.411 +        </pathconvert>
  76.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  76.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  76.414 +            <fileset dir="${build.classes.dir}"/>
  76.415 +            <manifest>
  76.416 +                <attribute name="Main-Class" value="${main.class}"/>
  76.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  76.418 +            </manifest>
  76.419 +        </copylibs>
  76.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  76.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  76.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  76.423 +    </target>
  76.424 +    <target name="-post-jar">
  76.425 +        <!-- Empty placeholder for easier customization. -->
  76.426 +        <!-- You can override this target in the ../build.xml file. -->
  76.427 +    </target>
  76.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"/>
  76.429 +    <!--
  76.430 +                =================
  76.431 +                EXECUTION SECTION
  76.432 +                =================
  76.433 +            -->
  76.434 +    <target depends="init,compile" description="Run a main class." name="run">
  76.435 +        <j2seproject1:java>
  76.436 +            <customize>
  76.437 +                <arg line="${application.args}"/>
  76.438 +            </customize>
  76.439 +        </j2seproject1:java>
  76.440 +    </target>
  76.441 +    <target name="-do-not-recompile">
  76.442 +        <property name="javac.includes.binary" value=""/>
  76.443 +    </target>
  76.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  76.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  76.446 +        <j2seproject1:java classname="${run.class}"/>
  76.447 +    </target>
  76.448 +    <!--
  76.449 +                =================
  76.450 +                DEBUGGING SECTION
  76.451 +                =================
  76.452 +            -->
  76.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  76.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  76.455 +    </target>
  76.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  76.457 +        <j2seproject3:debug>
  76.458 +            <customize>
  76.459 +                <arg line="${application.args}"/>
  76.460 +            </customize>
  76.461 +        </j2seproject3:debug>
  76.462 +    </target>
  76.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  76.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  76.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  76.466 +    </target>
  76.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  76.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  76.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  76.470 +        <j2seproject3:debug classname="${debug.class}"/>
  76.471 +    </target>
  76.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  76.473 +    <target depends="init" name="-pre-debug-fix">
  76.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  76.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  76.476 +    </target>
  76.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  76.478 +        <j2seproject1:nbjpdareload/>
  76.479 +    </target>
  76.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  76.481 +    <!--
  76.482 +                ===============
  76.483 +                JAVADOC SECTION
  76.484 +                ===============
  76.485 +            -->
  76.486 +    <target depends="init" name="-javadoc-build">
  76.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  76.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}">
  76.489 +            <classpath>
  76.490 +                <path path="${javac.classpath}"/>
  76.491 +            </classpath>
  76.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  76.493 +                <filename name="**/*.java"/>
  76.494 +            </fileset>
  76.495 +        </javadoc>
  76.496 +    </target>
  76.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  76.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  76.499 +    </target>
  76.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  76.501 +    <!--
  76.502 +                =========================
  76.503 +                JUNIT COMPILATION SECTION
  76.504 +                =========================
  76.505 +            -->
  76.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  76.507 +        <mkdir dir="${build.test.classes.dir}"/>
  76.508 +    </target>
  76.509 +    <target name="-pre-compile-test">
  76.510 +        <!-- Empty placeholder for easier customization. -->
  76.511 +        <!-- You can override this target in the ../build.xml file. -->
  76.512 +    </target>
  76.513 +    <target if="do.depend.true" name="-compile-test-depend">
  76.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  76.515 +    </target>
  76.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  76.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  76.518 +        <copy todir="${build.test.classes.dir}">
  76.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  76.520 +        </copy>
  76.521 +    </target>
  76.522 +    <target name="-post-compile-test">
  76.523 +        <!-- Empty placeholder for easier customization. -->
  76.524 +        <!-- You can override this target in the ../build.xml file. -->
  76.525 +    </target>
  76.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  76.527 +    <target name="-pre-compile-test-single">
  76.528 +        <!-- Empty placeholder for easier customization. -->
  76.529 +        <!-- You can override this target in the ../build.xml file. -->
  76.530 +    </target>
  76.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  76.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  76.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  76.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}"/>
  76.535 +        <copy todir="${build.test.classes.dir}">
  76.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  76.537 +        </copy>
  76.538 +    </target>
  76.539 +    <target name="-post-compile-test-single">
  76.540 +        <!-- Empty placeholder for easier customization. -->
  76.541 +        <!-- You can override this target in the ../build.xml file. -->
  76.542 +    </target>
  76.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"/>
  76.544 +    <!--
  76.545 +                =======================
  76.546 +                JUNIT EXECUTION SECTION
  76.547 +                =======================
  76.548 +            -->
  76.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  76.550 +        <mkdir dir="${build.test.results.dir}"/>
  76.551 +    </target>
  76.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  76.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  76.554 +    </target>
  76.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  76.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  76.557 +    </target>
  76.558 +    <target depends="init" if="have.tests" name="test-report"/>
  76.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  76.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"/>
  76.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  76.562 +        <mkdir dir="${build.test.results.dir}"/>
  76.563 +    </target>
  76.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  76.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  76.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  76.567 +    </target>
  76.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  76.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  76.570 +    </target>
  76.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"/>
  76.572 +    <!--
  76.573 +                =======================
  76.574 +                JUNIT DEBUGGING SECTION
  76.575 +                =======================
  76.576 +            -->
  76.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  76.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  76.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  76.580 +        <delete file="${test.report.file}"/>
  76.581 +        <mkdir dir="${build.test.results.dir}"/>
  76.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}">
  76.583 +            <customize>
  76.584 +                <syspropertyset>
  76.585 +                    <propertyref prefix="test-sys-prop."/>
  76.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  76.587 +                </syspropertyset>
  76.588 +                <arg value="${test.class}"/>
  76.589 +                <arg value="showoutput=true"/>
  76.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  76.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  76.592 +            </customize>
  76.593 +        </j2seproject3:debug>
  76.594 +    </target>
  76.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  76.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  76.597 +    </target>
  76.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  76.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  76.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  76.601 +    </target>
  76.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  76.603 +    <!--
  76.604 +                =========================
  76.605 +                APPLET EXECUTION SECTION
  76.606 +                =========================
  76.607 +            -->
  76.608 +    <target depends="init,compile-single" name="run-applet">
  76.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  76.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  76.611 +            <customize>
  76.612 +                <arg value="${applet.url}"/>
  76.613 +            </customize>
  76.614 +        </j2seproject1:java>
  76.615 +    </target>
  76.616 +    <!--
  76.617 +                =========================
  76.618 +                APPLET DEBUGGING  SECTION
  76.619 +                =========================
  76.620 +            -->
  76.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  76.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  76.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  76.624 +            <customize>
  76.625 +                <arg value="${applet.url}"/>
  76.626 +            </customize>
  76.627 +        </j2seproject3:debug>
  76.628 +    </target>
  76.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  76.630 +    <!--
  76.631 +                ===============
  76.632 +                CLEANUP SECTION
  76.633 +                ===============
  76.634 +            -->
  76.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  76.636 +    <target depends="init" name="-do-clean">
  76.637 +        <delete dir="${build.dir}"/>
  76.638 +        <delete dir="${dist.dir}"/>
  76.639 +    </target>
  76.640 +    <target name="-post-clean">
  76.641 +        <!-- Empty placeholder for easier customization. -->
  76.642 +        <!-- You can override this target in the ../build.xml file. -->
  76.643 +    </target>
  76.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  76.645 +</project>
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/task2/solution07/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    77.3 @@ -0,0 +1,8 @@
    77.4 +build.xml.data.CRC32=2ab820eb
    77.5 +build.xml.script.CRC32=58a52595
    77.6 +build.xml.stylesheet.CRC32=be360661
    77.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    77.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    77.9 +nbproject/build-impl.xml.data.CRC32=979fc7ba
   77.10 +nbproject/build-impl.xml.script.CRC32=92452d37
   77.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/task2/solution07/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    78.3 @@ -0,0 +1,68 @@
    78.4 +application.title=currency
    78.5 +application.vendor=apidesign.org
    78.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    78.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    78.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    78.9 +build.classes.dir=${build.dir}/classes
   78.10 +build.classes.excludes=**/*.java,**/*.form
   78.11 +# This directory is removed when the project is cleaned:
   78.12 +build.dir=build
   78.13 +build.generated.dir=${build.dir}/generated
   78.14 +# Only compile against the classpath explicitly listed here:
   78.15 +build.sysclasspath=ignore
   78.16 +build.test.classes.dir=${build.dir}/test/classes
   78.17 +build.test.results.dir=${build.dir}/test/results
   78.18 +debug.classpath=\
   78.19 +    ${run.classpath}
   78.20 +debug.test.classpath=\
   78.21 +    ${run.test.classpath}
   78.22 +# This directory is removed when the project is cleaned:
   78.23 +dist.dir=dist
   78.24 +dist.jar=${dist.dir}/currency.jar
   78.25 +dist.javadoc.dir=${dist.dir}/javadoc
   78.26 +excludes=
   78.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   78.28 +file.reference.src-apifest08=..
   78.29 +includes=**
   78.30 +jar.compress=false
   78.31 +javac.classpath=
   78.32 +# Space-separated list of extra javac options
   78.33 +javac.compilerargs=
   78.34 +javac.deprecation=false
   78.35 +javac.source=1.5
   78.36 +javac.target=1.5
   78.37 +javac.test.classpath=\
   78.38 +    ${javac.classpath}:\
   78.39 +    ${build.classes.dir}:\
   78.40 +    ${file.reference.junit-4.4.jar}
   78.41 +javadoc.additionalparam=
   78.42 +javadoc.author=false
   78.43 +javadoc.encoding=
   78.44 +javadoc.noindex=false
   78.45 +javadoc.nonavbar=false
   78.46 +javadoc.notree=false
   78.47 +javadoc.private=false
   78.48 +javadoc.splitindex=true
   78.49 +javadoc.use=true
   78.50 +javadoc.version=false
   78.51 +javadoc.windowtitle=
   78.52 +jnlp.codebase.type=local
   78.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   78.54 +jnlp.descriptor=application
   78.55 +jnlp.enabled=false
   78.56 +jnlp.offline-allowed=false
   78.57 +jnlp.signed=false
   78.58 +meta.inf.dir=${src.dir}/META-INF
   78.59 +platform.active=default_platform
   78.60 +run.classpath=\
   78.61 +    ${javac.classpath}:\
   78.62 +    ${build.classes.dir}
   78.63 +# Space-separated list of JVM arguments used when running the project
   78.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   78.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   78.66 +run.jvmargs=
   78.67 +run.test.classpath=\
   78.68 +    ${javac.test.classpath}:\
   78.69 +    ${build.test.classes.dir}
   78.70 +src.dir=src
   78.71 +test.src.dir=test
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/task2/solution07/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    79.3 @@ -0,0 +1,16 @@
    79.4 +<?xml version="1.0" encoding="UTF-8"?>
    79.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    79.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    79.7 +    <configuration>
    79.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    79.9 +            <name>Currency Convertor Solution 07</name>
   79.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   79.11 +            <source-roots>
   79.12 +                <root id="src.dir"/>
   79.13 +            </source-roots>
   79.14 +            <test-roots>
   79.15 +                <root id="test.src.dir"/>
   79.16 +            </test-roots>
   79.17 +        </data>
   79.18 +    </configuration>
   79.19 +</project>
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/ConversionRate.java	Wed Oct 01 10:43:05 2008 +0200
    80.3 @@ -0,0 +1,91 @@
    80.4 +package org.apidesign.apifest08.currency;
    80.5 +
    80.6 +import java.math.BigDecimal;
    80.7 +import java.math.RoundingMode;
    80.8 +
    80.9 +/**
   80.10 + * A rate of conversion from one currency to another.
   80.11 + * @author jdvorak
   80.12 + */
   80.13 +public class ConversionRate {
   80.14 +
   80.15 +    private final MonetaryAmount srcUnitAmount;
   80.16 +    private final MonetaryAmount tgtUnitAmount;
   80.17 +    private final int tgtScale;
   80.18 +    private final RoundingMode roundingMode;
   80.19 +
   80.20 +    /**
   80.21 +     * A new conversion rate that gives tgtUnitAmount per every srcUnitAmount.
   80.22 +     * @param srcUnitAmount the amount of source currency
   80.23 +     * @param tgtUnitAmount the corresponding amount of target currency
   80.24 +     * @param tgtScale the scale of the target amounts
   80.25 +     * @param roundingMode the rounding mode to use when producing the target amounts
   80.26 +     */
   80.27 +    public ConversionRate( final MonetaryAmount srcUnitAmount, final MonetaryAmount tgtUnitAmount, final int targetScale, final RoundingMode roundingMode ) {
   80.28 +        this.srcUnitAmount = srcUnitAmount;
   80.29 +        this.tgtUnitAmount = tgtUnitAmount;
   80.30 +        this.tgtScale = targetScale;
   80.31 +        this.roundingMode = roundingMode;
   80.32 +    }
   80.33 +
   80.34 +    /**
   80.35 +     * A new conversion rate that gives tgtUnitAmount per every srcUnitAmount, default number of fraction digits and the given rounding mode.
   80.36 +     * @param srcUnitAmount the amount of source currency
   80.37 +     * @param tgtUnitAmount the corresponding amount of target currency
   80.38 +     * @param roundingMode the rounding mode to use
   80.39 +     */
   80.40 +    public ConversionRate( final MonetaryAmount srcUnitAmount, final MonetaryAmount tgtUnitAmount, final RoundingMode roundingMode ) {
   80.41 +        this( srcUnitAmount, tgtUnitAmount, tgtUnitAmount.getCurrency().getDefaultFractionDigits(), roundingMode );
   80.42 +    }
   80.43 +
   80.44 +    /**
   80.45 +     * A new conversion rate that gives tgtUnitAmount per every srcUnitAmount, default number of fraction digits and {@link RoundingMode#HALF_EVEN}.
   80.46 +     * @param srcUnitAmount the amount of source currency
   80.47 +     * @param tgtUnitAmount the corresponding amount of target currency
   80.48 +     */
   80.49 +    public ConversionRate( final MonetaryAmount srcUnitAmount, final MonetaryAmount tgtUnitAmount ) {
   80.50 +        this( srcUnitAmount, tgtUnitAmount, RoundingMode.HALF_EVEN );
   80.51 +    }
   80.52 +
   80.53 +    public RoundingMode getRoundingMode() {
   80.54 +        return roundingMode;
   80.55 +    }
   80.56 +
   80.57 +    public MonetaryAmount getSrcUnitAmount() {
   80.58 +        return srcUnitAmount;
   80.59 +    }
   80.60 +
   80.61 +    public int getTgtScale() {
   80.62 +        return tgtScale;
   80.63 +    }
   80.64 +
   80.65 +    public MonetaryAmount getTgtUnitAmount() {
   80.66 +        return tgtUnitAmount;
   80.67 +    }
   80.68 +    
   80.69 +    /**
   80.70 +     * Multiplies the given amount with the given rate.
   80.71 +     * @param srcAmount
   80.72 +     * @return
   80.73 +     */
   80.74 +    public BigDecimal convert( final BigDecimal srcAmount ) {
   80.75 +        return srcAmount
   80.76 +            .multiply( tgtUnitAmount.getAmount() )
   80.77 +            .divide( srcUnitAmount.getAmount(), tgtScale, roundingMode );
   80.78 +    }
   80.79 +    
   80.80 +    /**
   80.81 +     * Creates a monetary amount that corresponds to the given source amount multiplied by the rate.
   80.82 +     * @param srcAmount the source amount
   80.83 +     * @return the monetary amount in the target currency
   80.84 +     * @throws IllegalArgumentException if the currency of srcAmount is not equal to the source currency of this rate
   80.85 +     */
   80.86 +    public MonetaryAmount convert( final MonetaryAmount srcAmount ) {
   80.87 +        if ( srcUnitAmount.getCurrency().equals( srcAmount.getCurrency() ) ) {
   80.88 +            return new MonetaryAmount( convert( srcAmount.getAmount() ), tgtUnitAmount.getCurrency() );
   80.89 +        } else {
   80.90 +            throw new IllegalArgumentException( "This rate converts from " + srcUnitAmount.getCurrency() + ", but a conversion from " + srcAmount.getCurrency() + " is attempted" );
   80.91 +        }
   80.92 +    }
   80.93 +    
   80.94 +}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    81.3 @@ -0,0 +1,109 @@
    81.4 +package org.apidesign.apifest08.currency;
    81.5 +
    81.6 +import java.util.Currency;
    81.7 +
    81.8 +/** This is the skeleton class for your API. You need to make it public, so
    81.9 + * it is accessible to your client code (currently in Task1Test.java) file.
   81.10 + * <p>
   81.11 + * Feel free to create additional classes or rename this one, just keep all
   81.12 + * the API and its implementation in this package. Do not spread it outside
   81.13 + * to other packages.
   81.14 + */
   81.15 +public interface Convertor {
   81.16 +    
   81.17 +    /**
   81.18 +     * Converts by taking a request and producing a response.
   81.19 +     * If a convertor finds it cannot perform the requested conversion,
   81.20 +     * it should return a non-null {@link ConversionResult} that has null {@link ConversionResult#getNetAmount()}.
   81.21 +     * A convertor must not convert to a different currency than the one specified in the request.
   81.22 +     * <p>
   81.23 +     * When the need comes to extend the semantics, one subclasses the ConversionRequest and/or ConversionResult classes.
   81.24 +     * <p>
   81.25 +     * This method can be called as many times as you like.
   81.26 +     * A {@link Convertor} shall be considered immutable wrt calls to {@link #convert(org.apidesign.apifest08.currency.Convertor.ConversionRequest).
   81.27 +     * This method of a single {@link Convertor} can be called from many threads concurrently.
   81.28 +     * @param req the conversion request; mustn't be null
   81.29 +     * @return the result of carrying out the conversion request; never null
   81.30 +     * @throws IllegalRequestSubtypeException when the particular implementation cannot handle a specific ConversionRequest type
   81.31 +     */
   81.32 +    public ConversionResult convert( final ConversionRequest req ) throws IllegalRequestSubtypeException;
   81.33 +
   81.34 +    /**
   81.35 +     * The request for converting a monetary amout into another currency.
   81.36 +     * Immutable.
   81.37 +     */
   81.38 +    public class ConversionRequest {
   81.39 +        
   81.40 +        private final MonetaryAmount srcAmount;
   81.41 +        private final Currency tgtCurrency;
   81.42 +
   81.43 +        /**
   81.44 +         * A request to convert srcAmount into tgtCurrency.
   81.45 +         * @param srcAmount the source amount; must not be null
   81.46 +         * @param tgtCurrency the currency we want it in afterwards; must not be null
   81.47 +         */
   81.48 +        public ConversionRequest( final MonetaryAmount srcAmount, final Currency tgtCurrency ) {
   81.49 +            this.srcAmount = srcAmount;
   81.50 +            this.tgtCurrency = tgtCurrency;
   81.51 +            if ( srcAmount == null ) {
   81.52 +                throw new NullPointerException( "The source amount" );
   81.53 +            }
   81.54 +            if ( tgtCurrency == null ) {
   81.55 +                throw new NullPointerException( "The target currency" );
   81.56 +            }
   81.57 +            if ( srcAmount.getCurrency().equals( tgtCurrency ) ) {
   81.58 +                throw new IllegalArgumentException( "Cannot request conversion from " + srcAmount.getCurrency() + " to " + tgtCurrency );
   81.59 +            }
   81.60 +        }
   81.61 +
   81.62 +        /**
   81.63 +         * The source amount.
   81.64 +         */
   81.65 +        public MonetaryAmount getSrcAmount() {
   81.66 +            return srcAmount;
   81.67 +        }
   81.68 +
   81.69 +        /**
   81.70 +         * The target currency.
   81.71 +         */
   81.72 +        public Currency getTgtCurrency() {
   81.73 +            return tgtCurrency;
   81.74 +        }
   81.75 +        
   81.76 +    }
   81.77 +    
   81.78 +    /**
   81.79 +     * The result of converting a monetary amount into another currency.
   81.80 +     * For now it records just the net amount one recieves from the conversion.
   81.81 +     * Immutable.
   81.82 +     * <p>
   81.83 +     * <b>Extension note:</b> 
   81.84 +     * Other items can be added further down the road, as the need for them arises.
   81.85 +     * These items might provide info on other aspects of the conversion,
   81.86 +     * such as the fee or a reason why the conversion might not be admissible.
   81.87 +     */
   81.88 +    public class ConversionResult {
   81.89 +        
   81.90 +        private final MonetaryAmount netAmount;
   81.91 +        
   81.92 +        /**
   81.93 +         * A new conversion result.
   81.94 +         * @param netAmount the amount one recieves from the conversion; 
   81.95 +         * null means the conversion was not admissible
   81.96 +         */
   81.97 +        public ConversionResult( final MonetaryAmount netAmount ) {
   81.98 +            this.netAmount = netAmount;
   81.99 +        }
  81.100 +        
  81.101 +        /**
  81.102 +         * The amount one recieves from the conversion.
  81.103 +         * If null, the conversion is not admissible.
  81.104 +         * @return the amount
  81.105 +         */
  81.106 +        public MonetaryAmount getNetAmount() {
  81.107 +            return netAmount;
  81.108 +        }
  81.109 +        
  81.110 +    }
  81.111 +    
  81.112 +}
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/DelegatingConvertor.java	Wed Oct 01 10:43:05 2008 +0200
    82.3 @@ -0,0 +1,28 @@
    82.4 +/*
    82.5 + * To change this template, choose Tools | Templates
    82.6 + * and open the template in the editor.
    82.7 + */
    82.8 +
    82.9 +package org.apidesign.apifest08.currency;
   82.10 +
   82.11 +/**
   82.12 + *
   82.13 + * @author jdvorak
   82.14 + */
   82.15 +public class DelegatingConvertor implements Convertor {
   82.16 +    
   82.17 +    private final Convertor underlyingConvertor;
   82.18 +
   82.19 +    public DelegatingConvertor( final Convertor underlyingConvertor ) {
   82.20 +        this.underlyingConvertor = underlyingConvertor;
   82.21 +    }
   82.22 +
   82.23 +    protected Convertor getUnderlyingConvertor() {
   82.24 +        return underlyingConvertor;
   82.25 +    }
   82.26 +    
   82.27 +    public ConversionResult convert( final ConversionRequest req ) {
   82.28 +        return underlyingConvertor.convert( req );
   82.29 +    }
   82.30 +    
   82.31 +}
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/IllegalRequestSubtypeException.java	Wed Oct 01 10:43:05 2008 +0200
    83.3 @@ -0,0 +1,30 @@
    83.4 +/*
    83.5 + * To change this template, choose Tools | Templates
    83.6 + * and open the template in the editor.
    83.7 + */
    83.8 +
    83.9 +package org.apidesign.apifest08.currency;
   83.10 +
   83.11 +/**
   83.12 + * Rised when a {@link Convertor} implementation cannot handle a particular subtype of {@link Convertor.ConversionRequest}.
   83.13 + * @author jdvorak
   83.14 + */
   83.15 +public class IllegalRequestSubtypeException extends IllegalArgumentException {
   83.16 +
   83.17 +    public IllegalRequestSubtypeException() {
   83.18 +        super();
   83.19 +    }
   83.20 +    
   83.21 +    public IllegalRequestSubtypeException( final String msg ) {
   83.22 +        super( msg );
   83.23 +    }
   83.24 +    
   83.25 +    public IllegalRequestSubtypeException( final Throwable cause ) {
   83.26 +        super( cause );
   83.27 +    }
   83.28 +    
   83.29 +    public IllegalRequestSubtypeException( final String msg, final Throwable cause ) {
   83.30 +        super( msg, cause );
   83.31 +    }
   83.32 +    
   83.33 +}
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/MonetaryAmount.java	Wed Oct 01 10:43:05 2008 +0200
    84.3 @@ -0,0 +1,89 @@
    84.4 +package org.apidesign.apifest08.currency;
    84.5 +
    84.6 +import java.math.BigDecimal;
    84.7 +import java.util.Currency;
    84.8 +
    84.9 +/**
   84.10 + * An amount of a currency.
   84.11 + * Immutable.
   84.12 + * @author jdvorak
   84.13 + */
   84.14 +public class MonetaryAmount {
   84.15 +
   84.16 +    private final BigDecimal amount;
   84.17 +    private final Currency currency;
   84.18 +    
   84.19 +    /**
   84.20 +     * A new amount.
   84.21 +     * @param amount the quantity of the currency; must not be null
   84.22 +     * @param currency the currency; must not be null
   84.23 +     */
   84.24 +    public MonetaryAmount( final BigDecimal amount, final Currency currency ) {
   84.25 +        this.amount = amount;
   84.26 +        this.currency = currency;
   84.27 +        if ( amount == null ) {
   84.28 +            throw new NullPointerException( "The amount" );
   84.29 +        }
   84.30 +        if ( currency == null ) {
   84.31 +            throw new NullPointerException( "The currency" );
   84.32 +        }
   84.33 +    }
   84.34 +    
   84.35 +    /**
   84.36 +     * A new amount.
   84.37 +     * @param amount the quantity of the currency; must not be null
   84.38 +     * @param currency the currency; must not be null
   84.39 +     */
   84.40 +    public MonetaryAmount( final double amount, final Currency currency ) {
   84.41 +        this( new BigDecimal( amount ), currency );
   84.42 +    }
   84.43 +    
   84.44 +    /**
   84.45 +     * The amount.
   84.46 +     * @return the amount
   84.47 +     */
   84.48 +    public BigDecimal getAmount() {
   84.49 +        return amount;
   84.50 +    }
   84.51 +    
   84.52 +    /**
   84.53 +     * The currency.
   84.54 +     * @return the currency
   84.55 +     */
   84.56 +    public Currency getCurrency() {
   84.57 +        return currency;
   84.58 +    }
   84.59 +
   84.60 +    /**
   84.61 +     * The string representation of the monetary amount.
   84.62 +     * @return the amount, a non-breakable space, the currency
   84.63 +     */
   84.64 +    @Override
   84.65 +    public String toString() {
   84.66 +        return amount.toPlainString() + "\u00a0" + currency.toString();
   84.67 +    }
   84.68 +    
   84.69 +    /**
   84.70 +     * Two monetary amounts are equal to each other iff they have equal amounts of equal currencies.
   84.71 +     * @param other the other object
   84.72 +     * @return equality
   84.73 +     */
   84.74 +    @Override
   84.75 +    public boolean equals( final Object other ) {
   84.76 +        if ( other instanceof MonetaryAmount ) {
   84.77 +            final MonetaryAmount otherMonetaryAmount = (MonetaryAmount) other;
   84.78 +            return getAmount().equals( otherMonetaryAmount.getAmount() ) && getCurrency().equals( otherMonetaryAmount.getCurrency() );
   84.79 +        }
   84.80 +        return false;
   84.81 +    }
   84.82 +    
   84.83 +    /**
   84.84 +     * The hash code combines the hash codes of the amount and of the currency.
   84.85 +     * @return hash code
   84.86 +     */
   84.87 +    @Override
   84.88 +    public int hashCode() {
   84.89 +        return amount.hashCode() * 37 + currency.hashCode();
   84.90 +    }
   84.91 +    
   84.92 +}
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/task2/solution07/src/org/apidesign/apifest08/currency/TableConvertor.java	Wed Oct 01 10:43:05 2008 +0200
    85.3 @@ -0,0 +1,71 @@
    85.4 +package org.apidesign.apifest08.currency;
    85.5 +
    85.6 +import java.util.Currency;
    85.7 +import java.util.HashMap;
    85.8 +import java.util.Map;
    85.9 +
   85.10 +/**
   85.11 + * A {@link Convertor} that works from a pre-set conversion table.
   85.12 + * First use {@link #putIntoTable(org.apidesign.apifest08.currency.ConversionRate)} to set the conversion table.
   85.13 + * Then invoke the {@link #convert(org.apidesign.apifest08.currency.Convertor.ConversionRequest)} method as many times as you wish.
   85.14 + * @author jdvorak
   85.15 + */
   85.16 +public class TableConvertor implements Convertor {
   85.17 +
   85.18 +    private final Map<Currency, Map<Currency, ConversionRate>> conversionTable = new HashMap<Currency, Map<Currency, ConversionRate>>();
   85.19 +    
   85.20 +    public TableConvertor() {
   85.21 +    }
   85.22 +
   85.23 +    /**
   85.24 +     * Puts a rate into the table.
   85.25 +     * @param rate
   85.26 +     */
   85.27 +    public void putIntoTable( final ConversionRate rate ) {
   85.28 +        final Currency srcCurrency = rate.getSrcUnitAmount().getCurrency();
   85.29 +        final Currency tgtCurrency = rate.getTgtUnitAmount().getCurrency();
   85.30 +        synchronized ( conversionTable ) {
   85.31 +            Map<Currency, ConversionRate> targetTable = conversionTable.get( srcCurrency );
   85.32 +            if ( targetTable == null ) {
   85.33 +                targetTable = new HashMap<Currency, ConversionRate>();
   85.34 +                conversionTable.put( srcCurrency, targetTable );
   85.35 +            }
   85.36 +            targetTable.put( tgtCurrency, rate );
   85.37 +        }
   85.38 +    }
   85.39 +    
   85.40 +    /**
   85.41 +     * Carries out the conversion.
   85.42 +     * If the table does not contain a conversion from the source currency to the target one,
   85.43 +     * a {@link ConversionResult} is returned that has null netAmount.
   85.44 +     * This implementation works with any {@link ConversionRequest}, it won't throw {@link IllegalRequestSubtypeException}.
   85.45 +     * @param req the conversion request
   85.46 +     * @return the conversion result
   85.47 +     */
   85.48 +    public ConversionResult convert( final ConversionRequest req ) {
   85.49 +        final Currency srcCurrency = req.getSrcAmount().getCurrency();
   85.50 +        final Currency tgtCurrency = req.getTgtCurrency();
   85.51 +        final ConversionRate rate = findConversionRate( srcCurrency, tgtCurrency );
   85.52 +        if ( rate != null ) {
   85.53 +            final MonetaryAmount tgtAmount = rate.convert( req.getSrcAmount() );
   85.54 +            return new ConversionResult( tgtAmount );
   85.55 +        } else {
   85.56 +            return new ConversionResult( null );    // did not find the pair of currencies in the table
   85.57 +        }
   85.58 +    }
   85.59 +
   85.60 +    /**
   85.61 +     * Looks up the conversion between the given currencies in the table.
   85.62 +     * @param srcCurrency the source currency
   85.63 +     * @param tgtCurrency the target currency
   85.64 +     * @return the conversion rate; null means no conversion between the currencies was found in the table
   85.65 +     */
   85.66 +    protected ConversionRate findConversionRate( final Currency srcCurrency, final Currency tgtCurrency ) {
   85.67 +        synchronized ( conversionTable ) {
   85.68 +            final Map<Currency, ConversionRate> targetTable = conversionTable.get(srcCurrency);
   85.69 +            final ConversionRate rate = (targetTable != null) ? targetTable.get(tgtCurrency) : null;
   85.70 +            return rate;
   85.71 +        }
   85.72 +    }
   85.73 +
   85.74 +}
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/task2/solution07/test/org/apidesign/apifest08/test/ContractImposingDelegatingConvertor.java	Wed Oct 01 10:43:05 2008 +0200
    86.3 @@ -0,0 +1,53 @@
    86.4 +/*
    86.5 + * To change this template, choose Tools | Templates
    86.6 + * and open the template in the editor.
    86.7 + */
    86.8 +
    86.9 +package org.apidesign.apifest08.test;
   86.10 +
   86.11 +import java.math.BigDecimal;
   86.12 +import java.util.Currency;
   86.13 +import junit.framework.Assert;
   86.14 +import org.apidesign.apifest08.currency.Convertor;
   86.15 +import org.apidesign.apifest08.currency.DelegatingConvertor;
   86.16 +import org.apidesign.apifest08.currency.MonetaryAmount;
   86.17 +
   86.18 +/**
   86.19 + * A delegating convertor that checks preconditions and postconditions.
   86.20 + * Useful for testing.
   86.21 + * @author jdvorak
   86.22 + */
   86.23 +public class ContractImposingDelegatingConvertor extends DelegatingConvertor {
   86.24 +
   86.25 +    public ContractImposingDelegatingConvertor( final Convertor underlyingConvertor ) {
   86.26 +        super( underlyingConvertor );
   86.27 +    }
   86.28 +
   86.29 +    @Override
   86.30 +    public ConversionResult convert( final ConversionRequest req ) {
   86.31 +        Assert.assertNotNull( "The request", req );
   86.32 +        final ConversionResult result = super.convert( req );
   86.33 +        Assert.assertNotNull( "Result of the convert() call", result );
   86.34 +        final MonetaryAmount netAmount = result.getNetAmount();
   86.35 +        if ( netAmount != null ) {
   86.36 +            Assert.assertEquals( "Converted to a different currency than specified in the request", req.getTgtCurrency(), netAmount.getCurrency() );
   86.37 +        }
   86.38 +        return result;
   86.39 +    }
   86.40 +
   86.41 +    /**
   86.42 +     * Do some tests on our own.
   86.43 +     * @return this
   86.44 +     */
   86.45 +    public Convertor test() {
   86.46 +        try {
   86.47 +            final Currency aCurrency = Currency.getInstance( "EUR" );
   86.48 +            new ConversionRequest( new MonetaryAmount( BigDecimal.ONE, aCurrency ), aCurrency );
   86.49 +            Assert.fail( "Should have thrown an IllegalArgumentException" );
   86.50 +        } catch ( final IllegalArgumentException e ) {
   86.51 +            Assert.assertEquals( "Cannot request conversion from EUR to EUR", e.getMessage() );
   86.52 +        }
   86.53 +        return this;
   86.54 +    }
   86.55 +
   86.56 +}
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/task2/solution07/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    87.3 @@ -0,0 +1,177 @@
    87.4 +package org.apidesign.apifest08.test;
    87.5 +
    87.6 +import java.util.Currency;
    87.7 +import junit.framework.TestCase;
    87.8 +import org.apidesign.apifest08.currency.ConversionRate;
    87.9 +import org.apidesign.apifest08.currency.Convertor;
   87.10 +import org.apidesign.apifest08.currency.MonetaryAmount;
   87.11 +import org.apidesign.apifest08.currency.TableConvertor;
   87.12 +
   87.13 +/** Finish the Convertor API, and then write bodies of methods inside
   87.14 + * of this class to match the given tasks. To fullfil your task, use the
   87.15 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   87.16 + * Do not you reflection, or other hacks as your code
   87.17 + * shall run without any runtime permissions.
   87.18 + */
   87.19 +public class Task1Test extends TestCase {
   87.20 +    public Task1Test(String testName) {
   87.21 +        super(testName);
   87.22 +    }
   87.23 +
   87.24 +    @Override
   87.25 +    protected void setUp() throws Exception {
   87.26 +    }
   87.27 +
   87.28 +    @Override
   87.29 +    protected void tearDown() throws Exception {
   87.30 +    }
   87.31 +
   87.32 +    //
   87.33 +    // Imagine that there are three parts of the whole system:
   87.34 +    // 1. there is someone who knows the current exchange rate
   87.35 +    // 2. there is someone who wants to do the conversion
   87.36 +    // 3. there is the API between 1. and 2. which allows them to communicate
   87.37 +    // Please design such API
   87.38 +    //
   87.39 +
   87.40 +    protected static final Currency CZK = Currency.getInstance( "CZK" );
   87.41 +    protected static final Currency SKK = Currency.getInstance( "SKK" );
   87.42 +    protected static final Currency USD = Currency.getInstance( "USD" );
   87.43 +    
   87.44 +    /** Create convertor that understands two currencies, CZK and
   87.45 +     *  USD. Make 1 USD == 17 CZK.
   87.46 +     *  USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
   87.47 +     *  e.g. those that know the exchange rate. They somehow need to create
   87.48 +     *  the objects from the API and tell them the exchange rate. The API itself
   87.49 +     *  knows nothing about any rates, before the createCZKtoUSD method is called.
   87.50 +     *
   87.51 +     * Creation of the convertor shall not require subclassing of any class
   87.52 +     * or interface on the client side.
   87.53 +     *
   87.54 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   87.55 +     */
   87.56 +    public static Convertor createCZKtoUSD() {
   87.57 +        final TableConvertor convertor = new TableConvertor();
   87.58 +        final MonetaryAmount amountInCZK = new MonetaryAmount( 17, CZK );
   87.59 +        final MonetaryAmount amountInUSD = new MonetaryAmount( 1, USD );
   87.60 +        convertor.putIntoTable( new ConversionRate( amountInCZK, amountInUSD ) );
   87.61 +        convertor.putIntoTable( new ConversionRate( amountInUSD, amountInCZK ) );
   87.62 +        return new ContractImposingDelegatingConvertor( convertor ).test();
   87.63 +    }
   87.64 +
   87.65 +    /** Create convertor that understands two currencies, CZK and
   87.66 +     *  SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
   87.67 +     *  it knows the exchange rate, and needs to use the API to create objects
   87.68 +     *  with the exchange rate. Anyone shall be ready to call this method without
   87.69 +     *  any other method being called previously. The API itself shall know
   87.70 +     *  nothing about any rates, before this method is called.
   87.71 +     *
   87.72 +     * Creation of the convertor shall not require subclassing of any class
   87.73 +     * or interface on the client side.
   87.74 +     * 
   87.75 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   87.76 +     */
   87.77 +    public static Convertor createSKKtoCZK() {
   87.78 +        final TableConvertor convertor = new TableConvertor();
   87.79 +        final MonetaryAmount amountInSKK = new MonetaryAmount( 100, SKK );
   87.80 +        final MonetaryAmount amountInCZK = new MonetaryAmount( 80, CZK );
   87.81 +        convertor.putIntoTable( new ConversionRate( amountInSKK, amountInCZK ) );
   87.82 +        convertor.putIntoTable( new ConversionRate( amountInCZK, amountInSKK ) );
   87.83 +        return new ContractImposingDelegatingConvertor( convertor ).test();
   87.84 +    }
   87.85 +
   87.86 +    //
   87.87 +    // now the methods for group #2 follow:
   87.88 +    // this group knows nothing about exchange rates, but knows how to use
   87.89 +    // the API to do conversions. It somehow (by calling one of the factory
   87.90 +    // methods) gets objects from the API and uses them to do the conversions.
   87.91 +    //
   87.92 +
   87.93 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   87.94 +     * with it.
   87.95 +     */
   87.96 +    public void testCurrencyCZKUSD() throws Exception {
   87.97 +        final Convertor c = createCZKtoUSD();
   87.98 +        
   87.99 +        // convert $5 to CZK using c:
  87.100 +        final Convertor.ConversionResult r1 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 5, USD ), CZK ) );
  87.101 +        final MonetaryAmount a1 = r1.getNetAmount();
  87.102 +        // assertEquals("Result is 85 CZK");
  87.103 +        assertNotNull( a1 );
  87.104 +        assertEquals( 85.0, a1.getAmount().doubleValue() );
  87.105 +        assertEquals( CZK, a1.getCurrency() );
  87.106 +
  87.107 +        // convert $8 to CZK
  87.108 +        final Convertor.ConversionResult r2 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 8, USD ), CZK ) );
  87.109 +        final MonetaryAmount a2 = r2.getNetAmount();
  87.110 +        // assertEquals("Result is 136 CZK");
  87.111 +        assertNotNull( a2 );
  87.112 +        assertEquals( 136.0, a2.getAmount().doubleValue() );
  87.113 +        assertEquals( CZK, a2.getCurrency() );
  87.114 +
  87.115 +        // convert 1003CZK to USD
  87.116 +        final Convertor.ConversionResult r3 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 1003, CZK ), USD ) );
  87.117 +        final MonetaryAmount a3 = r3.getNetAmount();
  87.118 +        // assertEquals("Result is 59 USD");
  87.119 +        assertNotNull( a3 );
  87.120 +        assertEquals( 59.0, a3.getAmount().doubleValue() );
  87.121 +        assertEquals( USD, a3.getCurrency() );
  87.122 +    }
  87.123 +
  87.124 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
  87.125 +     * with it.
  87.126 +     */
  87.127 +    public void testCurrencySKKCZK() throws Exception {
  87.128 +        final Convertor c = createSKKtoCZK();
  87.129 +        
  87.130 +        // convert 16CZK using c:
  87.131 +        final Convertor.ConversionResult r1 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 16, CZK ), SKK ) );
  87.132 +        final MonetaryAmount a1 = r1.getNetAmount();
  87.133 +        // assertEquals("Result is 20 SKK");
  87.134 +        assertNotNull( a1 );
  87.135 +        assertEquals( 20.0, a1.getAmount().doubleValue() );
  87.136 +        assertEquals( SKK, a1.getCurrency() );
  87.137 +        
  87.138 +        // convert 500SKK to CZK
  87.139 +        final Convertor.ConversionResult r2 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 500, SKK ), CZK ) );
  87.140 +        final MonetaryAmount a2 = r2.getNetAmount();
  87.141 +        // assertEquals("Result is 400 CZK");
  87.142 +        assertNotNull( a2 );
  87.143 +        assertEquals( 400.0, a2.getAmount().doubleValue() );
  87.144 +        assertEquals( CZK, a2.getCurrency() );
  87.145 +    }
  87.146 +
  87.147 +    /** Verify that the CZK to USD convertor knows nothing about SKK.
  87.148 +    */
  87.149 +    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
  87.150 +        final Convertor c = createCZKtoUSD();
  87.151 +        
  87.152 +        // convert $5 to SKK, the API shall say this is not possible
  87.153 +        final Convertor.ConversionResult r1 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 5, USD ), SKK ) );
  87.154 +        final MonetaryAmount a1 = r1.getNetAmount();
  87.155 +        assertNull( a1 );
  87.156 +
  87.157 +        // convert 500 SKK to CZK, the API shall say this is not possible
  87.158 +        final Convertor.ConversionResult r2 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 5, SKK ), CZK ) );
  87.159 +        final MonetaryAmount a2 = r2.getNetAmount();
  87.160 +        assertNull( a2 );
  87.161 +    }
  87.162 +
  87.163 +    /** Verify that the CZK to SKK convertor knows nothing about USD.
  87.164 +    */
  87.165 +    public void testCannotConvertToUSDwithCZKSKKConvertor() throws Exception {
  87.166 +        final Convertor c = createSKKtoCZK();
  87.167 +        
  87.168 +        // convert $5 to SKK, the API shall say this is not possible
  87.169 +        final Convertor.ConversionResult r1 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 5, USD ), SKK ) );
  87.170 +        final MonetaryAmount a1 = r1.getNetAmount();
  87.171 +        assertNull( a1 );
  87.172 +        
  87.173 +        // convert 500 CZK to USD, the API shall say this is not possible
  87.174 +        final Convertor.ConversionResult r2 = c.convert( new Convertor.ConversionRequest( new MonetaryAmount( 5, CZK ), USD ) );
  87.175 +        final MonetaryAmount a2 = r2.getNetAmount();
  87.176 +        assertNull( a2 );
  87.177 +    }
  87.178 +
  87.179 +}
  87.180 +
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/task2/solution08/build.xml	Wed Oct 01 10:43:05 2008 +0200
    88.3 @@ -0,0 +1,69 @@
    88.4 +<?xml version="1.0" encoding="UTF-8"?>
    88.5 +<!-- You may freely edit this file. See commented blocks below for -->
    88.6 +<!-- some examples of how to customize the build. -->
    88.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    88.8 +<project name="currency" default="default" basedir=".">
    88.9 +    <description>Builds, tests, and runs the project.</description>
   88.10 +    <import file="nbproject/build-impl.xml"/>
   88.11 +    <!--
   88.12 +
   88.13 +    There exist several targets which are by default empty and which can be 
   88.14 +    used for execution of your tasks. These targets are usually executed 
   88.15 +    before and after some main targets. They are: 
   88.16 +
   88.17 +      -pre-init:                 called before initialization of project properties
   88.18 +      -post-init:                called after initialization of project properties
   88.19 +      -pre-compile:              called before javac compilation
   88.20 +      -post-compile:             called after javac compilation
   88.21 +      -pre-compile-single:       called before javac compilation of single file
   88.22 +      -post-compile-single:      called after javac compilation of single file
   88.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   88.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   88.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   88.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   88.27 +      -pre-jar:                  called before JAR building
   88.28 +      -post-jar:                 called after JAR building
   88.29 +      -post-clean:               called after cleaning build products
   88.30 +
   88.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   88.32 +
   88.33 +    Example of inserting an obfuscator after compilation could look like this:
   88.34 +
   88.35 +        <target name="-post-compile">
   88.36 +            <obfuscate>
   88.37 +                <fileset dir="${build.classes.dir}"/>
   88.38 +            </obfuscate>
   88.39 +        </target>
   88.40 +
   88.41 +    For list of available properties check the imported 
   88.42 +    nbproject/build-impl.xml file. 
   88.43 +
   88.44 +
   88.45 +    Another way to customize the build is by overriding existing main targets.
   88.46 +    The targets of interest are: 
   88.47 +
   88.48 +      -init-macrodef-javac:     defines macro for javac compilation
   88.49 +      -init-macrodef-junit:     defines macro for junit execution
   88.50 +      -init-macrodef-debug:     defines macro for class debugging
   88.51 +      -init-macrodef-java:      defines macro for class execution
   88.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   88.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   88.54 +      run:                      execution of project 
   88.55 +      -javadoc-build:           Javadoc generation
   88.56 +      test-report:              JUnit report generation
   88.57 +
   88.58 +    An example of overriding the target for project execution could look like this:
   88.59 +
   88.60 +        <target name="run" depends="currency-impl.jar">
   88.61 +            <exec dir="bin" executable="launcher.exe">
   88.62 +                <arg file="${dist.jar}"/>
   88.63 +            </exec>
   88.64 +        </target>
   88.65 +
   88.66 +    Notice that the overridden target depends on the jar target and not only on 
   88.67 +    the compile target as the regular run target does. Again, for a list of available 
   88.68 +    properties which you can use, check the target you are overriding in the
   88.69 +    nbproject/build-impl.xml file. 
   88.70 +
   88.71 +    -->
   88.72 +</project>
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/task2/solution08/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    89.3 @@ -0,0 +1,642 @@
    89.4 +<?xml version="1.0" encoding="UTF-8"?>
    89.5 +<!--
    89.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    89.7 +***         EDIT ../build.xml INSTEAD         ***
    89.8 +
    89.9 +For the purpose of easier reading the script
   89.10 +is divided into following sections:
   89.11 +
   89.12 +  - initialization
   89.13 +  - compilation
   89.14 +  - jar
   89.15 +  - execution
   89.16 +  - debugging
   89.17 +  - javadoc
   89.18 +  - junit compilation
   89.19 +  - junit execution
   89.20 +  - junit debugging
   89.21 +  - applet
   89.22 +  - cleanup
   89.23 +
   89.24 +        -->
   89.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">
   89.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   89.27 +    <!-- 
   89.28 +                ======================
   89.29 +                INITIALIZATION SECTION 
   89.30 +                ======================
   89.31 +            -->
   89.32 +    <target name="-pre-init">
   89.33 +        <!-- Empty placeholder for easier customization. -->
   89.34 +        <!-- You can override this target in the ../build.xml file. -->
   89.35 +    </target>
   89.36 +    <target depends="-pre-init" name="-init-private">
   89.37 +        <property file="nbproject/private/config.properties"/>
   89.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   89.39 +        <property file="nbproject/private/private.properties"/>
   89.40 +    </target>
   89.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   89.42 +        <property file="${user.properties.file}"/>
   89.43 +        <!-- The two properties below are usually overridden -->
   89.44 +        <!-- by the active platform. Just a fallback. -->
   89.45 +        <property name="default.javac.source" value="1.4"/>
   89.46 +        <property name="default.javac.target" value="1.4"/>
   89.47 +    </target>
   89.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   89.49 +        <property file="nbproject/configs/${config}.properties"/>
   89.50 +        <property file="nbproject/project.properties"/>
   89.51 +    </target>
   89.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   89.53 +        <available file="${manifest.file}" property="manifest.available"/>
   89.54 +        <condition property="manifest.available+main.class">
   89.55 +            <and>
   89.56 +                <isset property="manifest.available"/>
   89.57 +                <isset property="main.class"/>
   89.58 +                <not>
   89.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   89.60 +                </not>
   89.61 +            </and>
   89.62 +        </condition>
   89.63 +        <condition property="manifest.available+main.class+mkdist.available">
   89.64 +            <and>
   89.65 +                <istrue value="${manifest.available+main.class}"/>
   89.66 +                <isset property="libs.CopyLibs.classpath"/>
   89.67 +            </and>
   89.68 +        </condition>
   89.69 +        <condition property="have.tests">
   89.70 +            <or>
   89.71 +                <available file="${test.src.dir}"/>
   89.72 +            </or>
   89.73 +        </condition>
   89.74 +        <condition property="have.sources">
   89.75 +            <or>
   89.76 +                <available file="${src.dir}"/>
   89.77 +            </or>
   89.78 +        </condition>
   89.79 +        <condition property="netbeans.home+have.tests">
   89.80 +            <and>
   89.81 +                <isset property="netbeans.home"/>
   89.82 +                <isset property="have.tests"/>
   89.83 +            </and>
   89.84 +        </condition>
   89.85 +        <condition property="no.javadoc.preview">
   89.86 +            <and>
   89.87 +                <isset property="javadoc.preview"/>
   89.88 +                <isfalse value="${javadoc.preview}"/>
   89.89 +            </and>
   89.90 +        </condition>
   89.91 +        <property name="run.jvmargs" value=""/>
   89.92 +        <property name="javac.compilerargs" value=""/>
   89.93 +        <property name="work.dir" value="${basedir}"/>
   89.94 +        <condition property="no.deps">
   89.95 +            <and>
   89.96 +                <istrue value="${no.dependencies}"/>
   89.97 +            </and>
   89.98 +        </condition>
   89.99 +        <property name="javac.debug" value="true"/>
  89.100 +        <property name="javadoc.preview" value="true"/>
  89.101 +        <property name="application.args" value=""/>
  89.102 +        <property name="source.encoding" value="${file.encoding}"/>
  89.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  89.104 +            <and>
  89.105 +                <isset property="javadoc.encoding"/>
  89.106 +                <not>
  89.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  89.108 +                </not>
  89.109 +            </and>
  89.110 +        </condition>
  89.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  89.112 +        <property name="includes" value="**"/>
  89.113 +        <property name="excludes" value=""/>
  89.114 +        <property name="do.depend" value="false"/>
  89.115 +        <condition property="do.depend.true">
  89.116 +            <istrue value="${do.depend}"/>
  89.117 +        </condition>
  89.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  89.119 +            <and>
  89.120 +                <isset property="jaxws.endorsed.dir"/>
  89.121 +                <available file="nbproject/jaxws-build.xml"/>
  89.122 +            </and>
  89.123 +        </condition>
  89.124 +    </target>
  89.125 +    <target name="-post-init">
  89.126 +        <!-- Empty placeholder for easier customization. -->
  89.127 +        <!-- You can override this target in the ../build.xml file. -->
  89.128 +    </target>
  89.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  89.130 +        <fail unless="src.dir">Must set src.dir</fail>
  89.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  89.132 +        <fail unless="build.dir">Must set build.dir</fail>
  89.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  89.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  89.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  89.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  89.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  89.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  89.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  89.140 +    </target>
  89.141 +    <target name="-init-macrodef-property">
  89.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  89.143 +            <attribute name="name"/>
  89.144 +            <attribute name="value"/>
  89.145 +            <sequential>
  89.146 +                <property name="@{name}" value="${@{value}}"/>
  89.147 +            </sequential>
  89.148 +        </macrodef>
  89.149 +    </target>
  89.150 +    <target name="-init-macrodef-javac">
  89.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  89.152 +            <attribute default="${src.dir}" name="srcdir"/>
  89.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  89.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  89.155 +            <attribute default="${includes}" name="includes"/>
  89.156 +            <attribute default="${excludes}" name="excludes"/>
  89.157 +            <attribute default="${javac.debug}" name="debug"/>
  89.158 +            <attribute default="" name="sourcepath"/>
  89.159 +            <element name="customize" optional="true"/>
  89.160 +            <sequential>
  89.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}">
  89.162 +                    <classpath>
  89.163 +                        <path path="@{classpath}"/>
  89.164 +                    </classpath>
  89.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  89.166 +                    <customize/>
  89.167 +                </javac>
  89.168 +            </sequential>
  89.169 +        </macrodef>
  89.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  89.171 +            <attribute default="${src.dir}" name="srcdir"/>
  89.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  89.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  89.174 +            <sequential>
  89.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  89.176 +                    <classpath>
  89.177 +                        <path path="@{classpath}"/>
  89.178 +                    </classpath>
  89.179 +                </depend>
  89.180 +            </sequential>
  89.181 +        </macrodef>
  89.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  89.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  89.184 +            <sequential>
  89.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  89.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  89.187 +                    <path>
  89.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  89.189 +                    </path>
  89.190 +                    <globmapper from="*.java" to="*.class"/>
  89.191 +                </pathconvert>
  89.192 +                <delete>
  89.193 +                    <files includes="${javac.includes.binary}"/>
  89.194 +                </delete>
  89.195 +            </sequential>
  89.196 +        </macrodef>
  89.197 +    </target>
  89.198 +    <target name="-init-macrodef-junit">
  89.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  89.200 +            <attribute default="${includes}" name="includes"/>
  89.201 +            <attribute default="${excludes}" name="excludes"/>
  89.202 +            <attribute default="**" name="testincludes"/>
  89.203 +            <sequential>
  89.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  89.205 +                    <batchtest todir="${build.test.results.dir}">
  89.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  89.207 +                            <filename name="@{testincludes}"/>
  89.208 +                        </fileset>
  89.209 +                    </batchtest>
  89.210 +                    <classpath>
  89.211 +                        <path path="${run.test.classpath}"/>
  89.212 +                    </classpath>
  89.213 +                    <syspropertyset>
  89.214 +                        <propertyref prefix="test-sys-prop."/>
  89.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  89.216 +                    </syspropertyset>
  89.217 +                    <formatter type="brief" usefile="false"/>
  89.218 +                    <formatter type="xml"/>
  89.219 +                    <jvmarg line="${run.jvmargs}"/>
  89.220 +                </junit>
  89.221 +            </sequential>
  89.222 +        </macrodef>
  89.223 +    </target>
  89.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  89.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  89.226 +            <attribute default="${main.class}" name="name"/>
  89.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  89.228 +            <attribute default="" name="stopclassname"/>
  89.229 +            <sequential>
  89.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  89.231 +                    <classpath>
  89.232 +                        <path path="@{classpath}"/>
  89.233 +                    </classpath>
  89.234 +                </nbjpdastart>
  89.235 +            </sequential>
  89.236 +        </macrodef>
  89.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  89.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  89.239 +            <sequential>
  89.240 +                <nbjpdareload>
  89.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  89.242 +                        <include name="${fix.includes}*.class"/>
  89.243 +                    </fileset>
  89.244 +                </nbjpdareload>
  89.245 +            </sequential>
  89.246 +        </macrodef>
  89.247 +    </target>
  89.248 +    <target name="-init-debug-args">
  89.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  89.250 +        <condition property="have-jdk-older-than-1.4">
  89.251 +            <or>
  89.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  89.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  89.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  89.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  89.256 +            </or>
  89.257 +        </condition>
  89.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  89.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  89.260 +        </condition>
  89.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  89.262 +            <os family="windows"/>
  89.263 +        </condition>
  89.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  89.265 +            <isset property="debug.transport"/>
  89.266 +        </condition>
  89.267 +    </target>
  89.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  89.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  89.270 +            <attribute default="${main.class}" name="classname"/>
  89.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  89.272 +            <element name="customize" optional="true"/>
  89.273 +            <sequential>
  89.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  89.275 +                    <jvmarg line="${debug-args-line}"/>
  89.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  89.277 +                    <jvmarg line="${run.jvmargs}"/>
  89.278 +                    <classpath>
  89.279 +                        <path path="@{classpath}"/>
  89.280 +                    </classpath>
  89.281 +                    <syspropertyset>
  89.282 +                        <propertyref prefix="run-sys-prop."/>
  89.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  89.284 +                    </syspropertyset>
  89.285 +                    <customize/>
  89.286 +                </java>
  89.287 +            </sequential>
  89.288 +        </macrodef>
  89.289 +    </target>
  89.290 +    <target name="-init-macrodef-java">
  89.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  89.292 +            <attribute default="${main.class}" name="classname"/>
  89.293 +            <element name="customize" optional="true"/>
  89.294 +            <sequential>
  89.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  89.296 +                    <jvmarg line="${run.jvmargs}"/>
  89.297 +                    <classpath>
  89.298 +                        <path path="${run.classpath}"/>
  89.299 +                    </classpath>
  89.300 +                    <syspropertyset>
  89.301 +                        <propertyref prefix="run-sys-prop."/>
  89.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  89.303 +                    </syspropertyset>
  89.304 +                    <customize/>
  89.305 +                </java>
  89.306 +            </sequential>
  89.307 +        </macrodef>
  89.308 +    </target>
  89.309 +    <target name="-init-presetdef-jar">
  89.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  89.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  89.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  89.313 +            </jar>
  89.314 +        </presetdef>
  89.315 +    </target>
  89.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"/>
  89.317 +    <!--
  89.318 +                ===================
  89.319 +                COMPILATION SECTION
  89.320 +                ===================
  89.321 +            -->
  89.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  89.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  89.324 +    <target depends="init" name="-check-automatic-build">
  89.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  89.326 +    </target>
  89.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  89.328 +        <antcall target="clean"/>
  89.329 +    </target>
  89.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  89.331 +        <mkdir dir="${build.classes.dir}"/>
  89.332 +    </target>
  89.333 +    <target name="-pre-compile">
  89.334 +        <!-- Empty placeholder for easier customization. -->
  89.335 +        <!-- You can override this target in the ../build.xml file. -->
  89.336 +    </target>
  89.337 +    <target if="do.depend.true" name="-compile-depend">
  89.338 +        <j2seproject3:depend/>
  89.339 +    </target>
  89.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  89.341 +        <j2seproject3:javac/>
  89.342 +        <copy todir="${build.classes.dir}">
  89.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  89.344 +        </copy>
  89.345 +    </target>
  89.346 +    <target name="-post-compile">
  89.347 +        <!-- Empty placeholder for easier customization. -->
  89.348 +        <!-- You can override this target in the ../build.xml file. -->
  89.349 +    </target>
  89.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  89.351 +    <target name="-pre-compile-single">
  89.352 +        <!-- Empty placeholder for easier customization. -->
  89.353 +        <!-- You can override this target in the ../build.xml file. -->
  89.354 +    </target>
  89.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  89.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  89.357 +        <j2seproject3:force-recompile/>
  89.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  89.359 +    </target>
  89.360 +    <target name="-post-compile-single">
  89.361 +        <!-- Empty placeholder for easier customization. -->
  89.362 +        <!-- You can override this target in the ../build.xml file. -->
  89.363 +    </target>
  89.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  89.365 +    <!--
  89.366 +                ====================
  89.367 +                JAR BUILDING SECTION
  89.368 +                ====================
  89.369 +            -->
  89.370 +    <target depends="init" name="-pre-pre-jar">
  89.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  89.372 +        <mkdir dir="${dist.jar.dir}"/>
  89.373 +    </target>
  89.374 +    <target name="-pre-jar">
  89.375 +        <!-- Empty placeholder for easier customization. -->
  89.376 +        <!-- You can override this target in the ../build.xml file. -->
  89.377 +    </target>
  89.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  89.379 +        <j2seproject1:jar/>
  89.380 +    </target>
  89.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  89.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  89.383 +    </target>
  89.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">
  89.385 +        <j2seproject1:jar manifest="${manifest.file}">
  89.386 +            <j2seproject1:manifest>
  89.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  89.388 +            </j2seproject1:manifest>
  89.389 +        </j2seproject1:jar>
  89.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  89.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  89.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  89.393 +        <pathconvert property="run.classpath.with.dist.jar">
  89.394 +            <path path="${run.classpath}"/>
  89.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  89.396 +        </pathconvert>
  89.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  89.398 +    </target>
  89.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  89.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  89.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  89.402 +            <path path="${run.classpath}"/>
  89.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  89.404 +        </pathconvert>
  89.405 +        <pathconvert pathsep=" " property="jar.classpath">
  89.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  89.407 +            <chainedmapper>
  89.408 +                <flattenmapper/>
  89.409 +                <globmapper from="*" to="lib/*"/>
  89.410 +            </chainedmapper>
  89.411 +        </pathconvert>
  89.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  89.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  89.414 +            <fileset dir="${build.classes.dir}"/>
  89.415 +            <manifest>
  89.416 +                <attribute name="Main-Class" value="${main.class}"/>
  89.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  89.418 +            </manifest>
  89.419 +        </copylibs>
  89.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  89.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  89.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  89.423 +    </target>
  89.424 +    <target name="-post-jar">
  89.425 +        <!-- Empty placeholder for easier customization. -->
  89.426 +        <!-- You can override this target in the ../build.xml file. -->
  89.427 +    </target>
  89.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"/>
  89.429 +    <!--
  89.430 +                =================
  89.431 +                EXECUTION SECTION
  89.432 +                =================
  89.433 +            -->
  89.434 +    <target depends="init,compile" description="Run a main class." name="run">
  89.435 +        <j2seproject1:java>
  89.436 +            <customize>
  89.437 +                <arg line="${application.args}"/>
  89.438 +            </customize>
  89.439 +        </j2seproject1:java>
  89.440 +    </target>
  89.441 +    <target name="-do-not-recompile">
  89.442 +        <property name="javac.includes.binary" value=""/>
  89.443 +    </target>
  89.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  89.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  89.446 +        <j2seproject1:java classname="${run.class}"/>
  89.447 +    </target>
  89.448 +    <!--
  89.449 +                =================
  89.450 +                DEBUGGING SECTION
  89.451 +                =================
  89.452 +            -->
  89.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  89.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  89.455 +    </target>
  89.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  89.457 +        <j2seproject3:debug>
  89.458 +            <customize>
  89.459 +                <arg line="${application.args}"/>
  89.460 +            </customize>
  89.461 +        </j2seproject3:debug>
  89.462 +    </target>
  89.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  89.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  89.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  89.466 +    </target>
  89.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  89.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  89.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  89.470 +        <j2seproject3:debug classname="${debug.class}"/>
  89.471 +    </target>
  89.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  89.473 +    <target depends="init" name="-pre-debug-fix">
  89.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  89.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  89.476 +    </target>
  89.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  89.478 +        <j2seproject1:nbjpdareload/>
  89.479 +    </target>
  89.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  89.481 +    <!--
  89.482 +                ===============
  89.483 +                JAVADOC SECTION
  89.484 +                ===============
  89.485 +            -->
  89.486 +    <target depends="init" name="-javadoc-build">
  89.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  89.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}">
  89.489 +            <classpath>
  89.490 +                <path path="${javac.classpath}"/>
  89.491 +            </classpath>
  89.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  89.493 +                <filename name="**/*.java"/>
  89.494 +            </fileset>
  89.495 +        </javadoc>
  89.496 +    </target>
  89.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  89.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  89.499 +    </target>
  89.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  89.501 +    <!--
  89.502 +                =========================
  89.503 +                JUNIT COMPILATION SECTION
  89.504 +                =========================
  89.505 +            -->
  89.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  89.507 +        <mkdir dir="${build.test.classes.dir}"/>
  89.508 +    </target>
  89.509 +    <target name="-pre-compile-test">
  89.510 +        <!-- Empty placeholder for easier customization. -->
  89.511 +        <!-- You can override this target in the ../build.xml file. -->
  89.512 +    </target>
  89.513 +    <target if="do.depend.true" name="-compile-test-depend">
  89.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  89.515 +    </target>
  89.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  89.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  89.518 +        <copy todir="${build.test.classes.dir}">
  89.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  89.520 +        </copy>
  89.521 +    </target>
  89.522 +    <target name="-post-compile-test">
  89.523 +        <!-- Empty placeholder for easier customization. -->
  89.524 +        <!-- You can override this target in the ../build.xml file. -->
  89.525 +    </target>
  89.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  89.527 +    <target name="-pre-compile-test-single">
  89.528 +        <!-- Empty placeholder for easier customization. -->
  89.529 +        <!-- You can override this target in the ../build.xml file. -->
  89.530 +    </target>
  89.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  89.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  89.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  89.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}"/>
  89.535 +        <copy todir="${build.test.classes.dir}">
  89.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  89.537 +        </copy>
  89.538 +    </target>
  89.539 +    <target name="-post-compile-test-single">
  89.540 +        <!-- Empty placeholder for easier customization. -->
  89.541 +        <!-- You can override this target in the ../build.xml file. -->
  89.542 +    </target>
  89.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"/>
  89.544 +    <!--
  89.545 +                =======================
  89.546 +                JUNIT EXECUTION SECTION
  89.547 +                =======================
  89.548 +            -->
  89.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  89.550 +        <mkdir dir="${build.test.results.dir}"/>
  89.551 +    </target>
  89.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  89.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  89.554 +    </target>
  89.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  89.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  89.557 +    </target>
  89.558 +    <target depends="init" if="have.tests" name="test-report"/>
  89.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  89.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"/>
  89.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  89.562 +        <mkdir dir="${build.test.results.dir}"/>
  89.563 +    </target>
  89.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  89.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  89.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  89.567 +    </target>
  89.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  89.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  89.570 +    </target>
  89.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"/>
  89.572 +    <!--
  89.573 +                =======================
  89.574 +                JUNIT DEBUGGING SECTION
  89.575 +                =======================
  89.576 +            -->
  89.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  89.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  89.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  89.580 +        <delete file="${test.report.file}"/>
  89.581 +        <mkdir dir="${build.test.results.dir}"/>
  89.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}">
  89.583 +            <customize>
  89.584 +                <syspropertyset>
  89.585 +                    <propertyref prefix="test-sys-prop."/>
  89.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  89.587 +                </syspropertyset>
  89.588 +                <arg value="${test.class}"/>
  89.589 +                <arg value="showoutput=true"/>
  89.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  89.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  89.592 +            </customize>
  89.593 +        </j2seproject3:debug>
  89.594 +    </target>
  89.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  89.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  89.597 +    </target>
  89.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  89.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  89.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  89.601 +    </target>
  89.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  89.603 +    <!--
  89.604 +                =========================
  89.605 +                APPLET EXECUTION SECTION
  89.606 +                =========================
  89.607 +            -->
  89.608 +    <target depends="init,compile-single" name="run-applet">
  89.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  89.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  89.611 +            <customize>
  89.612 +                <arg value="${applet.url}"/>
  89.613 +            </customize>
  89.614 +        </j2seproject1:java>
  89.615 +    </target>
  89.616 +    <!--
  89.617 +                =========================
  89.618 +                APPLET DEBUGGING  SECTION
  89.619 +                =========================
  89.620 +            -->
  89.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  89.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  89.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  89.624 +            <customize>
  89.625 +                <arg value="${applet.url}"/>
  89.626 +            </customize>
  89.627 +        </j2seproject3:debug>
  89.628 +    </target>
  89.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  89.630 +    <!--
  89.631 +                ===============
  89.632 +                CLEANUP SECTION
  89.633 +                ===============
  89.634 +            -->
  89.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  89.636 +    <target depends="init" name="-do-clean">
  89.637 +        <delete dir="${build.dir}"/>
  89.638 +        <delete dir="${dist.dir}"/>
  89.639 +    </target>
  89.640 +    <target name="-post-clean">
  89.641 +        <!-- Empty placeholder for easier customization. -->
  89.642 +        <!-- You can override this target in the ../build.xml file. -->
  89.643 +    </target>
  89.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  89.645 +</project>
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/task2/solution08/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    90.3 @@ -0,0 +1,8 @@
    90.4 +build.xml.data.CRC32=2ab820eb
    90.5 +build.xml.script.CRC32=58a52595
    90.6 +build.xml.stylesheet.CRC32=be360661
    90.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    90.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    90.9 +nbproject/build-impl.xml.data.CRC32=a2ad29dd
   90.10 +nbproject/build-impl.xml.script.CRC32=43c3e6a6
   90.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/task2/solution08/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    91.3 @@ -0,0 +1,68 @@
    91.4 +application.title=currency
    91.5 +application.vendor=apidesign.org
    91.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    91.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    91.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    91.9 +build.classes.dir=${build.dir}/classes
   91.10 +build.classes.excludes=**/*.java,**/*.form
   91.11 +# This directory is removed when the project is cleaned:
   91.12 +build.dir=build
   91.13 +build.generated.dir=${build.dir}/generated
   91.14 +# Only compile against the classpath explicitly listed here:
   91.15 +build.sysclasspath=ignore
   91.16 +build.test.classes.dir=${build.dir}/test/classes
   91.17 +build.test.results.dir=${build.dir}/test/results
   91.18 +debug.classpath=\
   91.19 +    ${run.classpath}
   91.20 +debug.test.classpath=\
   91.21 +    ${run.test.classpath}
   91.22 +# This directory is removed when the project is cleaned:
   91.23 +dist.dir=dist
   91.24 +dist.jar=${dist.dir}/currency.jar
   91.25 +dist.javadoc.dir=${dist.dir}/javadoc
   91.26 +excludes=
   91.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   91.28 +file.reference.src-apifest08=..
   91.29 +includes=**
   91.30 +jar.compress=false
   91.31 +javac.classpath=
   91.32 +# Space-separated list of extra javac options
   91.33 +javac.compilerargs=
   91.34 +javac.deprecation=false
   91.35 +javac.source=1.5
   91.36 +javac.target=1.5
   91.37 +javac.test.classpath=\
   91.38 +    ${javac.classpath}:\
   91.39 +    ${build.classes.dir}:\
   91.40 +    ${file.reference.junit-4.4.jar}
   91.41 +javadoc.additionalparam=
   91.42 +javadoc.author=false
   91.43 +javadoc.encoding=
   91.44 +javadoc.noindex=false
   91.45 +javadoc.nonavbar=false
   91.46 +javadoc.notree=false
   91.47 +javadoc.private=false
   91.48 +javadoc.splitindex=true
   91.49 +javadoc.use=true
   91.50 +javadoc.version=false
   91.51 +javadoc.windowtitle=
   91.52 +jnlp.codebase.type=local
   91.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   91.54 +jnlp.descriptor=application
   91.55 +jnlp.enabled=false
   91.56 +jnlp.offline-allowed=false
   91.57 +jnlp.signed=false
   91.58 +meta.inf.dir=${src.dir}/META-INF
   91.59 +platform.active=default_platform
   91.60 +run.classpath=\
   91.61 +    ${javac.classpath}:\
   91.62 +    ${build.classes.dir}
   91.63 +# Space-separated list of JVM arguments used when running the project
   91.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   91.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   91.66 +run.jvmargs=
   91.67 +run.test.classpath=\
   91.68 +    ${javac.test.classpath}:\
   91.69 +    ${build.test.classes.dir}
   91.70 +src.dir=src
   91.71 +test.src.dir=test
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/task2/solution08/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    92.3 @@ -0,0 +1,16 @@
    92.4 +<?xml version="1.0" encoding="UTF-8"?>
    92.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    92.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    92.7 +    <configuration>
    92.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    92.9 +            <name>Currency Convertor Solution 08</name>
   92.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   92.11 +            <source-roots>
   92.12 +                <root id="src.dir"/>
   92.13 +            </source-roots>
   92.14 +            <test-roots>
   92.15 +                <root id="test.src.dir"/>
   92.16 +            </test-roots>
   92.17 +        </data>
   92.18 +    </configuration>
   92.19 +</project>
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/task2/solution08/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
    93.3 @@ -0,0 +1,55 @@
    93.4 +package org.apidesign.apifest08.currency;
    93.5 +
    93.6 +import java.util.Currency;
    93.7 +import java.util.Hashtable;
    93.8 +import java.util.Map;
    93.9 +
   93.10 +/** This is the skeleton class for your API. You need to make it public, so
   93.11 + * it is accessible to your client code (currently in Task1Test.java) file.
   93.12 + * <p>
   93.13 + * Feel free to create additional classes or rename this one, just keep all
   93.14 + * the API and its implementation in this package. Do not spread it outside
   93.15 + * to other packages.
   93.16 + */
   93.17 +public class Convertor {
   93.18 +    
   93.19 +    private static final Map<String, Float> EXCHANGE_RATES = new Hashtable<String, Float>() { {
   93.20 +            put("CZKUSD", 1/17F);
   93.21 +            put("USDCZK", 17F);
   93.22 +            put("SKKCZK", 100/80F);
   93.23 +            put("CZKSKK", 80/100F);
   93.24 +        }
   93.25 +    };
   93.26 +    
   93.27 +    private Currency currencyFirst;
   93.28 +    private Currency currencySecond;
   93.29 +    
   93.30 +    private Convertor(Currency currencyFirst, Currency currencySecond) {
   93.31 +        this.currencyFirst = currencyFirst;
   93.32 +        this.currencySecond = currencySecond;
   93.33 +    }
   93.34 +    
   93.35 +    public static Convertor getInstanceFor(Currency currencyFirst, Currency currencySecond) {
   93.36 +        return new Convertor(currencyFirst, currencySecond);
   93.37 +    }
   93.38 +    
   93.39 +    public float convert(float value, Currency toCurrency) {
   93.40 +        if (!toCurrency.equals(currencyFirst) && !toCurrency.equals(currencySecond)) {
   93.41 +            throw new IllegalArgumentException("Unsupported currency for this convertor!: " + toCurrency.getCurrencyCode());
   93.42 +        }
   93.43 +        
   93.44 +        Float rate = null;
   93.45 +        if (toCurrency.equals(currencyFirst)) {
   93.46 +            rate = EXCHANGE_RATES.get(currencyFirst.getCurrencyCode() + currencySecond.getCurrencyCode());
   93.47 +        }
   93.48 +        if (toCurrency.equals(currencySecond)) {
   93.49 +            rate = EXCHANGE_RATES.get(currencySecond.getCurrencyCode() + currencyFirst.getCurrencyCode());
   93.50 +        }
   93.51 +
   93.52 +        if (rate == null) {
   93.53 +            throw new IllegalStateException("Undefinied conversion!");
   93.54 +        }
   93.55 +
   93.56 +        return rate*value;
   93.57 +    }
   93.58 +}
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/task2/solution08/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
    94.3 @@ -0,0 +1,86 @@
    94.4 +package org.apidesign.apifest08.test;
    94.5 +
    94.6 +import java.util.Currency;
    94.7 +import junit.framework.TestCase;
    94.8 +import org.apidesign.apifest08.currency.Convertor;
    94.9 +
   94.10 +/** Finish the Convertor API, and then write bodies of methods inside
   94.11 + * of this class to match the given tasks. To fullfil your task, use the
   94.12 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
   94.13 + * Do not you reflection, or other hacks as your code
   94.14 + * shall run without any runtime permissions.
   94.15 + */
   94.16 +public class Task1Test extends TestCase {
   94.17 +    public Task1Test(String testName) {
   94.18 +        super(testName);
   94.19 +    }
   94.20 +
   94.21 +    @Override
   94.22 +    protected void setUp() throws Exception {
   94.23 +    }
   94.24 +
   94.25 +    @Override
   94.26 +    protected void tearDown() throws Exception {
   94.27 +    }
   94.28 +
   94.29 +    /** Create convertor that understands two currencies, CZK and
   94.30 +     *  USD. Make 1 USD == 17 CZK.
   94.31 +     *
   94.32 +     * Creation of the convertor shall not require subclassing of any class
   94.33 +     * or interface on the client side.
   94.34 +     *
   94.35 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   94.36 +     */
   94.37 +    public static Convertor createCZKtoUSD() {
   94.38 +        return Convertor.getInstanceFor(Currency.getInstance("CZK"), Currency.getInstance("USD"));
   94.39 +    }
   94.40 +
   94.41 +    /** Create convertor that understands two currencies, CZK and
   94.42 +     *  SKK. Make 100 SKK == 80 CZK.
   94.43 +     *
   94.44 +     * Creation of the convertor shall not require subclassing of any class
   94.45 +     * or interface on the client side.
   94.46 +     * 
   94.47 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   94.48 +     */
   94.49 +    public static Convertor createSKKtoCZK() {
   94.50 +        return Convertor.getInstanceFor(Currency.getInstance("SKK"), Currency.getInstance("CZK"));
   94.51 +    }
   94.52 +    
   94.53 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   94.54 +     * with it.
   94.55 +     */
   94.56 +    public void testCurrencyCZKUSD() throws Exception {
   94.57 +        Convertor c = createCZKtoUSD();
   94.58 +        Currency usd = Currency.getInstance("USD");
   94.59 +        Currency czk = Currency.getInstance("CZK");
   94.60 +        // convert $5 to CZK using c:
   94.61 +        // assertEquals("Result is 85 CZK");
   94.62 +        assertEquals(85F, c.convert(5, usd));
   94.63 +
   94.64 +        // convert $8 to CZK
   94.65 +        // assertEquals("Result is 136 CZK");
   94.66 +        assertEquals(136F, c.convert(8, usd));
   94.67 +
   94.68 +        // convert 1003CZK to USD
   94.69 +        // assertEquals("Result is 59 USD");
   94.70 +        assertEquals(59F, c.convert(1003, czk));
   94.71 +    }
   94.72 +
   94.73 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
   94.74 +     * with it.
   94.75 +     */
   94.76 +    public void testCurrencySKKCZK() throws Exception {
   94.77 +        Convertor c = createSKKtoCZK();
   94.78 +        Currency skk = Currency.getInstance("SKK");
   94.79 +        Currency czk = Currency.getInstance("CZK");
   94.80 +        // convert 16CZK using c:
   94.81 +        // assertEquals("Result is 20 SKK");
   94.82 +        assertEquals(20F, c.convert(16, skk));
   94.83 +
   94.84 +        // convert 500SKK to CZK
   94.85 +        // assertEquals("Result is 400 CZK");
   94.86 +        assertEquals(400F, c.convert(500, czk));
   94.87 +    }
   94.88 +}
   94.89 +
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/task2/solution09/build.xml	Wed Oct 01 10:43:05 2008 +0200
    95.3 @@ -0,0 +1,69 @@
    95.4 +<?xml version="1.0" encoding="UTF-8"?>
    95.5 +<!-- You may freely edit this file. See commented blocks below for -->
    95.6 +<!-- some examples of how to customize the build. -->
    95.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
    95.8 +<project name="currency" default="default" basedir=".">
    95.9 +    <description>Builds, tests, and runs the project.</description>
   95.10 +    <import file="nbproject/build-impl.xml"/>
   95.11 +    <!--
   95.12 +
   95.13 +    There exist several targets which are by default empty and which can be 
   95.14 +    used for execution of your tasks. These targets are usually executed 
   95.15 +    before and after some main targets. They are: 
   95.16 +
   95.17 +      -pre-init:                 called before initialization of project properties
   95.18 +      -post-init:                called after initialization of project properties
   95.19 +      -pre-compile:              called before javac compilation
   95.20 +      -post-compile:             called after javac compilation
   95.21 +      -pre-compile-single:       called before javac compilation of single file
   95.22 +      -post-compile-single:      called after javac compilation of single file
   95.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
   95.24 +      -post-compile-test:        called after javac compilation of JUnit tests
   95.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
   95.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
   95.27 +      -pre-jar:                  called before JAR building
   95.28 +      -post-jar:                 called after JAR building
   95.29 +      -post-clean:               called after cleaning build products
   95.30 +
   95.31 +    (Targets beginning with '-' are not intended to be called on their own.)
   95.32 +
   95.33 +    Example of inserting an obfuscator after compilation could look like this:
   95.34 +
   95.35 +        <target name="-post-compile">
   95.36 +            <obfuscate>
   95.37 +                <fileset dir="${build.classes.dir}"/>
   95.38 +            </obfuscate>
   95.39 +        </target>
   95.40 +
   95.41 +    For list of available properties check the imported 
   95.42 +    nbproject/build-impl.xml file. 
   95.43 +
   95.44 +
   95.45 +    Another way to customize the build is by overriding existing main targets.
   95.46 +    The targets of interest are: 
   95.47 +
   95.48 +      -init-macrodef-javac:     defines macro for javac compilation
   95.49 +      -init-macrodef-junit:     defines macro for junit execution
   95.50 +      -init-macrodef-debug:     defines macro for class debugging
   95.51 +      -init-macrodef-java:      defines macro for class execution
   95.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
   95.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
   95.54 +      run:                      execution of project 
   95.55 +      -javadoc-build:           Javadoc generation
   95.56 +      test-report:              JUnit report generation
   95.57 +
   95.58 +    An example of overriding the target for project execution could look like this:
   95.59 +
   95.60 +        <target name="run" depends="currency-impl.jar">
   95.61 +            <exec dir="bin" executable="launcher.exe">
   95.62 +                <arg file="${dist.jar}"/>
   95.63 +            </exec>
   95.64 +        </target>
   95.65 +
   95.66 +    Notice that the overridden target depends on the jar target and not only on 
   95.67 +    the compile target as the regular run target does. Again, for a list of available 
   95.68 +    properties which you can use, check the target you are overriding in the
   95.69 +    nbproject/build-impl.xml file. 
   95.70 +
   95.71 +    -->
   95.72 +</project>
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/task2/solution09/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
    96.3 @@ -0,0 +1,642 @@
    96.4 +<?xml version="1.0" encoding="UTF-8"?>
    96.5 +<!--
    96.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
    96.7 +***         EDIT ../build.xml INSTEAD         ***
    96.8 +
    96.9 +For the purpose of easier reading the script
   96.10 +is divided into following sections:
   96.11 +
   96.12 +  - initialization
   96.13 +  - compilation
   96.14 +  - jar
   96.15 +  - execution
   96.16 +  - debugging
   96.17 +  - javadoc
   96.18 +  - junit compilation
   96.19 +  - junit execution
   96.20 +  - junit debugging
   96.21 +  - applet
   96.22 +  - cleanup
   96.23 +
   96.24 +        -->
   96.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">
   96.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
   96.27 +    <!-- 
   96.28 +                ======================
   96.29 +                INITIALIZATION SECTION 
   96.30 +                ======================
   96.31 +            -->
   96.32 +    <target name="-pre-init">
   96.33 +        <!-- Empty placeholder for easier customization. -->
   96.34 +        <!-- You can override this target in the ../build.xml file. -->
   96.35 +    </target>
   96.36 +    <target depends="-pre-init" name="-init-private">
   96.37 +        <property file="nbproject/private/config.properties"/>
   96.38 +        <property file="nbproject/private/configs/${config}.properties"/>
   96.39 +        <property file="nbproject/private/private.properties"/>
   96.40 +    </target>
   96.41 +    <target depends="-pre-init,-init-private" name="-init-user">
   96.42 +        <property file="${user.properties.file}"/>
   96.43 +        <!-- The two properties below are usually overridden -->
   96.44 +        <!-- by the active platform. Just a fallback. -->
   96.45 +        <property name="default.javac.source" value="1.4"/>
   96.46 +        <property name="default.javac.target" value="1.4"/>
   96.47 +    </target>
   96.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
   96.49 +        <property file="nbproject/configs/${config}.properties"/>
   96.50 +        <property file="nbproject/project.properties"/>
   96.51 +    </target>
   96.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
   96.53 +        <available file="${manifest.file}" property="manifest.available"/>
   96.54 +        <condition property="manifest.available+main.class">
   96.55 +            <and>
   96.56 +                <isset property="manifest.available"/>
   96.57 +                <isset property="main.class"/>
   96.58 +                <not>
   96.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
   96.60 +                </not>
   96.61 +            </and>
   96.62 +        </condition>
   96.63 +        <condition property="manifest.available+main.class+mkdist.available">
   96.64 +            <and>
   96.65 +                <istrue value="${manifest.available+main.class}"/>
   96.66 +                <isset property="libs.CopyLibs.classpath"/>
   96.67 +            </and>
   96.68 +        </condition>
   96.69 +        <condition property="have.tests">
   96.70 +            <or>
   96.71 +                <available file="${test.src.dir}"/>
   96.72 +            </or>
   96.73 +        </condition>
   96.74 +        <condition property="have.sources">
   96.75 +            <or>
   96.76 +                <available file="${src.dir}"/>
   96.77 +            </or>
   96.78 +        </condition>
   96.79 +        <condition property="netbeans.home+have.tests">
   96.80 +            <and>
   96.81 +                <isset property="netbeans.home"/>
   96.82 +                <isset property="have.tests"/>
   96.83 +            </and>
   96.84 +        </condition>
   96.85 +        <condition property="no.javadoc.preview">
   96.86 +            <and>
   96.87 +                <isset property="javadoc.preview"/>
   96.88 +                <isfalse value="${javadoc.preview}"/>
   96.89 +            </and>
   96.90 +        </condition>
   96.91 +        <property name="run.jvmargs" value=""/>
   96.92 +        <property name="javac.compilerargs" value=""/>
   96.93 +        <property name="work.dir" value="${basedir}"/>
   96.94 +        <condition property="no.deps">
   96.95 +            <and>
   96.96 +                <istrue value="${no.dependencies}"/>
   96.97 +            </and>
   96.98 +        </condition>
   96.99 +        <property name="javac.debug" value="true"/>
  96.100 +        <property name="javadoc.preview" value="true"/>
  96.101 +        <property name="application.args" value=""/>
  96.102 +        <property name="source.encoding" value="${file.encoding}"/>
  96.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
  96.104 +            <and>
  96.105 +                <isset property="javadoc.encoding"/>
  96.106 +                <not>
  96.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
  96.108 +                </not>
  96.109 +            </and>
  96.110 +        </condition>
  96.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
  96.112 +        <property name="includes" value="**"/>
  96.113 +        <property name="excludes" value=""/>
  96.114 +        <property name="do.depend" value="false"/>
  96.115 +        <condition property="do.depend.true">
  96.116 +            <istrue value="${do.depend}"/>
  96.117 +        </condition>
  96.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
  96.119 +            <and>
  96.120 +                <isset property="jaxws.endorsed.dir"/>
  96.121 +                <available file="nbproject/jaxws-build.xml"/>
  96.122 +            </and>
  96.123 +        </condition>
  96.124 +    </target>
  96.125 +    <target name="-post-init">
  96.126 +        <!-- Empty placeholder for easier customization. -->
  96.127 +        <!-- You can override this target in the ../build.xml file. -->
  96.128 +    </target>
  96.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
  96.130 +        <fail unless="src.dir">Must set src.dir</fail>
  96.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
  96.132 +        <fail unless="build.dir">Must set build.dir</fail>
  96.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
  96.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
  96.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
  96.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
  96.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
  96.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
  96.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
  96.140 +    </target>
  96.141 +    <target name="-init-macrodef-property">
  96.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
  96.143 +            <attribute name="name"/>
  96.144 +            <attribute name="value"/>
  96.145 +            <sequential>
  96.146 +                <property name="@{name}" value="${@{value}}"/>
  96.147 +            </sequential>
  96.148 +        </macrodef>
  96.149 +    </target>
  96.150 +    <target name="-init-macrodef-javac">
  96.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
  96.152 +            <attribute default="${src.dir}" name="srcdir"/>
  96.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
  96.154 +            <attribute default="${javac.classpath}" name="classpath"/>
  96.155 +            <attribute default="${includes}" name="includes"/>
  96.156 +            <attribute default="${excludes}" name="excludes"/>
  96.157 +            <attribute default="${javac.debug}" name="debug"/>
  96.158 +            <attribute default="" name="sourcepath"/>
  96.159 +            <element name="customize" optional="true"/>
  96.160 +            <sequential>
  96.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}">
  96.162 +                    <classpath>
  96.163 +                        <path path="@{classpath}"/>
  96.164 +                    </classpath>
  96.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
  96.166 +                    <customize/>
  96.167 +                </javac>
  96.168 +            </sequential>
  96.169 +        </macrodef>
  96.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
  96.171 +            <attribute default="${src.dir}" name="srcdir"/>
  96.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
  96.173 +            <attribute default="${javac.classpath}" name="classpath"/>
  96.174 +            <sequential>
  96.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
  96.176 +                    <classpath>
  96.177 +                        <path path="@{classpath}"/>
  96.178 +                    </classpath>
  96.179 +                </depend>
  96.180 +            </sequential>
  96.181 +        </macrodef>
  96.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
  96.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
  96.184 +            <sequential>
  96.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
  96.186 +                <pathconvert pathsep="," property="javac.includes.binary">
  96.187 +                    <path>
  96.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
  96.189 +                    </path>
  96.190 +                    <globmapper from="*.java" to="*.class"/>
  96.191 +                </pathconvert>
  96.192 +                <delete>
  96.193 +                    <files includes="${javac.includes.binary}"/>
  96.194 +                </delete>
  96.195 +            </sequential>
  96.196 +        </macrodef>
  96.197 +    </target>
  96.198 +    <target name="-init-macrodef-junit">
  96.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
  96.200 +            <attribute default="${includes}" name="includes"/>
  96.201 +            <attribute default="${excludes}" name="excludes"/>
  96.202 +            <attribute default="**" name="testincludes"/>
  96.203 +            <sequential>
  96.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
  96.205 +                    <batchtest todir="${build.test.results.dir}">
  96.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
  96.207 +                            <filename name="@{testincludes}"/>
  96.208 +                        </fileset>
  96.209 +                    </batchtest>
  96.210 +                    <classpath>
  96.211 +                        <path path="${run.test.classpath}"/>
  96.212 +                    </classpath>
  96.213 +                    <syspropertyset>
  96.214 +                        <propertyref prefix="test-sys-prop."/>
  96.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
  96.216 +                    </syspropertyset>
  96.217 +                    <formatter type="brief" usefile="false"/>
  96.218 +                    <formatter type="xml"/>
  96.219 +                    <jvmarg line="${run.jvmargs}"/>
  96.220 +                </junit>
  96.221 +            </sequential>
  96.222 +        </macrodef>
  96.223 +    </target>
  96.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
  96.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
  96.226 +            <attribute default="${main.class}" name="name"/>
  96.227 +            <attribute default="${debug.classpath}" name="classpath"/>
  96.228 +            <attribute default="" name="stopclassname"/>
  96.229 +            <sequential>
  96.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
  96.231 +                    <classpath>
  96.232 +                        <path path="@{classpath}"/>
  96.233 +                    </classpath>
  96.234 +                </nbjpdastart>
  96.235 +            </sequential>
  96.236 +        </macrodef>
  96.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
  96.238 +            <attribute default="${build.classes.dir}" name="dir"/>
  96.239 +            <sequential>
  96.240 +                <nbjpdareload>
  96.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
  96.242 +                        <include name="${fix.includes}*.class"/>
  96.243 +                    </fileset>
  96.244 +                </nbjpdareload>
  96.245 +            </sequential>
  96.246 +        </macrodef>
  96.247 +    </target>
  96.248 +    <target name="-init-debug-args">
  96.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
  96.250 +        <condition property="have-jdk-older-than-1.4">
  96.251 +            <or>
  96.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
  96.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
  96.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
  96.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
  96.256 +            </or>
  96.257 +        </condition>
  96.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
  96.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
  96.260 +        </condition>
  96.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
  96.262 +            <os family="windows"/>
  96.263 +        </condition>
  96.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
  96.265 +            <isset property="debug.transport"/>
  96.266 +        </condition>
  96.267 +    </target>
  96.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
  96.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
  96.270 +            <attribute default="${main.class}" name="classname"/>
  96.271 +            <attribute default="${debug.classpath}" name="classpath"/>
  96.272 +            <element name="customize" optional="true"/>
  96.273 +            <sequential>
  96.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  96.275 +                    <jvmarg line="${debug-args-line}"/>
  96.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
  96.277 +                    <jvmarg line="${run.jvmargs}"/>
  96.278 +                    <classpath>
  96.279 +                        <path path="@{classpath}"/>
  96.280 +                    </classpath>
  96.281 +                    <syspropertyset>
  96.282 +                        <propertyref prefix="run-sys-prop."/>
  96.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  96.284 +                    </syspropertyset>
  96.285 +                    <customize/>
  96.286 +                </java>
  96.287 +            </sequential>
  96.288 +        </macrodef>
  96.289 +    </target>
  96.290 +    <target name="-init-macrodef-java">
  96.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
  96.292 +            <attribute default="${main.class}" name="classname"/>
  96.293 +            <element name="customize" optional="true"/>
  96.294 +            <sequential>
  96.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
  96.296 +                    <jvmarg line="${run.jvmargs}"/>
  96.297 +                    <classpath>
  96.298 +                        <path path="${run.classpath}"/>
  96.299 +                    </classpath>
  96.300 +                    <syspropertyset>
  96.301 +                        <propertyref prefix="run-sys-prop."/>
  96.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
  96.303 +                    </syspropertyset>
  96.304 +                    <customize/>
  96.305 +                </java>
  96.306 +            </sequential>
  96.307 +        </macrodef>
  96.308 +    </target>
  96.309 +    <target name="-init-presetdef-jar">
  96.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
  96.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
  96.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
  96.313 +            </jar>
  96.314 +        </presetdef>
  96.315 +    </target>
  96.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"/>
  96.317 +    <!--
  96.318 +                ===================
  96.319 +                COMPILATION SECTION
  96.320 +                ===================
  96.321 +            -->
  96.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
  96.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
  96.324 +    <target depends="init" name="-check-automatic-build">
  96.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
  96.326 +    </target>
  96.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
  96.328 +        <antcall target="clean"/>
  96.329 +    </target>
  96.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
  96.331 +        <mkdir dir="${build.classes.dir}"/>
  96.332 +    </target>
  96.333 +    <target name="-pre-compile">
  96.334 +        <!-- Empty placeholder for easier customization. -->
  96.335 +        <!-- You can override this target in the ../build.xml file. -->
  96.336 +    </target>
  96.337 +    <target if="do.depend.true" name="-compile-depend">
  96.338 +        <j2seproject3:depend/>
  96.339 +    </target>
  96.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
  96.341 +        <j2seproject3:javac/>
  96.342 +        <copy todir="${build.classes.dir}">
  96.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  96.344 +        </copy>
  96.345 +    </target>
  96.346 +    <target name="-post-compile">
  96.347 +        <!-- Empty placeholder for easier customization. -->
  96.348 +        <!-- You can override this target in the ../build.xml file. -->
  96.349 +    </target>
  96.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
  96.351 +    <target name="-pre-compile-single">
  96.352 +        <!-- Empty placeholder for easier customization. -->
  96.353 +        <!-- You can override this target in the ../build.xml file. -->
  96.354 +    </target>
  96.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
  96.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  96.357 +        <j2seproject3:force-recompile/>
  96.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
  96.359 +    </target>
  96.360 +    <target name="-post-compile-single">
  96.361 +        <!-- Empty placeholder for easier customization. -->
  96.362 +        <!-- You can override this target in the ../build.xml file. -->
  96.363 +    </target>
  96.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
  96.365 +    <!--
  96.366 +                ====================
  96.367 +                JAR BUILDING SECTION
  96.368 +                ====================
  96.369 +            -->
  96.370 +    <target depends="init" name="-pre-pre-jar">
  96.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
  96.372 +        <mkdir dir="${dist.jar.dir}"/>
  96.373 +    </target>
  96.374 +    <target name="-pre-jar">
  96.375 +        <!-- Empty placeholder for easier customization. -->
  96.376 +        <!-- You can override this target in the ../build.xml file. -->
  96.377 +    </target>
  96.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
  96.379 +        <j2seproject1:jar/>
  96.380 +    </target>
  96.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
  96.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
  96.383 +    </target>
  96.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">
  96.385 +        <j2seproject1:jar manifest="${manifest.file}">
  96.386 +            <j2seproject1:manifest>
  96.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
  96.388 +            </j2seproject1:manifest>
  96.389 +        </j2seproject1:jar>
  96.390 +        <echo>To run this application from the command line without Ant, try:</echo>
  96.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  96.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  96.393 +        <pathconvert property="run.classpath.with.dist.jar">
  96.394 +            <path path="${run.classpath}"/>
  96.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
  96.396 +        </pathconvert>
  96.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
  96.398 +    </target>
  96.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
  96.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
  96.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
  96.402 +            <path path="${run.classpath}"/>
  96.403 +            <map from="${build.classes.dir.resolved}" to=""/>
  96.404 +        </pathconvert>
  96.405 +        <pathconvert pathsep=" " property="jar.classpath">
  96.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
  96.407 +            <chainedmapper>
  96.408 +                <flattenmapper/>
  96.409 +                <globmapper from="*" to="lib/*"/>
  96.410 +            </chainedmapper>
  96.411 +        </pathconvert>
  96.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
  96.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
  96.414 +            <fileset dir="${build.classes.dir}"/>
  96.415 +            <manifest>
  96.416 +                <attribute name="Main-Class" value="${main.class}"/>
  96.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
  96.418 +            </manifest>
  96.419 +        </copylibs>
  96.420 +        <echo>To run this application from the command line without Ant, try:</echo>
  96.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
  96.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
  96.423 +    </target>
  96.424 +    <target name="-post-jar">
  96.425 +        <!-- Empty placeholder for easier customization. -->
  96.426 +        <!-- You can override this target in the ../build.xml file. -->
  96.427 +    </target>
  96.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"/>
  96.429 +    <!--
  96.430 +                =================
  96.431 +                EXECUTION SECTION
  96.432 +                =================
  96.433 +            -->
  96.434 +    <target depends="init,compile" description="Run a main class." name="run">
  96.435 +        <j2seproject1:java>
  96.436 +            <customize>
  96.437 +                <arg line="${application.args}"/>
  96.438 +            </customize>
  96.439 +        </j2seproject1:java>
  96.440 +    </target>
  96.441 +    <target name="-do-not-recompile">
  96.442 +        <property name="javac.includes.binary" value=""/>
  96.443 +    </target>
  96.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
  96.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
  96.446 +        <j2seproject1:java classname="${run.class}"/>
  96.447 +    </target>
  96.448 +    <!--
  96.449 +                =================
  96.450 +                DEBUGGING SECTION
  96.451 +                =================
  96.452 +            -->
  96.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
  96.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
  96.455 +    </target>
  96.456 +    <target depends="init,compile" name="-debug-start-debuggee">
  96.457 +        <j2seproject3:debug>
  96.458 +            <customize>
  96.459 +                <arg line="${application.args}"/>
  96.460 +            </customize>
  96.461 +        </j2seproject3:debug>
  96.462 +    </target>
  96.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
  96.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
  96.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
  96.466 +    </target>
  96.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
  96.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
  96.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
  96.470 +        <j2seproject3:debug classname="${debug.class}"/>
  96.471 +    </target>
  96.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
  96.473 +    <target depends="init" name="-pre-debug-fix">
  96.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
  96.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
  96.476 +    </target>
  96.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
  96.478 +        <j2seproject1:nbjpdareload/>
  96.479 +    </target>
  96.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
  96.481 +    <!--
  96.482 +                ===============
  96.483 +                JAVADOC SECTION
  96.484 +                ===============
  96.485 +            -->
  96.486 +    <target depends="init" name="-javadoc-build">
  96.487 +        <mkdir dir="${dist.javadoc.dir}"/>
  96.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}">
  96.489 +            <classpath>
  96.490 +                <path path="${javac.classpath}"/>
  96.491 +            </classpath>
  96.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
  96.493 +                <filename name="**/*.java"/>
  96.494 +            </fileset>
  96.495 +        </javadoc>
  96.496 +    </target>
  96.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
  96.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
  96.499 +    </target>
  96.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
  96.501 +    <!--
  96.502 +                =========================
  96.503 +                JUNIT COMPILATION SECTION
  96.504 +                =========================
  96.505 +            -->
  96.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
  96.507 +        <mkdir dir="${build.test.classes.dir}"/>
  96.508 +    </target>
  96.509 +    <target name="-pre-compile-test">
  96.510 +        <!-- Empty placeholder for easier customization. -->
  96.511 +        <!-- You can override this target in the ../build.xml file. -->
  96.512 +    </target>
  96.513 +    <target if="do.depend.true" name="-compile-test-depend">
  96.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  96.515 +    </target>
  96.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
  96.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
  96.518 +        <copy todir="${build.test.classes.dir}">
  96.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  96.520 +        </copy>
  96.521 +    </target>
  96.522 +    <target name="-post-compile-test">
  96.523 +        <!-- Empty placeholder for easier customization. -->
  96.524 +        <!-- You can override this target in the ../build.xml file. -->
  96.525 +    </target>
  96.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
  96.527 +    <target name="-pre-compile-test-single">
  96.528 +        <!-- Empty placeholder for easier customization. -->
  96.529 +        <!-- You can override this target in the ../build.xml file. -->
  96.530 +    </target>
  96.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
  96.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
  96.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
  96.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}"/>
  96.535 +        <copy todir="${build.test.classes.dir}">
  96.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
  96.537 +        </copy>
  96.538 +    </target>
  96.539 +    <target name="-post-compile-test-single">
  96.540 +        <!-- Empty placeholder for easier customization. -->
  96.541 +        <!-- You can override this target in the ../build.xml file. -->
  96.542 +    </target>
  96.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"/>
  96.544 +    <!--
  96.545 +                =======================
  96.546 +                JUNIT EXECUTION SECTION
  96.547 +                =======================
  96.548 +            -->
  96.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
  96.550 +        <mkdir dir="${build.test.results.dir}"/>
  96.551 +    </target>
  96.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
  96.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
  96.554 +    </target>
  96.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
  96.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  96.557 +    </target>
  96.558 +    <target depends="init" if="have.tests" name="test-report"/>
  96.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
  96.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"/>
  96.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
  96.562 +        <mkdir dir="${build.test.results.dir}"/>
  96.563 +    </target>
  96.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
  96.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
  96.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
  96.567 +    </target>
  96.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
  96.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
  96.570 +    </target>
  96.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"/>
  96.572 +    <!--
  96.573 +                =======================
  96.574 +                JUNIT DEBUGGING SECTION
  96.575 +                =======================
  96.576 +            -->
  96.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
  96.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
  96.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
  96.580 +        <delete file="${test.report.file}"/>
  96.581 +        <mkdir dir="${build.test.results.dir}"/>
  96.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}">
  96.583 +            <customize>
  96.584 +                <syspropertyset>
  96.585 +                    <propertyref prefix="test-sys-prop."/>
  96.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
  96.587 +                </syspropertyset>
  96.588 +                <arg value="${test.class}"/>
  96.589 +                <arg value="showoutput=true"/>
  96.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
  96.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
  96.592 +            </customize>
  96.593 +        </j2seproject3:debug>
  96.594 +    </target>
  96.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
  96.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
  96.597 +    </target>
  96.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
  96.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
  96.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
  96.601 +    </target>
  96.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
  96.603 +    <!--
  96.604 +                =========================
  96.605 +                APPLET EXECUTION SECTION
  96.606 +                =========================
  96.607 +            -->
  96.608 +    <target depends="init,compile-single" name="run-applet">
  96.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  96.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
  96.611 +            <customize>
  96.612 +                <arg value="${applet.url}"/>
  96.613 +            </customize>
  96.614 +        </j2seproject1:java>
  96.615 +    </target>
  96.616 +    <!--
  96.617 +                =========================
  96.618 +                APPLET DEBUGGING  SECTION
  96.619 +                =========================
  96.620 +            -->
  96.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
  96.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
  96.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
  96.624 +            <customize>
  96.625 +                <arg value="${applet.url}"/>
  96.626 +            </customize>
  96.627 +        </j2seproject3:debug>
  96.628 +    </target>
  96.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
  96.630 +    <!--
  96.631 +                ===============
  96.632 +                CLEANUP SECTION
  96.633 +                ===============
  96.634 +            -->
  96.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
  96.636 +    <target depends="init" name="-do-clean">
  96.637 +        <delete dir="${build.dir}"/>
  96.638 +        <delete dir="${dist.dir}"/>
  96.639 +    </target>
  96.640 +    <target name="-post-clean">
  96.641 +        <!-- Empty placeholder for easier customization. -->
  96.642 +        <!-- You can override this target in the ../build.xml file. -->
  96.643 +    </target>
  96.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
  96.645 +</project>
    97.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.2 +++ b/task2/solution09/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
    97.3 @@ -0,0 +1,8 @@
    97.4 +build.xml.data.CRC32=2ab820eb
    97.5 +build.xml.script.CRC32=58a52595
    97.6 +build.xml.stylesheet.CRC32=be360661
    97.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    97.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
    97.9 +nbproject/build-impl.xml.data.CRC32=cab2f6f1
   97.10 +nbproject/build-impl.xml.script.CRC32=711fa7d6
   97.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/task2/solution09/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
    98.3 @@ -0,0 +1,68 @@
    98.4 +application.title=currency
    98.5 +application.vendor=apidesign.org
    98.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
    98.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
    98.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
    98.9 +build.classes.dir=${build.dir}/classes
   98.10 +build.classes.excludes=**/*.java,**/*.form
   98.11 +# This directory is removed when the project is cleaned:
   98.12 +build.dir=build
   98.13 +build.generated.dir=${build.dir}/generated
   98.14 +# Only compile against the classpath explicitly listed here:
   98.15 +build.sysclasspath=ignore
   98.16 +build.test.classes.dir=${build.dir}/test/classes
   98.17 +build.test.results.dir=${build.dir}/test/results
   98.18 +debug.classpath=\
   98.19 +    ${run.classpath}
   98.20 +debug.test.classpath=\
   98.21 +    ${run.test.classpath}
   98.22 +# This directory is removed when the project is cleaned:
   98.23 +dist.dir=dist
   98.24 +dist.jar=${dist.dir}/currency.jar
   98.25 +dist.javadoc.dir=${dist.dir}/javadoc
   98.26 +excludes=
   98.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
   98.28 +file.reference.src-apifest08=..
   98.29 +includes=**
   98.30 +jar.compress=false
   98.31 +javac.classpath=
   98.32 +# Space-separated list of extra javac options
   98.33 +javac.compilerargs=
   98.34 +javac.deprecation=false
   98.35 +javac.source=1.5
   98.36 +javac.target=1.5
   98.37 +javac.test.classpath=\
   98.38 +    ${javac.classpath}:\
   98.39 +    ${build.classes.dir}:\
   98.40 +    ${file.reference.junit-4.4.jar}
   98.41 +javadoc.additionalparam=
   98.42 +javadoc.author=false
   98.43 +javadoc.encoding=
   98.44 +javadoc.noindex=false
   98.45 +javadoc.nonavbar=false
   98.46 +javadoc.notree=false
   98.47 +javadoc.private=false
   98.48 +javadoc.splitindex=true
   98.49 +javadoc.use=true
   98.50 +javadoc.version=false
   98.51 +javadoc.windowtitle=
   98.52 +jnlp.codebase.type=local
   98.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
   98.54 +jnlp.descriptor=application
   98.55 +jnlp.enabled=false
   98.56 +jnlp.offline-allowed=false
   98.57 +jnlp.signed=false
   98.58 +meta.inf.dir=${src.dir}/META-INF
   98.59 +platform.active=default_platform
   98.60 +run.classpath=\
   98.61 +    ${javac.classpath}:\
   98.62 +    ${build.classes.dir}
   98.63 +# Space-separated list of JVM arguments used when running the project
   98.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
   98.65 +# or test-sys-prop.name=value to set system properties for unit tests):
   98.66 +run.jvmargs=
   98.67 +run.test.classpath=\
   98.68 +    ${javac.test.classpath}:\
   98.69 +    ${build.test.classes.dir}
   98.70 +src.dir=src
   98.71 +test.src.dir=test
    99.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.2 +++ b/task2/solution09/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
    99.3 @@ -0,0 +1,16 @@
    99.4 +<?xml version="1.0" encoding="UTF-8"?>
    99.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
    99.6 +    <type>org.netbeans.modules.java.j2seproject</type>
    99.7 +    <configuration>
    99.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
    99.9 +            <name>Currency Convertor Solution 09</name>
   99.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
   99.11 +            <source-roots>
   99.12 +                <root id="src.dir"/>
   99.13 +            </source-roots>
   99.14 +            <test-roots>
   99.15 +                <root id="test.src.dir"/>
   99.16 +            </test-roots>
   99.17 +        </data>
   99.18 +    </configuration>
   99.19 +</project>
   100.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.2 +++ b/task2/solution09/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
   100.3 @@ -0,0 +1,26 @@
   100.4 +package org.apidesign.apifest08.currency;
   100.5 +
   100.6 +/** This is the skeleton class for your API. You need to make it public, so
   100.7 + * it is accessible to your client code (currently in Task1Test.java) file.
   100.8 + * <p>
   100.9 + * Feel free to create additional classes or rename this one, just keep all
  100.10 + * the API and its implementation in this package. Do not spread it outside
  100.11 + * to other packages.
  100.12 + */
  100.13 +public interface Convertor {
  100.14 +
  100.15 +    /**
  100.16 +     * converts amount in first currency to amount second currency.
  100.17 +     * @param amountInCents the amount of first currency in cents (or equivalent)
  100.18 +     * @return the amount in the second currency in cents (or equivalent)
  100.19 +     */
  100.20 +    public long convertTo(long amountInCents);
  100.21 +
  100.22 +
  100.23 +    /**
  100.24 +     * converts from second currency amount to first currency amount.
  100.25 +     * @param amountInCents the amount of second currency in cents (or equivalent)
  100.26 +     * @return the amount in the first currency in cents (or equivalent)
  100.27 +     */
  100.28 +    public long convertFrom(long amountInCents);
  100.29 +}
   101.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.2 +++ b/task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
   101.3 @@ -0,0 +1,38 @@
   101.4 +package org.apidesign.apifest08.currency;
   101.5 +
   101.6 +import java.math.BigDecimal;
   101.7 +
   101.8 +
   101.9 +public class ConvertorFactory {
  101.10 +
  101.11 +    public static Convertor getConvertor(CurrencyType from, CurrencyType to) {
  101.12 +        if (from == CurrencyType.CZK && to == CurrencyType.USD) {
  101.13 +             return new BasicConvertor(new BigDecimal(17));
  101.14 +        } else if (from == CurrencyType.SKK && to == CurrencyType.CZK) {
  101.15 +            double rate = 0.8d;
  101.16 +            return new BasicConvertor(new BigDecimal(rate));
  101.17 +        }
  101.18 +
  101.19 +
  101.20 +        throw new UnsupportedOperationException("Conversion not supported now");
  101.21 +    }
  101.22 +
  101.23 +    private static class BasicConvertor implements Convertor {
  101.24 +
  101.25 +        private final BigDecimal conversionRate;
  101.26 +
  101.27 +        BasicConvertor(BigDecimal conversionRate) {
  101.28 +            this.conversionRate = conversionRate;
  101.29 +        }
  101.30 +
  101.31 +        @Override
  101.32 +        public long convertTo(long amount) {
  101.33 +            return (long) (conversionRate.doubleValue() * amount);
  101.34 +        }
  101.35 +
  101.36 +        @Override
  101.37 +        public long convertFrom(long amount) {
  101.38 +            return (long) (amount / conversionRate.doubleValue());
  101.39 +        }
  101.40 +    }
  101.41 +}
   102.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.2 +++ b/task2/solution09/src/org/apidesign/apifest08/currency/CurrencyType.java	Wed Oct 01 10:43:05 2008 +0200
   102.3 @@ -0,0 +1,7 @@
   102.4 +package org.apidesign.apifest08.currency;
   102.5 +
   102.6 +public enum CurrencyType {
   102.7 +
   102.8 +    CZK, SKK, USD;
   102.9 +    
  102.10 +}
   103.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.2 +++ b/task2/solution09/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   103.3 @@ -0,0 +1,77 @@
   103.4 +package org.apidesign.apifest08.test;
   103.5 +
   103.6 +import junit.framework.TestCase;
   103.7 +import org.apidesign.apifest08.currency.Convertor;
   103.8 +import org.apidesign.apifest08.currency.ConvertorFactory;
   103.9 +import org.apidesign.apifest08.currency.CurrencyType;
  103.10 +
  103.11 +/** Finish the Convertor API, and then write bodies of methods inside
  103.12 + * of this class to match the given tasks. To fullfil your task, use the
  103.13 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
  103.14 + * Do not you reflection, or other hacks as your code
  103.15 + * shall run without any runtime permissions.
  103.16 + */
  103.17 +public class Task1Test extends TestCase {
  103.18 +    public Task1Test(String testName) {
  103.19 +        super(testName);
  103.20 +    }
  103.21 +
  103.22 +
  103.23 +    /** Create convertor that understands two currencies, CZK and
  103.24 +     *  USD. Make 1 USD == 17 CZK.
  103.25 +     *
  103.26 +     * Creation of the convertor shall not require subclassing of any class
  103.27 +     * or interface on the client side.
  103.28 +     *
  103.29 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
  103.30 +     */
  103.31 +    public static Convertor createCZKtoUSD() {
  103.32 +        return ConvertorFactory.getConvertor(CurrencyType.CZK, CurrencyType.USD);
  103.33 +    }
  103.34 +
  103.35 +    /** Create convertor that understands two currencies, CZK and
  103.36 +     *  SKK. Make 100 SKK == 80 CZK.
  103.37 +     *
  103.38 +     * Creation of the convertor shall not require subclassing of any class
  103.39 +     * or interface on the client side.
  103.40 +     * 
  103.41 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  103.42 +     */
  103.43 +    public static Convertor createSKKtoCZK() {
  103.44 +        return ConvertorFactory.getConvertor(CurrencyType.SKK, CurrencyType.CZK);
  103.45 +    }
  103.46 +    
  103.47 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
  103.48 +     * with it.
  103.49 +     */
  103.50 +    public void testCurrencyCZKUSD() throws Exception {
  103.51 +        Convertor c = createCZKtoUSD();
  103.52 +
  103.53 +        // convert $5 to CZK using c:
  103.54 +        // assertEquals("Result is 85 CZK");
  103.55 +        assertEquals(85, c.convertTo(5));
  103.56 +
  103.57 +        // convert $8 to CZK
  103.58 +        // assertEquals("Result is 136 CZK");
  103.59 +        assertEquals(136, c.convertTo(8));
  103.60 +
  103.61 +        // convert 1003CZK to USD
  103.62 +        // assertEquals("Result is 59 USD");
  103.63 +        assertEquals(59, c.convertFrom(1003));
  103.64 +    }
  103.65 +
  103.66 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
  103.67 +     * with it.
  103.68 +     */
  103.69 +    public void testCurrencySKKCZK() throws Exception {
  103.70 +        Convertor c = createSKKtoCZK();
  103.71 +        // convert 16CZK using c:
  103.72 +        // assertEquals("Result is 20 SKK");
  103.73 +        assertEquals(20, c.convertFrom(16));
  103.74 +
  103.75 +        // convert 500SKK to CZK
  103.76 +        // assertEquals("Result is 400 CZK");
  103.77 +        assertEquals(400, c.convertTo(500));
  103.78 +    }
  103.79 +}
  103.80 +
   104.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.2 +++ b/task2/solution10/build.xml	Wed Oct 01 10:43:05 2008 +0200
   104.3 @@ -0,0 +1,69 @@
   104.4 +<?xml version="1.0" encoding="UTF-8"?>
   104.5 +<!-- You may freely edit this file. See commented blocks below for -->
   104.6 +<!-- some examples of how to customize the build. -->
   104.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
   104.8 +<project name="Currency_Convertor_Solution_10" default="default" basedir=".">
   104.9 +    <description>Builds, tests, and runs the project Currency Convertor Solution 10.</description>
  104.10 +    <import file="nbproject/build-impl.xml"/>
  104.11 +    <!--
  104.12 +
  104.13 +    There exist several targets which are by default empty and which can be 
  104.14 +    used for execution of your tasks. These targets are usually executed 
  104.15 +    before and after some main targets. They are: 
  104.16 +
  104.17 +      -pre-init:                 called before initialization of project properties
  104.18 +      -post-init:                called after initialization of project properties
  104.19 +      -pre-compile:              called before javac compilation
  104.20 +      -post-compile:             called after javac compilation
  104.21 +      -pre-compile-single:       called before javac compilation of single file
  104.22 +      -post-compile-single:      called after javac compilation of single file
  104.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
  104.24 +      -post-compile-test:        called after javac compilation of JUnit tests
  104.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
  104.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
  104.27 +      -pre-jar:                  called before JAR building
  104.28 +      -post-jar:                 called after JAR building
  104.29 +      -post-clean:               called after cleaning build products
  104.30 +
  104.31 +    (Targets beginning with '-' are not intended to be called on their own.)
  104.32 +
  104.33 +    Example of inserting an obfuscator after compilation could look like this:
  104.34 +
  104.35 +        <target name="-post-compile">
  104.36 +            <obfuscate>
  104.37 +                <fileset dir="${build.classes.dir}"/>
  104.38 +            </obfuscate>
  104.39 +        </target>
  104.40 +
  104.41 +    For list of available properties check the imported 
  104.42 +    nbproject/build-impl.xml file. 
  104.43 +
  104.44 +
  104.45 +    Another way to customize the build is by overriding existing main targets.
  104.46 +    The targets of interest are: 
  104.47 +
  104.48 +      -init-macrodef-javac:     defines macro for javac compilation
  104.49 +      -init-macrodef-junit:     defines macro for junit execution
  104.50 +      -init-macrodef-debug:     defines macro for class debugging
  104.51 +      -init-macrodef-java:      defines macro for class execution
  104.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  104.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  104.54 +      run:                      execution of project 
  104.55 +      -javadoc-build:           Javadoc generation
  104.56 +      test-report:              JUnit report generation
  104.57 +
  104.58 +    An example of overriding the target for project execution could look like this:
  104.59 +
  104.60 +        <target name="run" depends="Currency_Convertor_Solution_10-impl.jar">
  104.61 +            <exec dir="bin" executable="launcher.exe">
  104.62 +                <arg file="${dist.jar}"/>
  104.63 +            </exec>
  104.64 +        </target>
  104.65 +
  104.66 +    Notice that the overridden target depends on the jar target and not only on 
  104.67 +    the compile target as the regular run target does. Again, for a list of available 
  104.68 +    properties which you can use, check the target you are overriding in the
  104.69 +    nbproject/build-impl.xml file. 
  104.70 +
  104.71 +    -->
  104.72 +</project>
   105.1 Binary file task2/solution10/nbproject/.DS_Store has changed
   106.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.2 +++ b/task2/solution10/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
   106.3 @@ -0,0 +1,642 @@
   106.4 +<?xml version="1.0" encoding="UTF-8"?>
   106.5 +<!--
   106.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
   106.7 +***         EDIT ../build.xml INSTEAD         ***
   106.8 +
   106.9 +For the purpose of easier reading the script
  106.10 +is divided into following sections:
  106.11 +
  106.12 +  - initialization
  106.13 +  - compilation
  106.14 +  - jar
  106.15 +  - execution
  106.16 +  - debugging
  106.17 +  - javadoc
  106.18 +  - junit compilation
  106.19 +  - junit execution
  106.20 +  - junit debugging
  106.21 +  - applet
  106.22 +  - cleanup
  106.23 +
  106.24 +        -->
  106.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">
  106.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
  106.27 +    <!-- 
  106.28 +                ======================
  106.29 +                INITIALIZATION SECTION 
  106.30 +                ======================
  106.31 +            -->
  106.32 +    <target name="-pre-init">
  106.33 +        <!-- Empty placeholder for easier customization. -->
  106.34 +        <!-- You can override this target in the ../build.xml file. -->
  106.35 +    </target>
  106.36 +    <target depends="-pre-init" name="-init-private">
  106.37 +        <property file="nbproject/private/config.properties"/>
  106.38 +        <property file="nbproject/private/configs/${config}.properties"/>
  106.39 +        <property file="nbproject/private/private.properties"/>
  106.40 +    </target>
  106.41 +    <target depends="-pre-init,-init-private" name="-init-user">
  106.42 +        <property file="${user.properties.file}"/>
  106.43 +        <!-- The two properties below are usually overridden -->
  106.44 +        <!-- by the active platform. Just a fallback. -->
  106.45 +        <property name="default.javac.source" value="1.4"/>
  106.46 +        <property name="default.javac.target" value="1.4"/>
  106.47 +    </target>
  106.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
  106.49 +        <property file="nbproject/configs/${config}.properties"/>
  106.50 +        <property file="nbproject/project.properties"/>
  106.51 +    </target>
  106.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
  106.53 +        <available file="${manifest.file}" property="manifest.available"/>
  106.54 +        <condition property="manifest.available+main.class">
  106.55 +            <and>
  106.56 +                <isset property="manifest.available"/>
  106.57 +                <isset property="main.class"/>
  106.58 +                <not>
  106.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
  106.60 +                </not>
  106.61 +            </and>
  106.62 +        </condition>
  106.63 +        <condition property="manifest.available+main.class+mkdist.available">
  106.64 +            <and>
  106.65 +                <istrue value="${manifest.available+main.class}"/>
  106.66 +                <isset property="libs.CopyLibs.classpath"/>
  106.67 +            </and>
  106.68 +        </condition>
  106.69 +        <condition property="have.tests">
  106.70 +            <or>
  106.71 +                <available file="${test.src.dir}"/>
  106.72 +            </or>
  106.73 +        </condition>
  106.74 +        <condition property="have.sources">
  106.75 +            <or>
  106.76 +                <available file="${src.dir}"/>
  106.77 +            </or>
  106.78 +        </condition>
  106.79 +        <condition property="netbeans.home+have.tests">
  106.80 +            <and>
  106.81 +                <isset property="netbeans.home"/>
  106.82 +                <isset property="have.tests"/>
  106.83 +            </and>
  106.84 +        </condition>
  106.85 +        <condition property="no.javadoc.preview">
  106.86 +            <and>
  106.87 +                <isset property="javadoc.preview"/>
  106.88 +                <isfalse value="${javadoc.preview}"/>
  106.89 +            </and>
  106.90 +        </condition>
  106.91 +        <property name="run.jvmargs" value=""/>
  106.92 +        <property name="javac.compilerargs" value=""/>
  106.93 +        <property name="work.dir" value="${basedir}"/>
  106.94 +        <condition property="no.deps">
  106.95 +            <and>
  106.96 +                <istrue value="${no.dependencies}"/>
  106.97 +            </and>
  106.98 +        </condition>
  106.99 +        <property name="javac.debug" value="true"/>
 106.100 +        <property name="javadoc.preview" value="true"/>
 106.101 +        <property name="application.args" value=""/>
 106.102 +        <property name="source.encoding" value="${file.encoding}"/>
 106.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
 106.104 +            <and>
 106.105 +                <isset property="javadoc.encoding"/>
 106.106 +                <not>
 106.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
 106.108 +                </not>
 106.109 +            </and>
 106.110 +        </condition>
 106.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
 106.112 +        <property name="includes" value="**"/>
 106.113 +        <property name="excludes" value=""/>
 106.114 +        <property name="do.depend" value="false"/>
 106.115 +        <condition property="do.depend.true">
 106.116 +            <istrue value="${do.depend}"/>
 106.117 +        </condition>
 106.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
 106.119 +            <and>
 106.120 +                <isset property="jaxws.endorsed.dir"/>
 106.121 +                <available file="nbproject/jaxws-build.xml"/>
 106.122 +            </and>
 106.123 +        </condition>
 106.124 +    </target>
 106.125 +    <target name="-post-init">
 106.126 +        <!-- Empty placeholder for easier customization. -->
 106.127 +        <!-- You can override this target in the ../build.xml file. -->
 106.128 +    </target>
 106.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
 106.130 +        <fail unless="src.dir">Must set src.dir</fail>
 106.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
 106.132 +        <fail unless="build.dir">Must set build.dir</fail>
 106.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
 106.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
 106.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
 106.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
 106.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
 106.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
 106.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
 106.140 +    </target>
 106.141 +    <target name="-init-macrodef-property">
 106.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
 106.143 +            <attribute name="name"/>
 106.144 +            <attribute name="value"/>
 106.145 +            <sequential>
 106.146 +                <property name="@{name}" value="${@{value}}"/>
 106.147 +            </sequential>
 106.148 +        </macrodef>
 106.149 +    </target>
 106.150 +    <target name="-init-macrodef-javac">
 106.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
 106.152 +            <attribute default="${src.dir}" name="srcdir"/>
 106.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
 106.154 +            <attribute default="${javac.classpath}" name="classpath"/>
 106.155 +            <attribute default="${includes}" name="includes"/>
 106.156 +            <attribute default="${excludes}" name="excludes"/>
 106.157 +            <attribute default="${javac.debug}" name="debug"/>
 106.158 +            <attribute default="" name="sourcepath"/>
 106.159 +            <element name="customize" optional="true"/>
 106.160 +            <sequential>
 106.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}">
 106.162 +                    <classpath>
 106.163 +                        <path path="@{classpath}"/>
 106.164 +                    </classpath>
 106.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
 106.166 +                    <customize/>
 106.167 +                </javac>
 106.168 +            </sequential>
 106.169 +        </macrodef>
 106.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
 106.171 +            <attribute default="${src.dir}" name="srcdir"/>
 106.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
 106.173 +            <attribute default="${javac.classpath}" name="classpath"/>
 106.174 +            <sequential>
 106.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
 106.176 +                    <classpath>
 106.177 +                        <path path="@{classpath}"/>
 106.178 +                    </classpath>
 106.179 +                </depend>
 106.180 +            </sequential>
 106.181 +        </macrodef>
 106.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
 106.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
 106.184 +            <sequential>
 106.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
 106.186 +                <pathconvert pathsep="," property="javac.includes.binary">
 106.187 +                    <path>
 106.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
 106.189 +                    </path>
 106.190 +                    <globmapper from="*.java" to="*.class"/>
 106.191 +                </pathconvert>
 106.192 +                <delete>
 106.193 +                    <files includes="${javac.includes.binary}"/>
 106.194 +                </delete>
 106.195 +            </sequential>
 106.196 +        </macrodef>
 106.197 +    </target>
 106.198 +    <target name="-init-macrodef-junit">
 106.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
 106.200 +            <attribute default="${includes}" name="includes"/>
 106.201 +            <attribute default="${excludes}" name="excludes"/>
 106.202 +            <attribute default="**" name="testincludes"/>
 106.203 +            <sequential>
 106.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
 106.205 +                    <batchtest todir="${build.test.results.dir}">
 106.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
 106.207 +                            <filename name="@{testincludes}"/>
 106.208 +                        </fileset>
 106.209 +                    </batchtest>
 106.210 +                    <classpath>
 106.211 +                        <path path="${run.test.classpath}"/>
 106.212 +                    </classpath>
 106.213 +                    <syspropertyset>
 106.214 +                        <propertyref prefix="test-sys-prop."/>
 106.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
 106.216 +                    </syspropertyset>
 106.217 +                    <formatter type="brief" usefile="false"/>
 106.218 +                    <formatter type="xml"/>
 106.219 +                    <jvmarg line="${run.jvmargs}"/>
 106.220 +                </junit>
 106.221 +            </sequential>
 106.222 +        </macrodef>
 106.223 +    </target>
 106.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
 106.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
 106.226 +            <attribute default="${main.class}" name="name"/>
 106.227 +            <attribute default="${debug.classpath}" name="classpath"/>
 106.228 +            <attribute default="" name="stopclassname"/>
 106.229 +            <sequential>
 106.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
 106.231 +                    <classpath>
 106.232 +                        <path path="@{classpath}"/>
 106.233 +                    </classpath>
 106.234 +                </nbjpdastart>
 106.235 +            </sequential>
 106.236 +        </macrodef>
 106.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
 106.238 +            <attribute default="${build.classes.dir}" name="dir"/>
 106.239 +            <sequential>
 106.240 +                <nbjpdareload>
 106.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
 106.242 +                        <include name="${fix.includes}*.class"/>
 106.243 +                    </fileset>
 106.244 +                </nbjpdareload>
 106.245 +            </sequential>
 106.246 +        </macrodef>
 106.247 +    </target>
 106.248 +    <target name="-init-debug-args">
 106.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
 106.250 +        <condition property="have-jdk-older-than-1.4">
 106.251 +            <or>
 106.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
 106.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
 106.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
 106.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
 106.256 +            </or>
 106.257 +        </condition>
 106.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
 106.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
 106.260 +        </condition>
 106.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
 106.262 +            <os family="windows"/>
 106.263 +        </condition>
 106.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
 106.265 +            <isset property="debug.transport"/>
 106.266 +        </condition>
 106.267 +    </target>
 106.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
 106.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
 106.270 +            <attribute default="${main.class}" name="classname"/>
 106.271 +            <attribute default="${debug.classpath}" name="classpath"/>
 106.272 +            <element name="customize" optional="true"/>
 106.273 +            <sequential>
 106.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 106.275 +                    <jvmarg line="${debug-args-line}"/>
 106.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
 106.277 +                    <jvmarg line="${run.jvmargs}"/>
 106.278 +                    <classpath>
 106.279 +                        <path path="@{classpath}"/>
 106.280 +                    </classpath>
 106.281 +                    <syspropertyset>
 106.282 +                        <propertyref prefix="run-sys-prop."/>
 106.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 106.284 +                    </syspropertyset>
 106.285 +                    <customize/>
 106.286 +                </java>
 106.287 +            </sequential>
 106.288 +        </macrodef>
 106.289 +    </target>
 106.290 +    <target name="-init-macrodef-java">
 106.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
 106.292 +            <attribute default="${main.class}" name="classname"/>
 106.293 +            <element name="customize" optional="true"/>
 106.294 +            <sequential>
 106.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 106.296 +                    <jvmarg line="${run.jvmargs}"/>
 106.297 +                    <classpath>
 106.298 +                        <path path="${run.classpath}"/>
 106.299 +                    </classpath>
 106.300 +                    <syspropertyset>
 106.301 +                        <propertyref prefix="run-sys-prop."/>
 106.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 106.303 +                    </syspropertyset>
 106.304 +                    <customize/>
 106.305 +                </java>
 106.306 +            </sequential>
 106.307 +        </macrodef>
 106.308 +    </target>
 106.309 +    <target name="-init-presetdef-jar">
 106.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
 106.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
 106.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
 106.313 +            </jar>
 106.314 +        </presetdef>
 106.315 +    </target>
 106.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"/>
 106.317 +    <!--
 106.318 +                ===================
 106.319 +                COMPILATION SECTION
 106.320 +                ===================
 106.321 +            -->
 106.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
 106.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
 106.324 +    <target depends="init" name="-check-automatic-build">
 106.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
 106.326 +    </target>
 106.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
 106.328 +        <antcall target="clean"/>
 106.329 +    </target>
 106.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
 106.331 +        <mkdir dir="${build.classes.dir}"/>
 106.332 +    </target>
 106.333 +    <target name="-pre-compile">
 106.334 +        <!-- Empty placeholder for easier customization. -->
 106.335 +        <!-- You can override this target in the ../build.xml file. -->
 106.336 +    </target>
 106.337 +    <target if="do.depend.true" name="-compile-depend">
 106.338 +        <j2seproject3:depend/>
 106.339 +    </target>
 106.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
 106.341 +        <j2seproject3:javac/>
 106.342 +        <copy todir="${build.classes.dir}">
 106.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 106.344 +        </copy>
 106.345 +    </target>
 106.346 +    <target name="-post-compile">
 106.347 +        <!-- Empty placeholder for easier customization. -->
 106.348 +        <!-- You can override this target in the ../build.xml file. -->
 106.349 +    </target>
 106.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
 106.351 +    <target name="-pre-compile-single">
 106.352 +        <!-- Empty placeholder for easier customization. -->
 106.353 +        <!-- You can override this target in the ../build.xml file. -->
 106.354 +    </target>
 106.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
 106.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 106.357 +        <j2seproject3:force-recompile/>
 106.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
 106.359 +    </target>
 106.360 +    <target name="-post-compile-single">
 106.361 +        <!-- Empty placeholder for easier customization. -->
 106.362 +        <!-- You can override this target in the ../build.xml file. -->
 106.363 +    </target>
 106.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
 106.365 +    <!--
 106.366 +                ====================
 106.367 +                JAR BUILDING SECTION
 106.368 +                ====================
 106.369 +            -->
 106.370 +    <target depends="init" name="-pre-pre-jar">
 106.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
 106.372 +        <mkdir dir="${dist.jar.dir}"/>
 106.373 +    </target>
 106.374 +    <target name="-pre-jar">
 106.375 +        <!-- Empty placeholder for easier customization. -->
 106.376 +        <!-- You can override this target in the ../build.xml file. -->
 106.377 +    </target>
 106.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
 106.379 +        <j2seproject1:jar/>
 106.380 +    </target>
 106.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
 106.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
 106.383 +    </target>
 106.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">
 106.385 +        <j2seproject1:jar manifest="${manifest.file}">
 106.386 +            <j2seproject1:manifest>
 106.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
 106.388 +            </j2seproject1:manifest>
 106.389 +        </j2seproject1:jar>
 106.390 +        <echo>To run this application from the command line without Ant, try:</echo>
 106.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 106.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 106.393 +        <pathconvert property="run.classpath.with.dist.jar">
 106.394 +            <path path="${run.classpath}"/>
 106.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
 106.396 +        </pathconvert>
 106.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
 106.398 +    </target>
 106.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
 106.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 106.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
 106.402 +            <path path="${run.classpath}"/>
 106.403 +            <map from="${build.classes.dir.resolved}" to=""/>
 106.404 +        </pathconvert>
 106.405 +        <pathconvert pathsep=" " property="jar.classpath">
 106.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
 106.407 +            <chainedmapper>
 106.408 +                <flattenmapper/>
 106.409 +                <globmapper from="*" to="lib/*"/>
 106.410 +            </chainedmapper>
 106.411 +        </pathconvert>
 106.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
 106.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
 106.414 +            <fileset dir="${build.classes.dir}"/>
 106.415 +            <manifest>
 106.416 +                <attribute name="Main-Class" value="${main.class}"/>
 106.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
 106.418 +            </manifest>
 106.419 +        </copylibs>
 106.420 +        <echo>To run this application from the command line without Ant, try:</echo>
 106.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 106.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
 106.423 +    </target>
 106.424 +    <target name="-post-jar">
 106.425 +        <!-- Empty placeholder for easier customization. -->
 106.426 +        <!-- You can override this target in the ../build.xml file. -->
 106.427 +    </target>
 106.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"/>
 106.429 +    <!--
 106.430 +                =================
 106.431 +                EXECUTION SECTION
 106.432 +                =================
 106.433 +            -->
 106.434 +    <target depends="init,compile" description="Run a main class." name="run">
 106.435 +        <j2seproject1:java>
 106.436 +            <customize>
 106.437 +                <arg line="${application.args}"/>
 106.438 +            </customize>
 106.439 +        </j2seproject1:java>
 106.440 +    </target>
 106.441 +    <target name="-do-not-recompile">
 106.442 +        <property name="javac.includes.binary" value=""/>
 106.443 +    </target>
 106.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
 106.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
 106.446 +        <j2seproject1:java classname="${run.class}"/>
 106.447 +    </target>
 106.448 +    <!--
 106.449 +                =================
 106.450 +                DEBUGGING SECTION
 106.451 +                =================
 106.452 +            -->
 106.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
 106.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
 106.455 +    </target>
 106.456 +    <target depends="init,compile" name="-debug-start-debuggee">
 106.457 +        <j2seproject3:debug>
 106.458 +            <customize>
 106.459 +                <arg line="${application.args}"/>
 106.460 +            </customize>
 106.461 +        </j2seproject3:debug>
 106.462 +    </target>
 106.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
 106.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
 106.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
 106.466 +    </target>
 106.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
 106.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
 106.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
 106.470 +        <j2seproject3:debug classname="${debug.class}"/>
 106.471 +    </target>
 106.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
 106.473 +    <target depends="init" name="-pre-debug-fix">
 106.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
 106.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
 106.476 +    </target>
 106.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
 106.478 +        <j2seproject1:nbjpdareload/>
 106.479 +    </target>
 106.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
 106.481 +    <!--
 106.482 +                ===============
 106.483 +                JAVADOC SECTION
 106.484 +                ===============
 106.485 +            -->
 106.486 +    <target depends="init" name="-javadoc-build">
 106.487 +        <mkdir dir="${dist.javadoc.dir}"/>
 106.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}">
 106.489 +            <classpath>
 106.490 +                <path path="${javac.classpath}"/>
 106.491 +            </classpath>
 106.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
 106.493 +                <filename name="**/*.java"/>
 106.494 +            </fileset>
 106.495 +        </javadoc>
 106.496 +    </target>
 106.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
 106.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
 106.499 +    </target>
 106.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
 106.501 +    <!--
 106.502 +                =========================
 106.503 +                JUNIT COMPILATION SECTION
 106.504 +                =========================
 106.505 +            -->
 106.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
 106.507 +        <mkdir dir="${build.test.classes.dir}"/>
 106.508 +    </target>
 106.509 +    <target name="-pre-compile-test">
 106.510 +        <!-- Empty placeholder for easier customization. -->
 106.511 +        <!-- You can override this target in the ../build.xml file. -->
 106.512 +    </target>
 106.513 +    <target if="do.depend.true" name="-compile-test-depend">
 106.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 106.515 +    </target>
 106.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
 106.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 106.518 +        <copy todir="${build.test.classes.dir}">
 106.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 106.520 +        </copy>
 106.521 +    </target>
 106.522 +    <target name="-post-compile-test">
 106.523 +        <!-- Empty placeholder for easier customization. -->
 106.524 +        <!-- You can override this target in the ../build.xml file. -->
 106.525 +    </target>
 106.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
 106.527 +    <target name="-pre-compile-test-single">
 106.528 +        <!-- Empty placeholder for easier customization. -->
 106.529 +        <!-- You can override this target in the ../build.xml file. -->
 106.530 +    </target>
 106.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
 106.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 106.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
 106.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}"/>
 106.535 +        <copy todir="${build.test.classes.dir}">
 106.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 106.537 +        </copy>
 106.538 +    </target>
 106.539 +    <target name="-post-compile-test-single">
 106.540 +        <!-- Empty placeholder for easier customization. -->
 106.541 +        <!-- You can override this target in the ../build.xml file. -->
 106.542 +    </target>
 106.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"/>
 106.544 +    <!--
 106.545 +                =======================
 106.546 +                JUNIT EXECUTION SECTION
 106.547 +                =======================
 106.548 +            -->
 106.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
 106.550 +        <mkdir dir="${build.test.results.dir}"/>
 106.551 +    </target>
 106.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
 106.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
 106.554 +    </target>
 106.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
 106.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 106.557 +    </target>
 106.558 +    <target depends="init" if="have.tests" name="test-report"/>
 106.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
 106.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"/>
 106.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
 106.562 +        <mkdir dir="${build.test.results.dir}"/>
 106.563 +    </target>
 106.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
 106.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
 106.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
 106.567 +    </target>
 106.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
 106.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 106.570 +    </target>
 106.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"/>
 106.572 +    <!--
 106.573 +                =======================
 106.574 +                JUNIT DEBUGGING SECTION
 106.575 +                =======================
 106.576 +            -->
 106.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
 106.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
 106.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
 106.580 +        <delete file="${test.report.file}"/>
 106.581 +        <mkdir dir="${build.test.results.dir}"/>
 106.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}">
 106.583 +            <customize>
 106.584 +                <syspropertyset>
 106.585 +                    <propertyref prefix="test-sys-prop."/>
 106.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
 106.587 +                </syspropertyset>
 106.588 +                <arg value="${test.class}"/>
 106.589 +                <arg value="showoutput=true"/>
 106.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
 106.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
 106.592 +            </customize>
 106.593 +        </j2seproject3:debug>
 106.594 +    </target>
 106.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
 106.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
 106.597 +    </target>
 106.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
 106.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
 106.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
 106.601 +    </target>
 106.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
 106.603 +    <!--
 106.604 +                =========================
 106.605 +                APPLET EXECUTION SECTION
 106.606 +                =========================
 106.607 +            -->
 106.608 +    <target depends="init,compile-single" name="run-applet">
 106.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 106.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
 106.611 +            <customize>
 106.612 +                <arg value="${applet.url}"/>
 106.613 +            </customize>
 106.614 +        </j2seproject1:java>
 106.615 +    </target>
 106.616 +    <!--
 106.617 +                =========================
 106.618 +                APPLET DEBUGGING  SECTION
 106.619 +                =========================
 106.620 +            -->
 106.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
 106.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 106.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
 106.624 +            <customize>
 106.625 +                <arg value="${applet.url}"/>
 106.626 +            </customize>
 106.627 +        </j2seproject3:debug>
 106.628 +    </target>
 106.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
 106.630 +    <!--
 106.631 +                ===============
 106.632 +                CLEANUP SECTION
 106.633 +                ===============
 106.634 +            -->
 106.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
 106.636 +    <target depends="init" name="-do-clean">
 106.637 +        <delete dir="${build.dir}"/>
 106.638 +        <delete dir="${dist.dir}"/>
 106.639 +    </target>
 106.640 +    <target name="-post-clean">
 106.641 +        <!-- Empty placeholder for easier customization. -->
 106.642 +        <!-- You can override this target in the ../build.xml file. -->
 106.643 +    </target>
 106.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
 106.645 +</project>
   107.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.2 +++ b/task2/solution10/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
   107.3 @@ -0,0 +1,8 @@
   107.4 +build.xml.data.CRC32=6601af03
   107.5 +build.xml.script.CRC32=2c84d7b2
   107.6 +build.xml.stylesheet.CRC32=be360661
   107.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
   107.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
   107.9 +nbproject/build-impl.xml.data.CRC32=6601af03
  107.10 +nbproject/build-impl.xml.script.CRC32=5e67461a
  107.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
   108.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.2 +++ b/task2/solution10/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
   108.3 @@ -0,0 +1,59 @@
   108.4 +application.title=basic
   108.5 +application.vendor=vvessan
   108.6 +build.classes.dir=${build.dir}/classes
   108.7 +build.classes.excludes=**/*.java,**/*.form
   108.8 +# This directory is removed when the project is cleaned:
   108.9 +build.dir=build
  108.10 +build.generated.dir=${build.dir}/generated
  108.11 +# Only compile against the classpath explicitly listed here:
  108.12 +build.sysclasspath=ignore
  108.13 +build.test.classes.dir=${build.dir}/test/classes
  108.14 +build.test.results.dir=${build.dir}/test/results
  108.15 +debug.classpath=\
  108.16 +    ${run.classpath}
  108.17 +debug.test.classpath=\
  108.18 +    ${run.test.classpath}
  108.19 +# This directory is removed when the project is cleaned:
  108.20 +dist.dir=dist
  108.21 +dist.jar=${dist.dir}/Currency_Convertor_Solution_10.jar
  108.22 +dist.javadoc.dir=${dist.dir}/javadoc
  108.23 +excludes=
  108.24 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
  108.25 +includes=**
  108.26 +jar.compress=false
  108.27 +javac.classpath=
  108.28 +# Space-separated list of extra javac options
  108.29 +javac.compilerargs=
  108.30 +javac.deprecation=false
  108.31 +javac.source=1.5
  108.32 +javac.target=1.5
  108.33 +javac.test.classpath=\
  108.34 +    ${javac.classpath}:\
  108.35 +    ${build.classes.dir}:\
  108.36 +    ${file.reference.junit-4.4.jar}
  108.37 +javadoc.additionalparam=
  108.38 +javadoc.author=false
  108.39 +javadoc.encoding=${source.encoding}
  108.40 +javadoc.noindex=false
  108.41 +javadoc.nonavbar=false
  108.42 +javadoc.notree=false
  108.43 +javadoc.private=false
  108.44 +javadoc.splitindex=true
  108.45 +javadoc.use=true
  108.46 +javadoc.version=false
  108.47 +javadoc.windowtitle=
  108.48 +meta.inf.dir=${src.dir}/META-INF
  108.49 +platform.active=default_platform
  108.50 +run.classpath=\
  108.51 +    ${javac.classpath}:\
  108.52 +    ${build.classes.dir}
  108.53 +# Space-separated list of JVM arguments used when running the project
  108.54 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
  108.55 +# or test-sys-prop.name=value to set system properties for unit tests):
  108.56 +run.jvmargs=
  108.57 +run.test.classpath=\
  108.58 +    ${javac.test.classpath}:\
  108.59 +    ${build.test.classes.dir}
  108.60 +source.encoding=UTF-8
  108.61 +src.dir=src
  108.62 +test.src.dir=test
   109.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   109.2 +++ b/task2/solution10/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
   109.3 @@ -0,0 +1,16 @@
   109.4 +<?xml version="1.0" encoding="UTF-8"?>
   109.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
   109.6 +    <type>org.netbeans.modules.java.j2seproject</type>
   109.7 +    <configuration>
   109.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
   109.9 +            <name>Currency Convertor Solution 10</name>
  109.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
  109.11 +            <source-roots>
  109.12 +                <root id="src.dir"/>
  109.13 +            </source-roots>
  109.14 +            <test-roots>
  109.15 +                <root id="test.src.dir"/>
  109.16 +            </test-roots>
  109.17 +        </data>
  109.18 +    </configuration>
  109.19 +</project>
   110.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/ConstantRateConverter.java	Wed Oct 01 10:43:05 2008 +0200
   110.3 @@ -0,0 +1,44 @@
   110.4 +package org.apidesign.apifest08.currency;
   110.5 +
   110.6 +import java.util.*;
   110.7 +
   110.8 +final class ConstantRateConverter implements CurrencyConverter {
   110.9 +
  110.10 +	private final Currency from;
  110.11 +	private final Currency to;
  110.12 +
  110.13 +	private final double rate;
  110.14 +
  110.15 +	public ConstantRateConverter(Currency from, Currency to, double rate) throws IllegalArgumentException {
  110.16 +		if (from == null || to == null)
  110.17 +			throw new NullPointerException("None of the currencies can be null");
  110.18 +		if (from.equals(to))
  110.19 +			throw new IllegalArgumentException("Cannot create converter with two equal currencies");
  110.20 +		this.from = from;
  110.21 +		this.to = to;
  110.22 +		this.rate = rate;
  110.23 +	}
  110.24 +
  110.25 +	@Override
  110.26 +	public double convert(double value, String from, String to)
  110.27 +			throws CurrencyConversionException, NullPointerException {
  110.28 +		return convert(value, Currency.getInstance(from), Currency.getInstance(to));
  110.29 +	}
  110.30 +
  110.31 +	@Override
  110.32 +	public double convert(double value, Currency from, Currency to)
  110.33 +			throws NullPointerException, CurrencyConversionException {
  110.34 +
  110.35 +		if (this.from.equals(from)) {
  110.36 +			if (!this.to.equals(to))
  110.37 +				throw new CurrencyConversionException(from, to, "Unsupported currency");
  110.38 +			return value * rate;
  110.39 +		}
  110.40 +		if (this.from.equals(to)) {
  110.41 +			if (!this.to.equals(from))
  110.42 +				throw new CurrencyConversionException(from, to, "Unsupported currency");
  110.43 +			return value / rate;
  110.44 +		}
  110.45 +		throw new CurrencyConversionException(from, to, "Unsupported currency"); 
  110.46 +	}
  110.47 +}
   111.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   111.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java	Wed Oct 01 10:43:05 2008 +0200
   111.3 @@ -0,0 +1,42 @@
   111.4 +package org.apidesign.apifest08.currency;
   111.5 +
   111.6 +import java.util.*;
   111.7 +
   111.8 +/**
   111.9 + * Exception thrown in cases that a CurrencyConverter is unable ensure requested accuracy of conversion.
  111.10 + * Such situation may occur in cases that the client is not on-line, or the exchange rates are older than
  111.11 + * requested etc. This exception is defined as RuntimeException to enable simple usage in simple applications,
  111.12 + * but enable other applications to be informed about possible problems and prevent them from using
  111.13 + * inaccurate data.
  111.14 + */
  111.15 +public final class CurrencyConversionException extends RuntimeException {
  111.16 +
  111.17 +	private final Currency from;
  111.18 +	private final Currency to;
  111.19 +
  111.20 +	CurrencyConversionException(Currency from, Currency to) {
  111.21 +		this(from, to, (Throwable) null);
  111.22 +	}
  111.23 +
  111.24 +	CurrencyConversionException(Currency from, Currency to, Throwable throwable) {
  111.25 +		this(from, to, String.format("Failed to convert curency from %1$s to %2$s", from, to), throwable);
  111.26 +	}
  111.27 +
  111.28 +	CurrencyConversionException(Currency from, Currency to, String message) {
  111.29 +		this(from, to, message, null);
  111.30 +	}
  111.31 +
  111.32 +	CurrencyConversionException(Currency from, Currency to, String message, Throwable throwable) {
  111.33 +		super(message, throwable);
  111.34 +		this.from = from;
  111.35 +		this.to = to;
  111.36 +	}
  111.37 +
  111.38 +	public Currency getFromCurrency() {
  111.39 +		return from;
  111.40 +	}
  111.41 +
  111.42 +	public Currency getToCurrency() {
  111.43 +		return to;
  111.44 +	}
  111.45 +}
   112.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java	Wed Oct 01 10:43:05 2008 +0200
   112.3 @@ -0,0 +1,48 @@
   112.4 +package org.apidesign.apifest08.currency;
   112.5 +
   112.6 +import java.util.*;
   112.7 +
   112.8 +/** This is the skeleton class for your API. You need to make it public, so
   112.9 + * it is accessible to your client code (currently in Task1Test.java) file.
  112.10 + * <p>
  112.11 + * Feel free to create additional classes or rename this one, just keep all
  112.12 + * the API and its implementation in this package. Do not spread it outside
  112.13 + * to other packages.
  112.14 + *
  112.15 + * The converter will usually work internally with Currency class, to be more type-safe as String can be used
  112.16 + * for almost anything. But methods taking strings as parameters are provided for convenience.
  112.17 + */
  112.18 +public interface CurrencyConverter {
  112.19 +
  112.20 +	/**
  112.21 +	 * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
  112.22 +	 *
  112.23 +	 * @param value that should be converted form one currency to the other
  112.24 +	 * @param from ISO-4217 code of the currency of the value provided
  112.25 +	 * @param to ISO-4212 code of the currency to which the value should be converted
  112.26 +	 * @return value expressed in the target value
  112.27 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
  112.28 +	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
  112.29 +	 * for example the exchange rates are not current, connection to exchange rates provider is not available
  112.30 +	 * @throws NullPointerException if any of the specified currency ISO codes is null
  112.31 +	 */
  112.32 +	// this method is provided to ensure future compatibility for converters supporting more than 2 currencies
  112.33 +	//		- simpler methods with fewer arguments would make using such converters less intuitive
  112.34 +	double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
  112.35 +			throws CurrencyConversionException, NullPointerException, IllegalArgumentException;
  112.36 +
  112.37 +	/**
  112.38 +	 * Converts the specified value from one currency (from) to target currency (to).
  112.39 +	 *
  112.40 +	 * @param value that should be converted form one currency to the other
  112.41 +	 * @param from ISO-4217 code of the currency of the value provided
  112.42 +	 * @param to ISO-4212 code of the currency to which the value should be converted
  112.43 +	 * @return value expressed in the target value
  112.44 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
  112.45 +	 * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
  112.46 +	 * for example the exchange rates are not current, connection to exchange rates provider is not available
  112.47 +	 * @throws NullPointerException if any of the specified currency ISO codes is null
  112.48 +	 */
  112.49 +	double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
  112.50 +			throws CurrencyConversionException, NullPointerException;
  112.51 +}
   113.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java	Wed Oct 01 10:43:05 2008 +0200
   113.3 @@ -0,0 +1,68 @@
   113.4 +package org.apidesign.apifest08.currency;
   113.5 +
   113.6 +import java.util.*;
   113.7 +
   113.8 +/**
   113.9 + * CurrencyConversionService provides methods necessary for construction all necessary currency
  113.10 + * conversion-related classes.
  113.11 + */
  113.12 +public interface CurrencyConverterProvider {
  113.13 +
  113.14 +	/**
  113.15 +	 * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
  113.16 +	 *
  113.17 +	 * @param amount1 amount of the money in the currency1
  113.18 +	 * @param currency1 one of the supported currencies
  113.19 +	 * @param amount2 amount of the money in the currency2
  113.20 +	 * @param currency2 one of the supported currencies
  113.21 +	 * @return converter able to convert between the two specified currencies
  113.22 +	 * @throws IllegalArgumentException if any of the amount values is not positive
  113.23 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
  113.24 +	 */
  113.25 +	CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
  113.26 +								   double amount2, /*@NotNull*/ String currency2)
  113.27 +			throws IllegalArgumentException, CurrencyNotAvailableException;
  113.28 +
  113.29 +	/**
  113.30 +	 * Retrieves converter that is capable of converting values between currency1 and currency2.
  113.31 +	 * The exchange is specified in easy to understand way. By specifying values in two currencies that
  113.32 +	 * are equal. For example CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR.
  113.33 +	 * This enables user to use this method without having to calculate anything. In general this can be
  113.34 +	 * expressed by formula amount1[currency1] = amount2[currency2].
  113.35 +	 *
  113.36 +	 * @param amount1 amount of the money in the currency1
  113.37 +	 * @param currency1 one of the supported currencies
  113.38 +	 * @param amount2 amount of the money in the currency2
  113.39 +	 * @param currency2 one of the supported currencies
  113.40 +	 * @return converter able to convert between the two specified currencies
  113.41 +	 * @throws IllegalArgumentException if any of the amount values is not positive
  113.42 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
  113.43 +	 */
  113.44 +	CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
  113.45 +								   double amount2, /*@NotNull*/ Currency currency2)
  113.46 +			throws IllegalArgumentException, CurrencyNotAvailableException;
  113.47 +
  113.48 +	/**
  113.49 +	 * Creates a new converter that is able to convert between all specified currencies. The converter
  113.50 +	 * may optionally support additional currencies that were not specified.
  113.51 +	 *
  113.52 +	 * @param currencies that the converter should be created for
  113.53 +	 * @return converter able to convert between all specified currencies
  113.54 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
  113.55 +	 * @throws NullPointerException if any of the specified currencies is null of the array is null
  113.56 +	 */
  113.57 +	CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
  113.58 +			throws CurrencyNotAvailableException, NullPointerException;
  113.59 +
  113.60 +	/**
  113.61 +	 * Convenient method for getConverter(Currency...)
  113.62 +	 *
  113.63 +	 * @param currencies that the converter should be created for
  113.64 +	 * @return converter able to convert between all specified currencies
  113.65 +	 * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
  113.66 +	 * @throws NullPointerException if any of the specified currencies is null, or the array is null
  113.67 +	 * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
  113.68 +	 */
  113.69 +	CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
  113.70 +			throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;
  113.71 +}
  113.72 \ No newline at end of file
   114.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyNotAvailableException.java	Wed Oct 01 10:43:05 2008 +0200
   114.3 @@ -0,0 +1,21 @@
   114.4 +package org.apidesign.apifest08.currency;
   114.5 +
   114.6 +import java.util.*;
   114.7 +
   114.8 +public final class CurrencyNotAvailableException extends RuntimeException {
   114.9 +
  114.10 +	private final Currency currency;
  114.11 +
  114.12 +	CurrencyNotAvailableException(Currency currency) {
  114.13 +		this(currency, String.format("Currency %1$s not available", currency));	
  114.14 +	}
  114.15 +
  114.16 +	CurrencyNotAvailableException(Currency currency, String message) {
  114.17 +		super(message);
  114.18 +		this.currency = currency;
  114.19 +	}
  114.20 +
  114.21 +	public Currency getCurrency() {
  114.22 +		return currency;
  114.23 +	}
  114.24 +}
   115.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/MultiCurrencyConstantRateConverter.java	Wed Oct 01 10:43:05 2008 +0200
   115.3 @@ -0,0 +1,71 @@
   115.4 +package org.apidesign.apifest08.currency;
   115.5 +
   115.6 +import java.util.*;
   115.7 +
   115.8 +final class MultiCurrencyConstantRateConverter implements CurrencyConverter {
   115.9 +
  115.10 +	private final Map<Currency, Double> rates;
  115.11 +
  115.12 +	public MultiCurrencyConstantRateConverter(Map<Currency, Double> rates) {
  115.13 +		this.rates = rates;
  115.14 +	}
  115.15 +
  115.16 +	/**
  115.17 +	 * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
  115.18 +	 *
  115.19 +	 * @param value that should be converted form one currency to the other
  115.20 +	 * @param from  ISO-4217 code of the currency of the value provided
  115.21 +	 * @param to	ISO-4212 code of the currency to which the value should be converted
  115.22 +	 *
  115.23 +	 * @return value expressed in the target value
  115.24 +	 *
  115.25 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
  115.26 +	 * @throws CurrencyConversionException
  115.27 +	 *                                  if the conversion cannot be performed with desired parameters, for
  115.28 +	 *                                  example the exchange rates are not current, connection to exchange rates
  115.29 +	 *                                  provider is not available
  115.30 +	 * @throws NullPointerException	 if any of the specified currency ISO codes is null
  115.31 +	 */
  115.32 +	// this method is provided to ensure future compatibility for converters supporting more than 2 currencies
  115.33 +	//		- simpler methods with fewer arguments would make using such converters less intuitive
  115.34 +	@Override
  115.35 +	public double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
  115.36 +			throws CurrencyConversionException, NullPointerException, IllegalArgumentException {
  115.37 +		return convert(value, Currency.getInstance(from), Currency.getInstance(to));
  115.38 +	}
  115.39 +
  115.40 +	/**
  115.41 +	 * Converts the specified value from one currency (from) to target currency (to).
  115.42 +	 *
  115.43 +	 * @param value that should be converted form one currency to the other
  115.44 +	 * @param from  ISO-4217 code of the currency of the value provided
  115.45 +	 * @param to	ISO-4212 code of the currency to which the value should be converted
  115.46 +	 *
  115.47 +	 * @return value expressed in the target value
  115.48 +	 *
  115.49 +	 * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
  115.50 +	 * @throws CurrencyConversionException
  115.51 +	 *                                  if the conversion cannot be performed with desired parameters, for
  115.52 +	 *                                  example the exchange rates are not current, connection to exchange rates
  115.53 +	 *                                  provider is not available
  115.54 +	 * @throws NullPointerException	 if any of the specified currency ISO codes is null
  115.55 +	 */
  115.56 +	@Override
  115.57 +	public double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
  115.58 +			throws CurrencyConversionException, NullPointerException {
  115.59 +
  115.60 +		// this is not necessary, but we let users know that nulls are not allowed here - should be handled by annotations
  115.61 +		if (from == null || to == null)
  115.62 +			throw new NullPointerException("One of the specified currencies in null");
  115.63 +
  115.64 +		Double fromRate = rates.get(from);
  115.65 +		Double toRate = rates.get(to);
  115.66 +
  115.67 +		if (fromRate == null)
  115.68 +			throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", from));
  115.69 +		if (toRate == null)
  115.70 +			throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", to));
  115.71 +
  115.72 +		return (value / fromRate) * toRate;
  115.73 +	}
  115.74 +}
   116.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.2 +++ b/task2/solution10/src/org/apidesign/apifest08/currency/OfflineConverterProvider.java	Wed Oct 01 10:43:05 2008 +0200
   116.3 @@ -0,0 +1,120 @@
   116.4 +package org.apidesign.apifest08.currency;
   116.5 +
   116.6 +import java.util.*;
   116.7 +
   116.8 +/**
   116.9 + * ConvertorProvider class is introduced to handle
  116.10 + */
  116.11 +public final class OfflineConverterProvider implements CurrencyConverterProvider {
  116.12 +
  116.13 +
  116.14 +	// we can't synchronize on DEFAULT as it's not final and can even be null in synchronized section
  116.15 +	private static final Object LOCK = new Object();
  116.16 +	private static CurrencyConverterProvider DEFAULT;
  116.17 +
  116.18 +	// this is not nice and could be static, but future usage is uncertain and it's pretty easy to create
  116.19 +	private final Map<Currency, Double> rates;
  116.20 +
  116.21 +	private OfflineConverterProvider() {
  116.22 +		rates = new HashMap<Currency, Double>();
  116.23 +		// simple initialization just for Task1Test
  116.24 +		rates.put(Currency.getInstance("USD"), 100.0);
  116.25 +		rates.put(Currency.getInstance("CZK"), 1700.0);
  116.26 +		rates.put(Currency.getInstance("SKK"), 2125.0);
  116.27 +	}
  116.28 +
  116.29 +	/**
  116.30 +	 * Provides default implementation of ConvertorProvider. This Converter does nos not ensure accuracy
  116.31 +	 * of exchange rates, but should be functional at any circumstances including being offline.
  116.32 +	 *
  116.33 +	 * @return
  116.34 +	 */
  116.35 +	public static CurrencyConverterProvider getInstance() {
  116.36 +		// should be necessary in current implementation as creating CurrencyConverterProvider is cheap, but for future
  116.37 +		if (DEFAULT == null)
  116.38 +			synchronized (LOCK) {
  116.39 +				if (DEFAULT == null)
  116.40 +					DEFAULT = new OfflineConverterProvider();
  116.41 +			}
  116.42 +		return DEFAULT;
  116.43 +	}
  116.44 +
  116.45 +	@Override
  116.46 +	public CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
  116.47 +									   double amount2, /*@NotNull*/ String currency2)
  116.48 +			throws IllegalArgumentException {
  116.49 +
  116.50 +		return getConverter(amount1, Currency.getInstance(currency2), amount2, Currency.getInstance(currency1));
  116.51 +	}
  116.52 +
  116.53 +	/**
  116.54 +	 * Retrieves converter that is capable of converting values between currency1 and currency2. The exchange is
  116.55 +	 * specified in easy to understand way. By specifying values in two currencies that are equal. For example
  116.56 +	 * CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR. This enables user to
  116.57 +	 * use this method without having to calculate anything. In general this can be expressed by formula
  116.58 +	 * amount1[currency1] = amount2[currency2].
  116.59 +	 *
  116.60 +	 * @param amount1
  116.61 +	 * @param currency1
  116.62 +	 * @param amount2
  116.63 +	 * @param currency2
  116.64 +	 *
  116.65 +	 * @return
  116.66 +	 *
  116.67 +	 * @throws IllegalArgumentException
  116.68 +	 * @throws CurrencyNotAvailableException
  116.69 +	 *
  116.70 +	 */
  116.71 +	@Override
  116.72 +	public CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
  116.73 +									   double amount2, /*@NotNull*/ Currency currency2)
  116.74 +			throws IllegalArgumentException, CurrencyNotAvailableException {
  116.75 +		if (amount1 <= 0.0 || amount2 <= 0.0)
  116.76 +			throw new IllegalArgumentException(
  116.77 +					String.format("The specified currency values (%1$s, %2$s)", amount1, amount2));
  116.78 +		return new ConstantRateConverter(currency2, currency1, amount2 / amount1);
  116.79 +	}
  116.80 +
  116.81 +	/**
  116.82 +	 * Creates a new converter that is able to convert between all specified currencies.
  116.83 +	 *
  116.84 +	 * @param currencies that the converter should be created for
  116.85 +	 *
  116.86 +	 * @return converter able to convert between all specified currencies
  116.87 +	 *
  116.88 +	 * @throws CurrencyNotAvailableException
  116.89 +	 *          thrown when one of the currencies is not available
  116.90 +	 */
  116.91 +	@Override
  116.92 +	public CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies) throws CurrencyNotAvailableException {
  116.93 +		for (Currency c : currencies) {
  116.94 +			if (c == null)
  116.95 +				throw new NullPointerException("One of the specified currencies is null");
  116.96 +			if (!rates.containsKey(c))
  116.97 +				throw new CurrencyNotAvailableException(c);
  116.98 +		}
  116.99 +		return new MultiCurrencyConstantRateConverter(rates);
 116.100 +	}
 116.101 +
 116.102 +	/**
 116.103 +	 * Creates a new converter that is able to convert between all specified currencies.
 116.104 +	 *
 116.105 +	 * @param currencies that the converter should be created for
 116.106 +	 *
 116.107 +	 * @return converter able to convert between all specified currencies
 116.108 +	 *
 116.109 +	 * @throws CurrencyNotAvailableException
 116.110 +	 *                                  thrown when one of the currencies is not available
 116.111 +	 * @throws NullPointerException	 if any of the specified currencies is null
 116.112 +	 * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
 116.113 +	 */
 116.114 +	@Override
 116.115 +	public CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
 116.116 +			throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException {
 116.117 +
 116.118 +		Currency[] c2 = new Currency[currencies.length];
 116.119 +		for (int i = 0; i < c2.length; i++)
 116.120 +			c2[i] = Currency.getInstance(currencies[i]);
 116.121 +		return getConverter(c2);
 116.122 +	}
 116.123 +}
   117.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.2 +++ b/task2/solution10/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   117.3 @@ -0,0 +1,134 @@
   117.4 +package org.apidesign.apifest08.test;
   117.5 +
   117.6 +import junit.framework.*;
   117.7 +import org.apidesign.apifest08.currency.*;
   117.8 +
   117.9 +import java.util.*;
  117.10 +
  117.11 +/** Finish the Convertor API, and then write bodies of methods inside
  117.12 + * of this class to match the given tasks. To fullfil your task, use the
  117.13 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
  117.14 + * Do not you reflection, or other hacks as your code
  117.15 + * shall run without any runtime permissions.
  117.16 + */
  117.17 +public class Task1Test extends TestCase {
  117.18 +
  117.19 +	private static final String
  117.20 +			USD = "USD",
  117.21 +			CZK = "CZK",
  117.22 +			SKK = "SKK";
  117.23 +
  117.24 +	private static final Currency
  117.25 +			USD2 = Currency.getInstance(USD),
  117.26 +			CZK2 = Currency.getInstance(CZK),
  117.27 +			SKK2 = Currency.getInstance(SKK);
  117.28 +
  117.29 +	public Task1Test(String testName) {
  117.30 +    	super(testName);
  117.31 +    }
  117.32 +
  117.33 +    @Override
  117.34 +    protected void setUp() throws Exception {
  117.35 +	}
  117.36 +
  117.37 +    @Override
  117.38 +    protected void tearDown() throws Exception {
  117.39 +    }
  117.40 +
  117.41 +    /** Create convertor that understands two currencies, CZK and
  117.42 +     *  USD. Make 1 USD == 17 CZK.
  117.43 +     *
  117.44 +     * Creation of the convertor shall not require subclassing of any class
  117.45 +     * or interface on the client side.
  117.46 +     *
  117.47 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
  117.48 +     */
  117.49 +    public static CurrencyConverter createCZKtoUSD() {
  117.50 +		return OfflineConverterProvider.getInstance().getConverter(17, CZK, 1, USD);
  117.51 +    }
  117.52 +
  117.53 +	public static CurrencyConverter createCZKtoUSD2() {
  117.54 +		return OfflineConverterProvider.getInstance().getConverter(CZK, USD);
  117.55 +    }
  117.56 +
  117.57 +    /** Create convertor that understands two currencies, CZK and
  117.58 +     *  SKK. Make 100 SKK == 80 CZK.
  117.59 +     *
  117.60 +     * Creation of the convertor shall not require subclassing of any class
  117.61 +     * or interface on the client side.
  117.62 +     * 
  117.63 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  117.64 +     */
  117.65 +    public static CurrencyConverter createSKKtoCZK() {
  117.66 +        return OfflineConverterProvider.getInstance().getConverter(100, SKK, 80, CZK);
  117.67 +    }
  117.68 +
  117.69 +	public static CurrencyConverter createSKKtoCZK2() {
  117.70 +        return OfflineConverterProvider.getInstance().getConverter(SKK, CZK);
  117.71 +    }
  117.72 +    
  117.73 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
  117.74 +     * with it.
  117.75 +     */
  117.76 +    public void testCurrencyCZKUSD() throws Exception {
  117.77 +		CurrencyConverter c = createCZKtoUSD();
  117.78 +		testCZKUSD(c);
  117.79 +
  117.80 +		// test without specifying rates
  117.81 +		c = createCZKtoUSD2();
  117.82 +		testCZKUSD(c);
  117.83 +	}
  117.84 +
  117.85 +	private void testCZKUSD(CurrencyConverter c) {
  117.86 +		double czk, usd;
  117.87 +		// convert $5 to CZK using c:
  117.88 +		// assertEquals("Result is 85 CZK");
  117.89 +		czk = c.convert(5, USD, CZK);
  117.90 +		assertEquals(85.0, czk, 0.0);
  117.91 +		czk = c.convert(5, USD2, CZK2);
  117.92 +		assertEquals(85.0, czk, 0.0);
  117.93 +
  117.94 +		// convert $8 to CZK
  117.95 +		// assertEquals("Result is 136 CZK");
  117.96 +		czk = c.convert(8, USD, CZK);
  117.97 +		assertEquals(136.0, czk, 0.0);
  117.98 +		czk = c.convert(8, USD2, CZK2);
  117.99 +		assertEquals(136.0, czk, 0.0);
 117.100 +
 117.101 +		// convert 1003CZK to USD
 117.102 +		// assertEquals("Result is 59 USD");
 117.103 +		usd = c.convert(1003, CZK, USD);
 117.104 +		assertEquals(59.0, usd, 0.0);
 117.105 +		usd = c.convert(1003, CZK2, USD2);
 117.106 +		assertEquals(59.0, usd, 0.0);
 117.107 +	}
 117.108 +
 117.109 +	/** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
 117.110 +     * with it.
 117.111 +     */
 117.112 +    public void testCurrencySKKCZK() throws Exception {
 117.113 +		CurrencyConverter c = createSKKtoCZK();
 117.114 +		testCZKSKK(c);
 117.115 +
 117.116 +		// test without specifying rates
 117.117 +		c = createSKKtoCZK2();
 117.118 +		testCZKSKK(c);
 117.119 +	}
 117.120 +
 117.121 +	private void testCZKSKK(CurrencyConverter c) {
 117.122 +		double czk, skk;
 117.123 +		// convert 16CZK using c:
 117.124 +		// assertEquals("Result is 20 SKK");
 117.125 +		skk = c.convert(16, CZK, SKK);
 117.126 +		assertEquals(20.0, skk, 0.0);
 117.127 +		skk = c.convert(16, CZK2, SKK2);
 117.128 +		assertEquals(20.0, skk, 0.0);
 117.129 +
 117.130 +		// convert 500SKK to CZK
 117.131 +		// assertEquals("Result is 400 CZK");
 117.132 +		czk = c.convert(500, SKK, CZK);
 117.133 +		assertEquals(400.0, czk, 0.0);
 117.134 +		czk = c.convert(500, SKK2, CZK2);
 117.135 +		assertEquals(400.0, czk, 0.0);
 117.136 +	}
 117.137 +}
 117.138 \ No newline at end of file
   118.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   118.2 +++ b/task2/solution11/build.xml	Wed Oct 01 10:43:05 2008 +0200
   118.3 @@ -0,0 +1,69 @@
   118.4 +<?xml version="1.0" encoding="UTF-8"?>
   118.5 +<!-- You may freely edit this file. See commented blocks below for -->
   118.6 +<!-- some examples of how to customize the build. -->
   118.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
   118.8 +<project name="currency" default="default" basedir=".">
   118.9 +    <description>Builds, tests, and runs the project.</description>
  118.10 +    <import file="nbproject/build-impl.xml"/>
  118.11 +    <!--
  118.12 +
  118.13 +    There exist several targets which are by default empty and which can be 
  118.14 +    used for execution of your tasks. These targets are usually executed 
  118.15 +    before and after some main targets. They are: 
  118.16 +
  118.17 +      -pre-init:                 called before initialization of project properties
  118.18 +      -post-init:                called after initialization of project properties
  118.19 +      -pre-compile:              called before javac compilation
  118.20 +      -post-compile:             called after javac compilation
  118.21 +      -pre-compile-single:       called before javac compilation of single file
  118.22 +      -post-compile-single:      called after javac compilation of single file
  118.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
  118.24 +      -post-compile-test:        called after javac compilation of JUnit tests
  118.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
  118.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
  118.27 +      -pre-jar:                  called before JAR building
  118.28 +      -post-jar:                 called after JAR building
  118.29 +      -post-clean:               called after cleaning build products
  118.30 +
  118.31 +    (Targets beginning with '-' are not intended to be called on their own.)
  118.32 +
  118.33 +    Example of inserting an obfuscator after compilation could look like this:
  118.34 +
  118.35 +        <target name="-post-compile">
  118.36 +            <obfuscate>
  118.37 +                <fileset dir="${build.classes.dir}"/>
  118.38 +            </obfuscate>
  118.39 +        </target>
  118.40 +
  118.41 +    For list of available properties check the imported 
  118.42 +    nbproject/build-impl.xml file. 
  118.43 +
  118.44 +
  118.45 +    Another way to customize the build is by overriding existing main targets.
  118.46 +    The targets of interest are: 
  118.47 +
  118.48 +      -init-macrodef-javac:     defines macro for javac compilation
  118.49 +      -init-macrodef-junit:     defines macro for junit execution
  118.50 +      -init-macrodef-debug:     defines macro for class debugging
  118.51 +      -init-macrodef-java:      defines macro for class execution
  118.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  118.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  118.54 +      run:                      execution of project 
  118.55 +      -javadoc-build:           Javadoc generation
  118.56 +      test-report:              JUnit report generation
  118.57 +
  118.58 +    An example of overriding the target for project execution could look like this:
  118.59 +
  118.60 +        <target name="run" depends="currency-impl.jar">
  118.61 +            <exec dir="bin" executable="launcher.exe">
  118.62 +                <arg file="${dist.jar}"/>
  118.63 +            </exec>
  118.64 +        </target>
  118.65 +
  118.66 +    Notice that the overridden target depends on the jar target and not only on 
  118.67 +    the compile target as the regular run target does. Again, for a list of available 
  118.68 +    properties which you can use, check the target you are overriding in the
  118.69 +    nbproject/build-impl.xml file. 
  118.70 +
  118.71 +    -->
  118.72 +</project>
   119.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.2 +++ b/task2/solution11/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
   119.3 @@ -0,0 +1,642 @@
   119.4 +<?xml version="1.0" encoding="UTF-8"?>
   119.5 +<!--
   119.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
   119.7 +***         EDIT ../build.xml INSTEAD         ***
   119.8 +
   119.9 +For the purpose of easier reading the script
  119.10 +is divided into following sections:
  119.11 +
  119.12 +  - initialization
  119.13 +  - compilation
  119.14 +  - jar
  119.15 +  - execution
  119.16 +  - debugging
  119.17 +  - javadoc
  119.18 +  - junit compilation
  119.19 +  - junit execution
  119.20 +  - junit debugging
  119.21 +  - applet
  119.22 +  - cleanup
  119.23 +
  119.24 +        -->
  119.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_11-impl">
  119.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
  119.27 +    <!-- 
  119.28 +                ======================
  119.29 +                INITIALIZATION SECTION 
  119.30 +                ======================
  119.31 +            -->
  119.32 +    <target name="-pre-init">
  119.33 +        <!-- Empty placeholder for easier customization. -->
  119.34 +        <!-- You can override this target in the ../build.xml file. -->
  119.35 +    </target>
  119.36 +    <target depends="-pre-init" name="-init-private">
  119.37 +        <property file="nbproject/private/config.properties"/>
  119.38 +        <property file="nbproject/private/configs/${config}.properties"/>
  119.39 +        <property file="nbproject/private/private.properties"/>
  119.40 +    </target>
  119.41 +    <target depends="-pre-init,-init-private" name="-init-user">
  119.42 +        <property file="${user.properties.file}"/>
  119.43 +        <!-- The two properties below are usually overridden -->
  119.44 +        <!-- by the active platform. Just a fallback. -->
  119.45 +        <property name="default.javac.source" value="1.4"/>
  119.46 +        <property name="default.javac.target" value="1.4"/>
  119.47 +    </target>
  119.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
  119.49 +        <property file="nbproject/configs/${config}.properties"/>
  119.50 +        <property file="nbproject/project.properties"/>
  119.51 +    </target>
  119.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
  119.53 +        <available file="${manifest.file}" property="manifest.available"/>
  119.54 +        <condition property="manifest.available+main.class">
  119.55 +            <and>
  119.56 +                <isset property="manifest.available"/>
  119.57 +                <isset property="main.class"/>
  119.58 +                <not>
  119.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
  119.60 +                </not>
  119.61 +            </and>
  119.62 +        </condition>
  119.63 +        <condition property="manifest.available+main.class+mkdist.available">
  119.64 +            <and>
  119.65 +                <istrue value="${manifest.available+main.class}"/>
  119.66 +                <isset property="libs.CopyLibs.classpath"/>
  119.67 +            </and>
  119.68 +        </condition>
  119.69 +        <condition property="have.tests">
  119.70 +            <or>
  119.71 +                <available file="${test.src.dir}"/>
  119.72 +            </or>
  119.73 +        </condition>
  119.74 +        <condition property="have.sources">
  119.75 +            <or>
  119.76 +                <available file="${src.dir}"/>
  119.77 +            </or>
  119.78 +        </condition>
  119.79 +        <condition property="netbeans.home+have.tests">
  119.80 +            <and>
  119.81 +                <isset property="netbeans.home"/>
  119.82 +                <isset property="have.tests"/>
  119.83 +            </and>
  119.84 +        </condition>
  119.85 +        <condition property="no.javadoc.preview">
  119.86 +            <and>
  119.87 +                <isset property="javadoc.preview"/>
  119.88 +                <isfalse value="${javadoc.preview}"/>
  119.89 +            </and>
  119.90 +        </condition>
  119.91 +        <property name="run.jvmargs" value=""/>
  119.92 +        <property name="javac.compilerargs" value=""/>
  119.93 +        <property name="work.dir" value="${basedir}"/>
  119.94 +        <condition property="no.deps">
  119.95 +            <and>
  119.96 +                <istrue value="${no.dependencies}"/>
  119.97 +            </and>
  119.98 +        </condition>
  119.99 +        <property name="javac.debug" value="true"/>
 119.100 +        <property name="javadoc.preview" value="true"/>
 119.101 +        <property name="application.args" value=""/>
 119.102 +        <property name="source.encoding" value="${file.encoding}"/>
 119.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
 119.104 +            <and>
 119.105 +                <isset property="javadoc.encoding"/>
 119.106 +                <not>
 119.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
 119.108 +                </not>
 119.109 +            </and>
 119.110 +        </condition>
 119.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
 119.112 +        <property name="includes" value="**"/>
 119.113 +        <property name="excludes" value=""/>
 119.114 +        <property name="do.depend" value="false"/>
 119.115 +        <condition property="do.depend.true">
 119.116 +            <istrue value="${do.depend}"/>
 119.117 +        </condition>
 119.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
 119.119 +            <and>
 119.120 +                <isset property="jaxws.endorsed.dir"/>
 119.121 +                <available file="nbproject/jaxws-build.xml"/>
 119.122 +            </and>
 119.123 +        </condition>
 119.124 +    </target>
 119.125 +    <target name="-post-init">
 119.126 +        <!-- Empty placeholder for easier customization. -->
 119.127 +        <!-- You can override this target in the ../build.xml file. -->
 119.128 +    </target>
 119.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
 119.130 +        <fail unless="src.dir">Must set src.dir</fail>
 119.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
 119.132 +        <fail unless="build.dir">Must set build.dir</fail>
 119.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
 119.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
 119.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
 119.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
 119.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
 119.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
 119.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
 119.140 +    </target>
 119.141 +    <target name="-init-macrodef-property">
 119.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
 119.143 +            <attribute name="name"/>
 119.144 +            <attribute name="value"/>
 119.145 +            <sequential>
 119.146 +                <property name="@{name}" value="${@{value}}"/>
 119.147 +            </sequential>
 119.148 +        </macrodef>
 119.149 +    </target>
 119.150 +    <target name="-init-macrodef-javac">
 119.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
 119.152 +            <attribute default="${src.dir}" name="srcdir"/>
 119.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
 119.154 +            <attribute default="${javac.classpath}" name="classpath"/>
 119.155 +            <attribute default="${includes}" name="includes"/>
 119.156 +            <attribute default="${excludes}" name="excludes"/>
 119.157 +            <attribute default="${javac.debug}" name="debug"/>
 119.158 +            <attribute default="" name="sourcepath"/>
 119.159 +            <element name="customize" optional="true"/>
 119.160 +            <sequential>
 119.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}">
 119.162 +                    <classpath>
 119.163 +                        <path path="@{classpath}"/>
 119.164 +                    </classpath>
 119.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
 119.166 +                    <customize/>
 119.167 +                </javac>
 119.168 +            </sequential>
 119.169 +        </macrodef>
 119.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
 119.171 +            <attribute default="${src.dir}" name="srcdir"/>
 119.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
 119.173 +            <attribute default="${javac.classpath}" name="classpath"/>
 119.174 +            <sequential>
 119.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
 119.176 +                    <classpath>
 119.177 +                        <path path="@{classpath}"/>
 119.178 +                    </classpath>
 119.179 +                </depend>
 119.180 +            </sequential>
 119.181 +        </macrodef>
 119.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
 119.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
 119.184 +            <sequential>
 119.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
 119.186 +                <pathconvert pathsep="," property="javac.includes.binary">
 119.187 +                    <path>
 119.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
 119.189 +                    </path>
 119.190 +                    <globmapper from="*.java" to="*.class"/>
 119.191 +                </pathconvert>
 119.192 +                <delete>
 119.193 +                    <files includes="${javac.includes.binary}"/>
 119.194 +                </delete>
 119.195 +            </sequential>
 119.196 +        </macrodef>
 119.197 +    </target>
 119.198 +    <target name="-init-macrodef-junit">
 119.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
 119.200 +            <attribute default="${includes}" name="includes"/>
 119.201 +            <attribute default="${excludes}" name="excludes"/>
 119.202 +            <attribute default="**" name="testincludes"/>
 119.203 +            <sequential>
 119.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
 119.205 +                    <batchtest todir="${build.test.results.dir}">
 119.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
 119.207 +                            <filename name="@{testincludes}"/>
 119.208 +                        </fileset>
 119.209 +                    </batchtest>
 119.210 +                    <classpath>
 119.211 +                        <path path="${run.test.classpath}"/>
 119.212 +                    </classpath>
 119.213 +                    <syspropertyset>
 119.214 +                        <propertyref prefix="test-sys-prop."/>
 119.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
 119.216 +                    </syspropertyset>
 119.217 +                    <formatter type="brief" usefile="false"/>
 119.218 +                    <formatter type="xml"/>
 119.219 +                    <jvmarg line="${run.jvmargs}"/>
 119.220 +                </junit>
 119.221 +            </sequential>
 119.222 +        </macrodef>
 119.223 +    </target>
 119.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
 119.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
 119.226 +            <attribute default="${main.class}" name="name"/>
 119.227 +            <attribute default="${debug.classpath}" name="classpath"/>
 119.228 +            <attribute default="" name="stopclassname"/>
 119.229 +            <sequential>
 119.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
 119.231 +                    <classpath>
 119.232 +                        <path path="@{classpath}"/>
 119.233 +                    </classpath>
 119.234 +                </nbjpdastart>
 119.235 +            </sequential>
 119.236 +        </macrodef>
 119.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
 119.238 +            <attribute default="${build.classes.dir}" name="dir"/>
 119.239 +            <sequential>
 119.240 +                <nbjpdareload>
 119.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
 119.242 +                        <include name="${fix.includes}*.class"/>
 119.243 +                    </fileset>
 119.244 +                </nbjpdareload>
 119.245 +            </sequential>
 119.246 +        </macrodef>
 119.247 +    </target>
 119.248 +    <target name="-init-debug-args">
 119.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
 119.250 +        <condition property="have-jdk-older-than-1.4">
 119.251 +            <or>
 119.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
 119.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
 119.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
 119.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
 119.256 +            </or>
 119.257 +        </condition>
 119.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
 119.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
 119.260 +        </condition>
 119.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
 119.262 +            <os family="windows"/>
 119.263 +        </condition>
 119.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
 119.265 +            <isset property="debug.transport"/>
 119.266 +        </condition>
 119.267 +    </target>
 119.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
 119.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
 119.270 +            <attribute default="${main.class}" name="classname"/>
 119.271 +            <attribute default="${debug.classpath}" name="classpath"/>
 119.272 +            <element name="customize" optional="true"/>
 119.273 +            <sequential>
 119.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 119.275 +                    <jvmarg line="${debug-args-line}"/>
 119.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
 119.277 +                    <jvmarg line="${run.jvmargs}"/>
 119.278 +                    <classpath>
 119.279 +                        <path path="@{classpath}"/>
 119.280 +                    </classpath>
 119.281 +                    <syspropertyset>
 119.282 +                        <propertyref prefix="run-sys-prop."/>
 119.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 119.284 +                    </syspropertyset>
 119.285 +                    <customize/>
 119.286 +                </java>
 119.287 +            </sequential>
 119.288 +        </macrodef>
 119.289 +    </target>
 119.290 +    <target name="-init-macrodef-java">
 119.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
 119.292 +            <attribute default="${main.class}" name="classname"/>
 119.293 +            <element name="customize" optional="true"/>
 119.294 +            <sequential>
 119.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 119.296 +                    <jvmarg line="${run.jvmargs}"/>
 119.297 +                    <classpath>
 119.298 +                        <path path="${run.classpath}"/>
 119.299 +                    </classpath>
 119.300 +                    <syspropertyset>
 119.301 +                        <propertyref prefix="run-sys-prop."/>
 119.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 119.303 +                    </syspropertyset>
 119.304 +                    <customize/>
 119.305 +                </java>
 119.306 +            </sequential>
 119.307 +        </macrodef>
 119.308 +    </target>
 119.309 +    <target name="-init-presetdef-jar">
 119.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
 119.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
 119.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
 119.313 +            </jar>
 119.314 +        </presetdef>
 119.315 +    </target>
 119.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"/>
 119.317 +    <!--
 119.318 +                ===================
 119.319 +                COMPILATION SECTION
 119.320 +                ===================
 119.321 +            -->
 119.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
 119.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
 119.324 +    <target depends="init" name="-check-automatic-build">
 119.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
 119.326 +    </target>
 119.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
 119.328 +        <antcall target="clean"/>
 119.329 +    </target>
 119.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
 119.331 +        <mkdir dir="${build.classes.dir}"/>
 119.332 +    </target>
 119.333 +    <target name="-pre-compile">
 119.334 +        <!-- Empty placeholder for easier customization. -->
 119.335 +        <!-- You can override this target in the ../build.xml file. -->
 119.336 +    </target>
 119.337 +    <target if="do.depend.true" name="-compile-depend">
 119.338 +        <j2seproject3:depend/>
 119.339 +    </target>
 119.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
 119.341 +        <j2seproject3:javac/>
 119.342 +        <copy todir="${build.classes.dir}">
 119.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 119.344 +        </copy>
 119.345 +    </target>
 119.346 +    <target name="-post-compile">
 119.347 +        <!-- Empty placeholder for easier customization. -->
 119.348 +        <!-- You can override this target in the ../build.xml file. -->
 119.349 +    </target>
 119.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
 119.351 +    <target name="-pre-compile-single">
 119.352 +        <!-- Empty placeholder for easier customization. -->
 119.353 +        <!-- You can override this target in the ../build.xml file. -->
 119.354 +    </target>
 119.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
 119.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 119.357 +        <j2seproject3:force-recompile/>
 119.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
 119.359 +    </target>
 119.360 +    <target name="-post-compile-single">
 119.361 +        <!-- Empty placeholder for easier customization. -->
 119.362 +        <!-- You can override this target in the ../build.xml file. -->
 119.363 +    </target>
 119.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
 119.365 +    <!--
 119.366 +                ====================
 119.367 +                JAR BUILDING SECTION
 119.368 +                ====================
 119.369 +            -->
 119.370 +    <target depends="init" name="-pre-pre-jar">
 119.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
 119.372 +        <mkdir dir="${dist.jar.dir}"/>
 119.373 +    </target>
 119.374 +    <target name="-pre-jar">
 119.375 +        <!-- Empty placeholder for easier customization. -->
 119.376 +        <!-- You can override this target in the ../build.xml file. -->
 119.377 +    </target>
 119.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
 119.379 +        <j2seproject1:jar/>
 119.380 +    </target>
 119.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
 119.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
 119.383 +    </target>
 119.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">
 119.385 +        <j2seproject1:jar manifest="${manifest.file}">
 119.386 +            <j2seproject1:manifest>
 119.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
 119.388 +            </j2seproject1:manifest>
 119.389 +        </j2seproject1:jar>
 119.390 +        <echo>To run this application from the command line without Ant, try:</echo>
 119.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 119.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 119.393 +        <pathconvert property="run.classpath.with.dist.jar">
 119.394 +            <path path="${run.classpath}"/>
 119.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
 119.396 +        </pathconvert>
 119.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
 119.398 +    </target>
 119.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
 119.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 119.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
 119.402 +            <path path="${run.classpath}"/>
 119.403 +            <map from="${build.classes.dir.resolved}" to=""/>
 119.404 +        </pathconvert>
 119.405 +        <pathconvert pathsep=" " property="jar.classpath">
 119.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
 119.407 +            <chainedmapper>
 119.408 +                <flattenmapper/>
 119.409 +                <globmapper from="*" to="lib/*"/>
 119.410 +            </chainedmapper>
 119.411 +        </pathconvert>
 119.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
 119.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
 119.414 +            <fileset dir="${build.classes.dir}"/>
 119.415 +            <manifest>
 119.416 +                <attribute name="Main-Class" value="${main.class}"/>
 119.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
 119.418 +            </manifest>
 119.419 +        </copylibs>
 119.420 +        <echo>To run this application from the command line without Ant, try:</echo>
 119.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 119.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
 119.423 +    </target>
 119.424 +    <target name="-post-jar">
 119.425 +        <!-- Empty placeholder for easier customization. -->
 119.426 +        <!-- You can override this target in the ../build.xml file. -->
 119.427 +    </target>
 119.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"/>
 119.429 +    <!--
 119.430 +                =================
 119.431 +                EXECUTION SECTION
 119.432 +                =================
 119.433 +            -->
 119.434 +    <target depends="init,compile" description="Run a main class." name="run">
 119.435 +        <j2seproject1:java>
 119.436 +            <customize>
 119.437 +                <arg line="${application.args}"/>
 119.438 +            </customize>
 119.439 +        </j2seproject1:java>
 119.440 +    </target>
 119.441 +    <target name="-do-not-recompile">
 119.442 +        <property name="javac.includes.binary" value=""/>
 119.443 +    </target>
 119.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
 119.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
 119.446 +        <j2seproject1:java classname="${run.class}"/>
 119.447 +    </target>
 119.448 +    <!--
 119.449 +                =================
 119.450 +                DEBUGGING SECTION
 119.451 +                =================
 119.452 +            -->
 119.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
 119.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
 119.455 +    </target>
 119.456 +    <target depends="init,compile" name="-debug-start-debuggee">
 119.457 +        <j2seproject3:debug>
 119.458 +            <customize>
 119.459 +                <arg line="${application.args}"/>
 119.460 +            </customize>
 119.461 +        </j2seproject3:debug>
 119.462 +    </target>
 119.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
 119.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
 119.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
 119.466 +    </target>
 119.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
 119.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
 119.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
 119.470 +        <j2seproject3:debug classname="${debug.class}"/>
 119.471 +    </target>
 119.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
 119.473 +    <target depends="init" name="-pre-debug-fix">
 119.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
 119.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
 119.476 +    </target>
 119.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
 119.478 +        <j2seproject1:nbjpdareload/>
 119.479 +    </target>
 119.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
 119.481 +    <!--
 119.482 +                ===============
 119.483 +                JAVADOC SECTION
 119.484 +                ===============
 119.485 +            -->
 119.486 +    <target depends="init" name="-javadoc-build">
 119.487 +        <mkdir dir="${dist.javadoc.dir}"/>
 119.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}">
 119.489 +            <classpath>
 119.490 +                <path path="${javac.classpath}"/>
 119.491 +            </classpath>
 119.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
 119.493 +                <filename name="**/*.java"/>
 119.494 +            </fileset>
 119.495 +        </javadoc>
 119.496 +    </target>
 119.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
 119.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
 119.499 +    </target>
 119.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
 119.501 +    <!--
 119.502 +                =========================
 119.503 +                JUNIT COMPILATION SECTION
 119.504 +                =========================
 119.505 +            -->
 119.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
 119.507 +        <mkdir dir="${build.test.classes.dir}"/>
 119.508 +    </target>
 119.509 +    <target name="-pre-compile-test">
 119.510 +        <!-- Empty placeholder for easier customization. -->
 119.511 +        <!-- You can override this target in the ../build.xml file. -->
 119.512 +    </target>
 119.513 +    <target if="do.depend.true" name="-compile-test-depend">
 119.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 119.515 +    </target>
 119.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
 119.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 119.518 +        <copy todir="${build.test.classes.dir}">
 119.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 119.520 +        </copy>
 119.521 +    </target>
 119.522 +    <target name="-post-compile-test">
 119.523 +        <!-- Empty placeholder for easier customization. -->
 119.524 +        <!-- You can override this target in the ../build.xml file. -->
 119.525 +    </target>
 119.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
 119.527 +    <target name="-pre-compile-test-single">
 119.528 +        <!-- Empty placeholder for easier customization. -->
 119.529 +        <!-- You can override this target in the ../build.xml file. -->
 119.530 +    </target>
 119.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
 119.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 119.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
 119.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}"/>
 119.535 +        <copy todir="${build.test.classes.dir}">
 119.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 119.537 +        </copy>
 119.538 +    </target>
 119.539 +    <target name="-post-compile-test-single">
 119.540 +        <!-- Empty placeholder for easier customization. -->
 119.541 +        <!-- You can override this target in the ../build.xml file. -->
 119.542 +    </target>
 119.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"/>
 119.544 +    <!--
 119.545 +                =======================
 119.546 +                JUNIT EXECUTION SECTION
 119.547 +                =======================
 119.548 +            -->
 119.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
 119.550 +        <mkdir dir="${build.test.results.dir}"/>
 119.551 +    </target>
 119.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
 119.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
 119.554 +    </target>
 119.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
 119.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 119.557 +    </target>
 119.558 +    <target depends="init" if="have.tests" name="test-report"/>
 119.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
 119.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"/>
 119.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
 119.562 +        <mkdir dir="${build.test.results.dir}"/>
 119.563 +    </target>
 119.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
 119.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
 119.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
 119.567 +    </target>
 119.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
 119.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 119.570 +    </target>
 119.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"/>
 119.572 +    <!--
 119.573 +                =======================
 119.574 +                JUNIT DEBUGGING SECTION
 119.575 +                =======================
 119.576 +            -->
 119.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
 119.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
 119.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
 119.580 +        <delete file="${test.report.file}"/>
 119.581 +        <mkdir dir="${build.test.results.dir}"/>
 119.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}">
 119.583 +            <customize>
 119.584 +                <syspropertyset>
 119.585 +                    <propertyref prefix="test-sys-prop."/>
 119.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
 119.587 +                </syspropertyset>
 119.588 +                <arg value="${test.class}"/>
 119.589 +                <arg value="showoutput=true"/>
 119.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
 119.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
 119.592 +            </customize>
 119.593 +        </j2seproject3:debug>
 119.594 +    </target>
 119.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
 119.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
 119.597 +    </target>
 119.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
 119.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
 119.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
 119.601 +    </target>
 119.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
 119.603 +    <!--
 119.604 +                =========================
 119.605 +                APPLET EXECUTION SECTION
 119.606 +                =========================
 119.607 +            -->
 119.608 +    <target depends="init,compile-single" name="run-applet">
 119.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 119.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
 119.611 +            <customize>
 119.612 +                <arg value="${applet.url}"/>
 119.613 +            </customize>
 119.614 +        </j2seproject1:java>
 119.615 +    </target>
 119.616 +    <!--
 119.617 +                =========================
 119.618 +                APPLET DEBUGGING  SECTION
 119.619 +                =========================
 119.620 +            -->
 119.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
 119.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 119.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
 119.624 +            <customize>
 119.625 +                <arg value="${applet.url}"/>
 119.626 +            </customize>
 119.627 +        </j2seproject3:debug>
 119.628 +    </target>
 119.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
 119.630 +    <!--
 119.631 +                ===============
 119.632 +                CLEANUP SECTION
 119.633 +                ===============
 119.634 +            -->
 119.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
 119.636 +    <target depends="init" name="-do-clean">
 119.637 +        <delete dir="${build.dir}"/>
 119.638 +        <delete dir="${dist.dir}"/>
 119.639 +    </target>
 119.640 +    <target name="-post-clean">
 119.641 +        <!-- Empty placeholder for easier customization. -->
 119.642 +        <!-- You can override this target in the ../build.xml file. -->
 119.643 +    </target>
 119.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
 119.645 +</project>
   120.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   120.2 +++ b/task2/solution11/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
   120.3 @@ -0,0 +1,8 @@
   120.4 +build.xml.data.CRC32=2ab820eb
   120.5 +build.xml.script.CRC32=58a52595
   120.6 +build.xml.stylesheet.CRC32=be360661
   120.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
   120.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
   120.9 +nbproject/build-impl.xml.data.CRC32=0e1e702f
  120.10 +nbproject/build-impl.xml.script.CRC32=6cbb076a
  120.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
   121.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.2 +++ b/task2/solution11/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
   121.3 @@ -0,0 +1,68 @@
   121.4 +application.title=currency
   121.5 +application.vendor=apidesign.org
   121.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
   121.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
   121.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
   121.9 +build.classes.dir=${build.dir}/classes
  121.10 +build.classes.excludes=**/*.java,**/*.form
  121.11 +# This directory is removed when the project is cleaned:
  121.12 +build.dir=build
  121.13 +build.generated.dir=${build.dir}/generated
  121.14 +# Only compile against the classpath explicitly listed here:
  121.15 +build.sysclasspath=ignore
  121.16 +build.test.classes.dir=${build.dir}/test/classes
  121.17 +build.test.results.dir=${build.dir}/test/results
  121.18 +debug.classpath=\
  121.19 +    ${run.classpath}
  121.20 +debug.test.classpath=\
  121.21 +    ${run.test.classpath}
  121.22 +# This directory is removed when the project is cleaned:
  121.23 +dist.dir=dist
  121.24 +dist.jar=${dist.dir}/currency.jar
  121.25 +dist.javadoc.dir=${dist.dir}/javadoc
  121.26 +excludes=
  121.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
  121.28 +file.reference.src-apifest08=..
  121.29 +includes=**
  121.30 +jar.compress=false
  121.31 +javac.classpath=
  121.32 +# Space-separated list of extra javac options
  121.33 +javac.compilerargs=-Xlint:unchecked
  121.34 +javac.deprecation=false
  121.35 +javac.source=1.5
  121.36 +javac.target=1.5
  121.37 +javac.test.classpath=\
  121.38 +    ${javac.classpath}:\
  121.39 +    ${build.classes.dir}:\
  121.40 +    ${file.reference.junit-4.4.jar}
  121.41 +javadoc.additionalparam=
  121.42 +javadoc.author=false
  121.43 +javadoc.encoding=
  121.44 +javadoc.noindex=false
  121.45 +javadoc.nonavbar=false
  121.46 +javadoc.notree=false
  121.47 +javadoc.private=false
  121.48 +javadoc.splitindex=true
  121.49 +javadoc.use=true
  121.50 +javadoc.version=false
  121.51 +javadoc.windowtitle=
  121.52 +jnlp.codebase.type=local
  121.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
  121.54 +jnlp.descriptor=application
  121.55 +jnlp.enabled=false
  121.56 +jnlp.offline-allowed=false
  121.57 +jnlp.signed=false
  121.58 +meta.inf.dir=${src.dir}/META-INF
  121.59 +platform.active=default_platform
  121.60 +run.classpath=\
  121.61 +    ${javac.classpath}:\
  121.62 +    ${build.classes.dir}
  121.63 +# Space-separated list of JVM arguments used when running the project
  121.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
  121.65 +# or test-sys-prop.name=value to set system properties for unit tests):
  121.66 +run.jvmargs=
  121.67 +run.test.classpath=\
  121.68 +    ${javac.test.classpath}:\
  121.69 +    ${build.test.classes.dir}
  121.70 +src.dir=src
  121.71 +test.src.dir=test
   122.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.2 +++ b/task2/solution11/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
   122.3 @@ -0,0 +1,16 @@
   122.4 +<?xml version="1.0" encoding="UTF-8"?>
   122.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
   122.6 +    <type>org.netbeans.modules.java.j2seproject</type>
   122.7 +    <configuration>
   122.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
   122.9 +            <name>Currency Convertor Solution 11</name>
  122.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
  122.11 +            <source-roots>
  122.12 +                <root id="src.dir"/>
  122.13 +            </source-roots>
  122.14 +            <test-roots>
  122.15 +                <root id="test.src.dir"/>
  122.16 +            </test-roots>
  122.17 +        </data>
  122.18 +    </configuration>
  122.19 +</project>
   123.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.2 +++ b/task2/solution11/src/org/apidesign/apifest08/currency/Computer.java	Wed Oct 01 10:43:05 2008 +0200
   123.3 @@ -0,0 +1,65 @@
   123.4 +package org.apidesign.apifest08.currency;
   123.5 +
   123.6 +/**
   123.7 + * Interface declaring method for computing conversion.
   123.8 + * 
   123.9 + * Because of a vague definition of currency amount's type,
  123.10 + * the interface has a generic type.
  123.11 + * 
  123.12 + * @author ked
  123.13 + * @see http://wiki.apidesign.org/wiki/APIDesignPatterns:ResponseReply
  123.14 + */
  123.15 +interface Computer<AmountType> {
  123.16 +
  123.17 +    ComputerResponse<AmountType> compute(ComputerRequest<AmountType> request);
  123.18 +
  123.19 +    /**
  123.20 +     * 
  123.21 +     * @param <AmountType>
  123.22 +     */
  123.23 +    final class ComputerRequest<AmountType> {
  123.24 +
  123.25 +        private AmountType input;
  123.26 +        private AmountType inputCurrencyRatio;
  123.27 +        private AmountType outputCurrencyRatio;
  123.28 +
  123.29 +        AmountType getInput() {
  123.30 +            return input;
  123.31 +        }
  123.32 +
  123.33 +        void setInput(AmountType input) {
  123.34 +            this.input = input;
  123.35 +        }
  123.36 +
  123.37 +        AmountType getInputCurrencyRatio() {
  123.38 +            return inputCurrencyRatio;
  123.39 +        }
  123.40 +
  123.41 +        void setInputCurrencyRatio(AmountType inputCurrencyRatio) {
  123.42 +            this.inputCurrencyRatio = inputCurrencyRatio;
  123.43 +        }
  123.44 +
  123.45 +        AmountType getOutputCurrencyRatio() {
  123.46 +            return outputCurrencyRatio;
  123.47 +        }
  123.48 +
  123.49 +        void setOutputCurrencyRatio(AmountType outputCurrencyRatio) {
  123.50 +            this.outputCurrencyRatio = outputCurrencyRatio;
  123.51 +        }
  123.52 +    }
  123.53 +
  123.54 +    final class ComputerResponse<AmountType> {
  123.55 +
  123.56 +        private AmountType result;
  123.57 +
  123.58 +        AmountType getResult() {
  123.59 +            return result;
  123.60 +        }
  123.61 +
  123.62 +        void setResult(AmountType result) {
  123.63 +            this.result = result;
  123.64 +        }
  123.65 +    }
  123.66 +    
  123.67 +    
  123.68 +}
  123.69 \ No newline at end of file
   124.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   124.2 +++ b/task2/solution11/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
   124.3 @@ -0,0 +1,129 @@
   124.4 +package org.apidesign.apifest08.currency;
   124.5 +
   124.6 +import org.apidesign.apifest08.currency.Computer.ComputerRequest;
   124.7 +import org.apidesign.apifest08.currency.Computer.ComputerResponse;
   124.8 +
   124.9 +/**
  124.10 + * Convertor.
  124.11 + * 
  124.12 + * In Task 1's version provides conversion between currency values
  124.13 + * with amount stored in integer or double, that are identified
  124.14 + * with string value. Exchange rates are immutable.
  124.15 + * 
  124.16 + * @author ked
  124.17 + */
  124.18 +public final class Convertor<AmountType, IdentifierType> {
  124.19 +
  124.20 +    Computer<AmountType> computer;
  124.21 +    CurrencyValue<AmountType, IdentifierType> firstCurrencyExchangeRate;
  124.22 +    CurrencyValue<AmountType, IdentifierType> secondCurrencyExchangeRate;
  124.23 +
  124.24 +    Convertor(
  124.25 +            Computer<AmountType> computer,
  124.26 +            CurrencyValue<AmountType, IdentifierType> firstCurrencyExchangeRate,
  124.27 +            CurrencyValue<AmountType, IdentifierType> secondCurrencyExchangeRate) {
  124.28 +        if (firstCurrencyExchangeRate.getIdentifier() == null ||
  124.29 +            secondCurrencyExchangeRate.getIdentifier() == null ||
  124.30 +            firstCurrencyExchangeRate.getIdentifier().equals(secondCurrencyExchangeRate.getIdentifier())) {
  124.31 +                throw new IllegalArgumentException("Inappropriate exchange rates' identifiers!");
  124.32 +        }
  124.33 +        this.computer = computer;
  124.34 +        this.firstCurrencyExchangeRate = firstCurrencyExchangeRate;
  124.35 +        this.secondCurrencyExchangeRate = secondCurrencyExchangeRate;
  124.36 +    }
  124.37 +
  124.38 +    /**
  124.39 +     * Convert an amount of the one currency to an amount of the another one currency
  124.40 +     * with respect to previously specified exchange rate.
  124.41 +     * 
  124.42 +     * @param targetCurrency an identifier of the requested currency
  124.43 +     * @param currencyValue an amount of the another one currency
  124.44 +     * @return an amount of the requested currency
  124.45 +     */
  124.46 +    public CurrencyValue<AmountType, IdentifierType> convert(
  124.47 +            IdentifierType targetCurrency,
  124.48 +            CurrencyValue<AmountType, IdentifierType> currencyValue) {
  124.49 +        if (firstCurrencyExchangeRate.getIdentifier().equals(targetCurrency) &&
  124.50 +            secondCurrencyExchangeRate.getIdentifier().equals(currencyValue.getIdentifier())) {
  124.51 +            ComputerRequest<AmountType> computerRequest = new ComputerRequest<AmountType>();
  124.52 +            computerRequest.setInput(currencyValue.getAmount());
  124.53 +            computerRequest.setInputCurrencyRatio(secondCurrencyExchangeRate.getAmount());
  124.54 +            computerRequest.setOutputCurrencyRatio(firstCurrencyExchangeRate.getAmount());
  124.55 +            ComputerResponse<AmountType> computerResponse = computer.compute(computerRequest);
  124.56 +
  124.57 +            return CurrencyValue.getCurrencyValue(
  124.58 +                    computerResponse.getResult(),
  124.59 +                    firstCurrencyExchangeRate.getIdentifier());
  124.60 +        } else if (secondCurrencyExchangeRate.getIdentifier().equals(targetCurrency) &&
  124.61 +                   firstCurrencyExchangeRate.getIdentifier().equals(currencyValue.getIdentifier())) {
  124.62 +            ComputerRequest<AmountType> computerRequest = new ComputerRequest<AmountType>();
  124.63 +            computerRequest.setInput(currencyValue.getAmount());
  124.64 +            computerRequest.setInputCurrencyRatio(firstCurrencyExchangeRate.getAmount());
  124.65 +            computerRequest.setOutputCurrencyRatio(secondCurrencyExchangeRate.getAmount());
  124.66 +            ComputerResponse<AmountType> computerResponse = computer.compute(computerRequest);
  124.67 +
  124.68 +            return CurrencyValue.getCurrencyValue(
  124.69 +                    computerResponse.getResult(),
  124.70 +                    secondCurrencyExchangeRate.getIdentifier());
  124.71 +        } else {
  124.72 +            throw new IllegalArgumentException("Inappropriate currencies to convert!");
  124.73 +        }
  124.74 +    }
  124.75 +
  124.76 +    static <AmountType, IdentifierType> Convertor<AmountType, IdentifierType> getConvertor(
  124.77 +            Computer<AmountType> computer,
  124.78 +            CurrencyValue<AmountType, IdentifierType> firstCurrencyExchangeRate,
  124.79 +            CurrencyValue<AmountType, IdentifierType> secondCurrencyExchangeRate) {
  124.80 +        return new Convertor<AmountType, IdentifierType>(
  124.81 +                computer,
  124.82 +                firstCurrencyExchangeRate,
  124.83 +                secondCurrencyExchangeRate);
  124.84 +    }
  124.85 +    
  124.86 +    static final Computer<Double> DoubleComputer = new Computer<Double>() {
  124.87 +
  124.88 +        public ComputerResponse<Double> compute(ComputerRequest<Double> request) {
  124.89 +            ComputerResponse<Double> response = new ComputerResponse<Double>();
  124.90 +            response.setResult(request.getInput() * request.getOutputCurrencyRatio() / request.getInputCurrencyRatio());
  124.91 +            return response;
  124.92 +        }
  124.93 +    };
  124.94 +
  124.95 +    /**
  124.96 +     * Creates convertor for Double|String values with specified exchange rate
  124.97 +     * between two currencies.
  124.98 +     * 
  124.99 +     * @param firstCurrencyExchangeRate first currency
 124.100 +     * @param secondCurrencyExchangeRate second currency
 124.101 +     * @return convertor
 124.102 +     */
 124.103 +
 124.104 +    public static Convertor<Double, String> getConvertorDoubleString(
 124.105 +            CurrencyValue<Double, String> firstCurrencyExchangeRate,
 124.106 +            CurrencyValue<Double, String> secondCurrencyExchangeRate) {
 124.107 +        return getConvertor(DoubleComputer, firstCurrencyExchangeRate, secondCurrencyExchangeRate);
 124.108 +    }
 124.109 +    
 124.110 +    static final Computer<Integer> IntegerComputer = new Computer<Integer>() {
 124.111 +
 124.112 +        public ComputerResponse<Integer> compute(ComputerRequest<Integer> request) {
 124.113 +            ComputerResponse<Integer> response = new ComputerResponse<Integer>();
 124.114 +            response.setResult(request.getInput() * request.getOutputCurrencyRatio() / request.getInputCurrencyRatio());
 124.115 +            return response;
 124.116 +        }
 124.117 +    };
 124.118 +
 124.119 +    /**
 124.120 +     * Creates convertor for Integer|String values with specified exchange rate
 124.121 +     * between two currencies.
 124.122 +     * 
 124.123 +     * @param firstCurrencyExchangeRate first currency
 124.124 +     * @param secondCurrencyExchangeRate second currency
 124.125 +     * @return convertor
 124.126 +     */
 124.127 +    public static Convertor<Integer, String> getConvertorIntegerString(
 124.128 +            CurrencyValue<Integer, String> firstCurrencyExchangeRate,
 124.129 +            CurrencyValue<Integer, String> secondCurrencyExchangeRate) {
 124.130 +        return getConvertor(IntegerComputer, firstCurrencyExchangeRate, secondCurrencyExchangeRate);
 124.131 +    }
 124.132 +}
   125.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   125.2 +++ b/task2/solution11/src/org/apidesign/apifest08/currency/CurrencyValue.java	Wed Oct 01 10:43:05 2008 +0200
   125.3 @@ -0,0 +1,72 @@
   125.4 +package org.apidesign.apifest08.currency;
   125.5 +
   125.6 +import java.io.Serializable;
   125.7 +
   125.8 +/**
   125.9 + * Value class, holding an amount of the currency & an identifier of the currency.
  125.10 + * Designed to be an immutable.
  125.11 + * 
  125.12 + * Because of a vague definition of types of the both fields,
  125.13 + * the class has generic types, used as types of the fields.
  125.14 + * These types should be immutable classes, too.
  125.15 + * 
  125.16 + * @author ked
  125.17 + */
  125.18 +public final class CurrencyValue<AmountType, IdentifierType> implements Serializable {
  125.19 +
  125.20 +    private final AmountType amount;
  125.21 +    private final IdentifierType identifier;
  125.22 +
  125.23 +    private CurrencyValue(AmountType amount, IdentifierType identifier) {
  125.24 +        this.amount = amount;
  125.25 +        this.identifier = identifier;
  125.26 +    }
  125.27 +
  125.28 +    public AmountType getAmount() {
  125.29 +        return amount;
  125.30 +    }
  125.31 +
  125.32 +    public IdentifierType getIdentifier() {
  125.33 +        return identifier;
  125.34 +    }
  125.35 +
  125.36 +    @Override
  125.37 +    public boolean equals(Object obj) {
  125.38 +        if (obj == null) {
  125.39 +            return false;
  125.40 +        }
  125.41 +        if (getClass() != obj.getClass()) {
  125.42 +            return false;
  125.43 +        }
  125.44 +        final CurrencyValue other = (CurrencyValue) obj;
  125.45 +        if (this.amount != other.amount && (this.amount == null || !this.amount.equals(other.amount))) {
  125.46 +            return false;
  125.47 +        }
  125.48 +        if (this.identifier != other.identifier && (this.identifier == null || !this.identifier.equals(other.identifier))) {
  125.49 +            return false;
  125.50 +        }
  125.51 +        return true;
  125.52 +    }
  125.53 +
  125.54 +    @Override
  125.55 +    public int hashCode() {
  125.56 +        int hash = 7;
  125.57 +        hash = 97 * hash + (this.amount != null ? this.amount.hashCode() : 0);
  125.58 +        hash = 97 * hash + (this.identifier != null ? this.identifier.hashCode() : 0);
  125.59 +        return hash;
  125.60 +    }
  125.61 +
  125.62 +    /**
  125.63 +     * Creates new instance.
  125.64 +     * Generic types of the new instance are derived from types of the parameters.
  125.65 +     * 
  125.66 +     * @param <AmountType> type of the currency amount
  125.67 +     * @param <IdentifierType> type of the currency identifier
  125.68 +     * @param amount currency amount
  125.69 +     * @param identifier currency identifier
  125.70 +     * @return new instance
  125.71 +     */
  125.72 +    public static <AmountType, IdentifierType> CurrencyValue<AmountType, IdentifierType> getCurrencyValue(AmountType amount, IdentifierType identifier) {
  125.73 +        return new CurrencyValue<AmountType, IdentifierType>(amount, identifier);
  125.74 +    }
  125.75 +}
   126.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.2 +++ b/task2/solution11/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   126.3 @@ -0,0 +1,161 @@
   126.4 +package org.apidesign.apifest08.test;
   126.5 +
   126.6 +import junit.framework.TestCase;
   126.7 +import org.apidesign.apifest08.currency.Convertor;
   126.8 +import org.apidesign.apifest08.currency.CurrencyValue;
   126.9 +
  126.10 +/** Finish the Convertor API, and then write bodies of methods inside
  126.11 + * of this class to match the given tasks. To fullfil your task, use the
  126.12 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
  126.13 + * Do not you reflection, or other hacks as your code
  126.14 + * shall run without any runtime permissions.
  126.15 + */
  126.16 +public class Task1Test extends TestCase {
  126.17 +    public Task1Test(String testName) {
  126.18 +        super(testName);
  126.19 +    }
  126.20 +
  126.21 +    @Override
  126.22 +    protected void setUp() throws Exception {
  126.23 +    }
  126.24 +
  126.25 +    @Override
  126.26 +    protected void tearDown() throws Exception {
  126.27 +    }
  126.28 +
  126.29 +    //
  126.30 +    // Imagine that there are three parts of the whole system:
  126.31 +    // 1. there is someone who knows the current exchange rate
  126.32 +    // 2. there is someone who wants to do the conversion
  126.33 +    // 3. there is the API between 1. and 2. which allows them to communicate
  126.34 +    // Please design such API
  126.35 +    //
  126.36 +
  126.37 +    /** Create convertor that understands two currencies, CZK and
  126.38 +     *  USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
  126.39 +     *  e.g. those that know the exchange rate. They somehow need to create
  126.40 +     *  the objects from the API and tell them the exchange rate. The API itself
  126.41 +     *  knows nothing about any rates, before the createCZKtoUSD method is called.
  126.42 +     *
  126.43 +     * Creation of the convertor shall not require subclassing of any class
  126.44 +     * or interface on the client side.
  126.45 +     *
  126.46 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
  126.47 +     */
  126.48 +    public static Convertor<Integer, String> createCZKtoUSD() {
  126.49 +        return Convertor.getConvertorIntegerString(
  126.50 +                CurrencyValue.getCurrencyValue(1, "USD"),
  126.51 +                CurrencyValue.getCurrencyValue(17, "CZK")
  126.52 +        );
  126.53 +    }
  126.54 +
  126.55 +    /** Create convertor that understands two currencies, CZK and
  126.56 +     *  SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
  126.57 +     *  it knows the exchange rate, and needs to use the API to create objects
  126.58 +     *  with the exchange rate. Anyone shall be ready to call this method without
  126.59 +     *  any other method being called previously. The API itself shall know
  126.60 +     *  nothing about any rates, before this method is called.
  126.61 +     *
  126.62 +     * Creation of the convertor shall not require subclassing of any class
  126.63 +     * or interface on the client side.
  126.64 +     * 
  126.65 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  126.66 +     */
  126.67 +    public static Convertor<Integer, String> createSKKtoCZK() {
  126.68 +        return Convertor.getConvertorIntegerString(
  126.69 +                CurrencyValue.getCurrencyValue(100, "SKK"),
  126.70 +                CurrencyValue.getCurrencyValue(80, "CZK")
  126.71 +        );
  126.72 +    }
  126.73 +
  126.74 +    //
  126.75 +    // now the methods for group #2 follow:
  126.76 +    // this group knows nothing about exchange rates, but knows how to use
  126.77 +    // the API to do conversions. It somehow (by calling one of the factory
  126.78 +    // methods) gets objects from the API and uses them to do the conversions.
  126.79 +    //
  126.80 +    
  126.81 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
  126.82 +     * with it.
  126.83 +     */
  126.84 +    public void testCurrencyCZKUSD() throws Exception {
  126.85 +        Convertor<Integer, String> c = createCZKtoUSD();
  126.86 +        
  126.87 +        CurrencyValue<Integer, String> result;
  126.88 +        
  126.89 +        // convert $5 to CZK using c:
  126.90 +        // assertEquals("Result is 85 CZK");
  126.91 +        result = c.convert("CZK", CurrencyValue.getCurrencyValue(5, "USD"));
  126.92 +        assertEquals(CurrencyValue.getCurrencyValue(85, "CZK"), result);
  126.93 +
  126.94 +        // convert $8 to CZK
  126.95 +        // assertEquals("Result is 136 CZK");
  126.96 +        result = c.convert("CZK", CurrencyValue.getCurrencyValue(8, "USD"));
  126.97 +        assertEquals(CurrencyValue.getCurrencyValue(136, "CZK"), result);
  126.98 +
  126.99 +        // convert 1003CZK to USD
 126.100 +        // assertEquals("Result is 59 USD");
 126.101 +        result = c.convert("USD", CurrencyValue.getCurrencyValue(1003, "CZK"));
 126.102 +        assertEquals(CurrencyValue.getCurrencyValue(59, "USD"), result);
 126.103 +    }
 126.104 +
 126.105 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
 126.106 +     * with it.
 126.107 +     */
 126.108 +    public void testCurrencySKKCZK() throws Exception {
 126.109 +        Convertor<Integer, String> c = createSKKtoCZK();
 126.110 +        
 126.111 +        CurrencyValue<Integer, String> result;
 126.112 +        
 126.113 +        // convert 16CZK using c:
 126.114 +        // assertEquals("Result is 20 SKK");
 126.115 +        result = c.convert("SKK", CurrencyValue.getCurrencyValue(16, "CZK"));
 126.116 +        assertEquals(CurrencyValue.getCurrencyValue(20, "SKK"), result);
 126.117 +
 126.118 +        // convert 500SKK to CZK
 126.119 +        // assertEquals("Result is 400 CZK");
 126.120 +        result = c.convert("CZK", CurrencyValue.getCurrencyValue(500, "SKK"));
 126.121 +        assertEquals(CurrencyValue.getCurrencyValue(400, "CZK"), result);
 126.122 +    }
 126.123 +
 126.124 +    /** Verify that the CZK to USD convertor knows nothing about SKK.
 126.125 +     */
 126.126 +    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
 126.127 +        Convertor<Integer, String> c = createCZKtoUSD();
 126.128 +        try {
 126.129 +            // convert $5 to SKK, the API shall say this is not possible
 126.130 +            c.convert("SKK", CurrencyValue.getCurrencyValue(16, "CZK"));
 126.131 +            assertTrue("Should not convert", false);
 126.132 +        } catch (Exception e) {
 126.133 +            assertTrue(true);
 126.134 +        }
 126.135 +        try {
 126.136 +            // convert 500 SKK to CZK, the API shall say this is not possible
 126.137 +            c.convert("CZK", CurrencyValue.getCurrencyValue(500, "SKK"));
 126.138 +            assertTrue("Should not convert", false);
 126.139 +        } catch (Exception e) {
 126.140 +            assertTrue(true);
 126.141 +        }
 126.142 +        
 126.143 +    }
 126.144 +
 126.145 +    /** Verify that the CZK to SKK convertor knows nothing about USD.
 126.146 +     */
 126.147 +    public void testCannotConvertToUSDwithSKKCZKConvertor() throws Exception {
 126.148 +        Convertor<Integer, String> c = createSKKtoCZK();
 126.149 +        try {
 126.150 +            // convert $5 to SKK, the API shall say this is not possible
 126.151 +            c.convert("SKK", CurrencyValue.getCurrencyValue(5, "USD"));
 126.152 +            assertTrue("Should not convert", false);
 126.153 +        } catch (Exception e) {
 126.154 +            assertTrue(true);
 126.155 +        }
 126.156 +        try {
 126.157 +            // convert 500 CZK to USD, the API shall say this is not possible
 126.158 +            c.convert("USD", CurrencyValue.getCurrencyValue(500, "CZK"));
 126.159 +            assertTrue("Should not convert", false);
 126.160 +        } catch (Exception e) {
 126.161 +            assertTrue(true);
 126.162 +        }
 126.163 +    }
 126.164 +}
   127.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.2 +++ b/task2/solution12/build.xml	Wed Oct 01 10:43:05 2008 +0200
   127.3 @@ -0,0 +1,69 @@
   127.4 +<?xml version="1.0" encoding="UTF-8"?>
   127.5 +<!-- You may freely edit this file. See commented blocks below for -->
   127.6 +<!-- some examples of how to customize the build. -->
   127.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
   127.8 +<project name="currency" default="default" basedir=".">
   127.9 +    <description>Builds, tests, and runs the project.</description>
  127.10 +    <import file="nbproject/build-impl.xml"/>
  127.11 +    <!--
  127.12 +
  127.13 +    There exist several targets which are by default empty and which can be 
  127.14 +    used for execution of your tasks. These targets are usually executed 
  127.15 +    before and after some main targets. They are: 
  127.16 +
  127.17 +      -pre-init:                 called before initialization of project properties
  127.18 +      -post-init:                called after initialization of project properties
  127.19 +      -pre-compile:              called before javac compilation
  127.20 +      -post-compile:             called after javac compilation
  127.21 +      -pre-compile-single:       called before javac compilation of single file
  127.22 +      -post-compile-single:      called after javac compilation of single file
  127.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
  127.24 +      -post-compile-test:        called after javac compilation of JUnit tests
  127.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
  127.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
  127.27 +      -pre-jar:                  called before JAR building
  127.28 +      -post-jar:                 called after JAR building
  127.29 +      -post-clean:               called after cleaning build products
  127.30 +
  127.31 +    (Targets beginning with '-' are not intended to be called on their own.)
  127.32 +
  127.33 +    Example of inserting an obfuscator after compilation could look like this:
  127.34 +
  127.35 +        <target name="-post-compile">
  127.36 +            <obfuscate>
  127.37 +                <fileset dir="${build.classes.dir}"/>
  127.38 +            </obfuscate>
  127.39 +        </target>
  127.40 +
  127.41 +    For list of available properties check the imported 
  127.42 +    nbproject/build-impl.xml file. 
  127.43 +
  127.44 +
  127.45 +    Another way to customize the build is by overriding existing main targets.
  127.46 +    The targets of interest are: 
  127.47 +
  127.48 +      -init-macrodef-javac:     defines macro for javac compilation
  127.49 +      -init-macrodef-junit:     defines macro for junit execution
  127.50 +      -init-macrodef-debug:     defines macro for class debugging
  127.51 +      -init-macrodef-java:      defines macro for class execution
  127.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  127.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  127.54 +      run:                      execution of project 
  127.55 +      -javadoc-build:           Javadoc generation
  127.56 +      test-report:              JUnit report generation
  127.57 +
  127.58 +    An example of overriding the target for project execution could look like this:
  127.59 +
  127.60 +        <target name="run" depends="currency-impl.jar">
  127.61 +            <exec dir="bin" executable="launcher.exe">
  127.62 +                <arg file="${dist.jar}"/>
  127.63 +            </exec>
  127.64 +        </target>
  127.65 +
  127.66 +    Notice that the overridden target depends on the jar target and not only on 
  127.67 +    the compile target as the regular run target does. Again, for a list of available 
  127.68 +    properties which you can use, check the target you are overriding in the
  127.69 +    nbproject/build-impl.xml file. 
  127.70 +
  127.71 +    -->
  127.72 +</project>
   128.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   128.2 +++ b/task2/solution12/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
   128.3 @@ -0,0 +1,642 @@
   128.4 +<?xml version="1.0" encoding="UTF-8"?>
   128.5 +<!--
   128.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
   128.7 +***         EDIT ../build.xml INSTEAD         ***
   128.8 +
   128.9 +For the purpose of easier reading the script
  128.10 +is divided into following sections:
  128.11 +
  128.12 +  - initialization
  128.13 +  - compilation
  128.14 +  - jar
  128.15 +  - execution
  128.16 +  - debugging
  128.17 +  - javadoc
  128.18 +  - junit compilation
  128.19 +  - junit execution
  128.20 +  - junit debugging
  128.21 +  - applet
  128.22 +  - cleanup
  128.23 +
  128.24 +        -->
  128.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_12-impl">
  128.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
  128.27 +    <!-- 
  128.28 +                ======================
  128.29 +                INITIALIZATION SECTION 
  128.30 +                ======================
  128.31 +            -->
  128.32 +    <target name="-pre-init">
  128.33 +        <!-- Empty placeholder for easier customization. -->
  128.34 +        <!-- You can override this target in the ../build.xml file. -->
  128.35 +    </target>
  128.36 +    <target depends="-pre-init" name="-init-private">
  128.37 +        <property file="nbproject/private/config.properties"/>
  128.38 +        <property file="nbproject/private/configs/${config}.properties"/>
  128.39 +        <property file="nbproject/private/private.properties"/>
  128.40 +    </target>
  128.41 +    <target depends="-pre-init,-init-private" name="-init-user">
  128.42 +        <property file="${user.properties.file}"/>
  128.43 +        <!-- The two properties below are usually overridden -->
  128.44 +        <!-- by the active platform. Just a fallback. -->
  128.45 +        <property name="default.javac.source" value="1.4"/>
  128.46 +        <property name="default.javac.target" value="1.4"/>
  128.47 +    </target>
  128.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
  128.49 +        <property file="nbproject/configs/${config}.properties"/>
  128.50 +        <property file="nbproject/project.properties"/>
  128.51 +    </target>
  128.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
  128.53 +        <available file="${manifest.file}" property="manifest.available"/>
  128.54 +        <condition property="manifest.available+main.class">
  128.55 +            <and>
  128.56 +                <isset property="manifest.available"/>
  128.57 +                <isset property="main.class"/>
  128.58 +                <not>
  128.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
  128.60 +                </not>
  128.61 +            </and>
  128.62 +        </condition>
  128.63 +        <condition property="manifest.available+main.class+mkdist.available">
  128.64 +            <and>
  128.65 +                <istrue value="${manifest.available+main.class}"/>
  128.66 +                <isset property="libs.CopyLibs.classpath"/>
  128.67 +            </and>
  128.68 +        </condition>
  128.69 +        <condition property="have.tests">
  128.70 +            <or>
  128.71 +                <available file="${test.src.dir}"/>
  128.72 +            </or>
  128.73 +        </condition>
  128.74 +        <condition property="have.sources">
  128.75 +            <or>
  128.76 +                <available file="${src.dir}"/>
  128.77 +            </or>
  128.78 +        </condition>
  128.79 +        <condition property="netbeans.home+have.tests">
  128.80 +            <and>
  128.81 +                <isset property="netbeans.home"/>
  128.82 +                <isset property="have.tests"/>
  128.83 +            </and>
  128.84 +        </condition>
  128.85 +        <condition property="no.javadoc.preview">
  128.86 +            <and>
  128.87 +                <isset property="javadoc.preview"/>
  128.88 +                <isfalse value="${javadoc.preview}"/>
  128.89 +            </and>
  128.90 +        </condition>
  128.91 +        <property name="run.jvmargs" value=""/>
  128.92 +        <property name="javac.compilerargs" value=""/>
  128.93 +        <property name="work.dir" value="${basedir}"/>
  128.94 +        <condition property="no.deps">
  128.95 +            <and>
  128.96 +                <istrue value="${no.dependencies}"/>
  128.97 +            </and>
  128.98 +        </condition>
  128.99 +        <property name="javac.debug" value="true"/>
 128.100 +        <property name="javadoc.preview" value="true"/>
 128.101 +        <property name="application.args" value=""/>
 128.102 +        <property name="source.encoding" value="${file.encoding}"/>
 128.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
 128.104 +            <and>
 128.105 +                <isset property="javadoc.encoding"/>
 128.106 +                <not>
 128.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
 128.108 +                </not>
 128.109 +            </and>
 128.110 +        </condition>
 128.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
 128.112 +        <property name="includes" value="**"/>
 128.113 +        <property name="excludes" value=""/>
 128.114 +        <property name="do.depend" value="false"/>
 128.115 +        <condition property="do.depend.true">
 128.116 +            <istrue value="${do.depend}"/>
 128.117 +        </condition>
 128.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
 128.119 +            <and>
 128.120 +                <isset property="jaxws.endorsed.dir"/>
 128.121 +                <available file="nbproject/jaxws-build.xml"/>
 128.122 +            </and>
 128.123 +        </condition>
 128.124 +    </target>
 128.125 +    <target name="-post-init">
 128.126 +        <!-- Empty placeholder for easier customization. -->
 128.127 +        <!-- You can override this target in the ../build.xml file. -->
 128.128 +    </target>
 128.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
 128.130 +        <fail unless="src.dir">Must set src.dir</fail>
 128.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
 128.132 +        <fail unless="build.dir">Must set build.dir</fail>
 128.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
 128.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
 128.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
 128.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
 128.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
 128.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
 128.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
 128.140 +    </target>
 128.141 +    <target name="-init-macrodef-property">
 128.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
 128.143 +            <attribute name="name"/>
 128.144 +            <attribute name="value"/>
 128.145 +            <sequential>
 128.146 +                <property name="@{name}" value="${@{value}}"/>
 128.147 +            </sequential>
 128.148 +        </macrodef>
 128.149 +    </target>
 128.150 +    <target name="-init-macrodef-javac">
 128.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
 128.152 +            <attribute default="${src.dir}" name="srcdir"/>
 128.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
 128.154 +            <attribute default="${javac.classpath}" name="classpath"/>
 128.155 +            <attribute default="${includes}" name="includes"/>
 128.156 +            <attribute default="${excludes}" name="excludes"/>
 128.157 +            <attribute default="${javac.debug}" name="debug"/>
 128.158 +            <attribute default="" name="sourcepath"/>
 128.159 +            <element name="customize" optional="true"/>
 128.160 +            <sequential>
 128.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}">
 128.162 +                    <classpath>
 128.163 +                        <path path="@{classpath}"/>
 128.164 +                    </classpath>
 128.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
 128.166 +                    <customize/>
 128.167 +                </javac>
 128.168 +            </sequential>
 128.169 +        </macrodef>
 128.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
 128.171 +            <attribute default="${src.dir}" name="srcdir"/>
 128.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
 128.173 +            <attribute default="${javac.classpath}" name="classpath"/>
 128.174 +            <sequential>
 128.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
 128.176 +                    <classpath>
 128.177 +                        <path path="@{classpath}"/>
 128.178 +                    </classpath>
 128.179 +                </depend>
 128.180 +            </sequential>
 128.181 +        </macrodef>
 128.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
 128.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
 128.184 +            <sequential>
 128.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
 128.186 +                <pathconvert pathsep="," property="javac.includes.binary">
 128.187 +                    <path>
 128.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
 128.189 +                    </path>
 128.190 +                    <globmapper from="*.java" to="*.class"/>
 128.191 +                </pathconvert>
 128.192 +                <delete>
 128.193 +                    <files includes="${javac.includes.binary}"/>
 128.194 +                </delete>
 128.195 +            </sequential>
 128.196 +        </macrodef>
 128.197 +    </target>
 128.198 +    <target name="-init-macrodef-junit">
 128.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
 128.200 +            <attribute default="${includes}" name="includes"/>
 128.201 +            <attribute default="${excludes}" name="excludes"/>
 128.202 +            <attribute default="**" name="testincludes"/>
 128.203 +            <sequential>
 128.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
 128.205 +                    <batchtest todir="${build.test.results.dir}">
 128.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
 128.207 +                            <filename name="@{testincludes}"/>
 128.208 +                        </fileset>
 128.209 +                    </batchtest>
 128.210 +                    <classpath>
 128.211 +                        <path path="${run.test.classpath}"/>
 128.212 +                    </classpath>
 128.213 +                    <syspropertyset>
 128.214 +                        <propertyref prefix="test-sys-prop."/>
 128.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
 128.216 +                    </syspropertyset>
 128.217 +                    <formatter type="brief" usefile="false"/>
 128.218 +                    <formatter type="xml"/>
 128.219 +                    <jvmarg line="${run.jvmargs}"/>
 128.220 +                </junit>
 128.221 +            </sequential>
 128.222 +        </macrodef>
 128.223 +    </target>
 128.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
 128.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
 128.226 +            <attribute default="${main.class}" name="name"/>
 128.227 +            <attribute default="${debug.classpath}" name="classpath"/>
 128.228 +            <attribute default="" name="stopclassname"/>
 128.229 +            <sequential>
 128.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
 128.231 +                    <classpath>
 128.232 +                        <path path="@{classpath}"/>
 128.233 +                    </classpath>
 128.234 +                </nbjpdastart>
 128.235 +            </sequential>
 128.236 +        </macrodef>
 128.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
 128.238 +            <attribute default="${build.classes.dir}" name="dir"/>
 128.239 +            <sequential>
 128.240 +                <nbjpdareload>
 128.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
 128.242 +                        <include name="${fix.includes}*.class"/>
 128.243 +                    </fileset>
 128.244 +                </nbjpdareload>
 128.245 +            </sequential>
 128.246 +        </macrodef>
 128.247 +    </target>
 128.248 +    <target name="-init-debug-args">
 128.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
 128.250 +        <condition property="have-jdk-older-than-1.4">
 128.251 +            <or>
 128.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
 128.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
 128.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
 128.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
 128.256 +            </or>
 128.257 +        </condition>
 128.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
 128.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
 128.260 +        </condition>
 128.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
 128.262 +            <os family="windows"/>
 128.263 +        </condition>
 128.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
 128.265 +            <isset property="debug.transport"/>
 128.266 +        </condition>
 128.267 +    </target>
 128.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
 128.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
 128.270 +            <attribute default="${main.class}" name="classname"/>
 128.271 +            <attribute default="${debug.classpath}" name="classpath"/>
 128.272 +            <element name="customize" optional="true"/>
 128.273 +            <sequential>
 128.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 128.275 +                    <jvmarg line="${debug-args-line}"/>
 128.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
 128.277 +                    <jvmarg line="${run.jvmargs}"/>
 128.278 +                    <classpath>
 128.279 +                        <path path="@{classpath}"/>
 128.280 +                    </classpath>
 128.281 +                    <syspropertyset>
 128.282 +                        <propertyref prefix="run-sys-prop."/>
 128.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 128.284 +                    </syspropertyset>
 128.285 +                    <customize/>
 128.286 +                </java>
 128.287 +            </sequential>
 128.288 +        </macrodef>
 128.289 +    </target>
 128.290 +    <target name="-init-macrodef-java">
 128.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
 128.292 +            <attribute default="${main.class}" name="classname"/>
 128.293 +            <element name="customize" optional="true"/>
 128.294 +            <sequential>
 128.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 128.296 +                    <jvmarg line="${run.jvmargs}"/>
 128.297 +                    <classpath>
 128.298 +                        <path path="${run.classpath}"/>
 128.299 +                    </classpath>
 128.300 +                    <syspropertyset>
 128.301 +                        <propertyref prefix="run-sys-prop."/>
 128.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 128.303 +                    </syspropertyset>
 128.304 +                    <customize/>
 128.305 +                </java>
 128.306 +            </sequential>
 128.307 +        </macrodef>
 128.308 +    </target>
 128.309 +    <target name="-init-presetdef-jar">
 128.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
 128.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
 128.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
 128.313 +            </jar>
 128.314 +        </presetdef>
 128.315 +    </target>
 128.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"/>
 128.317 +    <!--
 128.318 +                ===================
 128.319 +                COMPILATION SECTION
 128.320 +                ===================
 128.321 +            -->
 128.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
 128.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
 128.324 +    <target depends="init" name="-check-automatic-build">
 128.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
 128.326 +    </target>
 128.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
 128.328 +        <antcall target="clean"/>
 128.329 +    </target>
 128.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
 128.331 +        <mkdir dir="${build.classes.dir}"/>
 128.332 +    </target>
 128.333 +    <target name="-pre-compile">
 128.334 +        <!-- Empty placeholder for easier customization. -->
 128.335 +        <!-- You can override this target in the ../build.xml file. -->
 128.336 +    </target>
 128.337 +    <target if="do.depend.true" name="-compile-depend">
 128.338 +        <j2seproject3:depend/>
 128.339 +    </target>
 128.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
 128.341 +        <j2seproject3:javac/>
 128.342 +        <copy todir="${build.classes.dir}">
 128.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 128.344 +        </copy>
 128.345 +    </target>
 128.346 +    <target name="-post-compile">
 128.347 +        <!-- Empty placeholder for easier customization. -->
 128.348 +        <!-- You can override this target in the ../build.xml file. -->
 128.349 +    </target>
 128.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
 128.351 +    <target name="-pre-compile-single">
 128.352 +        <!-- Empty placeholder for easier customization. -->
 128.353 +        <!-- You can override this target in the ../build.xml file. -->
 128.354 +    </target>
 128.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
 128.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 128.357 +        <j2seproject3:force-recompile/>
 128.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
 128.359 +    </target>
 128.360 +    <target name="-post-compile-single">
 128.361 +        <!-- Empty placeholder for easier customization. -->
 128.362 +        <!-- You can override this target in the ../build.xml file. -->
 128.363 +    </target>
 128.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
 128.365 +    <!--
 128.366 +                ====================
 128.367 +                JAR BUILDING SECTION
 128.368 +                ====================
 128.369 +            -->
 128.370 +    <target depends="init" name="-pre-pre-jar">
 128.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
 128.372 +        <mkdir dir="${dist.jar.dir}"/>
 128.373 +    </target>
 128.374 +    <target name="-pre-jar">
 128.375 +        <!-- Empty placeholder for easier customization. -->
 128.376 +        <!-- You can override this target in the ../build.xml file. -->
 128.377 +    </target>
 128.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
 128.379 +        <j2seproject1:jar/>
 128.380 +    </target>
 128.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
 128.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
 128.383 +    </target>
 128.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">
 128.385 +        <j2seproject1:jar manifest="${manifest.file}">
 128.386 +            <j2seproject1:manifest>
 128.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
 128.388 +            </j2seproject1:manifest>
 128.389 +        </j2seproject1:jar>
 128.390 +        <echo>To run this application from the command line without Ant, try:</echo>
 128.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 128.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 128.393 +        <pathconvert property="run.classpath.with.dist.jar">
 128.394 +            <path path="${run.classpath}"/>
 128.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
 128.396 +        </pathconvert>
 128.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
 128.398 +    </target>
 128.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
 128.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 128.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
 128.402 +            <path path="${run.classpath}"/>
 128.403 +            <map from="${build.classes.dir.resolved}" to=""/>
 128.404 +        </pathconvert>
 128.405 +        <pathconvert pathsep=" " property="jar.classpath">
 128.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
 128.407 +            <chainedmapper>
 128.408 +                <flattenmapper/>
 128.409 +                <globmapper from="*" to="lib/*"/>
 128.410 +            </chainedmapper>
 128.411 +        </pathconvert>
 128.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
 128.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
 128.414 +            <fileset dir="${build.classes.dir}"/>
 128.415 +            <manifest>
 128.416 +                <attribute name="Main-Class" value="${main.class}"/>
 128.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
 128.418 +            </manifest>
 128.419 +        </copylibs>
 128.420 +        <echo>To run this application from the command line without Ant, try:</echo>
 128.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 128.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
 128.423 +    </target>
 128.424 +    <target name="-post-jar">
 128.425 +        <!-- Empty placeholder for easier customization. -->
 128.426 +        <!-- You can override this target in the ../build.xml file. -->
 128.427 +    </target>
 128.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"/>
 128.429 +    <!--
 128.430 +                =================
 128.431 +                EXECUTION SECTION
 128.432 +                =================
 128.433 +            -->
 128.434 +    <target depends="init,compile" description="Run a main class." name="run">
 128.435 +        <j2seproject1:java>
 128.436 +            <customize>
 128.437 +                <arg line="${application.args}"/>
 128.438 +            </customize>
 128.439 +        </j2seproject1:java>
 128.440 +    </target>
 128.441 +    <target name="-do-not-recompile">
 128.442 +        <property name="javac.includes.binary" value=""/>
 128.443 +    </target>
 128.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
 128.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
 128.446 +        <j2seproject1:java classname="${run.class}"/>
 128.447 +    </target>
 128.448 +    <!--
 128.449 +                =================
 128.450 +                DEBUGGING SECTION
 128.451 +                =================
 128.452 +            -->
 128.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
 128.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
 128.455 +    </target>
 128.456 +    <target depends="init,compile" name="-debug-start-debuggee">
 128.457 +        <j2seproject3:debug>
 128.458 +            <customize>
 128.459 +                <arg line="${application.args}"/>
 128.460 +            </customize>
 128.461 +        </j2seproject3:debug>
 128.462 +    </target>
 128.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
 128.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
 128.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
 128.466 +    </target>
 128.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
 128.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
 128.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
 128.470 +        <j2seproject3:debug classname="${debug.class}"/>
 128.471 +    </target>
 128.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
 128.473 +    <target depends="init" name="-pre-debug-fix">
 128.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
 128.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
 128.476 +    </target>
 128.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
 128.478 +        <j2seproject1:nbjpdareload/>
 128.479 +    </target>
 128.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
 128.481 +    <!--
 128.482 +                ===============
 128.483 +                JAVADOC SECTION
 128.484 +                ===============
 128.485 +            -->
 128.486 +    <target depends="init" name="-javadoc-build">
 128.487 +        <mkdir dir="${dist.javadoc.dir}"/>
 128.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}">
 128.489 +            <classpath>
 128.490 +                <path path="${javac.classpath}"/>
 128.491 +            </classpath>
 128.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
 128.493 +                <filename name="**/*.java"/>
 128.494 +            </fileset>
 128.495 +        </javadoc>
 128.496 +    </target>
 128.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
 128.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
 128.499 +    </target>
 128.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
 128.501 +    <!--
 128.502 +                =========================
 128.503 +                JUNIT COMPILATION SECTION
 128.504 +                =========================
 128.505 +            -->
 128.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
 128.507 +        <mkdir dir="${build.test.classes.dir}"/>
 128.508 +    </target>
 128.509 +    <target name="-pre-compile-test">
 128.510 +        <!-- Empty placeholder for easier customization. -->
 128.511 +        <!-- You can override this target in the ../build.xml file. -->
 128.512 +    </target>
 128.513 +    <target if="do.depend.true" name="-compile-test-depend">
 128.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 128.515 +    </target>
 128.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
 128.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 128.518 +        <copy todir="${build.test.classes.dir}">
 128.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 128.520 +        </copy>
 128.521 +    </target>
 128.522 +    <target name="-post-compile-test">
 128.523 +        <!-- Empty placeholder for easier customization. -->
 128.524 +        <!-- You can override this target in the ../build.xml file. -->
 128.525 +    </target>
 128.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
 128.527 +    <target name="-pre-compile-test-single">
 128.528 +        <!-- Empty placeholder for easier customization. -->
 128.529 +        <!-- You can override this target in the ../build.xml file. -->
 128.530 +    </target>
 128.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
 128.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 128.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
 128.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}"/>
 128.535 +        <copy todir="${build.test.classes.dir}">
 128.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 128.537 +        </copy>
 128.538 +    </target>
 128.539 +    <target name="-post-compile-test-single">
 128.540 +        <!-- Empty placeholder for easier customization. -->
 128.541 +        <!-- You can override this target in the ../build.xml file. -->
 128.542 +    </target>
 128.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"/>
 128.544 +    <!--
 128.545 +                =======================
 128.546 +                JUNIT EXECUTION SECTION
 128.547 +                =======================
 128.548 +            -->
 128.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
 128.550 +        <mkdir dir="${build.test.results.dir}"/>
 128.551 +    </target>
 128.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
 128.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
 128.554 +    </target>
 128.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
 128.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 128.557 +    </target>
 128.558 +    <target depends="init" if="have.tests" name="test-report"/>
 128.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
 128.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"/>
 128.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
 128.562 +        <mkdir dir="${build.test.results.dir}"/>
 128.563 +    </target>
 128.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
 128.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
 128.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
 128.567 +    </target>
 128.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
 128.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 128.570 +    </target>
 128.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"/>
 128.572 +    <!--
 128.573 +                =======================
 128.574 +                JUNIT DEBUGGING SECTION
 128.575 +                =======================
 128.576 +            -->
 128.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
 128.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
 128.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
 128.580 +        <delete file="${test.report.file}"/>
 128.581 +        <mkdir dir="${build.test.results.dir}"/>
 128.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}">
 128.583 +            <customize>
 128.584 +                <syspropertyset>
 128.585 +                    <propertyref prefix="test-sys-prop."/>
 128.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
 128.587 +                </syspropertyset>
 128.588 +                <arg value="${test.class}"/>
 128.589 +                <arg value="showoutput=true"/>
 128.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
 128.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
 128.592 +            </customize>
 128.593 +        </j2seproject3:debug>
 128.594 +    </target>
 128.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
 128.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
 128.597 +    </target>
 128.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
 128.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
 128.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
 128.601 +    </target>
 128.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
 128.603 +    <!--
 128.604 +                =========================
 128.605 +                APPLET EXECUTION SECTION
 128.606 +                =========================
 128.607 +            -->
 128.608 +    <target depends="init,compile-single" name="run-applet">
 128.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 128.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
 128.611 +            <customize>
 128.612 +                <arg value="${applet.url}"/>
 128.613 +            </customize>
 128.614 +        </j2seproject1:java>
 128.615 +    </target>
 128.616 +    <!--
 128.617 +                =========================
 128.618 +                APPLET DEBUGGING  SECTION
 128.619 +                =========================
 128.620 +            -->
 128.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
 128.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 128.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
 128.624 +            <customize>
 128.625 +                <arg value="${applet.url}"/>
 128.626 +            </customize>
 128.627 +        </j2seproject3:debug>
 128.628 +    </target>
 128.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
 128.630 +    <!--
 128.631 +                ===============
 128.632 +                CLEANUP SECTION
 128.633 +                ===============
 128.634 +            -->
 128.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
 128.636 +    <target depends="init" name="-do-clean">
 128.637 +        <delete dir="${build.dir}"/>
 128.638 +        <delete dir="${dist.dir}"/>
 128.639 +    </target>
 128.640 +    <target name="-post-clean">
 128.641 +        <!-- Empty placeholder for easier customization. -->
 128.642 +        <!-- You can override this target in the ../build.xml file. -->
 128.643 +    </target>
 128.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
 128.645 +</project>
   129.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.2 +++ b/task2/solution12/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
   129.3 @@ -0,0 +1,8 @@
   129.4 +build.xml.data.CRC32=2ab820eb
   129.5 +build.xml.script.CRC32=58a52595
   129.6 +build.xml.stylesheet.CRC32=be360661
   129.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
   129.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
   129.9 +nbproject/build-impl.xml.data.CRC32=b63e115b
  129.10 +nbproject/build-impl.xml.script.CRC32=3bdfc4fa
  129.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
   130.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.2 +++ b/task2/solution12/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
   130.3 @@ -0,0 +1,68 @@
   130.4 +application.title=currency
   130.5 +application.vendor=apidesign.org
   130.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
   130.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
   130.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
   130.9 +build.classes.dir=${build.dir}/classes
  130.10 +build.classes.excludes=**/*.java,**/*.form
  130.11 +# This directory is removed when the project is cleaned:
  130.12 +build.dir=build
  130.13 +build.generated.dir=${build.dir}/generated
  130.14 +# Only compile against the classpath explicitly listed here:
  130.15 +build.sysclasspath=ignore
  130.16 +build.test.classes.dir=${build.dir}/test/classes
  130.17 +build.test.results.dir=${build.dir}/test/results
  130.18 +debug.classpath=\
  130.19 +    ${run.classpath}
  130.20 +debug.test.classpath=\
  130.21 +    ${run.test.classpath}
  130.22 +# This directory is removed when the project is cleaned:
  130.23 +dist.dir=dist
  130.24 +dist.jar=${dist.dir}/currency.jar
  130.25 +dist.javadoc.dir=${dist.dir}/javadoc
  130.26 +excludes=
  130.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
  130.28 +file.reference.src-apifest08=..
  130.29 +includes=**
  130.30 +jar.compress=false
  130.31 +javac.classpath=
  130.32 +# Space-separated list of extra javac options
  130.33 +javac.compilerargs=
  130.34 +javac.deprecation=false
  130.35 +javac.source=1.5
  130.36 +javac.target=1.5
  130.37 +javac.test.classpath=\
  130.38 +    ${javac.classpath}:\
  130.39 +    ${build.classes.dir}:\
  130.40 +    ${file.reference.junit-4.4.jar}
  130.41 +javadoc.additionalparam=
  130.42 +javadoc.author=false
  130.43 +javadoc.encoding=
  130.44 +javadoc.noindex=false
  130.45 +javadoc.nonavbar=false
  130.46 +javadoc.notree=false
  130.47 +javadoc.private=false
  130.48 +javadoc.splitindex=true
  130.49 +javadoc.use=true
  130.50 +javadoc.version=false
  130.51 +javadoc.windowtitle=
  130.52 +jnlp.codebase.type=local
  130.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
  130.54 +jnlp.descriptor=application
  130.55 +jnlp.enabled=false
  130.56 +jnlp.offline-allowed=false
  130.57 +jnlp.signed=false
  130.58 +meta.inf.dir=${src.dir}/META-INF
  130.59 +platform.active=default_platform
  130.60 +run.classpath=\
  130.61 +    ${javac.classpath}:\
  130.62 +    ${build.classes.dir}
  130.63 +# Space-separated list of JVM arguments used when running the project
  130.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
  130.65 +# or test-sys-prop.name=value to set system properties for unit tests):
  130.66 +run.jvmargs=
  130.67 +run.test.classpath=\
  130.68 +    ${javac.test.classpath}:\
  130.69 +    ${build.test.classes.dir}
  130.70 +src.dir=src
  130.71 +test.src.dir=test
   131.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.2 +++ b/task2/solution12/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
   131.3 @@ -0,0 +1,16 @@
   131.4 +<?xml version="1.0" encoding="UTF-8"?>
   131.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
   131.6 +    <type>org.netbeans.modules.java.j2seproject</type>
   131.7 +    <configuration>
   131.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
   131.9 +            <name>Currency Convertor Solution 12</name>
  131.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
  131.11 +            <source-roots>
  131.12 +                <root id="src.dir"/>
  131.13 +            </source-roots>
  131.14 +            <test-roots>
  131.15 +                <root id="test.src.dir"/>
  131.16 +            </test-roots>
  131.17 +        </data>
  131.18 +    </configuration>
  131.19 +</project>
   132.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   132.2 +++ b/task2/solution12/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
   132.3 @@ -0,0 +1,149 @@
   132.4 +package org.apidesign.apifest08.currency;
   132.5 +
   132.6 +import java.util.Currency;
   132.7 +import java.util.Hashtable;
   132.8 +
   132.9 +import org.apidesign.apifest08.currency.exceptions.ConvertorException;
  132.10 +import org.apidesign.apifest08.currency.exceptions.InvalidCurrencyException;
  132.11 +import org.apidesign.apifest08.currency.exceptions.UnknownConvertorException;
  132.12 +
  132.13 +/**
  132.14 + * This is the skeleton class for your API. You need to make it public, so it is accessible to your client code
  132.15 + * (currently in Task1Test.java) file.
  132.16 + * <p>
  132.17 + * Feel free to create additional classes or rename this one, just keep all the API and its implementation in this
  132.18 + * package. Do not spread it outside to other packages.
  132.19 + */
  132.20 +public class Convertor {
  132.21 +
  132.22 +  private static Hashtable<String, ExchangeRate> exchangeRates;
  132.23 +
  132.24 +  private ExchangeRate exchangeRate12;
  132.25 +  private ExchangeRate exchangeRate21;
  132.26 +
  132.27 +  private Convertor(Currency currency1, Currency currency2) throws UnknownConvertorException {
  132.28 +    String key12 = currency1.getCurrencyCode() + currency2.getCurrencyCode();
  132.29 +    String key21 = currency2.getCurrencyCode() + currency1.getCurrencyCode();
  132.30 +
  132.31 +    if (!(exchangeRates.containsKey(key12) && exchangeRates.containsKey(key21))) {
  132.32 +      throw new UnknownConvertorException("Selected convertor (" + currency1.getCurrencyCode() + "->"
  132.33 +          + currency2.getCurrencyCode() + ") has not defined any rates!!!");
  132.34 +    }
  132.35 +
  132.36 +    this.exchangeRate12 = exchangeRates.get(key12);
  132.37 +    this.exchangeRate21 = exchangeRates.get(key21);
  132.38 +  }
  132.39 +
  132.40 +  /**
  132.41 +   * Sets convertor rate for selected currencies.
  132.42 +   * @param currency1
  132.43 +   *          one of the currencies we want to convert to/from
  132.44 +   * @param currency2
  132.45 +   *          the other currency
  132.46 +   * @param rate
  132.47 +   *          exchange rate from currency1 to currency2
  132.48 +   * @param unit
  132.49 +   *          unit of exchangeRate (USD->CZK - unit=1, you exchange one dollar, SKK->CZK unit=100, exchange rate is for
  132.50 +   *          100SKK)
  132.51 +   */
  132.52 +  public static void setConvertorRates(Currency currency1, Currency currency2, double rate, double unit) {
  132.53 +    if (currency1 == null || currency2 == null) {
  132.54 +      throw new ConvertorException("None of the currencies should be null!!!");
  132.55 +    }
  132.56 +
  132.57 +    if (rate <= 0 || unit <= 0) {
  132.58 +      throw new ConvertorException("Rate(" + rate + ") and unit(" + unit + ") has to be grater then zero!!!");
  132.59 +    }
  132.60 +
  132.61 +    if (exchangeRates == null) {
  132.62 +      exchangeRates = new Hashtable<String, ExchangeRate>();
  132.63 +    }
  132.64 +
  132.65 +    String key12 = currency1.getCurrencyCode() + currency2.getCurrencyCode();
  132.66 +    String key21 = currency2.getCurrencyCode() + currency1.getCurrencyCode();
  132.67 +    double recountedRate = (unit / rate) * unit;
  132.68 +
  132.69 +    exchangeRates.put(key12, new ExchangeRate(currency1, currency2, rate, unit));
  132.70 +    exchangeRates.put(key21, new ExchangeRate(currency2, currency1, recountedRate, unit));
  132.71 +
  132.72 +  }
  132.73 +
  132.74 +  /**
  132.75 +   * Creates new instance of convertor.
  132.76 +   * @param currency1
  132.77 +   *          one of the currencies we want to convert to/from
  132.78 +   * @param currency2
  132.79 +   *          the other currency
  132.80 +   * @return new instance of convertor
  132.81 +   * @throws UnknownConvertorException
  132.82 +   *           thrown if convertor for selected currencies has not been defined
  132.83 +   */
  132.84 +  public static Convertor getConvertorInstance(Currency currency1, Currency currency2) throws UnknownConvertorException {
  132.85 +    if (currency1 == null || currency2 == null) {
  132.86 +      throw new ConvertorException("None of the currencies should be null!!!");
  132.87 +    }
  132.88 +    return new Convertor(currency1, currency2);
  132.89 +  }
  132.90 +
  132.91 +  /**
  132.92 +   * Converts selected amout of selected currency to other currency of this convertor instance.
  132.93 +   * @param amount
  132.94 +   *          amount to convert
  132.95 +   * @param originalCurrency
  132.96 +   *          currency of this amount
  132.97 +   * @param newCurrency
  132.98 +   *          currency to which we want convert
  132.99 +   * @return converted amount
 132.100 +   * @throws InvalidCurrencyException
 132.101 +   *           while one or both currencies doesn't fit for this convertor
 132.102 +   */
 132.103 +  public double convert(double amount, Currency originalCurrency, Currency newCurrency) throws InvalidCurrencyException {
 132.104 +    ExchangeRate actualyUsedExchangeRate = null;
 132.105 +
 132.106 +    if (originalCurrency == null) {
 132.107 +      throw new ConvertorException("Original currency is null!!!");
 132.108 +    }
 132.109 +
 132.110 +    if (newCurrency == null) {
 132.111 +      throw new ConvertorException("Destination currency is null!!!");
 132.112 +    }
 132.113 +
 132.114 +    actualyUsedExchangeRate = getExchangeRate(originalCurrency, newCurrency);
 132.115 +
 132.116 +    return countResult(actualyUsedExchangeRate, amount);
 132.117 +  }
 132.118 +
 132.119 +  private double countResult(ExchangeRate actualyUsedExchangeRate, double amount) {
 132.120 +    return amount * actualyUsedExchangeRate.getRate() / actualyUsedExchangeRate.getUnit();
 132.121 +  }
 132.122 +
 132.123 +  /**
 132.124 +   * Decides the direction of conversion and returns instance of actual exchange rate.
 132.125 +   * @param actualCurrency
 132.126 +   *          actual currency we want to convert
 132.127 +   * @return actual exchange rate of this convertor for selected currency
 132.128 +   */
 132.129 +  private ExchangeRate getExchangeRate(Currency originalCurrency, Currency newCurrency) throws InvalidCurrencyException {
 132.130 +    ExchangeRate actualyUsedExchangeRate = null;
 132.131 +
 132.132 +    if (originalCurrency.getCurrencyCode().equals(exchangeRate12.getOriginalCurrency().getCurrencyCode())
 132.133 +        && newCurrency.getCurrencyCode().equals(exchangeRate12.getNewCurrency().getCurrencyCode())) {
 132.134 +      actualyUsedExchangeRate = exchangeRate12;
 132.135 +    } else if (originalCurrency.getCurrencyCode().equals(exchangeRate21.getOriginalCurrency().getCurrencyCode())
 132.136 +        && newCurrency.getCurrencyCode().equals(exchangeRate21.getNewCurrency().getCurrencyCode())) {
 132.137 +      actualyUsedExchangeRate = exchangeRate21;
 132.138 +    } else {
 132.139 +      throw new InvalidCurrencyException("This convertor " + this
 132.140 +          + " could not be used for converting selected currencies (" + originalCurrency.getCurrencyCode() + "->"
 132.141 +          + newCurrency.getCurrencyCode() + ") !!!");
 132.142 +    }
 132.143 +
 132.144 +    return actualyUsedExchangeRate;
 132.145 +  }
 132.146 +
 132.147 +  public String toString() {
 132.148 +    String currency1Code = exchangeRate12.getOriginalCurrency().getCurrencyCode();
 132.149 +    String currency2Code = exchangeRate12.getNewCurrency().getCurrencyCode();
 132.150 +    return "Converter [" + currency1Code + "->" + currency2Code + ", " + currency2Code + "->" + currency1Code + "]";
 132.151 +  }
 132.152 +}
   133.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   133.2 +++ b/task2/solution12/src/org/apidesign/apifest08/currency/ExchangeRate.java	Wed Oct 01 10:43:05 2008 +0200
   133.3 @@ -0,0 +1,35 @@
   133.4 +package org.apidesign.apifest08.currency;
   133.5 +
   133.6 +import java.util.Currency;
   133.7 +
   133.8 +public class ExchangeRate {
   133.9 +
  133.10 +  private Currency originalCurrency;
  133.11 +  private Currency newCurrency;
  133.12 +  private double unit;
  133.13 +  private double rate;
  133.14 +
  133.15 +  public ExchangeRate(Currency originalCurrency, Currency newCurrency, double rate, double unit) {
  133.16 +    this.newCurrency = newCurrency;
  133.17 +    this.originalCurrency = originalCurrency;
  133.18 +    this.rate = rate;
  133.19 +    this.unit = unit;
  133.20 +  }
  133.21 +
  133.22 +  public Currency getOriginalCurrency() {
  133.23 +    return originalCurrency;
  133.24 +  }
  133.25 +
  133.26 +  public Currency getNewCurrency() {
  133.27 +    return newCurrency;
  133.28 +  }
  133.29 +
  133.30 +  public double getUnit() {
  133.31 +    return unit;
  133.32 +  }
  133.33 +
  133.34 +  public double getRate() {
  133.35 +    return rate;
  133.36 +  }
  133.37 +
  133.38 +}
   134.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   134.2 +++ b/task2/solution12/src/org/apidesign/apifest08/currency/exceptions/ConvertorException.java	Wed Oct 01 10:43:05 2008 +0200
   134.3 @@ -0,0 +1,20 @@
   134.4 +package org.apidesign.apifest08.currency.exceptions;
   134.5 +
   134.6 +public class ConvertorException extends RuntimeException {
   134.7 +
   134.8 +  public ConvertorException() {
   134.9 +  }
  134.10 +
  134.11 +  public ConvertorException(String message) {
  134.12 +    super(message);
  134.13 +  }
  134.14 +
  134.15 +  public ConvertorException(Throwable cause) {
  134.16 +    super(cause);
  134.17 +  }
  134.18 +
  134.19 +  public ConvertorException(String message, Throwable cause) {
  134.20 +    super(message, cause);
  134.21 +  }
  134.22 +
  134.23 +}
   135.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   135.2 +++ b/task2/solution12/src/org/apidesign/apifest08/currency/exceptions/InvalidCurrencyException.java	Wed Oct 01 10:43:05 2008 +0200
   135.3 @@ -0,0 +1,20 @@
   135.4 +package org.apidesign.apifest08.currency.exceptions;
   135.5 +
   135.6 +public class InvalidCurrencyException extends Exception {
   135.7 +
   135.8 +  public InvalidCurrencyException() {
   135.9 +  }
  135.10 +
  135.11 +  public InvalidCurrencyException(String message) {
  135.12 +    super(message);
  135.13 +  }
  135.14 +
  135.15 +  public InvalidCurrencyException(Throwable cause) {
  135.16 +    super(cause);
  135.17 +  }
  135.18 +
  135.19 +  public InvalidCurrencyException(String message, Throwable cause) {
  135.20 +    super(message, cause);
  135.21 +  }
  135.22 +
  135.23 +}
   136.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   136.2 +++ b/task2/solution12/src/org/apidesign/apifest08/currency/exceptions/UnknownConvertorException.java	Wed Oct 01 10:43:05 2008 +0200
   136.3 @@ -0,0 +1,20 @@
   136.4 +package org.apidesign.apifest08.currency.exceptions;
   136.5 +
   136.6 +public class UnknownConvertorException extends Exception {
   136.7 +
   136.8 +  public UnknownConvertorException() {
   136.9 +  }
  136.10 +
  136.11 +  public UnknownConvertorException(String message) {
  136.12 +    super(message);
  136.13 +  }
  136.14 +
  136.15 +  public UnknownConvertorException(Throwable cause) {
  136.16 +    super(cause);
  136.17 +  }
  136.18 +
  136.19 +  public UnknownConvertorException(String message, Throwable cause) {
  136.20 +    super(message, cause);
  136.21 +  }
  136.22 +
  136.23 +}
   137.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   137.2 +++ b/task2/solution12/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   137.3 @@ -0,0 +1,174 @@
   137.4 +package org.apidesign.apifest08.test;
   137.5 +
   137.6 +import java.util.Currency;
   137.7 +
   137.8 +import junit.framework.TestCase;
   137.9 +
  137.10 +import org.apidesign.apifest08.currency.Convertor;
  137.11 +import org.apidesign.apifest08.currency.exceptions.InvalidCurrencyException;
  137.12 +import org.apidesign.apifest08.currency.exceptions.UnknownConvertorException;
  137.13 +
  137.14 +/**
  137.15 + * Finish the Convertor API, and then write bodies of methods inside of this class to match the given tasks. To fullfil
  137.16 + * your task, use the API define in the <code>org.apidesign.apifest08.currency</code> package. Do not you reflection, or
  137.17 + * other hacks as your code shall run without any runtime permissions.
  137.18 + */
  137.19 +public class Task1Test extends TestCase {
  137.20 +  public Task1Test(String testName) {
  137.21 +    super(testName);
  137.22 +  }
  137.23 +
  137.24 +  @Override
  137.25 +  protected void setUp() throws Exception {
  137.26 +  }
  137.27 +
  137.28 +  @Override
  137.29 +  protected void tearDown() throws Exception {
  137.30 +  }
  137.31 +
  137.32 +  //
  137.33 +  // Imagine that there are three parts of the whole system:
  137.34 +  // 1. there is someone who knows the current exchange rate
  137.35 +  // 2. there is someone who wants to do the conversion
  137.36 +  // 3. there is the API between 1. and 2. which allows them to communicate
  137.37 +  // Please design such API
  137.38 +  //
  137.39 +
  137.40 +  /**
  137.41 +   * Create convertor that understands two currencies, CZK and USD. Make 1 USD == 17 CZK. This is a method provided for
  137.42 +   * #1 group - e.g. those that know the exchange rate. They somehow need to create the objects from the API and tell
  137.43 +   * them the exchange rate. The API itself knows nothing about any rates, before the createCZKtoUSD method is called.
  137.44 +   * Creation of the convertor shall not require subclassing of any class or interface on the client side.
  137.45 +   * @return prepared convertor ready for converting USD to CZK and CZK to USD
  137.46 +   */
  137.47 +  public static Convertor createCZKtoUSD() {
  137.48 +    // set exchange rates
  137.49 +    Convertor.setConvertorRates(Currency.getInstance("USD"), Currency.getInstance("CZK"), 17d, 1d);
  137.50 +
  137.51 +    // create new instance
  137.52 +    Convertor convertor = null;
  137.53 +    try {
  137.54 +      convertor = Convertor.getConvertorInstance(Currency.getInstance("USD"), Currency.getInstance("CZK"));
  137.55 +    } catch (UnknownConvertorException e) {
  137.56 +      e.printStackTrace();
  137.57 +    }
  137.58 +
  137.59 +    return convertor;
  137.60 +  }
  137.61 +
  137.62 +  /**
  137.63 +   * Create convertor that understands two currencies, CZK and SKK. Make 100 SKK == 80 CZK. Again this is method for the
  137.64 +   * #1 group - it knows the exchange rate, and needs to use the API to create objects with the exchange rate. Anyone
  137.65 +   * shall be ready to call this method without any other method being called previously. The API itself shall know
  137.66 +   * nothing about any rates, before this method is called. Creation of the convertor shall not require subclassing of
  137.67 +   * any class or interface on the client side.
  137.68 +   * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  137.69 +   */
  137.70 +  public static Convertor createSKKtoCZK() {
  137.71 +    // set exchange rates
  137.72 +    Convertor.setConvertorRates(Currency.getInstance("SKK"), Currency.getInstance("CZK"), 80d, 100d);
  137.73 +
  137.74 +    // create new instance
  137.75 +    Convertor convertor = null;
  137.76 +    try {
  137.77 +      convertor = Convertor.getConvertorInstance(Currency.getInstance("SKK"), Currency.getInstance("CZK"));
  137.78 +    } catch (UnknownConvertorException e) {
  137.79 +      e.printStackTrace();
  137.80 +    }
  137.81 +
  137.82 +    return convertor;
  137.83 +  }
  137.84 +
  137.85 +  //
  137.86 +  // now the methods for group #2 follow:
  137.87 +  // this group knows nothing about exchange rates, but knows how to use
  137.88 +  // the API to do conversions. It somehow (by calling one of the factory
  137.89 +  // methods) gets objects from the API and uses them to do the conversions.
  137.90 +  //
  137.91 +
  137.92 +  /**
  137.93 +   * Use the convertor from <code>createCZKtoUSD</code> method and do few conversions with it.
  137.94 +   */
  137.95 +  public void testCurrencyCZKUSD() throws Exception {
  137.96 +    Convertor c = createCZKtoUSD();
  137.97 +    // convert $5 to CZK using c:
  137.98 +    double result = c.convert(5, Currency.getInstance("USD"), Currency.getInstance("CZK"));
  137.99 +    assertEquals("Result is not 85 CZK", 85.0, result);
 137.100 +
 137.101 +    // convert $8 to CZK
 137.102 +    result = c.convert(8, Currency.getInstance("USD"), Currency.getInstance("CZK"));
 137.103 +    assertEquals("Result is not 136 CZK", 136.0, result);
 137.104 +
 137.105 +    // convert 1003CZK to USD
 137.106 +    result = c.convert(1003, Currency.getInstance("CZK"), Currency.getInstance("USD"));
 137.107 +    assertEquals("Result is not 59 USD", 59.0, result);
 137.108 +  }
 137.109 +
 137.110 +  /**
 137.111 +   * Use the convertor from <code>createSKKtoCZK</code> method and do few conversions with it.
 137.112 +   */
 137.113 +  public void testCurrencySKKCZK() throws Exception {
 137.114 +    Convertor c = createSKKtoCZK();
 137.115 +
 137.116 +    // convert 16CZK using c:
 137.117 +    double result = c.convert(16, Currency.getInstance("CZK"), Currency.getInstance("SKK"));
 137.118 +    assertEquals("Result is not 20 SKK", 20.0, result);
 137.119 +
 137.120 +    // convert 500SKK to CZK
 137.121 +    result = c.convert(500, Currency.getInstance("SKK"), Currency.getInstance("CZK"));
 137.122 +    assertEquals("Result is not 400 CZK", 400.0, result);
 137.123 +  }
 137.124 +
 137.125 +  /**
 137.126 +   * Verify that the CZK to USD convertor knows nothing about SKK.
 137.127 +   */
 137.128 +  public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
 137.129 +    Convertor c = createCZKtoUSD();
 137.130 +    boolean exceptionThrown = false;
 137.131 +
 137.132 +    // convert $5 to SKK, the API shall say this is not possible
 137.133 +    try {
 137.134 +      c.convert(5, Currency.getInstance("USD"), Currency.getInstance("SKK"));
 137.135 +      exceptionThrown = false;
 137.136 +    } catch (InvalidCurrencyException e) {
 137.137 +      exceptionThrown = true;
 137.138 +    }
 137.139 +    assertEquals("It should be impossible to convert to SKK with USD->CZK convertor", true, exceptionThrown);
 137.140 +
 137.141 +    // convert 500 SKK to CZK, the API shall say this is not possible
 137.142 +    try {
 137.143 +      c.convert(500, Currency.getInstance("SKK"), Currency.getInstance("CZK"));
 137.144 +      exceptionThrown = false;
 137.145 +    } catch (InvalidCurrencyException e) {
 137.146 +      exceptionThrown = true;
 137.147 +    }
 137.148 +    assertEquals("It should be impossible to convert from SKK with USD->CZK convertor", true, exceptionThrown);
 137.149 +
 137.150 +  }
 137.151 +
 137.152 +  /**
 137.153 +   * Verify that the CZK to SKK convertor knows nothing about USD.
 137.154 +   */
 137.155 +  public void testCannotConvertToSKKwithSKKCZKConvertor() throws Exception {
 137.156 +    Convertor c = createSKKtoCZK();
 137.157 +    boolean exceptionThrown = false;
 137.158 +
 137.159 +    // convert $5 to SKK, the API shall say this is not possible
 137.160 +    try {
 137.161 +      c.convert(5, Currency.getInstance("USD"), Currency.getInstance("SKK"));
 137.162 +      exceptionThrown = false;
 137.163 +    } catch (InvalidCurrencyException e) {
 137.164 +      exceptionThrown = true;
 137.165 +    }
 137.166 +    assertEquals("It should be impossible to convert form USD with SKK->CZK convertor", true, exceptionThrown);
 137.167 +
 137.168 +    // convert 500 CZK to USD, the API shall say this is not possible
 137.169 +    try {
 137.170 +      c.convert(500, Currency.getInstance("CZK"), Currency.getInstance("USD"));
 137.171 +      exceptionThrown = false;
 137.172 +    } catch (InvalidCurrencyException e) {
 137.173 +      exceptionThrown = true;
 137.174 +    }
 137.175 +    assertEquals("It should be impossible to convert to USD with SKK->CZK convertor", true, exceptionThrown);
 137.176 +  }
 137.177 +}
   138.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   138.2 +++ b/task2/solution13/build.xml	Wed Oct 01 10:43:05 2008 +0200
   138.3 @@ -0,0 +1,69 @@
   138.4 +<?xml version="1.0" encoding="UTF-8"?>
   138.5 +<!-- You may freely edit this file. See commented blocks below for -->
   138.6 +<!-- some examples of how to customize the build. -->
   138.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
   138.8 +<project name="currency" default="default" basedir=".">
   138.9 +    <description>Builds, tests, and runs the project.</description>
  138.10 +    <import file="nbproject/build-impl.xml"/>
  138.11 +    <!--
  138.12 +
  138.13 +    There exist several targets which are by default empty and which can be 
  138.14 +    used for execution of your tasks. These targets are usually executed 
  138.15 +    before and after some main targets. They are: 
  138.16 +
  138.17 +      -pre-init:                 called before initialization of project properties
  138.18 +      -post-init:                called after initialization of project properties
  138.19 +      -pre-compile:              called before javac compilation
  138.20 +      -post-compile:             called after javac compilation
  138.21 +      -pre-compile-single:       called before javac compilation of single file
  138.22 +      -post-compile-single:      called after javac compilation of single file
  138.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
  138.24 +      -post-compile-test:        called after javac compilation of JUnit tests
  138.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
  138.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
  138.27 +      -pre-jar:                  called before JAR building
  138.28 +      -post-jar:                 called after JAR building
  138.29 +      -post-clean:               called after cleaning build products
  138.30 +
  138.31 +    (Targets beginning with '-' are not intended to be called on their own.)
  138.32 +
  138.33 +    Example of inserting an obfuscator after compilation could look like this:
  138.34 +
  138.35 +        <target name="-post-compile">
  138.36 +            <obfuscate>
  138.37 +                <fileset dir="${build.classes.dir}"/>
  138.38 +            </obfuscate>
  138.39 +        </target>
  138.40 +
  138.41 +    For list of available properties check the imported 
  138.42 +    nbproject/build-impl.xml file. 
  138.43 +
  138.44 +
  138.45 +    Another way to customize the build is by overriding existing main targets.
  138.46 +    The targets of interest are: 
  138.47 +
  138.48 +      -init-macrodef-javac:     defines macro for javac compilation
  138.49 +      -init-macrodef-junit:     defines macro for junit execution
  138.50 +      -init-macrodef-debug:     defines macro for class debugging
  138.51 +      -init-macrodef-java:      defines macro for class execution
  138.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  138.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  138.54 +      run:                      execution of project 
  138.55 +      -javadoc-build:           Javadoc generation
  138.56 +      test-report:              JUnit report generation
  138.57 +
  138.58 +    An example of overriding the target for project execution could look like this:
  138.59 +
  138.60 +        <target name="run" depends="currency-impl.jar">
  138.61 +            <exec dir="bin" executable="launcher.exe">
  138.62 +                <arg file="${dist.jar}"/>
  138.63 +            </exec>
  138.64 +        </target>
  138.65 +
  138.66 +    Notice that the overridden target depends on the jar target and not only on 
  138.67 +    the compile target as the regular run target does. Again, for a list of available 
  138.68 +    properties which you can use, check the target you are overriding in the
  138.69 +    nbproject/build-impl.xml file. 
  138.70 +
  138.71 +    -->
  138.72 +</project>
   139.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   139.2 +++ b/task2/solution13/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
   139.3 @@ -0,0 +1,642 @@
   139.4 +<?xml version="1.0" encoding="UTF-8"?>
   139.5 +<!--
   139.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
   139.7 +***         EDIT ../build.xml INSTEAD         ***
   139.8 +
   139.9 +For the purpose of easier reading the script
  139.10 +is divided into following sections:
  139.11 +
  139.12 +  - initialization
  139.13 +  - compilation
  139.14 +  - jar
  139.15 +  - execution
  139.16 +  - debugging
  139.17 +  - javadoc
  139.18 +  - junit compilation
  139.19 +  - junit execution
  139.20 +  - junit debugging
  139.21 +  - applet
  139.22 +  - cleanup
  139.23 +
  139.24 +        -->
  139.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_13-impl">
  139.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
  139.27 +    <!-- 
  139.28 +                ======================
  139.29 +                INITIALIZATION SECTION 
  139.30 +                ======================
  139.31 +            -->
  139.32 +    <target name="-pre-init">
  139.33 +        <!-- Empty placeholder for easier customization. -->
  139.34 +        <!-- You can override this target in the ../build.xml file. -->
  139.35 +    </target>
  139.36 +    <target depends="-pre-init" name="-init-private">
  139.37 +        <property file="nbproject/private/config.properties"/>
  139.38 +        <property file="nbproject/private/configs/${config}.properties"/>
  139.39 +        <property file="nbproject/private/private.properties"/>
  139.40 +    </target>
  139.41 +    <target depends="-pre-init,-init-private" name="-init-user">
  139.42 +        <property file="${user.properties.file}"/>
  139.43 +        <!-- The two properties below are usually overridden -->
  139.44 +        <!-- by the active platform. Just a fallback. -->
  139.45 +        <property name="default.javac.source" value="1.4"/>
  139.46 +        <property name="default.javac.target" value="1.4"/>
  139.47 +    </target>
  139.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
  139.49 +        <property file="nbproject/configs/${config}.properties"/>
  139.50 +        <property file="nbproject/project.properties"/>
  139.51 +    </target>
  139.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
  139.53 +        <available file="${manifest.file}" property="manifest.available"/>
  139.54 +        <condition property="manifest.available+main.class">
  139.55 +            <and>
  139.56 +                <isset property="manifest.available"/>
  139.57 +                <isset property="main.class"/>
  139.58 +                <not>
  139.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
  139.60 +                </not>
  139.61 +            </and>
  139.62 +        </condition>
  139.63 +        <condition property="manifest.available+main.class+mkdist.available">
  139.64 +            <and>
  139.65 +                <istrue value="${manifest.available+main.class}"/>
  139.66 +                <isset property="libs.CopyLibs.classpath"/>
  139.67 +            </and>
  139.68 +        </condition>
  139.69 +        <condition property="have.tests">
  139.70 +            <or>
  139.71 +                <available file="${test.src.dir}"/>
  139.72 +            </or>
  139.73 +        </condition>
  139.74 +        <condition property="have.sources">
  139.75 +            <or>
  139.76 +                <available file="${src.dir}"/>
  139.77 +            </or>
  139.78 +        </condition>
  139.79 +        <condition property="netbeans.home+have.tests">
  139.80 +            <and>
  139.81 +                <isset property="netbeans.home"/>
  139.82 +                <isset property="have.tests"/>
  139.83 +            </and>
  139.84 +        </condition>
  139.85 +        <condition property="no.javadoc.preview">
  139.86 +            <and>
  139.87 +                <isset property="javadoc.preview"/>
  139.88 +                <isfalse value="${javadoc.preview}"/>
  139.89 +            </and>
  139.90 +        </condition>
  139.91 +        <property name="run.jvmargs" value=""/>
  139.92 +        <property name="javac.compilerargs" value=""/>
  139.93 +        <property name="work.dir" value="${basedir}"/>
  139.94 +        <condition property="no.deps">
  139.95 +            <and>
  139.96 +                <istrue value="${no.dependencies}"/>
  139.97 +            </and>
  139.98 +        </condition>
  139.99 +        <property name="javac.debug" value="true"/>
 139.100 +        <property name="javadoc.preview" value="true"/>
 139.101 +        <property name="application.args" value=""/>
 139.102 +        <property name="source.encoding" value="${file.encoding}"/>
 139.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
 139.104 +            <and>
 139.105 +                <isset property="javadoc.encoding"/>
 139.106 +                <not>
 139.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
 139.108 +                </not>
 139.109 +            </and>
 139.110 +        </condition>
 139.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
 139.112 +        <property name="includes" value="**"/>
 139.113 +        <property name="excludes" value=""/>
 139.114 +        <property name="do.depend" value="false"/>
 139.115 +        <condition property="do.depend.true">
 139.116 +            <istrue value="${do.depend}"/>
 139.117 +        </condition>
 139.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
 139.119 +            <and>
 139.120 +                <isset property="jaxws.endorsed.dir"/>
 139.121 +                <available file="nbproject/jaxws-build.xml"/>
 139.122 +            </and>
 139.123 +        </condition>
 139.124 +    </target>
 139.125 +    <target name="-post-init">
 139.126 +        <!-- Empty placeholder for easier customization. -->
 139.127 +        <!-- You can override this target in the ../build.xml file. -->
 139.128 +    </target>
 139.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
 139.130 +        <fail unless="src.dir">Must set src.dir</fail>
 139.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
 139.132 +        <fail unless="build.dir">Must set build.dir</fail>
 139.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
 139.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
 139.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
 139.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
 139.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
 139.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
 139.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
 139.140 +    </target>
 139.141 +    <target name="-init-macrodef-property">
 139.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
 139.143 +            <attribute name="name"/>
 139.144 +            <attribute name="value"/>
 139.145 +            <sequential>
 139.146 +                <property name="@{name}" value="${@{value}}"/>
 139.147 +            </sequential>
 139.148 +        </macrodef>
 139.149 +    </target>
 139.150 +    <target name="-init-macrodef-javac">
 139.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
 139.152 +            <attribute default="${src.dir}" name="srcdir"/>
 139.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
 139.154 +            <attribute default="${javac.classpath}" name="classpath"/>
 139.155 +            <attribute default="${includes}" name="includes"/>
 139.156 +            <attribute default="${excludes}" name="excludes"/>
 139.157 +            <attribute default="${javac.debug}" name="debug"/>
 139.158 +            <attribute default="" name="sourcepath"/>
 139.159 +            <element name="customize" optional="true"/>
 139.160 +            <sequential>
 139.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}">
 139.162 +                    <classpath>
 139.163 +                        <path path="@{classpath}"/>
 139.164 +                    </classpath>
 139.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
 139.166 +                    <customize/>
 139.167 +                </javac>
 139.168 +            </sequential>
 139.169 +        </macrodef>
 139.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
 139.171 +            <attribute default="${src.dir}" name="srcdir"/>
 139.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
 139.173 +            <attribute default="${javac.classpath}" name="classpath"/>
 139.174 +            <sequential>
 139.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
 139.176 +                    <classpath>
 139.177 +                        <path path="@{classpath}"/>
 139.178 +                    </classpath>
 139.179 +                </depend>
 139.180 +            </sequential>
 139.181 +        </macrodef>
 139.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
 139.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
 139.184 +            <sequential>
 139.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
 139.186 +                <pathconvert pathsep="," property="javac.includes.binary">
 139.187 +                    <path>
 139.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
 139.189 +                    </path>
 139.190 +                    <globmapper from="*.java" to="*.class"/>
 139.191 +                </pathconvert>
 139.192 +                <delete>
 139.193 +                    <files includes="${javac.includes.binary}"/>
 139.194 +                </delete>
 139.195 +            </sequential>
 139.196 +        </macrodef>
 139.197 +    </target>
 139.198 +    <target name="-init-macrodef-junit">
 139.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
 139.200 +            <attribute default="${includes}" name="includes"/>
 139.201 +            <attribute default="${excludes}" name="excludes"/>
 139.202 +            <attribute default="**" name="testincludes"/>
 139.203 +            <sequential>
 139.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
 139.205 +                    <batchtest todir="${build.test.results.dir}">
 139.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
 139.207 +                            <filename name="@{testincludes}"/>
 139.208 +                        </fileset>
 139.209 +                    </batchtest>
 139.210 +                    <classpath>
 139.211 +                        <path path="${run.test.classpath}"/>
 139.212 +                    </classpath>
 139.213 +                    <syspropertyset>
 139.214 +                        <propertyref prefix="test-sys-prop."/>
 139.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
 139.216 +                    </syspropertyset>
 139.217 +                    <formatter type="brief" usefile="false"/>
 139.218 +                    <formatter type="xml"/>
 139.219 +                    <jvmarg line="${run.jvmargs}"/>
 139.220 +                </junit>
 139.221 +            </sequential>
 139.222 +        </macrodef>
 139.223 +    </target>
 139.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
 139.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
 139.226 +            <attribute default="${main.class}" name="name"/>
 139.227 +            <attribute default="${debug.classpath}" name="classpath"/>
 139.228 +            <attribute default="" name="stopclassname"/>
 139.229 +            <sequential>
 139.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
 139.231 +                    <classpath>
 139.232 +                        <path path="@{classpath}"/>
 139.233 +                    </classpath>
 139.234 +                </nbjpdastart>
 139.235 +            </sequential>
 139.236 +        </macrodef>
 139.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
 139.238 +            <attribute default="${build.classes.dir}" name="dir"/>
 139.239 +            <sequential>
 139.240 +                <nbjpdareload>
 139.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
 139.242 +                        <include name="${fix.includes}*.class"/>
 139.243 +                    </fileset>
 139.244 +                </nbjpdareload>
 139.245 +            </sequential>
 139.246 +        </macrodef>
 139.247 +    </target>
 139.248 +    <target name="-init-debug-args">
 139.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
 139.250 +        <condition property="have-jdk-older-than-1.4">
 139.251 +            <or>
 139.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
 139.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
 139.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
 139.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
 139.256 +            </or>
 139.257 +        </condition>
 139.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
 139.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
 139.260 +        </condition>
 139.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
 139.262 +            <os family="windows"/>
 139.263 +        </condition>
 139.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
 139.265 +            <isset property="debug.transport"/>
 139.266 +        </condition>
 139.267 +    </target>
 139.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
 139.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
 139.270 +            <attribute default="${main.class}" name="classname"/>
 139.271 +            <attribute default="${debug.classpath}" name="classpath"/>
 139.272 +            <element name="customize" optional="true"/>
 139.273 +            <sequential>
 139.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 139.275 +                    <jvmarg line="${debug-args-line}"/>
 139.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
 139.277 +                    <jvmarg line="${run.jvmargs}"/>
 139.278 +                    <classpath>
 139.279 +                        <path path="@{classpath}"/>
 139.280 +                    </classpath>
 139.281 +                    <syspropertyset>
 139.282 +                        <propertyref prefix="run-sys-prop."/>
 139.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 139.284 +                    </syspropertyset>
 139.285 +                    <customize/>
 139.286 +                </java>
 139.287 +            </sequential>
 139.288 +        </macrodef>
 139.289 +    </target>
 139.290 +    <target name="-init-macrodef-java">
 139.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
 139.292 +            <attribute default="${main.class}" name="classname"/>
 139.293 +            <element name="customize" optional="true"/>
 139.294 +            <sequential>
 139.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 139.296 +                    <jvmarg line="${run.jvmargs}"/>
 139.297 +                    <classpath>
 139.298 +                        <path path="${run.classpath}"/>
 139.299 +                    </classpath>
 139.300 +                    <syspropertyset>
 139.301 +                        <propertyref prefix="run-sys-prop."/>
 139.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 139.303 +                    </syspropertyset>
 139.304 +                    <customize/>
 139.305 +                </java>
 139.306 +            </sequential>
 139.307 +        </macrodef>
 139.308 +    </target>
 139.309 +    <target name="-init-presetdef-jar">
 139.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
 139.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
 139.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
 139.313 +            </jar>
 139.314 +        </presetdef>
 139.315 +    </target>
 139.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"/>
 139.317 +    <!--
 139.318 +                ===================
 139.319 +                COMPILATION SECTION
 139.320 +                ===================
 139.321 +            -->
 139.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
 139.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
 139.324 +    <target depends="init" name="-check-automatic-build">
 139.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
 139.326 +    </target>
 139.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
 139.328 +        <antcall target="clean"/>
 139.329 +    </target>
 139.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
 139.331 +        <mkdir dir="${build.classes.dir}"/>
 139.332 +    </target>
 139.333 +    <target name="-pre-compile">
 139.334 +        <!-- Empty placeholder for easier customization. -->
 139.335 +        <!-- You can override this target in the ../build.xml file. -->
 139.336 +    </target>
 139.337 +    <target if="do.depend.true" name="-compile-depend">
 139.338 +        <j2seproject3:depend/>
 139.339 +    </target>
 139.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
 139.341 +        <j2seproject3:javac/>
 139.342 +        <copy todir="${build.classes.dir}">
 139.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 139.344 +        </copy>
 139.345 +    </target>
 139.346 +    <target name="-post-compile">
 139.347 +        <!-- Empty placeholder for easier customization. -->
 139.348 +        <!-- You can override this target in the ../build.xml file. -->
 139.349 +    </target>
 139.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
 139.351 +    <target name="-pre-compile-single">
 139.352 +        <!-- Empty placeholder for easier customization. -->
 139.353 +        <!-- You can override this target in the ../build.xml file. -->
 139.354 +    </target>
 139.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
 139.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 139.357 +        <j2seproject3:force-recompile/>
 139.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
 139.359 +    </target>
 139.360 +    <target name="-post-compile-single">
 139.361 +        <!-- Empty placeholder for easier customization. -->
 139.362 +        <!-- You can override this target in the ../build.xml file. -->
 139.363 +    </target>
 139.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
 139.365 +    <!--
 139.366 +                ====================
 139.367 +                JAR BUILDING SECTION
 139.368 +                ====================
 139.369 +            -->
 139.370 +    <target depends="init" name="-pre-pre-jar">
 139.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
 139.372 +        <mkdir dir="${dist.jar.dir}"/>
 139.373 +    </target>
 139.374 +    <target name="-pre-jar">
 139.375 +        <!-- Empty placeholder for easier customization. -->
 139.376 +        <!-- You can override this target in the ../build.xml file. -->
 139.377 +    </target>
 139.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
 139.379 +        <j2seproject1:jar/>
 139.380 +    </target>
 139.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
 139.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
 139.383 +    </target>
 139.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">
 139.385 +        <j2seproject1:jar manifest="${manifest.file}">
 139.386 +            <j2seproject1:manifest>
 139.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
 139.388 +            </j2seproject1:manifest>
 139.389 +        </j2seproject1:jar>
 139.390 +        <echo>To run this application from the command line without Ant, try:</echo>
 139.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 139.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 139.393 +        <pathconvert property="run.classpath.with.dist.jar">
 139.394 +            <path path="${run.classpath}"/>
 139.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
 139.396 +        </pathconvert>
 139.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
 139.398 +    </target>
 139.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
 139.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 139.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
 139.402 +            <path path="${run.classpath}"/>
 139.403 +            <map from="${build.classes.dir.resolved}" to=""/>
 139.404 +        </pathconvert>
 139.405 +        <pathconvert pathsep=" " property="jar.classpath">
 139.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
 139.407 +            <chainedmapper>
 139.408 +                <flattenmapper/>
 139.409 +                <globmapper from="*" to="lib/*"/>
 139.410 +            </chainedmapper>
 139.411 +        </pathconvert>
 139.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
 139.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
 139.414 +            <fileset dir="${build.classes.dir}"/>
 139.415 +            <manifest>
 139.416 +                <attribute name="Main-Class" value="${main.class}"/>
 139.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
 139.418 +            </manifest>
 139.419 +        </copylibs>
 139.420 +        <echo>To run this application from the command line without Ant, try:</echo>
 139.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 139.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
 139.423 +    </target>
 139.424 +    <target name="-post-jar">
 139.425 +        <!-- Empty placeholder for easier customization. -->
 139.426 +        <!-- You can override this target in the ../build.xml file. -->
 139.427 +    </target>
 139.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"/>
 139.429 +    <!--
 139.430 +                =================
 139.431 +                EXECUTION SECTION
 139.432 +                =================
 139.433 +            -->
 139.434 +    <target depends="init,compile" description="Run a main class." name="run">
 139.435 +        <j2seproject1:java>
 139.436 +            <customize>
 139.437 +                <arg line="${application.args}"/>
 139.438 +            </customize>
 139.439 +        </j2seproject1:java>
 139.440 +    </target>
 139.441 +    <target name="-do-not-recompile">
 139.442 +        <property name="javac.includes.binary" value=""/>
 139.443 +    </target>
 139.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
 139.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
 139.446 +        <j2seproject1:java classname="${run.class}"/>
 139.447 +    </target>
 139.448 +    <!--
 139.449 +                =================
 139.450 +                DEBUGGING SECTION
 139.451 +                =================
 139.452 +            -->
 139.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
 139.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
 139.455 +    </target>
 139.456 +    <target depends="init,compile" name="-debug-start-debuggee">
 139.457 +        <j2seproject3:debug>
 139.458 +            <customize>
 139.459 +                <arg line="${application.args}"/>
 139.460 +            </customize>
 139.461 +        </j2seproject3:debug>
 139.462 +    </target>
 139.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
 139.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
 139.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
 139.466 +    </target>
 139.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
 139.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
 139.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
 139.470 +        <j2seproject3:debug classname="${debug.class}"/>
 139.471 +    </target>
 139.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
 139.473 +    <target depends="init" name="-pre-debug-fix">
 139.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
 139.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
 139.476 +    </target>
 139.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
 139.478 +        <j2seproject1:nbjpdareload/>
 139.479 +    </target>
 139.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
 139.481 +    <!--
 139.482 +                ===============
 139.483 +                JAVADOC SECTION
 139.484 +                ===============
 139.485 +            -->
 139.486 +    <target depends="init" name="-javadoc-build">
 139.487 +        <mkdir dir="${dist.javadoc.dir}"/>
 139.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}">
 139.489 +            <classpath>
 139.490 +                <path path="${javac.classpath}"/>
 139.491 +            </classpath>
 139.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
 139.493 +                <filename name="**/*.java"/>
 139.494 +            </fileset>
 139.495 +        </javadoc>
 139.496 +    </target>
 139.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
 139.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
 139.499 +    </target>
 139.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
 139.501 +    <!--
 139.502 +                =========================
 139.503 +                JUNIT COMPILATION SECTION
 139.504 +                =========================
 139.505 +            -->
 139.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
 139.507 +        <mkdir dir="${build.test.classes.dir}"/>
 139.508 +    </target>
 139.509 +    <target name="-pre-compile-test">
 139.510 +        <!-- Empty placeholder for easier customization. -->
 139.511 +        <!-- You can override this target in the ../build.xml file. -->
 139.512 +    </target>
 139.513 +    <target if="do.depend.true" name="-compile-test-depend">
 139.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 139.515 +    </target>
 139.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
 139.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 139.518 +        <copy todir="${build.test.classes.dir}">
 139.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 139.520 +        </copy>
 139.521 +    </target>
 139.522 +    <target name="-post-compile-test">
 139.523 +        <!-- Empty placeholder for easier customization. -->
 139.524 +        <!-- You can override this target in the ../build.xml file. -->
 139.525 +    </target>
 139.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
 139.527 +    <target name="-pre-compile-test-single">
 139.528 +        <!-- Empty placeholder for easier customization. -->
 139.529 +        <!-- You can override this target in the ../build.xml file. -->
 139.530 +    </target>
 139.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
 139.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 139.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
 139.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}"/>
 139.535 +        <copy todir="${build.test.classes.dir}">
 139.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 139.537 +        </copy>
 139.538 +    </target>
 139.539 +    <target name="-post-compile-test-single">
 139.540 +        <!-- Empty placeholder for easier customization. -->
 139.541 +        <!-- You can override this target in the ../build.xml file. -->
 139.542 +    </target>
 139.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"/>
 139.544 +    <!--
 139.545 +                =======================
 139.546 +                JUNIT EXECUTION SECTION
 139.547 +                =======================
 139.548 +            -->
 139.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
 139.550 +        <mkdir dir="${build.test.results.dir}"/>
 139.551 +    </target>
 139.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
 139.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
 139.554 +    </target>
 139.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
 139.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 139.557 +    </target>
 139.558 +    <target depends="init" if="have.tests" name="test-report"/>
 139.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
 139.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"/>
 139.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
 139.562 +        <mkdir dir="${build.test.results.dir}"/>
 139.563 +    </target>
 139.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
 139.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
 139.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
 139.567 +    </target>
 139.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
 139.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 139.570 +    </target>
 139.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"/>
 139.572 +    <!--
 139.573 +                =======================
 139.574 +                JUNIT DEBUGGING SECTION
 139.575 +                =======================
 139.576 +            -->
 139.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
 139.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
 139.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
 139.580 +        <delete file="${test.report.file}"/>
 139.581 +        <mkdir dir="${build.test.results.dir}"/>
 139.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}">
 139.583 +            <customize>
 139.584 +                <syspropertyset>
 139.585 +                    <propertyref prefix="test-sys-prop."/>
 139.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
 139.587 +                </syspropertyset>
 139.588 +                <arg value="${test.class}"/>
 139.589 +                <arg value="showoutput=true"/>
 139.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
 139.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
 139.592 +            </customize>
 139.593 +        </j2seproject3:debug>
 139.594 +    </target>
 139.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
 139.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
 139.597 +    </target>
 139.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
 139.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
 139.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
 139.601 +    </target>
 139.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
 139.603 +    <!--
 139.604 +                =========================
 139.605 +                APPLET EXECUTION SECTION
 139.606 +                =========================
 139.607 +            -->
 139.608 +    <target depends="init,compile-single" name="run-applet">
 139.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 139.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
 139.611 +            <customize>
 139.612 +                <arg value="${applet.url}"/>
 139.613 +            </customize>
 139.614 +        </j2seproject1:java>
 139.615 +    </target>
 139.616 +    <!--
 139.617 +                =========================
 139.618 +                APPLET DEBUGGING  SECTION
 139.619 +                =========================
 139.620 +            -->
 139.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
 139.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 139.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
 139.624 +            <customize>
 139.625 +                <arg value="${applet.url}"/>
 139.626 +            </customize>
 139.627 +        </j2seproject3:debug>
 139.628 +    </target>
 139.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
 139.630 +    <!--
 139.631 +                ===============
 139.632 +                CLEANUP SECTION
 139.633 +                ===============
 139.634 +            -->
 139.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
 139.636 +    <target depends="init" name="-do-clean">
 139.637 +        <delete dir="${build.dir}"/>
 139.638 +        <delete dir="${dist.dir}"/>
 139.639 +    </target>
 139.640 +    <target name="-post-clean">
 139.641 +        <!-- Empty placeholder for easier customization. -->
 139.642 +        <!-- You can override this target in the ../build.xml file. -->
 139.643 +    </target>
 139.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
 139.645 +</project>
   140.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   140.2 +++ b/task2/solution13/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
   140.3 @@ -0,0 +1,8 @@
   140.4 +build.xml.data.CRC32=2ab820eb
   140.5 +build.xml.script.CRC32=58a52595
   140.6 +build.xml.stylesheet.CRC32=be360661
   140.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
   140.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
   140.9 +nbproject/build-impl.xml.data.CRC32=de21ce77
  140.10 +nbproject/build-impl.xml.script.CRC32=0903858a
  140.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
   141.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   141.2 +++ b/task2/solution13/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
   141.3 @@ -0,0 +1,68 @@
   141.4 +application.title=currency
   141.5 +application.vendor=apidesign.org
   141.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
   141.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
   141.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
   141.9 +build.classes.dir=${build.dir}/classes
  141.10 +build.classes.excludes=**/*.java,**/*.form
  141.11 +# This directory is removed when the project is cleaned:
  141.12 +build.dir=build
  141.13 +build.generated.dir=${build.dir}/generated
  141.14 +# Only compile against the classpath explicitly listed here:
  141.15 +build.sysclasspath=ignore
  141.16 +build.test.classes.dir=${build.dir}/test/classes
  141.17 +build.test.results.dir=${build.dir}/test/results
  141.18 +debug.classpath=\
  141.19 +    ${run.classpath}
  141.20 +debug.test.classpath=\
  141.21 +    ${run.test.classpath}
  141.22 +# This directory is removed when the project is cleaned:
  141.23 +dist.dir=dist
  141.24 +dist.jar=${dist.dir}/currency.jar
  141.25 +dist.javadoc.dir=${dist.dir}/javadoc
  141.26 +excludes=
  141.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
  141.28 +file.reference.src-apifest08=..
  141.29 +includes=**
  141.30 +jar.compress=false
  141.31 +javac.classpath=
  141.32 +# Space-separated list of extra javac options
  141.33 +javac.compilerargs=
  141.34 +javac.deprecation=false
  141.35 +javac.source=1.5
  141.36 +javac.target=1.5
  141.37 +javac.test.classpath=\
  141.38 +    ${javac.classpath}:\
  141.39 +    ${build.classes.dir}:\
  141.40 +    ${file.reference.junit-4.4.jar}
  141.41 +javadoc.additionalparam=
  141.42 +javadoc.author=false
  141.43 +javadoc.encoding=
  141.44 +javadoc.noindex=false
  141.45 +javadoc.nonavbar=false
  141.46 +javadoc.notree=false
  141.47 +javadoc.private=false
  141.48 +javadoc.splitindex=true
  141.49 +javadoc.use=true
  141.50 +javadoc.version=false
  141.51 +javadoc.windowtitle=
  141.52 +jnlp.codebase.type=local
  141.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
  141.54 +jnlp.descriptor=application
  141.55 +jnlp.enabled=false
  141.56 +jnlp.offline-allowed=false
  141.57 +jnlp.signed=false
  141.58 +meta.inf.dir=${src.dir}/META-INF
  141.59 +platform.active=default_platform
  141.60 +run.classpath=\
  141.61 +    ${javac.classpath}:\
  141.62 +    ${build.classes.dir}
  141.63 +# Space-separated list of JVM arguments used when running the project
  141.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
  141.65 +# or test-sys-prop.name=value to set system properties for unit tests):
  141.66 +run.jvmargs=
  141.67 +run.test.classpath=\
  141.68 +    ${javac.test.classpath}:\
  141.69 +    ${build.test.classes.dir}
  141.70 +src.dir=src
  141.71 +test.src.dir=test
   142.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   142.2 +++ b/task2/solution13/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
   142.3 @@ -0,0 +1,16 @@
   142.4 +<?xml version="1.0" encoding="UTF-8"?>
   142.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
   142.6 +    <type>org.netbeans.modules.java.j2seproject</type>
   142.7 +    <configuration>
   142.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
   142.9 +            <name>Currency Convertor Solution 13</name>
  142.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
  142.11 +            <source-roots>
  142.12 +                <root id="src.dir"/>
  142.13 +            </source-roots>
  142.14 +            <test-roots>
  142.15 +                <root id="test.src.dir"/>
  142.16 +            </test-roots>
  142.17 +        </data>
  142.18 +    </configuration>
  142.19 +</project>
   143.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/ConversionResult.java	Wed Oct 01 10:43:05 2008 +0200
   143.3 @@ -0,0 +1,49 @@
   143.4 +
   143.5 +package org.apidesign.apifest08.currency;
   143.6 +
   143.7 +import java.math.BigDecimal;
   143.8 +
   143.9 +/**
  143.10 + * Result of currency conversion. Holds converted value and remainder.
  143.11 + * <p>
  143.12 + * <em>Converter</em> describes value converted to <em>target</em> value. <em>Remainder</em> describes
  143.13 + * how much from original <em>amount</em> was not possible to convert. Converted never loses any (small) money
  143.14 + * in conversion error (rounding), but instead of rounding is converts only as much as possible and keeps rest as remainder.
  143.15 + * 
  143.16 + * @author arnostvalicek
  143.17 + */
  143.18 +public class ConversionResult {
  143.19 +    private BigDecimal converted;
  143.20 +    private BigDecimal remainder;
  143.21 +    
  143.22 +    /**
  143.23 +     * Get converted value.
  143.24 +     * @return Returns converted value.
  143.25 +     */
  143.26 +    public BigDecimal getConverted() {
  143.27 +        return converted;
  143.28 +    }
  143.29 +
  143.30 +    void setConverted(BigDecimal converted) {
  143.31 +        this.converted = converted;
  143.32 +    }
  143.33 +
  143.34 +    
  143.35 +    /**
  143.36 +     * Get remainder of conversion. Remainder is set if part of converted amount which can't be converted 
  143.37 +     * because this target currency precision can't handle small numbers. Remainder value is in <em>from currency</em>
  143.38 +     * <p>
  143.39 +     * Converter never loses any precision in conversion. Remainer describes how much of amount can't be converted. 
  143.40 +     * If we substract <em>remainder</em> from <em>amount</em> we will be able to get exact conversion.
  143.41 +     * 
  143.42 +     * @return Returns remainder of conversion.
  143.43 +     */
  143.44 +    public BigDecimal getRemainder() {
  143.45 +        return remainder;
  143.46 +    }
  143.47 +
  143.48 +    void setRemainder(BigDecimal remainder) {
  143.49 +        this.remainder = remainder;
  143.50 +    }
  143.51 +
  143.52 +}
   144.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
   144.3 @@ -0,0 +1,105 @@
   144.4 +package org.apidesign.apifest08.currency;
   144.5 +
   144.6 +import java.math.BigDecimal;
   144.7 +import java.math.MathContext;
   144.8 +import java.math.RoundingMode;
   144.9 +
  144.10 +/** Convertor able to convert amount from one currency to other currency.
  144.11 + * 
  144.12 + * Exchange rate is provided by {@link ExchangeRateProvider}.
  144.13 + */
  144.14 +public class Convertor {
  144.15 +    boolean remainderAllowed = false; //if false, remained is not allowed (should be true ideally, but can't handle it now)
  144.16 +    ExchangeRateProvider exchangeRateProvider; 
  144.17 +    
  144.18 +    private Convertor() {
  144.19 +        
  144.20 +    }
  144.21 +    
  144.22 +    /**
  144.23 +     * Static method used to create convertor.
  144.24 +     * 
  144.25 +     * @param exchangeRateProvider {@link ExchangeRateProvider} used to get exchange rate.
  144.26 +     * 
  144.27 +     * @return Returns <code>Convertor</code> which can be used to convert money.
  144.28 +     */
  144.29 +    public static Convertor createConvertor(ExchangeRateProvider exchangeRateProvider) {
  144.30 +        Convertor c = new Convertor();
  144.31 +
  144.32 +        c.exchangeRateProvider = exchangeRateProvider;
  144.33 +        return c;
  144.34 +    }
  144.35 +    
  144.36 +    /**
  144.37 +     * Convert <code>amount</code> from <code>fromCurrency</code> to <code>toCurrency</code> as specified
  144.38 +     * in <code>ExchangeRateProvider</code>.
  144.39 +     * 
  144.40 +     * @param amount Amount which should be converted. Can't be negative value (can be zero or positive).
  144.41 +     * @return Return <code>ConversionResult</code> which holds conversion result.
  144.42 +     */
  144.43 +    public ConversionResult convert(BigDecimal amount) {
  144.44 +        return convertValue(amount, false);
  144.45 +    }
  144.46 +    
  144.47 +    /**
  144.48 +     * Convert <code>amount</code> from <code>toCurrency</code> to <code>fromCurrency</code> as specified
  144.49 +     * in <code>ExchangeRateProvider</code>. This is <em>reverted</em> order than suggested by  names of currency fields in <code>ExchangeRate</code>.
  144.50 +     * 
  144.51 +     * @param amount Amount which should be converted. Can't be negative value (can be zero or positive).
  144.52 +     * @return Return <code>ConversionResult</code> which holds conversion result.
  144.53 +     */
  144.54 +    public ConversionResult convertBack(BigDecimal amount) {
  144.55 +        return convertValue(amount, true);
  144.56 +    }
  144.57 +
  144.58 +    private ConversionResult convertValue(BigDecimal amount, boolean convertBack) throws RuntimeException {
  144.59 +        ConversionResult result = new ConversionResult();
  144.60 +        
  144.61 +        ExchangeRate rate = exchangeRateProvider.getExchangeRate();
  144.62 +        int fromFranctionDigits = exchangeRateProvider.getFromCurrency().getDefaultFractionDigits();
  144.63 +        int toFractionDigits = exchangeRateProvider.getToCurrency().getDefaultFractionDigits();
  144.64 +         
  144.65 +        if (toFractionDigits!=2) {
  144.66 +            throw new RuntimeException("Can't process currency with defaultFractionDigits!=2, "+exchangeRateProvider.getToCurrency()+" has "+toFractionDigits+" defaultFractionDigits");
  144.67 +        }
  144.68 +        if (fromFranctionDigits!=2) {
  144.69 +            throw new RuntimeException("Can't process currency with defaultFractionDigits!=2, "+exchangeRateProvider.getFromCurrency()+" has "+fromFranctionDigits+" defaultFractionDigits");
  144.70 +        }
  144.71 +        
  144.72 +        if (amount.signum()==-1) {
  144.73 +            throw new RuntimeException("Can convert only non-negative value, current value is "+amount);
  144.74 +        }
  144.75 +        
  144.76 +        
  144.77 +        MathContext context = new MathContext(0, RoundingMode.DOWN);
  144.78 +        
  144.79 +        BigDecimal from;
  144.80 +        BigDecimal to;
  144.81 +        if (convertBack) {
  144.82 +            //converting in reverted way
  144.83 +            to = rate.getFromValue();
  144.84 +            from = rate.getToValue();
  144.85 +        } else {
  144.86 +            //converting in mornak way
  144.87 +            from = rate.getFromValue();
  144.88 +            to = rate.getToValue();
  144.89 +        }
  144.90 +
  144.91 +        BigDecimal amountCent = amount.movePointRight(2);
  144.92 +        
  144.93 +        final BigDecimal multiplied = amountCent.multiply(to,context);
  144.94 +        BigDecimal[] division = multiplied.divideAndRemainder(from,context);
  144.95 +
  144.96 +        if (!remainderAllowed && !(BigDecimal.ZERO.equals(division[1]))) {
  144.97 +            throw new RuntimeException("Remained is not allowed - remaining amount is " + division[1]+ " cents");
  144.98 +        } else {
  144.99 +            result.setRemainder(BigDecimal.ZERO);
 144.100 +        }
 144.101 +        
 144.102 +        final BigDecimal converted = division[0].movePointLeft(2);        
 144.103 +        result.setConverted(converted);
 144.104 +        //result.setRemainder(...);
 144.105 +
 144.106 +        return result;
 144.107 +    }
 144.108 +}
   145.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/ConvertorCurrency.java	Wed Oct 01 10:43:05 2008 +0200
   145.3 @@ -0,0 +1,46 @@
   145.4 +
   145.5 +package org.apidesign.apifest08.currency;
   145.6 +
   145.7 +import java.util.Currency;
   145.8 +
   145.9 +/**
  145.10 + * Desription of currency. 
  145.11 + * 
  145.12 + * Java has similar class {@link java.util.Currency}, but original class is not flexible
  145.13 + * enough, we use our own implementation of currency.
  145.14 + *
  145.15 + * @author arnostvalicek
  145.16 + */
  145.17 +public class ConvertorCurrency {
  145.18 +
  145.19 +    private Currency currency;
  145.20 +
  145.21 +    private void setJavaCurrency(Currency javaCurrency) {
  145.22 +        this.currency = javaCurrency;
  145.23 +    }
  145.24 +
  145.25 +    /**
  145.26 +     * Static method providing instance of <code>ConvertorCurrency</code> base of currency code.
  145.27 +     * 
  145.28 +     * @param currencyCode Code of required currency.
  145.29 +     * @return Returns required <code>ConvertorCurrency</code>
  145.30 +     */
  145.31 +    public static ConvertorCurrency getInstance(String currencyCode) {
  145.32 +        ConvertorCurrency convertorCurrency = new ConvertorCurrency();
  145.33 +        convertorCurrency.setJavaCurrency(Currency.getInstance(currencyCode));
  145.34 +        return convertorCurrency;
  145.35 +    }
  145.36 +
  145.37 +    /**
  145.38 +     * Gets the default number of fraction digits used with this currency. For example, the default number of fraction digits for the Euro is 2, while for the Japanese Yen it's 0.
  145.39 +     * @return Returns the default number of fraction digits used with this currency.
  145.40 +     */
  145.41 +    public int getDefaultFractionDigits() {
  145.42 +        return currency.getDefaultFractionDigits();
  145.43 +    }
  145.44 +
  145.45 +    @Override
  145.46 +    public String toString() {
  145.47 +        return getClass() + " based on " + (currency != null ? currency.toString() : "NO-BASE-CURRENCY");
  145.48 +    }
  145.49 +}
   146.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java	Wed Oct 01 10:43:05 2008 +0200
   146.3 @@ -0,0 +1,41 @@
   146.4 +
   146.5 +package org.apidesign.apifest08.currency;
   146.6 +
   146.7 +import java.math.BigDecimal;
   146.8 +
   146.9 +/**
  146.10 + * Exchange rate value. Contains <code>from</code> and <code>to</code> value.
  146.11 + * 
  146.12 + * @author arnostvalicek
  146.13 + */
  146.14 +public class ExchangeRate {
  146.15 +    private BigDecimal numberFor;
  146.16 +    private BigDecimal numberGet;
  146.17 +
  146.18 +    public  ExchangeRate(BigDecimal fromValue, BigDecimal toValue) {
  146.19 +        this.numberFor = fromValue;
  146.20 +        this.numberGet = toValue;
  146.21 +    }
  146.22 +
  146.23 +    @Override
  146.24 +    public String toString() {
  146.25 +        return "for "+numberFor+" recieve "+numberGet+" @"+getClass().getName();
  146.26 +    }
  146.27 +    
  146.28 +    public BigDecimal getFromValue() {
  146.29 +        return numberFor;
  146.30 +    }
  146.31 +    
  146.32 +    public BigDecimal getToValue() {
  146.33 +        return numberGet;
  146.34 +    }
  146.35 +    
  146.36 +    
  146.37 +//    public ExchangeRate createExchangeRate(BigDecimal forValue, BigDecimal getValue) {
  146.38 +//        ExchangeRate rate = new ExchangeRate(forValue, getValue);
  146.39 +//        return rate;
  146.40 +//    }
  146.41 +    
  146.42 +    
  146.43 +    
  146.44 +}
   147.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   147.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRateProvider.java	Wed Oct 01 10:43:05 2008 +0200
   147.3 @@ -0,0 +1,62 @@
   147.4 +
   147.5 +package org.apidesign.apifest08.currency;
   147.6 +
   147.7 +import java.math.BigDecimal;
   147.8 +import java.util.Date;
   147.9 +
  147.10 +/**
  147.11 + * Exchange rate provider - can provide fixed exchange rate which does not depend
  147.12 + * on date (method {@link #getExchangeRate()} ) or exchange rate based on date (method {@link #getExchangeRate(java.util.Date) }).
  147.13 + * 
  147.14 + * 
  147.15 + * @author arnostvalicek
  147.16 + */
  147.17 +public class ExchangeRateProvider {
  147.18 +    BigDecimal fromValue, toValue;
  147.19 +    ConvertorCurrency fromCurrency, toCurrency;
  147.20 +
  147.21 +    /**
  147.22 +     * Simple constructor for <code>ExchangeRateProviderM</code> which can provide fixed exchange rate.
  147.23 +     * 
  147.24 +     * Describes conversion <em>from</em> to <em>to</em> currency.
  147.25 +     * 
  147.26 +     * @param fromValue From value. BigDecimal value, precision should be set to currency precision.
  147.27 +     * @param fromCurrency From currency.
  147.28 +     * @param toValue To value. BigDecimal value, precision should be set to currency precision.
  147.29 +     * @param toCurrency To currency.
  147.30 +     */
  147.31 +    public ExchangeRateProvider(BigDecimal fromValue, ConvertorCurrency fromCurrency, BigDecimal toValue, ConvertorCurrency toCurrency) {
  147.32 +        this.fromValue = fromValue;
  147.33 +        this.toValue = toValue;
  147.34 +        this.fromCurrency = fromCurrency;
  147.35 +        this.toCurrency = toCurrency;
  147.36 +    }
  147.37 +    
  147.38 +    /**
  147.39 +     * Get fixed exange rate for currencies (from->to).
  147.40 +     * @return Returns exchange rate.
  147.41 +     */
  147.42 +    public ExchangeRate getExchangeRate() {
  147.43 +        return new ExchangeRate(fromValue, toValue);
  147.44 +    }
  147.45 +    
  147.46 +    /**
  147.47 +     * Get exchange rate for currencies (from->to) based on provided date.
  147.48 +     * @param date Date for which exchange rate should be provided.
  147.49 +     * @return Returns exchange rate 
  147.50 +     */
  147.51 +    public ExchangeRate getExchangeRate(Date date) {
  147.52 +        return new ExchangeRate(fromValue, toValue);
  147.53 +    }
  147.54 +    
  147.55 +
  147.56 +    ConvertorCurrency getFromCurrency() {
  147.57 +        return fromCurrency;
  147.58 +    }
  147.59 +    
  147.60 +    ConvertorCurrency getToCurrency() {
  147.61 +        return toCurrency;
  147.62 +    }
  147.63 +    
  147.64 +
  147.65 +}
   148.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.2 +++ b/task2/solution13/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   148.3 @@ -0,0 +1,209 @@
   148.4 +package org.apidesign.apifest08.test;
   148.5 +
   148.6 +import java.math.BigDecimal;
   148.7 +import junit.framework.TestCase;
   148.8 +import org.apidesign.apifest08.currency.ConversionResult;
   148.9 +import org.apidesign.apifest08.currency.Convertor;
  148.10 +import org.apidesign.apifest08.currency.ConvertorCurrency;
  148.11 +import org.apidesign.apifest08.currency.ExchangeRateProvider;
  148.12 +
  148.13 +/** Finish the Convertor API, and then write bodies of methods inside
  148.14 + * of this class to match the given tasks. To fullfil your task, use the
  148.15 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
  148.16 + * Do not you reflection, or other hacks as your code
  148.17 + * shall run without any runtime permissions.
  148.18 + */
  148.19 +public class Task1Test extends TestCase {
  148.20 +    public Task1Test(String testName) {
  148.21 +        super(testName);
  148.22 +    }
  148.23 +
  148.24 +    @Override
  148.25 +    protected void setUp() throws Exception {
  148.26 +    }
  148.27 +
  148.28 +    @Override
  148.29 +    protected void tearDown() throws Exception {
  148.30 +    }
  148.31 +
  148.32 +    /** Create convertor that understands two currencies, CZK and
  148.33 +     *  USD. Make 1 USD == 17 CZK.
  148.34 +     *
  148.35 +     * Creation of the convertor shall not require subclassing of any class
  148.36 +     * or interface on the client side.
  148.37 +     *
  148.38 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
  148.39 +     */
  148.40 +    public Convertor createCZKtoUSD() {
  148.41 +        ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("CZK");
  148.42 +        ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("USD");
  148.43 +        ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(17), fromCurrency, new BigDecimal(1), toCurrency);
  148.44 +        
  148.45 +        return Convertor.createConvertor(exchangeRateProvider);
  148.46 +    }
  148.47 +
  148.48 +    /** Create convertor that understands two currencies, CZK and
  148.49 +     *  SKK. Make 100 SKK == 80 CZK.
  148.50 +     *
  148.51 +     * Creation of the convertor shall not require subclassing of any class
  148.52 +     * or interface on the client side.
  148.53 +     * 
  148.54 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  148.55 +     */
  148.56 +    public Convertor createSKKtoCZK() {
  148.57 +        ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("SKK");
  148.58 +        ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("CZK");
  148.59 +        ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(100), fromCurrency, new BigDecimal(80), toCurrency);
  148.60 +        
  148.61 +        return Convertor.createConvertor(exchangeRateProvider);
  148.62 +    }
  148.63 +    
  148.64 +    
  148.65 +    public Convertor createCZKtoYEN() {
  148.66 +        ConvertorCurrency fromCurrency = ConvertorCurrency.getInstance("CZK");
  148.67 +        ConvertorCurrency toCurrency = ConvertorCurrency.getInstance("JPY");
  148.68 +        ExchangeRateProvider exchangeRateProvider = new ExchangeRateProvider(new BigDecimal(1), fromCurrency, new BigDecimal(1), toCurrency);
  148.69 +        
  148.70 +        return Convertor.createConvertor(exchangeRateProvider);
  148.71 +    }
  148.72 +    
  148.73 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
  148.74 +     * with it.
  148.75 +     */
  148.76 +    public void testCurrencyCZKUSD() throws Exception {
  148.77 +        Convertor convertCzkUsd = createCZKtoUSD();
  148.78 +
  148.79 +        {
  148.80 +            // convert $1 to CZK using c:
  148.81 +            ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(1));
  148.82 +            assertEquals("Result is 17 CZK", new BigDecimal("17.00"), result.getConverted());
  148.83 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
  148.84 +        }
  148.85 +
  148.86 +        {
  148.87 +            // convert 17CKZ to $ using c:
  148.88 +            ConversionResult result = convertCzkUsd.convert(new BigDecimal(17));
  148.89 +            assertEquals("Result is 1 $", new BigDecimal("1.00"), result.getConverted());
  148.90 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
  148.91 +        }
  148.92 +
  148.93 +        {
  148.94 +            // convert $5 to CZK using c:
  148.95 +            ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(5));
  148.96 +            assertEquals("Result is 85 CZK", new BigDecimal("85.00"), result.getConverted());
  148.97 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
  148.98 +        }
  148.99 +        
 148.100 +        {
 148.101 +            // convert $8 to CZK
 148.102 +            ConversionResult result = convertCzkUsd.convertBack(new BigDecimal(8));
 148.103 +            assertEquals("Result is 136 CZK", new BigDecimal("136.00"), result.getConverted());
 148.104 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
 148.105 +        }
 148.106 +
 148.107 +        {
 148.108 +            // convert 1003CZK to USD
 148.109 +            ConversionResult result = convertCzkUsd.convert(new BigDecimal(1003));
 148.110 +            assertEquals("Result is 59 USD", new BigDecimal("59.00"), result.getConverted());
 148.111 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
 148.112 +        }
 148.113 +    }
 148.114 +
 148.115 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
 148.116 +     * with it.
 148.117 +     */
 148.118 +    public void testCurrencySKKCZK() throws Exception {
 148.119 +        Convertor convertSkkCzk = createSKKtoCZK();
 148.120 +        {
 148.121 +            // convert 100SKK using c:
 148.122 +            ConversionResult result = convertSkkCzk.convert(new BigDecimal(100));
 148.123 +            assertEquals("Result is 80 CZK", new BigDecimal("80.00"), result.getConverted());
 148.124 +        }
 148.125 +        {
 148.126 +            // convert 80CZK using c:
 148.127 +            ConversionResult result = convertSkkCzk.convertBack(new BigDecimal(80));
 148.128 +            assertEquals("Result is 100 SKK", new BigDecimal("100.00"), result.getConverted());
 148.129 +        }
 148.130 +        
 148.131 +        {
 148.132 +            // convert 16CZK using c:
 148.133 +            ConversionResult result = convertSkkCzk.convertBack(new BigDecimal(16));
 148.134 +            assertEquals("Result is 20 SKK", new BigDecimal("20.00"), result.getConverted());
 148.135 +        }
 148.136 +
 148.137 +        {
 148.138 +            // convert 500SKK to CZK
 148.139 +            ConversionResult result = convertSkkCzk.convert(new BigDecimal(500));
 148.140 +            assertEquals("Result is 400 CZK", new BigDecimal("400.00"), result.getConverted());
 148.141 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());            
 148.142 +        }
 148.143 +        
 148.144 +        {
 148.145 +            // convert 501SKK to CZK
 148.146 +            ConversionResult result = convertSkkCzk.convert(new BigDecimal(501));
 148.147 +            assertEquals("Result is 400 CZK", new BigDecimal("400.80"), result.getConverted());
 148.148 +            assertEquals("No Remainer", BigDecimal.ZERO, result.getRemainder());
 148.149 +            
 148.150 +        }
 148.151 +    }
 148.152 +    
 148.153 +    /**
 148.154 +     * Convert SKK to CZK. Convertor can't convert whole amout (can't convert one SKK cent to CZK). Remaining
 148.155 +     * amount is stored in remainder result.
 148.156 +     * 
 148.157 +     * Test is currently failing, because implementation can't handle this case.
 148.158 +     */
 148.159 +//    public void testConvertSmallUnits_failing() {
 148.160 +//        Convertor convertSkkCzk = createSKKtoCZK();
 148.161 +//        {
 148.162 +//            // convert 501SKK to CZK
 148.163 +//            ConversionResult result = convertSkkCzk.convert(new BigDecimal("501.01"));
 148.164 +//            assertEquals("Result is 400 CZK", new BigDecimal("400.80"), result.getConverted());
 148.165 +//            assertEquals("No Remainer", new BigDecimal("0.01"), result.getRemainder());
 148.166 +//            
 148.167 +//        }
 148.168 +//        
 148.169 +//    }
 148.170 +    
 148.171 +    /**
 148.172 +     * Test converting from CZK to JPY. Remained has scale of CZK.
 148.173 +     * 
 148.174 +     * This test is currently failing, because converter implementation currently can't handle conversion from "cent" to "no-cent" currency.
 148.175 +     */
 148.176 +//    public void testConvertCzkToJpy_failing() {
 148.177 +//        Convertor convertSkkCzk = createCZKtoYEN();
 148.178 +//        {
 148.179 +//            // convert 501SKK to CZK
 148.180 +//            ConversionResult result = convertSkkCzk.convert(new BigDecimal("120.00"));
 148.181 +//            assertEquals("Result is 120 YEN", new BigDecimal("120"), result.getConverted());
 148.182 +//            assertEquals("No Remainer", new BigDecimal("0.00"), result.getRemainder());
 148.183 +//            
 148.184 +//        }
 148.185 +//    }
 148.186 +    
 148.187 +    /**
 148.188 +     * Test converting from JPY to CZK. Remained has scale of JPY.
 148.189 +     * 
 148.190 +     * This test is currently failing, because converter implementation currently can't handle conversion from "cent" to "no-cent" currency.
 148.191 +     */
 148.192 +//    public void testConvertJpyToCzk_failing() {
 148.193 +//        Convertor convertSkkCzk = createCZKtoYEN();
 148.194 +//        {
 148.195 +//            // convert 501SKK to CZK
 148.196 +//            ConversionResult result = convertSkkCzk.convert(new BigDecimal("120.00"));
 148.197 +//            assertEquals("Result is 120 YEN", new BigDecimal("120"), result.getConverted());
 148.198 +//            assertEquals("No Remainer", new BigDecimal("0"), result.getRemainder());
 148.199 +//            
 148.200 +//        }
 148.201 +//    }
 148.202 +    
 148.203 +    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
 148.204 +            Convertor c = createCZKtoUSD();
 148.205 +            // convert $5 to SKK, the API shall say this is not possible
 148.206 +            // convert 500 SKK to CZK, the API shall say this is not possible
 148.207 +            // ... no api for required call, should be here?
 148.208 +    }
 148.209 +    
 148.210 + 
 148.211 +}
 148.212 +
   149.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   149.2 +++ b/task2/solution14/build.xml	Wed Oct 01 10:43:05 2008 +0200
   149.3 @@ -0,0 +1,69 @@
   149.4 +<?xml version="1.0" encoding="UTF-8"?>
   149.5 +<!-- You may freely edit this file. See commented blocks below for -->
   149.6 +<!-- some examples of how to customize the build. -->
   149.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
   149.8 +<project name="currency" default="default" basedir=".">
   149.9 +    <description>Builds, tests, and runs the project.</description>
  149.10 +    <import file="nbproject/build-impl.xml"/>
  149.11 +    <!--
  149.12 +
  149.13 +    There exist several targets which are by default empty and which can be 
  149.14 +    used for execution of your tasks. These targets are usually executed 
  149.15 +    before and after some main targets. They are: 
  149.16 +
  149.17 +      -pre-init:                 called before initialization of project properties
  149.18 +      -post-init:                called after initialization of project properties
  149.19 +      -pre-compile:              called before javac compilation
  149.20 +      -post-compile:             called after javac compilation
  149.21 +      -pre-compile-single:       called before javac compilation of single file
  149.22 +      -post-compile-single:      called after javac compilation of single file
  149.23 +      -pre-compile-test:         called before javac compilation of JUnit tests
  149.24 +      -post-compile-test:        called after javac compilation of JUnit tests
  149.25 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
  149.26 +      -post-compile-test-single: called after javac compilation of single JUunit test
  149.27 +      -pre-jar:                  called before JAR building
  149.28 +      -post-jar:                 called after JAR building
  149.29 +      -post-clean:               called after cleaning build products
  149.30 +
  149.31 +    (Targets beginning with '-' are not intended to be called on their own.)
  149.32 +
  149.33 +    Example of inserting an obfuscator after compilation could look like this:
  149.34 +
  149.35 +        <target name="-post-compile">
  149.36 +            <obfuscate>
  149.37 +                <fileset dir="${build.classes.dir}"/>
  149.38 +            </obfuscate>
  149.39 +        </target>
  149.40 +
  149.41 +    For list of available properties check the imported 
  149.42 +    nbproject/build-impl.xml file. 
  149.43 +
  149.44 +
  149.45 +    Another way to customize the build is by overriding existing main targets.
  149.46 +    The targets of interest are: 
  149.47 +
  149.48 +      -init-macrodef-javac:     defines macro for javac compilation
  149.49 +      -init-macrodef-junit:     defines macro for junit execution
  149.50 +      -init-macrodef-debug:     defines macro for class debugging
  149.51 +      -init-macrodef-java:      defines macro for class execution
  149.52 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
  149.53 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
  149.54 +      run:                      execution of project 
  149.55 +      -javadoc-build:           Javadoc generation
  149.56 +      test-report:              JUnit report generation
  149.57 +
  149.58 +    An example of overriding the target for project execution could look like this:
  149.59 +
  149.60 +        <target name="run" depends="currency-impl.jar">
  149.61 +            <exec dir="bin" executable="launcher.exe">
  149.62 +                <arg file="${dist.jar}"/>
  149.63 +            </exec>
  149.64 +        </target>
  149.65 +
  149.66 +    Notice that the overridden target depends on the jar target and not only on 
  149.67 +    the compile target as the regular run target does. Again, for a list of available 
  149.68 +    properties which you can use, check the target you are overriding in the
  149.69 +    nbproject/build-impl.xml file. 
  149.70 +
  149.71 +    -->
  149.72 +</project>
   150.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.2 +++ b/task2/solution14/nbproject/build-impl.xml	Wed Oct 01 10:43:05 2008 +0200
   150.3 @@ -0,0 +1,642 @@
   150.4 +<?xml version="1.0" encoding="UTF-8"?>
   150.5 +<!--
   150.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
   150.7 +***         EDIT ../build.xml INSTEAD         ***
   150.8 +
   150.9 +For the purpose of easier reading the script
  150.10 +is divided into following sections:
  150.11 +
  150.12 +  - initialization
  150.13 +  - compilation
  150.14 +  - jar
  150.15 +  - execution
  150.16 +  - debugging
  150.17 +  - javadoc
  150.18 +  - junit compilation
  150.19 +  - junit execution
  150.20 +  - junit debugging
  150.21 +  - applet
  150.22 +  - cleanup
  150.23 +
  150.24 +        -->
  150.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_14-impl">
  150.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
  150.27 +    <!-- 
  150.28 +                ======================
  150.29 +                INITIALIZATION SECTION 
  150.30 +                ======================
  150.31 +            -->
  150.32 +    <target name="-pre-init">
  150.33 +        <!-- Empty placeholder for easier customization. -->
  150.34 +        <!-- You can override this target in the ../build.xml file. -->
  150.35 +    </target>
  150.36 +    <target depends="-pre-init" name="-init-private">
  150.37 +        <property file="nbproject/private/config.properties"/>
  150.38 +        <property file="nbproject/private/configs/${config}.properties"/>
  150.39 +        <property file="nbproject/private/private.properties"/>
  150.40 +    </target>
  150.41 +    <target depends="-pre-init,-init-private" name="-init-user">
  150.42 +        <property file="${user.properties.file}"/>
  150.43 +        <!-- The two properties below are usually overridden -->
  150.44 +        <!-- by the active platform. Just a fallback. -->
  150.45 +        <property name="default.javac.source" value="1.4"/>
  150.46 +        <property name="default.javac.target" value="1.4"/>
  150.47 +    </target>
  150.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
  150.49 +        <property file="nbproject/configs/${config}.properties"/>
  150.50 +        <property file="nbproject/project.properties"/>
  150.51 +    </target>
  150.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
  150.53 +        <available file="${manifest.file}" property="manifest.available"/>
  150.54 +        <condition property="manifest.available+main.class">
  150.55 +            <and>
  150.56 +                <isset property="manifest.available"/>
  150.57 +                <isset property="main.class"/>
  150.58 +                <not>
  150.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
  150.60 +                </not>
  150.61 +            </and>
  150.62 +        </condition>
  150.63 +        <condition property="manifest.available+main.class+mkdist.available">
  150.64 +            <and>
  150.65 +                <istrue value="${manifest.available+main.class}"/>
  150.66 +                <isset property="libs.CopyLibs.classpath"/>
  150.67 +            </and>
  150.68 +        </condition>
  150.69 +        <condition property="have.tests">
  150.70 +            <or>
  150.71 +                <available file="${test.src.dir}"/>
  150.72 +            </or>
  150.73 +        </condition>
  150.74 +        <condition property="have.sources">
  150.75 +            <or>
  150.76 +                <available file="${src.dir}"/>
  150.77 +            </or>
  150.78 +        </condition>
  150.79 +        <condition property="netbeans.home+have.tests">
  150.80 +            <and>
  150.81 +                <isset property="netbeans.home"/>
  150.82 +                <isset property="have.tests"/>
  150.83 +            </and>
  150.84 +        </condition>
  150.85 +        <condition property="no.javadoc.preview">
  150.86 +            <and>
  150.87 +                <isset property="javadoc.preview"/>
  150.88 +                <isfalse value="${javadoc.preview}"/>
  150.89 +            </and>
  150.90 +        </condition>
  150.91 +        <property name="run.jvmargs" value=""/>
  150.92 +        <property name="javac.compilerargs" value=""/>
  150.93 +        <property name="work.dir" value="${basedir}"/>
  150.94 +        <condition property="no.deps">
  150.95 +            <and>
  150.96 +                <istrue value="${no.dependencies}"/>
  150.97 +            </and>
  150.98 +        </condition>
  150.99 +        <property name="javac.debug" value="true"/>
 150.100 +        <property name="javadoc.preview" value="true"/>
 150.101 +        <property name="application.args" value=""/>
 150.102 +        <property name="source.encoding" value="${file.encoding}"/>
 150.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
 150.104 +            <and>
 150.105 +                <isset property="javadoc.encoding"/>
 150.106 +                <not>
 150.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
 150.108 +                </not>
 150.109 +            </and>
 150.110 +        </condition>
 150.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
 150.112 +        <property name="includes" value="**"/>
 150.113 +        <property name="excludes" value=""/>
 150.114 +        <property name="do.depend" value="false"/>
 150.115 +        <condition property="do.depend.true">
 150.116 +            <istrue value="${do.depend}"/>
 150.117 +        </condition>
 150.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
 150.119 +            <and>
 150.120 +                <isset property="jaxws.endorsed.dir"/>
 150.121 +                <available file="nbproject/jaxws-build.xml"/>
 150.122 +            </and>
 150.123 +        </condition>
 150.124 +    </target>
 150.125 +    <target name="-post-init">
 150.126 +        <!-- Empty placeholder for easier customization. -->
 150.127 +        <!-- You can override this target in the ../build.xml file. -->
 150.128 +    </target>
 150.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
 150.130 +        <fail unless="src.dir">Must set src.dir</fail>
 150.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
 150.132 +        <fail unless="build.dir">Must set build.dir</fail>
 150.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
 150.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
 150.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
 150.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
 150.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
 150.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
 150.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
 150.140 +    </target>
 150.141 +    <target name="-init-macrodef-property">
 150.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
 150.143 +            <attribute name="name"/>
 150.144 +            <attribute name="value"/>
 150.145 +            <sequential>
 150.146 +                <property name="@{name}" value="${@{value}}"/>
 150.147 +            </sequential>
 150.148 +        </macrodef>
 150.149 +    </target>
 150.150 +    <target name="-init-macrodef-javac">
 150.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
 150.152 +            <attribute default="${src.dir}" name="srcdir"/>
 150.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
 150.154 +            <attribute default="${javac.classpath}" name="classpath"/>
 150.155 +            <attribute default="${includes}" name="includes"/>
 150.156 +            <attribute default="${excludes}" name="excludes"/>
 150.157 +            <attribute default="${javac.debug}" name="debug"/>
 150.158 +            <attribute default="" name="sourcepath"/>
 150.159 +            <element name="customize" optional="true"/>
 150.160 +            <sequential>
 150.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}">
 150.162 +                    <classpath>
 150.163 +                        <path path="@{classpath}"/>
 150.164 +                    </classpath>
 150.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
 150.166 +                    <customize/>
 150.167 +                </javac>
 150.168 +            </sequential>
 150.169 +        </macrodef>
 150.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
 150.171 +            <attribute default="${src.dir}" name="srcdir"/>
 150.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
 150.173 +            <attribute default="${javac.classpath}" name="classpath"/>
 150.174 +            <sequential>
 150.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
 150.176 +                    <classpath>
 150.177 +                        <path path="@{classpath}"/>
 150.178 +                    </classpath>
 150.179 +                </depend>
 150.180 +            </sequential>
 150.181 +        </macrodef>
 150.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
 150.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
 150.184 +            <sequential>
 150.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
 150.186 +                <pathconvert pathsep="," property="javac.includes.binary">
 150.187 +                    <path>
 150.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
 150.189 +                    </path>
 150.190 +                    <globmapper from="*.java" to="*.class"/>
 150.191 +                </pathconvert>
 150.192 +                <delete>
 150.193 +                    <files includes="${javac.includes.binary}"/>
 150.194 +                </delete>
 150.195 +            </sequential>
 150.196 +        </macrodef>
 150.197 +    </target>
 150.198 +    <target name="-init-macrodef-junit">
 150.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
 150.200 +            <attribute default="${includes}" name="includes"/>
 150.201 +            <attribute default="${excludes}" name="excludes"/>
 150.202 +            <attribute default="**" name="testincludes"/>
 150.203 +            <sequential>
 150.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
 150.205 +                    <batchtest todir="${build.test.results.dir}">
 150.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
 150.207 +                            <filename name="@{testincludes}"/>
 150.208 +                        </fileset>
 150.209 +                    </batchtest>
 150.210 +                    <classpath>
 150.211 +                        <path path="${run.test.classpath}"/>
 150.212 +                    </classpath>
 150.213 +                    <syspropertyset>
 150.214 +                        <propertyref prefix="test-sys-prop."/>
 150.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
 150.216 +                    </syspropertyset>
 150.217 +                    <formatter type="brief" usefile="false"/>
 150.218 +                    <formatter type="xml"/>
 150.219 +                    <jvmarg line="${run.jvmargs}"/>
 150.220 +                </junit>
 150.221 +            </sequential>
 150.222 +        </macrodef>
 150.223 +    </target>
 150.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
 150.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
 150.226 +            <attribute default="${main.class}" name="name"/>
 150.227 +            <attribute default="${debug.classpath}" name="classpath"/>
 150.228 +            <attribute default="" name="stopclassname"/>
 150.229 +            <sequential>
 150.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
 150.231 +                    <classpath>
 150.232 +                        <path path="@{classpath}"/>
 150.233 +                    </classpath>
 150.234 +                </nbjpdastart>
 150.235 +            </sequential>
 150.236 +        </macrodef>
 150.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
 150.238 +            <attribute default="${build.classes.dir}" name="dir"/>
 150.239 +            <sequential>
 150.240 +                <nbjpdareload>
 150.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
 150.242 +                        <include name="${fix.includes}*.class"/>
 150.243 +                    </fileset>
 150.244 +                </nbjpdareload>
 150.245 +            </sequential>
 150.246 +        </macrodef>
 150.247 +    </target>
 150.248 +    <target name="-init-debug-args">
 150.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
 150.250 +        <condition property="have-jdk-older-than-1.4">
 150.251 +            <or>
 150.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
 150.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
 150.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
 150.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
 150.256 +            </or>
 150.257 +        </condition>
 150.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
 150.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
 150.260 +        </condition>
 150.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
 150.262 +            <os family="windows"/>
 150.263 +        </condition>
 150.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
 150.265 +            <isset property="debug.transport"/>
 150.266 +        </condition>
 150.267 +    </target>
 150.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
 150.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
 150.270 +            <attribute default="${main.class}" name="classname"/>
 150.271 +            <attribute default="${debug.classpath}" name="classpath"/>
 150.272 +            <element name="customize" optional="true"/>
 150.273 +            <sequential>
 150.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 150.275 +                    <jvmarg line="${debug-args-line}"/>
 150.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
 150.277 +                    <jvmarg line="${run.jvmargs}"/>
 150.278 +                    <classpath>
 150.279 +                        <path path="@{classpath}"/>
 150.280 +                    </classpath>
 150.281 +                    <syspropertyset>
 150.282 +                        <propertyref prefix="run-sys-prop."/>
 150.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 150.284 +                    </syspropertyset>
 150.285 +                    <customize/>
 150.286 +                </java>
 150.287 +            </sequential>
 150.288 +        </macrodef>
 150.289 +    </target>
 150.290 +    <target name="-init-macrodef-java">
 150.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
 150.292 +            <attribute default="${main.class}" name="classname"/>
 150.293 +            <element name="customize" optional="true"/>
 150.294 +            <sequential>
 150.295 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
 150.296 +                    <jvmarg line="${run.jvmargs}"/>
 150.297 +                    <classpath>
 150.298 +                        <path path="${run.classpath}"/>
 150.299 +                    </classpath>
 150.300 +                    <syspropertyset>
 150.301 +                        <propertyref prefix="run-sys-prop."/>
 150.302 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
 150.303 +                    </syspropertyset>
 150.304 +                    <customize/>
 150.305 +                </java>
 150.306 +            </sequential>
 150.307 +        </macrodef>
 150.308 +    </target>
 150.309 +    <target name="-init-presetdef-jar">
 150.310 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
 150.311 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
 150.312 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
 150.313 +            </jar>
 150.314 +        </presetdef>
 150.315 +    </target>
 150.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"/>
 150.317 +    <!--
 150.318 +                ===================
 150.319 +                COMPILATION SECTION
 150.320 +                ===================
 150.321 +            -->
 150.322 +    <target depends="init" name="deps-jar" unless="no.deps"/>
 150.323 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
 150.324 +    <target depends="init" name="-check-automatic-build">
 150.325 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
 150.326 +    </target>
 150.327 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
 150.328 +        <antcall target="clean"/>
 150.329 +    </target>
 150.330 +    <target depends="init,deps-jar" name="-pre-pre-compile">
 150.331 +        <mkdir dir="${build.classes.dir}"/>
 150.332 +    </target>
 150.333 +    <target name="-pre-compile">
 150.334 +        <!-- Empty placeholder for easier customization. -->
 150.335 +        <!-- You can override this target in the ../build.xml file. -->
 150.336 +    </target>
 150.337 +    <target if="do.depend.true" name="-compile-depend">
 150.338 +        <j2seproject3:depend/>
 150.339 +    </target>
 150.340 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
 150.341 +        <j2seproject3:javac/>
 150.342 +        <copy todir="${build.classes.dir}">
 150.343 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 150.344 +        </copy>
 150.345 +    </target>
 150.346 +    <target name="-post-compile">
 150.347 +        <!-- Empty placeholder for easier customization. -->
 150.348 +        <!-- You can override this target in the ../build.xml file. -->
 150.349 +    </target>
 150.350 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
 150.351 +    <target name="-pre-compile-single">
 150.352 +        <!-- Empty placeholder for easier customization. -->
 150.353 +        <!-- You can override this target in the ../build.xml file. -->
 150.354 +    </target>
 150.355 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
 150.356 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 150.357 +        <j2seproject3:force-recompile/>
 150.358 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
 150.359 +    </target>
 150.360 +    <target name="-post-compile-single">
 150.361 +        <!-- Empty placeholder for easier customization. -->
 150.362 +        <!-- You can override this target in the ../build.xml file. -->
 150.363 +    </target>
 150.364 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
 150.365 +    <!--
 150.366 +                ====================
 150.367 +                JAR BUILDING SECTION
 150.368 +                ====================
 150.369 +            -->
 150.370 +    <target depends="init" name="-pre-pre-jar">
 150.371 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
 150.372 +        <mkdir dir="${dist.jar.dir}"/>
 150.373 +    </target>
 150.374 +    <target name="-pre-jar">
 150.375 +        <!-- Empty placeholder for easier customization. -->
 150.376 +        <!-- You can override this target in the ../build.xml file. -->
 150.377 +    </target>
 150.378 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
 150.379 +        <j2seproject1:jar/>
 150.380 +    </target>
 150.381 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
 150.382 +        <j2seproject1:jar manifest="${manifest.file}"/>
 150.383 +    </target>
 150.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">
 150.385 +        <j2seproject1:jar manifest="${manifest.file}">
 150.386 +            <j2seproject1:manifest>
 150.387 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
 150.388 +            </j2seproject1:manifest>
 150.389 +        </j2seproject1:jar>
 150.390 +        <echo>To run this application from the command line without Ant, try:</echo>
 150.391 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 150.392 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 150.393 +        <pathconvert property="run.classpath.with.dist.jar">
 150.394 +            <path path="${run.classpath}"/>
 150.395 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
 150.396 +        </pathconvert>
 150.397 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
 150.398 +    </target>
 150.399 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
 150.400 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
 150.401 +        <pathconvert property="run.classpath.without.build.classes.dir">
 150.402 +            <path path="${run.classpath}"/>
 150.403 +            <map from="${build.classes.dir.resolved}" to=""/>
 150.404 +        </pathconvert>
 150.405 +        <pathconvert pathsep=" " property="jar.classpath">
 150.406 +            <path path="${run.classpath.without.build.classes.dir}"/>
 150.407 +            <chainedmapper>
 150.408 +                <flattenmapper/>
 150.409 +                <globmapper from="*" to="lib/*"/>
 150.410 +            </chainedmapper>
 150.411 +        </pathconvert>
 150.412 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
 150.413 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
 150.414 +            <fileset dir="${build.classes.dir}"/>
 150.415 +            <manifest>
 150.416 +                <attribute name="Main-Class" value="${main.class}"/>
 150.417 +                <attribute name="Class-Path" value="${jar.classpath}"/>
 150.418 +            </manifest>
 150.419 +        </copylibs>
 150.420 +        <echo>To run this application from the command line without Ant, try:</echo>
 150.421 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
 150.422 +        <echo>java -jar "${dist.jar.resolved}"</echo>
 150.423 +    </target>
 150.424 +    <target name="-post-jar">
 150.425 +        <!-- Empty placeholder for easier customization. -->
 150.426 +        <!-- You can override this target in the ../build.xml file. -->
 150.427 +    </target>
 150.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"/>
 150.429 +    <!--
 150.430 +                =================
 150.431 +                EXECUTION SECTION
 150.432 +                =================
 150.433 +            -->
 150.434 +    <target depends="init,compile" description="Run a main class." name="run">
 150.435 +        <j2seproject1:java>
 150.436 +            <customize>
 150.437 +                <arg line="${application.args}"/>
 150.438 +            </customize>
 150.439 +        </j2seproject1:java>
 150.440 +    </target>
 150.441 +    <target name="-do-not-recompile">
 150.442 +        <property name="javac.includes.binary" value=""/>
 150.443 +    </target>
 150.444 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
 150.445 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
 150.446 +        <j2seproject1:java classname="${run.class}"/>
 150.447 +    </target>
 150.448 +    <!--
 150.449 +                =================
 150.450 +                DEBUGGING SECTION
 150.451 +                =================
 150.452 +            -->
 150.453 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
 150.454 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
 150.455 +    </target>
 150.456 +    <target depends="init,compile" name="-debug-start-debuggee">
 150.457 +        <j2seproject3:debug>
 150.458 +            <customize>
 150.459 +                <arg line="${application.args}"/>
 150.460 +            </customize>
 150.461 +        </j2seproject3:debug>
 150.462 +    </target>
 150.463 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
 150.464 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
 150.465 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
 150.466 +    </target>
 150.467 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
 150.468 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
 150.469 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
 150.470 +        <j2seproject3:debug classname="${debug.class}"/>
 150.471 +    </target>
 150.472 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
 150.473 +    <target depends="init" name="-pre-debug-fix">
 150.474 +        <fail unless="fix.includes">Must set fix.includes</fail>
 150.475 +        <property name="javac.includes" value="${fix.includes}.java"/>
 150.476 +    </target>
 150.477 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
 150.478 +        <j2seproject1:nbjpdareload/>
 150.479 +    </target>
 150.480 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
 150.481 +    <!--
 150.482 +                ===============
 150.483 +                JAVADOC SECTION
 150.484 +                ===============
 150.485 +            -->
 150.486 +    <target depends="init" name="-javadoc-build">
 150.487 +        <mkdir dir="${dist.javadoc.dir}"/>
 150.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}">
 150.489 +            <classpath>
 150.490 +                <path path="${javac.classpath}"/>
 150.491 +            </classpath>
 150.492 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
 150.493 +                <filename name="**/*.java"/>
 150.494 +            </fileset>
 150.495 +        </javadoc>
 150.496 +    </target>
 150.497 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
 150.498 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
 150.499 +    </target>
 150.500 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
 150.501 +    <!--
 150.502 +                =========================
 150.503 +                JUNIT COMPILATION SECTION
 150.504 +                =========================
 150.505 +            -->
 150.506 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
 150.507 +        <mkdir dir="${build.test.classes.dir}"/>
 150.508 +    </target>
 150.509 +    <target name="-pre-compile-test">
 150.510 +        <!-- Empty placeholder for easier customization. -->
 150.511 +        <!-- You can override this target in the ../build.xml file. -->
 150.512 +    </target>
 150.513 +    <target if="do.depend.true" name="-compile-test-depend">
 150.514 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 150.515 +    </target>
 150.516 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
 150.517 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
 150.518 +        <copy todir="${build.test.classes.dir}">
 150.519 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 150.520 +        </copy>
 150.521 +    </target>
 150.522 +    <target name="-post-compile-test">
 150.523 +        <!-- Empty placeholder for easier customization. -->
 150.524 +        <!-- You can override this target in the ../build.xml file. -->
 150.525 +    </target>
 150.526 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
 150.527 +    <target name="-pre-compile-test-single">
 150.528 +        <!-- Empty placeholder for easier customization. -->
 150.529 +        <!-- You can override this target in the ../build.xml file. -->
 150.530 +    </target>
 150.531 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
 150.532 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
 150.533 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
 150.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}"/>
 150.535 +        <copy todir="${build.test.classes.dir}">
 150.536 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
 150.537 +        </copy>
 150.538 +    </target>
 150.539 +    <target name="-post-compile-test-single">
 150.540 +        <!-- Empty placeholder for easier customization. -->
 150.541 +        <!-- You can override this target in the ../build.xml file. -->
 150.542 +    </target>
 150.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"/>
 150.544 +    <!--
 150.545 +                =======================
 150.546 +                JUNIT EXECUTION SECTION
 150.547 +                =======================
 150.548 +            -->
 150.549 +    <target depends="init" if="have.tests" name="-pre-test-run">
 150.550 +        <mkdir dir="${build.test.results.dir}"/>
 150.551 +    </target>
 150.552 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
 150.553 +        <j2seproject3:junit testincludes="**/*Test.java"/>
 150.554 +    </target>
 150.555 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
 150.556 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 150.557 +    </target>
 150.558 +    <target depends="init" if="have.tests" name="test-report"/>
 150.559 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
 150.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"/>
 150.561 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
 150.562 +        <mkdir dir="${build.test.results.dir}"/>
 150.563 +    </target>
 150.564 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
 150.565 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
 150.566 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
 150.567 +    </target>
 150.568 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
 150.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
 150.570 +    </target>
 150.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"/>
 150.572 +    <!--
 150.573 +                =======================
 150.574 +                JUNIT DEBUGGING SECTION
 150.575 +                =======================
 150.576 +            -->
 150.577 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
 150.578 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
 150.579 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
 150.580 +        <delete file="${test.report.file}"/>
 150.581 +        <mkdir dir="${build.test.results.dir}"/>
 150.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}">
 150.583 +            <customize>
 150.584 +                <syspropertyset>
 150.585 +                    <propertyref prefix="test-sys-prop."/>
 150.586 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
 150.587 +                </syspropertyset>
 150.588 +                <arg value="${test.class}"/>
 150.589 +                <arg value="showoutput=true"/>
 150.590 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
 150.591 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
 150.592 +            </customize>
 150.593 +        </j2seproject3:debug>
 150.594 +    </target>
 150.595 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
 150.596 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
 150.597 +    </target>
 150.598 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
 150.599 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
 150.600 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
 150.601 +    </target>
 150.602 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
 150.603 +    <!--
 150.604 +                =========================
 150.605 +                APPLET EXECUTION SECTION
 150.606 +                =========================
 150.607 +            -->
 150.608 +    <target depends="init,compile-single" name="run-applet">
 150.609 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 150.610 +        <j2seproject1:java classname="sun.applet.AppletViewer">
 150.611 +            <customize>
 150.612 +                <arg value="${applet.url}"/>
 150.613 +            </customize>
 150.614 +        </j2seproject1:java>
 150.615 +    </target>
 150.616 +    <!--
 150.617 +                =========================
 150.618 +                APPLET DEBUGGING  SECTION
 150.619 +                =========================
 150.620 +            -->
 150.621 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
 150.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
 150.623 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
 150.624 +            <customize>
 150.625 +                <arg value="${applet.url}"/>
 150.626 +            </customize>
 150.627 +        </j2seproject3:debug>
 150.628 +    </target>
 150.629 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
 150.630 +    <!--
 150.631 +                ===============
 150.632 +                CLEANUP SECTION
 150.633 +                ===============
 150.634 +            -->
 150.635 +    <target depends="init" name="deps-clean" unless="no.deps"/>
 150.636 +    <target depends="init" name="-do-clean">
 150.637 +        <delete dir="${build.dir}"/>
 150.638 +        <delete dir="${dist.dir}"/>
 150.639 +    </target>
 150.640 +    <target name="-post-clean">
 150.641 +        <!-- Empty placeholder for easier customization. -->
 150.642 +        <!-- You can override this target in the ../build.xml file. -->
 150.643 +    </target>
 150.644 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
 150.645 +</project>
   151.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   151.2 +++ b/task2/solution14/nbproject/genfiles.properties	Wed Oct 01 10:43:05 2008 +0200
   151.3 @@ -0,0 +1,8 @@
   151.4 +build.xml.data.CRC32=2ab820eb
   151.5 +build.xml.script.CRC32=58a52595
   151.6 +build.xml.stylesheet.CRC32=be360661
   151.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
   151.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
   151.9 +nbproject/build-impl.xml.data.CRC32=1d0fd5f2
  151.10 +nbproject/build-impl.xml.script.CRC32=951643da
  151.11 +nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
   152.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   152.2 +++ b/task2/solution14/nbproject/project.properties	Wed Oct 01 10:43:05 2008 +0200
   152.3 @@ -0,0 +1,68 @@
   152.4 +application.title=currency
   152.5 +application.vendor=apidesign.org
   152.6 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
   152.7 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
   152.8 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
   152.9 +build.classes.dir=${build.dir}/classes
  152.10 +build.classes.excludes=**/*.java,**/*.form
  152.11 +# This directory is removed when the project is cleaned:
  152.12 +build.dir=build
  152.13 +build.generated.dir=${build.dir}/generated
  152.14 +# Only compile against the classpath explicitly listed here:
  152.15 +build.sysclasspath=ignore
  152.16 +build.test.classes.dir=${build.dir}/test/classes
  152.17 +build.test.results.dir=${build.dir}/test/results
  152.18 +debug.classpath=\
  152.19 +    ${run.classpath}
  152.20 +debug.test.classpath=\
  152.21 +    ${run.test.classpath}
  152.22 +# This directory is removed when the project is cleaned:
  152.23 +dist.dir=dist
  152.24 +dist.jar=${dist.dir}/currency.jar
  152.25 +dist.javadoc.dir=${dist.dir}/javadoc
  152.26 +excludes=
  152.27 +file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
  152.28 +file.reference.src-apifest08=..
  152.29 +includes=**
  152.30 +jar.compress=false
  152.31 +javac.classpath=
  152.32 +# Space-separated list of extra javac options
  152.33 +javac.compilerargs=
  152.34 +javac.deprecation=false
  152.35 +javac.source=1.5
  152.36 +javac.target=1.5
  152.37 +javac.test.classpath=\
  152.38 +    ${javac.classpath}:\
  152.39 +    ${build.classes.dir}:\
  152.40 +    ${file.reference.junit-4.4.jar}
  152.41 +javadoc.additionalparam=
  152.42 +javadoc.author=false
  152.43 +javadoc.encoding=
  152.44 +javadoc.noindex=false
  152.45 +javadoc.nonavbar=false
  152.46 +javadoc.notree=false
  152.47 +javadoc.private=false
  152.48 +javadoc.splitindex=true
  152.49 +javadoc.use=true
  152.50 +javadoc.version=false
  152.51 +javadoc.windowtitle=
  152.52 +jnlp.codebase.type=local
  152.53 +jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
  152.54 +jnlp.descriptor=application
  152.55 +jnlp.enabled=false
  152.56 +jnlp.offline-allowed=false
  152.57 +jnlp.signed=false
  152.58 +meta.inf.dir=${src.dir}/META-INF
  152.59 +platform.active=default_platform
  152.60 +run.classpath=\
  152.61 +    ${javac.classpath}:\
  152.62 +    ${build.classes.dir}
  152.63 +# Space-separated list of JVM arguments used when running the project
  152.64 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
  152.65 +# or test-sys-prop.name=value to set system properties for unit tests):
  152.66 +run.jvmargs=
  152.67 +run.test.classpath=\
  152.68 +    ${javac.test.classpath}:\
  152.69 +    ${build.test.classes.dir}
  152.70 +src.dir=src
  152.71 +test.src.dir=test
   153.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   153.2 +++ b/task2/solution14/nbproject/project.xml	Wed Oct 01 10:43:05 2008 +0200
   153.3 @@ -0,0 +1,16 @@
   153.4 +<?xml version="1.0" encoding="UTF-8"?>
   153.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
   153.6 +    <type>org.netbeans.modules.java.j2seproject</type>
   153.7 +    <configuration>
   153.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
   153.9 +            <name>Currency Convertor Solution 14</name>
  153.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
  153.11 +            <source-roots>
  153.12 +                <root id="src.dir"/>
  153.13 +            </source-roots>
  153.14 +            <test-roots>
  153.15 +                <root id="test.src.dir"/>
  153.16 +            </test-roots>
  153.17 +        </data>
  153.18 +    </configuration>
  153.19 +</project>
   154.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   154.2 +++ b/task2/solution14/src/org/apidesign/apifest08/currency/Convertor.java	Wed Oct 01 10:43:05 2008 +0200
   154.3 @@ -0,0 +1,88 @@
   154.4 +package org.apidesign.apifest08.currency;
   154.5 +
   154.6 +/** This is the skeleton class for your API. You need to make it public, so
   154.7 + * it is accessible to your client code (currently in Task1Test.java) file.
   154.8 + * <p>
   154.9 + * Feel free to create additional classes or rename this one, just keep all
  154.10 + * the API and its implementation in this package. Do not spread it outside
  154.11 + * to other packages.
  154.12 + */
  154.13 +public final class Convertor {
  154.14 +    private String currency1;
  154.15 +    private String currency2;
  154.16 +    private Rate rate;
  154.17 +    
  154.18 +    Convertor(String currency1, String currency2, Rate rate) {
  154.19 +        if ((currency1 == null)||(currency2 == null)||(rate == null)) {
  154.20 +            throw new IllegalArgumentException("All arguments have to be non-null.");
  154.21 +        }
  154.22 +        this.currency1 = currency1;
  154.23 +        this.currency2 = currency2;
  154.24 +        this.rate = rate;
  154.25 +    }
  154.26 +
  154.27 +    public double convert(String fromCurrency, String toCurrency, int amount) {
  154.28 +        if ((fromCurrency == null)||(toCurrency == null)) {
  154.29 +            throw new IllegalArgumentException("All arguments have to be non-null.");            
  154.30 +        }
  154.31 +        
  154.32 +        if (currency1.equals(fromCurrency) && currency2.equals(toCurrency)) {
  154.33 +            return rate.convertAtoB(amount);
  154.34 +        } else if (currency2.equals(fromCurrency) && currency1.equals(toCurrency)) {
  154.35 +            return rate.convertBtoA(amount);
  154.36 +        } else {
  154.37 +            throw new IllegalArgumentException("Convertor " + this.toString() + 
  154.38 +                    " cannot work with currencies " + fromCurrency + " and " + toCurrency + ".");
  154.39 +        }
  154.40 +    }
  154.41 +
  154.42 +    public double convert(String fromCurrency, String toCurrency, double amount) {
  154.43 +        if ((fromCurrency == null)||(toCurrency == null)) {
  154.44 +            throw new IllegalArgumentException("All arguments have to be non-null.");            
  154.45 +        }
  154.46 +        
  154.47 +        if (currency1.equals(fromCurrency) && currency2.equals(toCurrency)) {
  154.48 +            return rate.convertAtoB(amount);
  154.49 +        } else if (currency2.equals(fromCurrency) && currency1.equals(toCurrency)) {
  154.50 +            return rate.convertBtoA(amount);
  154.51 +        } else {
  154.52 +            throw new IllegalArgumentException("Convertor " + this.toString() + 
  154.53 +                    " cannot work with currencies " + fromCurrency + " and " + toCurrency + ".");
  154.54 +        }
  154.55 +    }
  154.56 +        
  154.57 +    @Override
  154.58 +    public String toString() {
  154.59 +        return currency1+currency2;
  154.60 +    }
  154.61 +    
  154.62 +    @Override
  154.63 +    public boolean equals(Object obj) {
  154.64 +        if (obj == null) {
  154.65 +            return false;
  154.66 +        }
  154.67 +        if (getClass() != obj.getClass()) {
  154.68 +            return false;
  154.69 +        }
  154.70 +        final Convertor other = (Convertor) obj;
  154.71 +        if (this.currency1 != other.currency1 && (this.currency1 == null || !this.currency1.equals(other.currency1))) {
  154.72 +            return false;
  154.73 +        }
  154.74 +        if (this.currency2 != other.currency2 && (this.currency2 == null || !this.currency2.equals(other.currency2))) {
  154.75 +            return false;
  154.76 +        }
  154.77 +        if (this.rate != other.rate && (this.rate == null || !this.rate.equals(other.rate))) {
  154.78 +            return false;
  154.79 +        }
  154.80 +        return true;
  154.81 +    }
  154.82 +
  154.83 +    @Override
  154.84 +    public int hashCode() {
  154.85 +        int hash = 5;
  154.86 +        hash = 67 * hash + (this.currency1 != null ? this.currency1.hashCode() : 0);
  154.87 +        hash = 67 * hash + (this.currency2 != null ? this.currency2.hashCode() : 0);
  154.88 +        hash = 67 * hash + (this.rate != null ? this.rate.hashCode() : 0);
  154.89 +        return hash;
  154.90 +    }
  154.91 +}
   155.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   155.2 +++ b/task2/solution14/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Wed Oct 01 10:43:05 2008 +0200
   155.3 @@ -0,0 +1,28 @@
   155.4 +
   155.5 +package org.apidesign.apifest08.currency;
   155.6 +
   155.7 +public final class ConvertorFactory {
   155.8 +
   155.9 +    //Singleton
  155.10 +    private static ConvertorFactory thisFactory = new ConvertorFactory();    
  155.11 +    private ConvertorFactory() {};    
  155.12 +    public static ConvertorFactory newInstance() {
  155.13 +        return thisFactory;
  155.14 +    }        
  155.15 +    
  155.16 +    public Convertor createConvertor(String currency1, String currency2, Rate rate) {
  155.17 +        return new Convertor(currency1, currency2, rate);
  155.18 +    }
  155.19 +    
  155.20 +    public Convertor createConvertor(String currency1, String currency2, int amount1, int amount2) {
  155.21 +        return new Convertor(currency1, currency2, new Rate(amount1, amount2));
  155.22 +    }
  155.23 +
  155.24 +    public Convertor createConvertor(String currency1, String currency2, double amount1, double amount2) {
  155.25 +        return new Convertor(currency1, currency2, new Rate(amount1, amount2));
  155.26 +    }
  155.27 +    
  155.28 +    public Convertor createConvertor(String currency1, String currency2, double rate) {
  155.29 +        return new Convertor(currency1, currency2, new Rate(rate));
  155.30 +    }
  155.31 +}
   156.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   156.2 +++ b/task2/solution14/src/org/apidesign/apifest08/currency/Rate.java	Wed Oct 01 10:43:05 2008 +0200
   156.3 @@ -0,0 +1,68 @@
   156.4 +
   156.5 +package org.apidesign.apifest08.currency;
   156.6 +
   156.7 +public final class Rate {
   156.8 +
   156.9 +    private double rate;
  156.10 +
  156.11 +    public Rate(int amountA, int amountB) {
  156.12 +        rate = amountA / (double)amountB;
  156.13 +        if (rate <= 0) {
  156.14 +            throw new IllegalArgumentException("Exchange rate must be positive.");
  156.15 +        }
  156.16 +    }
  156.17 +
  156.18 +    public Rate(double amountA, double amountB) {
  156.19 +        rate = amountA / amountB;
  156.20 +        if (rate <= 0) {
  156.21 +            throw new IllegalArgumentException("Exchange rate must be positive.");
  156.22 +        }
  156.23 +    }
  156.24 +    
  156.25 +    public Rate(double rate) {
  156.26 +        this.rate = rate;
  156.27 +        if (this.rate <= 0) {
  156.28 +            throw new IllegalArgumentException("Exchange rate must be positive.");
  156.29 +        }
  156.30 +    }
  156.31 +
  156.32 +    public double convertAtoB(int a) {
  156.33 +        return a / rate;
  156.34 +    }
  156.35 +
  156.36 +    public double convertAtoB(double a) {
  156.37 +        return a / rate;
  156.38 +    }
  156.39 +
  156.40 +    public double convertBtoA(int b) {
  156.41 +        return b * rate;
  156.42 +    }
  156.43 +
  156.44 +    public double convertBtoA(double b) {
  156.45 +        return b * rate;
  156.46 +    }
  156.47 +
  156.48 +
  156.49 +    @Override
  156.50 +    public boolean equals(Object obj) {
  156.51 +        if (obj == null) {
  156.52 +            return false;
  156.53 +        }
  156.54 +        if (getClass() != obj.getClass()) {
  156.55 +            return false;
  156.56 +        }
  156.57 +        final Rate other = (Rate) obj;
  156.58 +        return true;
  156.59 +    }
  156.60 +
  156.61 +    @Override
  156.62 +    public int hashCode() {
  156.63 +        int hash = 5;
  156.64 +        return hash;
  156.65 +    }
  156.66 +
  156.67 +    @Override
  156.68 +    public String toString() {
  156.69 +        return ""+rate;
  156.70 +    }
  156.71 +}
   157.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   157.2 +++ b/task2/solution14/test/org/apidesign/apifest08/test/Task1Test.java	Wed Oct 01 10:43:05 2008 +0200
   157.3 @@ -0,0 +1,144 @@
   157.4 +package org.apidesign.apifest08.test;
   157.5 +
   157.6 +import junit.framework.TestCase;
   157.7 +import org.apidesign.apifest08.currency.Convertor;
   157.8 +import org.apidesign.apifest08.currency.ConvertorFactory;
   157.9 +
  157.10 +/** Finish the Convertor API, and then write bodies of methods inside
  157.11 + * of this class to match the given tasks. To fullfil your task, use the
  157.12 + * API define in the <code>org.apidesign.apifest08.currency</code> package.
  157.13 + * Do not you reflection, or other hacks as your code
  157.14 + * shall run without any runtime permissions.
  157.15 + */
  157.16 +public class Task1Test extends TestCase {
  157.17 +    public Task1Test(String testName) {
  157.18 +        super(testName);
  157.19 +    }
  157.20 +
  157.21 +    @Override
  157.22 +    protected void setUp() throws Exception {
  157.23 +    }
  157.24 +
  157.25 +    @Override
  157.26 +    protected void tearDown() throws Exception {
  157.27 +    }
  157.28 +
  157.29 +    //
  157.30 +    // Imagine that there are three parts of the whole system:
  157.31 +    // 1. there is someone who knows the current exchange rate
  157.32 +    // 2. there is someone who wants to do the conversion
  157.33 +    // 3. there is the API between 1. and 2. which allows them to communicate
  157.34 +    // Please design such API
  157.35 +    //
  157.36 +
  157.37 +    /** Create convertor that understands two currencies, CZK and
  157.38 +     *  USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
  157.39 +     *  e.g. those that know the exchange rate. They somehow need to create
  157.40 +     *  the objects from the API and tell them the exchange rate. The API itself
  157.41 +     *  knows nothing about any rates, before the createCZKtoUSD method is called.
  157.42 +     *
  157.43 +     * Creation of the convertor shall not require subclassing of any class
  157.44 +     * or interface on the client side.
  157.45 +     *
  157.46 +     * @return prepared convertor ready for converting USD to CZK and CZK to USD
  157.47 +     */
  157.48 +    public static Convertor createCZKtoUSD() {
  157.49 +        return ConvertorFactory.newInstance().createConvertor("CZK", "USD", 17, 1);
  157.50 +    }
  157.51 +
  157.52 +    /** Create convertor that understands two currencies, CZK and
  157.53 +     *  SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
  157.54 +     *  it knows the exchange rate, and needs to use the API to create objects
  157.55 +     *  with the exchange rate. Anyone shall be ready to call this method without
  157.56 +     *  any other method being called previously. The API itself shall know
  157.57 +     *  nothing about any rates, before this method is called.
  157.58 +     *
  157.59 +     * Creation of the convertor shall not require subclassing of any class
  157.60 +     * or interface on the client side.
  157.61 +     * 
  157.62 +     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  157.63 +     */
  157.64 +    public static Convertor createSKKtoCZK() {
  157.65 +        return ConvertorFactory.newInstance().createConvertor("SKK", "CZK", 100, 80);
  157.66 +    }
  157.67 +
  157.68 +    //
  157.69 +    // now the methods for group #2 follow:
  157.70 +    // this group knows nothing about exchange rates, but knows how to use
  157.71 +    // the API to do conversions. It somehow (by calling one of the factory
  157.72 +    // methods) gets objects from the API and uses them to do the conversions.
  157.73 +    //
  157.74 +    
  157.75 +    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
  157.76 +     * with it.
  157.77 +     */
  157.78 +    public void testCurrencyCZKUSD() throws Exception {
  157.79 +        Convertor c = createCZKtoUSD();        
  157.80 +        // convert $5 to CZK using c:        
  157.81 +        assertEquals("Result is 85 CZK", 85.0, c.convert("USD", "CZK", 5));
  157.82 +
  157.83 +        // convert $8 to CZK
  157.84 +        assertEquals("Result is 136 CZK", 136.0, c.convert("USD", "CZK", 8));
  157.85 +
  157.86 +        // convert 1003CZK to USD
  157.87 +        assertEquals("Result is 59 CZK", 59.0, c.convert("CZK", "USD", 1003));
  157.88 +    }
  157.89 +
  157.90 +    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
  157.91 +     * with it.
  157.92 +     */
  157.93 +    public void testCurrencySKKCZK() throws Exception {
  157.94 +        Convertor c = createSKKtoCZK();
  157.95 +        // convert 16CZK using c:
  157.96 +        // assertEquals("Result is 20 SKK");
  157.97 +        assertEquals("Result is 20 SKK", 20.0, c.convert("CZK", "SKK", 16));
  157.98 +
  157.99 +        // convert 500SKK to CZK
 157.100 +        // assertEquals("Result is 400 CZK");
 157.101 +        assertEquals("Result is 400 SKK", 400.0, c.convert("SKK", "CZK", 500));
 157.102 +    }
 157.103 +
 157.104 +    /** Verify that the CZK to USD convertor knows nothing about SKK.
 157.105 +     */
 157.106 +    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
 157.107 +        Convertor c = createCZKtoUSD();
 157.108 +        // convert $5 to SKK, the API shall say this is not possible
 157.109 +        try {
 157.110 +            c.convert("USD", "SKK", 5);
 157.111 +            fail("Converting SKK with CZKUSD convertor is impossible");
 157.112 +        } catch (IllegalArgumentException e){
 157.113 +            //ok
 157.114 +        }
 157.115 +        
 157.116 +        // convert 500 SKK to CZK, the API shall say this is not possible
 157.117 +        try {
 157.118 +            c.convert("SKK", "CZK", 500);
 157.119 +            fail("Converting SKK with CZKUSD convertor is impossible");
 157.120 +        } catch (IllegalArgumentException e){
 157.121 +            //ok
 157.122 +        }
 157.123 +        
 157.124 +    }
 157.125 +
 157.126 +    /** Verify that the CZK to SKK convertor knows nothing about USD.
 157.127 +     */
 157.128 +    public void testCannotConvertToUSDwithCZKSKKConvertor() throws Exception {
 157.129 +        Convertor c = createSKKtoCZK();
 157.130 +        // convert $5 to SKK, the API shall say this is not possible
 157.131 +        try {
 157.132 +            c.convert("USD", "SKK", 5);
 157.133 +            fail("Converting SKK with SKKCZK convertor is impossible");
 157.134 +        } catch (IllegalArgumentException e){
 157.135 +            //ok
 157.136 +        }
 157.137 +        
 157.138 +        // convert 500 CZK to USD, the API shall say this is not possible
 157.139 +        try {
 157.140 +            c.convert("CZK", "USD", 500);
 157.141 +            fail("Converting USD with SKKCZK convertor is impossible");
 157.142 +        } catch (IllegalArgumentException e){
 157.143 +            //ok
 157.144 +        }
 157.145 +        
 157.146 +    }
 157.147 +}