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

public final Class MessageFormatter

extends Object
Class Inheritance
Imports
uk.ac.ed.ph.snuggletex.DOMOutputOptions, .ErrorCode, .ErrorGroup, .InputError, .SnuggleConstants, .SnuggleLogicException, .SnuggleRuntimeException, uk.ac.ed.ph.snuggletex.definitions.CorePackageDefinitions, .Globals, .W3CConstants, uk.ac.ed.ph.snuggletex.internal.FrozenSlice, .SnuggleInputReader, .WorkingDocument, .WorkingDocument.CharacterSource, .WorkingDocument.IndexResolution, .WorkingDocument.Slice, .WorkingDocument.SourceContext, uk.ac.ed.ph.snuggletex.internal.util.ObjectUtilities, java.text.MessageFormat, java.util.Arrays, .MissingResourceException, .PropertyResourceBundle, .ResourceBundle, org.w3c.dom.DOMException, .Document, .Element

Utility class that formats an InputError in various ways.

Note

We're using MessageFormat extensively here, which hasn't been updated to use StringBuilder so we'll sadly have to make do with StringBuffer

Author
David McKain
Version
$Revision$

Field Summary

Modifier and TypeField and Description
public static final PropertyResourceBundle
GENERAL_MESSAGE_BUNDLE

ResourceBundle providing templates for message bodies

private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
private static void
appendFrame(StringBuffer messageBuilder, WorkingDocument.CharacterSource source, int offsetInSource)

private static void
public static void
public static String
formatErrorAsString(InputError error)

Creates a full diagnosis of the given error

public static Element
formatErrorAsXHTML(Document ownerDocument, InputError error)

public static Element
formatErrorAsXML(Document
Document that will contain the resulting element.
ownerDocument
,
InputError
InputError to format
error
,
boolean
false if you just want the error code, true for full details.
fullDetails
)

Creates a DOM Element containing information about the given error, including either just the ErrorCode or full details.

public static Element
formatErrorAsXML(Document
Document that will contain the resulting element.
ownerDocument
,
DOMOutputOptions options, InputError
InputError to format
error
,
boolean
false if you just want the error code, true for full details.
fullDetails
)

Creates a DOM Element containing information about the given error, including either just the ErrorCode or full details.

public static String
public static String
private static String
formatText(CharSequence content)

Trivial helper to truncate a portion of text if it goes longer than TRUNCATE_LENGTH.

public static String
getErrorMessage(InputError error)

Constructs an error message for the given InputError.

public static String
getErrorMessage(ErrorCode errorCode, Object... arguments)

Constructs an error message for the given ErrorCode and arguments.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GENERAL_MESSAGE_BUNDLEback to summary
public static final PropertyResourceBundle GENERAL_MESSAGE_BUNDLE

ResourceBundle providing templates for message bodies

TRUNCATE_LENGTHback to summary
private static final int TRUNCATE_LENGTH

Constructor Detail

MessageFormatterback to summary
public MessageFormatter()

Method Detail

appendErrorAsStringback to summary
public static void appendErrorAsString(StringBuffer messageBuilder, InputError error)
appendFrameback to summary
private static void appendFrame(StringBuffer messageBuilder, WorkingDocument.CharacterSource source, int offsetInSource)
appendNewlineIfRequiredback to summary
private static void appendNewlineIfRequired(StringBuffer messageBuilder)
appendSliceContextback to summary
public static void appendSliceContext(StringBuffer messageBuilder, FrozenSlice slice)
formatErrorAsStringback to summary
public static String formatErrorAsString(InputError error)

Creates a full diagnosis of the given error

formatErrorAsXHTMLback to summary
public static Element formatErrorAsXHTML(Document ownerDocument, InputError error)
formatErrorAsXMLback to summary
public static Element formatErrorAsXML(Document ownerDocument, InputError error, boolean fullDetails)

Creates a DOM Element containing information about the given error, including either just the ErrorCode or full details.

The error Element will have qualified name error and belong to the SnuggleConstants#SNUGGLETEX_NAMESPACE namespace.

Parameters
ownerDocument:Document

Document that will contain the resulting element.

error:InputError

InputError to format

fullDetails:boolean

false if you just want the error code, true for full details.

formatErrorAsXMLback to summary
public static Element formatErrorAsXML(Document ownerDocument, DOMOutputOptions options, InputError error, boolean fullDetails)

Creates a DOM Element containing information about the given error, including either just the ErrorCode or full details.

The error Element will have the given qualified name and namespace as determined by the DOMOutputOptions passed.

Parameters
ownerDocument:Document

Document that will contain the resulting element.

error:InputError

InputError to format

fullDetails:boolean

false if you just want the error code, true for full details.

formatErrorCodeNameback to summary
public static String formatErrorCodeName(ErrorCode errorCode)
formatErrorGroupback to summary
public static String formatErrorGroup(ErrorGroup errorGroup)
formatTextback to summary
private static String formatText(CharSequence content)

Trivial helper to truncate a portion of text if it goes longer than TRUNCATE_LENGTH. This also replaces all whitespace with a spaces so as to avoid the results spanning multiple lines.

getErrorMessageback to summary
public static String getErrorMessage(InputError error)

Constructs an error message for the given InputError.

getErrorMessageback to summary
public static String getErrorMessage(ErrorCode errorCode, Object... arguments)

Constructs an error message for the given ErrorCode and arguments.