org.malai.mapping
Class Object2ObjectMapping<S,T>

java.lang.Object
  extended by org.malai.mapping.Object2ObjectMapping<S,T>
Type Parameters:
S - The type of the source object of the mapping.
T - The type of the target object of the mapping.
All Implemented Interfaces:
IMapping
Direct Known Subclasses:
Drawing2CanvasMapping, Package2TextViewMapping, Shape2BorderMapping, Shape2ViewMapping, Unit2ScaleRuler, Zoom2ScaleRuler

public abstract class Object2ObjectMapping<S,T>
extends java.lang.Object
implements IMapping

This interface defines the concept of mapping that link a source object to a target object.

This file is part of Malai.
Copyright (c) 2009-2012 Arnaud BLOUIN

Malai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Malai is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

05/16/2010

Since:
0.2
Version:
0.2
Author:
Arnaud BLOUIN

Field Summary
protected  S sourceObject
          The source object.
protected  T targetObject
          The target object.
 
Constructor Summary
Object2ObjectMapping(S source, T target)
          Creates the mapping.
 
Method Summary
 void clear()
          Removes the references of the mapped objects of the mapping to avoid memory leaks.
 S getSource()
          Returns the source object of the mapping.
 T getTarget()
          Returns the target object of the mapping.
 void init()
          At start, the mapping must be executed one time to initialise the binding between source and target objects.
 void onListCleaned(java.lang.Object list)
          Executes the mapping when all the elements of the source were removed.
 void onObjectAdded(java.lang.Object list, java.lang.Object object, int index)
          Executes the mapping for the addition of an object.
 void onObjectMoved(java.lang.Object list, java.lang.Object object, int srcIndex, int targetIndex)
          Executes the mapping for the move of an object.
 void onObjectRemoved(java.lang.Object list, java.lang.Object object, int index)
          Executes the mapping for the deletion of an object.
 void onObjectReplaced(IUnary<?> object, java.lang.Object replacedObject)
          Executes the mapping when an object has been replaced by an other one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.malai.mapping.IMapping
onObjectModified
 

Field Detail

sourceObject

protected S sourceObject
The source object.


targetObject

protected T targetObject
The target object.

Constructor Detail

Object2ObjectMapping

public Object2ObjectMapping(S source,
                            T target)
Creates the mapping.

Parameters:
source - The source object.
target - The target object.
Throws:
java.lang.IllegalArgumentException - If one of the given arguments is null or if they are the same object.
Since:
0.2
Method Detail

getSource

public S getSource()
Description copied from interface: IMapping
Returns the source object of the mapping. If there is several source objects, a collection is returned.

Specified by:
getSource in interface IMapping
Returns:
The source object of the mapping.

getTarget

public T getTarget()
Description copied from interface: IMapping
Returns the target object of the mapping. If there is several target objects, a collection is returned.

Specified by:
getTarget in interface IMapping
Returns:
The source object of the mapping.

onObjectAdded

public void onObjectAdded(java.lang.Object list,
                          java.lang.Object object,
                          int index)
Description copied from interface: IMapping
Executes the mapping for the addition of an object.

Specified by:
onObjectAdded in interface IMapping
Parameters:
list - The modified source list.
object - The added object.
index - The position where the object has been added. -1 = the last position.

onObjectMoved

public void onObjectMoved(java.lang.Object list,
                          java.lang.Object object,
                          int srcIndex,
                          int targetIndex)
Description copied from interface: IMapping
Executes the mapping for the move of an object.

Specified by:
onObjectMoved in interface IMapping
Parameters:
list - The modified source list.
object - The move object.
srcIndex - The source position of the object. -1 = the last position.
targetIndex - The target position of the object. -1 = the last position.

onObjectRemoved

public void onObjectRemoved(java.lang.Object list,
                            java.lang.Object object,
                            int index)
Description copied from interface: IMapping
Executes the mapping for the deletion of an object.

Specified by:
onObjectRemoved in interface IMapping
Parameters:
list - The modified source list.
object - The deleted object.
index - The position where the object has been deleted. -1 = the last position.

onListCleaned

public void onListCleaned(java.lang.Object list)
Description copied from interface: IMapping
Executes the mapping when all the elements of the source were removed.

Specified by:
onListCleaned in interface IMapping
Parameters:
list - The list before the cleaning, i.e. it still contains all the elements in order to know which elements have been removed.

onObjectReplaced

public void onObjectReplaced(IUnary<?> object,
                             java.lang.Object replacedObject)
Description copied from interface: IMapping
Executes the mapping when an object has been replaced by an other one.

Specified by:
onObjectReplaced in interface IMapping
Parameters:
object - The singleton that contains the new object.
replacedObject - The old object contained in the singleton that has been replaced.

init

public void init()
Description copied from interface: IMapping
At start, the mapping must be executed one time to initialise the binding between source and target objects.

Specified by:
init in interface IMapping

clear

public void clear()
Description copied from interface: IMapping
Removes the references of the mapped objects of the mapping to avoid memory leaks.

Specified by:
clear in interface IMapping