Logo of Bento frameworkspaceObject Oriented Programming


Example Map4String interface for RequestStore


package com.bentofw.requeststore;

import java.sql.*;
import com.bentofw.util.*;

/**
 * Map4String implementation for Long.
 *
 * @author Jun Inamori
 */
public class LongMap
   implements Map4String{

    public byte[] columnToBytesInUtf8
                  (ResultSet rs,
                   int columnindex)
	throws NestedException{
	try{
	    return (Long.toString(
                    rs.getLong(columnindex))).
                    getBytes("UTF-8");
	}
	catch(Exception ex){
	    throw new NestedException(ex);
	}
    }

    public void javaToColumn
                (PreparedStatement st,
                 int columnindex,
                 Object value)
	throws NestedException{
	if(value instanceof java.lang.String){
	    try{
		st.setLong(columnindex,
                   Long.parseLong((String)value)
                   );
	    }
	    catch(Exception ex){
		throw new NestedException(ex);
	    }
	}
	else{
	    try{
		st.setLong(columnindex,
                   ((Long)value).longValue()
                   );
	    }
	    catch(Exception ex){
		throw new NestedException(ex);
	    }
	}
    }

} //End of : LongMap


Copyright © 1997-2007 OOP-Research CorporationTM, All Rights Reserved.