class JavaSourceFetchExtension extends AbstractFetchException {

    public static String fetch( String location, String method ) throws Exception
    {        
        File fetchFile = checkCache( location );
        
        if ( fetchFile == null )
        {
            URL url = new URL(location);
            fetchFile = cache(location,url.openStream());
        }       
        

        if ( method == null || "".equals(method) )
        {
            CompilationUnit cu = JavaParser.parse(new FileInputStream(fetchFile));
            
            return cu.toString();
        }
        else
        {
            CompilationUnit cu = JavaParser.parse(new FileInputStream(fetchFile));

            // visit and print the methods names
            MethodVisitor mv = new MethodVisitor(method);

            mv.visit(cu,null);

            return mv.source;
        }
       
    }

}