Top Description Fields Constructors Methods
uk.ac.ed.ph.snuggletex.dombuilding

public final Class AccentHandler

extends Object
implements CommandHandler
Class Inheritance
All Implemented Interfaces
uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler
Imports
uk.ac.ed.ph.snuggletex.SnuggleLogicException, uk.ac.ed.ph.snuggletex.definitions.AccentMap, .CoreErrorCode, .MathCharacter, uk.ac.ed.ph.snuggletex.internal.DOMBuilder, .SnuggleParseException, uk.ac.ed.ph.snuggletex.semantics.InterpretationType, uk.ac.ed.ph.snuggletex.tokens.CommandToken, .FlowToken, .TokenType, java.util.List, org.w3c.dom.DOMException, .Element

This builder handles applying accents to characters. It has been written to work in both math and text modes - do note that some accents only apply in one of these modes.
Author
David McKain
Version
$Revision$

Field Summary

Modifier and TypeField and Description
private final AccentMap
accentMap

AccentMap to use to look up single characters (may be null)

private final char
combiningCharacter

Combining character to use when forming MathML accents (0 if this builder doesn't support MATH mode)

private final String
mathMLElementName

Name of resulting MathML element (must not be null)

Constructor Summary

AccessConstructor and Description
public
AccentHandler(final AccentMap accentMap, final char combiningCharacter, final String mathMLElementName)

public

Method Summary

Modifier and TypeMethod and Description
public void
handleCommand(DOMBuilder builder, Element parentElement, CommandToken token)

Implements uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler.handleCommand.

Called when a CommandToken is being handled by the DOMBuilder.

public void
handleCommandMathMode(DOMBuilder builder, Element parentElement, CommandToken token)

Handles accents in MATH mode.

public void
handleCommandTextMode(DOMBuilder builder, Element parentElement, CommandToken token)

LaTeX only adds an accent to the first character of the first token, and only if it is text.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accentMapback to summary
private final AccentMap accentMap

AccentMap to use to look up single characters (may be null)

combiningCharacterback to summary
private final char combiningCharacter

Combining character to use when forming MathML accents (0 if this builder doesn't support MATH mode)

mathMLElementNameback to summary
private final String mathMLElementName

Name of resulting MathML element (must not be null)

Constructor Detail

AccentHandlerback to summary
public AccentHandler(final AccentMap accentMap, final char combiningCharacter, final String mathMLElementName)
AccentHandlerback to summary
public AccentHandler(AccentMap accentMap)

Method Detail

handleCommandback to summary
public void handleCommand(DOMBuilder builder, Element parentElement, CommandToken token) throws SnuggleParseException

Implements uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler.handleCommand.

Doc from uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler.handleCommand.

Called when a CommandToken is being handled by the DOMBuilder.

Exceptions
SnuggleParseException:
to indicate a client error
handleCommandMathModeback to summary
public void handleCommandMathMode(DOMBuilder builder, Element parentElement, CommandToken token) throws SnuggleParseException

Handles accents in MATH mode.

handleCommandTextModeback to summary
public void handleCommandTextMode(DOMBuilder builder, Element parentElement, CommandToken token) throws SnuggleParseException

LaTeX only adds an accent to the first character of the first token, and only if it is text. If not, it outputs a lone accent character before the first token.

For simplicity, we will only allow a single simple text token as the argument of this command since anything else is really a nasty hack and does nothing for the output in LaTeX.