# HG changeset patch # User Jaroslav Tulach # Date 1213429851 -7200 # Node ID 82ff02d7f861e746a39e874b09cf9fcdb475dd96 # Parent 041165540a13eb1ca6a3ae8812f24154bc0f5f7d constants demonstrated in real project diff -r 041165540a13 -r 82ff02d7f861 samples/conditionaluseofapi/nbproject/project.properties --- a/samples/conditionaluseofapi/nbproject/project.properties Sat Jun 14 09:50:51 2008 +0200 +++ b/samples/conditionaluseofapi/nbproject/project.properties Sat Jun 14 09:50:51 2008 +0200 @@ -17,6 +17,7 @@ dist.dir=dist dist.jar=${dist.dir}/conditionaluseofapi.jar dist.javadoc.dir=${dist.dir}/javadoc +excludes= includes=** jar.compress=false javac.classpath= diff -r 041165540a13 -r 82ff02d7f861 samples/primitiveconstants/build.xml --- a/samples/primitiveconstants/build.xml Sat Jun 14 09:50:51 2008 +0200 +++ b/samples/primitiveconstants/build.xml Sat Jun 14 09:50:51 2008 +0200 @@ -24,7 +24,7 @@ - + @@ -44,7 +44,7 @@ + + org.netbeans.modules.ant.freeform + + + primitiveconstants + + + + primitiveconstants + + + + + java + src-api1.0 + UTF-8 + + + + java + impl + UTF-8 + + + + . + UTF-8 + + + + + build + + + clean + + + run + + + clean + build + + + + + + + src-api1.0 + + + + src-api2.0 + + + + impl + + + build.xml + + + + + + + + + + + + + src-api1.0 + 1.4 + + + src-api2.0 + 1.4 + + + src-impl + src-api1.0 + 1.4 + + + + diff -r 041165540a13 -r 82ff02d7f861 samples/primitiveconstants/src-api1.0/api/API.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/primitiveconstants/src-api1.0/api/API.java Sat Jun 14 09:50:51 2008 +0200 @@ -0,0 +1,15 @@ +package api; + +// BEGIN: theory.binary.constants.api +public abstract class API { + public static final int VERSION = 1; + + protected API() { + System.err.println("Initializing version " + VERSION); + init(API.VERSION); + System.err.println("Properly initialized: " + this); + } + + protected abstract void init(int version) throws IllegalStateException; +} +// END: theory.binary.constants.api \ No newline at end of file diff -r 041165540a13 -r 82ff02d7f861 samples/primitiveconstants/src-api2.0/api/API.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/primitiveconstants/src-api2.0/api/API.java Sat Jun 14 09:50:51 2008 +0200 @@ -0,0 +1,15 @@ +package api; + +public abstract class API { + // BEGIN: theory.binary.constants.api2 + public static final int VERSION = 2; + // END: theory.binary.constants.api2 + + protected API() { + System.err.println("Initializing version " + VERSION); + init(API.VERSION); + System.err.println("Properly initialized: " + this); + } + + protected abstract void init(int version) throws IllegalStateException; +} diff -r 041165540a13 -r 82ff02d7f861 samples/primitiveconstants/src-impl/impl/Impl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/primitiveconstants/src-impl/impl/Impl.java Sat Jun 14 09:50:51 2008 +0200 @@ -0,0 +1,18 @@ +package impl; +import api.API; + +// BEGIN: theory.binary.constants.impl +public class Impl extends API { + protected void init(int version) throws IllegalStateException { + if (version != API.VERSION) { + throw new IllegalStateException("Not the right API version error!"); + } + } +// END: theory.binary.constants.impl + + public static void main(String[] args) { + System.err.println("main expects version: " + API.VERSION); + new Impl(); + System.err.println("done for version: " + API.VERSION); + } +}