1.1 --- a/samples/apifest1/boolcircuit/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
1.2 +++ b/samples/apifest1/boolcircuit/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
1.3 @@ -1,5 +1,31 @@
1.4 +/*
1.5 + * The contents of this file are subject to the terms of the Common Development
1.6 + * and Distribution License (the License). You may not use this file except in
1.7 + * compliance with the License.
1.8 + *
1.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
1.10 + * or http://www.netbeans.org/cddl.txt.
1.11 + *
1.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
1.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
1.14 + * If applicable, add the following below the CDDL Header, with the fields
1.15 + * enclosed by brackets [] replaced by your own identifying information:
1.16 + * "Portions Copyrighted [year] [name of copyright owner]"
1.17 + *
1.18 + * The Original Software is NetBeans. The Initial Developer of the Original
1.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
1.20 + * Microsystems, Inc. All Rights Reserved.
1.21 + */
1.22 +
1.23 package org.netbeans.apifest.boolcircuit;
1.24
1.25 +import java.security.CodeSource;
1.26 +import java.security.Permission;
1.27 +import java.security.PermissionCollection;
1.28 +import java.security.Policy;
1.29 +import java.util.Collection;
1.30 +import java.util.Collections;
1.31 +import java.util.Enumeration;
1.32 import junit.framework.TestCase;
1.33 import junit.framework.*;
1.34
1.35 @@ -15,24 +41,20 @@
1.36 * on output 1 and 1 to 0
1.37 * <li>and - has two inputs and one output. The output is 1 only if both
1.38 * inputs are 1, otherwise it is 0
1.39 - * <li>or - has two inputs and one output. The output is 1 always,
1.40 - * except in the case when both inputs are 0
1.41 + * <li>or - has two inputs and one output. The output is 1 always, except
1.42 + * in the case when both inputs are 0
1.43 * </ul>
1.44 *
1.45 * <p>
1.46 - * The boolean circuit can be used to represent boolean formulas and
1.47 - * compute the results for certain values of its inputs. The individual
1.48 - * tasks described as tests bellow.
1.49 + * The boolean circuit can be used to represent boolean formulas and compute
1.50 + * the results for certain values of its inputs. The individual tasks described
1.51 + * as tests bellow.
1.52 *
1.53 * <p>
1.54 * Links of interest:
1.55 * <ul>
1.56 - * <li>
1.57 - * <a href="http://en.wikipedia.org/wiki/Truth_table">
1.58 - * Truth table</a>
1.59 - * <li>
1.60 - * <a href="http://en.wikipedia.org/wiki/Tautology_(logic)">
1.61 - * Taugology</a>
1.62 + * <li><a href="http://en.wikipedia.org/wiki/Truth_table">Truth table</a>
1.63 + * <li><a href="http://en.wikipedia.org/wiki/Tautology_(logic)">Taugology</a>
1.64 * </ul>
1.65 */
1.66 public class CircuitTest extends TestCase {
2.1 --- a/samples/apifest1/day1/inputandoperation/nbproject/build-impl.xml Sat Jun 14 09:58:05 2008 +0200
2.2 +++ b/samples/apifest1/day1/inputandoperation/nbproject/build-impl.xml Sat Jun 14 09:58:08 2008 +0200
2.3 @@ -19,7 +19,7 @@
2.4 - cleanup
2.5
2.6 -->
2.7 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="inputandoperation_-_day1-impl">
2.8 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="inputandoperation-impl">
2.9 <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
2.10 <!--
2.11 ======================
3.1 --- a/samples/apifest1/day1/inputandoperation/nbproject/genfiles.properties Sat Jun 14 09:58:05 2008 +0200
3.2 +++ b/samples/apifest1/day1/inputandoperation/nbproject/genfiles.properties Sat Jun 14 09:58:08 2008 +0200
3.3 @@ -1,5 +1,5 @@
3.4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
3.5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
3.6 -nbproject/build-impl.xml.data.CRC32=d3cc4b96
3.7 -nbproject/build-impl.xml.script.CRC32=4749e141
3.8 +nbproject/build-impl.xml.data.CRC32=835ca895
3.9 +nbproject/build-impl.xml.script.CRC32=d896881b
3.10 nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
4.1 --- a/samples/apifest1/day1/inputandoperation/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
4.2 +++ b/samples/apifest1/day1/inputandoperation/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
4.3 @@ -1,5 +1,3 @@
4.4 -application.title=inputandoperation - day1
4.5 -application.vendor=jarda
4.6 build.classes.dir=${build.dir}/classes
4.7 build.classes.excludes=**/*.java,**/*.form
4.8 # This directory is removed when the project is cleaned:
4.9 @@ -18,7 +16,6 @@
4.10 dist.jar=${dist.dir}/boolcircuit.jar
4.11 dist.javadoc.dir=${dist.dir}/javadoc
4.12 excludes=
4.13 -file.reference.junit-4.4.jar=../../../libs/dist/junit-4.4.jar
4.14 includes=**
4.15 jar.compress=false
4.16 javac.classpath=
4.17 @@ -30,7 +27,7 @@
4.18 javac.test.classpath=\
4.19 ${javac.classpath}:\
4.20 ${build.classes.dir}:\
4.21 - ${file.reference.junit-4.4.jar}
4.22 + ${libs.junit.classpath}
4.23 javadoc.additionalparam=
4.24 javadoc.author=false
4.25 javadoc.encoding=
4.26 @@ -42,6 +39,9 @@
4.27 javadoc.use=true
4.28 javadoc.version=false
4.29 javadoc.windowtitle=
4.30 +# Property libs.junit.classpath is set here just to make sharing of project simpler.
4.31 +# The library definition has always preference over this property.
4.32 +libs.junit.classpath=../../../../../usr/local/lib/netbeans/ide8/modules/ext/junit-3.8.2.jar
4.33 meta.inf.dir=${src.dir}/META-INF
4.34 platform.active=default_platform
4.35 run.classpath=\
5.1 --- a/samples/apifest1/day1/inputandoperation/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
5.2 +++ b/samples/apifest1/day1/inputandoperation/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
5.3 @@ -19,6 +19,13 @@
5.4
5.5 package org.netbeans.apifest.boolcircuit;
5.6
5.7 +import java.security.CodeSource;
5.8 +import java.security.Permission;
5.9 +import java.security.PermissionCollection;
5.10 +import java.security.Policy;
5.11 +import java.util.Collection;
5.12 +import java.util.Collections;
5.13 +import java.util.Enumeration;
5.14 import junit.framework.TestCase;
5.15 import junit.framework.*;
5.16
5.17 @@ -84,15 +91,11 @@
5.18 inTrue = Factory.createSimpleBooleanInput(true);
5.19 inFalse = Factory.createSimpleBooleanInput(false);
5.20 Operation op1 = Factory.createAndOperation(inFalse, inTrue);
5.21 - Operation op2 = Factory.createOrOperation(
5.22 - Factory.createOperationBasedBooleanInput(op1), inFalse
5.23 - );
5.24 + Operation op2 = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(op1), inFalse);
5.25 assertFalse(Circuit.evaluateBooleanOperation(op2));
5.26
5.27 op1 = Factory.createAndOperation(inFalse, inFalse);
5.28 - op2 = Factory.createOrOperation(
5.29 - Factory.createOperationBasedBooleanInput(op1), inTrue
5.30 - );
5.31 + op2 = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(op1), inTrue);
5.32 assertTrue(Circuit.evaluateBooleanOperation(op2));
5.33 }
5.34 /**
5.35 @@ -103,14 +106,10 @@
5.36 inTrue = Factory.createSimpleBooleanInput(true);
5.37 inFalse = Factory.createSimpleBooleanInput(false);
5.38 Operation not = Factory.createNotOperation(inTrue);
5.39 - Operation or = Factory.createOrOperation(
5.40 - Factory.createOperationBasedBooleanInput(not), inTrue
5.41 - );
5.42 + Operation or = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(not), inTrue);
5.43 assertTrue(Circuit.evaluateBooleanOperation(or));
5.44 not = Factory.createNotOperation(inFalse);
5.45 - or = Factory.createOrOperation(
5.46 - Factory.createOperationBasedBooleanInput(not), inFalse
5.47 - );
5.48 + or = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(not), inFalse);
5.49 assertTrue(Circuit.evaluateBooleanOperation(or));
5.50 }
5.51 // END: apifest.day1.inputandoperation.CircuitTest
6.1 --- a/samples/apifest1/day1/parsingsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:05 2008 +0200
6.2 +++ b/samples/apifest1/day1/parsingsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:08 2008 +0200
6.3 @@ -22,11 +22,10 @@
6.4 // BEGIN: apifest.day1.parsingsolution.Circuit
6.5 /**
6.6 * Usage:
6.7 - * First method parse must be called with valid logical expression on
6.8 - * input.
6.9 - * If it returns zero then it is possible to call method evaluate with
6.10 - * array of input values as parameter. Method evaluate can be invoked
6.11 - * many time with different input values.
6.12 + * First method parse must be called with valid logical expression on input.
6.13 + * If it returns zero then it is possible to call method evaluate with array
6.14 + * of input values as parameter. Method evaluate can be invoked many time with
6.15 + * different input values.
6.16 * Method parse can be called anytime to change logical expression.
6.17 */
6.18 public class Circuit {
6.19 @@ -37,21 +36,19 @@
6.20 * Input values are represented by x and number starting from 1 eg.: x1
6.21 * AND, NOT, OR and brackets '(',')' can be used.
6.22 * Example of valid expression: x1 AND x2
6.23 - * @return 0 when input expression is validated and parsed.
6.24 - * Return nonzero value otherwise.
6.25 + * @return 0 when input expression is validated and parsed. Return nonzero value otherwise.
6.26 */
6.27 public int parse(String expression) {
6.28 return 0;
6.29 }
6.30
6.31 /** Evaluate logical expression
6.32 - * @param array of boolean input values. Size of array must
6.33 - * correspond to number of variables used in expression
6.34 - * If size of array is bigger then only first N values are used
6.35 - * to evaluate expression. Remaining values are ignored.
6.36 + * @param array of boolean input values. Size of array must correspond to number
6.37 + * of variables used in expression
6.38 + * If size of array is bigger then only first N values are used to evaluate expression.
6.39 + * Remaining values are ignored.
6.40 * If size of array is smaller then IllegalArgumentException is thrown.
6.41 - * If no expression is set by method parse then
6.42 - * IllegalStateException is thrown.
6.43 + * If no expression is set by method parse then IllegalStateException is thrown.
6.44 */
6.45 public boolean evaluate(boolean [] x) {
6.46 return true;
7.1 --- a/samples/apifest1/day1/pinbasedsolution/build.xml Sat Jun 14 09:58:05 2008 +0200
7.2 +++ b/samples/apifest1/day1/pinbasedsolution/build.xml Sat Jun 14 09:58:08 2008 +0200
7.3 @@ -2,8 +2,8 @@
7.4 <!-- You may freely edit this file. See commented blocks below for -->
7.5 <!-- some examples of how to customize the build. -->
7.6 <!-- (If you delete it and reopen the project it will be recreated.) -->
7.7 -<project name="pinbasedsolution_-_day1" default="default" basedir=".">
7.8 - <description>Builds, tests, and runs the project pinbasedsolution - day1.</description>
7.9 +<project name="pinbasedsolution" default="default" basedir=".">
7.10 + <description>Builds, tests, and runs the project pinbasedsolution.</description>
7.11 <import file="nbproject/build-impl.xml"/>
7.12 <!--
7.13
7.14 @@ -54,7 +54,7 @@
7.15
7.16 An example of overriding the target for project execution could look like this:
7.17
7.18 - <target name="run" depends="pinbasedsolution_-_day1-impl.jar">
7.19 + <target name="run" depends="pinbasedsolution-impl.jar">
7.20 <exec dir="bin" executable="launcher.exe">
7.21 <arg file="${dist.jar}"/>
7.22 </exec>
8.1 --- a/samples/apifest1/day1/pinbasedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:05 2008 +0200
8.2 +++ b/samples/apifest1/day1/pinbasedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:08 2008 +0200
8.3 @@ -19,7 +19,7 @@
8.4 - cleanup
8.5
8.6 -->
8.7 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="pinbasedsolution_-_day1-impl">
8.8 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="pinbasedsolution-impl">
8.9 <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
8.10 <!--
8.11 ======================
9.1 --- a/samples/apifest1/day1/pinbasedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:05 2008 +0200
9.2 +++ b/samples/apifest1/day1/pinbasedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:08 2008 +0200
9.3 @@ -1,8 +1,8 @@
9.4 -build.xml.data.CRC32=ef095dd7
9.5 -build.xml.script.CRC32=5ff01653
9.6 +build.xml.data.CRC32=c2d9be31
9.7 +build.xml.script.CRC32=09dc18c1
9.8 build.xml.stylesheet.CRC32=be360661
9.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
9.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
9.11 -nbproject/build-impl.xml.data.CRC32=ef095dd7
9.12 -nbproject/build-impl.xml.script.CRC32=6e4480e5
9.13 +nbproject/build-impl.xml.data.CRC32=c2d9be31
9.14 +nbproject/build-impl.xml.script.CRC32=c591e2ef
9.15 nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
10.1 --- a/samples/apifest1/day1/pinbasedsolution/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
10.2 +++ b/samples/apifest1/day1/pinbasedsolution/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
10.3 @@ -1,5 +1,3 @@
10.4 -application.title=pinbasedsolution - day1
10.5 -application.vendor=jarda
10.6 build.classes.dir=${build.dir}/classes
10.7 build.classes.excludes=**/*.java,**/*.form
10.8 # This directory is removed when the project is cleaned:
10.9 @@ -18,7 +16,6 @@
10.10 dist.jar=${dist.dir}/boolcircuit.jar
10.11 dist.javadoc.dir=${dist.dir}/javadoc
10.12 excludes=
10.13 -file.reference.junit-4.4.jar=../../../libs/dist/junit-4.4.jar
10.14 includes=**
10.15 jar.compress=false
10.16 javac.classpath=
10.17 @@ -30,7 +27,7 @@
10.18 javac.test.classpath=\
10.19 ${javac.classpath}:\
10.20 ${build.classes.dir}:\
10.21 - ${file.reference.junit-4.4.jar}
10.22 + ${libs.junit.classpath}
10.23 javadoc.additionalparam=
10.24 javadoc.author=false
10.25 javadoc.encoding=
10.26 @@ -42,6 +39,9 @@
10.27 javadoc.use=true
10.28 javadoc.version=false
10.29 javadoc.windowtitle=
10.30 +# Property libs.junit.classpath is set here just to make sharing of project simpler.
10.31 +# The library definition has always preference over this property.
10.32 +libs.junit.classpath=../../../../../usr/local/lib/netbeans/ide8/modules/ext/junit-3.8.2.jar
10.33 meta.inf.dir=${src.dir}/META-INF
10.34 platform.active=default_platform
10.35 run.classpath=\
11.1 --- a/samples/apifest1/day1/pinbasedsolution/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
11.2 +++ b/samples/apifest1/day1/pinbasedsolution/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
11.3 @@ -19,6 +19,13 @@
11.4
11.5 package org.netbeans.apifest.boolcircuit;
11.6
11.7 +import java.security.CodeSource;
11.8 +import java.security.Permission;
11.9 +import java.security.PermissionCollection;
11.10 +import java.security.Policy;
11.11 +import java.util.Collection;
11.12 +import java.util.Collections;
11.13 +import java.util.Enumeration;
11.14 import junit.framework.TestCase;
11.15 import junit.framework.*;
11.16
11.17 @@ -58,6 +65,13 @@
11.18 super(testName);
11.19 }
11.20
11.21 + protected void setUp() throws Exception {
11.22 + }
11.23 +
11.24 + protected void tearDown() throws Exception {
11.25 + }
11.26 +
11.27 +
11.28 // BEGIN: apifest.day1.pinbasedsolution.CircuitTest
11.29 /**
11.30 * Create a circuit to evaluate x1 and x2 and then
11.31 @@ -92,14 +106,8 @@
11.32 )
11.33 );
11.34
11.35 - assertFalse (
11.36 - "(false AND true) OR false is false",
11.37 - c.evaluate(false, true, false)
11.38 - );
11.39 - assertTrue (
11.40 - "(false AND false) OR true is true",
11.41 - c.evaluate(false, false, true)
11.42 - );
11.43 + assertFalse ("(false AND true) OR false is false", c.evaluate(false, true, false));
11.44 + assertTrue ("(false AND false) OR true is true", c.evaluate(false, false, true));
11.45 }
11.46
11.47 /**
12.1 --- a/samples/apifest1/day1/stackbasedsolution/build.xml Sat Jun 14 09:58:05 2008 +0200
12.2 +++ b/samples/apifest1/day1/stackbasedsolution/build.xml Sat Jun 14 09:58:08 2008 +0200
12.3 @@ -2,8 +2,8 @@
12.4 <!-- You may freely edit this file. See commented blocks below for -->
12.5 <!-- some examples of how to customize the build. -->
12.6 <!-- (If you delete it and reopen the project it will be recreated.) -->
12.7 -<project name="stackbasedsolution_-_day1" default="default" basedir=".">
12.8 - <description>Builds, tests, and runs the project stackbasedsolution - day1.</description>
12.9 +<project name="stackbasedsolution" default="default" basedir=".">
12.10 + <description>Builds, tests, and runs the project stackbasedsolution.</description>
12.11 <import file="nbproject/build-impl.xml"/>
12.12 <!--
12.13
12.14 @@ -54,7 +54,7 @@
12.15
12.16 An example of overriding the target for project execution could look like this:
12.17
12.18 - <target name="run" depends="stackbasedsolution_-_day1-impl.jar">
12.19 + <target name="run" depends="stackbasedsolution-impl.jar">
12.20 <exec dir="bin" executable="launcher.exe">
12.21 <arg file="${dist.jar}"/>
12.22 </exec>
13.1 --- a/samples/apifest1/day1/stackbasedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:05 2008 +0200
13.2 +++ b/samples/apifest1/day1/stackbasedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:08 2008 +0200
13.3 @@ -19,7 +19,7 @@
13.4 - cleanup
13.5
13.6 -->
13.7 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="stackbasedsolution_-_day1-impl">
13.8 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="stackbasedsolution-impl">
13.9 <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
13.10 <!--
13.11 ======================
14.1 --- a/samples/apifest1/day1/stackbasedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:05 2008 +0200
14.2 +++ b/samples/apifest1/day1/stackbasedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:08 2008 +0200
14.3 @@ -1,8 +1,8 @@
14.4 -build.xml.data.CRC32=94a71a7b
14.5 -build.xml.script.CRC32=91c577b8
14.6 +build.xml.data.CRC32=10562595
14.7 +build.xml.script.CRC32=8e100d5a
14.8 build.xml.stylesheet.CRC32=be360661
14.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
14.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
14.11 -nbproject/build-impl.xml.data.CRC32=94a71a7b
14.12 -nbproject/build-impl.xml.script.CRC32=2b7b0da6
14.13 +nbproject/build-impl.xml.data.CRC32=10562595
14.14 +nbproject/build-impl.xml.script.CRC32=4a74b13c
14.15 nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
15.1 --- a/samples/apifest1/day1/stackbasedsolution/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
15.2 +++ b/samples/apifest1/day1/stackbasedsolution/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
15.3 @@ -1,5 +1,3 @@
15.4 -application.title=stackbasedsolution - day1
15.5 -application.vendor=jarda
15.6 build.classes.dir=${build.dir}/classes
15.7 build.classes.excludes=**/*.java,**/*.form
15.8 # This directory is removed when the project is cleaned:
15.9 @@ -18,7 +16,6 @@
15.10 dist.jar=${dist.dir}/boolcircuit.jar
15.11 dist.javadoc.dir=${dist.dir}/javadoc
15.12 excludes=
15.13 -file.reference.junit-4.4.jar=../../../libs/dist/junit-4.4.jar
15.14 includes=**
15.15 jar.compress=false
15.16 javac.classpath=
15.17 @@ -30,7 +27,7 @@
15.18 javac.test.classpath=\
15.19 ${javac.classpath}:\
15.20 ${build.classes.dir}:\
15.21 - ${file.reference.junit-4.4.jar}
15.22 + ${libs.junit.classpath}
15.23 javadoc.additionalparam=
15.24 javadoc.author=false
15.25 javadoc.encoding=
15.26 @@ -42,6 +39,9 @@
15.27 javadoc.use=true
15.28 javadoc.version=false
15.29 javadoc.windowtitle=
15.30 +# Property libs.junit.classpath is set here just to make sharing of project simpler.
15.31 +# The library definition has always preference over this property.
15.32 +libs.junit.classpath=../../../../../usr/local/lib/netbeans/ide8/modules/ext/junit-3.8.2.jar
15.33 meta.inf.dir=${src.dir}/META-INF
15.34 platform.active=default_platform
15.35 run.classpath=\
16.1 --- a/samples/apifest1/day1/stackbasedsolution/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
16.2 +++ b/samples/apifest1/day1/stackbasedsolution/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
16.3 @@ -74,11 +74,9 @@
16.4 public void testX1andX2() {
16.5 Stack<Character> s = new Stack<Character> ();
16.6 s.addAll(Arrays.asList('1', '1'));
16.7 - assertEquals("'1' for '11' input.", '1',
16.8 - CircuitFactory.getBasicCircuit(Operation.AND).evaluate(s));
16.9 + assertEquals("'1' for '11' input.", '1', CircuitFactory.getBasicCircuit(Operation.AND).evaluate(s));
16.10 s.addAll(Arrays.asList('1', '0'));
16.11 - assertEquals("'0' for '10' input.", '0',
16.12 - CircuitFactory.getBasicCircuit(Operation.AND).evaluate(s));
16.13 + assertEquals("'0' for '10' input.", '0', CircuitFactory.getBasicCircuit(Operation.AND).evaluate(s));
16.14 }
16.15
16.16 /**
16.17 @@ -89,28 +87,16 @@
16.18 public void testX1andX2orX3() {
16.19 Stack<Character> s = new Stack<Character> ();
16.20 s.addAll(Arrays.asList('0', '1', '0'));
16.21 - assertEquals("'0' for '010' input.", '0',
16.22 - CircuitFactory.join(CircuitFactory.getTrivialCircuit(),
16.23 - CircuitFactory.getBasicCircuit(Operation.OR),
16.24 - Operation.AND).evaluate(s)
16.25 - );
16.26 + assertEquals("'0' for '010' input.", '0', CircuitFactory.join(CircuitFactory.getTrivialCircuit(), CircuitFactory.getBasicCircuit(Operation.OR), Operation.AND).evaluate(s));
16.27 s.addAll(Arrays.asList('0', '0', '1'));
16.28 - assertEquals("'1' for '001' input.", '1',
16.29 - CircuitFactory.join(CircuitFactory.getTrivialCircuit(),
16.30 - CircuitFactory.getBasicCircuit(Operation.OR),
16.31 - Operation.AND).evaluate(s)
16.32 - );
16.33 + assertEquals("'1' for '001' input.", '1', CircuitFactory.join(CircuitFactory.getTrivialCircuit(), CircuitFactory.getBasicCircuit(Operation.OR), Operation.AND).evaluate(s));
16.34 }
16.35 /**
16.36 * Create a circuit to evaluate (x1 or not(x1)) and then
16.37 * verify that its result is true for all values of x1.
16.38 */
16.39 public void testAlwaysTrue() {
16.40 - Circuit alwaysTrue = CircuitFactory.join(
16.41 - CircuitFactory.getTrivialCircuit(),
16.42 - CircuitFactory.getBasicCircuit(Operation.NEG),
16.43 - Operation.OR
16.44 - );
16.45 + Circuit alwaysTrue = CircuitFactory.join(CircuitFactory.getTrivialCircuit(), CircuitFactory.getBasicCircuit(Operation.NEG), Operation.OR);
16.46 Stack<Character> s = new Stack<Character> ();
16.47 s.addAll(Arrays.asList('0', '0'));
16.48 assertEquals ("'1' for '00'", '1', alwaysTrue.evaluate(s));
17.1 --- a/samples/apifest1/day1/subclassingsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:05 2008 +0200
17.2 +++ b/samples/apifest1/day1/subclassingsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:08 2008 +0200
17.3 @@ -32,9 +32,7 @@
17.4 @Override
17.5 public boolean evaluate(boolean[] in) {
17.6 if ( in.length != 2) {
17.7 - throw new IllegalArgumentException(
17.8 - "Should have two parameters"
17.9 - );
17.10 + throw new IllegalArgumentException( "Should have two parameters");
17.11 }
17.12 return in[0] && in[1];
17.13 }
17.14 @@ -46,9 +44,7 @@
17.15 @Override
17.16 public boolean evaluate(boolean[] in) {
17.17 if ( in.length != 2) {
17.18 - throw new IllegalArgumentException(
17.19 - "Should have two parameters"
17.20 - );
17.21 + throw new IllegalArgumentException( "Should have two parameters");
17.22 }
17.23 return in[0] || in[1];
17.24 }
17.25 @@ -60,9 +56,7 @@
17.26 @Override
17.27 public boolean evaluate(boolean[] in) {
17.28 if ( in.length != 1) {
17.29 - throw new IllegalArgumentException(
17.30 - "Should have one parameter"
17.31 - );
17.32 + throw new IllegalArgumentException( "Should have one parameter");
17.33 }
17.34 return !in[0];
17.35 }
17.36 @@ -70,8 +64,7 @@
17.37 };
17.38
17.39
17.40 - /** Feel free to implement and don't hesitate to throw
17.41 - * IllegalArgumentEception
17.42 + /** Feel free to implement and don't hesitate to throw IllegalArgumentEception
17.43 */
17.44 public abstract boolean evaluate(boolean... in);
17.45
18.1 --- a/samples/apifest1/day2/RealTest.java Sat Jun 14 09:58:05 2008 +0200
18.2 +++ b/samples/apifest1/day2/RealTest.java Sat Jun 14 09:58:08 2008 +0200
18.3 @@ -1,12 +1,37 @@
18.4 +/*
18.5 + * The contents of this file are subject to the terms of the Common Development
18.6 + * and Distribution License (the License). You may not use this file except in
18.7 + * compliance with the License.
18.8 + *
18.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
18.10 + * or http://www.netbeans.org/cddl.txt.
18.11 + *
18.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
18.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
18.14 + * If applicable, add the following below the CDDL Header, with the fields
18.15 + * enclosed by brackets [] replaced by your own identifying information:
18.16 + * "Portions Copyrighted [year] [name of copyright owner]"
18.17 + *
18.18 + * The Original Software is NetBeans. The Initial Developer of the Original
18.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18.20 + * Microsystems, Inc. All Rights Reserved.
18.21 + */
18.22 +
18.23 package org.netbeans.apifest.boolcircuit;
18.24
18.25 +import java.security.CodeSource;
18.26 +import java.security.Permission;
18.27 +import java.security.PermissionCollection;
18.28 +import java.security.Policy;
18.29 +import java.util.Collection;
18.30 +import java.util.Collections;
18.31 +import java.util.Enumeration;
18.32 import junit.framework.TestCase;
18.33 import junit.framework.*;
18.34
18.35 // BEGIN: apitest.day2.RealTest
18.36 /** This file contains the APIFest quest for day 2. Simply, turn the
18.37 - * boolean circuit into circuit that can compute with double
18.38 - * values from 0 to 1.
18.39 + * boolean circuit into circuit that can compute with double values from 0 to 1.
18.40 * <p>
18.41 * This means that where ever a boolean was used to represent input or
18.42 * output values, one can now use any double number from >= 0 and <= 1.
18.43 @@ -14,23 +39,21 @@
18.44 * has to be kept available and have to work. In fact False shall be
18.45 * treated as 0 and True as 1.
18.46 * <p>
18.47 - * The basic elements has to be modified to work on doubles
18.48 - * in the following way:
18.49 + * The basic elements has to be modified to work on doubles in the following
18.50 + * way:
18.51 * <ul>
18.52 - * <li>negation - neg(x) = 1 - x, this is correct extension as
18.53 - * neg(false)=neg(0)=1-0=1=true
18.54 - * <li>and - and(x,y) = x * y, again this is fine as
18.55 - * and(true,true)=1*1=true and also
18.56 + * <li>negation - neg(x) = 1 - x, this is correct extension as neg(false)=neg(0)=1-0=1=true
18.57 + * <li>and - and(x,y) = x * y, again this is fine as and(true,true)=1*1=true and also
18.58 * and(false,true)=0*1=0=false
18.59 * <li>or - or(x,y) = 1 - (1 - x) * (1 - y) and this is also ok as
18.60 - * or(false,false) = 1 - (1 - 0) * (1 - 0) = 1 - 1 = 0 = false
18.61 - * or(true,false) = 1 - (1 - 1)*(1 - 0) = 1 - 0 * 1 = 1 = true
18.62 + * or(false,false) = 1 - (1 - 0) * (1 - 0) = 1 - 1 = 0 = false
18.63 + * or(true,false) = 1 - (1 - 1) * (1 - 0) = 1 - 0 * 1 = 1 = true
18.64 * </ul>
18.65 * <p>
18.66 - * However as the circuits with doubles are more rich than plain boolean
18.67 - * circuits, there is additional requirement to allow any user of your API
18.68 - * to write its own "element" type. This is all going to be exercise in
18.69 - * the tests bellow which you are supposed to implement.
18.70 + * However as the circuits with doubles are more rich than plain boolean circuits,
18.71 + * there is additional requirement to allow any user of your API to write its
18.72 + * own "element" type. This is all going to be exercise in the tests bellow
18.73 + * which you are supposed to implement.
18.74 */
18.75 public class RealTest extends TestCase {
18.76 static {
18.77 @@ -48,33 +71,30 @@
18.78 *
18.79 * Feed this circuit with x1=true, x2=false, assert result is false
18.80 *
18.81 - * Feed the same circuit with x1=false, x2=true, assert result is
18.82 - * true
18.83 + * Feed the same circuit with x1=false, x2=true, assert result is true
18.84 *
18.85 * Feed the same circuit with x1=0.0, x2=1.0, assert result is 1.0
18.86 *
18.87 * Feed the same circuit with x1=0.5, x2=0.5, assert result is 0.625
18.88 *
18.89 - * Feed the same circuit with x1=0.0, x2=2.0, make sure it
18.90 - * throws an exception
18.91 + * Feed the same circuit with x1=0.0, x2=2.0, make sure it throws an exception
18.92 */
18.93 public void testX1andX2orNotX1() {
18.94 fail("testX1andX2orNotX1");
18.95 }
18.96
18.97 - /** Ensure that one variable cannot be filled with two different
18.98 - * values. Create a circuit for x1 and x1. Make sure that for any
18.99 - * usage of your API that would not lead to x1 * x1 result, an
18.100 - * exception is thrown. For example if there was a way to feed the
18.101 - * circuit with two different values 0.3 and 0.5 an exception is
18.102 - * thrown indicating that this is improper use of the circuit.
18.103 + /** Ensure that one variable cannot be filled with two different values.
18.104 + * Create a circuit for x1 and x1. Make sure that for any usage of your
18.105 + * API that would not lead to x1 * x1 result, an exception is thrown.
18.106 + * For example if there was a way to feed the circuit with two different
18.107 + * values 0.3 and 0.5 an exception is thrown indicating that this is
18.108 + * improper use of the circuit.
18.109 */
18.110 public void testImproperUseOfTheCircuit() {
18.111 fail("testImproperUseOfTheCircuit");
18.112 }
18.113
18.114 - /** Write your own element type called "gte" that will have two
18.115 - * inputs and one output.
18.116 + /** Write your own element type called "gte" that will have two inputs and one output.
18.117 * The output value will be 1 if x1 >= x2 and 0 otherwise.
18.118 *
18.119 * Create
19.1 --- a/samples/apifest1/day2/elementbasedsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:05 2008 +0200
19.2 +++ b/samples/apifest1/day2/elementbasedsolution/src/org/netbeans/apifest/boolcircuit/Circuit.java Sat Jun 14 09:58:08 2008 +0200
19.3 @@ -1,3 +1,22 @@
19.4 +/*
19.5 + * The contents of this file are subject to the terms of the Common Development
19.6 + * and Distribution License (the License). You may not use this file except in
19.7 + * compliance with the License.
19.8 + *
19.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
19.10 + * or http://www.netbeans.org/cddl.txt.
19.11 + *
19.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
19.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
19.14 + * If applicable, add the following below the CDDL Header, with the fields
19.15 + * enclosed by brackets [] replaced by your own identifying information:
19.16 + * "Portions Copyrighted [year] [name of copyright owner]"
19.17 + *
19.18 + * The Original Software is NetBeans. The Initial Developer of the Original
19.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
19.20 + * Microsystems, Inc. All Rights Reserved.
19.21 + */
19.22 +
19.23 package org.netbeans.apifest.boolcircuit;
19.24
19.25 // BEGIN: apifest.day2.elementbasedsolution.Circuit
19.26 @@ -21,8 +40,7 @@
19.27 return e1.result() || e2.result();
19.28 }
19.29 public double doubleResult() {
19.30 - return 1.0 -
19.31 - (1.0 - e1.doubleResult()) * (1.0 - e2.doubleResult());
19.32 + return 1.0 - (1.0 - e1.doubleResult()) * (1.0 - e2.doubleResult());
19.33 }
19.34 };
19.35 }
19.36 @@ -38,9 +56,7 @@
19.37 };
19.38 }
19.39
19.40 - public static Element operation(
19.41 - final Operation op, final Element... elements
19.42 - ) {
19.43 + public static Element operation(final Operation op, final Element... elements) {
19.44 return new Element() {
19.45 public boolean result() {
19.46 return doubleResult() >= 1.0;
19.47 @@ -83,13 +99,11 @@
19.48 }
19.49
19.50 public boolean result() {
19.51 - return booleanValue != null ?
19.52 - booleanValue : doubleValue >= 1.0;
19.53 + return booleanValue != null ? booleanValue : doubleValue >= 1.0;
19.54 }
19.55
19.56 public double doubleResult() {
19.57 - return doubleValue != null ?
19.58 - doubleValue : (booleanValue ? 1.0 : 0.0);
19.59 + return doubleValue != null ? doubleValue : (booleanValue ? 1.0 : 0.0);
19.60 }
19.61
19.62 }
20.1 --- a/samples/apifest1/day2/inputandoperation/nbproject/build-impl.xml Sat Jun 14 09:58:05 2008 +0200
20.2 +++ b/samples/apifest1/day2/inputandoperation/nbproject/build-impl.xml Sat Jun 14 09:58:08 2008 +0200
20.3 @@ -19,7 +19,7 @@
20.4 - cleanup
20.5
20.6 -->
20.7 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="inputandoperation_-_day2-impl">
20.8 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="inputandoperation-impl">
20.9 <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
20.10 <!--
20.11 ======================
21.1 --- a/samples/apifest1/day2/inputandoperation/nbproject/genfiles.properties Sat Jun 14 09:58:05 2008 +0200
21.2 +++ b/samples/apifest1/day2/inputandoperation/nbproject/genfiles.properties Sat Jun 14 09:58:08 2008 +0200
21.3 @@ -1,5 +1,5 @@
21.4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
21.5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
21.6 -nbproject/build-impl.xml.data.CRC32=6bec2ae2
21.7 -nbproject/build-impl.xml.script.CRC32=8728834f
21.8 +nbproject/build-impl.xml.data.CRC32=835ca895
21.9 +nbproject/build-impl.xml.script.CRC32=d896881b
21.10 nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
22.1 --- a/samples/apifest1/day2/inputandoperation/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
22.2 +++ b/samples/apifest1/day2/inputandoperation/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
22.3 @@ -1,5 +1,3 @@
22.4 -application.title=inputandoperation - day2
22.5 -application.vendor=jarda
22.6 build.classes.dir=${build.dir}/classes
22.7 build.classes.excludes=**/*.java,**/*.form
22.8 # This directory is removed when the project is cleaned:
22.9 @@ -18,7 +16,6 @@
22.10 dist.jar=${dist.dir}/boolcircuit.jar
22.11 dist.javadoc.dir=${dist.dir}/javadoc
22.12 excludes=
22.13 -file.reference.junit-4.4.jar=../../../libs/dist/junit-4.4.jar
22.14 includes=**
22.15 jar.compress=false
22.16 javac.classpath=
22.17 @@ -30,7 +27,7 @@
22.18 javac.test.classpath=\
22.19 ${javac.classpath}:\
22.20 ${build.classes.dir}:\
22.21 - ${file.reference.junit-4.4.jar}
22.22 + ${libs.junit.classpath}
22.23 javadoc.additionalparam=
22.24 javadoc.author=false
22.25 javadoc.encoding=
22.26 @@ -42,6 +39,9 @@
22.27 javadoc.use=true
22.28 javadoc.version=false
22.29 javadoc.windowtitle=
22.30 +# Property libs.junit.classpath is set here just to make sharing of project simpler.
22.31 +# The library definition has always preference over this property.
22.32 +libs.junit.classpath=../../../../../usr/local/lib/netbeans/ide8/modules/ext/junit-3.8.2.jar
22.33 meta.inf.dir=${src.dir}/META-INF
22.34 platform.active=default_platform
22.35 run.classpath=\
23.1 --- a/samples/apifest1/day2/inputandoperation/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
23.2 +++ b/samples/apifest1/day2/inputandoperation/test/org/netbeans/apifest/boolcircuit/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
23.3 @@ -19,6 +19,13 @@
23.4
23.5 package org.netbeans.apifest.boolcircuit;
23.6
23.7 +import java.security.CodeSource;
23.8 +import java.security.Permission;
23.9 +import java.security.PermissionCollection;
23.10 +import java.security.Policy;
23.11 +import java.util.Collection;
23.12 +import java.util.Collections;
23.13 +import java.util.Enumeration;
23.14 import junit.framework.TestCase;
23.15 import junit.framework.*;
23.16
23.17 @@ -84,15 +91,11 @@
23.18 inTrue = Factory.createSimpleBooleanInput(true);
23.19 inFalse = Factory.createSimpleBooleanInput(false);
23.20 Operation op1 = Factory.createAndOperation(inFalse, inTrue);
23.21 - Operation op2 = Factory.createOrOperation(
23.22 - Factory.createOperationBasedBooleanInput(op1), inFalse
23.23 - );
23.24 + Operation op2 = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(op1), inFalse);
23.25 assertFalse(Circuit.evaluateBooleanOperation(op2));
23.26
23.27 op1 = Factory.createAndOperation(inFalse, inFalse);
23.28 - op2 = Factory.createOrOperation(
23.29 - Factory.createOperationBasedBooleanInput(op1), inTrue
23.30 - );
23.31 + op2 = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(op1), inTrue);
23.32 assertTrue(Circuit.evaluateBooleanOperation(op2));
23.33 }
23.34 /**
23.35 @@ -103,14 +106,10 @@
23.36 inTrue = Factory.createSimpleBooleanInput(true);
23.37 inFalse = Factory.createSimpleBooleanInput(false);
23.38 Operation not = Factory.createNotOperation(inTrue);
23.39 - Operation or = Factory.createOrOperation(
23.40 - Factory.createOperationBasedBooleanInput(not), inTrue
23.41 - );
23.42 + Operation or = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(not), inTrue);
23.43 assertTrue(Circuit.evaluateBooleanOperation(or));
23.44 not = Factory.createNotOperation(inFalse);
23.45 - or = Factory.createOrOperation(
23.46 - Factory.createOperationBasedBooleanInput(not), inFalse
23.47 - );
23.48 + or = Factory.createOrOperation(Factory.createOperationBasedBooleanInput(not), inFalse);
23.49 assertTrue(Circuit.evaluateBooleanOperation(or));
23.50 }
23.51
24.1 --- a/samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java Sat Jun 14 09:58:05 2008 +0200
24.2 +++ b/samples/apifest1/day2/pinbasedsolution/src/org/netbeans/apifest/boolcircuit/Element.java Sat Jun 14 09:58:08 2008 +0200
24.3 @@ -1,14 +1,22 @@
24.4 +/*
24.5 + * Element.java
24.6 + *
24.7 + * Created on 12. červenec 2006, 14:14
24.8 + *
24.9 + * To change this template, choose Tools | Template Manager
24.10 + * and open the template in the editor.
24.11 + */
24.12 +
24.13 package org.netbeans.apifest.boolcircuit;
24.14
24.15 /**
24.16 * Representation of an element in the circuit.
24.17 - * The internal behaviour of the element is opaque to the API user,
24.18 - * it can only be used as a building block for logical equations,
24.19 - * using primitive operation factories and a factory for input
24.20 - * pin representation.
24.21 - * Elements are chained to create the logical net.
24.22 - * The inputs to the net are represented by the elements created
24.23 - * by {@link #createInput(boolean[])} factory method.
24.24 + * The internal behaviour of the element is opaque to the API user, it can only
24.25 + * be used as a building block for logical equations, using primitive operation
24.26 + * factories and a factory for input pin representation.
24.27 + * Elements are chained to create the logical net. The inputs to the net are
24.28 + * represented by the elements created by {@link #createInput(boolean[])}
24.29 + * factory method.
24.30 */
24.31 public abstract class Element {
24.32
24.33 @@ -26,9 +34,7 @@
24.34 * Creates an Element representing 2-input AND function.
24.35 *
24.36 */
24.37 - public static Element createAnd(
24.38 - final Element source1, final Element source2
24.39 - ) {
24.40 + public static Element createAnd(final Element source1, final Element source2) {
24.41 return new Element() {
24.42 double evaluate(double[] inputs) {
24.43 return source1.evaluate(inputs) * source2.evaluate(inputs);
24.44 @@ -44,9 +50,7 @@
24.45 * Creates an Element representing 2-input OR function.
24.46 *
24.47 */
24.48 - public static Element createOr(
24.49 - final Element source1, final Element source2
24.50 - ) {
24.51 + public static Element createOr(final Element source1, final Element source2) {
24.52 return new Element() {
24.53 double evaluate(double[] inputs) {
24.54 double x = source1.evaluate(inputs);
24.55 @@ -96,17 +100,13 @@
24.56 /**
24.57 * Creates an Element with user-defined transfer function.
24.58 */
24.59 - public static Element createGate(
24.60 - final Element source1, final Element source2, final Function function
24.61 - ) {
24.62 + public static Element createGate(final Element source1, final Element source2, final Function function) {
24.63 return new Element() {
24.64 double evaluate(double[] inputs) {
24.65 double x = source1.evaluate(inputs);
24.66 double y = source2.evaluate(inputs);
24.67 double result = function.evaluate(x, y);
24.68 - if (result < 0.0 || result > 1.0) {
24.69 - throw new InternalError("Illegal gate function");
24.70 - }
24.71 + if (result < 0.0 || result > 1.0) throw new InternalError("Illegal gate function");
24.72 return result;
24.73 }
24.74
25.1 --- a/samples/apifest1/day2/stackbasedsolution/src/org/netbeans/apifest/boolcircuit/Circuit2.java Sat Jun 14 09:58:05 2008 +0200
25.2 +++ b/samples/apifest1/day2/stackbasedsolution/src/org/netbeans/apifest/boolcircuit/Circuit2.java Sat Jun 14 09:58:08 2008 +0200
25.3 @@ -1,3 +1,22 @@
25.4 +/*
25.5 + * The contents of this file are subject to the terms of the Common Development
25.6 + * and Distribution License (the License). You may not use this file except in
25.7 + * compliance with the License.
25.8 + *
25.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
25.10 + * or http://www.netbeans.org/cddl.txt.
25.11 + *
25.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
25.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
25.14 + * If applicable, add the following below the CDDL Header, with the fields
25.15 + * enclosed by brackets [] replaced by your own identifying information:
25.16 + * "Portions Copyrighted [year] [name of copyright owner]"
25.17 + *
25.18 + * The Original Software is NetBeans. The Initial Developer of the Original
25.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
25.20 + * Microsystems, Inc. All Rights Reserved.
25.21 + */
25.22 +
25.23 package org.netbeans.apifest.boolcircuit;
25.24
25.25 import java.util.Stack;
25.26 @@ -6,7 +25,6 @@
25.27 */
25.28 //BEGIN: apifest.day2.stackbasedsolution.Circuit2
25.29 public interface Circuit2 extends Circuit {
25.30 - public double evaluate (double ... input)
25.31 - throws IllegalArgumentException;
25.32 + public double evaluate (double ... input) throws IllegalArgumentException;
25.33 }
25.34 //END: apifest.day2.stackbasedsolution.Circuit2
26.1 --- a/samples/apifest1/day2/welltestedsolution/build.xml Sat Jun 14 09:58:05 2008 +0200
26.2 +++ b/samples/apifest1/day2/welltestedsolution/build.xml Sat Jun 14 09:58:08 2008 +0200
26.3 @@ -2,8 +2,8 @@
26.4 <!-- You may freely edit this file. See commented blocks below for -->
26.5 <!-- some examples of how to customize the build. -->
26.6 <!-- (If you delete it and reopen the project it will be recreated.) -->
26.7 -<project name="welltestedsolution_-_day2" default="default" basedir=".">
26.8 - <description>Builds, tests, and runs the project welltestedsolution - day2.</description>
26.9 +<project name="welltestedsolution" default="default" basedir=".">
26.10 + <description>Builds, tests, and runs the project welltestedsolution.</description>
26.11 <import file="nbproject/build-impl.xml"/>
26.12 <!--
26.13
26.14 @@ -54,7 +54,7 @@
26.15
26.16 An example of overriding the target for project execution could look like this:
26.17
26.18 - <target name="run" depends="welltestedsolution_-_day2-impl.jar">
26.19 + <target name="run" depends="welltestedsolution-impl.jar">
26.20 <exec dir="bin" executable="launcher.exe">
26.21 <arg file="${dist.jar}"/>
26.22 </exec>
27.1 --- a/samples/apifest1/day2/welltestedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:05 2008 +0200
27.2 +++ b/samples/apifest1/day2/welltestedsolution/nbproject/build-impl.xml Sat Jun 14 09:58:08 2008 +0200
27.3 @@ -19,7 +19,7 @@
27.4 - cleanup
27.5
27.6 -->
27.7 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="welltestedsolution_-_day2-impl">
27.8 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="welltestedsolution-impl">
27.9 <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
27.10 <!--
27.11 ======================
28.1 --- a/samples/apifest1/day2/welltestedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:05 2008 +0200
28.2 +++ b/samples/apifest1/day2/welltestedsolution/nbproject/genfiles.properties Sat Jun 14 09:58:08 2008 +0200
28.3 @@ -1,8 +1,8 @@
28.4 -build.xml.data.CRC32=645c53fa
28.5 -build.xml.script.CRC32=747792f9
28.6 +build.xml.data.CRC32=3022b908
28.7 +build.xml.script.CRC32=fdb77cae
28.8 build.xml.stylesheet.CRC32=be360661
28.9 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
28.10 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
28.11 -nbproject/build-impl.xml.data.CRC32=645c53fa
28.12 -nbproject/build-impl.xml.script.CRC32=e8210b65
28.13 +nbproject/build-impl.xml.data.CRC32=3022b908
28.14 +nbproject/build-impl.xml.script.CRC32=8c67cdf0
28.15 nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08
29.1 --- a/samples/apifest1/day2/welltestedsolution/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
29.2 +++ b/samples/apifest1/day2/welltestedsolution/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
29.3 @@ -1,5 +1,3 @@
29.4 -application.title=welltestedsolution - day2
29.5 -application.vendor=jarda
29.6 build.classes.dir=${build.dir}/classes
29.7 build.classes.excludes=**/*.java,**/*.form
29.8 # This directory is removed when the project is cleaned:
29.9 @@ -18,7 +16,6 @@
29.10 dist.jar=${dist.dir}/boolcircuit.jar
29.11 dist.javadoc.dir=${dist.dir}/javadoc
29.12 excludes=
29.13 -file.reference.junit-4.4.jar=../../../libs/dist/junit-4.4.jar
29.14 includes=**
29.15 jar.compress=false
29.16 javac.classpath=
29.17 @@ -30,7 +27,7 @@
29.18 javac.test.classpath=\
29.19 ${javac.classpath}:\
29.20 ${build.classes.dir}:\
29.21 - ${file.reference.junit-4.4.jar}
29.22 + ${libs.junit.classpath}
29.23 javadoc.additionalparam=
29.24 javadoc.author=false
29.25 javadoc.encoding=
29.26 @@ -42,6 +39,9 @@
29.27 javadoc.use=true
29.28 javadoc.version=false
29.29 javadoc.windowtitle=
29.30 +# Property libs.junit.classpath is set here just to make sharing of project simpler.
29.31 +# The library definition has always preference over this property.
29.32 +libs.junit.classpath=../../../../../usr/local/lib/netbeans/ide8/modules/ext/junit-3.8.2.jar
29.33 meta.inf.dir=${src.dir}/META-INF
29.34 platform.active=default_platform
29.35 run.classpath=\
30.1 --- a/samples/apifest1/day2/welltestedsolution/test/org/netbeans/apifest/boolcircuit/RealTest.java Sat Jun 14 09:58:05 2008 +0200
30.2 +++ b/samples/apifest1/day2/welltestedsolution/test/org/netbeans/apifest/boolcircuit/RealTest.java Sat Jun 14 09:58:08 2008 +0200
30.3 @@ -1,12 +1,37 @@
30.4 +/*
30.5 + * The contents of this file are subject to the terms of the Common Development
30.6 + * and Distribution License (the License). You may not use this file except in
30.7 + * compliance with the License.
30.8 + *
30.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
30.10 + * or http://www.netbeans.org/cddl.txt.
30.11 + *
30.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
30.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
30.14 + * If applicable, add the following below the CDDL Header, with the fields
30.15 + * enclosed by brackets [] replaced by your own identifying information:
30.16 + * "Portions Copyrighted [year] [name of copyright owner]"
30.17 + *
30.18 + * The Original Software is NetBeans. The Initial Developer of the Original
30.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30.20 + * Microsystems, Inc. All Rights Reserved.
30.21 + */
30.22 +
30.23 package org.netbeans.apifest.boolcircuit;
30.24
30.25 +import java.security.CodeSource;
30.26 +import java.security.Permission;
30.27 +import java.security.PermissionCollection;
30.28 +import java.security.Policy;
30.29 +import java.util.Collection;
30.30 +import java.util.Collections;
30.31 +import java.util.Enumeration;
30.32 import junit.framework.TestCase;
30.33 import junit.framework.*;
30.34 import org.netbeans.apifest.custom.Gte;
30.35
30.36 /** This file contains the APIFest quest for day 2. Simply, turn the
30.37 - * boolean circuit into circuit that can compute with double
30.38 - * values from 0 to 1.
30.39 + * boolean circuit into circuit that can compute with double values from 0 to 1.
30.40 * <p>
30.41 * This means that where ever a boolean was used to represent input or
30.42 * output values, one can now use any double number from >= 0 and <= 1.
30.43 @@ -17,15 +42,17 @@
30.44 * The basic elements has to be modified to work on doubles in the following
30.45 * way:
30.46 * <ul>
30.47 - * <li>negation - neg(x) = 1 - x
30.48 - * <li>and - and(x,y) = x * y
30.49 - * <li>or - or(x,y) = 1 - (1 - x) * (1 - y)
30.50 + * <li>negation - neg(x) = 1 - x, this is correct extension as neg(false)=neg(0)=1-0=1=true
30.51 + * <li>and - and(x,y) = x * y, again this is fine as and(true,true)=1*1=true and also
30.52 + * and(false,true)=0*1=0=false
30.53 + * <li>or - or(x,y) = 1 - (1 - x) * (1 - y) and this is also ok as
30.54 + * or(false,false) = 1 - (1 - 0) * (1 - 0) = 1 - 1 = 0 = false
30.55 + * or(true,false) = 1 - (1 - 1) * (1 - 0) = 1 - 0 * 1 = 1 = true
30.56 * </ul>
30.57 * <p>
30.58 - * However as the circuits with doubles are more rich than plain
30.59 - * boolean circuits, there is additional requirement to allow any user
30.60 - * of your API to write its own "element" type. This is all going to
30.61 - * be exercise in the tests bellow
30.62 + * However as the circuits with doubles are more rich than plain boolean circuits,
30.63 + * there is additional requirement to allow any user of your API to write its
30.64 + * own "element" type. This is all going to be exercise in the tests bellow
30.65 * which you are supposed to implement.
30.66 */
30.67 // BEGIN: apifest.day2.welltestedsolution.RealTest
30.68 @@ -51,33 +78,30 @@
30.69 *
30.70 * Feed this circuit with x1=true, x2=false, assert result is false
30.71 *
30.72 - * Feed the same circuit with x1=false, x2=true, assert result is
30.73 - * true
30.74 + * Feed the same circuit with x1=false, x2=true, assert result is true
30.75 *
30.76 * Feed the same circuit with x1=0.0, x2=1.0, assert result is 1.0
30.77 *
30.78 * Feed the same circuit with x1=0.5, x2=0.5, assert result is 0.625
30.79 *
30.80 - * Feed the same circuit with x1=0.0, x2=2.0
30.81 - * , make sure it throws an exception
30.82 + * Feed the same circuit with x1=0.0, x2=2.0, make sure it throws an exception
30.83 */
30.84 public void testX1andX2orNotX1() {
30.85 Circuit c = Circuit.createOrCircuit(
30.86 - Circuit.createAndCircuit(Circuit.input(0),
30.87 - Circuit.input(1)),
30.88 - Circuit.createNotCircuit(Circuit.input(0))
30.89 - );
30.90 + Circuit.createAndCircuit(Circuit.input(0), Circuit.input(1)),
30.91 + Circuit.createNotCircuit(Circuit.input(0))
30.92 + );
30.93 assertFalse("true, false", c.evaluate(true, false));
30.94 assertTrue("false, true", c.evaluate(false, true));
30.95 assertEquals("0.0, 1.0", 1.0, c.evaluateFuzzy(0.0, 1.0), 0.0);
30.96 }
30.97
30.98 - /** Ensure that one variable cannot be filled with two different
30.99 - * values. Create a circuit for x1 and x1. Make sure that for any
30.100 - * usage of your API that would not lead to x1 * x1 result, an
30.101 - * exception is thrown. For example if there was a way to feed the
30.102 - * circuit with two different values 0.3 and 0.5 an exception is
30.103 - * thrown indicating that this is improper use of the circuit.
30.104 + /** Ensure that one variable cannot be filled with two different values.
30.105 + * Create a circuit for x1 and x1. Make sure that for any usage of your
30.106 + * API that would not lead to x1 * x1 result, an exception is thrown.
30.107 + * For example if there was a way to feed the circuit with two different
30.108 + * values 0.3 and 0.5 an exception is thrown indicating that this is
30.109 + * improper use of the circuit.
30.110 */
30.111 public void testImproperUseOfTheCircuit() {
30.112 // does not apply
30.113 @@ -106,8 +130,7 @@
30.114 }
30.115 }
30.116
30.117 - /** Write your own element type called "gte" that
30.118 - * will have two inputs and one output.
30.119 + /** Write your own element type called "gte" that will have two inputs and one output.
30.120 * The output value will be 1 if x1 >= x2 and 0 otherwise.
30.121 *
30.122 * Create
30.123 @@ -121,10 +144,10 @@
30.124 */
30.125 public void testGreaterThanEqualElement() {
30.126 Circuit gte = new Gte(Circuit.createAndCircuit(
30.127 - Circuit.input(0),
30.128 - Circuit.createNotCircuit(Circuit.input(0))),
30.129 - Circuit.input(0)
30.130 - );
30.131 + Circuit.input(0),
30.132 + Circuit.createNotCircuit(Circuit.input(0))),
30.133 + Circuit.input(0)
30.134 + );
30.135 assertEquals("0.5", 0.0, gte.evaluateFuzzy(0.5), 0.0);
30.136 assertEquals("1.0", 0.0, gte.evaluateFuzzy(1.0), 0.0);
30.137 assertEquals("0.0", 1.0, gte.evaluateFuzzy(0.0), 0.0);
30.138 @@ -134,11 +157,11 @@
30.139 public void testSilly() {
30.140 // (x1 and not x2) or x3
30.141 Circuit c = Circuit.createOrCircuit(
30.142 - Circuit.createAndCircuit(
30.143 - null,
30.144 - Circuit.createNotCircuit(null)),
30.145 - null
30.146 - );
30.147 + Circuit.createAndCircuit(
30.148 + null,
30.149 + Circuit.createNotCircuit(null)),
30.150 + null
30.151 + );
30.152 assertEquals("1 1 1", 1.0, c.evaluateFuzzy(1.0, 1.0, 1.0), 0.0);
30.153 assertEquals("1 1 0", 0.0, c.evaluateFuzzy(1.0, 1.0, 0.0), 0.0);
30.154 assertEquals("1 0 1", 1.0, c.evaluateFuzzy(1.0, 0.0, 1.0), 0.0);
31.1 --- a/samples/apifest1/day3-intermezzo/pnejedly/against-alwayscreatenewcircuit/test/apifest/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
31.2 +++ b/samples/apifest1/day3-intermezzo/pnejedly/against-alwayscreatenewcircuit/test/apifest/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
31.3 @@ -14,8 +14,7 @@
31.4
31.5 public void testReallyUnrealistic() throws Exception {
31.6 // OK, this is not fair, right?
31.7 - assertEquals(null, Circuit.or(false, false).getClass().
31.8 - getSuperclass().getSuperclass().getSuperclass());
31.9 + assertEquals(null, Circuit.or(false, false).getClass().getSuperclass().getSuperclass().getSuperclass());
31.10 }
31.11 }
31.12 // END: apifest.day3.against-alwayscreatenewcircuit
32.1 --- a/samples/apifest1/day3-intermezzo/pnejedly/against-elementbasedsolution/test/apifest/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
32.2 +++ b/samples/apifest1/day3-intermezzo/pnejedly/against-elementbasedsolution/test/apifest/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
32.3 @@ -1,3 +1,43 @@
32.4 +/*
32.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
32.6 + *
32.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
32.8 + *
32.9 + * The contents of this file are subject to the terms of either the GNU
32.10 + * General Public License Version 2 only ("GPL") or the Common
32.11 + * Development and Distribution License("CDDL") (collectively, the
32.12 + * "License"). You may not use this file except in compliance with the
32.13 + * License. You can obtain a copy of the License at
32.14 + * http://www.netbeans.org/cddl-gplv2.html
32.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
32.16 + * specific language governing permissions and limitations under the
32.17 + * License. When distributing the software, include this License Header
32.18 + * Notice in each file and include the License file at
32.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
32.20 + * particular file as subject to the "Classpath" exception as provided
32.21 + * by Sun in the GPL Version 2 section of the License file that
32.22 + * accompanied this code. If applicable, add the following below the
32.23 + * License Header, with the fields enclosed by brackets [] replaced by
32.24 + * your own identifying information:
32.25 + * "Portions Copyrighted [year] [name of copyright owner]"
32.26 + *
32.27 + * Contributor(s):
32.28 + *
32.29 + * The Original Software is NetBeans. The Initial Developer of the Original
32.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
32.31 + * Microsystems, Inc. All Rights Reserved.
32.32 + *
32.33 + * If you wish your version of this file to be governed by only the CDDL
32.34 + * or only the GPL Version 2, indicate your decision by adding
32.35 + * "[Contributor] elects to include this software in this distribution
32.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
32.37 + * single choice of license, a recipient has the option to distribute
32.38 + * your version of this file under either the CDDL, the GPL Version 2 or
32.39 + * to extend the choice of license to its licensees as provided above.
32.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
32.41 + * Version 2 license, then the option applies only if the new code is
32.42 + * made subject to such option by the copyright holder.
32.43 + */
32.44 package apifest;
32.45
32.46 import junit.framework.TestCase;
32.47 @@ -12,8 +52,8 @@
32.48 super(n);
32.49 }
32.50 /**
32.51 - * OK, elementbasedsolution looked bulletproof. Every code path
32.52 - * was exactly the same as in the initial version. Except one.
32.53 + * OK, elementbasedsolution looked bulletproof. Every code path was exactly
32.54 + * the same as in the initial version. Except one.
32.55 */
32.56 public void testEvaluateWithoutAssign() throws Exception {
32.57 Circuit.Variable var = Circuit.var();
33.1 --- a/samples/apifest1/day3-intermezzo/pnejedly/against-welltestedsolution/test/apifest/CircuitTest.java Sat Jun 14 09:58:05 2008 +0200
33.2 +++ b/samples/apifest1/day3-intermezzo/pnejedly/against-welltestedsolution/test/apifest/CircuitTest.java Sat Jun 14 09:58:08 2008 +0200
33.3 @@ -14,12 +14,8 @@
33.4
33.5 public void testClass() throws Exception {
33.6 // OK, this is not fair as well.
33.7 - assertEquals("Created AND circuit", "AndCircuit",
33.8 - getName(Circuit.createAndCircuit(null, null))
33.9 - );
33.10 - assertEquals("Created OR circuit", "OrCircuit",
33.11 - getName(Circuit.createOrCircuit(null, null))
33.12 - );
33.13 + assertEquals("Created AND circuit", "AndCircuit", getName(Circuit.createAndCircuit(null, null)));
33.14 + assertEquals("Created OR circuit", "OrCircuit", getName(Circuit.createOrCircuit(null, null)));
33.15 }
33.16
33.17 private String getName(Object obj) {
34.1 --- a/samples/aserverinfo/src/org/apidesign/aserverinfo/AServerInfo.java Sat Jun 14 09:58:05 2008 +0200
34.2 +++ b/samples/aserverinfo/src/org/apidesign/aserverinfo/AServerInfo.java Sat Jun 14 09:58:08 2008 +0200
34.3 @@ -9,10 +9,7 @@
34.4 private final ResetHandler reset;
34.5 private final ShutdownHandler shutdown;
34.6
34.7 - private AServerInfo(
34.8 - NameProvider name, URLProvider url,
34.9 - ResetHandler reset, ShutdownHandler shutdown
34.10 - ) {
34.11 + private AServerInfo(NameProvider name, URLProvider url, ResetHandler reset, ShutdownHandler shutdown) {
34.12 this.name = name;
34.13 this.url = url;
34.14 this.reset = reset;
34.15 @@ -87,11 +84,7 @@
34.16 }
34.17
34.18 // BEGIN: aserverinfo.regularcreate
34.19 - public static AServerInfo create(
34.20 - NameProvider nameProvider,
34.21 - URLProvider urlProvider,
34.22 - ResetHandler reset
34.23 - )
34.24 + public static AServerInfo create(NameProvider nameProvider, URLProvider urlProvider, ResetHandler reset)
34.25 // END: aserverinfo.regularcreate
34.26 {
34.27 return new AServerInfo(nameProvider, urlProvider, reset, null);
34.28 @@ -104,12 +97,7 @@
34.29 }
34.30
34.31 /** @since 2.0 */
34.32 - public static AServerInfo create(
34.33 - NameProvider nameProvider,
34.34 - URLProvider urlProvider,
34.35 - ResetHandler reset,
34.36 - ShutdownHandler shutdown
34.37 - )
34.38 + public static AServerInfo create(NameProvider nameProvider, URLProvider urlProvider, ResetHandler reset, ShutdownHandler shutdown)
34.39 // END: aserverinfo.regularcreate.withshutdown
34.40 {
34.41 return new AServerInfo(nameProvider, urlProvider, reset, shutdown);
35.1 --- a/samples/aserverinfo/test/org/apidesign/aserverinfo/AServerInfoTest.java Sat Jun 14 09:58:05 2008 +0200
35.2 +++ b/samples/aserverinfo/test/org/apidesign/aserverinfo/AServerInfoTest.java Sat Jun 14 09:58:08 2008 +0200
35.3 @@ -23,17 +23,17 @@
35.4
35.5 @Test
35.6 public void showUseOfCumulativeFactory() throws Exception {
35.7 - Prov p = new Prov();
35.8 - AServerInfo inf;
35.9 + Prov prov = new Prov();
35.10 + AServerInfo info;
35.11
35.12 // BEGIN: aserverinfo.cumulative.creation
35.13 - inf = AServerInfo.empty().nameProvider(p).urlProvider(p).reset(p);
35.14 + info = AServerInfo.empty().nameProvider(prov).urlProvider(prov).reset(prov);
35.15 // END: aserverinfo.cumulative.creation
35.16
35.17 - assertEquals("API Design Server", inf.getName());
35.18 - assertEquals("http://www.apidesign.org", inf.getURL().toExternalForm());
35.19 - inf.reset();
35.20 - assertEquals("Once reset", 1, p.resets);
35.21 + assertEquals("API Design Server", info.getName());
35.22 + assertEquals("http://www.apidesign.org", info.getURL().toExternalForm());
35.23 + info.reset();
35.24 + assertEquals("Once reset", 1, prov.resets);
35.25
35.26 }
35.27
36.1 --- a/samples/build.xml Sat Jun 14 09:58:05 2008 +0200
36.2 +++ b/samples/build.xml Sat Jun 14 09:58:08 2008 +0200
36.3 @@ -10,6 +10,7 @@
36.4
36.5 <target name="clean">
36.6 <delete dir="${samples.dir}/build"/>
36.7 + <delete dir="${samples.dir}/libs/dist"/>
36.8 <subant target="clean" antfile="../build.xml">
36.9 <dirset refid="examples"/>
36.10 </subant>
37.1 --- a/samples/componentinjection/src/org/apidesign/component/property/ToolkitFactory.java Sat Jun 14 09:58:05 2008 +0200
37.2 +++ b/samples/componentinjection/src/org/apidesign/component/property/ToolkitFactory.java Sat Jun 14 09:58:08 2008 +0200
37.3 @@ -85,10 +85,7 @@
37.4 Class c = Class.forName (classname);
37.5 t = (java.awt.Toolkit)c.newInstance ();
37.6 } catch (Exception ex) {
37.7 - LOG.log(
37.8 - Level.WARNING,
37.9 - "Cannot initialize toolkit: " + classname, ex
37.10 - );
37.11 + LOG.log(Level.WARNING, "Cannot initialize toolkit: " + classname, ex);
37.12 }
37.13 }
37.14 // fallback
38.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionSlotChangesTest.java Sat Jun 14 09:58:05 2008 +0200
38.2 +++ b/samples/componentinjection/test/org/apidesign/component/InjectionSlotChangesTest.java Sat Jun 14 09:58:08 2008 +0200
38.3 @@ -41,8 +41,7 @@
38.4 }
38.5 }
38.6 Listener listener = new Listener();
38.7 - Lookup.Result<InjectionSlot> res =
38.8 - Lookup.getDefault().lookupResult(InjectionSlot.class);
38.9 + Lookup.Result<InjectionSlot> res = Lookup.getDefault().lookupResult(InjectionSlot.class);
38.10 res.addLookupListener(listener);
38.11 assertEquals("Two services now", 2, res.allInstances().size());
38.12
38.13 @@ -50,11 +49,7 @@
38.14
38.15 assertEquals("One service only", 1, res.allInstances().size());
38.16 assertEquals("One change in listener", 1, listener.cnt);
38.17 - assertEquals(
38.18 - "The second is ImplTwo",
38.19 - ImplTwo.class,
38.20 - res.allInstances().iterator().next().getClass()
38.21 - );
38.22 + assertEquals("The second is ImplTwo", ImplTwo.class, res.allInstances().iterator().next().getClass());
38.23 // END: lookup.listener
38.24 }
38.25
39.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionSlotTest.java Sat Jun 14 09:58:05 2008 +0200
39.2 +++ b/samples/componentinjection/test/org/apidesign/component/InjectionSlotTest.java Sat Jun 14 09:58:08 2008 +0200
39.3 @@ -14,8 +14,7 @@
39.4 @BeforeClass
39.5 public static void setUpClass() throws Exception {
39.6 // this is a support for "dynamic" registration of any class
39.7 - // into the global pool of Lookup.getDefault() and
39.8 - // java.util.ServiceLoader
39.9 + // into the global pool of Lookup.getDefault() and java.util.ServiceLoader
39.10 // either in @BeforeClass or @Before register
39.11 // classes of the mock instances that you want your code
39.12 // to find
39.13 @@ -26,23 +25,16 @@
39.14 public void singleSlot() {
39.15 InjectionSlot result = InjectionSlot.singleSlot();
39.16 assertNotNull("Some result found", result);
39.17 - assertEquals(
39.18 - "The first is ImplOne", ImplOne.class, result.getClass()
39.19 - );
39.20 + assertEquals("The first is ImplOne", ImplOne.class, result.getClass());
39.21 }
39.22
39.23 @Test
39.24 public void multiSlot() {
39.25 - Iterator<? extends InjectionSlot> it =
39.26 - InjectionSlot.multiSlot().iterator();
39.27 + Iterator<? extends InjectionSlot> it = InjectionSlot.multiSlot().iterator();
39.28 assertTrue("Has at least one", it.hasNext());
39.29 - assertEquals(
39.30 - "The first is ImplOne", ImplOne.class, it.next().getClass()
39.31 - );
39.32 + assertEquals("The first is ImplOne", ImplOne.class, it.next().getClass());
39.33 assertTrue("Has two", it.hasNext());
39.34 - assertEquals(
39.35 - "The second is ImplTwo", ImplTwo.class, it.next().getClass()
39.36 - );
39.37 + assertEquals("The second is ImplTwo", ImplTwo.class, it.next().getClass());
39.38 assertFalse("No other instance registered", it.hasNext());
39.39 }
39.40
40.1 --- a/samples/componentinjection/test/org/apidesign/component/InjectionViaServiceLoaderTest.java Sat Jun 14 09:58:05 2008 +0200
40.2 +++ b/samples/componentinjection/test/org/apidesign/component/InjectionViaServiceLoaderTest.java Sat Jun 14 09:58:08 2008 +0200
40.3 @@ -14,8 +14,7 @@
40.4 @BeforeClass
40.5 public static void setUpClass() throws Exception {
40.6 // this is a support for "dynamic" registration of any class
40.7 - // into the global pool of Lookup.getDefault() and
40.8 - // java.util.ServiceLoader
40.9 + // into the global pool of Lookup.getDefault() and java.util.ServiceLoader
40.10 // either in @BeforeClass or @Before register
40.11 // classes of the mock instances that you want your code
40.12 // to find
40.13 @@ -26,23 +25,16 @@
40.14 public void singleSlot() {
40.15 InjectionSlot result = InjectionViaServiceLoader.singleSlot();
40.16 assertNotNull("Some result found", result);
40.17 - assertEquals(
40.18 - "The first is ImplOne", ImplOne.class, result.getClass()
40.19 - );
40.20 + assertEquals("The first is ImplOne", ImplOne.class, result.getClass());
40.21 }
40.22
40.23 @Test
40.24 public void multiSlot() {
40.25 - Iterator<? extends InjectionSlot> it =
40.26 - InjectionViaServiceLoader.multiSlot().iterator();
40.27 + Iterator<? extends InjectionSlot> it = InjectionViaServiceLoader.multiSlot().iterator();
40.28 assertTrue("Has at least one", it.hasNext());
40.29 - assertEquals(
40.30 - "The first is ImplOne", ImplOne.class, it.next().getClass()
40.31 - );
40.32 + assertEquals("The first is ImplOne", ImplOne.class, it.next().getClass());
40.33 assertTrue("Has two", it.hasNext());
40.34 - assertEquals(
40.35 - "The second is ImplTwo", ImplTwo.class, it.next().getClass()
40.36 - );
40.37 + assertEquals("The second is ImplTwo", ImplTwo.class, it.next().getClass());
40.38 assertFalse("No other instance registered", it.hasNext());
40.39 }
40.40
41.1 --- a/samples/composition/build.xml Sat Jun 14 09:58:05 2008 +0200
41.2 +++ b/samples/composition/build.xml Sat Jun 14 09:58:08 2008 +0200
41.3 @@ -12,15 +12,6 @@
41.4 <antcall target="-build-one">
41.5 <param name="version" value="api2.0"/>
41.6 </antcall>
41.7 - <antcall target="-build-one">
41.8 - <param name="version" value="api2.0-compat"/>
41.9 - </antcall>
41.10 - <antcall target="-build-one">
41.11 - <param name="version" value="api2.0-property"/>
41.12 - </antcall>
41.13 - <antcall target="-build-one">
41.14 - <param name="version" value="api2.0-enum"/>
41.15 - </antcall>
41.16
41.17 <antcall target="-build-one">
41.18 <param name="version" value="test"/>
41.19 @@ -37,18 +28,6 @@
41.20 <antcall target="-run-one">
41.21 <param name="version" value="api2.0"/>
41.22 </antcall>
41.23 - <echo level="info" message="Running the Implementation against Version 2.0 with compatible extension of the API. This should succeed."/>
41.24 - <antcall target="-run-one">
41.25 - <param name="version" value="api2.0-compat"/>
41.26 - </antcall>
41.27 - <echo level="info" message="Running the Implementation against Version 2.0 with property guarded extension of the API. This should succeed."/>
41.28 - <antcall target="-run-one">
41.29 - <param name="version" value="api2.0-property"/>
41.30 - </antcall>
41.31 - <echo level="info" message="Running the Implementation against Version 2.0 with enum guarded extension of the API. This should succeed."/>
41.32 - <antcall target="-run-one">
41.33 - <param name="version" value="api2.0-enum"/>
41.34 - </antcall>
41.35 </target>
41.36
41.37 <!-- support methods -->
42.1 --- a/samples/composition/nbproject/project.xml Sat Jun 14 09:58:05 2008 +0200
42.2 +++ b/samples/composition/nbproject/project.xml Sat Jun 14 09:58:08 2008 +0200
42.3 @@ -23,29 +23,11 @@
42.4 <encoding>UTF-8</encoding>
42.5 </source-folder>
42.6 <source-folder>
42.7 - <label>src-api2.0-compat</label>
42.8 - <type>java</type>
42.9 - <location>src-api2.0-compat</location>
42.10 - <encoding>UTF-8</encoding>
42.11 - </source-folder>
42.12 - <source-folder>
42.13 - <label>src-api2.0-property</label>
42.14 - <type>java</type>
42.15 - <location>src-api2.0-property</location>
42.16 - <encoding>UTF-8</encoding>
42.17 - </source-folder>
42.18 - <source-folder>
42.19 <label>test</label>
42.20 <type>java</type>
42.21 <location>src-test</location>
42.22 <encoding>UTF-8</encoding>
42.23 </source-folder>
42.24 - <source-folder>
42.25 - <label>src-api2.0-enum</label>
42.26 - <type>java</type>
42.27 - <location>src-api2.0-enum</location>
42.28 - <encoding>UTF-8</encoding>
42.29 - </source-folder>
42.30 </folders>
42.31 <ide-actions>
42.32 <action name="build">
42.33 @@ -57,9 +39,6 @@
42.34 <action name="test">
42.35 <target>test</target>
42.36 </action>
42.37 - <action name="run">
42.38 - <target>test</target>
42.39 - </action>
42.40 <action name="rebuild">
42.41 <target>clean</target>
42.42 <target>build</target>
42.43 @@ -76,18 +55,6 @@
42.44 <location>src-api2.0</location>
42.45 </source-folder>
42.46 <source-folder style="packages">
42.47 - <label>API Version 2.0, in compatible style</label>
42.48 - <location>src-api2.0-compat</location>
42.49 - </source-folder>
42.50 - <source-folder style="packages">
42.51 - <label>API Version 2.0, with property</label>
42.52 - <location>src-api2.0-property</location>
42.53 - </source-folder>
42.54 - <source-folder style="packages">
42.55 - <label>API Version 2.0, with enum</label>
42.56 - <location>src-api2.0-enum</location>
42.57 - </source-folder>
42.58 - <source-folder style="packages">
42.59 <label>Usage of the API</label>
42.60 <location>src-test</location>
42.61 </source-folder>
42.62 @@ -98,7 +65,6 @@
42.63 <context-menu>
42.64 <ide-action name="build"/>
42.65 <ide-action name="rebuild"/>
42.66 - <ide-action name="run"/>
42.67 <ide-action name="clean"/>
42.68 <ide-action name="test"/>
42.69 </context-menu>
42.70 @@ -114,18 +80,6 @@
42.71 <source-level>1.5</source-level>
42.72 </compilation-unit>
42.73 <compilation-unit>
42.74 - <package-root>src-api2.0-compat</package-root>
42.75 - <source-level>1.5</source-level>
42.76 - </compilation-unit>
42.77 - <compilation-unit>
42.78 - <package-root>src-api2.0-enum</package-root>
42.79 - <source-level>1.5</source-level>
42.80 - </compilation-unit>
42.81 - <compilation-unit>
42.82 - <package-root>src-api2.0-property</package-root>
42.83 - <source-level>1.5</source-level>
42.84 - </compilation-unit>
42.85 - <compilation-unit>
42.86 <package-root>src-test</package-root>
42.87 <classpath mode="compile">src-api1.0:../libs/dist/junit-4.4.jar</classpath>
42.88 <source-level>1.5</source-level>
43.1 --- a/samples/conditionaluseofapi/src/conditionaluseofapi/Main.java Sat Jun 14 09:58:05 2008 +0200
43.2 +++ b/samples/conditionaluseofapi/src/conditionaluseofapi/Main.java Sat Jun 14 09:58:08 2008 +0200
43.3 @@ -24,10 +24,7 @@
43.4
43.5 try {
43.6 Class onlyOn15 = Class.forName("java.lang.StringBuilder");
43.7 - Class codeOn15 = Class.forName(
43.8 - "conditionaluseofapi.StringBuilderAdd15"
43.9 - );
43.10 - add = (AddString)codeOn15.newInstance();
43.11 + add = (AddString)Class.forName("conditionaluseofapi.StringBuilderAdd15").newInstance();
43.12 } catch (ClassNotFoundException ex) {
43.13 add = new StringBufferAdd();
43.14 }
44.1 --- a/samples/consistency/src-api1.0/api/Lookup.java Sat Jun 14 09:58:05 2008 +0200
44.2 +++ b/samples/consistency/src-api1.0/api/Lookup.java Sat Jun 14 09:58:08 2008 +0200
44.3 @@ -20,9 +20,7 @@
44.4 // END: design.consistency.lookupAll.1.0
44.5
44.6 // BEGIN: design.consistency.lookupAllClasses.1.0
44.7 - public abstract <T> Set<Class<? extends T>> lookupAllClasses(
44.8 - Class<T> clazz
44.9 - );
44.10 + public abstract <T> Set<Class<? extends T>> lookupAllClasses(Class<T> clazz);
44.11 // END: design.consistency.lookupAllClasses.1.0
44.12 }
44.13 // END: design.consistency.1.0
45.1 --- a/samples/deadlock/src/org/apidesign/deadlock/logs/OverrideMePlease.java Sat Jun 14 09:58:05 2008 +0200
45.2 +++ b/samples/deadlock/src/org/apidesign/deadlock/logs/OverrideMePlease.java Sat Jun 14 09:58:08 2008 +0200
45.3 @@ -11,9 +11,7 @@
45.4 }
45.5 // BEGIN: logs.override
45.6 protected boolean overideMePlease() {
45.7 - Logger.getLogger(OverrideMePlease.class.getName()).warning(
45.8 - "subclasses are supposed to override overideMePlease() method!"
45.9 - );
45.10 + Logger.getLogger(OverrideMePlease.class.getName()).warning("subclasses are supposed to override overideMePlease() method!");
45.11 // some default
45.12 return true;
45.13 }
46.1 --- a/samples/deadlock/src/org/apidesign/deadlock/startuplock/CLIHandler.java Sat Jun 14 09:58:05 2008 +0200
46.2 +++ b/samples/deadlock/src/org/apidesign/deadlock/startuplock/CLIHandler.java Sat Jun 14 09:58:08 2008 +0200
46.3 @@ -19,9 +19,7 @@
46.4 }
46.5 // otherwise try to create the file yourself
46.6 lockFile.createNewFile();
46.7 - DataOutputStream os = new DataOutputStream(
46.8 - new FileOutputStream(lockFile)
46.9 - );
46.10 + DataOutputStream os = new DataOutputStream(new FileOutputStream(lockFile));
46.11 ServerSocket server = new ServerSocket();
46.12 int p = server.getLocalPort();
46.13 os.writeInt(p);
47.1 --- a/samples/deadlock/src/org/apidesign/deadlock/startuplock/CLIHandlerBlocking.java Sat Jun 14 09:58:05 2008 +0200
47.2 +++ b/samples/deadlock/src/org/apidesign/deadlock/startuplock/CLIHandlerBlocking.java Sat Jun 14 09:58:08 2008 +0200
47.3 @@ -24,9 +24,7 @@
47.4 // otherwise try to create the file yourself
47.5 enterState(20);
47.6 lockFile.createNewFile();
47.7 - DataOutputStream os = new DataOutputStream(
47.8 - new FileOutputStream(lockFile)
47.9 - );
47.10 + DataOutputStream os = new DataOutputStream(new FileOutputStream(lockFile));
47.11 ServerSocket server = new ServerSocket();
47.12 enterState(21);
47.13 int p = server.getLocalPort();
48.1 --- a/samples/deadlock/test/org/apidesign/deadlock/DeadlockTest.java Sat Jun 14 09:58:05 2008 +0200
48.2 +++ b/samples/deadlock/test/org/apidesign/deadlock/DeadlockTest.java Sat Jun 14 09:58:08 2008 +0200
48.3 @@ -14,9 +14,7 @@
48.4
48.5 // BEGIN: deadlock.test
48.6 public class DeadlockTest extends NbTestCase {
48.7 - static final Logger LOG = Logger.getLogger(
48.8 - DeadlockTest.class.getName()
48.9 - );
48.10 + static final Logger LOG = Logger.getLogger(DeadlockTest.class.getName());
48.11
48.12 public DeadlockTest(String n) {
48.13 super(n);
48.14 @@ -36,10 +34,7 @@
48.15 JLabel sampleLabel = createLabel();
48.16 return sampleLabel.getPreferredSize();
48.17 } catch (InterruptedException ex) {
48.18 - Logger l = Logger.getLogger(
48.19 - DeadlockTest.class.getName()
48.20 - );
48.21 - l.log(Level.SEVERE, null, ex);
48.22 + Logger.getLogger(DeadlockTest.class.getName()).log(Level.SEVERE, null, ex);
48.23 return super.getPreferredSize();
48.24 }
48.25 }
49.1 --- a/samples/deadlock/test/org/apidesign/deadlock/LabelProviderTest.java Sat Jun 14 09:58:05 2008 +0200
49.2 +++ b/samples/deadlock/test/org/apidesign/deadlock/LabelProviderTest.java Sat Jun 14 09:58:08 2008 +0200
49.3 @@ -13,9 +13,7 @@
49.4
49.5 // BEGIN: deadlock.test.controlflow
49.6 public class LabelProviderTest extends NbTestCase {
49.7 - static final Logger LOG = Logger.getLogger(
49.8 - LabelProviderTest.class.getName()
49.9 - );
49.10 + static final Logger LOG = Logger.getLogger(LabelProviderTest.class.getName());
49.11
49.12 public LabelProviderTest(String n) {
49.13 super(n);
50.1 --- a/samples/deadlock/test/org/apidesign/deadlock/logs/ParallelSortedTest.java Sat Jun 14 09:58:05 2008 +0200
50.2 +++ b/samples/deadlock/test/org/apidesign/deadlock/logs/ParallelSortedTest.java Sat Jun 14 09:58:08 2008 +0200
50.3 @@ -37,8 +37,7 @@
50.4 if (!record.getMessage().startsWith("cnt")) {
50.5 return;
50.6 }
50.7 - boolean snd = Thread.currentThread().getName().equals("2nd");
50.8 - if (runSecond == snd) {
50.9 + if (runSecond == Thread.currentThread().getName().equals("2nd")) {
50.10 notify();
50.11 runSecond = !runSecond;
50.12 }
51.1 --- a/samples/deadlock/test/org/apidesign/deadlock/startuplock/CLIHandlerBlockingTest.java Sat Jun 14 09:58:05 2008 +0200
51.2 +++ b/samples/deadlock/test/org/apidesign/deadlock/startuplock/CLIHandlerBlockingTest.java Sat Jun 14 09:58:08 2008 +0200
51.3 @@ -52,5 +52,5 @@
51.4 public void close() throws SecurityException {
51.5 }
51.6 } // end of H
51.7 -}
51.8 // END: test.capture.logs
51.9 +}
51.10 \ No newline at end of file
52.1 --- a/samples/delegatingwriter/nbproject/project.properties Sat Jun 14 09:58:05 2008 +0200
52.2 +++ b/samples/delegatingwriter/nbproject/project.properties Sat Jun 14 09:58:08 2008 +0200
52.3 @@ -1,5 +1,3 @@
52.4 -application.title=delegatingwriter
52.5 -application.vendor=jarda
52.6 build.classes.dir=${build.dir}/classes
52.7 build.classes.excludes=**/*.java,**/*.form
52.8 # This directory is removed when the project is cleaned:
52.9 @@ -18,7 +16,6 @@
52.10 dist.jar=${dist.dir}/delegatingwriter.jar
52.11 dist.javadoc.dir=${dist.dir}/javadoc
52.12 excludes=
52.13 -file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar
52.14 includes=**
52.15 jar.compress=false
52.16 javac.classpath=
52.17 @@ -30,7 +27,8 @@
52.18 javac.test.classpath=\
52.19 ${javac.classpath}:\
52.20 ${build.classes.dir}:\
52.21 - ${file.reference.junit-4.4.jar}
52.22 + ${libs.junit.classpath}:\
52.23 + ${libs.junit_4.classpath}
52.24 javadoc.additionalparam=
52.25 javadoc.author=false
52.26 javadoc.encoding=${source.encoding}
53.1 --- a/samples/delegatingwriter/src/org/apidesign/delegatingwriter/AltBufferedWriter.java Sat Jun 14 09:58:05 2008 +0200
53.2 +++ b/samples/delegatingwriter/src/org/apidesign/delegatingwriter/AltBufferedWriter.java Sat Jun 14 09:58:08 2008 +0200
53.3 @@ -1,3 +1,8 @@
53.4 +/*
53.5 + * To change this template, choose Tools | Templates
53.6 + * and open the template in the editor.
53.7 + */
53.8 +
53.9 package org.apidesign.delegatingwriter;
53.10
53.11 import java.io.BufferedWriter;
53.12 @@ -28,25 +33,18 @@
53.13 @Override
53.14 public Writer append(CharSequence csq) throws IOException {
53.15 switch (behaviour) {
53.16 - case THROW_EXCEPTION:
53.17 - return appendThrowException(csq);
53.18 - case DELEGATE_TO_SUPER:
53.19 - return appendDelegateToSuper(csq);
53.20 - case DELEGATE_TO_OUT:
53.21 - return appendDelegateToUnderlaying(csq);
53.22 - case DELEGATE_CONDITIONALLY:
53.23 - return appendDelegateConditionally(csq);
53.24 - default:
53.25 - throw new IllegalStateException("Unknown" + behaviour);
53.26 + case THROW_EXCEPTION: return appendThrowException(csq);
53.27 + case DELEGATE_TO_SUPER: return appendDelegateToSuper(csq);
53.28 + case DELEGATE_TO_OUT: return appendDelegateToUnderlaying(csq);
53.29 + case DELEGATE_CONDITIONALLY: return appendDelegateConditionally(csq);
53.30 + default: throw new IllegalStateException("Unknown" + behaviour);
53.31 }
53.32 }
53.33
53.34 public Writer appendThrowException(CharSequence csq) throws IOException {
53.35 - /* in case of real code, this would be part of
53.36 - the regular append method. BEGIN: writer.throw
53.37 + /* in case of real code, this would be part of the regular append method BEGIN: writer.throw
53.38 public Writer append(CharSequence csq) throws IOException {
53.39 - /* thrown an exception as this method is new and
53.40 - subclasses need to override it */
53.41 + /* thrown an exception as this method is new and subclasses need to override it */
53.42 throw new UnsupportedOperationException();
53.43 }
53.44 // END: writer.throw
53.45 @@ -78,27 +76,14 @@
53.46 // END: writer.delegateout
53.47 }
53.48
53.49 - private Writer appendDelegateConditionally(CharSequence csq)
53.50 - throws IOException {
53.51 + private Writer appendDelegateConditionally(CharSequence csq) throws IOException {
53.52 // BEGIN: writer.conditionally
53.53 boolean isOverriden = false;
53.54 try {
53.55 isOverriden =
53.56 - (
53.57 - getClass().getMethod(
53.58 - "write", String.class
53.59 - ).getDeclaringClass() != Writer.class
53.60 - ) ||
53.61 - (
53.62 - getClass().getMethod(
53.63 - "write", Integer.TYPE
53.64 - ).getDeclaringClass() != BufferedWriter.class
53.65 - ) ||
53.66 - (
53.67 - getClass().getMethod(
53.68 - "write", String.class, Integer.TYPE, Integer.TYPE
53.69 - ).getDeclaringClass() != BufferedWriter.class
53.70 - );
53.71 + (getClass().getMethod("write", String.class).getDeclaringClass() != Writer.class) ||
53.72 + (getClass().getMethod("write", Integer.TYPE).getDeclaringClass() != BufferedWriter.class) ||
53.73 + (getClass().getMethod("write", String.class, Integer.TYPE, Integer.TYPE).getDeclaringClass() != BufferedWriter.class);
53.74 } catch (Exception ex) {
53.75 throw new IOException(ex);
53.76 }
53.77 @@ -114,9 +99,6 @@
53.78 }
53.79
53.80 public enum Behaviour {
53.81 - THROW_EXCEPTION,
53.82 - DELEGATE_TO_SUPER,
53.83 - DELEGATE_TO_OUT,
53.84 - DELEGATE_CONDITIONALLY
53.85 + THROW_EXCEPTION, DELEGATE_TO_SUPER, DELEGATE_TO_OUT, DELEGATE_CONDITIONALLY
53.86 }
53.87 }
54.1 --- a/samples/delegatingwriter/test/org/apidesign/delegatingwriter/BufferedWriterOnCDImageTest.java Sat Jun 14 09:58:05 2008 +0200
54.2 +++ b/samples/delegatingwriter/test/org/apidesign/delegatingwriter/BufferedWriterOnCDImageTest.java Sat Jun 14 09:58:08 2008 +0200
54.3 @@ -23,10 +23,7 @@
54.4 CDSequence cdImage = new CDSequence();
54.5 BufferedWriter bufferedWriter = new BufferedWriter(writer);
54.6 bufferedWriter.append(cdImage);
54.7 - assertEquals(
54.8 - "Correct number of writes delegated",
54.9 - cdImage.length(), writer.getCharacterCount()
54.10 - );
54.11 + assertEquals("Correct number of writes delegated", cdImage.length(), writer.getCharacterCount());
54.12 // END: writer.countcd
54.13 }
54.14
54.15 @@ -34,30 +31,18 @@
54.16 public void testBehaviourOfBufferThatDelegatesToAppend() throws IOException {
54.17 CountingWriter writer = new CountingWriter();
54.18 CDSequence cdImage = new CDSequence();
54.19 - BufferedWriter bufferedWriter = new AltBufferedWriter(
54.20 - writer, AltBufferedWriter.Behaviour.DELEGATE_TO_OUT
54.21 - );
54.22 + BufferedWriter bufferedWriter = new AltBufferedWriter(writer, AltBufferedWriter.Behaviour.DELEGATE_TO_OUT);
54.23 bufferedWriter.append(cdImage);
54.24 - assertEquals(
54.25 - "Correct number of writes delegated",
54.26 - cdImage.length(),
54.27 - writer.getCharacterCount()
54.28 - );
54.29 + assertEquals("Correct number of writes delegated", cdImage.length(), writer.getCharacterCount());
54.30 }
54.31
54.32 @Test
54.33 public void testBehaviourWhenDelegatingConditionallyIsOK() throws IOException {
54.34 CountingWriter writer = new CountingWriter();
54.35 CDSequence cdImage = new CDSequence();
54.36 - BufferedWriter bufferedWriter = new AltBufferedWriter(
54.37 - writer, AltBufferedWriter.Behaviour.DELEGATE_CONDITIONALLY
54.38 - );
54.39 + BufferedWriter bufferedWriter = new AltBufferedWriter(writer, AltBufferedWriter.Behaviour.DELEGATE_CONDITIONALLY);
54.40 bufferedWriter.append(cdImage);
54.41 - assertEquals(
54.42 - "Correct number of writes delegated",
54.43 - cdImage.length(),
54.44 - writer.getCharacterCount()
54.45 - );
54.46 + assertEquals("Correct number of writes delegated", cdImage.length(), writer.getCharacterCount());
54.47 }
54.48
54.49
54.50 @@ -82,7 +67,7 @@
54.51 public int length() {
54.52 return end - start;
54.53 }
54.54 -// FINISH: writer.bigseq
54.55 +// END: writer.bigseq
54.56
54.57 public char charAt(int index) {
54.58 int ch = index % ('Z' - 'A' + 1);
55.1 --- a/samples/delegatingwriter/test/org/apidesign/delegatingwriter/CountingWriter.java Sat Jun 14 09:58:05 2008 +0200
55.2 +++ b/samples/delegatingwriter/test/org/apidesign/delegatingwriter/CountingWriter.java Sat Jun 14 09:58:08 2008 +0200
55.3 @@ -27,7 +27,7 @@
55.4 counter += csq.length();
55.5 return this;
55.6 }
55.7 -// FINISH: writer.CountingWriter
55.8 +// END: writer.CountingWriter
55.9
55.10 @Override
55.11 public Writer append(CharSequence csq, int start, int end) throws IOException {
56.1 --- a/samples/delegatingwriter/test/org/apidesign/delegatingwriter/CryptoWriter.java Sat Jun 14 09:58:05 2008 +0200
56.2 +++ b/samples/delegatingwriter/test/org/apidesign/delegatingwriter/CryptoWriter.java Sat Jun 14 09:58:08 2008 +0200
56.3 @@ -13,9 +13,7 @@
56.4 public CryptoWriter(Writer out) {
56.5 super(out);
56.6 }
56.7 - public CryptoWriter(
56.8 - Writer out, AltBufferedWriter.Behaviour behaviour
56.9 - ) {
56.10 + public CryptoWriter(Writer out, AltBufferedWriter.Behaviour behaviour) {
56.11 super(out, behaviour);
56.12 }
56.13 /* The above code is here to let us simulate different behaviours of the append
56.14 @@ -26,15 +24,15 @@
56.15 super(out);
56.16 }
56.17
56.18 - /* We need to override all known methods of BufferedWriter
56.19 - * and do conversion of the argument char, string or char array.
56.20 + /* We need to override all known methods of BufferedWriter and do conversion
56.21 + * of the argument char, string or char array.
56.22 */
56.23
56.24 @Override
56.25 - public void write(char[] buf, int off, int len) throws IOException {
56.26 + public void write(char[] cbuf, int off, int len) throws IOException {
56.27 char[] arr = new char[len];
56.28 for (int i = 0; i < len; i++) {
56.29 - arr[i] = convertChar(buf[off + i]);
56.30 + arr[i] = convertChar(cbuf[off + i]);
56.31 }
56.32 super.write(arr, 0, len);
56.33 }
56.34 @@ -62,7 +60,7 @@
56.35 }
56.36 return (char)(c + 1);
56.37 }
56.38 -// FINISH: writer.CryptoWriter
56.39 +// END: writer.CryptoWriter
56.40
56.41 /* delegates to write(cbuf, 0, cbuf.length)
56.42 public void write(char[] cbuf) throws IOException {
57.1 --- a/samples/delegatingwriterfinal/src-api1.0/api/Writer.java Sat Jun 14 09:58:05 2008 +0200
57.2 +++ b/samples/delegatingwriterfinal/src-api1.0/api/Writer.java Sat Jun 14 09:58:08 2008 +0200
57.3 @@ -22,15 +22,13 @@
57.4 public final void write(char cbuf[]) throws IOException {
57.5 impl.write(cbuf, 0, cbuf.length);
57.6 }
57.7 - public final void write(char cbuf[], int off, int len)
57.8 - throws IOException {
57.9 + public final void write(char cbuf[], int off, int len) throws IOException {
57.10 impl.write(cbuf, off, len);
57.11 }
57.12 public final void write(String str) throws IOException {
57.13 impl.write(str, 0, str.length());
57.14 }
57.15 - public final void write(String str, int off, int len)
57.16 - throws IOException {
57.17 + public final void write(String str, int off, int len) throws IOException {
57.18 impl.write(str, off, len);
57.19 }
57.20 public final void flush() throws IOException {
57.21 @@ -46,13 +44,11 @@
57.22
57.23 public static Writer create(final java.io.Writer w) {
57.24 return new Writer(new Impl() {
57.25 - public void write(String str, int off, int len)
57.26 - throws IOException {
57.27 + public void write(String str, int off, int len) throws IOException {
57.28 w.write(str, off, len);
57.29 }
57.30
57.31 - public void write(char[] arr, int off, int len)
57.32 - throws IOException {
57.33 + public void write(char[] arr, int off, int len) throws IOException {
57.34 w.write(arr, off, len);
57.35 }
57.36
57.37 @@ -74,8 +70,8 @@
57.38 public static interface Impl {
57.39 public void close() throws IOException;
57.40 public void flush() throws IOException;
57.41 - public void write(String s, int off, int len) throws IOException;
57.42 - public void write(char[] a, int off, int len) throws IOException;
57.43 + public void write(String str, int off, int len) throws IOException;
57.44 + public void write(char[] arr, int off, int len) throws IOException;
57.45 }
57.46 }
57.47 // END: writer.final.1.0
58.1 --- a/samples/delegatingwriterfinal/src-api2.0/api/Writer.java Sat Jun 14 09:58:05 2008 +0200
58.2 +++ b/samples/delegatingwriterfinal/src-api2.0/api/Writer.java Sat Jun 14 09:58:08 2008 +0200
58.3 @@ -32,8 +32,7 @@
58.4 seq.write(new CharSeq(cbuf, 0, cbuf.length));
58.5 }
58.6 }
58.7 - public final void write(char cbuf[], int off, int len)
58.8 - throws IOException {
58.9 + public final void write(char cbuf[], int off, int len) throws IOException {
58.10 if (impl != null) {
58.11 impl.write(cbuf, off, len);
58.12 } else {
58.13 @@ -47,8 +46,7 @@
58.14 seq.write(str);
58.15 }
58.16 }
58.17 - public final void write(String str, int off, int len)
58.18 - throws IOException {
58.19 + public final void write(String str, int off, int len) throws IOException {
58.20 if (impl != null) {
58.21 impl.write(str, off, len);
58.22 } else {
58.23 @@ -83,8 +81,7 @@
58.24 return this;
58.25 }
58.26
58.27 - public final Writer append(CharSequence csq, int start, int end)
58.28 - throws IOException {
58.29 + public final Writer append(CharSequence csq, int start, int end) throws IOException {
58.30 return append(csq.subSequence(start, end));
58.31 }
58.32
59.1 --- a/samples/differentreturntype/build.xml Sat Jun 14 09:58:05 2008 +0200
59.2 +++ b/samples/differentreturntype/build.xml Sat Jun 14 09:58:08 2008 +0200
59.3 @@ -6,26 +6,18 @@
59.4
59.5 <!-- BEGIN: theory.binary.differentreturntype.ant -->
59.6 <!-- This is the target that does the whole trick - e,g. it compiles
59.7 - the Java source and then replaces tokens
59.8 - inside of the .class file
59.9 + the Java source and then replaces tokens inside of the .class file
59.10 -->
59.11 <target name="-build-and-rename">
59.12 <mkdir dir="build/apimerge/classes"/>
59.13 - <javac
59.14 - srcdir="src-apimerge" destdir="build/apimerge/classes"
59.15 - source="1.4" target="1.4" classpath="${cp}"
59.16 - />
59.17 + <javac srcdir="src-apimerge" destdir="build/apimerge/classes" source="1.4" target="1.4" classpath="${cp}"/>
59.18
59.19 <!-- this is the replace. As the replace is done textually,
59.20 - we need to use some reasonable encoding that treats all
59.21 - byte values as characters. E.g. it is not possible to
59.22 - use UTF-8 as it does not like the standard Java header
59.23 - 0xCAFEBABE. Western Europe encoding is fine
59.24 + we need to use some reasonable encoding that treats all byte values
59.25 + as characters. E.g. it is not possible to use UTF-8 as it does not
59.26 + like the standard Java header 0xCAFEBABE. Western Europe encoding is fine
59.27 -->
59.28 - <replace
59.29 - dir="build/apimerge/classes" casesensitive="true"
59.30 - encoding="iso-8859-1" summary="true"
59.31 - >
59.32 + <replace dir="build/apimerge/classes" casesensitive="true" encoding="iso-8859-1" summary="true">
59.33 <include name="**/*.class"/>
59.34 <replacetoken>g3tIcon</replacetoken>
59.35 <replacevalue>getIcon</replacevalue>
60.1 --- a/samples/differentreturntype/src-api1.0/api/API.java Sat Jun 14 09:58:05 2008 +0200
60.2 +++ b/samples/differentreturntype/src-api1.0/api/API.java Sat Jun 14 09:58:08 2008 +0200
60.3 @@ -5,7 +5,7 @@
60.4 public abstract class API {
60.5 // BEGIN: theory.binary.differentreturntype.api
60.6 public static Icon getIcon() {
60.7 - return null; // compute something
60.8 +// END: theory.binary.differentreturntype.api
60.9 + return null;
60.10 }
60.11 -// END: theory.binary.differentreturntype.api
60.12 }
61.1 --- a/samples/differentreturntype/src-api2.0/api/API.java Sat Jun 14 09:58:05 2008 +0200
61.2 +++ b/samples/differentreturntype/src-api2.0/api/API.java Sat Jun 14 09:58:08 2008 +0200
61.3 @@ -5,7 +5,7 @@
61.4 public abstract class API {
61.5 // BEGIN: theory.binary.differentreturntype.api2
61.6 public static ImageIcon getIcon() {
61.7 +// END: theory.binary.differentreturntype.api2
61.8 return null;
61.9 }
61.10 -// END: theory.binary.differentreturntype.api2
61.11 }
62.1 --- a/samples/extensibleicon/src/org/apidesign/extensibleicon/CatQuery.java Sat Jun 14 09:58:05 2008 +0200
62.2 +++ b/samples/extensibleicon/src/org/apidesign/extensibleicon/CatQuery.java Sat Jun 14 09:58:08 2008 +0200
62.3 @@ -7,18 +7,14 @@
62.4 private CatQuery() { }
62.5
62.6 public static boolean isCat(ExtIcon icon) {
62.7 - for (CatQueryImplementation impl :
62.8 - Lookup.getDefault().lookupAll(CatQueryImplementation.class)
62.9 - ) {
62.10 + for (CatQueryImplementation impl : Lookup.getDefault().lookupAll(CatQueryImplementation.class)) {
62.11 Boolean res = impl.isCat(icon);
62.12 if (res != null) {
62.13 return res;
62.14 }
62.15 }
62.16
62.17 - for (CatQueryImplementation impl :
62.18 - icon.getLookup().lookupAll(CatQueryImplementation.class)
62.19 - ) {
62.20 + for (CatQueryImplementation impl : icon.getLookup().lookupAll(CatQueryImplementation.class)) {
62.21 Boolean res = impl.isCat(icon);
62.22 if (res != null) {
62.23 return res;
63.1 --- a/samples/extensibleicon/src/org/apidesign/extensibleicon/Icon2Image.java Sat Jun 14 09:58:05 2008 +0200
63.2 +++ b/samples/extensibleicon/src/org/apidesign/extensibleicon/Icon2Image.java Sat Jun 14 09:58:08 2008 +0200
63.3 @@ -12,11 +12,7 @@
63.4 if (img != null) {
63.5 return img;
63.6 }
63.7 - BufferedImage buf = new BufferedImage(
63.8 - icon.getIconWidth(),
63.9 - icon.getIconHeight(),
63.10 - BufferedImage.TYPE_INT_RGB
63.11 - );
63.12 + BufferedImage buf = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
63.13 icon.paintIcon(null, buf.getGraphics(), 0, 0);
63.14 return buf;
63.15 }
64.1 --- a/samples/extensionpoint/src-api/org/apidesign/extensionpoint/Main.java Sat Jun 14 09:58:05 2008 +0200
64.2 +++ b/samples/extensionpoint/src-api/org/apidesign/extensionpoint/Main.java Sat Jun 14 09:58:08 2008 +0200
64.3 @@ -12,8 +12,7 @@
64.4 public static void main(String[] args) {
64.5 for (;;) {
64.6 // BEGIN: extension.point.Query
64.7 - Collection<? extends TipOfTheDay> all =
64.8 - Lookup.getDefault().lookupAll(TipOfTheDay.class);
64.9 + Collection<? extends TipOfTheDay> all = Lookup.getDefault().lookupAll(TipOfTheDay.class);
64.10 List<TipOfTheDay> arr = new ArrayList<TipOfTheDay>(all);
64.11 Collections.shuffle(arr);
64.12
64.13 @@ -34,9 +33,7 @@
64.14 String again = "Once Again";
64.15 String exit = "Exit";
64.16 String[] options = new String[] { again, exit };
64.17 - int ret = JOptionPane.showOptionDialog(
64.18 - null, msg, title, 0, type, null, options, exit
64.19 - );
64.20 + int ret = JOptionPane.showOptionDialog(null, msg, title, 0, type, null, options, exit);
64.21
64.22 if (ret != 0) {
64.23 break;
65.1 --- a/samples/forjoe/src-api1.0/api/InterfaceThatJustJoeCanImplement.java Sat Jun 14 09:58:05 2008 +0200
65.2 +++ b/samples/forjoe/src-api1.0/api/InterfaceThatJustJoeCanImplement.java Sat Jun 14 09:58:08 2008 +0200
65.3 @@ -4,9 +4,7 @@
65.4 public abstract class InterfaceThatJustJoeCanImplement {
65.5 protected InterfaceThatJustJoeCanImplement() {
65.6 if (!"impl.joe.JoesImpl".equals(getClass().getName())) {
65.7 - throw new IllegalStateException(
65.8 - "Sorry, you are not allowed to implement this class"
65.9 - );
65.10 + throw new IllegalStateException("Sorry, you are not allowed to implement this class");
65.11 }
65.12 }
65.13
66.1 --- a/samples/friendpackage/src/apipkg/Item.java Sat Jun 14 09:58:05 2008 +0200
66.2 +++ b/samples/friendpackage/src/apipkg/Item.java Sat Jun 14 09:58:08 2008 +0200
66.3 @@ -1,3 +1,16 @@
66.4 +/*
66.5 + * Sun Public License Notice
66.6 + *
66.7 + * The contents of this file are subject to the Sun Public License
66.8 + * Version 1.0 (the "License"). You may not use this file except in
66.9 + * compliance with the License. A copy of the License is available at
66.10 + * http://www.sun.com/
66.11 + *
66.12 + * The Original Code is NetBeans. The Initial Developer of the Original
66.13 + * Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach.
66.14 + * All Rights Reserved.
66.15 + */
66.16 +
66.17 package apipkg;
66.18
66.19 import implpkg.Accessor;
66.20 @@ -23,8 +36,7 @@
66.21 Item() {
66.22 }
66.23
66.24 - /** Anyone can value of the item. At least if it
66.25 - * can get a reference to it.
66.26 + /** Anyone can value of the item. At least if it can get a reference to it.
66.27 */
66.28 public void setValue(int x) {
66.29 value = x;
67.1 --- a/samples/friendpackage/src/implpkg/Accessor.java Sat Jun 14 09:58:05 2008 +0200
67.2 +++ b/samples/friendpackage/src/implpkg/Accessor.java Sat Jun 14 09:58:08 2008 +0200
67.3 @@ -30,9 +30,7 @@
67.4 }
67.5
67.6 try {
67.7 - Class.forName(
67.8 - Item.class.getName(), true, Item.class.getClassLoader()
67.9 - );
67.10 + Class.forName(Item.class.getName(), true, Item.class.getClassLoader());
67.11 } catch (Exception ex) {
67.12 ex.printStackTrace();
67.13 }
68.1 --- a/samples/gc/src/org/apidesign/gc/WeakListeners.java Sat Jun 14 09:58:05 2008 +0200
68.2 +++ b/samples/gc/src/org/apidesign/gc/WeakListeners.java Sat Jun 14 09:58:08 2008 +0200
68.3 @@ -6,12 +6,8 @@
68.4 private WeakListeners() { }
68.5
68.6 // BEGIN: gc.weaklistener.create
68.7 - public static <T extends EventListener> T create(
68.8 - Class<T> type, T listener, Object source
68.9 - ) {
68.10 - return org.openide.util.WeakListeners.create(
68.11 - type, listener, source
68.12 - );
68.13 + public static <T extends EventListener> T create(Class<T> type, T listener, Object source) {
68.14 + return org.openide.util.WeakListeners.create(type, listener, source);
68.15 }
68.16 // END: gc.weaklistener.create
68.17 }
69.1 --- a/samples/gc/test/org/apidesign/gc/SizeTest.java Sat Jun 14 09:58:05 2008 +0200
69.2 +++ b/samples/gc/test/org/apidesign/gc/SizeTest.java Sat Jun 14 09:58:08 2008 +0200
69.3 @@ -12,18 +12,14 @@
69.4 public void measureIsDataLowerThan8No() {
69.5 Data d = new Data();
69.6
69.7 - NbTestCase.assertSize(
69.8 - "The size of the data instance is higher than 8, fail", 8, d
69.9 - );
69.10 + NbTestCase.assertSize("The size of the data instance is higher than 8, fail", 8, d);
69.11 }
69.12
69.13 @Test
69.14 public void measureIsDataLowerThan16Yes() {
69.15 // BEGIN: size.measure
69.16 Data d = new Data();
69.17 - NbTestCase.assertSize(
69.18 - "The size of the data instance is higher than 16", 16, d
69.19 - );
69.20 + NbTestCase.assertSize("The size of the data instance is higher than 16", 16, d);
69.21 // END: size.measure
69.22 }
69.23
70.1 --- a/samples/growingparameters/src-api2.0/api/classes/Compute.java Sat Jun 14 09:58:05 2008 +0200
70.2 +++ b/samples/growingparameters/src-api2.0/api/classes/Compute.java Sat Jun 14 09:58:08 2008 +0200
70.3 @@ -10,17 +10,14 @@
70.4 * @return list of strings to work with
70.5 * @since 1.0 */
70.6 public abstract List<String> getData();
70.7 - /** Computes the strings to work with together with their
70.8 - * associated descriptions. Shall be overriden in subclasses.
70.9 - * By default delegates to {@link #getData}
70.10 - * and uses the provided strings as both, the string
70.11 - * and its description.
70.12 + /** Computes the strings to work with together with their associated descriptions.
70.13 + * Shall be overriden in subclasses. By default delegates to {@link #getData}
70.14 + * and uses the provided strings as both, the string and its description.
70.15 *
70.16 * @return name to description pairs to work with
70.17 * @since 2.0 */
70.18 public Map<String,String> getDataAndDescription() {
70.19 - LinkedHashMap<String,String> ret =
70.20 - new LinkedHashMap<String, String>();
70.21 + LinkedHashMap<String,String> ret = new LinkedHashMap<String, String>();
70.22 for (String s : getData()) {
70.23 ret.put(s, s);
70.24 }
71.1 --- a/samples/hellowithsubclassing/src/org/apidesign/hello/ThreeWaysToUseHello.java Sat Jun 14 09:58:05 2008 +0200
71.2 +++ b/samples/hellowithsubclassing/src/org/apidesign/hello/ThreeWaysToUseHello.java Sat Jun 14 09:58:08 2008 +0200
71.3 @@ -19,10 +19,7 @@
71.4 // BEGIN: hello.supercall
71.5 private static class SuperHello extends Hello {
71.6 @Override
71.7 - public void hello() {
71.8 - super.hello();
71.9 - System.out.println("Hello once again");
71.10 - }
71.11 + public void hello() { super.hello(); System.out.println("Hello once again"); }
71.12 }
71.13 // END: hello.supercall
71.14
72.1 --- a/samples/insertsuperclass/src-api2.0/api/HelloClass.java Sat Jun 14 09:58:05 2008 +0200
72.2 +++ b/samples/insertsuperclass/src-api2.0/api/HelloClass.java Sat Jun 14 09:58:08 2008 +0200
72.3 @@ -2,6 +2,6 @@
72.4
72.5 // BEGIN: design.insert.superclass2
72.6 public abstract class HelloClass extends SimpleHelloClass {
72.7 -// FINISH: design.insert.superclass2
72.8 +// END: design.insert.superclass2
72.9 public abstract String sayHelloTo(String who);
72.10 }
73.1 --- a/samples/javabeans/src/org/apidesign/javabeans/toomany/HighlightsContainer.java Sat Jun 14 09:58:05 2008 +0200
73.2 +++ b/samples/javabeans/src/org/apidesign/javabeans/toomany/HighlightsContainer.java Sat Jun 14 09:58:08 2008 +0200
73.3 @@ -4,9 +4,8 @@
73.4
73.5 public interface HighlightsContainer {
73.6 // BEGIN: javabeans.with.HighlightsContainer.TooMany
73.7 - public void addHighlightsChangeListener(HighlightsChangeListener l)
73.8 - throws TooManyListenersException;
73.9 + public void addHighlightsChangeListener(HighlightsChangeListener listener) throws TooManyListenersException;
73.10 // END: javabeans.with.HighlightsContainer.TooMany
73.11 public HighlightsSequence getHighlights(int startOffset, int endOffset);
73.12 - public void removeHighlightsChangeListener(HighlightsChangeListener l);
73.13 + public void removeHighlightsChangeListener(HighlightsChangeListener listener);
73.14 }
74.1 --- a/samples/javabeans/src/org/apidesign/javabeans/with/HighlightsContainer.java Sat Jun 14 09:58:05 2008 +0200
74.2 +++ b/samples/javabeans/src/org/apidesign/javabeans/with/HighlightsContainer.java Sat Jun 14 09:58:08 2008 +0200
74.3 @@ -2,8 +2,8 @@
74.4
74.5 // BEGIN: javabeans.with.HighlightsContainer
74.6 public interface HighlightsContainer {
74.7 - public void addHighlightsChangeListener(HighlightsChangeListener l);
74.8 - public HighlightsSequence getHighlights(int start, int end);
74.9 - public void removeHighlightsChangeListener(HighlightsChangeListener l);
74.10 + public void addHighlightsChangeListener(HighlightsChangeListener listener);
74.11 + public HighlightsSequence getHighlights(int startOffset, int endOffset);
74.12 + public void removeHighlightsChangeListener(HighlightsChangeListener listener);
74.13 }
74.14 // END: javabeans.with.HighlightsContainer
75.1 --- a/samples/javabeans/src/org/apidesign/javabeans/without/HighlightsContainer.java Sat Jun 14 09:58:05 2008 +0200
75.2 +++ b/samples/javabeans/src/org/apidesign/javabeans/without/HighlightsContainer.java Sat Jun 14 09:58:08 2008 +0200
75.3 @@ -3,7 +3,7 @@
75.4 // BEGIN: javabeans.without
75.5 public interface HighlightsContainer {
75.6 public void initialize(Callback callback);
75.7 - public HighlightsSequence getHighlights(int start, int end);
75.8 + public HighlightsSequence getHighlights(int startOffset, int endOffset);
75.9
75.10 public static final class Callback {
75.11 Callback() { /* only for the infastructure */ }
76.1 --- a/samples/javabeans/test/org/apidesign/javabeans/use/toomany/MyHighlightsContainer.java Sat Jun 14 09:58:05 2008 +0200
76.2 +++ b/samples/javabeans/test/org/apidesign/javabeans/use/toomany/MyHighlightsContainer.java Sat Jun 14 09:58:08 2008 +0200
76.3 @@ -11,19 +11,15 @@
76.4 final class MyHighlightsContainer implements HighlightsContainer {
76.5 private HighlightsChangeListener listener;
76.6
76.7 - public synchronized void addHighlightsChangeListener(
76.8 - HighlightsChangeListener l
76.9 - ) throws TooManyListenersException {
76.10 + public synchronized void addHighlightsChangeListener(HighlightsChangeListener l) throws TooManyListenersException {
76.11 if (listener != null) throw new TooManyListenersException();
76.12 listener = l;
76.13 }
76.14 - public synchronized void removeHighlightsChangeListener(
76.15 - HighlightsChangeListener l
76.16 - ) {
76.17 + public synchronized void removeHighlightsChangeListener(HighlightsChangeListener l) {
76.18 if (listener == l) listener = null;
76.19 }
76.20 - public HighlightsSequence getHighlights(int start, int end) {
76.21 + public HighlightsSequence getHighlights(int startOffset, int endOffset) {
76.22 return null; // implement
76.23 }
76.24 -}
76.25 // END: javabeans.with.MyHighlightsContainer
76.26 +}
76.27 \ No newline at end of file
77.1 --- a/samples/libs/build.xml Sat Jun 14 09:58:05 2008 +0200
77.2 +++ b/samples/libs/build.xml Sat Jun 14 09:58:08 2008 +0200
77.3 @@ -1,6 +1,10 @@
77.4 <?xml version="1.0" encoding="UTF-8"?>
77.5 <project name="Downloads necessary libraries" default="libraries" basedir=".">
77.6 - <target name="libraries">
77.7 + <target name="clean">
77.8 + <delete dir="dist"/>
77.9 + </target>
77.10 +
77.11 + <target name="libraries">
77.12 <antcall target="-library">
77.13 <param name="library" value="junit-4.4"/>
77.14 <param name="url" value="http://switch.dl.sourceforge.net/sourceforge/junit/junit-4.4.jar"/>
77.15 @@ -11,11 +15,6 @@
77.16 <param name="url" value="http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/nbms/platform8/org-openide-util.nbm"/>
77.17 </antcall>
77.18 <antcall target="-library-from-zip">
77.19 - <param name="library" value="org-openide-filesystems"/>
77.20 - <param name="library.include" value="**/org-openide-filesystems.jar"/>
77.21 - <param name="url" value="http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/nbms/platform8/org-openide-filesystems.nbm"/>
77.22 - </antcall>
77.23 - <antcall target="-library-from-zip">
77.24 <param name="library" value="org-netbeans-modules-nbjunit"/>
77.25 <param name="library.include" value="**/org-netbeans-modules-nbjunit.jar"/>
77.26 <param name="url" value="http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/nbms/testtools/org-netbeans-modules-nbjunit.nbm"/>
78.1 --- a/samples/messagedigest/src-bridge/org/apidesign/impl/security/extension/BridgeToNew.java Sat Jun 14 09:58:05 2008 +0200
78.2 +++ b/samples/messagedigest/src-bridge/org/apidesign/impl/security/extension/BridgeToNew.java Sat Jun 14 09:58:08 2008 +0200
78.3 @@ -1,3 +1,8 @@
78.4 +/*
78.5 + * To change this template, choose Tools | Templates
78.6 + * and open the template in the editor.
78.7 + */
78.8 +
78.9 package org.apidesign.impl.security.extension;
78.10
78.11 import java.nio.ByteBuffer;
78.12 @@ -13,8 +18,7 @@
78.13 */
78.14 // BEGIN: day.end.bridges.BridgeToNew
78.15 public class BridgeToNew extends Digestor<MessageDigest> {
78.16 - /** initializes the other bridge, and allow us to eliminate stack
78.17 - * overflow */
78.18 + /** initializes the other bridge, and allow us to eliminate stack overflow */
78.19 private static final BridgeToOld oldBridge = new BridgeToOld();
78.20
78.21 @Override
78.22 @@ -30,9 +34,7 @@
78.23 try {
78.24 return MessageDigest.getInstance(algorithm);
78.25 } catch (NoSuchAlgorithmException ex) {
78.26 - Logger.getLogger(BridgeToNew.class.getName()).log(
78.27 - Level.FINE, "Cannot find " + algorithm, ex
78.28 - );
78.29 + Logger.getLogger(BridgeToNew.class.getName()).log(Level.FINE, "Cannot find " + algorithm, ex);
78.30 return null;
78.31 }
78.32 }
79.1 --- a/samples/messagedigest/src-bridge/org/apidesign/impl/security/extension/BridgeToOld.java Sat Jun 14 09:58:05 2008 +0200
79.2 +++ b/samples/messagedigest/src-bridge/org/apidesign/impl/security/extension/BridgeToOld.java Sat Jun 14 09:58:08 2008 +0200
79.3 @@ -1,3 +1,8 @@
79.4 +/*
79.5 + * To change this template, choose Tools | Templates
79.6 + * and open the template in the editor.
79.7 + */
79.8 +
79.9 package org.apidesign.impl.security.extension;
79.10
79.11 import org.apidesign.api.security.Digest;
79.12 @@ -36,10 +41,7 @@
79.13 if ("MessageDigest".equals(type)) {
79.14 Digest dig = Digest.getInstance(algorithm);
79.15 if (dig != null) {
79.16 - return new ServiceImpl(
79.17 - dig, this, type, algorithm, "",
79.18 - Collections.<String>emptyList(),
79.19 - Collections.<String,String>emptyMap());
79.20 + return new ServiceImpl(dig, this, type, algorithm, "", Collections.<String>emptyList(), Collections.<String,String>emptyMap());
79.21 }
79.22 }
79.23 return null;
79.24 @@ -52,19 +54,13 @@
79.25 private static class ServiceImpl<Data> extends Service {
79.26 Digest dig;
79.27
79.28 - public ServiceImpl(Digest dig, Provider provider,
79.29 - String type, String algorithm, String className,
79.30 - List<String> aliases, Map<String, String> attributes
79.31 - ) {
79.32 - super(
79.33 - provider, type, algorithm, className, aliases, attributes
79.34 - );
79.35 + public ServiceImpl(Digest dig, Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String, String> attributes) {
79.36 + super(provider, type, algorithm, className, aliases, attributes);
79.37 this.dig = dig;
79.38 }
79.39
79.40 @Override
79.41 - public Object newInstance(Object constructorParameter)
79.42 - throws NoSuchAlgorithmException {
79.43 + public Object newInstance(Object constructorParameter) throws NoSuchAlgorithmException {
79.44 return new MessageDigest(getAlgorithm()) {
79.45 private byte[] res;
79.46
79.47 @@ -75,9 +71,7 @@
79.48 }
79.49
79.50 @Override
79.51 - protected void engineUpdate(
79.52 - byte[] input, int offset, int len
79.53 - ) {
79.54 + protected void engineUpdate(byte[] input, int offset, int len) {
79.55 ByteBuffer bb = ByteBuffer.wrap(input);
79.56 bb.position(offset);
79.57 bb.limit(offset + len);
80.1 --- a/samples/messagedigest/src-new-api/org/apidesign/api/security/Digest.java Sat Jun 14 09:58:05 2008 +0200
80.2 +++ b/samples/messagedigest/src-new-api/org/apidesign/api/security/Digest.java Sat Jun 14 09:58:08 2008 +0200
80.3 @@ -23,9 +23,7 @@
80.4 */
80.5 public static Digest getInstance(String algorithm) {
80.6 for (Digestor<?> digestor : ServiceLoader.load(Digestor.class)) {
80.7 - DigestImplementation<?> impl = DigestImplementation.create(
80.8 - digestor, algorithm
80.9 - );
80.10 + DigestImplementation<?> impl = DigestImplementation.create(digestor, algorithm);
80.11 if (impl != null) {
80.12 return new Digest(impl);
80.13 }
81.1 --- a/samples/messagedigest/src-new-api/org/apidesign/spi/security/Digestor.java Sat Jun 14 09:58:05 2008 +0200
81.2 +++ b/samples/messagedigest/src-new-api/org/apidesign/spi/security/Digestor.java Sat Jun 14 09:58:08 2008 +0200
81.3 @@ -17,7 +17,7 @@
81.4 protected abstract Data create(String algorithm);
81.5 protected abstract void update(Data data, ByteBuffer input);
81.6
81.7 -// FINISH: day.end.bridges.Digestor
81.8 +// END: day.end.bridges.Digestor
81.9
81.10
81.11 static {
82.1 --- a/samples/messagedigest/src-test/test/CountingDigestor.java Sat Jun 14 09:58:05 2008 +0200
82.2 +++ b/samples/messagedigest/src-test/test/CountingDigestor.java Sat Jun 14 09:58:08 2008 +0200
82.3 @@ -17,12 +17,7 @@
82.4 @Override
82.5 protected byte[] digest(int[] data) {
82.6 int i = data[0];
82.7 - byte[] arr = {
82.8 - (byte) (i & 255),
82.9 - (byte) ((i >> 8) & 255),
82.10 - (byte) ((i >> 16) & 255),
82.11 - (byte) ((i >> 24) & 255)
82.12 - };
82.13 + byte[] arr = { (byte) (i & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255) };
82.14 return arr;
82.15 }
82.16
83.1 --- a/samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationCorrect.java Sat Jun 14 09:58:05 2008 +0200
83.2 +++ b/samples/misuse/src/org/apidesign/misuse/projectconfig/ProjectConfigurationCorrect.java Sat Jun 14 09:58:08 2008 +0200
83.3 @@ -2,8 +2,7 @@
83.4
83.5 public class ProjectConfigurationCorrect {
83.6 // BEGIN: misuse.prjconfig.correct
83.7 - interface ProjectConfigurationProvider
83.8 - <Configuration extends ProjectConfiguration> {
83.9 + interface ProjectConfigurationProvider<Configuration extends ProjectConfiguration> {
83.10 Configuration[] getConfigurations();
83.11 Configuration getActive();
83.12 void setActive(Configuration c);
83.13 @@ -18,7 +17,7 @@
83.14 /* Following does not work:
83.15 static {
83.16 // BEGIN: misuse.prjconfig.correct.trivial.access
83.17 - ProjectConfigurationProvider<?> provider = null; // obtain elsewhere;
83.18 + ProjectConfigurationProvider<?> provider = null; // obtain from somewhere;
83.19 provider.setActive(provider.getConfigurations()[0]);
83.20 // END: misuse.prjconfig.correct.trivial.access
83.21 }
83.22 @@ -26,7 +25,7 @@
83.23
83.24 static {
83.25 // BEGIN: misuse.prjconfig.correct.access
83.26 - ProjectConfigurationProvider<?> provider = null; // obtain elsewhere;
83.27 + ProjectConfigurationProvider<?> provider = null; // obtain from somewhere;
83.28 resetToZero(provider);
83.29 // END: misuse.prjconfig.correct.access
83.30 }
83.31 @@ -40,9 +39,7 @@
83.32 // END: misuse.prjconfig.correct.openmethod
83.33
83.34 // BEGIN: misuse.prjconfig.correct.openclass
83.35 - static void workWithProjectConfigurationProvider(
83.36 - ProjectConfigurationProvider<?> p
83.37 - ) {
83.38 + static void workWithProjectConfigurationProvider(ProjectConfigurationProvider<?> p) {
83.39 ResetToZero<?> rtz = ResetToZero.create(p);
83.40 rtz.obtainFirst();
83.41 // after a while
83.42 @@ -57,9 +54,7 @@
83.43 this.provider = provider;
83.44 }
83.45
83.46 - static <C extends ProjectConfiguration> ResetToZero<C> create(
83.47 - ProjectConfigurationProvider<C> p
83.48 - ) {
83.49 + static <C extends ProjectConfiguration> ResetToZero<C> create(ProjectConfigurationProvider<C> p) {
83.50 return new ResetToZero<C>(p);
83.51 }
83.52
84.1 --- a/samples/preventcyclicdependencies/src-acyclic1/org/apidesign/cycles/array/MutableArray.java Sat Jun 14 09:58:05 2008 +0200
84.2 +++ b/samples/preventcyclicdependencies/src-acyclic1/org/apidesign/cycles/array/MutableArray.java Sat Jun 14 09:58:08 2008 +0200
84.3 @@ -17,7 +17,7 @@
84.4
84.5 public void encrypt(OutputStream os) throws IOException {
84.6 DoEncode en = Lookup.getDefault().lookup(DoEncode.class);
84.7 - assert en != null : "org.netbeans.example.crypt missing!";
84.8 + assert en != null : "We need org.netbeans.example.crypt to be enabled!";
84.9 byte[] clone = (byte[]) arr.clone();
84.10 en.encode(clone);
84.11 os.write(clone);
85.1 --- a/samples/primitiveconstants/src-impl/impl/Impl.java Sat Jun 14 09:58:05 2008 +0200
85.2 +++ b/samples/primitiveconstants/src-impl/impl/Impl.java Sat Jun 14 09:58:08 2008 +0200
85.3 @@ -5,10 +5,10 @@
85.4 public class Impl extends API {
85.5 protected void init(int version) throws IllegalStateException {
85.6 if (version != API.VERSION) {
85.7 - throw new IllegalStateException("Wrong API version error!");
85.8 + throw new IllegalStateException("Not the right API version error!");
85.9 }
85.10 }
85.11 -// FINISH: theory.binary.constants.impl
85.12 +// END: theory.binary.constants.impl
85.13
85.14 public static void main(String[] args) {
85.15 System.err.println("main expects version: " + API.VERSION);
86.1 --- a/samples/privilegedcreator/test/accessprotectedmethod/MyDocument.java Sat Jun 14 09:58:05 2008 +0200
86.2 +++ b/samples/privilegedcreator/test/accessprotectedmethod/MyDocument.java Sat Jun 14 09:58:08 2008 +0200
86.3 @@ -11,7 +11,7 @@
86.4 final void writeLockAccess() {
86.5 writeLock();
86.6 }
86.7 -// FINISH: public.accessor
86.8 +// END: public.accessor
86.9
86.10 @Override
86.11 public Element getDefaultRootElement() {