You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by vs...@apache.org on 2008/10/20 14:47:28 UTC
svn commit: r706267 - in
/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src:
main/java/org/apache/maven/doxia/module/confluence/
test/java/org/apache/maven/doxia/module/confluence/
Author: vsiveton
Date: Mon Oct 20 05:47:28 2008
New Revision: 706267
URL: http://svn.apache.org/viewvc?rev=706267&view=rev
Log:
DOXIA-124: Confluence sink Support
o first implementation
o added test case too
Added:
maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java (with props)
maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java (with props)
maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java (with props)
maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java (with props)
Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java?rev=706267&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java Mon Oct 20 05:47:28 2008
@@ -0,0 +1,102 @@
+package org.apache.maven.doxia.module.confluence;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.swing.text.html.HTML.Tag;
+
+import org.apache.maven.doxia.markup.TextMarkup;
+
+/**
+ * This interface defines all markups and syntaxes used by the <b>Confluence</b> format.
+ *
+ * See <a href="http://confluence.atlassian.com/display/CONF25/Confluence+Notation+Guide+Overview">
+ * Confluence Notation Guide Overview</a>
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ */
+public interface ConfluenceMarkup
+ extends TextMarkup
+{
+ // ----------------------------------------------------------------------
+ // Confluence markups
+ // ----------------------------------------------------------------------
+
+ /** Syntax for the anchor : "{anchor:" */
+ String ANCHOR_START_MARKUP = "{anchor:";
+
+ /** Syntax for the anchor : "}" */
+ String ANCHOR_END_MARKUP = "}";
+
+ /** Syntax for the bold markup: "*" */
+ String BOLD_END_MARKUP = "*";
+
+ /** Syntax for the bold markup: "*" */
+ String BOLD_START_MARKUP = "*";
+
+ /** Syntax for the figure markup: "!" */
+ String FIGURE_END_MARKUP = "!";
+
+ /** Syntax for the figure markup: "!" */
+ String FIGURE_START_MARKUP = "!";
+
+ /** Syntax for the italic markup: "_" */
+ String ITALIC_END_MARKUP = "_";
+
+ /** Syntax for the italic markup: "_" */
+ String ITALIC_START_MARKUP = "_";
+
+ /** Syntax for the line break markup: "\\\\" */
+ String LINE_BREAK_MARKUP = "\\\\";
+
+ /** Syntax for the link end markup: "]" */
+ String LINK_END_MARKUP = "]";
+
+ /** Syntax for the link middle markup: "|" */
+ String LINK_MIDDLE_MARKUP = "|";
+
+ /** Syntax for the link start markup: "[" */
+ String LINK_START_MARKUP = "[";
+
+ /** Syntax for the list item markup: "* */
+ String LIST_ITEM_MARKUP = "* ";
+
+ /** Syntax for the mono-spaced style end: "{{" */
+ String MONOSPACED_END_MARKUP = "{{";
+
+ /** Syntax for the mono-spaced style start: "}}" */
+ String MONOSPACED_START_MARKUP = "}}";
+
+ /** Syntax for the numbering decimal markup char: "1." */
+ String NUMBERING_MARKUP = "1.";
+
+ /** Syntax for the table cell header end markup: "|" */
+ String TABLE_CELL_HEADER_END_MARKUP = "|";
+
+ /** Syntax for the table cell header start markup: "|" */
+ String TABLE_CELL_HEADER_START_MARKUP = "|";
+
+ /** Syntax for the table cell markup: "|" */
+ String TABLE_CELL_MARKUP = "|";
+
+ /** Syntax for the table row markup: "|" */
+ String TABLE_ROW_MARKUP = "|";
+}
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceMarkup.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java?rev=706267&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java Mon Oct 20 05:47:28 2008
@@ -0,0 +1,1002 @@
+package org.apache.maven.doxia.module.confluence;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Stack;
+
+import org.apache.maven.doxia.sink.AbstractTextSink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
+import org.apache.maven.doxia.util.HtmlTools;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Confluence Sink implementation.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ */
+public class ConfluenceSink
+ extends AbstractTextSink
+ implements ConfluenceMarkup
+{
+ /** The writer to use. */
+ private PrintWriter out;
+
+ /** The writer to use. */
+ private StringWriter writer;
+
+ /** An indication on if we're in head mode. */
+ private boolean headFlag;
+
+ private int levelList = 0;
+
+ /** listStyles. */
+ private Stack listStyles;
+
+ /** An indication on if we're in verbatim box mode. */
+ private boolean verbatimBoxedFlag;
+
+ /** An indication on if we're in table header mode. */
+ private boolean tableHeaderFlag;
+
+ /** The link name. */
+ private String linkName;
+
+ /**
+ * @param writer writer not null
+ */
+ public ConfluenceSink( Writer writer )
+ {
+ this.out = new PrintWriter( writer );
+ this.writer = new StringWriter();
+ this.listStyles = new Stack();
+ }
+
+ /** {@inheritDoc} */
+ public void anchor( String name )
+ {
+ write( ANCHOR_START_MARKUP + name + ANCHOR_END_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void anchor( String name, SinkEventAttributes attributes )
+ {
+ anchor( name );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void anchor_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void author()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void author( SinkEventAttributes attributes )
+ {
+ author();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void author_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void body()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void body( SinkEventAttributes attributes )
+ {
+ body();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void body_()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void bold()
+ {
+ write( BOLD_START_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void bold_()
+ {
+ write( BOLD_END_MARKUP );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void comment( String comment )
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void close()
+ {
+ out.write( writer.toString() );
+ out.close();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void date()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void date( SinkEventAttributes attributes )
+ {
+ date();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void date_()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void definedTerm()
+ {
+ write( " " );
+ }
+
+ /** {@inheritDoc} */
+ public void definedTerm( SinkEventAttributes attributes )
+ {
+ definedTerm();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definedTerm_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definition()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definition( SinkEventAttributes attributes )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definition_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionList()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionList( SinkEventAttributes attributes )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionList_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionListItem()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionListItem( SinkEventAttributes attributes )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void definitionListItem_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void figure()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void figure( SinkEventAttributes attributes )
+ {
+ figure();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void figure_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void figureCaption()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void figureCaption( SinkEventAttributes attributes )
+ {
+ figureCaption();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void figureCaption_()
+ {
+ // nop;
+ }
+
+ /** {@inheritDoc} */
+ public void figureGraphics( String name )
+ {
+ writeEOL();
+ write( FIGURE_START_MARKUP + name + FIGURE_END_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void figureGraphics( String src, SinkEventAttributes attributes )
+ {
+ figureGraphics( src );
+ if ( attributes != null && attributes.getAttribute( "alt" ) != null )
+ {
+ write( attributes.getAttribute( "alt" ).toString() );
+ writeEOL( true );
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void flush()
+ {
+ close();
+ writer.flush();
+ }
+
+ /** {@inheritDoc} */
+ public void head()
+ {
+ headFlag = true;
+ }
+
+ /** {@inheritDoc} */
+ public void head( SinkEventAttributes attributes )
+ {
+ head();
+ }
+
+ /** {@inheritDoc} */
+ public void head_()
+ {
+ headFlag = false;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void horizontalRule()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void horizontalRule( SinkEventAttributes attributes )
+ {
+ horizontalRule();
+ }
+
+ /** {@inheritDoc} */
+ public void italic()
+ {
+ write( ITALIC_START_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void italic_()
+ {
+ write( ITALIC_END_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void lineBreak()
+ {
+ write( LINE_BREAK_MARKUP );
+ writeEOL();
+ }
+
+ /** {@inheritDoc} */
+ public void lineBreak( SinkEventAttributes attributes )
+ {
+ lineBreak();
+ }
+
+ /** {@inheritDoc} */
+ public void link( String name )
+ {
+ linkName = name;
+ }
+
+ /** {@inheritDoc} */
+ public void link( String name, SinkEventAttributes attributes )
+ {
+ link( name );
+ }
+
+ /** {@inheritDoc} */
+ public void link_()
+ {
+ linkName = null;
+ write( LINK_END_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void list()
+ {
+ if ( !writer.toString().endsWith( EOL + EOL ) )
+ {
+ writeEOL( true );
+ }
+
+ levelList++;
+ }
+
+ /** {@inheritDoc} */
+ public void list( SinkEventAttributes attributes )
+ {
+ list();
+ }
+
+ /** {@inheritDoc} */
+ public void list_()
+ {
+ levelList--;
+ }
+
+ /** {@inheritDoc} */
+ public void listItem()
+ {
+ write( StringUtils.repeat( "*", levelList ) + " " );
+ }
+
+ /** {@inheritDoc} */
+ public void listItem( SinkEventAttributes attributes )
+ {
+ listItem();
+ }
+
+ /** {@inheritDoc} */
+ public void listItem_()
+ {
+ writeEOL( true );
+ }
+
+ /** {@inheritDoc} */
+ public void monospaced()
+ {
+ write( MONOSPACED_START_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void monospaced_()
+ {
+ write( MONOSPACED_END_MARKUP );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void nonBreakingSpace()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void numberedList( int numbering )
+ {
+ levelList++;
+
+ String style;
+ switch ( numbering )
+ {
+ case NUMBERING_UPPER_ALPHA:
+ case NUMBERING_LOWER_ALPHA:
+ case NUMBERING_UPPER_ROMAN:
+ case NUMBERING_LOWER_ROMAN:
+ case NUMBERING_DECIMAL:
+ default:
+ style = NUMBERING_MARKUP;
+ }
+
+ listStyles.push( style );
+ }
+
+ /** {@inheritDoc} */
+ public void numberedList( int numbering, SinkEventAttributes attributes )
+ {
+ numberedList( numbering );
+ }
+
+ /** {@inheritDoc} */
+ public void numberedList_()
+ {
+ levelList--;
+ listStyles.pop();
+ }
+
+ /** {@inheritDoc} */
+ public void numberedListItem()
+ {
+ writeEOL( true );
+ String style = (String) listStyles.peek();
+ write( style + SPACE );
+ }
+
+ /** {@inheritDoc} */
+ public void numberedListItem( SinkEventAttributes attributes )
+ {
+ numberedListItem();
+ }
+
+ /** {@inheritDoc} */
+ public void numberedListItem_()
+ {
+ writeEOL( true );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void pageBreak()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void paragraph()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void paragraph( SinkEventAttributes attributes )
+ {
+ paragraph();
+ }
+
+ /** {@inheritDoc} */
+ public void paragraph_()
+ {
+ writeEOL( true );
+ writeEOL();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void rawText( String text )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section( int level, SinkEventAttributes attributes )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section1()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section1_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section2()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section2_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section3()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section3_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section4()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section4_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section5()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section5_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void section_( int level )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void sectionTitle()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle( int level, SinkEventAttributes attributes )
+ {
+ if ( level > 0 && level < 6 )
+ {
+ write( "h" + level + ". " );
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle1()
+ {
+ sectionTitle( 1, null );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle1_()
+ {
+ sectionTitle_( 1 );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle2()
+ {
+ sectionTitle( 2, null );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle2_()
+ {
+ sectionTitle_( 2 );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle3()
+ {
+ sectionTitle( 3, null );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle3_()
+ {
+ sectionTitle_( 3 );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle4()
+ {
+ sectionTitle( 4, null );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle4_()
+ {
+ sectionTitle_( 4 );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle5()
+ {
+ sectionTitle( 5, null );
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle5_()
+ {
+ sectionTitle_( 5 );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void sectionTitle_()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void sectionTitle_( int level )
+ {
+ writeEOL( true );
+ writeEOL();
+ }
+
+ /** {@inheritDoc} */
+ public void table()
+ {
+ // nop
+ writeEOL( true );
+ writeEOL();
+ }
+
+ /** {@inheritDoc} */
+ public void table( SinkEventAttributes attributes )
+ {
+ table();
+ }
+
+ /** {@inheritDoc} */
+ public void table_()
+ {
+ writeEOL( true );
+ writeEOL();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void tableCaption()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void tableCaption( SinkEventAttributes attributes )
+ {
+ tableCaption();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void tableCaption_()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void tableCell()
+ {
+ write( " " );
+ }
+
+ /** {@inheritDoc} */
+ public void tableCell( SinkEventAttributes attributes )
+ {
+ tableCell();
+ }
+
+ /** {@inheritDoc} */
+ public void tableCell( String width )
+ {
+ tableCell();
+ }
+
+ /** {@inheritDoc} */
+ public void tableCell_()
+ {
+ write( " " );
+ write( TABLE_CELL_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void tableHeaderCell()
+ {
+ tableHeaderFlag = true;
+ write( TABLE_CELL_HEADER_START_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void tableHeaderCell( SinkEventAttributes attributes )
+ {
+ tableHeaderCell();
+ }
+
+ /** {@inheritDoc} */
+ public void tableHeaderCell( String width )
+ {
+ tableHeaderCell();
+ }
+
+ /** {@inheritDoc} */
+ public void tableHeaderCell_()
+ {
+ write( TABLE_CELL_HEADER_END_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void tableRow()
+ {
+ write( TABLE_ROW_MARKUP );
+ }
+
+ /** {@inheritDoc} */
+ public void tableRow( SinkEventAttributes attributes )
+ {
+ tableRow();
+ }
+
+ /** {@inheritDoc} */
+ public void tableRow_()
+ {
+ if ( tableHeaderFlag )
+ {
+ tableHeaderFlag = false;
+ write( TABLE_ROW_MARKUP );
+ }
+ writeEOL( true );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void tableRows( int[] justification, boolean grid )
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void tableRows_()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void text( String text )
+ {
+ if ( headFlag )
+ {
+ return;
+ }
+
+ if ( linkName != null )
+ {
+ write( LINK_START_MARKUP );
+ }
+
+ content( text );
+
+ if ( linkName != null )
+ {
+ write( LINK_MIDDLE_MARKUP + linkName );
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void text( String text, SinkEventAttributes attributes )
+ {
+ text( text );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void title()
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void title( SinkEventAttributes attributes )
+ {
+ title();
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void title_()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+ {
+ // nop
+ }
+
+ /** {@inheritDoc} */
+ public void verbatim( boolean boxed )
+ {
+ if ( boxed )
+ {
+ verbatimBoxedFlag = true;
+ }
+
+ if ( verbatimBoxedFlag )
+ {
+ write( "{code|borderStyle=solid}" );
+ }
+ else
+ {
+ write( "{noformat}" );
+ }
+ writeEOL( true );
+ }
+
+ /** {@inheritDoc} */
+ public void verbatim( SinkEventAttributes attributes )
+ {
+ verbatim( false );
+ }
+
+ /** {@inheritDoc} */
+ public void verbatim_()
+ {
+ if ( verbatimBoxedFlag )
+ {
+ write( "{code}" );
+ }
+ else
+ {
+ write( "{noformat}" );
+ }
+
+ writeEOL( true );
+ writeEOL();
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
+ private void write( String text )
+ {
+ writer.write( unifyEOLs( text ) );
+ }
+
+ /**
+ * Writes a system EOL.
+ */
+ private void writeEOL()
+ {
+ write( EOL );
+ }
+
+ /**
+ * Writes a system EOL, with or without trim.
+ */
+ private void writeEOL( boolean trim )
+ {
+ if ( !trim )
+ {
+ writeEOL();
+ return;
+ }
+
+ String tmp = writer.toString().trim();
+ writer = new StringWriter();
+ writer.write( tmp );
+ write( EOL );
+ }
+
+ /**
+ * Write HTML escaped text to output.
+ *
+ * @param text The text to write.
+ */
+ protected void content( String text )
+ {
+ write( escapeHTML( text ) );
+ }
+
+ /**
+ * Forward to HtmlTools.escapeHTML( text ).
+ *
+ * @param text the String to escape, may be null
+ * @return the text escaped, "" if null String input
+ * @see org.apache.maven.doxia.util.HtmlTools#escapeHTML(String)
+ */
+ protected static String escapeHTML( String text )
+ {
+ return HtmlTools.escapeHTML( text );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java?rev=706267&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java Mon Oct 20 05:47:28 2008
@@ -0,0 +1,67 @@
+package org.apache.maven.doxia.module.confluence;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkFactory;
+import org.codehaus.plexus.util.WriterFactory;
+
+/**
+ * Confluence implementation of the Sink factory.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ * @plexus.component role="org.apache.maven.doxia.sink.SinkFactory" role-hint="confluence"
+ */
+public class ConfluenceSinkFactory
+ implements SinkFactory
+{
+ /** {@inheritDoc} */
+ public Sink createSink( File outputDir, String outputName )
+ throws IOException
+ {
+ return createSink( outputDir, outputName, WriterFactory.UTF_8 );
+ }
+
+ /** {@inheritDoc} */
+ public Sink createSink( File outputDir, String outputName, String encoding )
+ throws IOException
+ {
+ if ( !outputDir.isDirectory() )
+ {
+ throw new IllegalArgumentException( "The dir '" + outputDir + "' is not a directory or not exist" );
+ }
+
+ Writer writer = WriterFactory.newWriter( new File( outputDir, outputName ), encoding );
+
+ return new ConfluenceSink( writer );
+ }
+
+ /** {@inheritDoc} */
+ public Sink createSink( Writer writer )
+ {
+ return new ConfluenceSink( writer );
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkFactory.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java?rev=706267&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java (added)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java Mon Oct 20 05:47:28 2008
@@ -0,0 +1,276 @@
+package org.apache.maven.doxia.module.confluence;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Writer;
+
+import org.apache.maven.doxia.sink.AbstractSinkTest;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.util.HtmlTools;
+
+/**
+ * Test the Confluence Sink
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @see ConfluenceSink
+ */
+public class ConfluenceSinkTest
+ extends AbstractSinkTest
+{
+ /** {@inheritDoc} */
+ protected Sink createSink( Writer writer )
+ {
+ return new ConfluenceSink( writer );
+ }
+
+ /** {@inheritDoc} */
+ protected String getAnchorBlock( String anchor )
+ {
+ return ConfluenceMarkup.ANCHOR_START_MARKUP + anchor + ConfluenceMarkup.ANCHOR_END_MARKUP + anchor;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getAuthorBlock( String author )
+ {
+ return null;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getBodyBlock()
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected String getBoldBlock( String text )
+ {
+ return ConfluenceMarkup.BOLD_START_MARKUP + text + ConfluenceMarkup.BOLD_END_MARKUP;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getDateBlock( String date )
+ {
+ return null;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getDefinitionListBlock( String definum, String definition )
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected String getFigureBlock( String source, String caption )
+ {
+ return EOL + ConfluenceMarkup.FIGURE_START_MARKUP + source + ConfluenceMarkup.FIGURE_END_MARKUP + caption;
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getHeadBlock()
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected String getHorizontalRuleBlock()
+ {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ protected String getItalicBlock( String text )
+ {
+ return ConfluenceMarkup.ITALIC_START_MARKUP + text + ConfluenceMarkup.ITALIC_END_MARKUP;
+ }
+
+ /** {@inheritDoc} */
+ protected String getLineBreakBlock()
+ {
+ return ConfluenceMarkup.LINE_BREAK_MARKUP + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getLinkBlock( String link, String text )
+ {
+ return ConfluenceMarkup.LINK_START_MARKUP + text + ConfluenceMarkup.LINK_MIDDLE_MARKUP + link
+ + ConfluenceMarkup.LINK_END_MARKUP;
+ }
+
+ /** {@inheritDoc} */
+ protected String getListBlock( String item )
+ {
+ return ConfluenceMarkup.LIST_ITEM_MARKUP + item + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getMonospacedBlock( String text )
+ {
+ return ConfluenceMarkup.MONOSPACED_START_MARKUP + text + ConfluenceMarkup.MONOSPACED_END_MARKUP;
+ }
+
+ /** {@inheritDoc} */
+ protected String getNonBreakingSpaceBlock()
+ {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ protected String getNumberedListBlock( String item )
+ {
+ return ConfluenceMarkup.NUMBERING_MARKUP + " " + item + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getPageBreakBlock()
+ {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ protected String getParagraphBlock( String text )
+ {
+ return text + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getRawTextBlock( String text )
+ {
+ return "";
+ }
+
+ /** {@inheritDoc} */
+ protected String getSection1Block( String title )
+ {
+ return "h1. " + title + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getSection2Block( String title )
+ {
+ return "h2. " + title + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getSection3Block( String title )
+ {
+ return "h3. " + title + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getSection4Block( String title )
+ {
+ return "h4. " + title + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getSection5Block( String title )
+ {
+ return "h5. " + title + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getSectionTitleBlock( String title )
+ {
+ return title;
+ }
+
+ /** {@inheritDoc} */
+ protected String getTableBlock( String cell, String caption )
+ {
+ return "| " + cell + " |" + EOL + "Table_caption" + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String getTextBlock( String text )
+ {
+ return HtmlTools.escapeHTML( text );
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ protected String getTitleBlock( String title )
+ {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ protected String getVerbatimBlock( String text )
+ {
+ return "{code|borderStyle=solid}" + EOL + text + "{code}" + EOL + EOL;
+ }
+
+ /** {@inheritDoc} */
+ protected String outputExtension()
+ {
+ return "twiki";
+ }
+
+ // ----------------------------------------------------------------------
+ // Override unused tests
+ // ----------------------------------------------------------------------
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testAuthor()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testDate()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testHead()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testBody()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testTitle()
+ {
+ // nop
+ }
+
+ /** Not used.
+ * {@inheritDoc} */
+ public void testDefinitionList()
+ {
+ // nop
+ }
+}
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/test/java/org/apache/maven/doxia/module/confluence/ConfluenceSinkTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision