You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by ev...@apache.org on 2005/09/30 09:59:25 UTC
svn commit: r292670 -
/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
Author: evenisse
Date: Fri Sep 30 00:59:23 2005
New Revision: 292670
URL: http://svn.apache.org/viewcvs?rev=292670&view=rev
Log:
Add transform method for users that don't want to work on files but with Reader/Writer
Modified:
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java?rev=292670&r1=292669&r2=292670&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java Fri Sep 30 00:59:23 2005
@@ -683,6 +683,64 @@
/**
* This is the public method for doing all transforms of code.
*
+ * @param sourceReader Reader
+ * @param destWriter Writer
+ * @param locale String
+ * @param inputEncoding String
+ * @param outputEncoding String
+ * @param javadocLinkDir String
+ * @param revision String
+ * @param showHeader boolean
+ * @param showFooter boolean
+ * @throws IOException
+ */
+ public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
+ String outputEncoding, String javadocLinkDir, String revision, boolean showHeader,
+ boolean showFooter )
+ throws IOException
+ {
+ this.locale = locale;
+ this.inputEncoding = inputEncoding;
+ this.outputEncoding = outputEncoding;
+ this.javadocLinkDir = javadocLinkDir;
+ this.revision = revision;
+
+ BufferedReader in = new BufferedReader( sourceReader );
+
+ PrintWriter out = new PrintWriter( destWriter );
+
+ String line = "";
+
+ if ( showHeader )
+ {
+ out.println( getHeader() );
+ }
+
+ int linenumber = 1;
+ while ( ( line = in.readLine() ) != null )
+ {
+ if ( LINE_NUMBERS )
+ {
+ out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
+ "</a>" + getLineWidth( linenumber ) );
+ }
+
+ out.println( this.syntaxHighlight( line ) );
+
+ ++linenumber;
+ }
+
+ if ( showFooter )
+ {
+ out.println( getFooter() );
+ }
+
+ out.flush();
+ }
+
+ /**
+ * This is the public method for doing all transforms of code.
+ *
* @param sourcefile String
* @param destfile String
* @param locale String
@@ -701,11 +759,6 @@
this.sourcefile = sourcefile;
this.destfile = destfile;
- this.locale = locale;
- this.inputEncoding = inputEncoding;
- this.outputEncoding = outputEncoding;
- this.javadocLinkDir = javadocLinkDir;
- this.revision = revision;
//make sure that the parent directories exist...
new File( new File( destfile ).getParent() ).mkdirs();
@@ -730,30 +783,8 @@
{
fw = new FileWriter( destfile );
}
- BufferedReader in = new BufferedReader( fr );
-
- PrintWriter out = new PrintWriter( fw );
-
- String line = "";
- out.println( getHeader() );
-
- int linenumber = 1;
- while ( ( line = in.readLine() ) != null )
- {
- if ( LINE_NUMBERS )
- {
- out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
- "</a>" + getLineWidth( linenumber ) );
- }
-
- out.println( this.syntaxHighlight( line ) );
-
- ++linenumber;
- }
-
- out.println( getFooter() );
- out.flush();
+ transform( fr, fw, locale, inputEncoding, outputEncoding, javadocLinkDir, revision, true, true );
}
catch ( RuntimeException e )
{
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r292670 - /maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
Posted by Brett Porter <br...@apache.org>.
yep, that's fine. just asking because I couldn't see it outside the diff :)
Emmanuel Venisse wrote:
> we have a finally in second transform method, and I thought it will be
> good to let open reader and writer if user want to use reader and
> writer after the transform process.
>
> WDYT?
> Emmanuel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r292670 - /maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
Posted by Emmanuel Venisse <em...@venisse.net>.
we have a finally in second transform method, and I thought it will be good to let open
reader and writer if user want to use reader and writer after the transform process.
WDYT?
Emmanuel
Brett Porter a écrit :
> is this missing close() in a finally?
>
> - Brett
>
> evenisse@apache.org wrote:
>
>
>>Author: evenisse
>>Date: Fri Sep 30 00:59:23 2005
>>New Revision: 292670
>>
>>URL: http://svn.apache.org/viewcvs?rev=292670&view=rev
>>Log:
>>Add transform method for users that don't want to work on files but with Reader/Writer
>>
>>Modified:
>> maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
>>
>>Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
>>URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java?rev=292670&r1=292669&r2=292670&view=diff
>>==============================================================================
>>--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java (original)
>>+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java Fri Sep 30 00:59:23 2005
>>@@ -683,6 +683,64 @@
>> /**
>> * This is the public method for doing all transforms of code.
>> *
>>+ * @param sourceReader Reader
>>+ * @param destWriter Writer
>>+ * @param locale String
>>+ * @param inputEncoding String
>>+ * @param outputEncoding String
>>+ * @param javadocLinkDir String
>>+ * @param revision String
>>+ * @param showHeader boolean
>>+ * @param showFooter boolean
>>+ * @throws IOException
>>+ */
>>+ public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
>>+ String outputEncoding, String javadocLinkDir, String revision, boolean showHeader,
>>+ boolean showFooter )
>>+ throws IOException
>>+ {
>>+ this.locale = locale;
>>+ this.inputEncoding = inputEncoding;
>>+ this.outputEncoding = outputEncoding;
>>+ this.javadocLinkDir = javadocLinkDir;
>>+ this.revision = revision;
>>+
>>+ BufferedReader in = new BufferedReader( sourceReader );
>>+
>>+ PrintWriter out = new PrintWriter( destWriter );
>>+
>>+ String line = "";
>>+
>>+ if ( showHeader )
>>+ {
>>+ out.println( getHeader() );
>>+ }
>>+
>>+ int linenumber = 1;
>>+ while ( ( line = in.readLine() ) != null )
>>+ {
>>+ if ( LINE_NUMBERS )
>>+ {
>>+ out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
>>+ "</a>" + getLineWidth( linenumber ) );
>>+ }
>>+
>>+ out.println( this.syntaxHighlight( line ) );
>>+
>>+ ++linenumber;
>>+ }
>>+
>>+ if ( showFooter )
>>+ {
>>+ out.println( getFooter() );
>>+ }
>>+
>>+ out.flush();
>>+ }
>>+
>>+ /**
>>+ * This is the public method for doing all transforms of code.
>>+ *
>> * @param sourcefile String
>> * @param destfile String
>> * @param locale String
>>@@ -701,11 +759,6 @@
>>
>> this.sourcefile = sourcefile;
>> this.destfile = destfile;
>>- this.locale = locale;
>>- this.inputEncoding = inputEncoding;
>>- this.outputEncoding = outputEncoding;
>>- this.javadocLinkDir = javadocLinkDir;
>>- this.revision = revision;
>>
>> //make sure that the parent directories exist...
>> new File( new File( destfile ).getParent() ).mkdirs();
>>@@ -730,30 +783,8 @@
>> {
>> fw = new FileWriter( destfile );
>> }
>>- BufferedReader in = new BufferedReader( fr );
>>-
>>- PrintWriter out = new PrintWriter( fw );
>>-
>>- String line = "";
>>
>>- out.println( getHeader() );
>>-
>>- int linenumber = 1;
>>- while ( ( line = in.readLine() ) != null )
>>- {
>>- if ( LINE_NUMBERS )
>>- {
>>- out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
>>- "</a>" + getLineWidth( linenumber ) );
>>- }
>>-
>>- out.println( this.syntaxHighlight( line ) );
>>-
>>- ++linenumber;
>>- }
>>-
>>- out.println( getFooter() );
>>- out.flush();
>>+ transform( fr, fw, locale, inputEncoding, outputEncoding, javadocLinkDir, revision, true, true );
>> }
>> catch ( RuntimeException e )
>> {
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r292670 - /maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
Posted by Brett Porter <br...@apache.org>.
is this missing close() in a finally?
- Brett
evenisse@apache.org wrote:
>Author: evenisse
>Date: Fri Sep 30 00:59:23 2005
>New Revision: 292670
>
>URL: http://svn.apache.org/viewcvs?rev=292670&view=rev
>Log:
>Add transform method for users that don't want to work on files but with Reader/Writer
>
>Modified:
> maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
>
>Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
>URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java?rev=292670&r1=292669&r2=292670&view=diff
>==============================================================================
>--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java (original)
>+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java Fri Sep 30 00:59:23 2005
>@@ -683,6 +683,64 @@
> /**
> * This is the public method for doing all transforms of code.
> *
>+ * @param sourceReader Reader
>+ * @param destWriter Writer
>+ * @param locale String
>+ * @param inputEncoding String
>+ * @param outputEncoding String
>+ * @param javadocLinkDir String
>+ * @param revision String
>+ * @param showHeader boolean
>+ * @param showFooter boolean
>+ * @throws IOException
>+ */
>+ public final void transform( Reader sourceReader, Writer destWriter, Locale locale, String inputEncoding,
>+ String outputEncoding, String javadocLinkDir, String revision, boolean showHeader,
>+ boolean showFooter )
>+ throws IOException
>+ {
>+ this.locale = locale;
>+ this.inputEncoding = inputEncoding;
>+ this.outputEncoding = outputEncoding;
>+ this.javadocLinkDir = javadocLinkDir;
>+ this.revision = revision;
>+
>+ BufferedReader in = new BufferedReader( sourceReader );
>+
>+ PrintWriter out = new PrintWriter( destWriter );
>+
>+ String line = "";
>+
>+ if ( showHeader )
>+ {
>+ out.println( getHeader() );
>+ }
>+
>+ int linenumber = 1;
>+ while ( ( line = in.readLine() ) != null )
>+ {
>+ if ( LINE_NUMBERS )
>+ {
>+ out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
>+ "</a>" + getLineWidth( linenumber ) );
>+ }
>+
>+ out.println( this.syntaxHighlight( line ) );
>+
>+ ++linenumber;
>+ }
>+
>+ if ( showFooter )
>+ {
>+ out.println( getFooter() );
>+ }
>+
>+ out.flush();
>+ }
>+
>+ /**
>+ * This is the public method for doing all transforms of code.
>+ *
> * @param sourcefile String
> * @param destfile String
> * @param locale String
>@@ -701,11 +759,6 @@
>
> this.sourcefile = sourcefile;
> this.destfile = destfile;
>- this.locale = locale;
>- this.inputEncoding = inputEncoding;
>- this.outputEncoding = outputEncoding;
>- this.javadocLinkDir = javadocLinkDir;
>- this.revision = revision;
>
> //make sure that the parent directories exist...
> new File( new File( destfile ).getParent() ).mkdirs();
>@@ -730,30 +783,8 @@
> {
> fw = new FileWriter( destfile );
> }
>- BufferedReader in = new BufferedReader( fr );
>-
>- PrintWriter out = new PrintWriter( fw );
>-
>- String line = "";
>
>- out.println( getHeader() );
>-
>- int linenumber = 1;
>- while ( ( line = in.readLine() ) != null )
>- {
>- if ( LINE_NUMBERS )
>- {
>- out.print( "<a name=\"" + linenumber + "\" " + "href=\"#" + linenumber + "\">" + linenumber +
>- "</a>" + getLineWidth( linenumber ) );
>- }
>-
>- out.println( this.syntaxHighlight( line ) );
>-
>- ++linenumber;
>- }
>-
>- out.println( getFooter() );
>- out.flush();
>+ transform( fr, fw, locale, inputEncoding, outputEncoding, javadocLinkDir, revision, true, true );
> }
> catch ( RuntimeException e )
> {
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>For additional commands, e-mail: dev-help@maven.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org