// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/Creature.java
// public class Creature extends CommonModel {
// 
//     public String name;
//     public CreatureType type;
//     public Date birthDate;
//     public Date deathDate;
//     public CreatureState state;
//     public boolean alive;
//     public Gender gender;
// 
//     /**
//      * A convenience method for testing
//      * 
//      * @return A basic creature object
//      */
//     public static Creature createDefaultCreature() {
//         CreatureType type = new CreatureType();
//         type.id = 1;
//         type.name = "Default";
// 
//         Creature c = new Creature();
//         c.name = "Default Creature";
//         c.type = type;
//         c.birthDate = new Date();
//         c.state = new CreatureState();
//         c.alive = true;
//         c.gender = Gender.FEMALE;
//         return c;
//     }
// 
//     /**
//      * Create A Creature Simple function to call when a person leaves the
//      * creature-creation screen, and gets used to save the creature.
//      * 
//      * @author Hannes Vermeire
//      * @return The creature.
//      */
//     public static Creature createCreature(String name, Gender gender,
//             CreatureType type) {
//         Creature c = new Creature();
//         c.name = name;
//         c.type = type;
//         c.birthDate = new Date();
//         c.gender = gender;
//         c.state = new CreatureState();
//         c.alive = true;
//         c.gender = gender;
//         return c;
//     }
// 
// }
// 
// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/CreatureType.java
// public class CreatureType extends CommonModel {
// 
//     public String name;
// }
// 
// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/Gender.java
// public enum Gender {
//     MALE("M"), FEMALE("F");
// 
//     private String dbValue;
// 
//     Gender(String dbChar) {
//         dbValue = dbChar;
//     }
// 
//     public String getDbValue() {
//         return dbValue;
//     }
// 
//     public static Gender fromDbValue(String dbValue) {
//         for (Gender g : Gender.values()) {
//             if (dbValue.equals(g.getDbValue())) {
//                 return g;
//             }
//         }
//         return null;
//     }
// }


import java.util.Date;
import android.database.Cursor;
import com.redditandroiddevelopers.tamagotchi.model.Creature;
import com.redditandroiddevelopers.tamagotchi.model.CreatureType;
import com.redditandroiddevelopers.tamagotchi.model.Gender;
package com.redditandroiddevelopers.tamagotchi.mappers;




/**
 * The row mapper for Creature objects (CREATURE_INFO database table).
 * 
 * @author Jeffrey Selk
 * 
 */
public class CreatureMapper extends Mapper<Creature> {

    /**
     * Map a Cursor object from the DB to a Creature object
     * 
     * @param cursor
     *            Result from the DB query
     * @return The row-mapped Creature object
     */
    public Creature mapRow(Object obj) {
        if (obj instanceof Cursor) {
            Cursor cursor = (Cursor) obj;
            // assume only one row here
            Creature c = new Creature();
            c.id = cursor.getLong(cursor.getColumnIndex("CI_ID"));
            c.name = cursor.getString(cursor.getColumnIndex("CI_NAME"));
            CreatureType type = new CreatureType();
// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/Creature.java
// public class Creature extends CommonModel {
// 
//     public String name;
//     public CreatureType type;
//     public Date birthDate;
//     public Date deathDate;
//     public CreatureState state;
//     public boolean alive;
//     public Gender gender;
// 
//     /**
//      * A convenience method for testing
//      * 
//      * @return A basic creature object
//      */
//     public static Creature createDefaultCreature() {
//         CreatureType type = new CreatureType();
//         type.id = 1;
//         type.name = "Default";
// 
//         Creature c = new Creature();
//         c.name = "Default Creature";
//         c.type = type;
//         c.birthDate = new Date();
//         c.state = new CreatureState();
//         c.alive = true;
//         c.gender = Gender.FEMALE;
//         return c;
//     }
// 
//     /**
//      * Create A Creature Simple function to call when a person leaves the
//      * creature-creation screen, and gets used to save the creature.
//      * 
//      * @author Hannes Vermeire
//      * @return The creature.
//      */
//     public static Creature createCreature(String name, Gender gender,
//             CreatureType type) {
//         Creature c = new Creature();
//         c.name = name;
//         c.type = type;
//         c.birthDate = new Date();
//         c.gender = gender;
//         c.state = new CreatureState();
//         c.alive = true;
//         c.gender = gender;
//         return c;
//     }
// 
// }
// 
// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/CreatureType.java
// public class CreatureType extends CommonModel {
// 
//     public String name;
// }
// 
// Path: Tamagotchi/src/com/redditandroiddevelopers/tamagotchi/model/Gender.java
// public enum Gender {
//     MALE("M"), FEMALE("F");
// 
//     private String dbValue;
// 
//     Gender(String dbChar) {
//         dbValue = dbChar;
//     }
// 
//     public String getDbValue() {
//         return dbValue;
//     }
// 
//     public static Gender fromDbValue(String dbValue) {
//         for (Gender g : Gender.values()) {
//             if (dbValue.equals(g.getDbValue())) {
//                 return g;
//             }
//         }
//         return null;
//     }
// }


// Path: Tamagotchi-android/src/com/redditandroiddevelopers/tamagotchi/mappers/CreatureMapper.java
import java.util.Date;
import android.database.Cursor;
import com.redditandroiddevelopers.tamagotchi.model.Creature;
import com.redditandroiddevelopers.tamagotchi.model.CreatureType;
import com.redditandroiddevelopers.tamagotchi.model.Gender;

package com.redditandroiddevelopers.tamagotchi.mappers;




/**
 * The row mapper for Creature objects (CREATURE_INFO database table).
 * 
 * @author Jeffrey Selk
 * 
 */
public class CreatureMapper extends Mapper<Creature> {

    /**
     * Map a Cursor object from the DB to a Creature object
     * 
     * @param cursor
     *            Result from the DB query
     * @return The row-mapped Creature object
     */
    public Creature mapRow(Object obj) {
        if (obj instanceof Cursor) {
            Cursor cursor = (Cursor) obj;
            // assume only one row here
            Creature c = new Creature();
            c.id = cursor.getLong(cursor.getColumnIndex("CI_ID"));
            c.name = cursor.getString(cursor.getColumnIndex("CI_NAME"));
            CreatureType type = new CreatureType();
            type.id = cursor.getInt(cursor.getColumnIndex("CT_ID"));