uk.ac.starlink.ttools.lint
Class LintContext

java.lang.Object
  extended by uk.ac.starlink.ttools.lint.LintContext

public class LintContext
extends Object

Context for a VOTLint process. This is the object which knows most of the available global information about the parse. It also provides facilities for reporting log information about the parse to the user.

Author:
Mark Taylor (Starlink)

Field Summary
static int MAX_REPEAT
          Maximum number of identical error messages which will be logged.
static String V10
          VOTABLE element version attribute value representing version 1.0.
static String V11
          VOTABLE element version attribute value representing version 1.1.
static String[] VOT_VERSIONS
          VOTable element version values representing known versions.
 
Constructor Summary
LintContext()
          Constructor for unknown VOTable version.
LintContext(String version)
          Constructs a LintContext to parse documents with a given VOTable version.
 
Method Summary
 ElementHandler createHandler(String localName)
          Constructs a new ElementHandler for a given local element name.
 void error(String msg)
          Write an error message to the user.
 Map getAttributeCheckers(String localName)
          Returns a map of attribute checkers suitable for processing elements of a given name.
 Locator getLocator()
          Returns the SAX document locator for this parse.
 Map getNamespaceMap()
          Returns prefix->namespaceURI map for the xmlns namespaces currently in scope.
 PrintStream getOutput()
          Returns the output stream to which messages will be written.
 String getVersion()
          Returns the version of VOTable this context is parsing.
 void info(String msg)
          Write an informative message to the user.
 boolean isDebug()
          Returns whether we are in debug mode.
 boolean isValidating()
          Indicates whether this lint is validating.
 void message(String type, String msg, Throwable e)
          Dispatches a message to the user.
 void registerID(String id, ElementHandler handler)
          Register the fact that an XML ID-type attribute has been seen on an element.
 void registerRef(String id, ElementRef from, RefChecker checker)
          Register the fact that an XML IDREF-type attribute has been seen on an element.
 void reportUncheckedRefs()
          Goes through all the unresolved IDREF->ID arcs and reports them.
 void setDebug(boolean debug)
          Sets whether we are in debug mode.
 void setLocator(Locator locator)
          Sets the SAX document locator for this parse.
 void setOutput(PrintStream out)
          Sets the output stream to which messages will be written.
 void setValidating(boolean validate)
          Sets whether this lint is validating.
 void setVersion(String version)
          Sets the version we are parsing to a given value.
 void warning(String msg)
          Write a warning message to the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

V10

public static final String V10
VOTABLE element version attribute value representing version 1.0.

See Also:
Constant Field Values

V11

public static final String V11
VOTABLE element version attribute value representing version 1.1.

See Also:
Constant Field Values

VOT_VERSIONS

public static final String[] VOT_VERSIONS
VOTable element version values representing known versions.


MAX_REPEAT

public static final int MAX_REPEAT
Maximum number of identical error messages which will be logged.

See Also:
Constant Field Values
Constructor Detail

LintContext

public LintContext()
Constructor for unknown VOTable version.


LintContext

public LintContext(String version)
Constructs a LintContext to parse documents with a given VOTable version.

Parameters:
version - version string (currently "1.0" or "1.1")
Method Detail

getVersion

public String getVersion()
Returns the version of VOTable this context is parsing. It may be null if we don't yet know.

Returns:
version string

setVersion

public void setVersion(String version)
Sets the version we are parsing to a given value.

Parameters:
version - version string (currently "1.0" or "1.1")

setValidating

public void setValidating(boolean validate)
Sets whether this lint is validating.

Parameters:
validate - true for validating lint

isValidating

public boolean isValidating()
Indicates whether this lint is validating.

Returns:
true for validating lint

setLocator

public void setLocator(Locator locator)
Sets the SAX document locator for this parse.

Parameters:
locator - locator

getLocator

public Locator getLocator()
Returns the SAX document locator for this parse.

Returns:
locator

setDebug

public void setDebug(boolean debug)
Sets whether we are in debug mode. In debug mode a stack trace is output with each log message.

Parameters:
debug - true iff you want debugging output

isDebug

public boolean isDebug()
Returns whether we are in debug mode.

Returns:
true if debugging output is on

getOutput

public PrintStream getOutput()
Returns the output stream to which messages will be written.

Returns:
output stream

setOutput

public void setOutput(PrintStream out)
Sets the output stream to which messages will be written.

Parameters:
out - output stream

createHandler

public ElementHandler createHandler(String localName)
Constructs a new ElementHandler for a given local element name.

Parameters:
localName - element name
Returns:
handler to process an element of type name

getAttributeCheckers

public Map getAttributeCheckers(String localName)
Returns a map of attribute checkers suitable for processing elements of a given name.

Parameters:
localName - element name
Returns:
String->AttributeChecker map for checking attributes

getNamespaceMap

public Map getNamespaceMap()
Returns prefix->namespaceURI map for the xmlns namespaces currently in scope.


registerID

public void registerID(String id,
                       ElementHandler handler)
Register the fact that an XML ID-type attribute has been seen on an element.

Parameters:
id - ID value
handler - element labelled id

registerRef

public void registerRef(String id,
                        ElementRef from,
                        RefChecker checker)
Register the fact that an XML IDREF-type attribute has been seen on an element.

Parameters:
id - ID value
from - the element on which the ref has been seen
checker - the checker which knows how to check links of this type

reportUncheckedRefs

public void reportUncheckedRefs()
Goes through all the unresolved IDREF->ID arcs and reports them. This is done at the end of the parse.


info

public void info(String msg)
Write an informative message to the user.

Parameters:
msg - message

warning

public void warning(String msg)
Write a warning message to the user.

Parameters:
msg - message

error

public void error(String msg)
Write an error message to the user.

Parameters:
msg - message

message

public void message(String type,
                    String msg,
                    Throwable e)
Dispatches a message to the user. Context information, such as position in the parse and message severity, are output as well as the text itself. Additionally an effort is made not to write the same message millions of times. Either the msg or the e arguments, but not both, may be null.

Parameters:
type - indication of message severity
msg - specific message content
e - throwable associated with this message


Copyright © 2009 Central Laboratory of the Research Councils. All Rights Reserved.