Package uk.ac.starlink.ttools.votlint
Class ValueParser
- java.lang.Object
-
- uk.ac.starlink.ttools.votlint.ValueParser
-
public abstract class ValueParser extends java.lang.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
Constructors Constructor Description ValueParser()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
checkStream(java.io.InputStream in)
Checks the value of a table element which is encoded in a BINARY stream.abstract void
checkString(java.lang.String text)
Checks the value of a string which contains the value.void
error(java.lang.String msg)
Writes an error mesage to the user.abstract java.lang.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 classgetContentClass()
which correspond to values parsed by this parser.void
info(java.lang.String msg)
Writes an info mesage to the user.static ValueParser
makeParser(ElementHandler handler, java.lang.String datatype, java.lang.String arraysize)
Constructs a ValueParsers for a given element.void
setContext(VotLintContext context)
Sets this parser's context.static void
slurpStream(java.io.InputStream in, int nbyte, VotLintContext context)
Uncritically reads in a fixed number of bytes from a stream.void
warning(java.lang.String msg)
Writes a warning mesage to the user.
-
-
-
Method Detail
-
checkString
public abstract void checkString(java.lang.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(java.io.InputStream in) throws java.io.IOException
Checks the value of a table element which is encoded in a BINARY stream.- Parameters:
in
- input stream- Throws:
java.io.IOException
-
getContentClass
public abstract java.lang.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 thatValueInfo.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 classgetContentClass()
which correspond to values parsed by this parser. This should be the same as the product of shape elements returned byValueInfo.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(java.lang.String msg)
Writes an info mesage to the user.- Parameters:
msg
- message
-
warning
public void warning(java.lang.String msg)
Writes a warning mesage to the user.- Parameters:
msg
- message
-
error
public void error(java.lang.String msg)
Writes an error mesage to the user.- Parameters:
msg
- message
-
makeParser
public static ValueParser makeParser(ElementHandler handler, java.lang.String datatype, java.lang.String arraysize)
Constructs a ValueParsers for a given element.- Parameters:
handler
- element handlerdatatype
- datatype attribute valuearraysize
- arraysize attribute value- Returns:
- a suitable ValueParser, or null if one can't be constructed
-
slurpStream
public static void slurpStream(java.io.InputStream in, int nbyte, VotLintContext context) throws java.io.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 streamnbyte
- number of bytes to readcontext
- error reporting context- Throws:
java.io.IOException
-
-