uk.ac.starlink.ttools.lint
Class DoctypeInterpolator

java.lang.Object
  extended by uk.ac.starlink.ttools.lint.DoctypeInterpolator

public class DoctypeInterpolator
extends Object

Attempts to check that a DOCTYPE declaration is present in an input stream representing XML. If it is not, one is inserted. The algorithm used here isn't bulletproof, but should work in most sensible cases, and fail noisily if it can't do it. It copes with a number of not-too-weird XML encodings.

Author:
Mark Taylor (Starlink)

Constructor Summary
DoctypeInterpolator()
           
 
Method Summary
 InputStream getStreamWithDoctype(BufferedInputStream in)
          Returns an input stream which is a copy of a given one, except that if the given one doesn't include a DOCTYPE declaration, one is inserted.
 String getVotableVersion()
          Returns the value of the version attribute of the top-level VOTABLE element, if there was one and it was encountered.
static void main(String[] args)
          Filter program which takes a stream on standard output and writes to standard output including the DOCTYPE.
 void message(String msg)
          Presents a processing message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoctypeInterpolator

public DoctypeInterpolator()
Method Detail

getStreamWithDoctype

public InputStream getStreamWithDoctype(BufferedInputStream in)
                                 throws IOException
Returns an input stream which is a copy of a given one, except that if the given one doesn't include a DOCTYPE declaration, one is inserted. This method can only be called once for each instance of this class.

Parameters:
in - original input stream
Returns:
input stream like in but with a DOCTYPE
Throws:
IllegalStateException - if this method has already been called on this object
IOException

getVotableVersion

public String getVotableVersion()
Returns the value of the version attribute of the top-level VOTABLE element, if there was one and it was encountered.

Returns:
delcared VOTable version string, or null

message

public void message(String msg)
Presents a processing message.

Parameters:
msg - message text

main

public static void main(String[] args)
                 throws IOException
Filter program which takes a stream on standard output and writes to standard output including the DOCTYPE.

Throws:
IOException


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