1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/insertsuperclass/build.xml Sat Jun 14 09:50:57 2008 +0200
1.3 @@ -0,0 +1,54 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<project name="insertsuperclass" default="run" basedir=".">
1.6 + <target name="clean">
1.7 + <delete dir="build"/>
1.8 + </target>
1.9 +
1.10 + <target name="build">
1.11 + <antcall target="-build-one">
1.12 + <param name="version" value="api1.0"/>
1.13 + </antcall>
1.14 + <antcall target="-build-one">
1.15 + <param name="version" value="api2.0"/>
1.16 + </antcall>
1.17 + <echo level="info" message="Compiling the Implementation against Version 1.0 of the API. This should succeeds."/>
1.18 + <antcall target="-build-one">
1.19 + <param name="version" value="impl"/>
1.20 + <param name="cp" location="build/api1.0/classes"/>
1.21 + </antcall>
1.22 + </target>
1.23 +
1.24 + <target name="run" depends="build">
1.25 + <echo level="info" message="Running the Implementation against Version 1.0 of the API. This should succeeds."/>
1.26 + <antcall target="-run-one">
1.27 + <param name="version" value="api1.0"/>
1.28 + </antcall>
1.29 + <echo level="info" message="Running the Implementation against Version 2.0 of the API. This should succeeds."/>
1.30 + <antcall target="-run-one">
1.31 + <param name="version" value="api2.0"/>
1.32 + </antcall>
1.33 + </target>
1.34 +
1.35 +
1.36 + <!-- support methods -->
1.37 +
1.38 + <target name="-run-one">
1.39 + <fail message="You need to specify API version number" unless="version"/>
1.40 + <java classpath="build/${version}/classes:build/impl/classes" classname="impl.Main"
1.41 + failonerror="true"
1.42 + />
1.43 + </target>
1.44 +
1.45 + <target name="-build-one">
1.46 + <fail message="You need to specify version number" unless="version"/>
1.47 +
1.48 + <mkdir dir="build/${version}/classes"/>
1.49 + <property name="cp" value=""/>
1.50 + <javac
1.51 + srcdir="src-${version}"
1.52 + destdir="build/${version}/classes"
1.53 + source="1.5" target="1.5"
1.54 + classpath="${cp}"
1.55 + />
1.56 + </target>
1.57 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/samples/insertsuperclass/nbproject/project.xml Sat Jun 14 09:50:57 2008 +0200
2.3 @@ -0,0 +1,85 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
2.6 + <type>org.netbeans.modules.ant.freeform</type>
2.7 + <configuration>
2.8 + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
2.9 + <name>insertsuperclass</name>
2.10 + </general-data>
2.11 + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
2.12 + <!-- Do not use Project Properties customizer when editing this file manually. -->
2.13 + <name>insertsuperclass</name>
2.14 + <properties/>
2.15 + <folders>
2.16 + <source-folder>
2.17 + <label>primitiveconstants</label>
2.18 + <location>.</location>
2.19 + <encoding>UTF-8</encoding>
2.20 + </source-folder>
2.21 + <source-folder>
2.22 + <label>src-api1.0</label>
2.23 + <type>java</type>
2.24 + <location>src-api1.0</location>
2.25 + <encoding>UTF-8</encoding>
2.26 + </source-folder>
2.27 + <source-folder>
2.28 + <label>impl</label>
2.29 + <type>java</type>
2.30 + <location>impl</location>
2.31 + <encoding>UTF-8</encoding>
2.32 + </source-folder>
2.33 + </folders>
2.34 + <ide-actions>
2.35 + <action name="build">
2.36 + <target>build</target>
2.37 + </action>
2.38 + <action name="clean">
2.39 + <target>clean</target>
2.40 + </action>
2.41 + <action name="run">
2.42 + <target>run</target>
2.43 + </action>
2.44 + <action name="rebuild">
2.45 + <target>clean</target>
2.46 + <target>build</target>
2.47 + </action>
2.48 + </ide-actions>
2.49 + <view>
2.50 + <items>
2.51 + <source-folder style="packages">
2.52 + <label>src-api1.0</label>
2.53 + <location>src-api1.0</location>
2.54 + </source-folder>
2.55 + <source-folder style="packages">
2.56 + <label>impl</label>
2.57 + <location>impl</location>
2.58 + </source-folder>
2.59 + <source-file>
2.60 + <location>build.xml</location>
2.61 + </source-file>
2.62 + </items>
2.63 + <context-menu>
2.64 + <ide-action name="build"/>
2.65 + <ide-action name="rebuild"/>
2.66 + <ide-action name="clean"/>
2.67 + <ide-action name="run"/>
2.68 + </context-menu>
2.69 + </view>
2.70 + <subprojects/>
2.71 + </general-data>
2.72 + <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
2.73 + <compilation-unit>
2.74 + <package-root>src-api1.0</package-root>
2.75 + <source-level>1.5</source-level>
2.76 + </compilation-unit>
2.77 + <compilation-unit>
2.78 + <package-root>src-api2.0</package-root>
2.79 + <source-level>1.5</source-level>
2.80 + </compilation-unit>
2.81 + <compilation-unit>
2.82 + <package-root>src-impl</package-root>
2.83 + <classpath mode="compile">src-api1.0</classpath>
2.84 + <source-level>1.5</source-level>
2.85 + </compilation-unit>
2.86 + </java-data>
2.87 + </configuration>
2.88 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/samples/insertsuperclass/src-api1.0/api/HelloClass.java Sat Jun 14 09:50:57 2008 +0200
3.3 @@ -0,0 +1,8 @@
3.4 +package api;
3.5 +
3.6 +public abstract class HelloClass {
3.7 +// BEGIN: design.insert.superclass
3.8 + public abstract String sayHello();
3.9 + public abstract String sayHelloTo(String who);
3.10 +// END: design.insert.superclass
3.11 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/samples/insertsuperclass/src-api1.0/api/HelloInterface.java Sat Jun 14 09:50:57 2008 +0200
4.3 @@ -0,0 +1,8 @@
4.4 +package api;
4.5 +
4.6 +// BEGIN: design.insert.superinterface
4.7 +public interface HelloInterface {
4.8 + public abstract String sayHello();
4.9 + public abstract String sayHelloTo(String who);
4.10 +}
4.11 +// END: design.insert.superinterface
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/samples/insertsuperclass/src-api2.0/api/HelloClass.java Sat Jun 14 09:50:57 2008 +0200
5.3 @@ -0,0 +1,7 @@
5.4 +package api;
5.5 +
5.6 +// BEGIN: design.insert.superclass2
5.7 +public abstract class HelloClass extends SimpleHelloClass {
5.8 +// END: design.insert.superclass2
5.9 + public abstract String sayHelloTo(String who);
5.10 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/samples/insertsuperclass/src-api2.0/api/HelloInterface.java Sat Jun 14 09:50:57 2008 +0200
6.3 @@ -0,0 +1,5 @@
6.4 +package api;
6.5 +
6.6 +public interface HelloInterface extends SimpleHelloInterface {
6.7 + public abstract String sayHelloTo(String who);
6.8 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/samples/insertsuperclass/src-api2.0/api/SimpleHelloClass.java Sat Jun 14 09:50:57 2008 +0200
7.3 @@ -0,0 +1,7 @@
7.4 +package api;
7.5 +
7.6 +// BEGIN: design.insert.superclass1
7.7 +public abstract class SimpleHelloClass {
7.8 + public abstract String sayHello();
7.9 +}
7.10 +// END: design.insert.superclass1
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/samples/insertsuperclass/src-api2.0/api/SimpleHelloInterface.java Sat Jun 14 09:50:57 2008 +0200
8.3 @@ -0,0 +1,5 @@
8.4 +package api;
8.5 +
8.6 +public interface SimpleHelloInterface {
8.7 + public abstract String sayHello();
8.8 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/samples/insertsuperclass/src-impl/impl/ImplClass.java Sat Jun 14 09:50:57 2008 +0200
9.3 @@ -0,0 +1,13 @@
9.4 +package impl;
9.5 +
9.6 +import api.HelloClass;
9.7 +
9.8 +public class ImplClass extends HelloClass {
9.9 + public String sayHello() {
9.10 + return "Hello Unknown!";
9.11 + }
9.12 +
9.13 + public String sayHelloTo(String who) {
9.14 + return "Hello " + who + '!';
9.15 + }
9.16 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/samples/insertsuperclass/src-impl/impl/ImplInterface.java Sat Jun 14 09:50:57 2008 +0200
10.3 @@ -0,0 +1,12 @@
10.4 +package impl;
10.5 +
10.6 +import api.HelloInterface;
10.7 +public class ImplInterface implements HelloInterface {
10.8 + public String sayHello() {
10.9 + return "Hello Unknown!";
10.10 + }
10.11 +
10.12 + public String sayHelloTo(String who) {
10.13 + return "Hello " + who + '!';
10.14 + }
10.15 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/samples/insertsuperclass/src-impl/impl/Main.java Sat Jun 14 09:50:57 2008 +0200
11.3 @@ -0,0 +1,24 @@
11.4 +
11.5 +package impl;
11.6 +
11.7 +import api.HelloClass;
11.8 +import api.HelloInterface;
11.9 +
11.10 +/**
11.11 + *
11.12 + * @author Jaroslav Tulach <jtulach@netbeans.org>
11.13 + */
11.14 +public class Main {
11.15 + public static void main(String[] args) throws Exception {
11.16 + HelloClass clazz = new ImplClass();
11.17 + assert "Hello Unknown!".equals(clazz.sayHello());
11.18 + assert "Hello Jaroslav!".equals(clazz.sayHelloTo("Jaroslav"));
11.19 +
11.20 + HelloInterface iface = new ImplInterface();
11.21 + assert "Hello Unknown!".equals(iface.sayHello());
11.22 + assert "Hello Jaroslav!".equals(iface.sayHelloTo("Jaroslav"));
11.23 +
11.24 + System.err.println("Who defines sayHello(): " + clazz.getClass().getSuperclass().getMethod("sayHello"));
11.25 + System.err.println("Who defines sayHello(): " + iface.getClass().getInterfaces()[0].getMethod("sayHello"));
11.26 + }
11.27 +}