java.lang.Object
org.devtools.wiki.translators.OnsiteLinkTranslator
- All Implemented Interfaces:
- org.devtools.webtrans.Translator
- public class OnsiteLinkTranslator
- extends java.lang.Object
- implements org.devtools.webtrans.Translator
Picks up all of the mixed-case words in the page as on-site links.
If the mixed-case word is not a page of the current type, searches
other types. If it is not a page of any type, inserts an editme
(?) after the name. Only considers pages that have a type in the
list OnsiteLinkTypes.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
srv
private org.devtools.webtrans.TranslatorServices srv
- The services for this doc type
D
private org.devtools.util.debug.Debugger D
OnsiteLinkTranslator
public OnsiteLinkTranslator()
- Constructs a new onsite link detector. We'll need access to
the Persister in order to find out if pages exist.
init
public void init(org.devtools.webtrans.TranslatorServices srv)
- A constructor-like initialization method. The
TranslatorManager will call this method exactly once, before
any calls to translate(). The Translator may choose to do
nothing during this method, or it may choose to save the
reference to the provided TranslatorServices, which provide
getters for commonly needed information such as the site's
Persister, its base URL, the location of Special Pages such as
the front page, search page, edit page, putter page,
etc.
This method replaces a parametric constructor, so that
Translators can be created using the getInstance() method on
class Class, which requires a no-arg constructor.
- Specified by:
init in interface org.devtools.webtrans.Translator
translate
public void translate(org.devtools.webtrans.StringChanges c,
org.devtools.webtrans.WebContent content,
org.devtools.webtrans.TranslatorLog log,
java.util.Properties query)
- Translates the given document in some way, returning the
changes that should be made to the document to complete the
translation. This method should not throw exceptions even if
it is handed a document that it cannot deal with; translators
should instead quietly fail (for similar reasons to why web
browsers are so error-tolerant.)
If, however, the translator needs to give feedback to the
caller, it can do so by adding a message into the
TranslatorLog. In most implementations, I would expect these
strings to be human-readable, so that they could be presented
to an end-user to help them revise their document.
Take a look at the TranslatorLog interface for a list of the
information that a Translator is expected to furnish.
- Specified by:
translate in interface org.devtools.webtrans.Translator
getName
public java.lang.String getName()
- Returns the name of the translator. This should be something
descriptive and human-readable that uniquely indicates what the
translator does. This name will be included in error logging
if this translator has a conflict with another one, throws an
exception, etc.
- Specified by:
getName in interface org.devtools.webtrans.Translator
getUsage
public java.lang.String getUsage()
- Returns some HTML representing a description of what text this
translator processes. This will be shown to the user so that
they can determine how to write their documents. (If this
translator has no usage or if you wish it to be invisible to
the user, return null. This Translator will not be included in
the usage list.)
- Specified by:
getUsage in interface org.devtools.webtrans.Translator