semweb
Class ParseRDF

java.lang.Object
  extended by semweb.ParseRDF

public class ParseRDF
extends java.lang.Object

Tool for handling rdf-data. It is possible to - transform rdf-data from one language to another - use SPARQL-Queries on given rdf-data

Author:
Franz Schenk

Field Summary
(package private) static java.lang.String[] allowedOutputFormatters
          string array containing all accepted result formats
(package private) static boolean classtree
          default value for output of classtree
(package private) static java.lang.String commentString
          String that is recognized as start of comment Note, that # is also used by the arq-module as a character introducing comments.
(package private) static java.lang.String defaultNS
          default Namespace that is used when none is given in the document or the query
(package private) static boolean inferenceSupport
          default value for query support
(package private) static java.util.Vector<java.lang.String> inputFile
          vector containing all inputfilenames
(package private) static java.lang.String inputFileDefault
          default value for inputfilename
(package private) static java.lang.String inputLanguage
          default value for input language
(package private) static java.lang.String[] knownInputLanguages
          string array containing all accepted input languages
(package private) static java.lang.String[] knownOutputLanguages
          string array containing all accepted output languages
(package private) static org.apache.log4j.Logger logger
          log4j Logger Object
(package private) static java.lang.String outputFile
          default value for outputfilename
(package private) static java.lang.String outputLanguage
          Default Value for output language
(package private) static java.lang.String packageFormat
          Package format gives a hint where to look for a log4j configuration
(package private) static java.lang.String prettyPrint
          Query Result Output Format (aka pretty printing)
(package private) static java.lang.String queryFile
          default value for queryfilename
(package private) static java.lang.String reasonerAddress
          default value for reasoner address
 
Constructor Summary
ParseRDF()
           
 
Method Summary
private static java.lang.String arrayToString(java.lang.String[] stringarray, java.lang.String delimiter)
          return a string composed of elements of given array, each delimited by given string
private static boolean checkLanguage(java.lang.String givenLanguage, java.lang.String[] knownLanguages)
          check if a given language is supported as input or output language
private static void executeSPARQLQuery()
          Execute a SPARQL-Query
private static boolean formattedResultsOutput(com.hp.hpl.jena.query.ResultSet results)
          Output of a SPARQL Query ResultSet.
static java.util.Properties loadConfiguration()
          Load a log4j Properties File.
static void main(java.lang.String[] args)
           
private static void outputModel(com.hp.hpl.jena.rdf.model.Model model)
           
private static java.lang.String parseAddress(java.lang.String address)
          add protocol 'file:' to address-string if it is not given
private static java.lang.String parseQuery(java.lang.String queryString)
          Helper function to parse a query, remove all URI's in FROM-clauses (but not in FROM NAMED) and add those URI's to the list of input Filenames
private static com.hp.hpl.jena.rdf.model.Model prepareModel()
          Create a Model.
private static void printClassTree()
          uses a built-in function of the pellet knowledgebase-class, that gives the class tree of the actual graph (that the knowledgebase is equivalent to
private static void printHelp()
          Print out a help message on how to use this program.
private static com.hp.hpl.jena.rdf.model.Model readFileIntoModel(java.lang.String inputFileName, java.lang.String inputLanguage)
          Load data from file into a rdf-Model
private static java.lang.String readFileIntoString(java.lang.String filename)
          Load a given (text) File into a String (ignoring lines starting with #)
private static void translateDataFile()
          Transform a given file containing rdf-data from one language to another First load a model, then pass it on to the output-function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultNS

static final java.lang.String defaultNS
default Namespace that is used when none is given in the document or the query

See Also:
Constant Field Values

knownInputLanguages

static final java.lang.String[] knownInputLanguages
string array containing all accepted input languages


knownOutputLanguages

static final java.lang.String[] knownOutputLanguages
string array containing all accepted output languages


allowedOutputFormatters

static final java.lang.String[] allowedOutputFormatters
string array containing all accepted result formats


inputLanguage

static java.lang.String inputLanguage
default value for input language


outputLanguage

static java.lang.String outputLanguage
Default Value for output language


inputFileDefault

static java.lang.String inputFileDefault
default value for inputfilename


outputFile

static java.lang.String outputFile
default value for outputfilename


queryFile

static java.lang.String queryFile
default value for queryfilename


inferenceSupport

static boolean inferenceSupport
default value for query support


reasonerAddress

static java.lang.String reasonerAddress
default value for reasoner address


inputFile

static java.util.Vector<java.lang.String> inputFile
vector containing all inputfilenames


logger

static org.apache.log4j.Logger logger
log4j Logger Object


prettyPrint

static java.lang.String prettyPrint
Query Result Output Format (aka pretty printing)


packageFormat

static java.lang.String packageFormat
Package format gives a hint where to look for a log4j configuration


commentString

static java.lang.String commentString
String that is recognized as start of comment Note, that # is also used by the arq-module as a character introducing comments.


classtree

static boolean classtree
default value for output of classtree

Constructor Detail

ParseRDF

public ParseRDF()
Method Detail

main

public static void main(java.lang.String[] args)

translateDataFile

private static void translateDataFile()
Transform a given file containing rdf-data from one language to another First load a model, then pass it on to the output-function.


outputModel

private static void outputModel(com.hp.hpl.jena.rdf.model.Model model)

printClassTree

private static void printClassTree()
uses a built-in function of the pellet knowledgebase-class, that gives the class tree of the actual graph (that the knowledgebase is equivalent to


checkLanguage

private static boolean checkLanguage(java.lang.String givenLanguage,
                                     java.lang.String[] knownLanguages)
check if a given language is supported as input or output language


prepareModel

private static com.hp.hpl.jena.rdf.model.Model prepareModel()
Create a Model. Depending on the Parameters passed by the user either a model without inference support or a model backed by an internal / external reasoner is created.

Returns:
Model

readFileIntoModel

private static com.hp.hpl.jena.rdf.model.Model readFileIntoModel(java.lang.String inputFileName,
                                                                 java.lang.String inputLanguage)
Load data from file into a rdf-Model

Parameters:
inputFileName -
inputLanguage -
Returns:
Model

readFileIntoString

private static java.lang.String readFileIntoString(java.lang.String filename)
Load a given (text) File into a String (ignoring lines starting with #)

Parameters:
filename -
Returns:
querystring

executeSPARQLQuery

private static void executeSPARQLQuery()
Execute a SPARQL-Query


arrayToString

private static java.lang.String arrayToString(java.lang.String[] stringarray,
                                              java.lang.String delimiter)
return a string composed of elements of given array, each delimited by given string


parseAddress

private static java.lang.String parseAddress(java.lang.String address)
add protocol 'file:' to address-string if it is not given


parseQuery

private static java.lang.String parseQuery(java.lang.String queryString)
Helper function to parse a query, remove all URI's in FROM-clauses (but not in FROM NAMED) and add those URI's to the list of input Filenames

Parameters:
queryString -
Returns:
String

loadConfiguration

public static java.util.Properties loadConfiguration()
Load a log4j Properties File. The name of the File to be loaded is 'log4j.properties'. The location is within the same directory as this classfile. The intention is to be able to load a config-file inside the jar.

Returns:
Properties

formattedResultsOutput

private static boolean formattedResultsOutput(com.hp.hpl.jena.query.ResultSet results)
Output of a SPARQL Query ResultSet. Default method is a plain text table containing variable bindings. Other possibilities are RDF, XML.

Parameters:
results -
Returns:
boolean

printHelp

private static void printHelp()
Print out a help message on how to use this program.