% to weave:
%	noweave -delay -filter prettyjava -index -backend ./totex jtest.nw > jtest.tex
%	(-index must be *after* prettyjava)
%
\documentclass{article}
\usepackage{noweb,pp-java,amssymb,multicol}
% pp-java package must come *after* noweb
\javaclass{aaa}
\javaclass{a_long_class_name}
\javaclass{another$long$class$name}
\javaclass{AbstractClass}
\javaclass{FinalClass}
\javaclass{PublicClass}
\javaclass{AbstractFinal}
\javaclass{AbstractPublic}
\javaclass{FinalAbstract}
\javaclass{FinalPublic}
\javaclass{PublicFinal}
\javaclass{PublicAbstract}
\javaclass{_Forget_It}
\javaclass{$forget$this$too$}
\javaclass{SomeClass}
\javaclass{AnotherClass}
\javaclass{Object}
\javaclass{OtherClass}
\javaclass{Another}
\javaclass{Other}
\javaclass{String}
\begin{document}
@
This is a class definition
<<Class def'n>>=
class aaa {
	<<Another class>>;
}
@ %def aaa
<<Another class>>=
class a {}
class a_long_class_name {}
class another$long$class$name {}
@ %def a_long_class_name another$long$class$name
@
Some extra chunks for sticking places:
<<some chunk>>=
// empty chunk---Pretzel can't deal with truly empty chunks
<<another chunk>>=
// empty chunk with math $y = \frac{1}{\sqrt{z}}$
@
Now for some class modifiers:
<<More classes>>=
abstract class AbstractClass {}
final class FinalClass{}
public class PublicClass{}
abstract final class AbstractFinal{}
abstract public class AbstractPublic{}
final abstract class FinalAbstract{}
final public class FinalPublic{}
public final class PublicFinal{}
public abstract class PublicAbstract{}
public final abstract class _Forget_It{<<some chunk>>;<<another chunk>>;}
public final abstract class $forget$this$too${<<some chunk>>;<<another chunk>>;}
@ %def AbstractClass FinalClass AbstractFinal AbstractPublic FinalAbstract PublicFinal PublicAbstract FinalPublic _Forget_It PublicClass $forget$this$too$
@
Now lets try some inheritance:
<<Inheriting classes>>=
class a extends b {}
class x implements y {}
class x implements y,z {}
class c extends a, b implements y, z {}
@
Now for some standard declarations:
<<Standard decls>>=
int x;
int y;
boolean p = true;
float f;
boolean p,q = true ,r;
float these, are = n+y, non_trivial, names = a+b;
SomeClass something;
AnotherClass more, than, one;
SomeClass less$, $than, ma$ny;
@ %def these are non_trivial names something more than one less$ $than ma$ny
@
Now the same stuff with modifiers:
<<Standard decls>>=
public int x;
private static boolean p,q,r;
final private protected float these, are, non_trivial, names, and,
the, line, overflows;
static SomeClass something;
private static AnotherClass more, than, one;
@ %def these are non_trivial names something more than one and the line overflows
@
Some array declarations:
<<array declarations>>=
int[]		ai;
short[][]	as;
Object[]	ao,
			otherAo;
short		s,
			as[],
			aas[][];
@ %def ai as ao anotherAo as aas
@
Importing packages:
<<Imports>>=
import java;
<<Imports>>=
import java.util.Vector;
import java.io.*;
<<Imports>>=
import x.y.z.*.*;
import a.*.b;
class x {}
@
Method declarations:
<<Methods>>=
void aMethod() {
}
@ %def aMethod
<<Methods>>=
void aMethod(int x) {
}
@ %def aMethod
<<Methods>>=
void aMethod(Otherclass y) {
}
@ %def aMethod
<<Methods>>=
void aMethod(float f, double d) {
}
@ %def aMethod
<<Methods>>=
void aMethod(Other a, Another b) {
}
@ %def aMethod
<<Methods>>=
void aMethod(int a, other b) {
}
@ %def aMethod
<<Methods>>=
void aMethod(other a, int b) {
}
@ %def aMethod
<<Methods>>=
<<some chunk>>;
private static SomeClass Method() {
	<<some chunk>>;
	<<another chunk>>;
	<<some chunk>>;
	int i;
}
SomeClass Method(int a[], x[] y[]) {
}
<<another chunk>>;
static public private transient boolean Fancy_Method(int a[],
boolean[] b, char c[][], double[][][] d)[] throws x,y,z {
}
@ %def Method Fancy_Method
<<Methods>>=
public Constructor(){}
AnotherConstructor(a b, c d) throws nothing {}
@ %def Constructor AnotherConstructor
@
<<Statements>>=
;;
{
int i;
<<some chunk>>;
<<another chunk>>;
}
label: {super;this;null;}
default: null;
case xxx: case yyy: case zzz:
case hello: this;
@ %def label
@
<<Statements>>=
"Hello, world\n";
"This \"string\" has quotes (\") in it";
'Hello, world\n';
'This \'string\' has quotes in it';
@
<<Unary operators>>=
+x;-x;~x;!x;new x;
<<Increment operators>>=
x++;++x;x--;--x;
<<Increment operators>>=
(x++);(x--);
<<Increment operators>>=
(++x);(--x);
<<Special operator>>=
x ? y : z;
<<Binary operators>>=
x>y;
x<y;
x==y;
x<=y;
x>=y;
x!=y;
x&&y;
x||y;
x+y;
x-y;
x*y;
x/y;
x&y;
x|y;
x^y;
x%y;
x<<y;
x>>y;
x>>>y;
<<Assignments>>=
x=y;
x+=y;
x-=y;
x*=y;
x/=y;
x&=y;
x|=y;
x^=y;
x%=y;
x<<=y;
x>>=y;
x>>>=y;
<<Complex examples>>=
Long_variable = x.a + y * sqrt(george_jr);
new double[a][a][];
float[][] matrix=
new float[a][];
String[][][][][] fivedims =
new String[n][m][o][p][];
(int) x + (float) y * (double[])z / (SomeClass) a;
x instanceof String[];
a *= (y+z.a.m.n/x_y_z)^(f(y,z,sqrt(nnn),b+c) == null);
x = y[n];
@ %def matrix fivedims
@
<<Some jumps>>=
break;
continue;
return;
break some_label;
continue some_label;
return x+y*z- -a;
throw a/b/c/+z;
<<Synchronized>>=
x = (y[n]+z[m]);
synchronized (x) x = y;
synchronized (xyz[n]+abc[m]) { <<some chunk>>; }
@
Let's look at some numbers:
<<numbers>>=
x=y+1;
<<numbers>>=
x*=2;
x+=0+2+
0777
+0xDadaCafe
+0777777777777777777777L
+0x7fffffffffffffffL
+0x8000000000000000L
+01777777777777777777777L;
<<numbers>>=
x-=0+2+0666+0XdADAcAFE
+0777777777777777777777l
+0X7FFFFFFFFFFFFFFFl
+0X8000000000000000l
+01777777777777777777777l;
<<numbers>>=
1e1f+2.f+.3f+3.14f+6.02e+23f+1e1+2+.3+3.14+1e-9d
<<numbers>>=
1E1F+2.F+.3F+3.14F+6.02E+23F+1E1+2+.3+3.14+1E-9D
<<chunks together>>=
class <<some chunk>> extends <<another chunk>> {
	AbstractPublic ap;
	<<Complex examples>>;
	aMethod(false, '\u0000', -128, -32768, -3.40292347e+38);
	aMethod(true,  '\uFFFF', +127, +32767, +3.40292347e+38);
	<<Synchronized>>
	<<numbers>>;
}
@
\section*{Identifier Index}
\begin{multicols}{2}
\nowebindex
\end{multicols}
\end{document}
