Package uk.ac.starlink.ttools.votlint
Class ElementHandler
java.lang.Object
uk.ac.starlink.ttools.votlint.ElementHandler
- Direct Known Subclasses:
DataHandler
,ParamHandler
,StreamHandler
,StreamingHandler
,TableHandler
,TdHandler
,TrHandler
Provides checking of a VOTable element during a SAX parse.
There is one ElementHandler for each element encountered by the SAX
parser; it is manipulated chiefly by the
VotLintContentHandler
which
calls various methods on it in a controlled sequence as its life
cycle progresses to handle the current state of the parse.
Element-specific subclasses should generally override only the
startElement()
, endElement()
and characters(char[], int, int)
methods, which are invoked by the ContentHandler's similarly named
methods.
The checking done by an ElementHandler does not attempt to repeat or replace that done by validating against a DTD, it provides additional semantic checks based on what it knows about VOTables.
- Since:
- 7 Apr 2005
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) Called when character content is found in the element.void
configure
(String localName, VotLintContext context) Sets this handler up ready for use.void
Called when the element has ended.void
error
(VotLintCode code, String msg) Writes an error message through the context.Returns an object containing the family relationships of this handler.getAttribute
(String name) Returns the value of a named attribute.Returns this handler's context.getName()
Returns the localName for this element.getRef()
Returns a reference for this element.void
info
(VotLintCode code, String msg) Writes an info message through the context.void
registerChildName
(ElementRef child, String name) Called to indicate that a child of this element has a "name" attribute.void
setAncestry
(Ancestry ancestry) Sets the ancestry of this handler.void
setAttributes
(Map<String, String> atts) Sets this handler's attributes.void
Called after the attributes have been set and checked.toString()
void
warning
(VotLintCode code, String msg) Writes a warning message through the context.
-
Constructor Details
-
ElementHandler
public ElementHandler()
-
-
Method Details
-
configure
Sets this handler up ready for use. Must be called before most of the other methods can be used.- Parameters:
localName
- local name of the element this handler knows aboutcontext
- lint context
-
setAncestry
Sets the ancestry of this handler.- Parameters:
ancestry
- family values
-
getAncestry
Returns an object containing the family relationships of this handler. This will only return a non-null value while the element is active (between its startElement and endElement calls). An ancestry object should not be used outside of this context.- Returns:
- ancestry
-
getRef
Returns a reference for this element.- Returns:
- reference
-
getName
Returns the localName for this element.- Returns:
- element name
-
setAttributes
Sets this handler's attributes.- Parameters:
atts
- name -> value map representing this element's attributes
-
getAttribute
Returns the value of a named attribute.- Parameters:
name
- attribute name- Returns:
- attribute value
-
startElement
public void startElement()Called after the attributes have been set and checked. The default implementation does nothing. -
endElement
public void endElement()Called when the element has ended. The default implementation does nothing. -
characters
public void characters(char[] ch, int start, int length) Called when character content is found in the element. The default implementation does nothing. -
registerChildName
Called to indicate that a child of this element has a "name" attribute.- Parameters:
child
- child elementname
- value of child's name attribute
-
getContext
Returns this handler's context.- Returns:
- context
-
info
Writes an info message through the context.- Parameters:
code
- message identifiermsg
- message text
-
warning
Writes a warning message through the context.- Parameters:
code
- message identifiermsg
- message text
-
error
Writes an error message through the context.- Parameters:
code
- message identifiermsg
- message text
-
toString
-