org.mulgara.mrg.parser
Class XMLGraphParser

java.lang.Object
  extended by org.mulgara.mrg.parser.XMLGraphParser
All Implemented Interfaces:
StatementHandler, GraphParser, ErrorHandler

public class XMLGraphParser
extends Object
implements StatementHandler, ErrorHandler, GraphParser

Parses the contents of an RDF/XML file into a graph representation.


Constructor Summary
XMLGraphParser(File f)
          Create a graph from a File.
XMLGraphParser(File f, GraphFactory graphFactory)
          Create a graph from a file and a graph factory.
XMLGraphParser(InputStream is)
          Create a graph from an InputStream.
XMLGraphParser(InputStream is, GraphFactory graphFactory)
          Create a graph from an InputStream and a graph factory.
XMLGraphParser(String s)
          Create a graph from a string.
XMLGraphParser(String s, GraphFactory graphFactory)
          Create a graph from a string and a graph factory.
 
Method Summary
protected  void error(Exception arg0, String arg1)
          Log an exception as an error.
 void error(SAXParseException e)
          Indicates an error detected in the XML stream.
protected  void error(String msg)
          General error logging.
 void fatalError(SAXParseException e)
          Indicates an unrecoverable error in the XML stream.
 WritableGraph getGraph()
          Gets the parsed graph.
 long getProcessedRows()
          Return the number of rows parsed.
 void statement(AResource subject, AResource predicate, ALiteral obj)
          Called to record a statement in the input.
 void statement(AResource subject, AResource predicate, AResource obj)
          Called to record a statement in the input.
 void warning(SAXParseException e)
          Indicates a warning condition in the XML stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLGraphParser

public XMLGraphParser(String s)
               throws ParseException,
                      IOException
Create a graph from a string.

Parameters:
s - The string containing the RDF/XML.
Throws:
ParseException
IOException

XMLGraphParser

public XMLGraphParser(InputStream is)
               throws ParseException,
                      IOException
Create a graph from an InputStream.

Parameters:
is - The input stream with the graph data.
Throws:
ParseException
IOException

XMLGraphParser

public XMLGraphParser(File f)
               throws ParseException,
                      IOException
Create a graph from a File.

Parameters:
f - The File with the graph data.
Throws:
ParseException
IOException

XMLGraphParser

public XMLGraphParser(String s,
                      GraphFactory graphFactory)
               throws ParseException,
                      IOException
Create a graph from a string and a graph factory.

Parameters:
s - The string containing the RDF/XML.
graphFactory - A mechanism for creating a graph to populate.
Throws:
ParseException
IOException

XMLGraphParser

public XMLGraphParser(File f,
                      GraphFactory graphFactory)
               throws ParseException,
                      IOException
Create a graph from a file and a graph factory.

Parameters:
f - The file containing the RDF/XML.
graphFactory - A mechanism for creating a graph to populate.
Throws:
ParseException
IOException

XMLGraphParser

public XMLGraphParser(InputStream is,
                      GraphFactory graphFactory)
               throws ParseException,
                      IOException
Create a graph from an InputStream and a graph factory.

Parameters:
is - The input stream with the graph data.
graphFactory - A mechanism for creating a graph to populate.
Throws:
ParseException
IOException
Method Detail

getGraph

public WritableGraph getGraph()
Gets the parsed graph.

Specified by:
getGraph in interface GraphParser
Returns:
a writable graph that has been parsed.

getProcessedRows

public long getProcessedRows()
Return the number of rows parsed.

Specified by:
getProcessedRows in interface GraphParser
Returns:
the number of processed triples. This may be larger than the size of the graph if there are duplicates.

error

protected void error(String msg)
General error logging.


error

protected void error(Exception arg0,
                     String arg1)
Log an exception as an error.


statement

public void statement(AResource subject,
                      AResource predicate,
                      ALiteral obj)
Called to record a statement in the input.

Specified by:
statement in interface StatementHandler
Parameters:
subject - The subject of the triple.
predicate - The predicate of the triple.
obj - The literal object of the triple.

statement

public void statement(AResource subject,
                      AResource predicate,
                      AResource obj)
Called to record a statement in the input.

Specified by:
statement in interface StatementHandler
Parameters:
subject - The subject of the triple.
predicate - The predicate of the triple.
obj - The object resource of the triple.

error

public void error(SAXParseException e)
Indicates an error detected in the XML stream.

Specified by:
error in interface ErrorHandler
Parameters:
e - The exception describing the error condition.

fatalError

public void fatalError(SAXParseException e)
                throws SAXException
Indicates an unrecoverable error in the XML stream.

Specified by:
fatalError in interface ErrorHandler
Parameters:
e - The exception describing the error condition.
Throws:
ParseException - The exception that will halt the parsing process after this method has completed.
SAXException

warning

public void warning(SAXParseException e)
Indicates a warning condition in the XML stream.

Specified by:
warning in interface ErrorHandler
Parameters:
e - The exception describing the warning condition.


Copyright © 2011. All Rights Reserved.