uk.ac.starlink.ttools.votlint
Class ElementHandler

java.lang.Object
  extended by uk.ac.starlink.ttools.votlint.ElementHandler
Direct Known Subclasses:
DataHandler, ParamHandler, StreamHandler, StreamingHandler, TableHandler, TdHandler, TrHandler

public class ElementHandler
extends 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 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
ElementHandler()
           
 
Method Summary
 void 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 endElement()
          Called when the element has ended.
 void error(String msg)
          Writes an error message through the context.
 Ancestry getAncestry()
          Returns an object containing the family relationships of this handler.
 String getAttribute(String name)
          Returns the value of a named attribute.
 VotLintContext getContext()
          Returns this handler's context.
 String getName()
          Returns the localName for this element.
 ElementRef getRef()
          Returns a reference for this element.
 void info(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 atts)
          Sets this handler's attributes.
 void startElement()
          Called after the attributes have been set and checked.
 String toString()
           
 void warning(String msg)
          Writes a warning message through the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ElementHandler

public ElementHandler()
Method Detail

configure

public void configure(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 about
context - 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 String getName()
Returns the localName for this element.

Returns:
element name

setAttributes

public void setAttributes(Map atts)
Sets this handler's attributes.

Parameters:
atts - name -> value map representing this element's attributes

getAttribute

public String getAttribute(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,
                              String name)
Called to indicate that a child of this element has a "name" attribute.

Parameters:
child - child element
name - value of child's name attribute

getContext

public VotLintContext getContext()
Returns this handler's context.

Returns:
context

info

public void info(String msg)
Writes an info message through the context.

Parameters:
msg - message

warning

public void warning(String msg)
Writes a warning message through the context.

Parameters:
msg - message

error

public void error(String msg)
Writes an error message through the context.

Parameters:
msg - message

toString

public String toString()
Overrides:
toString in class Object


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