ibspan.tss.semantic
Class Memory

java.lang.Object
  extended by ibspan.tss.semantic.Memory

public class Memory
extends Object

This class provides a set of methods for transparent operating on Jena memory-based model.

Examples say more then thousand of words:

Author:
Maciej Gawinecki, Michal Laclavik
See Also:
OntModel, Thing, OWLData

Field Summary
static String DEFAULT_BASE
          Default base namespace URI.
static String DEFAULT_LANG
          Default serialization language.
 
Constructor Summary
Memory()
          Creates Memory with empy model.
Memory(com.hp.hpl.jena.ontology.OntModel model)
          Creates Memory object with given model.
Memory(String rdf)
          Creates Memory object with model with RDF statements represented in language DEFAULT_LANG.
Memory(String rdf, String base)
          Creates Memory object with model including RDF statements represented in language DEFAULT_LANG.
Memory(com.ibm.adtech.jastor.Thing thing)
          Creates Memory object with model including resource of given Thing.
 
Method Summary
 void addProperties(com.hp.hpl.jena.rdf.model.Resource root)
          Recursive method which copy resource with all properties recursively into memory.
 void addResource(com.hp.hpl.jena.rdf.model.Resource r)
          Creates a copy of given resource if it is not there
 void addRootThing(com.ibm.adtech.jastor.Thing thing)
          Remembers thing in memory and registers it as one of the roots.
 void addThing(com.ibm.adtech.jastor.Thing thing)
          Remembers thing in memory.
 OWLData buildOWLData()
          Creates OWLData containing internal model of this Memory object.
 OWLData buildOWLData(boolean needAll)
          Creates OWLData containing internal model of this Memory object.
 com.hp.hpl.jena.rdf.model.Resource createAnonResource()
          Creates and returns anonymous resource in the memory.
static com.hp.hpl.jena.ontology.OntModel createDefaultOntModel()
          Answer a new ontology model which will process in-memory models of ontologies expressed the default ontology language (OWL).
 String dump()
          Returns a serialized represention of the internal model in a language DEFAULT_LANG.No content from any imported model will be serialized.
 String dump(boolean needAll)
          Returns a serialized represention of the internal model in a language DEFAULT_LANG.
 com.hp.hpl.jena.ontology.OntModel getModel()
          Returns internal model.
protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model, boolean needAll)
          Returns a serialized represention of a model in a language DEFAULT_LANG.
protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model, String lang, boolean needAll)
          Returns a serialized represention of a model in a language lang.
protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model, String lang, String base, boolean needAll)
          Returns a serialized represention of a model in a language DEFAULT_LANG.
protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf)
          Add RDF statements represented in language DEFAULT_LANG to the model.
protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf, String base)
          Add RDF statements represented in language DEFAULT_LANG to the model.
protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf, String base, String lang)
          Add RDF statements represented in language lang to the model.
 void removeProperties(com.hp.hpl.jena.rdf.model.Resource root)
          Recursive method which remove resource with all properties recursively from the memory.
 void removeProperties(com.ibm.adtech.jastor.Thing root)
          Recursive method which remove resource with all properties recursively from the memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LANG

public static final String DEFAULT_LANG
Default serialization language.

See Also:
Constant Field Values

DEFAULT_BASE

public static final String DEFAULT_BASE
Default base namespace URI.

Constructor Detail

Memory

public Memory()
Creates Memory with empy model.


Memory

public Memory(String rdf)
Creates Memory object with model with RDF statements represented in language DEFAULT_LANG.

Parameters:
rdf - the source input of the input serialization.
See Also:
DEFAULT_LANG

Memory

public Memory(String rdf,
              String base)
Creates Memory object with model including RDF statements represented in language DEFAULT_LANG.

Parameters:
rdf - the source input of the input serialization.
base - the base uri to be used when converting relative URI's to absolute URI's. The base URI may be null if there are no relative URIs to convert. A base URI of "" may permit relative URIs to be used in the model.

Memory

public Memory(com.hp.hpl.jena.ontology.OntModel model)
Creates Memory object with given model.

Parameters:
model - existing model.

Memory

public Memory(com.ibm.adtech.jastor.Thing thing)
Creates Memory object with model including resource of given Thing.

Parameters:
model - existing model.
Method Detail

getModel

public com.hp.hpl.jena.ontology.OntModel getModel()
Returns internal model.

Returns:
this model.

dump

public String dump(boolean needAll)
Returns a serialized represention of the internal model in a language DEFAULT_LANG.

Parameters:
needAll - if true then returns also inferred statements and statements imported from other documents
Returns:
serialized representation
See Also:
DEFAULT_LANG

dump

public String dump()
Returns a serialized represention of the internal model in a language DEFAULT_LANG.No content from any imported model will be serialized.

Returns:
serialized representation
See Also:
DEFAULT_LANG

addRootThing

public void addRootThing(com.ibm.adtech.jastor.Thing thing)
Remembers thing in memory and registers it as one of the roots. More precisely, copies resource of thing into internal model.

Parameters:
thing - given thing

buildOWLData

public OWLData buildOWLData()
Creates OWLData containing internal model of this Memory object. No content from any imported model will be attached.

Syntax language will be set to the value of DEFAULT_LANG and all resources registered as roots will be added as values of withRootURI property of OWLData object.

Returns:
OWLData representing content of this memory

buildOWLData

public OWLData buildOWLData(boolean needAll)
Creates OWLData containing internal model of this Memory object. Syntax language will be set to the value of DEFAULT_LANG and all resources registered as roots will be added as values of withRootURI property of OWLData object.

Parameters:
needAll - true means that also content of imported ontologies will be serialized into OWLData.
Returns:
OWLData representing content of this memory

addThing

public void addThing(com.ibm.adtech.jastor.Thing thing)
Remembers thing in memory. More precisely, copies resource of thing into internal model.

Parameters:
thing - given thing

addResource

public void addResource(com.hp.hpl.jena.rdf.model.Resource r)
Creates a copy of given resource if it is not there

Parameters:
r -

createAnonResource

public com.hp.hpl.jena.rdf.model.Resource createAnonResource()
Creates and returns anonymous resource in the memory.

Returns:
creates resource

createDefaultOntModel

public static com.hp.hpl.jena.ontology.OntModel createDefaultOntModel()
Answer a new ontology model which will process in-memory models of ontologies expressed the default ontology language (OWL).

Returns:
a new ontology model.

model2rdf

protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model,
                                  boolean needAll)
Returns a serialized represention of a model in a language DEFAULT_LANG.

Parameters:
model - the source model of the output serialization.
needAll - true means that also content of imported ontologies will be serialized
Returns:
serialized representation
See Also:
DEFAULT_LANG

model2rdf

protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model,
                                  String lang,
                                  boolean needAll)
Returns a serialized represention of a model in a language lang.

Parameters:
model - the source model of the output serialization.
lang - the language in which the RDF should be serialized
needAll - true means that also content of imported ontologies will be serialized
Returns:
serialized representation.

model2rdf

protected static String model2rdf(com.hp.hpl.jena.ontology.OntModel model,
                                  String lang,
                                  String base,
                                  boolean needAll)
Returns a serialized represention of a model in a language DEFAULT_LANG.

Parameters:
model - the source model of the output serialization.
lang - the language in which the RDF should be serialized
base - the base uri for relative URI calculations; null means use only absolute URI's.
needAll - true means that also content of imported ontologies will be serialized
Returns:
serialized representation

rdf2model

protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf)
Add RDF statements represented in language DEFAULT_LANG to the model.

Parameters:
rdf - the source input of the input serialization.
Returns:
newly serialiazed model.
See Also:
DEFAULT_LANG

rdf2model

protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf,
                                                             String base)
Add RDF statements represented in language DEFAULT_LANG to the model.

Parameters:
rdf - the source input of the input serialization.
base - the base uri to be used when converting relative URI's to absolute URI's. The base URI may be null if there are no relative URIs to convert. A base URI of "" may permit relative URIs to be used in the model.
Returns:
newly serialiazed model.
See Also:
DEFAULT_LANG

rdf2model

protected static com.hp.hpl.jena.ontology.OntModel rdf2model(String rdf,
                                                             String base,
                                                             String lang)
Add RDF statements represented in language lang to the model.

Parameters:
rdf - the source input of the input serialization.
base - the base uri to be used when converting relative URI's to absolute URI's. The base URI may be null if there are no relative URIs to convert. A base URI of "" may permit relative URIs to be used in the model.
lang - the langauge of the serialization; null selects the default.
Returns:
newly serialiazed model.

addProperties

public void addProperties(com.hp.hpl.jena.rdf.model.Resource root)
Recursive method which copy resource with all properties recursively into memory.

Parameters:
r - resource which properties should be added

removeProperties

public void removeProperties(com.hp.hpl.jena.rdf.model.Resource root)
Recursive method which remove resource with all properties recursively from the memory.

Parameters:
r - resource which properties should be added

removeProperties

public void removeProperties(com.ibm.adtech.jastor.Thing root)
Recursive method which remove resource with all properties recursively from the memory.

Parameters:
r - thing which properties should be added