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
public class ElementHandler extends java.lang.Object
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 theVotLintContentHandler
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 thestartElement()
,endElement()
andcharacters(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 Constructor Description ElementHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] ch, int start, int length)
Called when character content is found in the element.void
configure(java.lang.String localName, VotLintContext context)
Sets this handler up ready for use.void
endElement()
Called when the element has ended.void
error(VotLintCode code, java.lang.String msg)
Writes an error message through the context.Ancestry
getAncestry()
Returns an object containing the family relationships of this handler.java.lang.String
getAttribute(java.lang.String name)
Returns the value of a named attribute.VotLintContext
getContext()
Returns this handler's context.java.lang.String
getName()
Returns the localName for this element.ElementRef
getRef()
Returns a reference for this element.void
info(VotLintCode code, java.lang.String msg)
Writes an info message through the context.void
registerChildName(ElementRef child, java.lang.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(java.util.Map<java.lang.String,java.lang.String> atts)
Sets this handler's attributes.void
startElement()
Called after the attributes have been set and checked.java.lang.String
toString()
void
warning(VotLintCode code, java.lang.String msg)
Writes a warning message through the context.
-
-
-
Method Detail
-
configure
public void configure(java.lang.String localName, VotLintContext context)
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
public void setAncestry(Ancestry ancestry)
Sets the ancestry of this handler.- Parameters:
ancestry
- family values
-
getAncestry
public Ancestry 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
public ElementRef getRef()
Returns a reference for this element.- Returns:
- reference
-
getName
public java.lang.String getName()
Returns the localName for this element.- Returns:
- element name
-
setAttributes
public void setAttributes(java.util.Map<java.lang.String,java.lang.String> atts)
Sets this handler's attributes.- Parameters:
atts
- name -> value map representing this element's attributes
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
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
public void registerChildName(ElementRef child, java.lang.String name)
Called to indicate that a child of this element has a "name" attribute.- Parameters:
child
- child elementname
- value of child's name attribute
-
getContext
public VotLintContext getContext()
Returns this handler's context.- Returns:
- context
-
info
public void info(VotLintCode code, java.lang.String msg)
Writes an info message through the context.- Parameters:
code
- message identifiermsg
- message text
-
warning
public void warning(VotLintCode code, java.lang.String msg)
Writes a warning message through the context.- Parameters:
code
- message identifiermsg
- message text
-
error
public void error(VotLintCode code, java.lang.String msg)
Writes an error message through the context.- Parameters:
code
- message identifiermsg
- message text
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-