You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2007/10/27 13:34:20 UTC
svn commit: r589076 -
/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java
Author: vsiveton
Date: Sat Oct 27 04:34:19 2007
New Revision: 589076
URL: http://svn.apache.org/viewvc?rev=589076&view=rev
Log:
o used optional stylesheet
Modified:
maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java?rev=589076&r1=589075&r2=589076&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/JavaSrc.java Sat Oct 27 04:34:19 2007
@@ -20,6 +20,7 @@
*/
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -154,7 +155,14 @@
Pass2 p2 = new Pass2( getOptions() );
p2.run();
- copyDefaultStylesheet( getDestDir() );
+ if ( StringUtils.isNotEmpty( getOptions().getStylesheetfile() ) )
+ {
+ copyStylesheet( getOptions().getStylesheetfile(), getDestDir() );
+ }
+ else
+ {
+ copyDefaultStylesheet( getDestDir() );
+ }
}
// ----------------------------------------------------------------------
@@ -329,9 +337,10 @@
*
* @param outputDirectory the output directory
* @throws IOException if any
+ * @see #RESOURCE_CSS_DIR
* @see #DEFAULT_CSS_NAME
*/
- private void copyDefaultStylesheet( File outputDirectory )
+ private static void copyDefaultStylesheet( File outputDirectory )
throws IOException
{
if ( outputDirectory == null || !outputDirectory.exists() )
@@ -340,14 +349,50 @@
}
InputStream is = getStream( RESOURCE_CSS_DIR + "/" + DEFAULT_CSS_NAME );
+ copyStylesheetInputStream( is, outputDirectory );
+ }
+
+ /**
+ * Method that copy a given stylesheet file to the <code>outputDirectory</code>.
+ *
+ * @param outputDirectory the output directory
+ * @throws IOException if any
+ * @see #DEFAULT_CSS_NAME
+ */
+ private static void copyStylesheet( String stylesheetFile, File outputDirectory )
+ throws IOException
+ {
+ if ( outputDirectory == null || !outputDirectory.exists() )
+ {
+ throw new IOException( "The outputDirectory " + outputDirectory + " doesn't exists." );
+ }
+
+ File stylesheet = new File( stylesheetFile );
+ if ( !stylesheet.exists() || stylesheet.isDirectory() )
+ {
+ throw new IOException( "The stylesheet " + stylesheetFile + " doesn't exists or not a file." );
+ }
+
+ InputStream is = new FileInputStream( stylesheet );
+ copyStylesheetInputStream( is, outputDirectory );
+ }
+ /**
+ * Method that copy a stylesheet input stream to the <code>outputDirectory</code>.
+ *
+ * @param outputDirectory the output directory
+ * @throws IOException if any
+ * @see #DEFAULT_CSS_NAME
+ */
+ private static void copyStylesheetInputStream( InputStream is, File outputDirectory )
+ throws IOException
+ {
if ( is == null )
{
- throw new IOException( "The resource " + DEFAULT_CSS_NAME + " doesn't exists." );
+ throw new IOException( "The inputstream could not be null." );
}
File outputFile = new File( outputDirectory, DEFAULT_CSS_NAME );
-
if ( !outputFile.getParentFile().exists() )
{
outputFile.getParentFile().mkdirs();