More Netbeans mods
This commit is contained in:
parent
7175059a16
commit
f5a2dd0e00
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="Cake" />
|
<jrun cls="Cake" />
|
||||||
<jrun cls="ChocolateChip" />
|
<jrun cls="ChocolateChip" />
|
||||||
<jrun cls="ChocolateChip2" />
|
<jrun cls="ChocolateChip2" />
|
||||||
@ -18,7 +17,6 @@
|
|||||||
<jrun cls="PrintTest" />
|
<jrun cls="PrintTest" />
|
||||||
<jrun cls="QualifiedMyClass" />
|
<jrun cls="QualifiedMyClass" />
|
||||||
<jrun cls="SingleImport" />
|
<jrun cls="SingleImport" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -30,28 +30,27 @@ public class InterfaceExtractorProcessor
|
|||||||
interfaceMethods.add(m);
|
interfaceMethods.add(m);
|
||||||
if(interfaceMethods.size() > 0) {
|
if(interfaceMethods.size() > 0) {
|
||||||
try {
|
try {
|
||||||
PrintWriter writer =
|
try (PrintWriter writer = env.getFiler().createSourceFile(annot.value())) {
|
||||||
env.getFiler().createSourceFile(annot.value());
|
writer.println("package " +
|
||||||
writer.println("package " +
|
typeDecl.getPackage().getQualifiedName() +";");
|
||||||
typeDecl.getPackage().getQualifiedName() +";");
|
writer.println("public interface " +
|
||||||
writer.println("public interface " +
|
annot.value() + " {");
|
||||||
annot.value() + " {");
|
for(MethodDeclaration m : interfaceMethods) {
|
||||||
for(MethodDeclaration m : interfaceMethods) {
|
writer.print(" public ");
|
||||||
writer.print(" public ");
|
writer.print(m.getReturnType() + " ");
|
||||||
writer.print(m.getReturnType() + " ");
|
writer.print(m.getSimpleName() + " (");
|
||||||
writer.print(m.getSimpleName() + " (");
|
int i = 0;
|
||||||
int i = 0;
|
for(ParameterDeclaration parm :
|
||||||
for(ParameterDeclaration parm :
|
m.getParameters()) {
|
||||||
m.getParameters()) {
|
writer.print(parm.getType() + " " +
|
||||||
writer.print(parm.getType() + " " +
|
parm.getSimpleName());
|
||||||
parm.getSimpleName());
|
if(++i < m.getParameters().size())
|
||||||
if(++i < m.getParameters().size())
|
writer.print(", ");
|
||||||
writer.print(", ");
|
}
|
||||||
|
writer.println(");");
|
||||||
}
|
}
|
||||||
writer.println(");");
|
writer.println("}");
|
||||||
}
|
}
|
||||||
writer.println("}");
|
|
||||||
writer.close();
|
|
||||||
} catch(IOException ioe) {
|
} catch(IOException ioe) {
|
||||||
throw new RuntimeException(ioe);
|
throw new RuntimeException(ioe);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="annotations.AtUnitComposition" dirpath="../annotations" />
|
<jrun cls="annotations.AtUnitComposition" dirpath="../annotations" />
|
||||||
<jrun cls="annotations.AtUnitExample1" dirpath="../annotations" />
|
<jrun cls="annotations.AtUnitExample1" dirpath="../annotations" />
|
||||||
<jrun cls="annotations.AtUnitExample2" dirpath="../annotations" />
|
<jrun cls="annotations.AtUnitExample2" dirpath="../annotations" />
|
||||||
@ -19,7 +18,6 @@
|
|||||||
<jrun cls="annotations.StackLStringTest" dirpath="../annotations" />
|
<jrun cls="annotations.StackLStringTest" dirpath="../annotations" />
|
||||||
<jrun cls="UseCaseTracker" />
|
<jrun cls="UseCaseTracker" />
|
||||||
<jrun cls="annotations.database.TableCreator" dirpath="../annotations/database" arguments='annotations.database.Member' />
|
<jrun cls="annotations.database.TableCreator" dirpath="../annotations/database" arguments='annotations.database.Member' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -25,12 +25,7 @@ public class CompType implements Comparable<CompType> {
|
|||||||
}
|
}
|
||||||
private static Random r = new Random(47);
|
private static Random r = new Random(47);
|
||||||
public static Generator<CompType> generator() {
|
public static Generator<CompType> generator() {
|
||||||
return new Generator<CompType>() {
|
return () -> new CompType(r.nextInt(100),r.nextInt(100));
|
||||||
@Override
|
|
||||||
public CompType next() {
|
|
||||||
return new CompType(r.nextInt(100),r.nextInt(100));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
CompType[] a =
|
CompType[] a =
|
||||||
|
@ -23,8 +23,8 @@ public class CopyingArrays {
|
|||||||
// Objects:
|
// Objects:
|
||||||
Integer[] u = new Integer[10];
|
Integer[] u = new Integer[10];
|
||||||
Integer[] v = new Integer[5];
|
Integer[] v = new Integer[5];
|
||||||
Arrays.fill(u, new Integer(47));
|
Arrays.fill(u, 47);
|
||||||
Arrays.fill(v, new Integer(99));
|
Arrays.fill(v, 99);
|
||||||
print("u = " + Arrays.toString(u));
|
print("u = " + Arrays.toString(u));
|
||||||
print("v = " + Arrays.toString(v));
|
print("v = " + Arrays.toString(v));
|
||||||
System.arraycopy(v, 0, u, u.length/2, v.length);
|
System.arraycopy(v, 0, u, u.length/2, v.length);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AlphabeticSearch" />
|
<jrun cls="AlphabeticSearch" />
|
||||||
<jrun cls="ArrayOfGenerics" />
|
<jrun cls="ArrayOfGenerics" />
|
||||||
<jrun cls="ArrayOptions" />
|
<jrun cls="ArrayOptions" />
|
||||||
@ -33,7 +32,6 @@
|
|||||||
<jrun cls="TestArrayGeneration" />
|
<jrun cls="TestArrayGeneration" />
|
||||||
<jrun cls="TestGenerated" />
|
<jrun cls="TestGenerated" />
|
||||||
<jrun cls="ThreeDWithNew" />
|
<jrun cls="ThreeDWithNew" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,12 +6,10 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="Assert1" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="Assert1" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<jrun cls="Assert2" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="Assert2" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<jrun cls="LoaderAssertions" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="LoaderAssertions" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<jrun cls="Queue" />
|
<jrun cls="Queue" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -22,24 +22,18 @@ public class ActiveObjectDemo {
|
|||||||
}
|
}
|
||||||
public Future<Integer>
|
public Future<Integer>
|
||||||
calculateInt(final int x, final int y) {
|
calculateInt(final int x, final int y) {
|
||||||
return ex.submit(new Callable<Integer>() {
|
return ex.submit(() -> {
|
||||||
@Override
|
print("starting " + x + " + " + y);
|
||||||
public Integer call() {
|
pause(500);
|
||||||
print("starting " + x + " + " + y);
|
return x + y;
|
||||||
pause(500);
|
|
||||||
return x + y;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public Future<Float>
|
public Future<Float>
|
||||||
calculateFloat(final float x, final float y) {
|
calculateFloat(final float x, final float y) {
|
||||||
return ex.submit(new Callable<Float>() {
|
return ex.submit(() -> {
|
||||||
@Override
|
print("starting " + x + " + " + y);
|
||||||
public Float call() {
|
pause(2000);
|
||||||
print("starting " + x + " + " + y);
|
return x + y;
|
||||||
pause(2000);
|
|
||||||
return x + y;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void shutdown() { ex.shutdown(); }
|
public void shutdown() { ex.shutdown(); }
|
||||||
|
@ -11,16 +11,16 @@ public class CloseResource {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
ExecutorService exec = Executors.newCachedThreadPool();
|
ExecutorService exec = Executors.newCachedThreadPool();
|
||||||
ServerSocket server = new ServerSocket(8080);
|
ServerSocket server = new ServerSocket(8080);
|
||||||
InputStream socketInput =
|
try (InputStream socketInput = new Socket("localhost", 8080).getInputStream()) {
|
||||||
new Socket("localhost", 8080).getInputStream();
|
exec.execute(new IOBlocked(socketInput));
|
||||||
exec.execute(new IOBlocked(socketInput));
|
exec.execute(new IOBlocked(System.in));
|
||||||
exec.execute(new IOBlocked(System.in));
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
print("Shutting down all threads");
|
||||||
print("Shutting down all threads");
|
exec.shutdownNow();
|
||||||
exec.shutdownNow();
|
TimeUnit.SECONDS.sleep(1);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
print("Closing " + socketInput.getClass().getName());
|
||||||
print("Closing " + socketInput.getClass().getName());
|
socketInput.close(); // Releases blocked thread
|
||||||
socketInput.close(); // Releases blocked thread
|
}
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
print("Closing " + System.in.getClass().getName());
|
print("Closing " + System.in.getClass().getName());
|
||||||
System.in.close(); // Releases blocked thread
|
System.in.close(); // Releases blocked thread
|
||||||
|
@ -46,26 +46,23 @@ public class HorseRace {
|
|||||||
Executors.newCachedThreadPool();
|
Executors.newCachedThreadPool();
|
||||||
private CyclicBarrier barrier;
|
private CyclicBarrier barrier;
|
||||||
public HorseRace(int nHorses, final int pause) {
|
public HorseRace(int nHorses, final int pause) {
|
||||||
barrier = new CyclicBarrier(nHorses, new Runnable() {
|
barrier = new CyclicBarrier(nHorses, () -> {
|
||||||
@Override
|
StringBuilder s = new StringBuilder();
|
||||||
public void run() {
|
for(int i = 0; i < FINISH_LINE; i++)
|
||||||
StringBuilder s = new StringBuilder();
|
s.append("="); // The fence on the racetrack
|
||||||
for(int i = 0; i < FINISH_LINE; i++)
|
print(s);
|
||||||
s.append("="); // The fence on the racetrack
|
for(Horse horse : horses)
|
||||||
print(s);
|
print(horse.tracks());
|
||||||
for(Horse horse : horses)
|
for(Horse horse : horses)
|
||||||
print(horse.tracks());
|
if(horse.getStrides() >= FINISH_LINE) {
|
||||||
for(Horse horse : horses)
|
print(horse + "won!");
|
||||||
if(horse.getStrides() >= FINISH_LINE) {
|
exec.shutdownNow();
|
||||||
print(horse + "won!");
|
return;
|
||||||
exec.shutdownNow();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
TimeUnit.MILLISECONDS.sleep(pause);
|
|
||||||
} catch(InterruptedException e) {
|
|
||||||
print("barrier-action sleep interrupted");
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(pause);
|
||||||
|
} catch(InterruptedException e) {
|
||||||
|
print("barrier-action sleep interrupted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for(int i = 0; i < nHorses; i++) {
|
for(int i = 0; i < nHorses; i++) {
|
||||||
|
@ -33,16 +33,16 @@ public class NIOInterruption {
|
|||||||
InetSocketAddress isa =
|
InetSocketAddress isa =
|
||||||
new InetSocketAddress("localhost", 8080);
|
new InetSocketAddress("localhost", 8080);
|
||||||
SocketChannel sc1 = SocketChannel.open(isa);
|
SocketChannel sc1 = SocketChannel.open(isa);
|
||||||
SocketChannel sc2 = SocketChannel.open(isa);
|
try (SocketChannel sc2 = SocketChannel.open(isa)) {
|
||||||
Future<?> f = exec.submit(new NIOBlocked(sc1));
|
Future<?> f = exec.submit(new NIOBlocked(sc1));
|
||||||
exec.execute(new NIOBlocked(sc2));
|
exec.execute(new NIOBlocked(sc2));
|
||||||
exec.shutdown();
|
exec.shutdown();
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
// Produce an interrupt via cancel:
|
// Produce an interrupt via cancel:
|
||||||
f.cancel(true);
|
f.cancel(true);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
// Release the block by closing the channel:
|
// Release the block by closing the channel:
|
||||||
sc2.close();
|
}
|
||||||
}
|
}
|
||||||
} /* Output: (Sample)
|
} /* Output: (Sample)
|
||||||
Waiting for read() in NIOBlocked@7a84e4
|
Waiting for read() in NIOBlocked@7a84e4
|
||||||
|
@ -45,16 +45,13 @@ public class SemaphoreDemo {
|
|||||||
f.operation();
|
f.operation();
|
||||||
list.add(f);
|
list.add(f);
|
||||||
}
|
}
|
||||||
Future<?> blocked = exec.submit(new Runnable() {
|
Future<?> blocked = exec.submit(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
// Semaphore prevents additional checkout,
|
||||||
try {
|
// so call is blocked:
|
||||||
// Semaphore prevents additional checkout,
|
pool.checkOut();
|
||||||
// so call is blocked:
|
} catch(InterruptedException e) {
|
||||||
pool.checkOut();
|
print("checkOut() Interrupted");
|
||||||
} catch(InterruptedException e) {
|
|
||||||
print("checkOut() Interrupted");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TimeUnit.SECONDS.sleep(2);
|
TimeUnit.SECONDS.sleep(2);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="ActiveObjectDemo" />
|
<jrun cls="ActiveObjectDemo" />
|
||||||
<jrun cls="AtomicEvenGenerator" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="AtomicEvenGenerator" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="AtomicIntegerTest" />
|
<jrun cls="AtomicIntegerTest" />
|
||||||
@ -74,7 +73,6 @@
|
|||||||
<jrun cls="concurrency.restaurant2.RestaurantWithQueues" dirpath="../concurrency/restaurant2" arguments='5' />
|
<jrun cls="concurrency.restaurant2.RestaurantWithQueues" dirpath="../concurrency/restaurant2" arguments='5' />
|
||||||
<jrun cls="concurrency.waxomatic.WaxOMatic" dirpath="../concurrency/waxomatic" />
|
<jrun cls="concurrency.waxomatic.WaxOMatic" dirpath="../concurrency/waxomatic" />
|
||||||
<jrun cls="concurrency.waxomatic2.WaxOMatic2" dirpath="../concurrency/waxomatic2" />
|
<jrun cls="concurrency.waxomatic2.WaxOMatic2" dirpath="../concurrency/waxomatic2" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AssociativeArray" />
|
<jrun cls="AssociativeArray" />
|
||||||
<jrun cls="Bits" />
|
<jrun cls="Bits" />
|
||||||
<jrun cls="CanonicalMapping" />
|
<jrun cls="CanonicalMapping" />
|
||||||
@ -44,7 +43,6 @@
|
|||||||
<jrun cls="TypesForSets" />
|
<jrun cls="TypesForSets" />
|
||||||
<jrun cls="Unsupported" />
|
<jrun cls="Unsupported" />
|
||||||
<jrun cls="Utilities" />
|
<jrun cls="Utilities" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="BreakAndContinue" />
|
<jrun cls="BreakAndContinue" />
|
||||||
<jrun cls="CommaOperator" />
|
<jrun cls="CommaOperator" />
|
||||||
<jrun cls="ForEachFloat" />
|
<jrun cls="ForEachFloat" />
|
||||||
@ -20,7 +19,6 @@
|
|||||||
<jrun cls="StringSwitch" />
|
<jrun cls="StringSwitch" />
|
||||||
<jrun cls="VowelsAndConsonants" />
|
<jrun cls="VowelsAndConsonants" />
|
||||||
<jrun cls="WhileTest" />
|
<jrun cls="WhileTest" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="SimpleDebugging" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="SimpleDebugging" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -11,13 +11,11 @@ public class EnumMaps {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EnumMap<AlarmPoints,Command> em =
|
EnumMap<AlarmPoints,Command> em =
|
||||||
new EnumMap<>(AlarmPoints.class);
|
new EnumMap<>(AlarmPoints.class);
|
||||||
em.put(KITCHEN, new Command() {
|
em.put(KITCHEN, (Command) () -> {
|
||||||
@Override
|
print("Kitchen fire!");
|
||||||
public void action() { print("Kitchen fire!"); }
|
|
||||||
});
|
});
|
||||||
em.put(BATHROOM, new Command() {
|
em.put(BATHROOM, (Command) () -> {
|
||||||
@Override
|
print("Bathroom alert!");
|
||||||
public void action() { print("Bathroom alert!"); }
|
|
||||||
});
|
});
|
||||||
for(Map.Entry<AlarmPoints,Command> e : em.entrySet()) {
|
for(Map.Entry<AlarmPoints,Command> e : em.entrySet()) {
|
||||||
printnb(e.getKey() + ": ");
|
printnb(e.getKey() + ": ");
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="BigEnumSet" />
|
<jrun cls="BigEnumSet" />
|
||||||
<jrun cls="enumerated.Burrito" dirpath="../enumerated" />
|
<jrun cls="enumerated.Burrito" dirpath="../enumerated" />
|
||||||
<jrun cls="CarWash" />
|
<jrun cls="CarWash" />
|
||||||
@ -34,7 +33,6 @@
|
|||||||
<jrun cls="enumerated.menu.Meal" dirpath="../enumerated/menu" />
|
<jrun cls="enumerated.menu.Meal" dirpath="../enumerated/menu" />
|
||||||
<jrun cls="enumerated.menu.Meal2" dirpath="../enumerated/menu" />
|
<jrun cls="enumerated.menu.Meal2" dirpath="../enumerated/menu" />
|
||||||
<jrun cls="enumerated.menu.TypeOfFood" dirpath="../enumerated/menu" />
|
<jrun cls="enumerated.menu.TypeOfFood" dirpath="../enumerated/menu" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AlwaysFinally" />
|
<jrun cls="AlwaysFinally" />
|
||||||
<jrun cls="Cleanup" />
|
<jrun cls="Cleanup" />
|
||||||
<jrun cls="CleanupIdiom" />
|
<jrun cls="CleanupIdiom" />
|
||||||
@ -31,7 +30,6 @@
|
|||||||
<jrun cls="TurnOffChecking" />
|
<jrun cls="TurnOffChecking" />
|
||||||
<jrun cls="WhoCalled" />
|
<jrun cls="WhoCalled" />
|
||||||
<jrun cls="WithFinally" />
|
<jrun cls="WithFinally" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -11,10 +11,7 @@ class Customer {
|
|||||||
public String toString() { return "Customer " + id; }
|
public String toString() { return "Customer " + id; }
|
||||||
// A method to produce Generator objects:
|
// A method to produce Generator objects:
|
||||||
public static Generator<Customer> generator() {
|
public static Generator<Customer> generator() {
|
||||||
return new Generator<Customer>() {
|
return () -> new Customer();
|
||||||
@Override
|
|
||||||
public Customer next() { return new Customer(); }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,10 +23,7 @@ class Teller {
|
|||||||
public String toString() { return "Teller " + id; }
|
public String toString() { return "Teller " + id; }
|
||||||
// A single Generator object:
|
// A single Generator object:
|
||||||
public static Generator<Teller> generator =
|
public static Generator<Teller> generator =
|
||||||
new Generator<Teller>() {
|
() -> new Teller();
|
||||||
@Override
|
|
||||||
public Teller next() { return new Teller(); }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BankTeller {
|
public class BankTeller {
|
||||||
|
@ -15,7 +15,7 @@ class Foo2<T> {
|
|||||||
class IntegerFactory implements FactoryI<Integer> {
|
class IntegerFactory implements FactoryI<Integer> {
|
||||||
@Override
|
@Override
|
||||||
public Integer create() {
|
public Integer create() {
|
||||||
return new Integer(0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="ApplyTest" />
|
<jrun cls="ApplyTest" />
|
||||||
<jrun cls="ArrayMaker" />
|
<jrun cls="ArrayMaker" />
|
||||||
<jrun cls="ArrayOfGeneric" />
|
<jrun cls="ArrayOfGeneric" />
|
||||||
@ -78,7 +77,6 @@
|
|||||||
<jrun cls="Wildcards" />
|
<jrun cls="Wildcards" />
|
||||||
<jrun cls="generics.coffee.CoffeeGenerator" dirpath="../generics/coffee" />
|
<jrun cls="generics.coffee.CoffeeGenerator" dirpath="../generics/coffee" />
|
||||||
<jrun cls="generics.decorator.Decoration" dirpath="../generics/decorator" />
|
<jrun cls="generics.decorator.Decoration" dirpath="../generics/decorator" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -10,12 +10,9 @@ public class Button2b extends JFrame {
|
|||||||
b1 = new JButton("Button 1"),
|
b1 = new JButton("Button 1"),
|
||||||
b2 = new JButton("Button 2");
|
b2 = new JButton("Button 2");
|
||||||
private JTextField txt = new JTextField(10);
|
private JTextField txt = new JTextField(10);
|
||||||
private ActionListener bl = new ActionListener() {
|
private ActionListener bl = (ActionEvent e) -> {
|
||||||
@Override
|
String name1 = ((JButton)e.getSource()).getText();
|
||||||
public void actionPerformed(ActionEvent e) {
|
txt.setText(name1);
|
||||||
String name = ((JButton)e.getSource()).getText();
|
|
||||||
txt.setText(name);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public Button2b() {
|
public Button2b() {
|
||||||
b1.addActionListener(bl);
|
b1.addActionListener(bl);
|
||||||
|
@ -12,23 +12,14 @@ public class CheckBoxes extends JFrame {
|
|||||||
cb2 = new JCheckBox("Check Box 2"),
|
cb2 = new JCheckBox("Check Box 2"),
|
||||||
cb3 = new JCheckBox("Check Box 3");
|
cb3 = new JCheckBox("Check Box 3");
|
||||||
public CheckBoxes() {
|
public CheckBoxes() {
|
||||||
cb1.addActionListener(new ActionListener() {
|
cb1.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
trace("1", cb1);
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
trace("1", cb1);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
cb2.addActionListener(new ActionListener() {
|
cb2.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
trace("2", cb2);
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
trace("2", cb2);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
cb3.addActionListener(new ActionListener() {
|
cb3.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
trace("3", cb3);
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
trace("3", cb3);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(new JScrollPane(t));
|
add(new JScrollPane(t));
|
||||||
|
@ -18,19 +18,13 @@ public class ComboBoxes extends JFrame {
|
|||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
c.addItem(description[count++]);
|
c.addItem(description[count++]);
|
||||||
t.setEditable(false);
|
t.setEditable(false);
|
||||||
b.addActionListener(new ActionListener() {
|
b.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
if(count < description.length)
|
||||||
public void actionPerformed(ActionEvent e) {
|
c.addItem(description[count++]);
|
||||||
if(count < description.length)
|
|
||||||
c.addItem(description[count++]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
c.addActionListener(new ActionListener() {
|
c.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
t.setText("index: "+ c.getSelectedIndex() + " " +
|
||||||
public void actionPerformed(ActionEvent e) {
|
((JComboBox)e.getSource()).getSelectedItem());
|
||||||
t.setText("index: "+ c.getSelectedIndex() + " " +
|
|
||||||
((JComboBox)e.getSource()).getSelectedItem());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(t);
|
add(t);
|
||||||
|
@ -11,11 +11,8 @@ class MyDialog extends JDialog {
|
|||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(new JLabel("Here is my dialog"));
|
add(new JLabel("Here is my dialog"));
|
||||||
JButton ok = new JButton("OK");
|
JButton ok = new JButton("OK");
|
||||||
ok.addActionListener(new ActionListener() {
|
ok.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
dispose(); // Closes the dialog
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dispose(); // Closes the dialog
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
add(ok);
|
add(ok);
|
||||||
setSize(150,125);
|
setSize(150,125);
|
||||||
@ -26,11 +23,8 @@ public class Dialogs extends JFrame {
|
|||||||
private JButton b1 = new JButton("Dialog Box");
|
private JButton b1 = new JButton("Dialog Box");
|
||||||
private MyDialog dlg = new MyDialog(null);
|
private MyDialog dlg = new MyDialog(null);
|
||||||
public Dialogs() {
|
public Dialogs() {
|
||||||
b1.addActionListener(new ActionListener() {
|
b1.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
dlg.setVisible(true);
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dlg.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
add(b1);
|
add(b1);
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,16 @@ public class Faces extends JFrame {
|
|||||||
};
|
};
|
||||||
jb = new JButton("JButton", faces[3]);
|
jb = new JButton("JButton", faces[3]);
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
jb.addActionListener(new ActionListener() {
|
jb.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
if(mad) {
|
||||||
public void actionPerformed(ActionEvent e) {
|
jb.setIcon(faces[3]);
|
||||||
if(mad) {
|
mad = false;
|
||||||
jb.setIcon(faces[3]);
|
} else {
|
||||||
mad = false;
|
jb.setIcon(faces[0]);
|
||||||
} else {
|
mad = true;
|
||||||
jb.setIcon(faces[0]);
|
|
||||||
mad = true;
|
|
||||||
}
|
|
||||||
jb.setVerticalAlignment(JButton.TOP);
|
|
||||||
jb.setHorizontalAlignment(JButton.LEFT);
|
|
||||||
}
|
}
|
||||||
|
jb.setVerticalAlignment(JButton.TOP);
|
||||||
|
jb.setHorizontalAlignment(JButton.LEFT);
|
||||||
});
|
});
|
||||||
jb.setRolloverEnabled(true);
|
jb.setRolloverEnabled(true);
|
||||||
jb.setRolloverIcon(faces[1]);
|
jb.setRolloverIcon(faces[1]);
|
||||||
@ -39,16 +36,13 @@ public class Faces extends JFrame {
|
|||||||
jb.setDisabledIcon(faces[4]);
|
jb.setDisabledIcon(faces[4]);
|
||||||
jb.setToolTipText("Yow!");
|
jb.setToolTipText("Yow!");
|
||||||
add(jb);
|
add(jb);
|
||||||
jb2.addActionListener(new ActionListener() {
|
jb2.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
if(jb.isEnabled()) {
|
||||||
public void actionPerformed(ActionEvent e) {
|
jb.setEnabled(false);
|
||||||
if(jb.isEnabled()) {
|
jb2.setText("Enable");
|
||||||
jb.setEnabled(false);
|
} else {
|
||||||
jb2.setText("Enable");
|
jb.setEnabled(true);
|
||||||
} else {
|
jb2.setText("Disable");
|
||||||
jb.setEnabled(true);
|
|
||||||
jb2.setText("Disable");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(jb2);
|
add(jb2);
|
||||||
|
@ -10,14 +10,11 @@ public class HTMLButton extends JFrame {
|
|||||||
"<html><b><font size=+2>" +
|
"<html><b><font size=+2>" +
|
||||||
"<center>Hello!<br><i>Press me now!");
|
"<center>Hello!<br><i>Press me now!");
|
||||||
public HTMLButton() {
|
public HTMLButton() {
|
||||||
b.addActionListener(new ActionListener() {
|
b.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
add(new JLabel("<html>" +
|
||||||
public void actionPerformed(ActionEvent e) {
|
"<i><font size=+4>Kapow!"));
|
||||||
add(new JLabel("<html>" +
|
// Force a re-layout to include the new label:
|
||||||
"<i><font size=+4>Kapow!"));
|
validate();
|
||||||
// Force a re-layout to include the new label:
|
|
||||||
validate();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(b);
|
add(b);
|
||||||
|
@ -25,31 +25,21 @@ InterruptableLongRunningCallable extends JFrame {
|
|||||||
private TaskManager<String,CallableTask> manager =
|
private TaskManager<String,CallableTask> manager =
|
||||||
new TaskManager<>();
|
new TaskManager<>();
|
||||||
public InterruptableLongRunningCallable() {
|
public InterruptableLongRunningCallable() {
|
||||||
b1.addActionListener(new ActionListener() {
|
b1.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
CallableTask task = new CallableTask();
|
||||||
public void actionPerformed(ActionEvent e) {
|
manager.add(task);
|
||||||
CallableTask task = new CallableTask();
|
System.out.println(task + " added to the queue");
|
||||||
manager.add(task);
|
|
||||||
System.out.println(task + " added to the queue");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
b2.addActionListener(new ActionListener() {
|
b2.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
for(String result : manager.purge())
|
||||||
public void actionPerformed(ActionEvent e) {
|
System.out.println(result);
|
||||||
for(String result : manager.purge())
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
b3.addActionListener(new ActionListener() {
|
b3.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
// Sample call to a Task method:
|
||||||
public void actionPerformed(ActionEvent e) {
|
for(TaskItem<String,CallableTask> tt : manager)
|
||||||
// Sample call to a Task method:
|
tt.task.id(); // No cast required
|
||||||
for(TaskItem<String,CallableTask> tt :
|
for(String result : manager.getResults())
|
||||||
manager)
|
System.out.println(result);
|
||||||
tt.task.id(); // No cast required
|
|
||||||
for(String result : manager.getResults())
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(b1);
|
add(b1);
|
||||||
|
@ -32,19 +32,13 @@ public class InterruptableLongRunningTask extends JFrame {
|
|||||||
ExecutorService executor =
|
ExecutorService executor =
|
||||||
Executors.newSingleThreadExecutor();
|
Executors.newSingleThreadExecutor();
|
||||||
public InterruptableLongRunningTask() {
|
public InterruptableLongRunningTask() {
|
||||||
b1.addActionListener(new ActionListener() {
|
b1.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
Task task = new Task();
|
||||||
public void actionPerformed(ActionEvent e) {
|
executor.execute(task);
|
||||||
Task task = new Task();
|
System.out.println(task + " added to the queue");
|
||||||
executor.execute(task);
|
|
||||||
System.out.println(task + " added to the queue");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
b2.addActionListener(new ActionListener() {
|
b2.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
executor.shutdownNow(); // Heavy-handed
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
executor.shutdownNow(); // Heavy-handed
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(b1);
|
add(b1);
|
||||||
|
@ -18,28 +18,22 @@ public class List extends JFrame {
|
|||||||
private JTextArea t =
|
private JTextArea t =
|
||||||
new JTextArea(flavors.length, 20);
|
new JTextArea(flavors.length, 20);
|
||||||
private JButton b = new JButton("Add Item");
|
private JButton b = new JButton("Add Item");
|
||||||
private ActionListener bl = new ActionListener() {
|
private ActionListener bl = (ActionEvent e) -> {
|
||||||
@Override
|
if(count < flavors.length) {
|
||||||
public void actionPerformed(ActionEvent e) {
|
lItems.add(0, flavors[count++]);
|
||||||
if(count < flavors.length) {
|
} else {
|
||||||
lItems.add(0, flavors[count++]);
|
// Disable, since there are no more
|
||||||
} else {
|
// flavors left to be added to the List
|
||||||
// Disable, since there are no more
|
b.setEnabled(false);
|
||||||
// flavors left to be added to the List
|
|
||||||
b.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ListSelectionListener ll =
|
private ListSelectionListener ll =
|
||||||
new ListSelectionListener() {
|
(ListSelectionEvent e) -> {
|
||||||
@Override
|
if(e.getValueIsAdjusting()) return;
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
t.setText("");
|
||||||
if(e.getValueIsAdjusting()) return;
|
for(Object item : lst.getSelectedValues())
|
||||||
t.setText("");
|
t.append(item + "\n");
|
||||||
for(Object item : lst.getSelectedValues())
|
};
|
||||||
t.append(item + "\n");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public List() {
|
public List() {
|
||||||
t.setEditable(false);
|
t.setEditable(false);
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
|
@ -11,24 +11,18 @@ public class LongRunningTask extends JFrame {
|
|||||||
b1 = new JButton("Start Long Running Task"),
|
b1 = new JButton("Start Long Running Task"),
|
||||||
b2 = new JButton("End Long Running Task");
|
b2 = new JButton("End Long Running Task");
|
||||||
public LongRunningTask() {
|
public LongRunningTask() {
|
||||||
b1.addActionListener(new ActionListener() {
|
b1.addActionListener((ActionEvent evt) -> {
|
||||||
@Override
|
try {
|
||||||
public void actionPerformed(ActionEvent evt) {
|
TimeUnit.SECONDS.sleep(3);
|
||||||
try {
|
} catch(InterruptedException e) {
|
||||||
TimeUnit.SECONDS.sleep(3);
|
System.out.println("Task interrupted");
|
||||||
} catch(InterruptedException e) {
|
return;
|
||||||
System.out.println("Task interrupted");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
System.out.println("Task completed");
|
|
||||||
}
|
}
|
||||||
|
System.out.println("Task completed");
|
||||||
});
|
});
|
||||||
b2.addActionListener(new ActionListener() {
|
b2.addActionListener((ActionEvent evt) -> {
|
||||||
@Override
|
// Interrupt yourself?
|
||||||
public void actionPerformed(ActionEvent evt) {
|
Thread.currentThread().interrupt();
|
||||||
// Interrupt yourself?
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(b1);
|
add(b1);
|
||||||
|
@ -55,9 +55,9 @@ public class MessageBoxes extends JFrame {
|
|||||||
};
|
};
|
||||||
public MessageBoxes() {
|
public MessageBoxes() {
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
for(int i = 0; i < b.length; i++) {
|
for (JButton b1 : b) {
|
||||||
b[i].addActionListener(al);
|
b1.addActionListener(al);
|
||||||
add(b[i]);
|
add(b1);
|
||||||
}
|
}
|
||||||
add(txt);
|
add(txt);
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,9 @@ class MonitoredCallable implements Callable<String> {
|
|||||||
if(monitor.isCanceled())
|
if(monitor.isCanceled())
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
final int progress = i;
|
final int progress = i;
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
monitor.setProgress(progress);
|
||||||
public void run() {
|
});
|
||||||
monitor.setProgress(progress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
monitor.close();
|
monitor.close();
|
||||||
@ -55,31 +51,22 @@ public class MonitoredLongRunningCallable extends JFrame {
|
|||||||
private TaskManager<String,MonitoredCallable> manager =
|
private TaskManager<String,MonitoredCallable> manager =
|
||||||
new TaskManager<>();
|
new TaskManager<>();
|
||||||
public MonitoredLongRunningCallable() {
|
public MonitoredLongRunningCallable() {
|
||||||
b1.addActionListener(new ActionListener() {
|
b1.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
MonitoredCallable task = new MonitoredCallable(
|
||||||
public void actionPerformed(ActionEvent e) {
|
new ProgressMonitor(
|
||||||
MonitoredCallable task = new MonitoredCallable(
|
MonitoredLongRunningCallable.this,
|
||||||
new ProgressMonitor(
|
"Long-Running Task", "", 0, 0)
|
||||||
MonitoredLongRunningCallable.this,
|
);
|
||||||
"Long-Running Task", "", 0, 0)
|
manager.add(task);
|
||||||
);
|
System.out.println(task + " added to the queue");
|
||||||
manager.add(task);
|
|
||||||
System.out.println(task + " added to the queue");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
b2.addActionListener(new ActionListener() {
|
b2.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
for(String result : manager.purge())
|
||||||
public void actionPerformed(ActionEvent e) {
|
System.out.println(result);
|
||||||
for(String result : manager.purge())
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
b3.addActionListener(new ActionListener() {
|
b3.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
for(String result : manager.getResults())
|
||||||
public void actionPerformed(ActionEvent e) {
|
System.out.println(result);
|
||||||
for(String result : manager.getResults())
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(b1);
|
add(b1);
|
||||||
|
@ -11,11 +11,8 @@ public class Popup extends JFrame {
|
|||||||
public Popup() {
|
public Popup() {
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(t);
|
add(t);
|
||||||
ActionListener al = new ActionListener() {
|
ActionListener al = (ActionEvent e) -> {
|
||||||
@Override
|
t.setText(((JMenuItem)e.getSource()).getText());
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
t.setText(((JMenuItem)e.getSource()).getText());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
JMenuItem m = new JMenuItem("Hither");
|
JMenuItem m = new JMenuItem("Hither");
|
||||||
m.addActionListener(al);
|
m.addActionListener(al);
|
||||||
|
@ -24,11 +24,8 @@ public class Progress extends JFrame {
|
|||||||
sb.setBorder(new TitledBorder("Slide Me"));
|
sb.setBorder(new TitledBorder("Slide Me"));
|
||||||
pb.setModel(sb.getModel()); // Share model
|
pb.setModel(sb.getModel()); // Share model
|
||||||
add(sb);
|
add(sb);
|
||||||
sb.addChangeListener(new ChangeListener() {
|
sb.addChangeListener((ChangeEvent e) -> {
|
||||||
@Override
|
pm.setProgress(sb.getValue());
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
pm.setProgress(sb.getValue());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -12,12 +12,9 @@ public class RadioButtons extends JFrame {
|
|||||||
rb1 = new JRadioButton("one", false),
|
rb1 = new JRadioButton("one", false),
|
||||||
rb2 = new JRadioButton("two", false),
|
rb2 = new JRadioButton("two", false),
|
||||||
rb3 = new JRadioButton("three", false);
|
rb3 = new JRadioButton("three", false);
|
||||||
private ActionListener al = new ActionListener() {
|
private ActionListener al = (ActionEvent e) -> {
|
||||||
@Override
|
t.setText("Radio button " +
|
||||||
public void actionPerformed(ActionEvent e) {
|
((JRadioButton)e.getSource()).getText());
|
||||||
t.setText("Radio button " +
|
|
||||||
((JRadioButton)e.getSource()).getText());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public RadioButtons() {
|
public RadioButtons() {
|
||||||
rb1.addActionListener(al);
|
rb1.addActionListener(al);
|
||||||
|
@ -6,11 +6,8 @@ import static net.mindview.util.SwingConsole.*;
|
|||||||
|
|
||||||
public class SimpleMenus extends JFrame {
|
public class SimpleMenus extends JFrame {
|
||||||
private JTextField t = new JTextField(15);
|
private JTextField t = new JTextField(15);
|
||||||
private ActionListener al = new ActionListener() {
|
private ActionListener al = (ActionEvent e) -> {
|
||||||
@Override
|
t.setText(((JMenuItem)e.getSource()).getText());
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
t.setText(((JMenuItem)e.getSource()).getText());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
private JMenu[] menus = {
|
private JMenu[] menus = {
|
||||||
new JMenu("Winken"), new JMenu("Blinken"),
|
new JMenu("Winken"), new JMenu("Blinken"),
|
||||||
|
@ -11,11 +11,8 @@ public class SubmitLabelManipulationTask {
|
|||||||
frame.setSize(300, 100);
|
frame.setSize(300, 100);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
label.setText("Hey! This is Different!");
|
||||||
public void run() {
|
|
||||||
label.setText("Hey! This is Different!");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -14,16 +14,12 @@ public class SubmitSwingProgram extends JFrame {
|
|||||||
}
|
}
|
||||||
static SubmitSwingProgram ssp;
|
static SubmitSwingProgram ssp;
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
ssp = new SubmitSwingProgram();
|
||||||
public void run() { ssp = new SubmitSwingProgram(); }
|
|
||||||
});
|
});
|
||||||
TimeUnit.SECONDS.sleep(1);
|
TimeUnit.SECONDS.sleep(1);
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
ssp.label.setText("Hey! This is Different!");
|
||||||
public void run() {
|
|
||||||
ssp.label.setText("Hey! This is Different!");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -18,12 +18,9 @@ public class TabbedPane1 extends JFrame {
|
|||||||
for(String flavor : flavors)
|
for(String flavor : flavors)
|
||||||
tabs.addTab(flavors[i],
|
tabs.addTab(flavors[i],
|
||||||
new JButton("Tabbed pane " + i++));
|
new JButton("Tabbed pane " + i++));
|
||||||
tabs.addChangeListener(new ChangeListener() {
|
tabs.addChangeListener((ChangeEvent e) -> {
|
||||||
@Override
|
txt.setText("Tab selected: " +
|
||||||
public void stateChanged(ChangeEvent e) {
|
tabs.getSelectedIndex());
|
||||||
txt.setText("Tab selected: " +
|
|
||||||
tabs.getSelectedIndex());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
add(BorderLayout.SOUTH, txt);
|
add(BorderLayout.SOUTH, txt);
|
||||||
add(tabs);
|
add(tabs);
|
||||||
|
@ -16,18 +16,12 @@ public class TextArea extends JFrame {
|
|||||||
public TextArea() {
|
public TextArea() {
|
||||||
// Use up all the data:
|
// Use up all the data:
|
||||||
m.putAll(Countries.capitals());
|
m.putAll(Countries.capitals());
|
||||||
b.addActionListener(new ActionListener() {
|
b.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
for(Map.Entry me : m.entrySet())
|
||||||
public void actionPerformed(ActionEvent e) {
|
t.append(me.getKey() + ": "+ me.getValue()+"\n");
|
||||||
for(Map.Entry me : m.entrySet())
|
|
||||||
t.append(me.getKey() + ": "+ me.getValue()+"\n");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
c.addActionListener(new ActionListener() {
|
c.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
t.setText("");
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
t.setText("");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
add(new JScrollPane(t));
|
add(new JScrollPane(t));
|
||||||
|
@ -12,12 +12,9 @@ public class TextPane extends JFrame {
|
|||||||
private static Generator sg =
|
private static Generator sg =
|
||||||
new RandomGenerator.String(7);
|
new RandomGenerator.String(7);
|
||||||
public TextPane() {
|
public TextPane() {
|
||||||
b.addActionListener(new ActionListener() {
|
b.addActionListener((ActionEvent e) -> {
|
||||||
@Override
|
for(int i = 1; i < 10; i++)
|
||||||
public void actionPerformed(ActionEvent e) {
|
tp.setText(tp.getText() + sg.next() + "\n");
|
||||||
for(int i = 1; i < 10; i++)
|
|
||||||
tp.setText(tp.getText() + sg.next() + "\n");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
add(new JScrollPane(tp));
|
add(new JScrollPane(tp));
|
||||||
add(BorderLayout.SOUTH, b);
|
add(BorderLayout.SOUTH, b);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="BorderLayout1" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="BorderLayout1" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="Borders" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="Borders" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="Button1" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="Button1" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
@ -47,7 +46,6 @@
|
|||||||
<jrun cls="TextPane" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="TextPane" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="TicTacToe" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="TicTacToe" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="TrackEvent" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="TrackEvent" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,20 +6,15 @@ import java.util.*;
|
|||||||
class ReversibleArrayList<T> extends ArrayList<T> {
|
class ReversibleArrayList<T> extends ArrayList<T> {
|
||||||
public ReversibleArrayList(Collection<T> c) { super(c); }
|
public ReversibleArrayList(Collection<T> c) { super(c); }
|
||||||
public Iterable<T> reversed() {
|
public Iterable<T> reversed() {
|
||||||
return new Iterable<T>() {
|
return () -> new Iterator<T>() {
|
||||||
|
int current = size() - 1;
|
||||||
@Override
|
@Override
|
||||||
public Iterator<T> iterator() {
|
public boolean hasNext() { return current > -1; }
|
||||||
return new Iterator<T>() {
|
@Override
|
||||||
int current = size() - 1;
|
public T next() { return get(current--); }
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() { return current > -1; }
|
public void remove() { // Not implemented
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public T next() { return get(current--); }
|
|
||||||
@Override
|
|
||||||
public void remove() { // Not implemented
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,9 @@ public class ApplesAndOrangesWithGenerics {
|
|||||||
apples.add(new Apple());
|
apples.add(new Apple());
|
||||||
// Compile-time error:
|
// Compile-time error:
|
||||||
// apples.add(new Orange());
|
// apples.add(new Orange());
|
||||||
for(int i = 0; i < apples.size(); i++)
|
for (Apple apple : apples) {
|
||||||
System.out.println(apples.get(i).id());
|
System.out.println(apple.id());
|
||||||
|
}
|
||||||
// Using foreach:
|
// Using foreach:
|
||||||
for(Apple c : apples)
|
for(Apple c : apples)
|
||||||
System.out.println(c.id());
|
System.out.println(c.id());
|
||||||
|
@ -19,8 +19,9 @@ public class ApplesAndOrangesWithoutGenerics {
|
|||||||
apples.add(new Apple());
|
apples.add(new Apple());
|
||||||
// Not prevented from adding an Orange to apples:
|
// Not prevented from adding an Orange to apples:
|
||||||
apples.add(new Orange());
|
apples.add(new Orange());
|
||||||
for(int i = 0; i < apples.size(); i++)
|
for (Object apple : apples) {
|
||||||
((Apple)apples.get(i)).id();
|
((Apple) apple).id();
|
||||||
// Orange is detected only at run time
|
// Orange is detected only at run time
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* (Execute to see output) *///:~
|
} /* (Execute to see output) *///:~
|
||||||
|
@ -4,32 +4,24 @@ import java.util.*;
|
|||||||
|
|
||||||
public class MultiIterableClass extends IterableClass {
|
public class MultiIterableClass extends IterableClass {
|
||||||
public Iterable<String> reversed() {
|
public Iterable<String> reversed() {
|
||||||
return new Iterable<String>() {
|
return () -> new Iterator<String>() {
|
||||||
|
int current = words.length - 1;
|
||||||
@Override
|
@Override
|
||||||
public Iterator<String> iterator() {
|
public boolean hasNext() { return current > -1; }
|
||||||
return new Iterator<String>() {
|
@Override
|
||||||
int current = words.length - 1;
|
public String next() { return words[current--]; }
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() { return current > -1; }
|
public void remove() { // Not implemented
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public String next() { return words[current--]; }
|
|
||||||
@Override
|
|
||||||
public void remove() { // Not implemented
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public Iterable<String> randomized() {
|
public Iterable<String> randomized() {
|
||||||
return new Iterable<String>() {
|
return () -> {
|
||||||
@Override
|
List<String> shuffled =
|
||||||
public Iterator<String> iterator() {
|
new ArrayList<>(Arrays.asList(words));
|
||||||
List<String> shuffled =
|
Collections.shuffle(shuffled, new Random(47));
|
||||||
new ArrayList<>(Arrays.asList(words));
|
return shuffled.iterator();
|
||||||
Collections.shuffle(shuffled, new Random(47));
|
|
||||||
return shuffled.iterator();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AdapterMethodIdiom" />
|
<jrun cls="AdapterMethodIdiom" />
|
||||||
<jrun cls="AddingGroups" />
|
<jrun cls="AddingGroups" />
|
||||||
<jrun cls="ApplesAndOrangesWithGenerics" />
|
<jrun cls="ApplesAndOrangesWithGenerics" />
|
||||||
@ -42,7 +41,6 @@
|
|||||||
<jrun cls="Statistics" />
|
<jrun cls="Statistics" />
|
||||||
<jrun cls="UniqueWords" />
|
<jrun cls="UniqueWords" />
|
||||||
<jrun cls="UniqueWordsAlphabetic" />
|
<jrun cls="UniqueWordsAlphabetic" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,13 +5,11 @@ import java.util.*;
|
|||||||
public class ArrayInit {
|
public class ArrayInit {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Integer[] a = {
|
Integer[] a = {
|
||||||
new Integer(1),
|
1, 2,
|
||||||
new Integer(2),
|
|
||||||
3, // Autoboxing
|
3, // Autoboxing
|
||||||
};
|
};
|
||||||
Integer[] b = new Integer[]{
|
Integer[] b = new Integer[]{
|
||||||
new Integer(1),
|
1, 2,
|
||||||
new Integer(2),
|
|
||||||
3, // Autoboxing
|
3, // Autoboxing
|
||||||
};
|
};
|
||||||
System.out.println(Arrays.toString(a));
|
System.out.println(Arrays.toString(a));
|
||||||
|
@ -7,9 +7,9 @@ public class AutoboxingVarargs {
|
|||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
f(new Integer(1), new Integer(2));
|
f(1, 2);
|
||||||
f(4, 5, 6, 7, 8, 9);
|
f(4, 5, 6, 7, 8, 9);
|
||||||
f(10, new Integer(11), 12);
|
f(10, 11, 12);
|
||||||
}
|
}
|
||||||
} /* Output:
|
} /* Output:
|
||||||
1 2
|
1 2
|
||||||
|
@ -9,8 +9,7 @@ public class NewVarArgs {
|
|||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Can take individual elements:
|
// Can take individual elements:
|
||||||
printArray(new Integer(47), new Float(3.14),
|
printArray(47, (float) 3.14, 11.11);
|
||||||
new Double(11.11));
|
|
||||||
printArray(47, 3.14F, 11.11);
|
printArray(47, 3.14F, 11.11);
|
||||||
printArray("one", "two", "three");
|
printArray("one", "two", "three");
|
||||||
printArray(new A(), new A(), new A());
|
printArray(new A(), new A(), new A());
|
||||||
|
@ -11,8 +11,7 @@ public class VarArgs {
|
|||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
printArray(new Object[]{
|
printArray(new Object[]{
|
||||||
new Integer(47), new Float(3.14), new Double(11.11)
|
47, (float) 3.14, 11.11});
|
||||||
});
|
|
||||||
printArray(new Object[]{"one", "two", "three" });
|
printArray(new Object[]{"one", "two", "three" });
|
||||||
printArray(new Object[]{new A(), new A(), new A()});
|
printArray(new Object[]{new A(), new A(), new A()});
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="ArrayClassObj" />
|
<jrun cls="ArrayClassObj" />
|
||||||
<jrun cls="ArrayInit" />
|
<jrun cls="ArrayInit" />
|
||||||
<jrun cls="ArrayNew" />
|
<jrun cls="ArrayNew" />
|
||||||
@ -40,7 +39,6 @@
|
|||||||
<jrun cls="TerminationCondition" />
|
<jrun cls="TerminationCondition" />
|
||||||
<jrun cls="VarArgs" />
|
<jrun cls="VarArgs" />
|
||||||
<jrun cls="VarargType" />
|
<jrun cls="VarargType" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AnonymousConstructor" />
|
<jrun cls="AnonymousConstructor" />
|
||||||
<jrun cls="BigEgg" />
|
<jrun cls="BigEgg" />
|
||||||
<jrun cls="BigEgg2" />
|
<jrun cls="BigEgg2" />
|
||||||
@ -36,7 +35,6 @@
|
|||||||
<jrun cls="Sequence" />
|
<jrun cls="Sequence" />
|
||||||
<jrun cls="TestBed$Tester" />
|
<jrun cls="TestBed$Tester" />
|
||||||
<jrun cls="TestParcel" />
|
<jrun cls="TestParcel" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AdaptedRandomDoubles" />
|
<jrun cls="AdaptedRandomDoubles" />
|
||||||
<jrun cls="Adventure" />
|
<jrun cls="Adventure" />
|
||||||
<jrun cls="Factories" />
|
<jrun cls="Factories" />
|
||||||
@ -21,7 +20,6 @@
|
|||||||
<jrun cls="interfaces.music4.Music4" dirpath="../interfaces/music4" />
|
<jrun cls="interfaces.music4.Music4" dirpath="../interfaces/music4" />
|
||||||
<jrun cls="interfaces.music5.Music5" dirpath="../interfaces/music5" />
|
<jrun cls="interfaces.music5.Music5" dirpath="../interfaces/music5" />
|
||||||
<jrun cls="interfaces.nesting.NestingInterfaces" dirpath="../interfaces/nesting" />
|
<jrun cls="interfaces.nesting.NestingInterfaces" dirpath="../interfaces/nesting" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -8,13 +8,13 @@ public class BasicFileOutput {
|
|||||||
BufferedReader in = new BufferedReader(
|
BufferedReader in = new BufferedReader(
|
||||||
new StringReader(
|
new StringReader(
|
||||||
BufferedInputFile.read("BasicFileOutput.java")));
|
BufferedInputFile.read("BasicFileOutput.java")));
|
||||||
PrintWriter out = new PrintWriter(
|
try (PrintWriter out = new PrintWriter(
|
||||||
new BufferedWriter(new FileWriter(file)));
|
new BufferedWriter(new FileWriter(file)))) {
|
||||||
int lineCount = 1;
|
int lineCount = 1;
|
||||||
String s;
|
String s;
|
||||||
while((s = in.readLine()) != null )
|
while((s = in.readLine()) != null )
|
||||||
out.println(lineCount++ + ": " + s);
|
out.println(lineCount++ + ": " + s);
|
||||||
out.close();
|
}
|
||||||
// Show the stored file:
|
// Show the stored file:
|
||||||
System.out.println(BufferedInputFile.read(file));
|
System.out.println(BufferedInputFile.read(file));
|
||||||
}
|
}
|
||||||
|
@ -39,11 +39,11 @@ public class Blip3 implements Externalizable {
|
|||||||
print("Constructing objects:");
|
print("Constructing objects:");
|
||||||
Blip3 b3 = new Blip3("A String ", 47);
|
Blip3 b3 = new Blip3("A String ", 47);
|
||||||
print(b3);
|
print(b3);
|
||||||
ObjectOutputStream o = new ObjectOutputStream(
|
try (ObjectOutputStream o = new ObjectOutputStream(
|
||||||
new FileOutputStream("Blip3.out"));
|
new FileOutputStream("Blip3.out"))) {
|
||||||
print("Saving object:");
|
print("Saving object:");
|
||||||
o.writeObject(b3);
|
o.writeObject(b3);
|
||||||
o.close();
|
}
|
||||||
// Now get it back:
|
// Now get it back:
|
||||||
ObjectInputStream in = new ObjectInputStream(
|
ObjectInputStream in = new ObjectInputStream(
|
||||||
new FileInputStream("Blip3.out"));
|
new FileInputStream("Blip3.out"));
|
||||||
|
@ -41,12 +41,12 @@ public class Blips {
|
|||||||
print("Constructing objects:");
|
print("Constructing objects:");
|
||||||
Blip1 b1 = new Blip1();
|
Blip1 b1 = new Blip1();
|
||||||
Blip2 b2 = new Blip2();
|
Blip2 b2 = new Blip2();
|
||||||
ObjectOutputStream o = new ObjectOutputStream(
|
try (ObjectOutputStream o = new ObjectOutputStream(
|
||||||
new FileOutputStream("Blips.out"));
|
new FileOutputStream("Blips.out"))) {
|
||||||
print("Saving objects:");
|
print("Saving objects:");
|
||||||
o.writeObject(b1);
|
o.writeObject(b1);
|
||||||
o.writeObject(b2);
|
o.writeObject(b2);
|
||||||
o.close();
|
}
|
||||||
// Now get them back:
|
// Now get them back:
|
||||||
ObjectInputStream in = new ObjectInputStream(
|
ObjectInputStream in = new ObjectInputStream(
|
||||||
new FileInputStream("Blips.out"));
|
new FileInputStream("Blips.out"));
|
||||||
|
@ -5,14 +5,15 @@ public class BufferedInputFile {
|
|||||||
// Throw exceptions to console:
|
// Throw exceptions to console:
|
||||||
public static String
|
public static String
|
||||||
read(String filename) throws IOException {
|
read(String filename) throws IOException {
|
||||||
// Reading input by lines:
|
StringBuilder sb;
|
||||||
BufferedReader in = new BufferedReader(
|
try ( // Reading input by lines:
|
||||||
new FileReader(filename));
|
BufferedReader in = new BufferedReader(
|
||||||
String s;
|
new FileReader(filename))) {
|
||||||
StringBuilder sb = new StringBuilder();
|
String s;
|
||||||
while((s = in.readLine())!= null)
|
sb = new StringBuilder();
|
||||||
sb.append(s + "\n");
|
while((s = in.readLine())!= null)
|
||||||
in.close();
|
sb.append(s + "\n");
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
@ -5,15 +5,15 @@ import java.io.*;
|
|||||||
|
|
||||||
public class FileLocking {
|
public class FileLocking {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
FileOutputStream fos= new FileOutputStream("file.txt");
|
try (FileOutputStream fos = new FileOutputStream("file.txt")) {
|
||||||
FileLock fl = fos.getChannel().tryLock();
|
FileLock fl = fos.getChannel().tryLock();
|
||||||
if(fl != null) {
|
if(fl != null) {
|
||||||
System.out.println("Locked File");
|
System.out.println("Locked File");
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
fl.release();
|
fl.release();
|
||||||
System.out.println("Released Lock");
|
System.out.println("Released Lock");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fos.close();
|
|
||||||
}
|
}
|
||||||
} /* Output:
|
} /* Output:
|
||||||
Locked File
|
Locked File
|
||||||
|
@ -8,13 +8,13 @@ public class FileOutputShortcut {
|
|||||||
BufferedReader in = new BufferedReader(
|
BufferedReader in = new BufferedReader(
|
||||||
new StringReader(
|
new StringReader(
|
||||||
BufferedInputFile.read("FileOutputShortcut.java")));
|
BufferedInputFile.read("FileOutputShortcut.java")));
|
||||||
// Here's the shortcut:
|
try ( // Here's the shortcut:
|
||||||
PrintWriter out = new PrintWriter(file);
|
PrintWriter out = new PrintWriter(file)) {
|
||||||
int lineCount = 1;
|
int lineCount = 1;
|
||||||
String s;
|
String s;
|
||||||
while((s = in.readLine()) != null )
|
while((s = in.readLine()) != null )
|
||||||
out.println(lineCount++ + ": " + s);
|
out.println(lineCount++ + ": " + s);
|
||||||
out.close();
|
}
|
||||||
// Show the stored file:
|
// Show the stored file:
|
||||||
System.out.println(BufferedInputFile.read(file));
|
System.out.println(BufferedInputFile.read(file));
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,17 @@ public class GZIPcompress {
|
|||||||
"the file to test.gz");
|
"the file to test.gz");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
InputStream in = new BufferedInputStream(
|
BufferedOutputStream out;
|
||||||
new FileInputStream(args[0]));
|
try (InputStream in = new BufferedInputStream(
|
||||||
BufferedOutputStream out = new BufferedOutputStream(
|
new FileInputStream(args[0]))) {
|
||||||
new GZIPOutputStream(
|
out = new BufferedOutputStream(
|
||||||
new FileOutputStream("test.gz")));
|
new GZIPOutputStream(
|
||||||
System.out.println("Writing file");
|
new FileOutputStream("test.gz")));
|
||||||
int c;
|
System.out.println("Writing file");
|
||||||
while((c = in.read()) != -1)
|
int c;
|
||||||
|
while((c = in.read()) != -1)
|
||||||
out.write(c);
|
out.write(c);
|
||||||
in.close();
|
}
|
||||||
out.close();
|
out.close();
|
||||||
System.out.println("Reading file");
|
System.out.println("Reading file");
|
||||||
BufferedReader in2 = new BufferedReader(
|
BufferedReader in2 = new BufferedReader(
|
||||||
|
@ -21,10 +21,10 @@ public class Logon implements Serializable {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Logon a = new Logon("Hulk", "myLittlePony");
|
Logon a = new Logon("Hulk", "myLittlePony");
|
||||||
print("logon a = " + a);
|
print("logon a = " + a);
|
||||||
ObjectOutputStream o = new ObjectOutputStream(
|
try (ObjectOutputStream o = new ObjectOutputStream(
|
||||||
new FileOutputStream("Logon.out"));
|
new FileOutputStream("Logon.out"))) {
|
||||||
o.writeObject(a);
|
o.writeObject(a);
|
||||||
o.close();
|
}
|
||||||
TimeUnit.SECONDS.sleep(1); // Delay
|
TimeUnit.SECONDS.sleep(1); // Delay
|
||||||
// Now get them back:
|
// Now get them back:
|
||||||
ObjectInputStream in = new ObjectInputStream(
|
ObjectInputStream in = new ObjectInputStream(
|
||||||
|
@ -26,77 +26,76 @@ public class MappedIO {
|
|||||||
new Tester("Stream Write") {
|
new Tester("Stream Write") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
DataOutputStream dos = new DataOutputStream(
|
try (DataOutputStream dos = new DataOutputStream(
|
||||||
new BufferedOutputStream(
|
new BufferedOutputStream(
|
||||||
new FileOutputStream(new File("temp.tmp"))));
|
new FileOutputStream(new File("temp.tmp"))))) {
|
||||||
for(int i = 0; i < numOfInts; i++)
|
for(int i = 0; i < numOfInts; i++)
|
||||||
dos.writeInt(i);
|
dos.writeInt(i);
|
||||||
dos.close();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Tester("Mapped Write") {
|
new Tester("Mapped Write") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
FileChannel fc =
|
try (FileChannel fc = new RandomAccessFile("temp.tmp", "rw")
|
||||||
new RandomAccessFile("temp.tmp", "rw")
|
.getChannel()) {
|
||||||
.getChannel();
|
IntBuffer ib = fc.map(
|
||||||
IntBuffer ib = fc.map(
|
FileChannel.MapMode.READ_WRITE, 0, fc.size())
|
||||||
FileChannel.MapMode.READ_WRITE, 0, fc.size())
|
.asIntBuffer();
|
||||||
.asIntBuffer();
|
for(int i = 0; i < numOfInts; i++)
|
||||||
for(int i = 0; i < numOfInts; i++)
|
ib.put(i);
|
||||||
ib.put(i);
|
}
|
||||||
fc.close();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Tester("Stream Read") {
|
new Tester("Stream Read") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
DataInputStream dis = new DataInputStream(
|
try (DataInputStream dis = new DataInputStream(
|
||||||
new BufferedInputStream(
|
new BufferedInputStream(
|
||||||
new FileInputStream("temp.tmp")));
|
new FileInputStream("temp.tmp")))) {
|
||||||
for(int i = 0; i < numOfInts; i++)
|
for(int i = 0; i < numOfInts; i++)
|
||||||
dis.readInt();
|
dis.readInt();
|
||||||
dis.close();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Tester("Mapped Read") {
|
new Tester("Mapped Read") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
FileChannel fc = new FileInputStream(
|
try (FileChannel fc = new FileInputStream(
|
||||||
new File("temp.tmp")).getChannel();
|
new File("temp.tmp")).getChannel()) {
|
||||||
IntBuffer ib = fc.map(
|
IntBuffer ib = fc.map(
|
||||||
FileChannel.MapMode.READ_ONLY, 0, fc.size())
|
FileChannel.MapMode.READ_ONLY, 0, fc.size())
|
||||||
.asIntBuffer();
|
.asIntBuffer();
|
||||||
while(ib.hasRemaining())
|
while(ib.hasRemaining())
|
||||||
ib.get();
|
ib.get();
|
||||||
fc.close();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Tester("Stream Read/Write") {
|
new Tester("Stream Read/Write") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
RandomAccessFile raf = new RandomAccessFile(
|
try (RandomAccessFile raf = new RandomAccessFile(
|
||||||
new File("temp.tmp"), "rw");
|
new File("temp.tmp"), "rw")) {
|
||||||
raf.writeInt(1);
|
raf.writeInt(1);
|
||||||
for(int i = 0; i < numOfUbuffInts; i++) {
|
for(int i = 0; i < numOfUbuffInts; i++) {
|
||||||
raf.seek(raf.length() - 4);
|
raf.seek(raf.length() - 4);
|
||||||
raf.writeInt(raf.readInt());
|
raf.writeInt(raf.readInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
raf.close();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Tester("Mapped Read/Write") {
|
new Tester("Mapped Read/Write") {
|
||||||
@Override
|
@Override
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
FileChannel fc = new RandomAccessFile(
|
try (FileChannel fc = new RandomAccessFile(
|
||||||
new File("temp.tmp"), "rw").getChannel();
|
new File("temp.tmp"), "rw").getChannel()) {
|
||||||
IntBuffer ib = fc.map(
|
IntBuffer ib = fc.map(
|
||||||
FileChannel.MapMode.READ_WRITE, 0, fc.size())
|
FileChannel.MapMode.READ_WRITE, 0, fc.size())
|
||||||
.asIntBuffer();
|
.asIntBuffer();
|
||||||
ib.put(0);
|
ib.put(0);
|
||||||
for(int i = 1; i < numOfUbuffInts; i++)
|
for(int i = 1; i < numOfUbuffInts; i++)
|
||||||
ib.put(ib.get(i - 1));
|
ib.put(ib.get(i - 1));
|
||||||
fc.close();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,18 +8,19 @@ public class Redirecting {
|
|||||||
PrintStream console = System.out;
|
PrintStream console = System.out;
|
||||||
BufferedInputStream in = new BufferedInputStream(
|
BufferedInputStream in = new BufferedInputStream(
|
||||||
new FileInputStream("Redirecting.java"));
|
new FileInputStream("Redirecting.java"));
|
||||||
PrintStream out = new PrintStream(
|
try (PrintStream out = new PrintStream(
|
||||||
new BufferedOutputStream(
|
new BufferedOutputStream(
|
||||||
new FileOutputStream("test.out")));
|
new FileOutputStream("test.out")))) {
|
||||||
System.setIn(in);
|
System.setIn(in);
|
||||||
System.setOut(out);
|
System.setOut(out);
|
||||||
System.setErr(out);
|
System.setErr(out);
|
||||||
BufferedReader br = new BufferedReader(
|
BufferedReader br = new BufferedReader(
|
||||||
new InputStreamReader(System.in));
|
new InputStreamReader(System.in));
|
||||||
String s;
|
String s;
|
||||||
while((s = br.readLine()) != null)
|
while((s = br.readLine()) != null)
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
out.close(); // Remember this!
|
out.close(); // Remember this!
|
||||||
|
}
|
||||||
System.setOut(console);
|
System.setOut(console);
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -4,14 +4,14 @@ import java.io.*;
|
|||||||
public class StoringAndRecoveringData {
|
public class StoringAndRecoveringData {
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DataOutputStream out = new DataOutputStream(
|
try (DataOutputStream out = new DataOutputStream(
|
||||||
new BufferedOutputStream(
|
new BufferedOutputStream(
|
||||||
new FileOutputStream("Data.txt")));
|
new FileOutputStream("Data.txt")))) {
|
||||||
out.writeDouble(3.14159);
|
out.writeDouble(3.14159);
|
||||||
out.writeUTF("That was pi");
|
out.writeUTF("That was pi");
|
||||||
out.writeDouble(1.41413);
|
out.writeDouble(1.41413);
|
||||||
out.writeUTF("Square root of 2");
|
out.writeUTF("Square root of 2");
|
||||||
out.close();
|
}
|
||||||
DataInputStream in = new DataInputStream(
|
DataInputStream in = new DataInputStream(
|
||||||
new BufferedInputStream(
|
new BufferedInputStream(
|
||||||
new FileInputStream("Data.txt")));
|
new FileInputStream("Data.txt")));
|
||||||
|
@ -4,12 +4,12 @@ import java.io.*;
|
|||||||
public class UsingRandomAccessFile {
|
public class UsingRandomAccessFile {
|
||||||
static String file = "rtest.dat";
|
static String file = "rtest.dat";
|
||||||
static void display() throws IOException {
|
static void display() throws IOException {
|
||||||
RandomAccessFile rf = new RandomAccessFile(file, "r");
|
try (RandomAccessFile rf = new RandomAccessFile(file, "r")) {
|
||||||
for(int i = 0; i < 7; i++)
|
for(int i = 0; i < 7; i++)
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Value " + i + ": " + rf.readDouble());
|
"Value " + i + ": " + rf.readDouble());
|
||||||
System.out.println(rf.readUTF());
|
System.out.println(rf.readUTF());
|
||||||
rf.close();
|
}
|
||||||
}
|
}
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
11
io/Worm.java
11
io/Worm.java
@ -46,11 +46,12 @@ public class Worm implements Serializable {
|
|||||||
throws ClassNotFoundException, IOException {
|
throws ClassNotFoundException, IOException {
|
||||||
Worm w = new Worm(6, 'a');
|
Worm w = new Worm(6, 'a');
|
||||||
print("w = " + w);
|
print("w = " + w);
|
||||||
ObjectOutputStream out = new ObjectOutputStream(
|
try (ObjectOutputStream out = new ObjectOutputStream(
|
||||||
new FileOutputStream("worm.out"));
|
new FileOutputStream("worm.out"))) {
|
||||||
out.writeObject("Worm storage\n");
|
out.writeObject("Worm storage\n");
|
||||||
out.writeObject(w);
|
out.writeObject(w);
|
||||||
out.close(); // Also flushes output
|
out.close(); // Also flushes output
|
||||||
|
}
|
||||||
ObjectInputStream in = new ObjectInputStream(
|
ObjectInputStream in = new ObjectInputStream(
|
||||||
new FileInputStream("worm.out"));
|
new FileInputStream("worm.out"));
|
||||||
String s = (String)in.readObject();
|
String s = (String)in.readObject();
|
||||||
|
@ -14,22 +14,21 @@ public class ZipCompress {
|
|||||||
CheckedOutputStream csum =
|
CheckedOutputStream csum =
|
||||||
new CheckedOutputStream(f, new Adler32());
|
new CheckedOutputStream(f, new Adler32());
|
||||||
ZipOutputStream zos = new ZipOutputStream(csum);
|
ZipOutputStream zos = new ZipOutputStream(csum);
|
||||||
BufferedOutputStream out =
|
try (BufferedOutputStream out = new BufferedOutputStream(zos)) {
|
||||||
new BufferedOutputStream(zos);
|
zos.setComment("A test of Java Zipping");
|
||||||
zos.setComment("A test of Java Zipping");
|
// No corresponding getComment(), though.
|
||||||
// No corresponding getComment(), though.
|
for (String arg : args) {
|
||||||
for(String arg : args) {
|
print("Writing file " + arg);
|
||||||
print("Writing file " + arg);
|
try (InputStream in = new BufferedInputStream(
|
||||||
InputStream in = new BufferedInputStream(
|
new FileInputStream(arg))) {
|
||||||
new FileInputStream(arg));
|
zos.putNextEntry(new ZipEntry(arg));
|
||||||
zos.putNextEntry(new ZipEntry(arg));
|
int c;
|
||||||
int c;
|
while((c = in.read()) != -1)
|
||||||
while((c = in.read()) != -1)
|
out.write(c);
|
||||||
out.write(c);
|
}
|
||||||
in.close();
|
out.flush();
|
||||||
out.flush();
|
}
|
||||||
}
|
}
|
||||||
out.close();
|
|
||||||
// Checksum valid only after the file is closed!
|
// Checksum valid only after the file is closed!
|
||||||
print("Checksum: " + csum.getChecksum().getValue());
|
print("Checksum: " + csum.getChecksum().getValue());
|
||||||
// Now extract the files:
|
// Now extract the files:
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AStoreCADState" />
|
<jrun cls="AStoreCADState" />
|
||||||
<jrun cls="AvailableCharSets" />
|
<jrun cls="AvailableCharSets" />
|
||||||
<jrun cls="BasicFileOutput" />
|
<jrun cls="BasicFileOutput" />
|
||||||
@ -51,7 +50,6 @@
|
|||||||
<jrun cls="Worm" />
|
<jrun cls="Worm" />
|
||||||
<jrun cls="ZipCompress" arguments='ZipCompress.java' />
|
<jrun cls="ZipCompress" arguments='ZipCompress.java' />
|
||||||
<jrun cls="ThawAlien" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="ThawAlien" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="ConfigureLogging" />
|
<jrun cls="ConfigureLogging" />
|
||||||
<jrun cls="CustomHandler" />
|
<jrun cls="CustomHandler" />
|
||||||
<jrun cls="InfoLogging" />
|
<jrun cls="InfoLogging" />
|
||||||
@ -19,7 +18,6 @@
|
|||||||
<jrun cls="MultipleHandlers2" />
|
<jrun cls="MultipleHandlers2" />
|
||||||
<jrun cls="PrintableLogRecord" />
|
<jrun cls="PrintableLogRecord" />
|
||||||
<jrun cls="SimpleFilter" />
|
<jrun cls="SimpleFilter" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="net.mindview.atunit.AtUnit" dirpath="../net/mindview/atunit" />
|
<jrun cls="net.mindview.atunit.AtUnit" dirpath="../net/mindview/atunit" />
|
||||||
<jrun cls="net.mindview.atunit.AtUnitRemover" dirpath="../net/mindview/atunit" arguments='..' />
|
<jrun cls="net.mindview.atunit.AtUnitRemover" dirpath="../net/mindview/atunit" arguments='..' failOnError='false' msg='* Exception was Expected *' />
|
||||||
<jrun cls="net.mindview.atunit.ClassNameFinder" dirpath="../net/mindview/atunit" />
|
<jrun cls="net.mindview.atunit.ClassNameFinder" dirpath="../net/mindview/atunit" />
|
||||||
<jrun cls="net.mindview.util.ContainerMethodDifferences" dirpath="../net/mindview/util" />
|
<jrun cls="net.mindview.util.ContainerMethodDifferences" dirpath="../net/mindview/util" />
|
||||||
<jrun cls="net.mindview.util.CountingIntegerList" dirpath="../net/mindview/util" />
|
<jrun cls="net.mindview.util.CountingIntegerList" dirpath="../net/mindview/util" />
|
||||||
@ -19,7 +18,6 @@
|
|||||||
<jrun cls="net.mindview.util.New" dirpath="../net/mindview/util" />
|
<jrun cls="net.mindview.util.New" dirpath="../net/mindview/util" />
|
||||||
<jrun cls="net.mindview.util.ProcessFiles" dirpath="../net/mindview/util" />
|
<jrun cls="net.mindview.util.ProcessFiles" dirpath="../net/mindview/util" />
|
||||||
<jrun cls="net.mindview.util.TextFile" dirpath="../net/mindview/util" />
|
<jrun cls="net.mindview.util.TextFile" dirpath="../net/mindview/util" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//: net/mindview/atunit/AtUnitRemover.java
|
//: net/mindview/atunit/AtUnitRemover.java
|
||||||
// Displays @Unit annotations in compiled class files. If
|
// Displays @Unit annotations in compiled class files. If
|
||||||
// first argument is "-r", @Unit annotations are removed.
|
// first argument is "-r", @Unit annotations are removed.
|
||||||
|
// {ThrowsException} Some kind of bug here...
|
||||||
// {Args: ..}
|
// {Args: ..}
|
||||||
// {Requires: javassist.bytecode.ClassFile;
|
// {Requires: javassist.bytecode.ClassFile;
|
||||||
// You must install the Javassist library from
|
// You must install the Javassist library from
|
||||||
|
@ -5,14 +5,11 @@ import java.io.*;
|
|||||||
|
|
||||||
public class BinaryFile {
|
public class BinaryFile {
|
||||||
public static byte[] read(File bFile) throws IOException{
|
public static byte[] read(File bFile) throws IOException{
|
||||||
BufferedInputStream bf = new BufferedInputStream(
|
try (BufferedInputStream bf = new BufferedInputStream(
|
||||||
new FileInputStream(bFile));
|
new FileInputStream(bFile))) {
|
||||||
try {
|
|
||||||
byte[] data = new byte[bf.available()];
|
byte[] data = new byte[bf.available()];
|
||||||
bf.read(data);
|
bf.read(data);
|
||||||
return data;
|
return data;
|
||||||
} finally {
|
|
||||||
bf.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static byte[]
|
public static byte[]
|
||||||
|
@ -41,11 +41,8 @@ public class ProcessFiles {
|
|||||||
}
|
}
|
||||||
// Demonstration of how to use it:
|
// Demonstration of how to use it:
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new ProcessFiles(new ProcessFiles.Strategy() {
|
new ProcessFiles((File file) -> {
|
||||||
@Override
|
System.out.println(file);
|
||||||
public void process(File file) {
|
|
||||||
System.out.println(file);
|
|
||||||
}
|
|
||||||
}, "java").start(args);
|
}, "java").start(args);
|
||||||
}
|
}
|
||||||
} /* (Execute to see output) *///:~
|
} /* (Execute to see output) *///:~
|
||||||
|
@ -58,7 +58,7 @@ public class RandomGenerator {
|
|||||||
public Long(int modulo) { mod = modulo; }
|
public Long(int modulo) { mod = modulo; }
|
||||||
@Override
|
@Override
|
||||||
public java.lang.Long next() {
|
public java.lang.Long next() {
|
||||||
return new java.lang.Long(r.nextInt(mod));
|
return (long) r.nextInt(mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class
|
public static class
|
||||||
|
@ -7,14 +7,11 @@ import javax.swing.*;
|
|||||||
public class SwingConsole {
|
public class SwingConsole {
|
||||||
public static void
|
public static void
|
||||||
run(final JFrame f, final int width, final int height) {
|
run(final JFrame f, final int width, final int height) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@Override
|
f.setTitle(f.getClass().getSimpleName());
|
||||||
public void run() {
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
f.setTitle(f.getClass().getSimpleName());
|
f.setSize(width, height);
|
||||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
f.setVisible(true);
|
||||||
f.setSize(width, height);
|
|
||||||
f.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -10,16 +10,13 @@ public class TextFile extends ArrayList<String> {
|
|||||||
public static String read(String fileName) {
|
public static String read(String fileName) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
BufferedReader in= new BufferedReader(new FileReader(
|
try (BufferedReader in = new BufferedReader(new FileReader(
|
||||||
new File(fileName).getAbsoluteFile()));
|
new File(fileName).getAbsoluteFile()))) {
|
||||||
try {
|
|
||||||
String s;
|
String s;
|
||||||
while((s = in.readLine()) != null) {
|
while((s = in.readLine()) != null) {
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
in.close();
|
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -29,12 +26,9 @@ public class TextFile extends ArrayList<String> {
|
|||||||
// Write a single file in one method call:
|
// Write a single file in one method call:
|
||||||
public static void write(String fileName, String text) {
|
public static void write(String fileName, String text) {
|
||||||
try {
|
try {
|
||||||
PrintWriter out = new PrintWriter(
|
try (PrintWriter out = new PrintWriter(
|
||||||
new File(fileName).getAbsoluteFile());
|
new File(fileName).getAbsoluteFile())) {
|
||||||
try {
|
|
||||||
out.print(text);
|
out.print(text);
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -53,13 +47,10 @@ public class TextFile extends ArrayList<String> {
|
|||||||
}
|
}
|
||||||
public void write(String fileName) {
|
public void write(String fileName) {
|
||||||
try {
|
try {
|
||||||
PrintWriter out = new PrintWriter(
|
try (PrintWriter out = new PrintWriter(
|
||||||
new File(fileName).getAbsoluteFile());
|
new File(fileName).getAbsoluteFile())) {
|
||||||
try {
|
|
||||||
for(String item : this)
|
for(String item : this)
|
||||||
out.println(item);
|
out.println(item);
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="ChatterClient" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="ChatterClient" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="ChatterServer" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="ChatterServer" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="MultiSimpleClient" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="MultiSimpleClient" failOnError='false' msg='* Exception was Expected *' />
|
||||||
@ -14,7 +13,6 @@
|
|||||||
<jrun cls="SimpleClient" failOnError='false' msg='* Exception was Expected *' />
|
<jrun cls="SimpleClient" failOnError='false' msg='* Exception was Expected *' />
|
||||||
<jrun cls="SimpleServer" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
<jrun cls="SimpleServer" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
|
||||||
<jrun cls="WhoAmI" arguments='MindviewToshibaLaptop' />
|
<jrun cls="WhoAmI" arguments='MindviewToshibaLaptop' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,10 +6,8 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="HelloDate" />
|
<jrun cls="HelloDate" />
|
||||||
<jrun cls="ShowProperties" />
|
<jrun cls="ShowProperties" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public class EqualsMethod {
|
public class EqualsMethod {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Integer n1 = new Integer(47);
|
Integer n1 = 47;
|
||||||
Integer n2 = new Integer(47);
|
Integer n2 = 47;
|
||||||
System.out.println(n1.equals(n2));
|
System.out.println(n1.equals(n2));
|
||||||
}
|
}
|
||||||
} /* Output:
|
} /* Output:
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public class Equivalence {
|
public class Equivalence {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Integer n1 = new Integer(47);
|
Integer n1 = 47;
|
||||||
Integer n2 = new Integer(47);
|
Integer n2 = 47;
|
||||||
System.out.println(n1 == n2);
|
System.out.println(n1 == n2);
|
||||||
System.out.println(n1 != n2);
|
System.out.println(n1 != n2);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="Assignment" />
|
<jrun cls="Assignment" />
|
||||||
<jrun cls="AutoInc" />
|
<jrun cls="AutoInc" />
|
||||||
<jrun cls="BitManipulation" />
|
<jrun cls="BitManipulation" />
|
||||||
@ -28,7 +27,6 @@
|
|||||||
<jrun cls="StringOperators" />
|
<jrun cls="StringOperators" />
|
||||||
<jrun cls="TernaryIfElse" />
|
<jrun cls="TernaryIfElse" />
|
||||||
<jrun cls="URShift" />
|
<jrun cls="URShift" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -79,9 +79,9 @@ public class ShapeFactory2 {
|
|||||||
"Square", "Circle", "Circle", "Square" };
|
"Square", "Circle", "Circle", "Square" };
|
||||||
ArrayList shapes = new ArrayList();
|
ArrayList shapes = new ArrayList();
|
||||||
try {
|
try {
|
||||||
for(int i = 0; i < shlist.length; i++)
|
for (String shlist1 : shlist) {
|
||||||
shapes.add(
|
shapes.add(ShapeFactory.createShape(shlist1));
|
||||||
ShapeFactory.createShape(shlist[i]));
|
}
|
||||||
} catch(BadShapeCreation e) {
|
} catch(BadShapeCreation e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="CommandPattern" />
|
<jrun cls="CommandPattern" />
|
||||||
<jrun cls="Facade" />
|
<jrun cls="Facade" />
|
||||||
<jrun cls="PaperScissorsRock" />
|
<jrun cls="PaperScissorsRock" />
|
||||||
@ -30,7 +29,6 @@
|
|||||||
<jrun cls="patterns.trashvisitor.TrashVisitor" dirpath="../patterns/trashvisitor" />
|
<jrun cls="patterns.trashvisitor.TrashVisitor" dirpath="../patterns/trashvisitor" />
|
||||||
<jrun cls="patterns.visitor.BeeAndFlowers" dirpath="../patterns/visitor" />
|
<jrun cls="patterns.visitor.BeeAndFlowers" dirpath="../patterns/visitor" />
|
||||||
<jrun cls="patterns.visualobserver.BoxObserver" dirpath="../patterns/visualobserver" failOnError='false' timeOut='4000' />
|
<jrun cls="patterns.visualobserver.BoxObserver" dirpath="../patterns/visualobserver" failOnError='false' timeOut='4000' />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -8,9 +8,11 @@ public class DDAluminum extends Aluminum
|
|||||||
public DDAluminum(double wt) { super(wt); }
|
public DDAluminum(double wt) { super(wt); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addToBin(TypedBin[] tb) {
|
public boolean addToBin(TypedBin[] tb) {
|
||||||
for(int i = 0; i < tb.length; i++)
|
for (TypedBin tb1 : tb) {
|
||||||
if(tb[i].add(this))
|
if (tb1.add(this)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -8,9 +8,11 @@ public class DDCardboard extends Cardboard
|
|||||||
public DDCardboard(double wt) { super(wt); }
|
public DDCardboard(double wt) { super(wt); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addToBin(TypedBin[] tb) {
|
public boolean addToBin(TypedBin[] tb) {
|
||||||
for(int i = 0; i < tb.length; i++)
|
for (TypedBin tb1 : tb) {
|
||||||
if(tb[i].add(this))
|
if (tb1.add(this)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -8,9 +8,11 @@ public class DDGlass extends Glass
|
|||||||
public DDGlass(double wt) { super(wt); }
|
public DDGlass(double wt) { super(wt); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addToBin(TypedBin[] tb) {
|
public boolean addToBin(TypedBin[] tb) {
|
||||||
for(int i = 0; i < tb.length; i++)
|
for (TypedBin tb1 : tb) {
|
||||||
if(tb[i].add(this))
|
if (tb1.add(this)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -8,9 +8,11 @@ public class DDPaper extends Paper
|
|||||||
public DDPaper(double wt) { super(wt); }
|
public DDPaper(double wt) { super(wt); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addToBin(TypedBin[] tb) {
|
public boolean addToBin(TypedBin[] tb) {
|
||||||
for(int i = 0; i < tb.length; i++)
|
for (TypedBin tb1 : tb) {
|
||||||
if(tb[i].add(this))
|
if (tb1.add(this)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -63,8 +63,9 @@ public class DoubleDispatch {
|
|||||||
bins.sortIntoBins(bin);
|
bins.sortIntoBins(bin);
|
||||||
TypedBin[] tb = bins.binSet();
|
TypedBin[] tb = bins.binSet();
|
||||||
// Perform sumValue for each bin...
|
// Perform sumValue for each bin...
|
||||||
for(int i = 0; i < tb.length; i++)
|
for (TypedBin tb1 : tb) {
|
||||||
Trash.sumValue(tb[i].v);
|
Trash.sumValue(tb1.v);
|
||||||
|
}
|
||||||
// ... and for the master bin
|
// ... and for the master bin
|
||||||
Trash.sumValue(bin);
|
Trash.sumValue(bin);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,9 @@ public class ShapeFactory1 {
|
|||||||
"Square", "Circle", "Circle", "Square" };
|
"Square", "Circle", "Circle", "Square" };
|
||||||
ArrayList shapes = new ArrayList();
|
ArrayList shapes = new ArrayList();
|
||||||
try {
|
try {
|
||||||
for(int i = 0; i < shlist.length; i++)
|
for (String shlist1 : shlist) {
|
||||||
shapes.add(Shape.factory(shlist[i]));
|
shapes.add(Shape.factory(shlist1));
|
||||||
|
}
|
||||||
} catch(BadShapeCreation e) {
|
} catch(BadShapeCreation e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -9,23 +9,22 @@ public class ParseTrash {
|
|||||||
public static void
|
public static void
|
||||||
fillBin(String filename, Fillable bin) {
|
fillBin(String filename, Fillable bin) {
|
||||||
try {
|
try {
|
||||||
BufferedReader data =
|
try (BufferedReader data = new BufferedReader(
|
||||||
new BufferedReader(
|
new FileReader(filename))) {
|
||||||
new FileReader(filename));
|
String buf;
|
||||||
String buf;
|
while((buf = data.readLine())!= null) {
|
||||||
while((buf = data.readLine())!= null) {
|
if(buf.trim().length() == 0)
|
||||||
if(buf.trim().length() == 0)
|
continue; // Skip empty lines
|
||||||
continue; // Skip empty lines
|
String type = buf.substring(0,
|
||||||
String type = buf.substring(0,
|
buf.indexOf(':')).trim();
|
||||||
buf.indexOf(':')).trim();
|
double weight = Double.valueOf(
|
||||||
double weight = Double.valueOf(
|
buf.substring(buf.indexOf(':') + 1)
|
||||||
buf.substring(buf.indexOf(':') + 1)
|
.trim());
|
||||||
.trim()).doubleValue();
|
bin.addTrash(
|
||||||
bin.addTrash(
|
Trash.factory(
|
||||||
Trash.factory(
|
new Trash.Info(type, weight)));
|
||||||
new Trash.Info(type, weight)));
|
}
|
||||||
}
|
}
|
||||||
data.close();
|
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -39,22 +39,21 @@ public abstract class Trash {
|
|||||||
public static Trash factory(Info info)
|
public static Trash factory(Info info)
|
||||||
throws PrototypeNotFoundException,
|
throws PrototypeNotFoundException,
|
||||||
CannotCreateTrashException {
|
CannotCreateTrashException {
|
||||||
for(int i = 0; i < trashTypes.size(); i++) {
|
for (Object trashType : trashTypes) {
|
||||||
// Somehow determine the new type
|
// Somehow determine the new type
|
||||||
// to create, and create one:
|
// to create, and create one:
|
||||||
Class tc =
|
Class tc = (Class) trashType;
|
||||||
(Class)trashTypes.get(i);
|
if (tc.getName().contains(info.id)) {
|
||||||
if (tc.getName().indexOf(info.id) != -1) {
|
|
||||||
try {
|
try {
|
||||||
// Get the dynamic constructor method
|
// Get the dynamic constructor method
|
||||||
// that takes a double argument:
|
// that takes a double argument:
|
||||||
Constructor ctor =
|
Constructor ctor =
|
||||||
tc.getConstructor(
|
tc.getConstructor(
|
||||||
new Class[] {double.class});
|
new Class[] {double.class});
|
||||||
// Call the constructor to create a
|
// Call the constructor to create a
|
||||||
// new object:
|
// new object:
|
||||||
return (Trash)ctor.newInstance(
|
return (Trash)ctor.newInstance(
|
||||||
new Object[]{new Double(info.data)});
|
new Object[]{info.data});
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw new CannotCreateTrashException();
|
throw new CannotCreateTrashException();
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="CovariantReturn" />
|
<jrun cls="CovariantReturn" />
|
||||||
<jrun cls="FieldAccess" />
|
<jrun cls="FieldAccess" />
|
||||||
<jrun cls="polymorphism.Frog" dirpath="../polymorphism" />
|
<jrun cls="polymorphism.Frog" dirpath="../polymorphism" />
|
||||||
@ -21,7 +20,6 @@
|
|||||||
<jrun cls="polymorphism.music.Music" dirpath="../polymorphism/music" />
|
<jrun cls="polymorphism.music.Music" dirpath="../polymorphism/music" />
|
||||||
<jrun cls="polymorphism.music.Music2" dirpath="../polymorphism/music" />
|
<jrun cls="polymorphism.music.Music2" dirpath="../polymorphism/music" />
|
||||||
<jrun cls="polymorphism.music3.Music3" dirpath="../polymorphism/music3" />
|
<jrun cls="polymorphism.music3.Music3" dirpath="../polymorphism/music3" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -84,7 +84,8 @@ public class CheckCloneable {
|
|||||||
// This won't compile; clone() is protected in Object:
|
// This won't compile; clone() is protected in Object:
|
||||||
//! x = (Ordinary)x.clone();
|
//! x = (Ordinary)x.clone();
|
||||||
// Checks first to see if a class implements Cloneable:
|
// Checks first to see if a class implements Cloneable:
|
||||||
for(int i = 0; i < ord.length; i++)
|
for (Ordinary ord1 : ord) {
|
||||||
tryToClone(ord[i]);
|
tryToClone(ord1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} ///:~
|
} ///:~
|
||||||
|
@ -47,8 +47,9 @@ public class Compete {
|
|||||||
long t1 = System.currentTimeMillis();
|
long t1 = System.currentTimeMillis();
|
||||||
ByteArrayOutputStream buf= new ByteArrayOutputStream();
|
ByteArrayOutputStream buf= new ByteArrayOutputStream();
|
||||||
ObjectOutputStream o = new ObjectOutputStream(buf);
|
ObjectOutputStream o = new ObjectOutputStream(buf);
|
||||||
for(int i = 0; i < a.length; i++)
|
for (Thing2 a1 : a) {
|
||||||
o.writeObject(a[i]);
|
o.writeObject(a1);
|
||||||
|
}
|
||||||
// Now get copies:
|
// Now get copies:
|
||||||
ObjectInputStream in = new ObjectInputStream(
|
ObjectInputStream in = new ObjectInputStream(
|
||||||
new ByteArrayInputStream(buf.toByteArray()));
|
new ByteArrayInputStream(buf.toByteArray()));
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="AddingClone" />
|
<jrun cls="AddingClone" />
|
||||||
<jrun cls="Alias1" />
|
<jrun cls="Alias1" />
|
||||||
<jrun cls="Alias2" />
|
<jrun cls="Alias2" />
|
||||||
@ -25,7 +24,6 @@
|
|||||||
<jrun cls="PassReferences" />
|
<jrun cls="PassReferences" />
|
||||||
<jrun cls="Snake" />
|
<jrun cls="Snake" />
|
||||||
<jrun cls="Stringer" />
|
<jrun cls="Stringer" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
<import file="../Ant-Common.xml"/>
|
<import file="../Ant-Common.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
<touch file="failures"/>
|
|
||||||
<jrun cls="Bath" />
|
<jrun cls="Bath" />
|
||||||
<jrun cls="Beetle" />
|
<jrun cls="Beetle" />
|
||||||
<jrun cls="BlankFinal" />
|
<jrun cls="BlankFinal" />
|
||||||
@ -26,7 +25,6 @@
|
|||||||
<jrun cls="SpaceShipDelegation" />
|
<jrun cls="SpaceShipDelegation" />
|
||||||
<jrun cls="SprinklerSystem" />
|
<jrun cls="SprinklerSystem" />
|
||||||
<jrun cls="Wind" />
|
<jrun cls="Wind" />
|
||||||
<delete file="failures"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user