de.fuberlin.wiwiss.d2rq.algebra
Class AliasMap

java.lang.Object
  extended by de.fuberlin.wiwiss.d2rq.algebra.ColumnRenamer
      extended by de.fuberlin.wiwiss.d2rq.algebra.AliasMap

public class AliasMap
extends ColumnRenamer

A map from table names to aliases. Can be applied to various objects and will replace all mentions of a table with its alias. For some kinds of objects, the inverse operation is available as well. TODO: There is an assumption that one original table has at most one alias. Otherwise, the applyTo() operations are indeterministic. This is troublesome. All uses of this class that need applyTo() should probably be redesigned to use something else than a "real" AliasMap. TODO: AliasMap and ColumnRenamer are different concepts. An AliasMap is a bunch of "table AS alias" declarations. A column renamer is something that can be applied to a column name to yield a new one. It should be possible to obtain a ColumnRenamer from a declared AliasMap, but they should be separate classes. AliasMap might also be better called Aliases or AliasSet.

Author:
Richard Cyganiak (richard@cyganiak.de)

Nested Class Summary
static class AliasMap.Alias
           
 
Field Summary
static AliasMap NO_ALIASES
           
 
Fields inherited from class de.fuberlin.wiwiss.d2rq.algebra.ColumnRenamer
NULL
 
Constructor Summary
AliasMap(Collection<AliasMap.Alias> aliases)
           
 
Method Summary
 AliasMap.Alias applyTo(AliasMap.Alias alias)
           
 AliasMap applyTo(AliasMap other)
           
 Attribute applyTo(Attribute attribute)
           
 Join applyTo(Join join)
           
 RelationName applyTo(RelationName original)
           
static AliasMap create1(RelationName original, RelationName alias)
           
 boolean equals(Object other)
           
 boolean hasAlias(RelationName original)
           
 int hashCode()
           
 boolean isAlias(RelationName name)
           
 AliasMap.Alias originalOf(AliasMap.Alias alias)
           
 Attribute originalOf(Attribute attribute)
           
 RelationName originalOf(RelationName name)
           
 String toString()
           
 
Methods inherited from class de.fuberlin.wiwiss.d2rq.algebra.ColumnRenamer
applyTo, applyTo, applyTo, applyToJoinSet, applyToProjectionSet, invertMap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ALIASES

public static final AliasMap NO_ALIASES
Constructor Detail

AliasMap

public AliasMap(Collection<AliasMap.Alias> aliases)
Method Detail

create1

public static AliasMap create1(RelationName original,
                               RelationName alias)

isAlias

public boolean isAlias(RelationName name)

hasAlias

public boolean hasAlias(RelationName original)

applyTo

public RelationName applyTo(RelationName original)

originalOf

public RelationName originalOf(RelationName name)

applyTo

public Attribute applyTo(Attribute attribute)
Specified by:
applyTo in class ColumnRenamer
Parameters:
attribute - A column
Returns:
The renamed version of that column, or the same column if the renamer does not apply to this argument

originalOf

public Attribute originalOf(Attribute attribute)

applyTo

public AliasMap.Alias applyTo(AliasMap.Alias alias)

originalOf

public AliasMap.Alias originalOf(AliasMap.Alias alias)

applyTo

public Join applyTo(Join join)
Overrides:
applyTo in class ColumnRenamer
Parameters:
join - A join
Returns:
A join with all columns renamed according to this Renamer

applyTo

public AliasMap applyTo(AliasMap other)
Specified by:
applyTo in class ColumnRenamer

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object