Class SavotStaxParser

  • All Implemented Interfaces:
    Markups

    public final class SavotStaxParser
    extends java.lang.Object
    implements Markups

    It has been tested with Java 1.6 Stax implementation but it is possible to use other Stax implementations

    Designed to use with JSR-173 compliant (Streaming API for XML)

    remark L. Bourgès : equalsIgnoreCase() vs() equals as XML is case sensitive and VOTable specification says that clearly

    Author:
    Andre Schaaff
    • Field Detail

      • FULL

        public static final int FULL
        FULL parsing mode: deprecated and replaced by FULLREAD
        See Also:
        Constant Field Values
      • FULLREAD

        public static final int FULLREAD
        FULLREAD parsing mode: all in memory
        See Also:
        Constant Field Values
      • SEQUENTIAL

        public static final int SEQUENTIAL
        SEQUENTIAL parsing mode: deprecated and replaced by RESOURCEREAD
        See Also:
        Constant Field Values
      • RESOURCEREAD

        public static final int RESOURCEREAD
        RESOURCEREAD parsing mode: resource per resource reading
        See Also:
        Constant Field Values
      • ROWREAD

        public static final int ROWREAD
        ROWREAD parsing mode: row per row reading
        See Also:
        Constant Field Values
      • DEFAULT_STACK_CAPACITY

        public static final int DEFAULT_STACK_CAPACITY
        default stack capacity = 4 slots
        See Also:
        Constant Field Values
    • Constructor Detail

      • SavotStaxParser

        public SavotStaxParser​(java.lang.String file,
                               int mode)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        file - a file to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.lang.String file,
                               int mode,
                               boolean debug)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        file - a file to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.lang.String file,
                               int mode,
                               boolean debug,
                               SavotStatistics stats)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        file - a file to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        stats -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.net.URL url,
                               int mode)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        url - url to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.net.URL url,
                               int mode,
                               boolean debug)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        url - url to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.net.URL url,
                               int mode,
                               boolean debug,
                               SavotStatistics stats)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        url - url to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        stats -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.InputStream instream,
                               int mode)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        instream - stream to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.InputStream instream,
                               int mode,
                               boolean debug)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        instream - stream to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.InputStream instream,
                               int mode,
                               boolean debug,
                               SavotStatistics stats)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        instream - stream to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        stats -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.Reader reader,
                               int mode)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        reader - reader to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.Reader reader,
                               int mode,
                               boolean debug)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        reader - reader to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • SavotStaxParser

        public SavotStaxParser​(java.io.Reader reader,
                               int mode,
                               boolean debug,
                               SavotStatistics stats)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Constructor
        Parameters:
        reader - reader to parse
        mode - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        debug -
        stats -
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
    • Method Detail

      • close

        public void close()
        Close the input stream if still opened and free the internal parser
      • reset

        public void reset()
        Reset of the engine before another parsing LBO: useless methods ?
      • parse

        public void parse​(int parsingType)
                   throws java.io.IOException,
                          javax.xml.stream.XMLStreamException
        Parsing engine
        Parameters:
        parsingType - FULLREAD (all in memory), RESOURCEREAD (per RESOURCE) or ROWREAD (per ROW, for small memory size applications)
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • getNextResource

        public SavotResource getNextResource()
        Get the next Resource (warning : RESOURCEREAD mode only)
        Returns:
        a SavotResource (always NULL if other mode)
      • getNextTR

        public SavotTR getNextTR()
        Get the next TR (warning : ROWREAD mode only)
        Returns:
        a SavotTR (always NULL if other mode)
      • getVOTable

        public SavotVOTable getVOTable()
        Get a reference to V0TABLE object
        Returns:
        SavotVOTable
      • getResourceCount

        public int getResourceCount()
        Get the number of RESOURCE elements in the document (for statistics)
        Returns:
        a long value
      • getTableCount

        public int getTableCount()
        Get the number of TABLE elements in the document (for statistics)
        Returns:
        a long value
      • getTRCount

        public int getTRCount()
        Get the number of TR elements in the document (for statistics)
        Returns:
        a long value
      • getDataCount

        public int getDataCount()
        Get the number of DATA elements in the document (for statistics)
        Returns:
        a long value
      • getIdRefLinks

        public java.util.Map<java.lang.String,​java.lang.Object> getIdRefLinks()
        Get a reference on the Hashtable containing the link between ID and ref
        Returns:
        a refernce to the Hashtable
      • getResourceFromRef

        public SavotResource getResourceFromRef​(java.lang.String ref)
        Search a RESOURCE corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        a reference to a SavotResource object
      • getFieldFromRef

        public SavotField getFieldFromRef​(java.lang.String ref)
        Search a FIELD corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotField
      • getFieldRefFromRef

        public SavotFieldRef getFieldRefFromRef​(java.lang.String ref)
        Search a FIELDref corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotFieldRef
      • getParamFromRef

        public SavotParam getParamFromRef​(java.lang.String ref)
        Search a PARAM corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotParam
      • getParamRefFromRef

        public SavotParamRef getParamRefFromRef​(java.lang.String ref)
        Search a PARAMref corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotParamRef
      • getTableFromRef

        public SavotTable getTableFromRef​(java.lang.String ref)
        Search a TABLE corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotTable
      • getGroupFromRef

        public SavotGroup getGroupFromRef​(java.lang.String ref)
        Search a GROUP corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotGROUP
      • getInfoFromRef

        public SavotInfo getInfoFromRef​(java.lang.String ref)
        Search a RESOURCE corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotInfo
      • getValuesFromRef

        public SavotValues getValuesFromRef​(java.lang.String ref)
        Search a VALUES corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotValues
      • getLinkFromRef

        public SavotLink getLinkFromRef​(java.lang.String ref)
        Search a LINK corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotLink
      • getCoosysFromRef

        public SavotCoosys getCoosysFromRef​(java.lang.String ref)
        Search a COOSYS corresponding to an ID ref
        Parameters:
        ref -
        Returns:
        SavotCoosys
      • getAllResources

        public SavotVOTable getAllResources()
        Get current VOTable (all resources)
        Returns:
        SavotVOTable
      • enableDebug

        public void enableDebug​(boolean debug)
        Enable debug mode
        Parameters:
        debug - boolean
      • getStatistics

        public SavotStatistics getStatistics()
        Returns the statistics
        Returns:
        statistics
      • getVersion

        public java.lang.String getVersion()
        Get Parser Version
        Returns:
        String
      • sequentialTester

        public void sequentialTester()
        For test only
      • main

        public static void main​(java.lang.String[] argv)
                         throws java.lang.Exception
        Main
        Parameters:
        argv -
        Throws:
        java.lang.Exception