constants demonstrated in real project
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:50:51 +0200
changeset 882ff02d7f861
parent 7 041165540a13
child 9 45a6b338a903
constants demonstrated in real project
samples/conditionaluseofapi/nbproject/project.properties
samples/primitiveconstants/build.xml
samples/primitiveconstants/nbproject/project.xml
samples/primitiveconstants/src-api1.0/api/API.java
samples/primitiveconstants/src-api2.0/api/API.java
samples/primitiveconstants/src-impl/impl/Impl.java
     1.1 --- a/samples/conditionaluseofapi/nbproject/project.properties	Sat Jun 14 09:50:51 2008 +0200
     1.2 +++ b/samples/conditionaluseofapi/nbproject/project.properties	Sat Jun 14 09:50:51 2008 +0200
     1.3 @@ -17,6 +17,7 @@
     1.4  dist.dir=dist
     1.5  dist.jar=${dist.dir}/conditionaluseofapi.jar
     1.6  dist.javadoc.dir=${dist.dir}/javadoc
     1.7 +excludes=
     1.8  includes=**
     1.9  jar.compress=false
    1.10  javac.classpath=
     2.1 --- a/samples/primitiveconstants/build.xml	Sat Jun 14 09:50:51 2008 +0200
     2.2 +++ b/samples/primitiveconstants/build.xml	Sat Jun 14 09:50:51 2008 +0200
     2.3 @@ -24,7 +24,7 @@
     2.4          </antcall>
     2.5          <echo message="Running the Implementation against Version 2.0 of the API. This should fail."/>
     2.6          <antcall target="-run-one">
     2.7 -            <param name="version" value="api1.0"/>
     2.8 +            <param name="version" value="api2.0"/>
     2.9          </antcall>
    2.10      </target>
    2.11  
    2.12 @@ -44,7 +44,7 @@
    2.13          <mkdir dir="build/${version}/classes"/>
    2.14          <property name="cp" value=""/>
    2.15          <javac 
    2.16 -            src="src-${version}" 
    2.17 +            srcdir="src-${version}" 
    2.18              destdir="build/${version}/classes" 
    2.19              source="1.4" target="1.4"
    2.20              classpath="${cp}"
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/samples/primitiveconstants/nbproject/project.xml	Sat Jun 14 09:50:51 2008 +0200
     3.3 @@ -0,0 +1,88 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
     3.6 +    <type>org.netbeans.modules.ant.freeform</type>
     3.7 +    <configuration>
     3.8 +        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
     3.9 +            <name>primitiveconstants</name>
    3.10 +        </general-data>
    3.11 +        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
    3.12 +            <!-- Do not use Project Properties customizer when editing this file manually. -->
    3.13 +            <name>primitiveconstants</name>
    3.14 +            <properties/>
    3.15 +            <folders>
    3.16 +                <source-folder>
    3.17 +                    <label>src-api1.0</label>
    3.18 +                    <type>java</type>
    3.19 +                    <location>src-api1.0</location>
    3.20 +                    <encoding>UTF-8</encoding>
    3.21 +                </source-folder>
    3.22 +                <source-folder>
    3.23 +                    <label>impl</label>
    3.24 +                    <type>java</type>
    3.25 +                    <location>impl</location>
    3.26 +                    <encoding>UTF-8</encoding>
    3.27 +                </source-folder>
    3.28 +                <source-folder>
    3.29 +                    <label>primitiveconstants</label>
    3.30 +                    <location>.</location>
    3.31 +                    <encoding>UTF-8</encoding>
    3.32 +                </source-folder>
    3.33 +            </folders>
    3.34 +            <ide-actions>
    3.35 +                <action name="build">
    3.36 +                    <target>build</target>
    3.37 +                </action>
    3.38 +                <action name="clean">
    3.39 +                    <target>clean</target>
    3.40 +                </action>
    3.41 +                <action name="run">
    3.42 +                    <target>run</target>
    3.43 +                </action>
    3.44 +                <action name="rebuild">
    3.45 +                    <target>clean</target>
    3.46 +                    <target>build</target>
    3.47 +                </action>
    3.48 +            </ide-actions>
    3.49 +            <view>
    3.50 +                <items>
    3.51 +                    <source-folder style="packages">
    3.52 +                        <label>API Version 1.0</label>
    3.53 +                        <location>src-api1.0</location>
    3.54 +                    </source-folder>
    3.55 +                    <source-folder style="packages">
    3.56 +                        <label>API Version 2.0</label>
    3.57 +                        <location>src-api2.0</location>
    3.58 +                    </source-folder>
    3.59 +                    <source-folder style="packages">
    3.60 +                        <label>impl</label>
    3.61 +                        <location>impl</location>
    3.62 +                    </source-folder>
    3.63 +                    <source-file>
    3.64 +                        <location>build.xml</location>
    3.65 +                    </source-file>
    3.66 +                </items>
    3.67 +                <context-menu>
    3.68 +                    <ide-action name="build"/>
    3.69 +                    <ide-action name="rebuild"/>
    3.70 +                    <ide-action name="clean"/>
    3.71 +                    <ide-action name="run"/>
    3.72 +                </context-menu>
    3.73 +            </view>
    3.74 +        </general-data>
    3.75 +        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
    3.76 +            <compilation-unit>
    3.77 +                <package-root>src-api1.0</package-root>
    3.78 +                <source-level>1.4</source-level>
    3.79 +            </compilation-unit>
    3.80 +            <compilation-unit>
    3.81 +                <package-root>src-api2.0</package-root>
    3.82 +                <source-level>1.4</source-level>
    3.83 +            </compilation-unit>
    3.84 +            <compilation-unit>
    3.85 +                <package-root>src-impl</package-root>
    3.86 +                <classpath mode="compile">src-api1.0</classpath>
    3.87 +                <source-level>1.4</source-level>
    3.88 +            </compilation-unit>
    3.89 +        </java-data>
    3.90 +    </configuration>
    3.91 +</project>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/primitiveconstants/src-api1.0/api/API.java	Sat Jun 14 09:50:51 2008 +0200
     4.3 @@ -0,0 +1,15 @@
     4.4 +package api;
     4.5 +
     4.6 +// BEGIN: theory.binary.constants.api
     4.7 +public abstract class API {
     4.8 +    public static final int VERSION = 1;
     4.9 +
    4.10 +    protected API() {
    4.11 +        System.err.println("Initializing version " + VERSION);
    4.12 +        init(API.VERSION);
    4.13 +        System.err.println("Properly initialized: " + this);
    4.14 +    }
    4.15 +
    4.16 +    protected abstract void init(int version) throws IllegalStateException;
    4.17 +}
    4.18 +// END: theory.binary.constants.api
    4.19 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/samples/primitiveconstants/src-api2.0/api/API.java	Sat Jun 14 09:50:51 2008 +0200
     5.3 @@ -0,0 +1,15 @@
     5.4 +package api;
     5.5 +
     5.6 +public abstract class API {
     5.7 +    // BEGIN: theory.binary.constants.api2
     5.8 +    public static final int VERSION = 2;
     5.9 +    // END: theory.binary.constants.api2
    5.10 +
    5.11 +    protected API() {
    5.12 +        System.err.println("Initializing version " + VERSION);
    5.13 +        init(API.VERSION);
    5.14 +        System.err.println("Properly initialized: " + this);
    5.15 +    }
    5.16 +
    5.17 +    protected abstract void init(int version) throws IllegalStateException;
    5.18 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/samples/primitiveconstants/src-impl/impl/Impl.java	Sat Jun 14 09:50:51 2008 +0200
     6.3 @@ -0,0 +1,18 @@
     6.4 +package impl;
     6.5 +import api.API;
     6.6 +
     6.7 +// BEGIN: theory.binary.constants.impl
     6.8 +public class Impl extends API {
     6.9 +    protected void init(int version) throws IllegalStateException {
    6.10 +        if (version != API.VERSION) {
    6.11 +          throw new IllegalStateException("Not the right API version error!");
    6.12 +        }
    6.13 +    }
    6.14 +// END: theory.binary.constants.impl
    6.15 +    
    6.16 +    public static void main(String[] args) {
    6.17 +        System.err.println("main expects version: " + API.VERSION);
    6.18 +        new Impl();
    6.19 +        System.err.println("done for version: " + API.VERSION);
    6.20 +    }
    6.21 +}