de.fuberlin.wiwiss.d2rq.map
Class ContainsRestriction

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

public class ContainsRestriction
extends java.lang.Object
implements ValueSource, Prefixable

Restriction which can be chained with another ValueSource to state that all its values contain a certain string. This is useful because the query engine can exclude sources if a value doesn't contain the string.

History:
08-03-2004: Initial version of this class.

Version:
V0.2
Author:
Richard Cyganiak

Field Summary
private  java.lang.String containedValue
           
private  ValueSource valueSource
           
 
Constructor Summary
ContainsRestriction(ValueSource valueSource, java.lang.String containedValue)
           
 
Method Summary
 java.lang.Object clone()
          Make a shallow copy of this.
 boolean couldFit(java.lang.String value)
          Checks if a given value fits this source without querying the database.
 java.util.Set getColumns()
          Returns a set of all columns containing data necessary for this ValueSource.
 java.util.Map getColumnValues(java.lang.String value)
          Returns a map of database fields and values corresponding to the argument.
 java.lang.String getValue(java.lang.String[] row, java.util.Map columnNameNumberMap)
          Retrieves a value from a database row according to some rule or pattern.
 void prefixTables(TablePrefixer prefixer)
          Changes the fields in a newly created clone that are to be modified when making aliasses.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valueSource

private ValueSource valueSource

containedValue

private java.lang.String containedValue
Constructor Detail

ContainsRestriction

public ContainsRestriction(ValueSource valueSource,
                           java.lang.String containedValue)
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.

couldFit

public boolean couldFit(java.lang.String value)
Description copied from interface: ValueSource
Checks if a given value fits this source without querying the database.

Specified by:
couldFit in interface ValueSource

getColumns

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

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

getColumnValues

public java.util.Map getColumnValues(java.lang.String value)
Description copied from interface: ValueSource
Returns a map of database fields and values corresponding to the argument.

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

Specified by:
getColumnValues in interface ValueSource
Parameters:
value - a non-null value
Returns:
a map with Column keys, and string values.

getValue

public java.lang.String getValue(java.lang.String[] row,
                                 java.util.Map columnNameNumberMap)
Description copied from interface: ValueSource
Retrieves a value from a database row according to some rule or pattern.

Specified by:
getValue in interface ValueSource
Parameters:
row - the database row
columnNameNumberMap - a map from Table.Column style column names to Integer indices into the row array
Returns:
a value created from the row