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

public final Class SnugglePackage

extends Object
Class Inheritance
Imports
uk.ac.ed.ph.snuggletex.definitions.BuiltinCommand, .BuiltinEnvironment, .CombinerTargetMatcher, .CommandType, .CorePackageDefinitions, .Globals, .LaTeXMode, .MathCharacter, .MathCharacter.MathCharacterType, .TextFlowContext, uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler, .EnvironmentHandler, .InterpretableSimpleMathHandler, uk.ac.ed.ph.snuggletex.internal.util.ConstraintUtilities, .StringUtilities, uk.ac.ed.ph.snuggletex.semantics.Interpretation, .InterpretationType, .MathBigLimitOwnerInterpretation, .MathBracketInterpretation, .MathBracketInterpretation.BracketType, .MathFunctionInterpretation, .MathInterpretation, .MathNegatableInterpretation, java.io.BufferedReader, .InputStream, .InputStreamReader, java.util.ArrayList, .Collections, .EnumMap, .EnumSet, .List, .Map, .ResourceBundle, java.util.concurrent.ConcurrentHashMap

A SnugglePackage defines a collection of BuiltinCommands, BuiltinEnvironments, and ErrorCodes/ErrorGroups that can be registered with a SnuggleEngine to add in extra functionality.

The core SnuggleTeX distribution comes with what is essentially a built-in package defined in CorePackageDefinitions which provides its core functionality.

Notes

Author
David McKain
Since
1.2.0
Version
$Revision:179 $
See Also
BuiltinCommand, BuiltinEnvironment

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface

Field Summary

Modifier and TypeField and Description
private final ConcurrentHashMap<String, BuiltinCommand>
builtinCommandMap

Thread-safe Map of built-in commands, keyed on name

private final ConcurrentHashMap<String, BuiltinEnvironment>
builtinEnvironmentMap

Thread-safe Map of built-in environments, keyed on name

private final List<ErrorGroup>
errorGroupList

Thread-safe List of all ErrorGroups

private final ConcurrentHashMap<ErrorGroup, List<ErrorCode>>
errorGroupMap

Thread-safe Map of all ErrorGroups defined by this package

private ResourceBundle
errorMessageBundle

ResourceBundle providing details for formatting ErrorCodes

public static final InterpretableSimpleMathHandler
interpretableSimpleMathBuilder

Share instance of InterpretableSimpleMathHandler since it is stateless

private final ConcurrentHashMap<Integer, MathCharacter>
mathCharacterMap

Thread-safe Map of MathCharacters defined in this package, keyed on Unicode code point

private final String
name

Short name, used when formatting ErrorCodes

Constructor Summary

AccessConstructor and Description
public
SnugglePackage(final String name)

Method Summary

Modifier and TypeMethod and Description
public BuiltinCommand
addCombinerCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final CombinerTargetMatcher combinerTargetMatcher, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addCommand(final BuiltinCommand command)

public void
addCommandInterpretation(final String name, final Interpretation interpretation)

public BuiltinCommand
addComplexCommand(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode[] argumentModes, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addComplexCommandOneArg(final String name, final boolean allowOptionalArgument, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode argumentMode, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addComplexCommandOneArg(final String name, final boolean allowOptionalArgument, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode argumentMode, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addComplexCommandSameArgMode(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addComplexCommandSameArgMode(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)

public BuiltinEnvironment
addEnvironment(final String name, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation interpretation, final EnvironmentHandler handler, final TextFlowContext context)

public BuiltinEnvironment
addEnvironment(final String name, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation[] interpretations, final EnvironmentHandler handler, final TextFlowContext context)

public BuiltinEnvironment
addEnvironment(final String name, final boolean allowOptionalArgument, final int argumentCount, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation interpretation, final EnvironmentHandler handler, final TextFlowContext context)

public BuiltinEnvironment
addEnvironment(final String name, final boolean allowOptionalArgument, final int argumentCount, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation[] interpretations, final EnvironmentHandler handler, final TextFlowContext context)

public BuiltinEnvironment
public void
public void
addErrorCodes(ErrorCode... errorCodes)

public BuiltinCommand
public BuiltinCommand
addMathCharacterCommandAlias(final String name, final MathCharacter mathCharacter)

public BuiltinCommand
addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final Interpretation[] interpretations, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)

public BuiltinCommand
addSimpleMathCommand(final String name, final MathInterpretation... interpretations)

public BuiltinCommand
addSimpleMathCommand(final String name, final MathInterpretation interpretation, final CommandHandler handler)

public BuiltinCommand
addSimpleMathCommand(final String name, final MathInterpretation[] interpretations, final CommandHandler handler)

private MathCharacter
ensureBuiltinMathCharacterCommand(String texName, String errorMessageContext)

public BuiltinCommand
getBuiltinCommandByTeXName(String texName)

Returns the BuiltinCommand corresponding to LaTeX command called \texName defined by this package, or null if this command is not defined.

public Map<String, BuiltinCommand>
getBuiltinCommandMap()

Returns a read-only Map of all BuiltinCommands defined in this package, keyed on the name texName of the command (\texName).

public BuiltinEnvironment
getBuiltinEnvironmentByTeXName(String texName)

Returns the BuiltinEnvironment corresponding to LaTeX environment called texName defined by this package, or null if this environment is not defined.

public Map<String, BuiltinEnvironment>
getBuiltinEnvironmentMap()

Returns a read-only Map of all BuiltinEnvironments defined in this package, keyed on the name of the environment.

public List<ErrorCode>
getErrorCodes(ErrorGroup errorGroup)

Returns an unmodifiable view of the ErrorCodes corresponding to the given ErrorGroup.

public List<ErrorGroup>
getErrorGroups()

Returns an unmodifiable view of all of the ErrorGroups declared for this package.

public ResourceBundle
getErrorMessageBundle()

Returns the ResourceBundle used to format error messages.

public MathCharacter
getMathCharacter(int codePoint)

Returns the MathCharacter corresponding to the Unicode character at the given input codePoint, or null if no MathCharacter is defined for this codepoint.

public Map<Integer, MathCharacter>
getMathCharacterMap()

Returns a read-only Map of all MathCharacters defined in this package, keyed on input Unicode code point.

public String
getName()

Returns the name for this package.

public static boolean
isInputableTeXName(final String texName)

Tests whether the name of a command or environment is "inputable".

public void
loadMathCharacterAliases(final String resourceLocation)

public void
loadMathCharacterBigLimitTargets(final String resourceLocation)

public void
loadMathCharacterBrackets(final String resourceLocation)

public void
loadMathCharacterDefinitions(final String resourceLocation)

public void
loadMathCharacterNegations(final String resourceLocation)

public void
loadMathFunctionDefinitions(final String resourceLocation)

public static EnumMap<InterpretationType, Interpretation>
makeInterpretationMap(final Interpretation interpretation)

public static EnumMap<InterpretationType, Interpretation>
makeInterpretationMap(final Interpretation... interpretations)

private void
readResourceData(final String resourceLocation, final SnugglePackage.LineHandler handler)

public void
setErrorMessageBundle(ResourceBundle errorMessageBundle)

Sets the ResourceBundle used to format error messages.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

builtinCommandMapback to summary
private final ConcurrentHashMap<String, BuiltinCommand> builtinCommandMap

Thread-safe Map of built-in commands, keyed on name

builtinEnvironmentMapback to summary
private final ConcurrentHashMap<String, BuiltinEnvironment> builtinEnvironmentMap

Thread-safe Map of built-in environments, keyed on name

errorGroupListback to summary
private final List<ErrorGroup> errorGroupList

Thread-safe List of all ErrorGroups

errorGroupMapback to summary
private final ConcurrentHashMap<ErrorGroup, List<ErrorCode>> errorGroupMap

Thread-safe Map of all ErrorGroups defined by this package

errorMessageBundleback to summary
private ResourceBundle errorMessageBundle

ResourceBundle providing details for formatting ErrorCodes

interpretableSimpleMathBuilderback to summary
public static final InterpretableSimpleMathHandler interpretableSimpleMathBuilder

Share instance of InterpretableSimpleMathHandler since it is stateless

mathCharacterMapback to summary
private final ConcurrentHashMap<Integer, MathCharacter> mathCharacterMap

Thread-safe Map of MathCharacters defined in this package, keyed on Unicode code point

nameback to summary
private final String name

Short name, used when formatting ErrorCodes

Constructor Detail

SnugglePackageback to summary
public SnugglePackage(final String name)

Method Detail

addCombinerCommandback to summary
public BuiltinCommand addCombinerCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final CombinerTargetMatcher combinerTargetMatcher, final CommandHandler handler, final TextFlowContext context)
addCommandback to summary
public BuiltinCommand addCommand(final BuiltinCommand command)
addCommandInterpretationback to summary
public void addCommandInterpretation(final String name, final Interpretation interpretation)
addComplexCommandback to summary
public BuiltinCommand addComplexCommand(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode[] argumentModes, final CommandHandler handler, final TextFlowContext context)
addComplexCommandOneArgback to summary
public BuiltinCommand addComplexCommandOneArg(final String name, final boolean allowOptionalArgument, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode argumentMode, final CommandHandler handler, final TextFlowContext context)
addComplexCommandOneArgback to summary
public BuiltinCommand addComplexCommandOneArg(final String name, final boolean allowOptionalArgument, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode argumentMode, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)
addComplexCommandSameArgModeback to summary
public BuiltinCommand addComplexCommandSameArgMode(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final CommandHandler handler, final TextFlowContext context)
addComplexCommandSameArgModeback to summary
public BuiltinCommand addComplexCommandSameArgMode(final String name, final boolean allowOptionalArgument, final int arguments, final EnumSet<LaTeXMode> allowedModes, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)
addEnvironmentback to summary
public BuiltinEnvironment addEnvironment(final String name, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation interpretation, final EnvironmentHandler handler, final TextFlowContext context)
addEnvironmentback to summary
public BuiltinEnvironment addEnvironment(final String name, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation[] interpretations, final EnvironmentHandler handler, final TextFlowContext context)
addEnvironmentback to summary
public BuiltinEnvironment addEnvironment(final String name, final boolean allowOptionalArgument, final int argumentCount, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation interpretation, final EnvironmentHandler handler, final TextFlowContext context)
addEnvironmentback to summary
public BuiltinEnvironment addEnvironment(final String name, final boolean allowOptionalArgument, final int argumentCount, final EnumSet<LaTeXMode> allowedModes, final LaTeXMode contentMode, final Interpretation[] interpretations, final EnvironmentHandler handler, final TextFlowContext context)
addEnvironmentback to summary
public BuiltinEnvironment addEnvironment(final BuiltinEnvironment environment)
addErrorCodeback to summary
public void addErrorCode(ErrorCode errorCode)
addErrorCodesback to summary
public void addErrorCodes(ErrorCode... errorCodes)
addMathCharacterCommandback to summary
public BuiltinCommand addMathCharacterCommand(final MathCharacter mathCharacter)
addMathCharacterCommandAliasback to summary
public BuiltinCommand addMathCharacterCommandAlias(final String name, final MathCharacter mathCharacter)
addSimpleCommandback to summary
public BuiltinCommand addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final CommandHandler handler, final TextFlowContext context)
addSimpleCommandback to summary
public BuiltinCommand addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final Interpretation[] interpretations, final CommandHandler handler, final TextFlowContext context)
addSimpleCommandback to summary
public BuiltinCommand addSimpleCommand(final String name, final EnumSet<LaTeXMode> allowedModes, final Interpretation interpretation, final CommandHandler handler, final TextFlowContext context)
addSimpleMathCommandback to summary
public BuiltinCommand addSimpleMathCommand(final String name, final MathInterpretation... interpretations)
addSimpleMathCommandback to summary
public BuiltinCommand addSimpleMathCommand(final String name, final MathInterpretation interpretation, final CommandHandler handler)
addSimpleMathCommandback to summary
public BuiltinCommand addSimpleMathCommand(final String name, final MathInterpretation[] interpretations, final CommandHandler handler)
ensureBuiltinMathCharacterCommandback to summary
private MathCharacter ensureBuiltinMathCharacterCommand(String texName, String errorMessageContext)
getBuiltinCommandByTeXNameback to summary
public BuiltinCommand getBuiltinCommandByTeXName(String texName)

Returns the BuiltinCommand corresponding to LaTeX command called \texName defined by this package, or null if this command is not defined.

getBuiltinCommandMapback to summary
public Map<String, BuiltinCommand> getBuiltinCommandMap()

Returns a read-only Map of all BuiltinCommands defined in this package, keyed on the name texName of the command (\texName).

getBuiltinEnvironmentByTeXNameback to summary
public BuiltinEnvironment getBuiltinEnvironmentByTeXName(String texName)

Returns the BuiltinEnvironment corresponding to LaTeX environment called texName defined by this package, or null if this environment is not defined.

getBuiltinEnvironmentMapback to summary
public Map<String, BuiltinEnvironment> getBuiltinEnvironmentMap()

Returns a read-only Map of all BuiltinEnvironments defined in this package, keyed on the name of the environment.

getErrorCodesback to summary
public List<ErrorCode> getErrorCodes(ErrorGroup errorGroup)

Returns an unmodifiable view of the ErrorCodes corresponding to the given ErrorGroup.

getErrorGroupsback to summary
public List<ErrorGroup> getErrorGroups()

Returns an unmodifiable view of all of the ErrorGroups declared for this package.

getErrorMessageBundleback to summary
public ResourceBundle getErrorMessageBundle()

Returns the ResourceBundle used to format error messages.

getMathCharacterback to summary
public MathCharacter getMathCharacter(int codePoint)

Returns the MathCharacter corresponding to the Unicode character at the given input codePoint, or null if no MathCharacter is defined for this codepoint.

getMathCharacterMapback to summary
public Map<Integer, MathCharacter> getMathCharacterMap()

Returns a read-only Map of all MathCharacters defined in this package, keyed on input Unicode code point.

getNameback to summary
public String getName()

Returns the name for this package.

isInputableTeXNameback to summary
public static boolean isInputableTeXName(final String texName)

Tests whether the name of a command or environment is "inputable". Ones which cannot be directly input are enclosed in angle brackets. These commands are created during token fixing.

loadMathCharacterAliasesback to summary
public void loadMathCharacterAliases(final String resourceLocation)
loadMathCharacterBigLimitTargetsback to summary
public void loadMathCharacterBigLimitTargets(final String resourceLocation)
loadMathCharacterBracketsback to summary
public void loadMathCharacterBrackets(final String resourceLocation)
loadMathCharacterDefinitionsback to summary
public void loadMathCharacterDefinitions(final String resourceLocation)
loadMathCharacterNegationsback to summary
public void loadMathCharacterNegations(final String resourceLocation)
loadMathFunctionDefinitionsback to summary
public void loadMathFunctionDefinitions(final String resourceLocation)
makeInterpretationMapback to summary
public static EnumMap<InterpretationType, Interpretation> makeInterpretationMap(final Interpretation interpretation)
makeInterpretationMapback to summary
public static EnumMap<InterpretationType, Interpretation> makeInterpretationMap(final Interpretation... interpretations)
readResourceDataback to summary
private void readResourceData(final String resourceLocation, final SnugglePackage.LineHandler handler)
setErrorMessageBundleback to summary
public void setErrorMessageBundle(ResourceBundle errorMessageBundle)

Sets the ResourceBundle used to format error messages.

uk.ac.ed.ph.snuggletex back to summary

private Interface SnugglePackage.LineHandler


Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

handleLineback to summary
public void handleLine(String line)