站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

MapSqlParameterSource (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.jdbc.core.namedparam
Class MapSqlParameterSource

java.lang.Object
  extended by org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
      extended by org.springframework.jdbc.core.namedparam.MapSqlParameterSource
All Implemented Interfaces:
SqlParameterSource

public class MapSqlParameterSource
extends AbstractSqlParameterSource

SqlParameterSource implementation that holds a given Map of parameters.

This class is intended for passing in a simple Map of parameter values to the methods of the NamedParameterJdbcTemplate class.

The addValue methods on this class will make adding several values easier. The methods return a reference to the MapSqlParameterSource itself, so you can chain several method calls together within a single statement.

Since:
2.0
Author:
Thomas Risberg, Juergen Hoeller
See Also:
addValue(String, Object), addValue(String, Object, int), AbstractSqlParameterSource.registerSqlType(java.lang.String, int), NamedParameterJdbcTemplate

Field Summary
 
Fields inherited from interface org.springframework.jdbc.core.namedparam.SqlParameterSource
TYPE_UNKNOWN
 
Constructor Summary
MapSqlParameterSource()
          Create an empty MapSqlParameterSource, with values to be added via addValue.
MapSqlParameterSource(Map values)
          Create a new MapSqlParameterSource based on a Map.
MapSqlParameterSource(String paramName, Object value)
          Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.
 
Method Summary
 MapSqlParameterSource addValue(String paramName, Object value)
          Add a parameter to this parameter source.
 MapSqlParameterSource addValue(String paramName, Object value, int sqlType)
          Add a parameter to this parameter source.
 MapSqlParameterSource addValues(Map values)
          Add a Map of parameters to this parameter source.
 Object getValue(String paramName)
          Return the parameter value for the requested named parameter.
 Map getValues()
          Expose the current parameter values as read-only Map.
 boolean hasValue(String paramName)
          Determine whether there is a value for the specified named parameter.
 
Methods inherited from class org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
getSqlType, registerSqlType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapSqlParameterSource

public MapSqlParameterSource()
Create an empty MapSqlParameterSource, with values to be added via addValue.

See Also:
addValue(String, Object)

MapSqlParameterSource

public MapSqlParameterSource(String paramName,
                             Object value)
Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.

Parameters:
paramName - the name of the parameter
value - the value of the parameter
See Also:
addValue(String, Object)

MapSqlParameterSource

public MapSqlParameterSource(Map values)
Create a new MapSqlParameterSource based on a Map.

Parameters:
values - a Map holding existing parameter values (can be null)
Method Detail

addValue

public MapSqlParameterSource addValue(String paramName,
                                      Object value)
Add a parameter to this parameter source.

Parameters:
paramName - the name of the parameter
value - the value of the parameter
Returns:
a reference to this parameter source, so it's possible to chain several calls together

addValue

public MapSqlParameterSource addValue(String paramName,
                                      Object value,
                                      int sqlType)
Add a parameter to this parameter source.

Parameters:
paramName - the name of the parameter
value - the value of the parameter
sqlType - the SQL type of the parameter
Returns:
a reference to this parameter source, so it's possible to chain several calls together

addValues

public MapSqlParameterSource addValues(Map values)
Add a Map of parameters to this parameter source.

Parameters:
values - a Map holding existing parameter values (can be null)
Returns:
a reference to this parameter source, so it's possible to chain several calls together

getValues

public Map getValues()
Expose the current parameter values as read-only Map.


hasValue

public boolean hasValue(String paramName)
Description copied from interface: SqlParameterSource
Determine whether there is a value for the specified named parameter.

Parameters:
paramName - the name of the parameter
Returns:
whether there is a value defined

getValue

public Object getValue(String paramName)
Description copied from interface: SqlParameterSource
Return the parameter value for the requested named parameter.

Parameters:
paramName - the name of the parameter
Returns:
the value of the specified parameter

The Spring Framework

Copyright © 2002-2007 The Spring Framework.