de.fuberlin.wiwiss.d2rq.map
Class LiteralMaker

java.lang.Object
  extended byde.fuberlin.wiwiss.d2rq.map.LiteralMaker
All Implemented Interfaces:
java.lang.Cloneable, NodeMaker, Prefixable

public class LiteralMaker
extends java.lang.Object
implements NodeMaker, Prefixable

LiteralMakers transform attribute values from a result set into literals.

History:
06-21-2004: Initial version of this class.
08-03-2004: Extended with couldFit, getColumns, getColumnValues

Version:
V0.2
Author:
Chris Bizer chris@bizer.de, Richard Cyganiak

Field Summary
private  com.hp.hpl.jena.datatypes.RDFDatatype datatype
           
private  java.lang.String id
           
private  java.lang.String lang
           
private  ValueSource valueSource
           
 
Constructor Summary
LiteralMaker(java.lang.String id, ValueSource valueSource, com.hp.hpl.jena.datatypes.RDFDatatype datatype, java.lang.String lang)
           
 
Method Summary
private  boolean areCompatibleDatatypes(com.hp.hpl.jena.datatypes.RDFDatatype dt1, com.hp.hpl.jena.datatypes.RDFDatatype dt2)
           
private  boolean areCompatibleLanguages(java.lang.String lang1, java.lang.String lang2)
           
 java.lang.Object clone()
          Make a shallow copy of this.
 boolean couldFit(com.hp.hpl.jena.graph.Node node)
          Checks if a node could fit this NodeMaker without querying the database.
 java.util.Set getColumns()
          Returns a set of all columns containing data necessary for this NodeMaker to build its nodes.
 java.util.Map getColumnValues(com.hp.hpl.jena.graph.Node node)
          Returns a map of database fields and values corresponding to the argument node.
 com.hp.hpl.jena.graph.Node getNode(java.lang.String[] row, java.util.Map columnNameNumberMap)
          Creates a new Node from a database result row.
 void matchConstraint(NodeConstraint c)
          Adds constraint information to a NodeConstraint.
 boolean matchesOtherLiteralMaker(LiteralMaker other)
           
 void prefixTables(TablePrefixer prefixer)
          Changes the fields in a newly created clone that are to be modified when making aliasses.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

valueSource

private ValueSource valueSource

datatype

private com.hp.hpl.jena.datatypes.RDFDatatype datatype

lang

private java.lang.String lang

id

private java.lang.String id
Constructor Detail

LiteralMaker

public LiteralMaker(java.lang.String id,
                    ValueSource valueSource,
                    com.hp.hpl.jena.datatypes.RDFDatatype datatype,
                    java.lang.String lang)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Prefixable
Make a shallow copy of this. General advice: Do not overwrite clone(). prefixTables() works best with shallow copy which Object implements. Issues: I have not found a (preferred) static equivalent of clone(). Since Objects clone() method is protected, we cannot just declare Cloneable, if we want to call clone() from outside of that class hierarchy. Instead it must be public and implemented in each Prefixable class by a call to super.clone().

Specified by:
clone in interface Prefixable
Throws:
java.lang.CloneNotSupportedException

prefixTables

public void prefixTables(TablePrefixer prefixer)
Description copied from interface: Prefixable
Changes the fields in a newly created clone that are to be modified when making aliasses.

Specified by:
prefixTables in interface Prefixable
Parameters:
prefixer - does the actual prefixing of simple and complex types.

matchConstraint

public void matchConstraint(NodeConstraint c)
Description copied from interface: NodeMaker
Adds constraint information to a NodeConstraint. In a RDQL query a shared variable generally corresponds to different NodeMakers.

Specified by:
matchConstraint in interface NodeMaker
Parameters:
c -
See Also:
NodeConstraint

matchesOtherLiteralMaker

public boolean matchesOtherLiteralMaker(LiteralMaker other)

couldFit

public boolean couldFit(com.hp.hpl.jena.graph.Node node)
Description copied from interface: NodeMaker
Checks if a node could fit this NodeMaker without querying the database.

Specified by:
couldFit in interface NodeMaker

getColumns

public java.util.Set getColumns()
Description copied from interface: NodeMaker
Returns a set of all columns containing data necessary for this NodeMaker to build its nodes.

Specified by:
getColumns in interface NodeMaker
Returns:
a set of {Column}s

getColumnValues

public java.util.Map getColumnValues(com.hp.hpl.jena.graph.Node node)
Description copied from interface: NodeMaker
Returns a map of database fields and values corresponding to the argument node.

For example, a NodeMaker that corresponds directly to a single DB column would return a single-entry map with that column as the key, and the DB value corresponding to the node as the value.

Specified by:
getColumnValues in interface NodeMaker
Parameters:
node - a concrete, non-null RDF node
Returns:
a map with Column keys, and string values.

getNode

public com.hp.hpl.jena.graph.Node getNode(java.lang.String[] row,
                                          java.util.Map columnNameNumberMap)
Description copied from interface: NodeMaker
Creates a new Node from a database result row.

Specified by:
getNode in interface NodeMaker
Parameters:
row - a database result row
columnNameNumberMap - a map from Table.Column style column names to Integers representing indices within the row array
Returns:
a node created from the row, or null if a NULL value was encountered in a required field.

areCompatibleDatatypes

private boolean areCompatibleDatatypes(com.hp.hpl.jena.datatypes.RDFDatatype dt1,
                                       com.hp.hpl.jena.datatypes.RDFDatatype dt2)

areCompatibleLanguages

private boolean areCompatibleLanguages(java.lang.String lang1,
                                       java.lang.String lang2)

toString

public java.lang.String toString()