org.mulgara.mrg.parser
Class N3GraphParser

java.lang.Object
  extended by org.mulgara.mrg.parser.N3GraphParser
All Implemented Interfaces:
TurtleEventHandler, GraphParser

public class N3GraphParser
extends Object
implements TurtleEventHandler, GraphParser

Parses the contents of an N3 file into a graph representation.


Constructor Summary
N3GraphParser(File f)
          Create a graph from a file.
N3GraphParser(File f, GraphFactory graphFactory)
          Create a graph from a file.
N3GraphParser(InputStream is)
          Create a graph from an InputStream.
N3GraphParser(InputStream is, GraphFactory graphFactory)
          Create a graph from an InputStream.
N3GraphParser(String s)
          Create a graph from a string.
N3GraphParser(String s, GraphFactory graphFactory)
          Create a graph from a string.
 
Method Summary
 void endFormula(int line, int col)
          This function handles formulas, but we ignore them.
protected  void error(String msg)
          General error logging.
 WritableGraph getGraph()
          Retrieves the ResultSet that this parser built.
 long getProcessedRows()
          Return the number of rows parsed.
 void prefix(int line, int col, String prefix, String iri)
          Shouldn't need to know about prefixes at this level.
 void startFormula(int line, int col)
          This function handles formulas, but we ignore them.
 void triple(int line, int col, Triple triple)
          Collect a triple from the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

N3GraphParser

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

Parameters:
s - The string containing the N3.
Throws:
ParseException
IOException

N3GraphParser

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

Parameters:
f - The file containing the N3.
Throws:
ParseException
IOException

N3GraphParser

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

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

N3GraphParser

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

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

N3GraphParser

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

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

N3GraphParser

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

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()
Retrieves the ResultSet that this parser built.

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.


triple

public void triple(int line,
                   int col,
                   Triple triple)
Collect a triple from the parser.

Specified by:
triple in interface TurtleEventHandler
Parameters:
line - The line number that the parser has reached.
col - The column number that the parser has reached.
triple - The parsed triple/

prefix

public void prefix(int line,
                   int col,
                   String prefix,
                   String iri)
Shouldn't need to know about prefixes at this level.

Specified by:
prefix in interface TurtleEventHandler
Parameters:
line - The line number that the parser has reached.
col - The column number that the parser has reached.
prefix - The prefix to be mapped.
iri - The IRI to map the prefix to.

endFormula

public void endFormula(int line,
                       int col)
This function handles formulas, but we ignore them.

Specified by:
endFormula in interface TurtleEventHandler
Parameters:
line - The line number that the parser has reached.
col - The column number that the parser has reached.

startFormula

public void startFormula(int line,
                         int col)
This function handles formulas, but we ignore them.

Specified by:
startFormula in interface TurtleEventHandler
Parameters:
line - The line number that the parser has reached.
col - The column number that the parser has reached.


Copyright © 2011. All Rights Reserved.