/*
 * File:           NominaHandlerImpl.java
 * Date:           November 11, 2002  1:01 AM
 *
 * @author  gustavo
 * @version generated by NetBeans XML module
 */
import org.xml.sax.*;
import java.util.Hashtable;

public class NominaHandlerHashImpl implements NominaHandler {
    
    public static final boolean DEBUG = true;
    private Hashtable hash;
    
    public NominaHandlerHashImpl() {
        hash = new Hashtable();
        
    }    
   
    public Hashtable getHashTable(){
       return hash;   
    }
    
    public Empleado empleadoActual =null;
    public void start_empleado(final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("start_empleado: " + meta);
        //obtener campo llave primaria
        String llave=meta.getValue("llaveprimaria");
       //insertar nuevo empleado
        Hashtable hsh = (Hashtable) hash.get("empleados");
        empleadoActual =new Empleado(); 
        hsh.put(llave,empleadoActual);
    }
    
    public void end_empleado() throws SAXException {
        if (DEBUG) System.err.println("end_empleado()");
        empleadoActual=null;
    }
    
    private boolean empleados = false;
    public void start_empleados(final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("start_empleados: " + meta);
        Hashtable hsh = new Hashtable();
        hash.put("empleados",hsh);
        
        empleados=true;
    }
    
    public void end_empleados() throws SAXException {
        if (DEBUG) System.err.println("end_empleados()");
        empleados=false;
    }
    
    public void handle_apellidoPaterno(final java.lang.String data, final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("handle_apellidoPaterno: " + data);
        if (empleadoActual!=null && empleados){
         empleadoActual.setApellidopaterno(data);
        }
    }
    
    public void handle_apellidoMaterno(final java.lang.String data, final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("handle_apellidoMaterno: " + data);
        if (empleadoActual!=null && empleados){
         empleadoActual.setApellidomaterno(data);
        }
    }
    
    public void handle_nombre(final java.lang.String data, final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("handle_nombre: " + data);
        if (empleadoActual!=null && empleados){
         empleadoActual.setNombre(data);
        }
    }
    
    public void handle_edad(final java.lang.String data, final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("handle_edad: " + data);
        if (empleadoActual!=null && empleados){
         empleadoActual.setEdad(new Integer(data).intValue());
        }
    }
    
    private boolean sueldos=false;
    public void start_sueldos(final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("start_sueldos: " + meta);
        hash.put("sueldos",new Hashtable());
        sueldos=true;
    }
    
    public void end_sueldos() throws SAXException {
        if (DEBUG) System.err.println("end_sueldos()");
        sueldos = false;
    }
    
    private Sueldo sueldoActual;
    
    public void start_sueldo(final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("start_sueldo: " + meta);
         //obtener campo llave primaria
        String llave=meta.getValue("llaveprimaria");
       //insertar nuevo sueldo
        Hashtable hsh = (Hashtable) hash.get("sueldos");
        sueldoActual =new Sueldo(); 
        hsh.put(llave,sueldoActual);
    }
    
    public void end_sueldo() throws SAXException {
        if (DEBUG) System.err.println("end_sueldo()");
        sueldoActual=null;
    }
    
    public void handle_cantidad(final java.lang.String data, final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("handle_cantidad: " + data);
        
    if (sueldoActual!=null && sueldos){
         sueldoActual.setCantidad(new Double(data).doubleValue());
        }
    }
    
    public void start_nomina(final Attributes meta) throws SAXException {
        if (DEBUG) System.err.println("start_nomina: " + meta);
    }
    
    public void end_nomina() throws SAXException {
        if (DEBUG) System.err.println("end_nomina()");
    }
    
}

