pl.edu.agh.cast.model.mapper
Class AbstractMappable

java.lang.Object
  extended by pl.edu.agh.cast.model.mapper.AbstractMappable
All Implemented Interfaces:
Serializable, Cloneable, Mappable
Direct Known Subclasses:
DataSet, Entity, Model, Relation

@Mapping
public abstract class AbstractMappable
extends Object
implements Mappable, Serializable, Cloneable

Default implementation of the Mappable interface. The implementation should be exactly same in all implementing classes. Custom implementation is needed only if class implementing Mappable cannot extend AbstractMappable.

Author:
AGH CAST Team
See Also:
Serialized Form

Field Summary
protected  String id
          The general id of the mappable - this value is viewable by users and is designed for the data identification.
 
Constructor Summary
AbstractMappable()
           
 
Method Summary
 AbstractMappable clone()
          This method makes a shallow copy of the object.
 Object getAttribute(String name)
          Get value of attribute with given name.
 String[] getAttributeNames()
          Return all mapped attributes names.
 Class getAttributeType(String name)
          Returns the type of the attribute with given name.
 String getId()
          Domain specific id of the object.
 long getMid()
          The base model id of the object.
 String getType()
          The mapped type of the object.
 void setAttribute(String name, Object value)
          Sets the value of the attribute with given name.
 void setId(String id)
          Domain specific id setter.
 void setMid(long mid)
          Base model id setter.
 String toString()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected String id
The general id of the mappable - this value is viewable by users and is designed for the data identification. E.g. for phone number the id would be the value of the phone number (i.e. "123-456-789").

Constructor Detail

AbstractMappable

public AbstractMappable()
Method Detail

getId

@MapAttribute(typeName="mappableId")
public String getId()
Domain specific id of the object.

Specified by:
getId in interface Mappable
Returns:
The id of the object.
See Also:
Mappable.getId()

setId

public void setId(String id)
Domain specific id setter.

Specified by:
setId in interface Mappable
Parameters:
id - The id to set.
See Also:
Mappable.setId(java.lang.String)

getMid

public final long getMid()
The base model id of the object.

Specified by:
getMid in interface Mappable
Returns:
Base model id.
See Also:
Mappable.getMid()

setMid

public final void setMid(long mid)
Base model id setter.

Specified by:
setMid in interface Mappable
Parameters:
mid - to set.
See Also:
Mappable.setMid(long)

getAttribute

public final Object getAttribute(String name)
Get value of attribute with given name.

Specified by:
getAttribute in interface Mappable
Parameters:
name - the name of the attribute
Returns:
the value of the attribute

setAttribute

public final void setAttribute(String name,
                               Object value)
Sets the value of the attribute with given name.

Specified by:
setAttribute in interface Mappable
Parameters:
name - The name of the attribute.
value - The value of the attribute.
See Also:
Mappable.setAttribute(java.lang.String, java.lang.Object)

getAttributeType

public final Class getAttributeType(String name)
Returns the type of the attribute with given name.

Specified by:
getAttributeType in interface Mappable
Parameters:
name - The name of the attribute.
Returns:
The type (class) of the attribute.
See Also:
Mappable.getAttributeType(java.lang.String)

getAttributeNames

public final String[] getAttributeNames()
Return all mapped attributes names.

Specified by:
getAttributeNames in interface Mappable
Returns:
Array of attribute names

getType

public String getType()
The mapped type of the object.

Specified by:
getType in interface Mappable
Returns:
The type.
See Also:
Mappable.getType()

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

clone

public AbstractMappable clone()
This method makes a shallow copy of the object. Subclasses may override, to break the referential integrity.

Specified by:
clone in interface Mappable
Overrides:
clone in class Object
Returns:
copy of the mappable


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.