Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.devtools.wiki
Class WikiTranslatorManager  view WikiTranslatorManager download WikiTranslatorManager.java

java.lang.Object
  extended byorg.devtools.wiki.WikiTranslatorManager
All Implemented Interfaces:
org.devtools.webtrans.TranslatorManager
Direct Known Subclasses:
CachingTranslatorManager

public class WikiTranslatorManager
extends java.lang.Object
implements org.devtools.webtrans.TranslatorManager

Translates a WebContent into HTML by applying a number of Translators. Each Translator can insert, delete, and replace text in the original content. The changes are gathered together, merged, and applied to the document at the end of the process. (This is done so that each Translator module works with the real, original document and does not accidentally interpret partial changes to the document to be original content.)

In addition, TranslatorManager hides any literal areas from the Translators, so that it cannot be considered or changed. (A literal area is any text enclosed in the LITERAL symbols). Thus, any text between these characters will come straight through the translation process and be served right to the browser (except of course for the LITERAL symbols themselves, which will be removed unless escaped. See below.) Presumably the content author will type raw HTML into the literal areas. FIXME: Would have liked to implement this as a Translator rather than a special behavior.

Each LITERAL_ESCAPE symbol in the document will appear to the Translators as LITERAL symbols, and will not denote a literal area. The content author must type LITERAL_ESCAPE symbols into the content anywhere they wish a character to appear that is one of the reserved LITERAL symbols, even if it appears in a literal area. TranslatorManager will attempt to interpret any unescaped LITERAL symbols as literal area control instructions.


Field Summary
private  org.devtools.util.debug.Debugger D
           
static java.lang.String LITERAL_START
          The symbol which should be considered the start of a literal area during the translation process.
static java.lang.String LITERAL_START_ESCAPE
          The symbol which the content author must use in order to force a LITERAL_START symbol to appear in the document (This escape character must be used even in the literal areas).
static java.lang.String LITERAL_STOP
          The symbol which should be considered the end of a literal area during the translation process.
static java.lang.String LITERAL_STOP_ESCAPE
          The symbol which the content author must use in order to force a LITERAL_STOP symbol to appear in the document (This escape character must be used even in the literal areas).
private  java.util.Vector modules
          The modules that the document will be passed through when processed during a translate() call.
private  org.devtools.webtrans.TranslatorServices srv
          Some site services
 
Constructor Summary
WikiTranslatorManager()
          Constructs a new TranslatorManager that is initially empty.
 
Method Summary
 void addTranslator(org.devtools.webtrans.Translator t)
          Adds a translator to the list.
 java.lang.String getUsage()
          Returns an HTML-formatted display of the usage for each translator in this translator manager.
 void init(org.devtools.webtrans.TranslatorServices srv)
          Initializes the translatorManager with the given TranslatorServices.
static void main(java.lang.String[] args)
           
private  java.lang.String showMessages(org.devtools.webtrans.TranslatorLog log)
          Formats up the messages in the Translation log politely.
private  TempWebContent stripLiteralAreas(org.devtools.webtrans.StringChanges sc, org.devtools.webtrans.WebContent content, org.devtools.webtrans.TranslatorLog log)
          Strips out the literal areas and returns the resulting content in a TempWebContent.
 java.lang.String translate(org.devtools.webtrans.WebContent content, java.util.Properties query)
          Translates the given content into HTML.
private  java.lang.String translateF(org.devtools.webtrans.WebContent content, java.util.Properties query, org.devtools.webtrans.TranslatorLog log)
          Translates the given content into HTML.
 java.lang.String translateWithDetails(org.devtools.webtrans.WebContent content, java.util.Properties query)
          Translates the given content into HTML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LITERAL_START

public static final java.lang.String LITERAL_START
The symbol which should be considered the start of a literal area during the translation process. Text between this symbol and the next LITERAL_STOP symbol will be invisible to the Translators, and will appear in the final translation directly.

See Also:
Constant Field Values

LITERAL_STOP

public static final java.lang.String LITERAL_STOP
The symbol which should be considered the end of a literal area during the translation process. Text between this symbol and the last LITERAL_START symbol will be invisible to the Translators, and will appear in the final translation directly.

See Also:
Constant Field Values

LITERAL_START_ESCAPE

public static final java.lang.String LITERAL_START_ESCAPE
The symbol which the content author must use in order to force a LITERAL_START symbol to appear in the document (This escape character must be used even in the literal areas).

See Also:
Constant Field Values

LITERAL_STOP_ESCAPE

public static final java.lang.String LITERAL_STOP_ESCAPE
The symbol which the content author must use in order to force a LITERAL_STOP symbol to appear in the document (This escape character must be used even in the literal areas).

See Also:
Constant Field Values

modules

private java.util.Vector modules
The modules that the document will be passed through when processed during a translate() call. Everything in here should conform to the TranslatorInterface.


srv

private org.devtools.webtrans.TranslatorServices srv
Some site services


D

private org.devtools.util.debug.Debugger D
Constructor Detail

WikiTranslatorManager

public WikiTranslatorManager()
Constructs a new TranslatorManager that is initially empty. Without any Translators, the translate() method will simply return the given document. You must add Translators to the FlexTranslator (using addTranslator, etc) in order to get it to do something interesting.

Method Detail

init

public void init(org.devtools.webtrans.TranslatorServices srv)
Initializes the translatorManager with the given TranslatorServices. The manager can assume that this method will be called exactly once, before any other method is called.

Specified by:
init in interface org.devtools.webtrans.TranslatorManager

addTranslator

public void addTranslator(org.devtools.webtrans.Translator t)
Adds a translator to the list. Since in some cases Translators may interfere, the order in which the translators were added to the document is the deciding factor (last-added translators get precedence in applying their changes over earlier ones.)

Specified by:
addTranslator in interface org.devtools.webtrans.TranslatorManager

translate

public java.lang.String translate(org.devtools.webtrans.WebContent content,
                                  java.util.Properties query)
Translates the given content into HTML. FIXME: Should eventually handle other content types, maybe?

Specified by:
translate in interface org.devtools.webtrans.TranslatorManager

translateF

private java.lang.String translateF(org.devtools.webtrans.WebContent content,
                                    java.util.Properties query,
                                    org.devtools.webtrans.TranslatorLog log)
Translates the given content into HTML. FIXME: Should eventually handle other content types, maybe?


getUsage

public java.lang.String getUsage()
Returns an HTML-formatted display of the usage for each translator in this translator manager. Each translator will be an item in a list.

Specified by:
getUsage in interface org.devtools.webtrans.TranslatorManager

showMessages

private java.lang.String showMessages(org.devtools.webtrans.TranslatorLog log)
Formats up the messages in the Translation log politely.


stripLiteralAreas

private TempWebContent stripLiteralAreas(org.devtools.webtrans.StringChanges sc,
                                         org.devtools.webtrans.WebContent content,
                                         org.devtools.webtrans.TranslatorLog log)
                                  throws org.devtools.webtrans.PersistenceException
Strips out the literal areas and returns the resulting content in a TempWebContent. The actual literal areas are put into the StringChanges as insert commands.


translateWithDetails

public java.lang.String translateWithDetails(org.devtools.webtrans.WebContent content,
                                             java.util.Properties query)
Translates the given content into HTML. Additiionally, the translation should have (somewhere) an indication of the warnings and details that each Translator might have returned.

Since this method is usually called for the purposes of showing the page author a preview of the content they have just created, the message output should probably not obscure the actual appearance of the page.

Specified by:
translateWithDetails in interface org.devtools.webtrans.TranslatorManager

main

public static void main(java.lang.String[] args)