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

Quick Search    Search Deep

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

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

public class CachingTranslatorManager
extends WikiTranslatorManager
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  java.util.Hashtable cache
          A hash of URL string keys and HTML string values.
private  org.devtools.util.debug.Debugger D
           
private  org.devtools.util.adt.DirectedGraph dependencies
          A graph where each node is a document URL and each edge from A to B represents the fact that if B becomes dirty, A should become dirty.
private  org.devtools.util.adt.IntegerFlyweight fly
           
private  java.util.Hashtable translating
          A hash of URLs who are currently being translated.
 
Fields inherited from class org.devtools.wiki.WikiTranslatorManager
LITERAL_START, LITERAL_START_ESCAPE, LITERAL_STOP, LITERAL_STOP_ESCAPE
 
Constructor Summary
CachingTranslatorManager()
          Constructs a new CachingTranslatorManager that is initially empty.
 
Method Summary
 void addDependency(java.lang.String childURL, java.lang.String parentURL)
          Creates a dependency between the given pages, used for determining how to refresh caching information.
 void dirtyPage(java.lang.String URL)
          Marks the given page as "dirty" for a caching scheme.
 void removeAllDependencies(java.lang.String URL)
          Removes all incoming and outgoing dependencies for the given page.
 void removeDependency(java.lang.String childURL, java.lang.String parentURL)
          Removes a dependency between the given pages, used for determining how to refresh caching information.
 java.lang.String translate(org.devtools.webtrans.WebContent content, java.util.Properties query)
          Translates the given content into HTML, or just returns a cached copy if it exists and is clean.
 
Methods inherited from class org.devtools.wiki.WikiTranslatorManager
addTranslator, getUsage, init, main, translateWithDetails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.devtools.webtrans.TranslatorManager
addTranslator, getUsage, init, translateWithDetails
 

Field Detail

fly

private org.devtools.util.adt.IntegerFlyweight fly

translating

private java.util.Hashtable translating
A hash of URLs who are currently being translated. If a page is dirtied while being translated, it is removed from this table to indicate that it should not be cached once the translation is complete.


cache

private java.util.Hashtable cache
A hash of URL string keys and HTML string values. Each value represents a cached translation of the document at URL. Pages with no cached translation will not be in here.


dependencies

private org.devtools.util.adt.DirectedGraph dependencies
A graph where each node is a document URL and each edge from A to B represents the fact that if B becomes dirty, A should become dirty.


D

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

CachingTranslatorManager

public CachingTranslatorManager()
Constructs a new CachingTranslatorManager 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

translate

public java.lang.String translate(org.devtools.webtrans.WebContent content,
                                  java.util.Properties query)
Translates the given content into HTML, or just returns a cached copy if it exists and is clean. FIXME: How do queries fit into this? Should I try to cache different versions of the page for different queries? What about query items that aren't used by the translators? Best to leave that up to the translator, I think.

Specified by:
translate in interface org.devtools.webtrans.TranslatorManager
Overrides:
translate in class WikiTranslatorManager

dirtyPage

public void dirtyPage(java.lang.String URL)
Marks the given page as "dirty" for a caching scheme. Once marked, this page should be considered in need of translation. Any dependents of this page are also marked.


addDependency

public void addDependency(java.lang.String childURL,
                          java.lang.String parentURL)
Creates a dependency between the given pages, used for determining how to refresh caching information. Once added, the page at childURL should be considered "dirty" whenever the page at parentURL has changed.


removeDependency

public void removeDependency(java.lang.String childURL,
                             java.lang.String parentURL)
Removes a dependency between the given pages, used for determining how to refresh caching information. Once removed, the page at childURL will not be considered "dirty" just because the page at parentURL has changed.


removeAllDependencies

public void removeAllDependencies(java.lang.String URL)
Removes all incoming and outgoing dependencies for the given page.