maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r736290 - in /maven/doxia: doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/ doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/ doxia/trunk/doxia-modules...
Date Wed, 21 Jan 2009 11:40:33 GMT
Author: vsiveton
Date: Wed Jan 21 03:40:32 2009
New Revision: 736290

URL: http://svn.apache.org/viewvc?rev=736290&view=rev
Log:
o fixed TODO in XHTML about RenderingContext
o moved the logic in the sub classes

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/SiteRendererSink.java
    maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/XhtmlBookSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/SiteRendererSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/SiteRendererSink.java?rev=736290&r1=736289&r2=736290&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/SiteRendererSink.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/sink/SiteRendererSink.java
Wed Jan 21 03:40:32 2009
@@ -32,6 +32,7 @@
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.util.HtmlTools;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Sink for site renderering.
@@ -53,8 +54,12 @@
 
     private final Writer writer;
 
+    private RenderingContext renderingContext;
+
     /**
-     * @param renderingContext
+     * Construct a new SiteRendererSink.
+     *
+     * @param renderingContext the RenderingContext.
      */
     public SiteRendererSink( RenderingContext renderingContext )
     {
@@ -62,14 +67,17 @@
     }
 
     /**
-     * @param writer
-     * @param renderingContext
+     * Construct a new SiteRendererSink.
+     *
+     * @param writer the writer for the sink.
+     * @param renderingContext the RenderingContext.
      */
     private SiteRendererSink( StringWriter writer, RenderingContext renderingContext )
     {
-        super( writer, renderingContext, null );
+        super( writer );
 
         this.writer = writer;
+        this.renderingContext = renderingContext;
     }
 
     /** {@inheritDoc} */
@@ -261,4 +269,32 @@
     {
         sectionTitle_( SECTION_LEVEL_2 );
     }
+
+    /**
+     * @return the current rendering context
+     */
+    public RenderingContext getRenderingContext()
+    {
+        return renderingContext;
+    }
+
+    /** {@inheritDoc} */
+    protected void write( String text )
+    {
+        if ( renderingContext != null )
+        {
+            String relativePathToBasedir = renderingContext.getRelativePath();
+
+            if ( relativePathToBasedir == null )
+            {
+                text = StringUtils.replace( text, "$relativePath", "." );
+            }
+            else
+            {
+                text = StringUtils.replace( text, "$relativePath", relativePathToBasedir
);
+            }
+        }
+
+        super.write( text );
+    }
 }

Modified: maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/XhtmlBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/XhtmlBookSink.java?rev=736290&r1=736289&r2=736290&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/XhtmlBookSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-book/src/main/java/org/apache/maven/doxia/book/services/renderer/xhtml/XhtmlBookSink.java
Wed Jan 21 03:40:32 2009
@@ -21,6 +21,7 @@
 
 import org.apache.maven.doxia.module.xhtml.XhtmlSink;
 import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.Writer;
 
@@ -35,6 +36,8 @@
 public class XhtmlBookSink
     extends XhtmlSink
 {
+    private RenderingContext renderingContext;
+
     /**
      * Construct a new XhtmlBookSink.
      *
@@ -43,7 +46,8 @@
      */
     public XhtmlBookSink( Writer out, RenderingContext context )
     {
-        super( out, context );
+        super( out );
+        this.renderingContext = context;
     }
 
     // ----------------------------------------------------------------------
@@ -159,4 +163,24 @@
     {
         writeEndTag( Tag.H1 );
     }
+
+    /** {@inheritDoc} */
+    protected void write( String text )
+    {
+        if ( renderingContext != null )
+        {
+            String relativePathToBasedir = renderingContext.getRelativePath();
+
+            if ( relativePathToBasedir == null )
+            {
+                text = StringUtils.replace( text, "$relativePath", "." );
+            }
+            else
+            {
+                text = StringUtils.replace( text, "$relativePath", relativePathToBasedir
);
+            }
+        }
+
+        super.write( text );
+    }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java?rev=736290&r1=736289&r2=736290&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlSink.java
Wed Jan 21 03:40:32 2009
@@ -20,16 +20,13 @@
  */
 
 import java.io.Writer;
-import java.util.Map;
 
 import javax.swing.text.MutableAttributeSet;
 import javax.swing.text.html.HTML.Attribute;
 import javax.swing.text.html.HTML.Tag;
 
-import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
 import org.apache.maven.doxia.sink.XhtmlBaseSink;
 import org.apache.maven.doxia.sink.SinkEventAttributeSet;
-import org.codehaus.plexus.util.StringUtils;
 
 /**
  * Xhtml sink implementation.
@@ -56,9 +53,6 @@
     // Instance fields
     // ----------------------------------------------------------------------
 
-    // TODO: this doesn't belong here
-    private RenderingContext renderingContext;
-
     private String encoding;
 
     /** An indication on if we're inside a head title. */
@@ -75,7 +69,7 @@
      */
     protected XhtmlSink( Writer writer )
     {
-        this( writer, (RenderingContext) null );
+        super( writer );
     }
 
     /**
@@ -87,31 +81,9 @@
      */
     protected XhtmlSink( Writer writer, String encoding )
     {
-        this( writer, (RenderingContext) null );
-
-        this.encoding = encoding;
-    }
-
-    /**
-     * @param writer
-     * @param renderingContext
-     */
-    protected XhtmlSink( Writer writer, RenderingContext renderingContext )
-    {
         super( writer );
 
-        this.renderingContext = renderingContext;
-    }
-
-    /**
-     * @param writer
-     * @param renderingContext
-     * @param directives
-     * @todo directives Map is not used
-     */
-    protected XhtmlSink( Writer writer, RenderingContext renderingContext, Map directives
)
-    {
-        this( writer, renderingContext );
+        this.encoding = encoding;
     }
 
     /** {@inheritDoc} */
@@ -245,33 +217,10 @@
     /** {@inheritDoc} */
     protected void write( String text )
     {
-        // TODO: this doesn't belong here
-        if ( renderingContext != null )
-        {
-            String relativePathToBasedir = renderingContext.getRelativePath();
-
-            if ( relativePathToBasedir == null )
-            {
-                text = StringUtils.replace( text, "$relativePath", "." );
-            }
-            else
-            {
-                text = StringUtils.replace( text, "$relativePath", relativePathToBasedir
);
-            }
-        }
-
         super.write( text );
     }
 
     /**
-     * @return the current rendering context
-     */
-    public RenderingContext getRenderingContext()
-    {
-        return renderingContext;
-    }
-
-    /**
      * @param headTitleFlag an header title flag.
      */
     protected void setHeadTitleFlag( boolean headTitleFlag )



Mime
View raw message