Skip navigation links
EDB/Java
jp.ac.tokushima_u.db.utlf.parser

Class UTLFParser

  • All Implemented Interfaces:
    org.jrdf.parser.ConfigurableParser, org.jrdf.parser.Parser, org.jrdf.parser.ParserConfiguration, org.jrdf.parser.StatementHandlerConfiguration


    public final class UTLFParser
    extends Object
    implements org.jrdf.parser.ConfigurableParser
    A parser for XML-serialized RDF. This parser operates directly on the SAX events generated by a SAX-enabled XML parser. The XML parser should be compliant with SAX2. You should specify which SAX parser should be used by setting the org.xml.sax.driver property. This parser is not thread-safe, therefore it's public methods are synchronized.

    To parse a document using this parser:

    • Create an instance of UTLFParser, optionally supplying it with your own ValueFactory.
    • Set the StatementHandler.
    • Optionally, set the ParseErrorListener, ParseLocationListener and/or NamespaceListener.
    • Optionally, specify whether the parser should verify the data it parses and whether it should stop immediately when it finds an error in the data (both default to true).
    • Call the parse method.
    Example code:
     Graph jrdfGraph = new GraphImpl();
     Parser parser = new UTLFParser(jrdfGraph.getElementFactory());
     parser.setStatementHandler(myStatementHandler);
     parser.setParseErrorListener(myParseErrorListener);
     parser.setVerifyData(true);
     parser.setStopAtFirstError(false);
     // Parse the data from inputStream, resolving any relative URIs against http://foo/bar:
     parser.parse(inputStream, "http://foo/bar");
     
    • Field Detail

      • verifyData

        boolean verifyData
        Flag indicating whether the parser should check the data it parses.
      • preserveBNodeIds

        boolean preserveBNodeIds
        Flag indicating whether the parser should preserve bnode identifiers specified in the source.
    • Constructor Detail

      • UTLFParser

        public UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory)
                   throws org.jrdf.graph.GraphException
        Creates a new UTLFParser that will use the supplied GraphElementFactory to create objects for resources, bNodes and literals. This create an in memory blank node factory which may exhaust available memory.
        Parameters:
        graphElementFactory - A GraphElementFactory.
        Throws:
        org.jrdf.graph.GraphException - Graph Exception
      • UTLFParser

        public UTLFParser(org.jrdf.graph.GraphElementFactory graphElementFactory,
                          org.jrdf.map.MapFactory creator)
                   throws org.jrdf.graph.GraphException
        Creates a new UTLFParser that will use the supplied BlankNodeFactoryCreator and create a new map to be used by the generic ParserBlankNodeFactoryImpl.
        Parameters:
        graphElementFactory - A GraphElementFactory.
        creator - A BlankNodeFactoryCreator.
        Throws:
        org.jrdf.graph.GraphException - Graph Exception
      • UTLFParser

        public UTLFParser(org.jrdf.graph.GraphElementFactory valueFactory,
                          org.jrdf.parser.ParserBlankNodeFactory parserBlankNodeFactory)
                   throws org.jrdf.graph.GraphException
        Creates a new UTLFParser that will use the supplied GraphElementFactory to create objects for resources, bNodes and literals.
        Parameters:
        valueFactory - A GraphElementFactory.
        parserBlankNodeFactory - A ParserBlankNodeFactory.
        Throws:
        org.jrdf.graph.GraphException - Graph Exception
    • Method Detail

      • setStatementHandler

        public void setStatementHandler(org.jrdf.parser.StatementHandler sh)
        Specified by:
        setStatementHandler in interface org.jrdf.parser.StatementHandlerConfiguration
      • setParseErrorListener

        public void setParseErrorListener(org.jrdf.parser.ParseErrorListener el)
        Specified by:
        setParseErrorListener in interface org.jrdf.parser.ParserConfiguration
      • setParseLocationListener

        public void setParseLocationListener(org.jrdf.parser.ParseLocationListener ll)
        Specified by:
        setParseLocationListener in interface org.jrdf.parser.ParserConfiguration
      • setNamespaceListener

        public void setNamespaceListener(org.jrdf.parser.NamespaceListener nl)
        Specified by:
        setNamespaceListener in interface org.jrdf.parser.ParserConfiguration
      • setVerifyData

        public void setVerifyData(boolean verifyData)
        Specified by:
        setVerifyData in interface org.jrdf.parser.ParserConfiguration
      • setPreserveBNodeIds

        public void setPreserveBNodeIds(boolean preserveBNodeIds)
        Specified by:
        setPreserveBNodeIds in interface org.jrdf.parser.ParserConfiguration
      • setStopAtFirstError

        public void setStopAtFirstError(boolean stopAtFirstError)
        Specified by:
        setStopAtFirstError in interface org.jrdf.parser.ParserConfiguration
      • setDatatypeHandling

        public void setDatatypeHandling(int datatypeHandling)
        Specified by:
        setDatatypeHandling in interface org.jrdf.parser.ParserConfiguration
      • setParseStandAloneDocuments

        public void setParseStandAloneDocuments(boolean standAloneDocs)
        Specified by:
        setParseStandAloneDocuments in interface org.jrdf.parser.ParserConfiguration
      • getParseStandAloneDocuments

        public boolean getParseStandAloneDocuments()
        Returns whether the parser is currently in a mode to parse stand-alone RDF documents.
        Returns:
        saxFilter.getParseStandAloneDocuments()
        See Also:
        setParseStandAloneDocuments(boolean)
      • parse

        public void parse(InputStream in,
                          String baseURI)
                   throws IOException,
                          org.jrdf.parser.ParseException,
                          org.jrdf.parser.StatementHandlerException
        Parses the data from the supplied InputStream, using the supplied BASE_URI to resolve any relative URI references.
        Specified by:
        parse in interface org.jrdf.parser.Parser
        Parameters:
        in - The InputStream from which to read the data.
        baseURI - The URI associated with the data in the InputStream.
        Throws:
        IOException - If an I/O error occurred while data was read from the InputStream.
        org.jrdf.parser.ParseException - If the parser has found an unrecoverable parse error.
        org.jrdf.parser.StatementHandlerException - If the configured statement handler encountered an unrecoverable error.
        IllegalArgumentException - If the supplied input stream or base URI is null.
      • parse

        public void parse(Reader reader,
                          String baseURI)
                   throws IOException,
                          org.jrdf.parser.ParseException,
                          org.jrdf.parser.StatementHandlerException
        Parses the data from the supplied Reader, using the supplied BASE_URI to resolve any relative URI references.
        Specified by:
        parse in interface org.jrdf.parser.Parser
        Parameters:
        reader - The Reader from which to read the data.
        baseURI - The URI associated with the data in the InputStream.
        Throws:
        IOException - If an I/O error occurred while data was read from the InputStream.
        org.jrdf.parser.ParseException - If the parser has found an unrecoverable parse error.
        org.jrdf.parser.StatementHandlerException - If the configured statement handler has encountered an unrecoverable error.
        IllegalArgumentException - If the supplied reader or base URI is null.
      • setBaseURI

        void setBaseURI(URI baseURI)
      • setXmlLang

        void setXmlLang(String xmlLang)
      • sendWarning

        void sendWarning(String msg)
EDB/Java

EDB Working Group at Tue Jun 10 17:08:59 JST 2025