uk.ac.starlink.ttools.votlint
Class ValueParser

java.lang.Object
  extended by uk.ac.starlink.ttools.votlint.ValueParser

public abstract class ValueParser
extends Object

Object which knows how to interpret the values associated with a FIELD or PARAM object. This interpretation takes the form only of checking whether it is encoded legally, writing some message to the context if it is not, and throwing away the result (if it was ever calculated in the first place).

Since:
7 Apr 2005
Author:
Mark Taylor (Starlink)

Constructor Summary
ValueParser()
           
 
Method Summary
abstract  void checkStream(InputStream in)
          Checks the value of a table element which is encoded in a BINARY stream.
abstract  void checkString(String text)
          Checks the value of a string which contains the value.
 void error(String msg)
          Writes an error mesage to the user.
abstract  Class getContentClass()
          Returns the class of values which would be used in Java to represent an object parsed by this parser, although this class does not actually return such values.
 VotLintContext getContext()
          Returns this parser's context.
abstract  int getElementCount()
          Returns the number of items of class getContentClass() which correspond to values parsed by this parser.
 void info(String msg)
          Writes an info mesage to the user.
static ValueParser makeParser(ElementHandler handler, String datatype, String arraysize)
          Constructs a ValueParsers for a given element.
 void setContext(VotLintContext context)
          Sets this parser's context.
static void slurpStream(InputStream in, int nbyte, VotLintContext context)
          Uncritically reads in a fixed number of bytes from a stream.
 void warning(String msg)
          Writes a warning mesage to the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueParser

public ValueParser()
Method Detail

checkString

public abstract void checkString(String text)
Checks the value of a string which contains the value. This is presumably either the content of the value attribute of a PARAM element or the contents of a TD element.

Parameters:
text - value string

checkStream

public abstract void checkStream(InputStream in)
                          throws IOException
Checks the value of a table element which is encoded in a BINARY stream.

Parameters:
in - input stream
Throws:
IOException

getContentClass

public abstract Class getContentClass()
Returns the class of values which would be used in Java to represent an object parsed by this parser, although this class does not actually return such values. This should be the same class that ValueInfo.getContentClass() would return for this object if a StarTable was being built.

Returns:
value class

getElementCount

public abstract int getElementCount()
Returns the number of items of class getContentClass() which correspond to values parsed by this parser. This should be the same as the product of shape elements returned by ValueInfo.getShape(). If the number is indeterminate, -1 should be returned.

Returns:
number of elements per value

setContext

public void setContext(VotLintContext context)
Sets this parser's context. This method should be called shortly after construction.

Parameters:
context - lint context

getContext

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

Returns:
lint context

info

public void info(String msg)
Writes an info mesage to the user.

Parameters:
msg - message

warning

public void warning(String msg)
Writes a warning mesage to the user.

Parameters:
msg - message

error

public void error(String msg)
Writes an error mesage to the user.

Parameters:
msg - message

makeParser

public static ValueParser makeParser(ElementHandler handler,
                                     String datatype,
                                     String arraysize)
Constructs a ValueParsers for a given element.

Parameters:
handler - element handler
datatype - datatype attribute value
arraysize - arraysize attribute value
Returns:
a suitable ValueParser, or null if one can't be constructed

slurpStream

public static void slurpStream(InputStream in,
                               int nbyte,
                               VotLintContext context)
                        throws IOException
Uncritically reads in a fixed number of bytes from a stream. An error is reported if the stream ends mid-read.

Parameters:
in - input stream
nbyte - number of bytes to read
context - error reporting context
Throws:
IOException


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