|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fuberlin.wiwiss.d2rq.map.TranslationTable
Translation table that maps a set of database values to a set of
RDF literals or URIs. The getTranslatingValueSource(de.fuberlin.wiwiss.d2rq.map.ValueSource)
method creates
a TranslationTable.TranslatingValueSource
that can be chained with other ValueSources.
The RDF values can be either literals or URIs. The type of the
node that is actually generated is determined by a NodeMaker
that should sit on top of the translator. Mappings can be explicitly
provided, or a Translator
instance can be used to map
values.
TODO: The two cases (addTranslation calls and setTranslator) should
probalby be in separate classes.
History:
08-03-2004: Initial version.
Nested Class Summary | |
private class |
TranslationTable.TranslatingValueSource
|
Field Summary | |
private java.util.Map |
db2rdf
|
private java.util.Map |
rdf2db
|
private Translator |
translatorInstance
|
Constructor Summary | |
TranslationTable()
|
Method Summary | |
void |
addAll(java.util.Map translationMap)
Adds multiple translation mappings. |
void |
addTranslation(java.lang.String dbValue,
java.lang.String rdfValue)
Adds a translation mapping. |
ValueSource |
getTranslatingValueSource(ValueSource valueSource)
Creates a new ValueSource that translates values from the argument ValueSource according to the mappings in this TranslationTable. |
private boolean |
hasConstructorWithArg(java.lang.Class aClass)
|
private boolean |
hasConstructorWithoutArg(java.lang.Class aClass)
|
private boolean |
implementsTranslator(java.lang.Class aClass)
|
private Translator |
invokeConstructorWithArg(java.lang.Class aClass,
com.hp.hpl.jena.rdf.model.Resource r)
|
private Translator |
invokeConstructorWithoutArg(java.lang.Class aClass)
|
void |
setTranslator(Translator translator)
Sets a Translator. |
void |
setTranslatorClass(java.lang.String className,
com.hp.hpl.jena.rdf.model.Resource resource)
Sets a translation class. |
int |
size()
Returns the number of defined mappings. |
java.lang.String |
toDBValue(java.lang.String rdfValue)
Translates an RDF value to a database value. |
java.lang.String |
toRDFValue(java.lang.String dbValue)
Translates a database value to a RDF value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.Map db2rdf
private java.util.Map rdf2db
private Translator translatorInstance
Constructor Detail |
public TranslationTable()
Method Detail |
public int size()
public void addTranslation(java.lang.String dbValue, java.lang.String rdfValue)
dbValue
- the value on the database side (usually coming from a DB column)rdfValue
- the value on the RDF side (a string or URI)public void setTranslatorClass(java.lang.String className, com.hp.hpl.jena.rdf.model.Resource resource)
Translator
interface. This method will take care
of generating an instance of the class.
className
- name of a class implementing Translator
resource
- the node in the D2RQ map where the d2rq:javaClass
statement was foundpublic void setTranslator(Translator translator)
private boolean implementsTranslator(java.lang.Class aClass)
private boolean hasConstructorWithArg(java.lang.Class aClass)
private Translator invokeConstructorWithArg(java.lang.Class aClass, com.hp.hpl.jena.rdf.model.Resource r)
private boolean hasConstructorWithoutArg(java.lang.Class aClass)
private Translator invokeConstructorWithoutArg(java.lang.Class aClass)
public void addAll(java.util.Map translationMap)
translationMap
- a map of DB => RDF mappings (both strings)public java.lang.String toDBValue(java.lang.String rdfValue)
toDBValue
in interface Translator
rdfValue
- a value coming from an RDF source
public java.lang.String toRDFValue(java.lang.String dbValue)
toRDFValue
in interface Translator
dbValue
- a value coming from the database
public ValueSource getTranslatingValueSource(ValueSource valueSource)
valueSource
- the ValueSource whose values should be translated
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |