uk.org.ogsadai.dqp.lqp
Class SimpleRenameMap

java.lang.Object
  extended by uk.org.ogsadai.dqp.lqp.SimpleRenameMap
All Implemented Interfaces:
RenameMap

public class SimpleRenameMap
extends java.lang.Object
implements RenameMap

Simple implementation of the RenameMap interface.

Author:
The OGSA-DAI Project Team.

Constructor Summary
SimpleRenameMap()
          Constructor.
SimpleRenameMap(java.util.List<Attribute> originalAttrList, java.util.List<Attribute> renamedAttrList)
          Constructor.
 
Method Summary
 void add(Attribute originalAttribute, Attribute renamedAttribute)
          Adds the attribute mapping from original to renamed attribute.
 Attribute getOriginalAttribute(Attribute renamedAttribute)
          Get original (input) attribute.
 java.util.List<Attribute> getOriginalAttributeList()
          Get an ordered list of original attributes.
 RenameMap getOriginalToRenamedMap(java.util.List<Attribute> attributeList)
          Gets a map of original attributes as keys and renamed attributes as values
 Attribute getRenamedAttribute(Attribute originalAttribute)
          Get renamed (output) attribute.
 java.util.List<Attribute> getRenamedAttributeList()
          Get an ordered list of renamed attributes.
 RenameMap getRenamedToOriginalMap(java.util.Collection<Attribute> attributes)
          Gets a map with renamed attributes as keys and original attributes as values.
 void removeRenamedAttribute(Attribute attr)
          Removes the renamed attributes for the renaming list.
 void resetRenamedAttributeSources(java.lang.String newSource)
          Resets source in each attribute that belongs to the renamed attributes list.
 void setAttributeMatchMode(AttributeMatchMode matchMode)
          Sets attribute match mode.
 int size()
          Gets the number of entries in the map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleRenameMap

public SimpleRenameMap()
Constructor.


SimpleRenameMap

public SimpleRenameMap(java.util.List<Attribute> originalAttrList,
                       java.util.List<Attribute> renamedAttrList)
Constructor.

Parameters:
originalAttrList - a list of original attributes
renamedAttrList - a list of renamed attributes
Method Detail

add

public void add(Attribute originalAttribute,
                Attribute renamedAttribute)
Adds the attribute mapping from original to renamed attribute. Attributes are cloned by this method before being stored.

Specified by:
add in interface RenameMap
Parameters:
originalAttribute - original (input) attribute
renamedAttribute - renamed (output) attribute

getOriginalAttribute

public Attribute getOriginalAttribute(Attribute renamedAttribute)
                               throws AmbiguousAttributeException,
                                      AmbiguousMappingException
Get original (input) attribute.

Specified by:
getOriginalAttribute in interface RenameMap
Parameters:
renamedAttribute - renamed (output) attribute
Returns:
original (input) attribute or null if no mapping exists
Throws:
AmbiguousAttributeException - when renamed attribute is not unique in the list of renamed attributes
AmbiguousMappingException - when an attribute could map to several original attributes if we would to ignore positioning

getRenamedAttribute

public Attribute getRenamedAttribute(Attribute originalAttribute)
                              throws AmbiguousAttributeException,
                                     AmbiguousMappingException
Get renamed (output) attribute.

Specified by:
getRenamedAttribute in interface RenameMap
Parameters:
originalAttribute - original (input) attribute
Returns:
renamed attribute or null if no mapping exists
Throws:
AmbiguousAttributeException - when original attribute is not unique in the list of original attributes
AmbiguousMappingException - when an attribute could map to several renamed attributes if we would to ignore positioning (id, id, id) -> (id, id, ident)

getOriginalAttributeList

public java.util.List<Attribute> getOriginalAttributeList()
Get an ordered list of original attributes.

Specified by:
getOriginalAttributeList in interface RenameMap
Returns:
list of original attributes

getRenamedAttributeList

public java.util.List<Attribute> getRenamedAttributeList()
Get an ordered list of renamed attributes.

Specified by:
getRenamedAttributeList in interface RenameMap
Returns:
list of renamed attributes

resetRenamedAttributeSources

public void resetRenamedAttributeSources(java.lang.String newSource)
Resets source in each attribute that belongs to the renamed attributes list.

Specified by:
resetRenamedAttributeSources in interface RenameMap
Parameters:
newSource - new source name

getRenamedToOriginalMap

public RenameMap getRenamedToOriginalMap(java.util.Collection<Attribute> attributes)
                                  throws AmbiguousMappingException,
                                         AmbiguousAttributeException
Gets a map with renamed attributes as keys and original attributes as values.

Specified by:
getRenamedToOriginalMap in interface RenameMap
Parameters:
attributes - a collection of renamed attributes
Returns:
renamed to original map
Throws:
AmbiguousMappingException - if an attribute maps to an attribute in attributeList
AmbiguousAttributeException - if there are several possible mappings

getOriginalToRenamedMap

public RenameMap getOriginalToRenamedMap(java.util.List<Attribute> attributeList)
                                  throws AmbiguousMappingException,
                                         AmbiguousAttributeException
Gets a map of original attributes as keys and renamed attributes as values

Specified by:
getOriginalToRenamedMap in interface RenameMap
Parameters:
attributeList - a list of original attributes
Returns:
original to renamed map
Throws:
AmbiguousMappingException - if an attribute maps to an attribute in attributeList
AmbiguousAttributeException - if there are several possible mappings

size

public int size()
Gets the number of entries in the map.

Specified by:
size in interface RenameMap
Returns:
number of entries in the map.

removeRenamedAttribute

public void removeRenamedAttribute(Attribute attr)
Removes the renamed attributes for the renaming list.

Specified by:
removeRenamedAttribute in interface RenameMap
Parameters:
attr - renamed attribute to be removed.

setAttributeMatchMode

public void setAttributeMatchMode(AttributeMatchMode matchMode)
Sets attribute match mode. The default attribute match mode is assumed to be NAME_AND_NULL_SOURCE.

Specified by:
setAttributeMatchMode in interface RenameMap

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object