public class DummyGraphics2d
        extends Graphics2D
{
    BufferedImage img;
    private Graphics2D g2D;

    public DummyGraphics2d()
    {
        img = new BufferedImage(1000, 1000, 2);
        g2D = (Graphics2D)img.getGraphics();
    }

    public void addRenderingHints(Map hints)
    {
        System.out.println( "addRenderingHinds(Map):" );
        System.out.println( "  hints = " + hints );
        g2D.addRenderingHints( hints );
    }

    public void clip(Shape s)
    {
        System.out.println( "clip(Shape):" );
        System.out.println( "  s = " + s );
        g2D.clip( s );
    }

    public void draw(Shape s)
    {
        System.out.println( "draw(Shape):" );
        System.out.println( "s = " + s );
        g2D.draw( s );
    }

    public void drawGlyphVector(GlyphVector g, float x, float y)
    {
        System.out.println( "drawGlyphVector(GlyphVector, float, float):" );
        System.out.println( "g = " + g );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawGlyphVector( g, x, y );
    }

    public void drawImage(BufferedImage img,
				   BufferedImageOp op,
				   int x,
				   int y)
    {
        System.out.println( "drawImage(BufferedImage, BufferedImageOp, x, y):" );
        System.out.println( "img = " + img );
        System.out.println( "op = " + op );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawImage( img, op, x, y );
    }

    public boolean drawImage(Image img,
                                      AffineTransform xform,
                                      ImageObserver obs)
    {
        System.out.println( "drawImage(Image,AfflineTransform,ImageObserver):" );
        System.out.println( "img = " + img );
        System.out.println( "xform = " + xform );
        System.out.println( "obs = " + obs );
        return g2D.drawImage( img, xform, obs );
    }

    public void drawRenderableImage(RenderableImage img,
                                             AffineTransform xform)
    {
        System.out.println( "drawRenderableImage(RenderableImage, AfflineTransform):" );
        System.out.println( "img = " + img );
        System.out.println( "xform = " + xform );
        g2D.drawRenderableImage( img, xform );
    }

    public void drawRenderedImage(RenderedImage img,
                                           AffineTransform xform)
    {
        System.out.println( "drawRenderedImage(RenderedImage, AffineTransform):" );
        System.out.println( "img = " + img );
        System.out.println( "xform = " + xform );
        g2D.drawRenderedImage( img, xform );
    }

    public void drawString(AttributedCharacterIterator iterator,
                                    float x, float y)
    {
        System.out.println( "drawString(AttributedCharacterIterator):" );
        System.out.println( "iterator = " + iterator );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawString( iterator, x, y );
    }

    public void drawString(String s, float x, float y)
    {
        System.out.println( "drawString(s,x,y):" );
        System.out.println( "s = " + s );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawString( s, x, y );
    }

    public void fill(Shape s)
    {
        System.out.println( "fill(Shape):" );
        System.out.println( "s = " + s );
        g2D.fill( s );
    }

    public Color getBackground()
    {
        System.out.println( "getBackground():" );
        return g2D.getBackground();
    }

    public Composite getComposite()
    {
        System.out.println( "getComposite():" );
        return g2D.getComposite();
    }

    public GraphicsConfiguration getDeviceConfiguration()
    {
        System.out.println( "getDeviceConfiguration():" );
        return g2D.getDeviceConfiguration();
    }

    public FontRenderContext getFontRenderContext()
    {
        System.out.println( "getFontRenderContext():" );
        return g2D.getFontRenderContext();
    }

    public Paint getPaint()
    {
        System.out.println( "getPaint():" );
        return g2D.getPaint();
    }

    public Object getRenderingHint(RenderingHints.Key hintKey)
    {
        System.out.println( "getRenderingHint(RenderingHints.Key):" );
        System.out.println( "hintKey = " + hintKey );
        return g2D.getRenderingHint( hintKey );
    }

    public RenderingHints getRenderingHints()
    {
        System.out.println( "getRenderingHints():" );
        return g2D.getRenderingHints();
    }

    public Stroke getStroke()
    {
        System.out.println( "getStroke():" );
        return g2D.getStroke();
    }

    public AffineTransform getTransform()
    {
        System.out.println( "getTransform():" );
        return g2D.getTransform();
    }

    public boolean hit(Rectangle rect,
				Shape s,
				boolean onStroke)
    {
        System.out.println( "hit(Rectangle, Shape, onStroke):" );
        System.out.println( "rect = " + rect );
        System.out.println( "s = " + s );
        System.out.println( "onStroke = " + onStroke );
        return g2D.hit( rect, s, onStroke );
    }

    public void rotate(double theta)
    {
        System.out.println( "rotate(theta):" );
        System.out.println( "theta = " + theta );
        g2D.rotate( theta );
    }

    public void rotate(double theta, double x, double y)
    {
        System.out.println( "rotate(double,double,double):" );
        System.out.println( "theta = " + theta );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.rotate( theta, x, y );
    }

    public void scale(double sx, double sy)
    {
        System.out.println( "scale(double,double):" );
        System.out.println( "sx = " + sx );
        System.out.println( "sy" );
        g2D.scale( sx, sy );
    }

    public void setBackground(Color color)
    {
        System.out.println( "setBackground(Color):" );
        System.out.println( "color = " + color );
        g2D.setBackground( color );
    }

    public void setComposite(Composite comp)
    {
        System.out.println( "setComposite(Composite):" );
        System.out.println( "comp = " + comp );
        g2D.setComposite( comp );
    }

    public void setPaint( Paint paint )
    {
        System.out.println( "setPain(Paint):" );
        System.out.println( "paint = " + paint );
        g2D.setPaint( paint );
    }

    public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
    {
        System.out.println( "setRenderingHint(RenderingHints.Key, Object):" );
        System.out.println( "hintKey = " + hintKey );
        System.out.println( "hintValue = " + hintValue );
        g2D.setRenderingHint( hintKey, hintValue );
    }

    public void setRenderingHints(Map hints)
    {
        System.out.println( "setRenderingHints(Map):" );
        System.out.println( "hints = " + hints );
        g2D.setRenderingHints( hints );
    }

    public void setStroke(Stroke s)
    {
        System.out.println( "setStroke(Stoke):" );
        System.out.println( "s = " + s );
        g2D.setStroke( s );
    }

    public void setTransform(AffineTransform Tx)
    {
        System.out.println( "setTransform():" );
        System.out.println( "Tx = " + Tx );
        g2D.setTransform( Tx );
    }

    public void shear(double shx, double shy)
    {
        System.out.println( "shear(shx, dhy):" );
        System.out.println( "shx = " + shx );
        System.out.println( "shy = " + shy );
        g2D.shear( shx, shy );
    }

    public void transform(AffineTransform Tx)
    {
        System.out.println( "transform(AffineTransform):" );
        System.out.println( "Tx = " + Tx );
        g2D.transform( Tx );
    }

    public void translate(double tx, double ty)
    {
        System.out.println( "translate(double, double):" );
        System.out.println( "tx = " + tx );
        System.out.println( "ty = " + ty );
        g2D.translate( tx, ty );
    }

    public void clearRect(int x, int y, int width, int height)
    {
        System.out.println( "clearRect(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.clearRect( x, y, width, height );
    }

    public void clipRect(int x, int y, int width, int height)
    {
        System.out.println( "clipRect(int, int, int, int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.clipRect( x, y, width, height );
    }

    public void copyArea(int x, int y, int width, int height,
				  int dx, int dy)
    {
        System.out.println( "copyArea(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.copyArea( x, y, width, height, dx, dy );
    }

    public Graphics create()
    {
        System.out.println( "create():" );
        return g2D.create();
    }

    public Graphics create(int x, int y, int width, int height) {
        System.out.println( "create(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        return g2D.create( x, y, width, height );
    }

    public void dispose()
    {
        System.out.println( "dispose():" );
        g2D.dispose();
    }

    public void draw3DRect(int x, int y, int width, int height,
			   boolean raised) {
        System.out.println( "draw3DRect(int,int,int,int,boolean):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "raised = " + raised );
        g2D.draw3DRect( x, y, width, height, raised );
    }

    public void drawArc(int x, int y, int width, int height,
				 int startAngle, int arcAngle)
    {
        System.out.println( "drawArc(int,int,int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "startAngle = " + startAngle );
        System.out.println( "arcAngle = " + arcAngle );
        g2D.drawArc( x, y, width, height, startAngle, arcAngle );
    }

    public void drawBytes(byte data[], int offset, int length, int x, int y) {
        System.out.println( "drawBytes(byte[],int,int,int,int):" );
        System.out.println( "data = " + data );
        System.out.println( "offset = " + offset );
        System.out.println( "length = " + length );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawBytes( data, offset, length, x, y );
    }

    public void drawChars(char data[], int offset, int length, int x, int y) {
        System.out.println( "drawChars(data,int,int,int,int):" );
        System.out.println( "data = " + data.toString() );
        System.out.println( "offset = " + offset );
        System.out.println( "length = " + length );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawChars( data, offset, length, x, y );
    }

    public boolean drawImage(Image img,
				      int dx1, int dy1, int dx2, int dy2,
				      int sx1, int sy1, int sx2, int sy2,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" );
        System.out.println( "img = " + img );
        System.out.println( "dx1 = " + dx1 );
        System.out.println( "dy1 = " + dy1 );
        System.out.println( "dx2 = " + dx2 );
        System.out.println( "dy2 = " + dy2 );
        System.out.println( "sx1 = " + sx1 );
        System.out.println( "sy1 = " + sy1 );
        System.out.println( "sx2 = " + sx2 );
        System.out.println( "sy2 = " + sy2 );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer );
    }

    public boolean drawImage(Image img,
				      int dx1, int dy1, int dx2, int dy2,
				      int sx1, int sy1, int sx2, int sy2,
				      Color bgcolor,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):" );
        System.out.println( "img = " + img );
        System.out.println( "dx1 = " + dx1 );
        System.out.println( "dy1 = " + dy1 );
        System.out.println( "dx2 = " + dx2 );
        System.out.println( "dy2 = " + dy2 );
        System.out.println( "sx1 = " + sx1 );
        System.out.println( "sy1 = " + sy1 );
        System.out.println( "sx2 = " + sx2 );
        System.out.println( "sy2 = " + sy2 );
        System.out.println( "bgcolor = " + bgcolor );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer );
    }

    public boolean drawImage(Image img, int x, int y,
				      Color bgcolor,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,Color,ImageObserver):" );
        System.out.println( "img = " + img );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "bgcolor = " + bgcolor );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, x, y, bgcolor, observer );
    }

    public boolean drawImage(Image img, int x, int y,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,observer):" );
        System.out.println( "img = " + img );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, x, y, observer );
    }

    public boolean drawImage(Image img, int x, int y,
				      int width, int height,
				      Color bgcolor,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,int,int,Color,ImageObserver):" );
        System.out.println( "img = " + img );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "bgcolor = " + bgcolor );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, x, y, width, height, bgcolor, observer );
    }

    public boolean drawImage(Image img, int x, int y,
				      int width, int height,
				      ImageObserver observer)
    {
        System.out.println( "drawImage(Image,int,int,width,height,observer):" );
        System.out.println( "img = " + img );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "observer = " + observer );
        return g2D.drawImage( img, x, y, width, height, observer );
    }

    public void drawLine(int x1, int y1, int x2, int y2)
    {
        System.out.println( "drawLine(int,int,int,int):" );
        System.out.println( "x1 = " + x1 );
        System.out.println( "y1 = " + y1 );
        System.out.println( "x2 = " + x2 );
        System.out.println( "y2 = " + y2 );
        g2D.drawLine( x1, y1, x2, y2 );
    }

    public void drawOval(int x, int y, int width, int height)
    {
        System.out.println( "drawOval(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.drawOval( x, y, width, height );
    }

    public void drawPolygon(Polygon p) {
        System.out.println( "drawPolygon(Polygon):" );
        System.out.println( "p = " + p );
        g2D.drawPolygon( p );
    }

    public void drawPolygon(int xPoints[], int yPoints[],
				     int nPoints)
    {
        System.out.println( "drawPolygon(int[],int[],int):" );
        System.out.println( "xPoints = " + xPoints );
        System.out.println( "yPoints = " + yPoints );
        System.out.println( "nPoints = " + nPoints );
        g2D.drawPolygon( xPoints, yPoints, nPoints );
    }

    public void drawPolyline(int xPoints[], int yPoints[],
				      int nPoints)
    {
        System.out.println( "drawPolyline(int[],int[],int):" );
        System.out.println( "xPoints = " + xPoints );
        System.out.println( "yPoints = " + yPoints );
        System.out.println( "nPoints = " + nPoints );
        g2D.drawPolyline( xPoints, yPoints, nPoints );
    }

    public void drawRect(int x, int y, int width, int height) {
        System.out.println( "drawRect(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.drawRect( x, y, width, height );
    }

    public void drawRoundRect(int x, int y, int width, int height,
				       int arcWidth, int arcHeight)
    {
        System.out.println( "drawRoundRect(int,int,int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "arcWidth = " + arcWidth );
        System.out.println( "arcHeight = " + arcHeight );
        g2D.drawRoundRect( x, y, width, height, arcWidth, arcHeight );
    }

    public void drawString(AttributedCharacterIterator iterator,
                                    int x, int y)
    {
        System.out.println( "drawString(AttributedCharacterIterator,int,int):" );
        System.out.println( "iterator = " + iterator );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawString( iterator, x, y );
    }

    public void drawString(String str, int x, int y)
    {
        System.out.println( "drawString(str,int,int):" );
        System.out.println( "str = " + str );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.drawString( str, x, y );
    }

    public void fill3DRect(int x, int y, int width, int height,
			   boolean raised) {
        System.out.println( "fill3DRect(int,int,int,int,boolean):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "raised = " + raised );
        g2D.fill3DRect( x, y, width, height, raised );
    }

    public void fillArc(int x, int y, int width, int height,
				 int startAngle, int arcAngle)
    {
        System.out.println( "fillArc(int,int,int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        System.out.println( "startAngle = " + startAngle );
        System.out.println( "arcAngle = " + arcAngle );
        g2D.fillArc( x, y, width, height, startAngle, arcAngle );
    }

    public void fillOval(int x, int y, int width, int height)
    {
        System.out.println( "fillOval(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.fillOval( x, y, width, height );
    }

    public void fillPolygon(Polygon p) {
        System.out.println( "fillPolygon(Polygon):" );
        System.out.println( "p = " + p );
        g2D.fillPolygon( p );
    }

    public void fillPolygon(int xPoints[], int yPoints[],
				     int nPoints)
    {
        System.out.println( "fillPolygon(int[],int[],int):" );
        System.out.println( "xPoints = " + xPoints );
        System.out.println( "yPoints = " + yPoints );
        System.out.println( "nPoints = " + nPoints );
        g2D.fillPolygon( xPoints, yPoints, nPoints );
    }

    public void fillRect(int x, int y, int width, int height)
    {
        System.out.println( "fillRect(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.fillRect( x, y, width, height );
    }

    public void fillRoundRect(int x, int y, int width, int height,
				       int arcWidth, int arcHeight)
    {
        System.out.println( "fillRoundRect(int,int,int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.fillRoundRect( x, y, width, height, arcWidth, arcHeight );
    }

    public void finalize() {
        System.out.println( "finalize():" );
        g2D.finalize();
    }

    public Shape getClip()
    {
        System.out.println( "getClip():" );
        return g2D.getClip();
    }

    public Rectangle getClipBounds()
    {
        System.out.println( "getClipBounds():" );
        return g2D.getClipBounds();
    }

    public Rectangle getClipBounds(Rectangle r) {
        System.out.println( "getClipBounds(Rectangle):" );
        System.out.println( "r = " + r );
        return g2D.getClipBounds( r );
    }

    public Rectangle getClipRect() {
        System.out.println( "getClipRect():" );
        return g2D.getClipRect();
    }

    public Color getColor()
    {
        System.out.println( "getColor():" );
        return g2D.getColor();
    }

    public Font getFont()
    {
        System.out.println( "getFont():" );
        return g2D.getFont();
    }

    public FontMetrics getFontMetrics() {
        System.out.println( "getFontMetrics():" );
        return g2D.getFontMetrics();
    }

    public FontMetrics getFontMetrics(Font f)
    {
        System.out.println( "getFontMetrics():" );
        return g2D.getFontMetrics( f );
    }

    public boolean hitClip(int x, int y, int width, int height) {
        System.out.println( "hitClip(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        return g2D.hitClip( x, y, width, height );
    }

    public void setClip(Shape clip)
    {
        System.out.println( "setClip(Shape):" );
        System.out.println( "clip = " + clip );
        g2D.setClip( clip );
    }

    public void setClip(int x, int y, int width, int height)
    {
        System.out.println( "setClip(int,int,int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        System.out.println( "width = " + width );
        System.out.println( "height = " + height );
        g2D.setClip( x, y, width, height );
    }

    public void setColor(Color c)
    {
        System.out.println( "setColor():" );
        System.out.println( "c = " + c );
        g2D.setColor( c );
    }

    public void setFont(Font font)
    {
        System.out.println( "setFont(Font):" );
        System.out.println( "font = " + font );
        g2D.setFont( font );
    }

    public void setPaintMode()
    {
        System.out.println( "setPaintMode():" );
        g2D.setPaintMode();
    }

    public void setXORMode(Color c1)
    {
        System.out.println( "setXORMode(Color):" );
        System.out.println( "c1 = " + c1 );
        g2D.setXORMode( c1 );
    }

    public String toString() {
        System.out.println( "toString():" );
        return g2D.toString();
    }

    public void translate(int x, int y)
    {
        System.out.println( "translate(int,int):" );
        System.out.println( "x = " + x );
        System.out.println( "y = " + y );
        g2D.translate( x, y );

    public void clip(Shape s)
    {
        System.out.println( "clip(Shape):" );
        System.out.println( "  s = " + s );
        g2D.clip( s );

    public void draw(Shape s)
    {
        System.out.println( "draw(Shape):" );
        System.out.println( "s = " + s );
        g2D.draw( s );

    public void fill(Shape s)
    {
        System.out.println( "fill(Shape):" );
        System.out.println( "s = " + s );
        g2D.fill( s );

    public Color getBackground()
    {
        System.out.println( "getBackground():" );
        return g2D.getBackground();

    public Composite getComposite()
    {
        System.out.println( "getComposite():" );
        return g2D.getComposite();

    public Paint getPaint()
    {
        System.out.println( "getPaint():" );
        return g2D.getPaint();

    public Stroke getStroke()
    {
        System.out.println( "getStroke():" );
        return g2D.getStroke();

    public AffineTransform getTransform()
    {
        System.out.println( "getTransform():" );
        return g2D.getTransform();

    public Graphics create()
    {
        System.out.println( "create():" );
        return g2D.create();

    public void dispose()
    {
        System.out.println( "dispose():" );
        g2D.dispose();

    public void finalize() {
        System.out.println( "finalize():" );
        g2D.finalize();

    public Shape getClip()
    {
        System.out.println( "getClip():" );
        return g2D.getClip();

    public Rectangle getClipBounds()
    {
        System.out.println( "getClipBounds():" );
        return g2D.getClipBounds();

    public Rectangle getClipRect() {
        System.out.println( "getClipRect():" );
        return g2D.getClipRect();

    public Color getColor()
    {
        System.out.println( "getColor():" );
        return g2D.getColor();

    public Font getFont()
    {
        System.out.println( "getFont():" );
        return g2D.getFont();

    public FontMetrics getFontMetrics() {
        System.out.println( "getFontMetrics():" );
        return g2D.getFontMetrics();

    public FontMetrics getFontMetrics(Font f)
    {
        System.out.println( "getFontMetrics():" );
        return g2D.getFontMetrics( f );

FUNC_DECL RETURN PARAM CALL CALL LITERAL_ANCHOR

    public void setColor(Color c)
    {
        System.out.println( "setColor():" );
        System.out.println( "c = " + c );
        g2D.setColor( c );

    public void setPaintMode()
    {
        System.out.println( "setPaintMode():" );
        g2D.setPaintMode();

    public String toString() {
        System.out.println( "toString():" );
        return g2D.toString();

    public DummyGraphics2d()
    {
        img = new BufferedImage(1000, 1000, 2);
        g2D = (Graphics2D)img.getGraphics();


public abstract class BaseExtendSelector extends BaseSelector implements
        ExtendFileSelector {

    /** The passed in parameter array. */
    protected Parameter[] parameters = null;

    /**
     * Default constructor.
     */
    public BaseExtendSelector() {
    }

    /**
     * Set all the Parameters for this custom selector, collected by
     * the ExtendSelector class.
     *
     * @param parameters the complete set of parameters for this selector
     */
    public void setParameters(Parameter[] parameters) {
        this.parameters = parameters;
    }

    /**
     * Allows access to the parameters gathered and set within the
     * <custom> tag.
     *
     * @return the set of parameters defined for this selector
     */
    protected Parameter[] getParameters() {
        return parameters;
    }

    /**
     * Method that each selector will implement to create their
     * selection behaviour. If there is a problem with the setup
     * of a selector, it can throw a BuildException to indicate
     * the problem.
     *
     * @param basedir A java.io.File object for the base directory
     * @param filename The name of the file to check
     * @param file A File object for this filename
     * @return whether the file should be selected or not
     */
    public abstract boolean isSelected(File basedir, String filename,
                                       File file)


public class POIFSReader
{
    private POIFSReaderRegistry registry;
    private boolean             registryClosed;

    /**
     * Create a POIFSReader
     */

    public POIFSReader()
    {
        registry       = new POIFSReaderRegistry();
        registryClosed = false;
    }

    /**
     * Read from an InputStream and process the documents we get
     *
     * @param stream the InputStream from which to read the data
     *
     * @exception IOException on errors reading, or on invalid data
     */

    public void read(final InputStream stream)
        throws IOException
    {
        registryClosed = true;

        HeaderBlockReader header_block_reader = new HeaderBlockReader(stream);

        RawDataBlockList  data_blocks         = new RawDataBlockList(stream);

        new BlockAllocationTableReader(header_block_reader.getBATCount(),
                                       header_block_reader.getBATArray(),
                                       header_block_reader.getXBATCount(),
                                       header_block_reader.getXBATIndex(),
                                       data_blocks);

        PropertyTable properties =
            new PropertyTable(header_block_reader.getPropertyStart(),
                              data_blocks);

        processProperties(SmallBlockTableReader
            .getSmallDocumentBlocks(data_blocks, properties
                .getRoot(), header_block_reader
                    .getSBATStart()), data_blocks, properties.getRoot()
                        .getChildren(), new POIFSDocumentPath());
    }

    /**
     * Register a POIFSReaderListener for all documents
     *
     * @param listener the listener to be registered
     *
     * @exception NullPointerException if listener is null
     * @exception IllegalStateException if read() has already been
     *                                  called
     */

    public void registerListener(final POIFSReaderListener listener)
    {
        if (listener == null)
        {
            throw new NullPointerException();
        }
        if (registryClosed)
        {
            throw new IllegalStateException();
        }
        registry.registerListener(listener);
    }

    /**
     * Register a POIFSReaderListener for a document in the root
     * directory
     *
     * @param listener the listener to be registered
     * @param name the document name
     *
     * @exception NullPointerException if listener is null or name is
     *                                 null or empty
     * @exception IllegalStateException if read() has already been
     *                                  called
     */

    public void registerListener(final POIFSReaderListener listener,
                                 final String name)
    {
        registerListener(listener, null, name);
    }

    /**
     * Register a POIFSReaderListener for a document in the specified
     * directory
     *
     * @param listener the listener to be registered
     * @param path the document path; if null, the root directory is
     *             assumed
     * @param name the document name
     *
     * @exception NullPointerException if listener is null or name is
     *                                 null or empty
     * @exception IllegalStateException if read() has already been
     *                                  called
     */

    public void registerListener(final POIFSReaderListener listener,
                                 final POIFSDocumentPath path,
                                 final String name)
    {
        if ((listener == null) || (name == null) || (name.length() == 0))
        {
            throw new NullPointerException();
        }
        if (registryClosed)
        {
            throw new IllegalStateException();
        }
        registry.registerListener(listener,
                                  (path == null) ? new POIFSDocumentPath()
                                                 : path, name);
    }

    /**
     * read in files
     *
     * @param args names of the files
     *
     * @exception IOException
     */

    public static void main(String args[])
        throws IOException
    {
        if (args.length == 0)
        {
            System.err
                .println("at least one argument required: input filename(s)");
            System.exit(1);
        }

        for (int j = 0; j < args.length; j++)
        {
            POIFSReader         reader   = new POIFSReader();
            POIFSReaderListener listener = new SampleListener();

            reader.registerListener(listener);
            System.out.println("reading " + args[ j ]);
            FileInputStream istream = new FileInputStream(args[ j ]);

            reader.read(istream);
            istream.close();
        }
    }

    private void processProperties(final BlockList small_blocks,
                                   final BlockList big_blocks,
                                   final Iterator properties,
                                   final POIFSDocumentPath path)
        throws IOException
    {
        while (properties.hasNext())
        {
            Property property = ( Property ) properties.next();
            String   name     = property.getName();

            if (property.isDirectory())
            {
                POIFSDocumentPath new_path = new POIFSDocumentPath(path,
                                                 new String[]
                {
                    name
                });

                processProperties(
                    small_blocks, big_blocks,
                    (( DirectoryProperty ) property).getChildren(), new_path);
            }
            else
            {
                int      startBlock = property.getStartBlock();
                Iterator listeners  = registry.getListeners(path, name);

                if (listeners.hasNext())
                {
                    int           size     = property.getSize();
                    POIFSDocument document = null;

                    if (property.shouldUseSmallBlocks())
                    {
                        document =
                            new POIFSDocument(name, small_blocks
                                .fetchBlocks(startBlock), size);
                    }
                    else
                    {
                        document =
                            new POIFSDocument(name, big_blocks
                                .fetchBlocks(startBlock), size);
                    }
                    while (listeners.hasNext())
                    {
                        POIFSReaderListener listener =
                            ( POIFSReaderListener ) listeners.next();

                        listener.processPOIFSReaderEvent(
                            new POIFSReaderEvent(
                                new DocumentInputStream(document), path,
                                name));
                    }
                }
                else
                {

                    if (property.shouldUseSmallBlocks())
                    {
                        small_blocks.fetchBlocks(startBlock);
                    }
                    else
                    {
                        big_blocks.fetchBlocks(startBlock);
                    }
                }
            }
        }
    }

    private static class SampleListener
        implements POIFSReaderListener
    {

        /**
         * Constructor SampleListener
         */

        SampleListener()
        {
        }

        /**
         * Method processPOIFSReaderEvent
         *
         * @param event
         */

        public void processPOIFSReaderEvent(final POIFSReaderEvent event)
        {
            DocumentInputStream istream = event.getStream();
            POIFSDocumentPath   path    = event.getPath();
            String              name    = event.getName();

            try
            {
                byte[] data = new byte[ istream.available() ];

                istream.read(data);
                int pathLength = path.length();

                for (int k = 0; k < pathLength; k++)
                {
                    System.out.print("/" + path.getComponent(k));
                }
                System.out.println("/" + name + ": " + data.length
                                   + " bytes read");

FUNC_DECL VAR_DECL VAR_DECL VAR_DECL PARAM CALL CALL ASSIGN CALL CALL CALL CALL CALL CALL CALL CALL CALL CALL LITERAL_ANCHOR CALL CALL CALL CALL

FUNC_DECL LOOP PARAM PARAM PARAM PARAM CALL IF VAR_DECL VAR_DECL CALL IF VAR_DECL VAR_DECL VAR_DECL CALL CALL CALL CALL IF LOOP IF VAR_DECL VAR_DECL CALL CALL CALL CALL CALL CALL VAR_DECL LITERAL_ANCHOR CALL CALL CALL CALL ASSIGN ASSIGN CALL CALL CALL CALL CALL CALL CALL


public class TopicLoadBalancer extends LoadBalancerSupport {

    public void process(Exchange exchange) throws Exception {
        List<Processor> list = getProcessors();
        for (Processor processor : list) {
            Exchange copy = copyExchangeStrategy(processor, exchange);
            processor.process(copy);
        }
    }

    /**
     * Strategy method to copy the exchange before sending to another endpoint.
     * Derived classes such as the {@link org.apache.camel.processor.Pipeline Pipeline}
     * will not clone the exchange
     *
     * @param processor the processor that will send the exchange
     * @param exchange  the exchange
     * @return the current exchange if no copying is required such as for a
     *         pipeline otherwise a new copy of the exchange is returned.
     */
    protected Exchange copyExchangeStrategy(Processor processor, Exchange exchange) {
        return exchange.copy();
    }

    public boolean process(Exchange exchange, AsyncCallback callback) {
        List<Processor> list = getProcessors();
        for (Processor processor : list) {
            Exchange copy = copyExchangeStrategy(processor, exchange);
            try {
                processor.process(copy);
            } catch (Exception ex) {
            }
        }
        callback.done(false);
        return false;

FUNC_DECL RETURN LOOP VAR_DECL PARAM PARAM LITERAL_ANCHOR CALL LITERAL_ANCHOR TRY VAR_DECL CALL CATCH CALL CALL


gnu.regexp.RETokenRepeated

final class RETokenRepeated extends REToken {
    private REToken token;
    private int min,max;
    private boolean stingy;

    RETokenRepeated(int subIndex, REToken token, int min, int max) {
	super(subIndex);
	this.token = token;
	this.min = min;
	this.max = max;
    }

    /** Sets the minimal matching mode to true. */
    void makeStingy() {
	stingy = true;
    }

    /** Queries if this token has minimal matching enabled. */
    boolean isStingy() {
	return stingy;
    }

    /**
     * The minimum length of a repeated token is the minimum length
     * of the token multiplied by the minimum number of times it must
     * match.
     */
    int getMinimumLength() {
	return (min * token.getMinimumLength());
    }

    // We do need to save every possible point, but the number of clone()
    // invocations here is really a killer for performance on non-stingy
    // repeat operators.  I'm open to suggestions...

    // Hypothetical question: can you have a RE that matches 1 times,
    // 3 times, 5 times, but not 2 times or 4 times?  Does having
    // the subexpression back-reference operator allow that?

    boolean match(CharIndexed input, REMatch mymatch) {
	// number of times we've matched so far
	int numRepeats = 0;

	// Possible positions for the next repeat to match at
	REMatch newMatch = mymatch;
	REMatch last = null;
	REMatch current;

	// Add the '0-repeats' index
	// positions.elementAt(z) == position [] in input after <<z>> matches
	Vector positions = new Vector();
	positions.addElement(newMatch);

	// Declare variables used in loop
	REMatch doables;
	REMatch doablesLast;
	REMatch recurrent;

	do {
	    // Check for stingy match for each possibility.
	    if (stingy && (numRepeats >= min)) {
		REMatch result = matchRest(input, newMatch);
		if (result != null) {
		    mymatch.assignFrom(result);
		    return true;
		}
	    }

	    doables = null;
	    doablesLast = null;

	    // try next repeat at all possible positions
	    for (current = newMatch; current != null; current = current.next) {
		recurrent = (REMatch) current.clone();
		if (token.match(input, recurrent)) {
		    // add all items in current to doables array
		    if (doables == null) {
			doables = recurrent;
			doablesLast = recurrent;
		    } else {
			// Order these from longest to shortest
			// Start by assuming longest (more repeats)
			doablesLast.next = recurrent;
		    }
		    // Find new doablesLast
		    while (doablesLast.next != null) {
			doablesLast = doablesLast.next;
		    }
		}
	    }
	    // if none of the possibilities worked out, break out of do/while
	    if (doables == null) break;

	    // reassign where the next repeat can match
	    newMatch = doables;

	    // increment how many repeats we've successfully found
	    ++numRepeats;

	    positions.addElement(newMatch);
	} while (numRepeats < max);

	// If there aren't enough repeats, then fail
	if (numRepeats < min) return false;

	// We're greedy, but ease off until a true match is found
	int posIndex = positions.size();

	// At this point we've either got too many or just the right amount.
	// See if this numRepeats works with the rest of the regexp.
	REMatch allResults = null;
	REMatch allResultsLast = null;

	REMatch results = null;
	while (--posIndex >= min) {
	    newMatch = (REMatch) positions.elementAt(posIndex);
	    results = matchRest(input, newMatch);
	    if (results != null) {
		if (allResults == null) {
		    allResults = results;
		    allResultsLast = results;
		} else {
		    // Order these from longest to shortest
		    // Start by assuming longest (more repeats)
		    allResultsLast.next = results;
		}
		// Find new doablesLast
		while (allResultsLast.next != null) {
		    allResultsLast = allResultsLast.next;
		}
	    }
	    // else did not match rest of the tokens, try again on smaller sample
	}
	if (allResults != null) {
	    mymatch.assignFrom(allResults); // does this get all?
	    return true;
	}
	// If we fall out, no matches.
	return false;
    }

    private REMatch matchRest(CharIndexed input, final REMatch newMatch) {
	REMatch current, single;
	REMatch doneIndex = null;
	REMatch doneIndexLast = null;
	// Test all possible matches for this number of repeats
	for (current = newMatch; current != null; current = current.next) {
	    // clone() separates a single match from the chain
	    single = (REMatch) current.clone();
	    if (next(input, single)) {
		// chain results to doneIndex
		if (doneIndex == null) {
		    doneIndex = single;
		    doneIndexLast = single;
		} else {
		    doneIndexLast.next = single;
		}
		// Find new doneIndexLast
		while (doneIndexLast.next != null) {
		    doneIndexLast = doneIndexLast.next;
		}
	    }
	}
	return doneIndex;
    }

    void dump(StringBuffer os) {
	os.append("(?:");
	token.dumpAll(os);
	os.append(')');
	if ((max == Integer.MAX_VALUE) && (min <= 1))
	    os.append( (min == 0) ? '*' : '+' );
	else if ((min == 0) && (max == 1))
	    os.append('?');
	else {
	    os.append('{').append(min);
	    if (max > min) {
		os.append(',');
		if (max != Integer.MAX_VALUE) os.append(max);
	    }
	    os.append('}');
	}
	if (stingy) os.append('?');

    boolean isStingy() {
	return stingy;

FUNC_DECL PARAM PARAM PARAM PARAM ASSIGN ASSIGN ASSIGN


public final class FastCharStream implements CharStream {
  char[] buffer = null;

  /** Constructs from a Reader. */
  public FastCharStream(Reader r) {
    input = r;
  }

  public final char readChar() throws IOException {
    if (bufferPosition >= bufferLength)
      refill();
    return buffer[bufferPosition++];
  }

  private final void refill() throws IOException {
    int newPosition = bufferLength - tokenStart;

	buffer = new char[2048];
	char[] newBuffer = new char[buffer.length*2];
	System.arraycopy(buffer, 0, newBuffer, 0, bufferLength);
	buffer = newBuffer;

      System.arraycopy(buffer, tokenStart, buffer, 0, newPosition);

    bufferPosition = newPosition;
    bufferStart += tokenStart;
    tokenStart = 0;

      input.read(buffer, newPosition, buffer.length-newPosition);
    if (charsRead == -1)
      throw new IOException("read past eof");
    else
      bufferLength += charsRead;
  }

  public final char BeginToken() throws IOException {
    tokenStart = bufferPosition;
    return readChar();
  }

  public final void backup(int amount) {
    bufferPosition -= amount;
  }

  public final String GetImage() {
    return new String(buffer, tokenStart, bufferPosition - tokenStart);
  }

  public final char[] GetSuffix(int len) {
    char[] value = new char[len];
    System.arraycopy(buffer, bufferPosition - len, value, 0, len);
    return value;
  }

  public final void Done() {
    try {
      input.close();
    } catch (IOException e) {
      System.err.println("Caught: " + e + "; ignoring.");
    }
  }

  public final int getColumn() {
    return bufferStart + bufferPosition;
  }
  public final int getLine() {
    return 1;
  }
  public final int getEndColumn() {
    return bufferStart + bufferPosition;
  }
  public final int getEndLine() {
    return 1;
  }
  public final int getBeginColumn() {
    return bufferStart + tokenStart;
  }
  public final int getBeginLine() {
    return 1;

  public final int getLine() {
    return 1;


org.apache.xalan.templates.TemplateList

public class TemplateList implements java.io.Serializable
{

  /**
   * Construct a TemplateList object. Needs to be public so it can
   * be invoked from the CompilingStylesheetHandler.
   */
  public TemplateList()
  {
    super();
  }

  /**
   * Add a template to the table of named templates and/or the table of templates
   * with match patterns.  This routine should
   * be called in decreasing order of precedence but it checks nonetheless.
   *
   * @param template
   */
  public void setTemplate(ElemTemplate template)
  {
    XPath matchXPath = template.getMatch();

    if (null == template.getName() && null == matchXPath)
    {
      template.error(XSLTErrorResources.ER_NEED_NAME_OR_MATCH_ATTRIB,
          new Object[]{ "xsl:template" });
    }

    if (null != template.getName())
    {
      ElemTemplate existingTemplate = (ElemTemplate) m_namedTemplates.get(template.getName());
      if (null == existingTemplate)
      {
        m_namedTemplates.put(template.getName(), template);
      }
      else
      {
        int existingPrecedence =
                        existingTemplate.getStylesheetComposed().getImportCountComposed();
        int newPrecedence = template.getStylesheetComposed().getImportCountComposed();
        if (newPrecedence > existingPrecedence)
        {
          m_namedTemplates.put(template.getName(), template);
        }
        else if (newPrecedence == existingPrecedence)
          template.error(XSLTErrorResources.ER_DUPLICATE_NAMED_TEMPLATE,
                       new Object[]{ template.getName() });
      }
    }

    if (null != matchXPath)
    {
      Expression matchExpr = matchXPath.getExpression();

      if (matchExpr instanceof StepPattern)
      {
        insertPatternInTable((StepPattern) matchExpr, template);
      }
      else if (matchExpr instanceof UnionPattern)
      {
        UnionPattern upat = (UnionPattern) matchExpr;
        StepPattern[] pats = upat.getPatterns();
        int n = pats.length;

        for (int i = 0; i < n; i++)
        {
          insertPatternInTable(pats[i], template);
        }
      }
      else
      {

      }
    }
  }

  /** Flag to indicate whether in DEBUG mode          */
  static boolean DEBUG = false;

  /**
   * Dump all patterns and elements that match those patterns
   *
   */
  void dumpAssociationTables()
  {

    Enumeration associations = m_patternTable.elements();

    while (associations.hasMoreElements())
    {
      TemplateSubPatternAssociation head =
        (TemplateSubPatternAssociation) associations.nextElement();

      while (null != head)
      {
        System.out.print("(" + head.getTargetString() + ", "
                         + head.getPattern() + ")");

        head = head.getNext();
      }

      System.out.println("\n.....");
    }

    TemplateSubPatternAssociation head = m_wildCardPatterns;

    System.out.print("wild card list: ");

    while (null != head)
    {
      System.out.print("(" + head.getTargetString() + ", "
                       + head.getPattern() + ")");

      head = head.getNext();
    }

    System.out.println("\n.....");
  }

  /**
   * After all templates have been added, this function
   * should be called.
   */
  public void compose(StylesheetRoot sroot)
  {

    if (DEBUG)
    {
      System.out.println("Before wildcard insert...");
      dumpAssociationTables();
    }

    if (null != m_wildCardPatterns)
    {
      Enumeration associations = m_patternTable.elements();

      while (associations.hasMoreElements())
      {
        TemplateSubPatternAssociation head =
          (TemplateSubPatternAssociation) associations.nextElement();
        TemplateSubPatternAssociation wild = m_wildCardPatterns;

        while (null != wild)
        {
          try
          {
            head = insertAssociationIntoList(
              head, (TemplateSubPatternAssociation) wild.clone(), true);
          }
          catch (CloneNotSupportedException cnse){}

          wild = wild.getNext();
        }
      }
    }

    if (DEBUG)
    {
      System.out.println("After wildcard insert...");
      dumpAssociationTables();
    }
  }

  /**
   * Insert the given TemplateSubPatternAssociation into the the linked
   * list.  Sort by import precedence, then priority, then by document order.
   *
   * @param head The first TemplateSubPatternAssociation in the linked list.
   * @param item The item that we want to insert into the proper place.
   * @param isWildCardInsert true if we are inserting a wild card
   *             template onto this list.
   * @return the new head of the list.
   */
  private TemplateSubPatternAssociation
              insertAssociationIntoList(TemplateSubPatternAssociation head,
                                         TemplateSubPatternAssociation item,
                                         boolean isWildCardInsert)
  {

    double priority = getPriorityOrScore(item);
    double workPriority;
    int importLevel = item.getImportLevel();
    int docOrder = item.getDocOrderPos();
    TemplateSubPatternAssociation insertPoint = head;
    TemplateSubPatternAssociation next;

    while (true)
    {
      next = insertPoint.getNext();
      if (null == next)
        break;
      else
      {
        workPriority = getPriorityOrScore(next);
        if (importLevel > next.getImportLevel())
          break;
        else if (importLevel < next.getImportLevel()){
          insertPoint = next;
          break;
        }else if (priority < workPriority){
          insertPoint = next;
          break;
        }else
          insertPoint = next;
      }
    }

    if(true){
      workPriority = getPriorityOrScore(insertPoint);
      if (importLevel > insertPoint.getImportLevel())
        insertBefore = true;
      else if (importLevel < insertPoint.getImportLevel())
        insertBefore = false;
      else if (priority > workPriority)
        insertBefore = true;
      else if (priority < workPriority)
        insertBefore = false;
      else if (docOrder >= insertPoint.getDocOrderPos())
        insertBefore = true;
      else
        insertBefore = false;
    }
    else
      insertBefore = false;

    if (isWildCardInsert)
    {
      if (insertBefore)
      {
        item.setNext(insertPoint);

        String key = insertPoint.getTargetString();

        item.setTargetString(key);
        putHead(key, item);
        return item;
      }
      else
      {
        item.setNext(next);
        insertPoint.setNext(item);
        return head;
      }
    }
    else
    {
      if (insertBefore)
      {
        item.setNext(insertPoint);

        if (insertPoint.isWild() || item.isWild())
          m_wildCardPatterns = item;
        else
          putHead(item.getTargetString(), item);
        return item;
      }
      else
      {
        item.setNext(next);
        insertPoint.setNext(item);
        return head;
      }
    }
  }

  /**
   * Add a template to the template list.
   *
   * @param pattern
   * @param template
   */
  private void insertPatternInTable(StepPattern pattern, ElemTemplate template)
  {

    String target = pattern.getTargetString();

    if (null != target)
    {
      String pstring = template.getMatch().getPatternString();
      TemplateSubPatternAssociation association =
        new TemplateSubPatternAssociation(template, pattern, pstring);

      boolean isWildCard = association.isWild();
      TemplateSubPatternAssociation head = isWildCard
                                           ? m_wildCardPatterns
                                           : getHead(target);

      if (null == head)
      {
        if (isWildCard)
          m_wildCardPatterns = association;
        else
          putHead(target, association);
      }
      else
      {
        insertAssociationIntoList(head, association, false);
      }
    }
  }

  /**
   * Given a match pattern and template association, return the
   * score of that match.  This score or priority can always be
   * statically calculated.
   *
   * @param matchPat The match pattern to template association.
   *
   * @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
   *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
   *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
   *         {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
   *         {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}, or
   *         the value defined by the priority attribute of the template.
   *
   */
  private double getPriorityOrScore(TemplateSubPatternAssociation matchPat)
  {

    double priority = matchPat.getTemplate().getPriority();

    if (priority == XPath.MATCH_SCORE_NONE)
    {
      Expression ex = matchPat.getStepPattern();

      if (ex instanceof NodeTest)
      {
        return ((NodeTest) ex).getDefaultScore();
      }
    }

    return priority;
  }

  /**
   * Locate a named template.
   *
   * @param qname  Qualified name of the template.
   *
   * @return Template argument with the requested name, or null if not found.
   */
  public ElemTemplate getTemplate(QName qname)
  {
    return (ElemTemplate) m_namedTemplates.get(qname);
  }

  /**
   * Get the head of the most likely list of associations to check, based on
   * the name and type of the targetNode argument.
   *
   * @param xctxt The XPath runtime context.
   * @param targetNode The target node that will be checked for a match.
   * @param dtm The dtm owner for the target node.
   *
   * @return The head of a linked list that contains all possible match pattern to
   * template associations.
   */
  public TemplateSubPatternAssociation getHead(XPathContext xctxt,
                                               int targetNode, DTM dtm)
  {
    short targetNodeType = dtm.getNodeType(targetNode);
    TemplateSubPatternAssociation head;

    switch (targetNodeType)
    {
    case DTM.ELEMENT_NODE :
    case DTM.ATTRIBUTE_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get(
        dtm.getLocalName(targetNode));
      break;
    case DTM.TEXT_NODE :
    case DTM.CDATA_SECTION_NODE :
      head = m_textPatterns;
      break;
    case DTM.ENTITY_REFERENCE_NODE :
    case DTM.ENTITY_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get();
      break;
    case DTM.PROCESSING_INSTRUCTION_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get(
        dtm.getLocalName(targetNode));
      break;
    case DTM.COMMENT_NODE :
      head = m_commentPatterns;
      break;
    case DTM.DOCUMENT_NODE :
    case DTM.DOCUMENT_FRAGMENT_NODE :
      head = m_docPatterns;
      break;
    case DTM.NOTATION_NODE :
    default :
      head = (TemplateSubPatternAssociation) m_patternTable.get();
    }

    return (null == head) ? m_wildCardPatterns : head;
  }

  /**
   * Given a target element, find the template that best
   * matches in the given XSL document, according
   * to the rules specified in the xsl draft.  This variation of getTemplate
   * assumes the current node and current expression node have already been
   * pushed.
   *
   * @param xctxt
   * @param targetNode
   * @param mode A string indicating the display mode.
   * @param maxImportLevel The maximum importCountComposed that we should consider or -1
   *        if we should consider all import levels.  This is used by apply-imports to
   *        access templates that have been overridden.
   * @param quietConflictWarnings
   * @return Rule that best matches targetElem.
   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
   * the error condition is severe enough to halt processing.
   *
   * @throws TransformerException
   */
  public ElemTemplate getTemplateFast(XPathContext xctxt,
                                int targetNode,
                                int expTypeID,
                                QName mode,
                                int maxImportLevel,
                                boolean quietConflictWarnings,
                                DTM dtm)
            throws TransformerException
  {

    TemplateSubPatternAssociation head;

    switch (dtm.getNodeType(targetNode))
    {
    case DTM.ELEMENT_NODE :
    case DTM.ATTRIBUTE_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get(
        dtm.getLocalNameFromExpandedNameID(expTypeID));
      break;
    case DTM.TEXT_NODE :
    case DTM.CDATA_SECTION_NODE :
      head = m_textPatterns;
      break;
    case DTM.ENTITY_REFERENCE_NODE :
    case DTM.ENTITY_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get();
      break;
    case DTM.PROCESSING_INSTRUCTION_NODE :
      head = (TemplateSubPatternAssociation) m_patternTable.get(
        dtm.getLocalName(targetNode));
      break;
    case DTM.COMMENT_NODE :
      head = m_commentPatterns;
      break;
    case DTM.DOCUMENT_NODE :
    case DTM.DOCUMENT_FRAGMENT_NODE :
      head = m_docPatterns;
      break;
    case DTM.NOTATION_NODE :
    default :
      head = (TemplateSubPatternAssociation) m_patternTable.get();
    }

    if(null == head)
    {
      head = m_wildCardPatterns;
      if(null == head)
        return null;
    }

    xctxt.pushNamespaceContextNull();
    try
    {
      do
      {
        if ( (maxImportLevel > -1) && (head.getImportLevel() > maxImportLevel) )
        {
          continue;
        }
        ElemTemplate template = head.getTemplate();
        xctxt.setNamespaceContext(template);

        if ((head.m_stepPattern.execute(xctxt, targetNode, dtm, expTypeID) != NodeTest.SCORE_NONE)
                && head.matchMode(mode))
        {
          if (quietConflictWarnings)
            checkConflicts(head, xctxt, targetNode, mode);

          return template;
        }
      }
      while (null != (head = head.getNext()));
    }
    finally
    {
      xctxt.popNamespaceContext();
    }

    return null;
  }
  /**
   * Given a target element, find the template that best
   * matches in the given XSL document, according
   * to the rules specified in the xsl draft.
   *
   * @param xctxt
   * @param targetNode
   * @param mode A string indicating the display mode.
   * @param quietConflictWarnings
   * @return Rule that best matches targetElem.
   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
   * the error condition is severe enough to halt processing.
   *
   * @throws TransformerException
   */
  public ElemTemplate getTemplate(XPathContext xctxt,
                                int targetNode,
                                QName mode,
                                boolean quietConflictWarnings,
                                DTM dtm)
            throws TransformerException
  {

    TemplateSubPatternAssociation head = getHead(xctxt, targetNode, dtm);

    if (null != head)
    {
      xctxt.pushNamespaceContextNull();
      xctxt.pushCurrentNodeAndExpression(targetNode, targetNode);
      try
      {
        do
        {
          ElemTemplate template = head.getTemplate();
          xctxt.setNamespaceContext(template);

          if ((head.m_stepPattern.execute(xctxt, targetNode) != NodeTest.SCORE_NONE)
                  && head.matchMode(mode))
          {
            if (quietConflictWarnings)
              checkConflicts(head, xctxt, targetNode, mode);

            return template;
          }
        }
        while (null != (head = head.getNext()));
      }
      finally
      {
        xctxt.popCurrentNodeAndExpression();
        xctxt.popNamespaceContext();
      }
    }

    return null;
  }
  /**
   * Given a target element, find the template that best
   * matches in the given XSL document, according
   * to the rules specified in the xsl draft.
   *
   * @param xctxt
   * @param targetNode
   * @param mode A string indicating the display mode.
   * @param maxImportLevel The maximum importCountComposed that we should consider or -1
   *        if we should consider all import levels.  This is used by apply-imports to
   *        access templates that have been overridden.
   * @param maxEndImportLevel The count of composed imports
   * @param quietConflictWarnings
   * @return Rule that best matches targetElem.
   * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
   * the error condition is severe enough to halt processing.
   *
   * @throws TransformerException
   */
  public ElemTemplate getTemplate(XPathContext xctxt,
                                int targetNode,
                                QName mode,
                                int maxImportLevel, int endImportLevel,
                                boolean quietConflictWarnings,
                                DTM dtm)
            throws TransformerException
  {

    TemplateSubPatternAssociation head = getHead(xctxt, targetNode, dtm);

    if (null != head)
    {
      xctxt.pushNamespaceContextNull();
      xctxt.pushCurrentNodeAndExpression(targetNode, targetNode);
      try
      {
        do
        {
          if ( (maxImportLevel > -1) && (head.getImportLevel() > maxImportLevel))
          {
            continue;
          }
          if (head.getImportLevel()<= maxImportLevel - endImportLevel)
            return null;
          ElemTemplate template = head.getTemplate();
          xctxt.setNamespaceContext(template);

          if ((head.m_stepPattern.execute(xctxt, targetNode) != NodeTest.SCORE_NONE)
                  && head.matchMode(mode))
          {
            if (quietConflictWarnings)
              checkConflicts(head, xctxt, targetNode, mode);

            return template;
          }
        }
        while (null != (head = head.getNext()));
      }
      finally
      {
        xctxt.popCurrentNodeAndExpression();
        xctxt.popNamespaceContext();
      }
    }

    return null;
  }
  /**
   * Get a TemplateWalker for use by a compiler.  See the documentation for
   * the TreeWalker inner class for further details.
   */
  public TemplateWalker getWalker()
  {
    return new TemplateWalker();
  }

  /**
   * Check for match conflicts, and warn the stylesheet author.
   *
   * @param head Template pattern
   * @param xctxt Current XPath context
   * @param targetNode Node matching the pattern
   */
  private void checkConflicts(TemplateSubPatternAssociation head,
                              XPathContext xctxt, int targetNode, QName mode)
  {

  }

  /**
   * Add object to vector if not already there.
   *
   * @param obj
   * @param v
   */
  private void addObjectIfNotFound(Object obj, Vector v)
  {

    int n = v.size();
    boolean addIt = true;

    for (int i = 0; i < n; i++)
    {
      if (v.elementAt(i) == obj)
      {
        addIt = false;

        break;
      }
    }

    if (addIt)
    {
      v.addElement(obj);
    }
  }

  /**
   * Keyed on string macro names, and holding values
   * that are macro elements in the XSL DOM tree.
   * Initialized in initMacroLookupTable, and used in
   * findNamedTemplate.
   * @serial
   */
  private Hashtable m_namedTemplates = new Hashtable(89);

  /**
   * This table is keyed on the target elements
   * of patterns, and contains linked lists of
   * the actual patterns that match the target element
   * to some degree of specifity.
   * @serial
   */
  private Hashtable m_patternTable = new Hashtable(89);

  /** Wildcard patterns.
   *  @serial          */
  private TemplateSubPatternAssociation m_wildCardPatterns = null;

  /** Text Patterns.
   *  @serial          */
  private TemplateSubPatternAssociation m_textPatterns = null;

  /** Root document Patterns.
   *  @serial          */
  private TemplateSubPatternAssociation m_docPatterns = null;

  /** Comment Patterns.
   *  @serial          */
  private TemplateSubPatternAssociation m_commentPatterns = null;

  /**
   * Get table of named Templates.
   * These are keyed on template names, and holding values
   * that are template elements.
   *
   * @return A Hashtable dictionary that contains {@link java.lang.String}s
   * as the keys, and {@link org.apache.xalan.templates.ElemTemplate}s as the
   * values.
   */
  private Hashtable getNamedTemplates()
  {
    return m_namedTemplates;
  }

  /**
   * Set table of named Templates.
   * These are keyed on string macro names, and holding values
   * that are template elements in the XSL DOM tree.
   *
   * @param v Hashtable dictionary that contains {@link java.lang.String}s
   * as the keys, and {@link org.apache.xalan.templates.ElemTemplate}s as the
   * values.
   */
  private void setNamedTemplates(Hashtable v)
  {
    m_namedTemplates = v;
  }

  /**
   * Get the head of the assocation list that is keyed by target.
   *
   * @param key The name of a node.
   *
   * @return The head of a linked list that contains all possible match pattern to
   * template associations for the given key.
   */
  private TemplateSubPatternAssociation getHead(String key)
  {
    return (TemplateSubPatternAssociation) m_patternTable.get(key);
  }

  /**
   * Get the head of the assocation list that is keyed by target.
   *
   * @param key
   * @param assoc
   */
  private void putHead(String key, TemplateSubPatternAssociation assoc)
  {

    if (key.equals(PsuedoNames.PSEUDONAME_TEXT))
      m_textPatterns = assoc;
    else if (key.equals(PsuedoNames.PSEUDONAME_ROOT))
      m_docPatterns = assoc;
    else if (key.equals(PsuedoNames.PSEUDONAME_COMMENT))
      m_commentPatterns = assoc;

    m_patternTable.put(key, assoc);
  }

  /**
   * An inner class used by a compiler to iterate over all of the ElemTemplates
   * stored in this TemplateList.  The compiler can replace returned templates
   * with their compiled equivalent.
   */
  public class TemplateWalker
  {
    private Enumeration hashIterator;
    private boolean inPatterns;
    private TemplateSubPatternAssociation curPattern;

    private Hashtable m_compilerCache = new Hashtable();

    private TemplateWalker()
    {
      hashIterator = m_patternTable.elements();
      inPatterns = true;
      curPattern = null;
    }

    public ElemTemplate next()
    {

      ElemTemplate retValue = null;
      ElemTemplate ct;

      while (true)
      {
        if (inPatterns)
        {
          if (null != curPattern)
            curPattern = curPattern.getNext();

          if (null != curPattern)
            retValue = curPattern.getTemplate();
          else
          {
            if (hashIterator.hasMoreElements())
            {
              curPattern = (TemplateSubPatternAssociation) hashIterator.nextElement();
              retValue =  curPattern.getTemplate();
            }
            else
            {
              inPatterns = false;
              hashIterator = m_namedTemplates.elements();
            }
          }
        }

        if (!inPatterns)
        {
          if (hashIterator.hasMoreElements())
            retValue = (ElemTemplate) hashIterator.nextElement();
          else
            return null;
        }

        ct = (ElemTemplate) m_compilerCache.get(new Integer(retValue.getUid()));
        if (null == ct)
        {
          m_compilerCache.put(new Integer(retValue.getUid()), retValue);
          return retValue;

FUNC_DECL RETURN IF VAR_DECL PARAM PARAM PARAM PARAM PARAM LITERAL_ANCHOR BINARY_OP TRY LITERAL_ANCHOR CALL LOOP CALL CALL CALL CALL BINARY_OP IF VAR_DECL ASSIGN LITERAL_ANCHOR BINARY_OP CALL CALL RETURN IF CALL BINARY_OP CALL CALL CALL

FUNC_DECL IF PARAM PARAM CALL IF CALL IF CALL ASSIGN CALL ASSIGN ASSIGN

  public TemplateList()
  {
    super();


public class MemoryMessageIdRepository implements MessageIdRepository {
    private final Map cache;

    public MemoryMessageIdRepository(Map set) {
        this.cache = set;
    }

    /**
     * Creates a new MemoryMessageIdRepository with a memory based repository.
     * Warning this method should only really be used for testing as it
     * will involve keeping all message IDs in RAM.
     */
    public static MessageIdRepository memoryMessageIdRepository() {
        return memoryMessageIdRepository(new HashMap());
    }

    /**
     * Creates a new MemoryMessageIdRepository with a memory based repository.
     * Warning this method should only really be used for testing as it
     * will involve keeping all message IDs in RAM.
     */
    public static MessageIdRepository memoryMessageIdRepository(int cacheSize) {
        return memoryMessageIdRepository(new LRUCache(cacheSize));
    }

    /**
     * Creates a new MemoryMessageIdRepository using the given {@link Map} to
     * use to store the processed Message ID objects. Warning be careful of the
     * implementation of Map you use as if you are not careful it could be a
     * memory leak.
     */
    public static MessageIdRepository memoryMessageIdRepository(Map cache) {
        return new MemoryMessageIdRepository(cache);
    }

    public boolean contains(String messageId) {
        synchronized (cache) {
            if (cache.containsKey(messageId)) {
                return true;
            } else {
                cache.put(messageId, messageId);
                return false;

FUNC_DECL PARAM IF CALL RETURN RETURN LITERAL_ANCHOR CALL LITERAL_ANCHOR


org.apache.xalan.xsltc.compiler.When

final class When extends Instruction {

    private Expression _test;
    private boolean _ignore = false;

    public void display(int indent) {
	indent(indent);
	Util.println("When");
	indent(indent + IndentIncrement);
	System.out.print("test ");
	Util.println(_test.toString());
	displayContents(indent + IndentIncrement);
    }

    public Expression getTest() {
	return _test;
    }

    public boolean ignore() {
	return(_ignore);
    }

    public void parseContents(Parser parser) {
	_test = parser.parseExpression(this, "test", null);

	Object result = _test.evaluateAtCompileTime();
	if (result != null && result instanceof Boolean) {
	    _ignore = !((Boolean) result).booleanValue();
	}

	parseChildren(parser);

	if (_test.isDummy()) {
	    reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "test");
	}
    }

    /**
     * Type-check this when element. The test should always be type checked,
     * while we do not bother with the contents if we know the test fails.
     * This is important in cases where the "test" expression tests for
     * the support of a non-available element, and the <xsl:when> body contains
     * this non-available element.
     */
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
	if (_test.typeCheck(stable) instanceof BooleanType == false) {
	    _test = new CastExpr(_test, Type.Boolean);
	}
	if (!_ignore) {
	    typeCheckContents(stable);
	}

	return Type.Void;
    }

    /**
     * This method should never be called. An Otherwise object will explicitly
     * translate the "test" expression and and contents of this element.
     */
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
	final ErrorMsg msg = new ErrorMsg(ErrorMsg.STRAY_WHEN_ERR, this);
	getParser().reportError(Constants.ERROR, msg);

FUNC_DECL RETURN IF IF PARAM BINARY_OP LITERAL_ANCHOR BINARY_OP CALL ASSIGN CALL CALL

FUNC_DECL VAR_DECL PARAM PARAM CALL CALL CALL


public class ExtensionHandlerGeneral extends ExtensionHandler
{

  /** script source to run (if any)      */
  private String m_scriptSrc;

  /** URL of source of script (if any)         */
  private String m_scriptSrcURL;

  /** functions of namespace        */
  private Hashtable m_functions = new Hashtable();

  /** elements of namespace         */
  private Hashtable m_elements = new Hashtable();

  /** Instance of Manager class          */

  /** BSF manager used to run scripts         */
  private Object m_engine;

  /** BSFManager package name          */
  private static final String BSF_MANAGER = "com.ibm.bsf.BSFManager";

  /** Manager class          */
  private static Class managerClass;

  /** Manager load scripting engine          */
  private static Method mgrLoadScriptingEngine;

  /** BSFEngine package name          */
  private static final String BSF_ENGINE = "com.ibm.bsf.BSFEngine";

  /** Engine call to "compile" scripts         */
  private static Method engineExec;

  /** Engine call to invoke scripts          */
  private static Method engineCall;

  /** Negative one integer         */
  private static final Integer NEG1INT = new Integer(-1);

  static
  {
    try
    {
                        managerClass = ExtensionHandler.getClassForName(BSF_MANAGER);
      mgrLoadScriptingEngine = managerClass.getMethod("loadScriptingEngine",
              new Class[]{ String.class });

                        Class engineClass = ExtensionHandler.getClassForName(BSF_ENGINE);

      engineExec = engineClass.getMethod("exec", new Class[]{ String.class,
                                                              Integer.TYPE,
                                                              Integer.TYPE,
                                                              Object.class });
      engineCall = engineClass.getMethod("call", new Class[]{ Object.class,
                                                              String.class,
                                                              Class.forName(
                                                                "[Ljava.lang.Object;") });
    }
    catch (Exception e)
    {
      managerClass = null;
      mgrLoadScriptingEngine = null;
      engineExec = null;
      engineCall = null;

      e.printStackTrace();
    }
  }

  /**
   * Construct a new extension namespace handler given all the information
   * needed.
   *
   * @param namespaceUri the extension namespace URI that I'm implementing
   * @param elemNames Vector of element names
   * @param funcNames    string containing list of functions of extension NS
   * @param lang         language of code implementing the extension
   * @param srcURL       value of src attribute (if any) - treated as a URL
   *                     or a classname depending on the value of lang. If
   *                     srcURL is not null, then scriptSrc is ignored.
   * @param scriptLang Scripting language of implementation
   * @param scriptSrcURL URL of source script
   * @param scriptSrc    the actual script code (if any)
   *
   * @throws TransformerException
   */
  public ExtensionHandlerGeneral(
          String namespaceUri, StringVector elemNames, StringVector funcNames, String scriptLang, String scriptSrcURL, String scriptSrc, String systemId)
            throws TransformerException
  {

    super(namespaceUri, scriptLang);

    if (elemNames != null)
    {
      Object junk = new Object();
      int n = elemNames.size();

      for (int i = 0; i < n; i++)
      {
        String tok = elemNames.elementAt(i);

      }
    }

    if (funcNames != null)
    {
      Object junk = new Object();
      int n = funcNames.size();

      for (int i = 0; i < n; i++)
      {
        String tok = funcNames.elementAt(i);

      }
    }

    m_scriptSrcURL = scriptSrcURL;
    m_scriptSrc = scriptSrc;

    if (m_scriptSrcURL != null)
    {
      URL url = null;
      try{
        url = new URL(m_scriptSrcURL);
      }
      catch (java.net.MalformedURLException mue)
      {
        int indexOfColon = m_scriptSrcURL.indexOf(':');
        int indexOfSlash = m_scriptSrcURL.indexOf('/');

        if ((indexOfColon != -1) && (indexOfSlash != -1)
            && (indexOfColon < indexOfSlash))
        {
          url = null;
        }
        else
        {
          try{
            url = new URL(new URL(SystemIDResolver.getAbsoluteURI(systemId)), m_scriptSrcURL);
          }
          catch (java.net.MalformedURLException mue2)
          {
          }
        }
      }
      if (url != null)
      {
        try
        {
          URLConnection uc = url.openConnection();
          InputStream is = uc.getInputStream();
          byte []bArray = new byte[uc.getContentLength()];
          is.read(bArray);
          m_scriptSrc = new String(bArray);

        }
        catch (IOException ioe)
        {
        }
      }

    }

    if (null == managerClass)

    try
    {
      m_mgr = managerClass.newInstance();
      m_engine = mgrLoadScriptingEngine.invoke(m_mgr,
                                               new Object[]{ scriptLang });

      engineExec.invoke(m_engine, new Object[]{ "XalanScript", NEG1INT,
                                                NEG1INT, m_scriptSrc });
    }
    catch (Exception e)
    {
      e.printStackTrace();

    }
  }

  /**
   * Tests whether a certain function name is known within this namespace.
   * @param function name of the function being tested
   * @return true if its known, false if not.
   */
  public boolean isFunctionAvailable(String function)
  {
    return (m_functions.get(function) != null);
  }

  /**
   * Tests whether a certain element name is known within this namespace.
   * @param function name of the function being tested
   *
   * @param element name of the element being tested
   * @return true if its known, false if not.
   */
  public boolean isElementAvailable(String element)
  {
    return (m_elements.get(element) != null);
  }

  /**
   * Process a call to a function.
   *
   * @param funcName Function name.
   * @param args     The arguments of the function call.
   * @param methodKey A key that uniquely identifies this class and method call.
   * @param exprContext The context in which this expression is being executed.
   *
   * @return the return value of the function evaluation.
   *
   * @throws TransformerException          if parsing trouble
   */
  public Object callFunction(
          String funcName, Vector args, Object methodKey, ExpressionContext exprContext)
            throws TransformerException
  {

    Object[] argArray;

    try
    {
      argArray = new Object[args.size()];

      for (int i = 0; i < argArray.length; i++)
      {
        Object o = args.elementAt(i);

        argArray[i] = (o instanceof XObject) ? ((XObject) o).object() : o;
        o = argArray[i];
        if(null != o && o instanceof DTMIterator)
        {
          argArray[i] = new DTMNodeList((DTMIterator)o);
        }
      }

      return engineCall.invoke(m_engine, new Object[]{ null, funcName,
                                                       argArray });
    }
    catch (Exception e)
    {
      e.printStackTrace();

      String msg = e.getMessage();

      if (null != msg)
      {
        if (msg.startsWith("Stopping after fatal error:"))
        {
          msg = msg.substring("Stopping after fatal error:".length());
        }

        throw new TransformerException(e);
      }
      else
      {

      }
    }
  }

  /**
   * Process a call to an XPath extension function
   *
   * @param extFunction The XPath extension function
   * @param args The arguments of the function call.
   * @param exprContext The context in which this expression is being executed.
   * @return the return value of the function evaluation.
   * @throws TransformerException
   */
  public Object callFunction(FuncExtFunction extFunction,
                             Vector args,
                             ExpressionContext exprContext)
      throws TransformerException
  {
    return callFunction(extFunction.getFunctionName(), args,
                        extFunction.getMethodKey(), exprContext);
  }

  /**
   * Process a call to this extension namespace via an element. As a side
   * effect, the results are sent to the TransformerImpl's result tree.
   *
   * @param localPart      Element name's local part.
   * @param element        The extension element being processed.
   * @param transformer      Handle to TransformerImpl.
   * @param stylesheetTree The compiled stylesheet tree.
   * @param mode           The current mode.
   * @param sourceTree     The root of the source tree (but don't assume
   *                       it's a Document).
   * @param sourceNode     The current context node.
   * @param methodKey A key that uniquely identifies this class and method call.
   *
   * @throws XSLProcessorException thrown if something goes wrong
   *            while running the extension handler.
   * @throws MalformedURLException if loading trouble
   * @throws FileNotFoundException if loading trouble
   * @throws IOException           if loading trouble
   * @throws TransformerException          if parsing trouble
   */
  public void processElement(
          String localPart, ElemTemplateElement element, TransformerImpl transformer,
          Stylesheet stylesheetTree, Object methodKey)
            throws TransformerException, IOException
  {

    Object result = null;
    XSLProcessorContext xpc = new XSLProcessorContext(transformer, stylesheetTree);

    try
    {
      Vector argv = new Vector(2);

      argv.addElement(xpc);
      argv.addElement(element);

      result = callFunction(localPart, argv, methodKey,
                            transformer.getXPathContext().getExpressionContext());
    }
    catch (XPathProcessorException e)
    {

      throw new TransformerException(e.getMessage(), e);
    }

    if (result != null)
    {
      xpc.outputToResultTree(stylesheetTree, result);

FUNC_DECL RETURN PARAM PARAM PARAM CALL CALL CALL

FUNC_DECL IF TRY VAR_DECL VAR_DECL PARAM PARAM PARAM PARAM PARAM BINARY_OP CATCH VAR_DECL LITERAL_ANCHOR THROW_RAISE ASSIGN CALL CALL CALL LITERAL_ANCHOR CALL CALL CALL CALL CALL CALL LITERAL_ANCHOR CALL


org.apache.xml.dtm.ref.DTMNodeList

public class DTMNodeList extends DTMNodeListBase {
    private DTMIterator m_iter;

    private DTMNodeList() {
    }

    /**
     * Public constructor: Wrap a DTMNodeList around an existing
     * and preconfigured DTMIterator
     *
     * WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
     * AGAINST THE DTMIterator.
     *
     */
    public DTMNodeList(DTMIterator dtmIterator) {
        if (dtmIterator != null) {
            int pos = dtmIterator.getCurrentPos();
            try {
                m_iter=(DTMIterator)dtmIterator.cloneWithReset();
            } catch(CloneNotSupportedException cnse) {
                m_iter = dtmIterator;
            }
            m_iter.setShouldCacheNodes(true);
            m_iter.runTo(-1);
            m_iter.setCurrentPos(pos);
        }
    }

    /**
     * Access the wrapped DTMIterator. I'm not sure whether anyone will
     * need this or not, but let's write it and think about it.
     *
     */
    public DTMIterator getDTMIterator() {
        return m_iter;
    }

    /**
     * Returns the indexth item in the collection. If
     * index is greater than or equal to the number of nodes in
     * the list, this returns null.
     * @param indexIndex into the collection.
     * @return The node at the indexth position in the
     *   NodeList, or null if that is not a valid
     *   index.
     */
    public Node item(int index)
    {
        if (m_iter != null) {
            int handle=m_iter.item(index);
            if (handle == DTM.NULL) {
                return null;
            }
            return m_iter.getDTM(handle).getNode(handle);
        } else {
            return null;
        }
    }

    /**
     * The number of nodes in the list. The range of valid child node indices
     * is 0 to length-1 inclusive.
     */
    public int getLength() {
        return (m_iter != null) ? m_iter.getLength() : 0;


org.gjt.sp.jedit.gui.RecentFilesMenu

public class RecentFilesMenu extends EnhancedMenu
{
	//{{{ RecentFilesMenu constructor
	public RecentFilesMenu()
	{
		super("recent-files");
	} //}}}

	//{{{ menuSelected() method
	public void menuSelected(MenuEvent evt)
	{
		super.menuSelected(evt);
		final View view = GUIUtilities.getView(this);

		if(getMenuComponentCount() != 0)
			removeAll();

		//{{{ ActionListener...
		ActionListener actionListener = new ActionListener()
		{
			public void actionPerformed(ActionEvent evt)
			{
				jEdit.openFile(view,evt.getActionCommand());
				view.getStatus().setMessage(null);
			}
		}; //}}}

		//{{{ MouseListener...
		MouseListener mouseListener = new MouseAdapter()
		{
			public void mouseEntered(MouseEvent evt)
			{
				view.getStatus().setMessage(
					((JMenuItem)evt.getSource())
					.getActionCommand());
			}

			public void mouseExited(MouseEvent evt)
			{
				view.getStatus().setMessage(null);
			}
		}; //}}}

		Vector recentVector = BufferHistory.getBufferHistory();

		if(recentVector.size() == 0)
		{
			add(GUIUtilities.loadMenuItem("no-recent-files"));
			return;
		}

		Vector menuItems = new Vector();
		boolean sort = jEdit.getBooleanProperty("sortRecent");

		/*
		 * While recentVector has 50 entries or so, we only display
		 * a few of those in the menu (otherwise it will be way too
		 * long)
		 */
		int recentFileCount = Math.min(recentVector.size(),
			jEdit.getIntegerProperty("history",25));

		for(int i = recentVector.size() - 1;
			i >= recentVector.size() - recentFileCount;
			i--)
		{
			String path = ((BufferHistory.Entry)recentVector
				.elementAt(i)).path;
			VFS vfs = VFSManager.getVFSForPath(path);
			JMenuItem menuItem = new JMenuItem(vfs.getFileName(path));
			menuItem.setActionCommand(path);
			menuItem.addActionListener(actionListener);
			menuItem.addMouseListener(mouseListener);
			menuItem.setIcon(FileCellRenderer.fileIcon);

			if(sort)
				menuItems.addElement(menuItem);
			else
				add(menuItem);
		}

		if(sort)
		{
			MiscUtilities.quicksort(menuItems,
				new MiscUtilities.MenuItemCompare());
			for(int i = 0; i < menuItems.size(); i++)
			{
				add((JMenuItem)menuItems.elementAt(i));
			}
		}
	} //}}}

	public void menuDeselected(MenuEvent e) {}

	public void menuCanceled(MenuEvent e) {}


public class FuncSubstring extends Function3Args
{

  /**
   * Execute the function.  The function must return
   * a valid object.
   * @param xctxt The current execution context.
   * @return A valid XObject.
   *
   * @throws javax.xml.transform.TransformerException
   */
  public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    XMLString s1 = m_arg0.execute(xctxt).xstr();
    double start = m_arg1.execute(xctxt).num();
    int lenOfS1 = s1.length();
    XMLString substr;

    if (lenOfS1 <= 0)
      return XString.EMPTYSTRING;
    else
    {
      int startIndex;

      if (Double.isNaN(start))
      {

        start = -1000000;
        startIndex = 0;
      }
      else
      {
        start = Math.round(start);
        startIndex = (start > 0) ? (int) start - 1 : 0;
      }

      if (null != m_arg2)
      {
        double len = m_arg2.num(xctxt);
        int end = (int) (Math.round(len) + start) - 1;

        if (end < 0)
          end = 0;
        else if (end > lenOfS1)
          end = lenOfS1;

        if (startIndex > lenOfS1)
          startIndex = lenOfS1;

        substr = s1.substring(startIndex, end);
      }
      else
      {
        if (startIndex > lenOfS1)
          startIndex = lenOfS1;
        substr = s1.substring(startIndex);
      }
    }

  }

  /**
   * Check that the number of arguments passed to this function is correct.
   *
   *
   * @param argNum The number of arguments that is being passed to the function.
   *
   * @throws WrongNumberArgsException
   */
  public void checkNumberArgs(int argNum) throws WrongNumberArgsException
  {
    if (argNum < 2)
      reportWrongNumberArgs();
  }

  /**
   * Constructs and throws a WrongNumberArgException with the appropriate
   * message for this function object.
   *
   * @throws WrongNumberArgsException
   */
  protected void reportWrongNumberArgs() throws WrongNumberArgsException {


public class RangePtg extends OperationPtg
{
    public final static byte sid  = 0x11;

    public RangePtg()
    {
    }

    public RangePtg(RecordInputStream in)
    {
    }

    public int getSize()
    {
        return 1;
    }

    public void writeBytes( byte[] array, int offset )
    {
        array[ offset + 0 ] = sid;
    }

    public Object clone()
    {
        return new RangePtg();
    }

    public int getType()
    {
        return TYPE_BINARY;
    }

    /** Implementation of method from Ptg */
    public String toFormulaString(Workbook book)
    {
        return ":";
    }

    /** implementation of method from OperationsPtg*/
    public String toFormulaString(String[] operands)
    {
         StringBuffer buffer = new StringBuffer();

         buffer.append(operands[ 0 ]);
         buffer.append(":");
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }

    public int getNumberOfOperands()
    {
        return 2;

    public int getSize()
    {
        return 1;