Hello,

I'm a newcomer and I have a simple bug fix for XJavaDoc. I found that saving source files to another folder would cause truncation of the source. What I noticed was the FileWriter in the save method of xjavadoc.SourceClass was not being flushed like the Writer returned from the _sourceFile member when a root directory is not given. My modifications are only to the save method and include two lines of code. The source to the revised save method is as follows:

/**
* Saves the class at root dir rootDir. The actual java file is derived from
* tha package name. If no root dir is specified, save where it was loaded from
*
* @param rootDir the root directory.
* @return the relative fileName to which the file was saved.
* @throws IOException if the file couldn't be saved
*/
public String save( File rootDir ) throws IOException
{
if( !isWriteable() )
{
throw new UnsupportedOperationException( "Can't save classes that aren't parsed in AST mode (do getXJavaDoc().setUseNodeParser(true) before parsing starts!)" );
}
if( getContainingClass() != null )
{
// inner class. can't save these.
throw new UnsupportedOperationException( "Can't save inner classes" );
}
else if( rootDir != null )
{
String fileName = getFileName( getQualifiedName() );
File javaFile = new File( rootDir, fileName );


           javaFile.getParentFile().mkdirs();
           FileWriter fwtr = new FileWriter( javaFile );
           print( fwtr );
           fwtr.flush();
           fwtr.close();
           return fileName;
       }
       else
       {
           // no root dir specified, save in place
           Writer outputStream = _sourceFile.getWriter();

           print( new PrintWriter( outputStream ) );
           outputStream.flush();
           outputStream.close();
           return _sourceFile.toString();
       }
   }

I'm not sure about how things get committed in open source projects but I do know that this is a bug. I also know that my patch, while small, does correct the problem. I'm not sure about where to go from here, so if someone wants to advise me I'd be most thankful.

--
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
2101 Embassy Drive
Lancaster, PA  17603

Phone: 717-295-7977 ext. 621
Fax: 717-295-7683
[EMAIL PROTECTED]
[EMAIL PROTECTED]




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to