Package com.ibatis.sqlmap.engine.type

Examples of com.ibatis.sqlmap.engine.type.TypeHandler


    Document doc = newDocument("parameter");
    Probe probe = ProbeFactory.getProbe(doc);

    String complexName = mapping.getColumnName();

    TypeHandler stringTypeHandler = typeHandlerFactory.getTypeHandler(String.class);
    if (complexName.indexOf('=') > -1) {
      // old 1.x style multiple params
      StringTokenizer parser = new StringTokenizer(complexName, "{}=, ", false);
      while (parser.hasMoreTokens()) {
        String propName = parser.nextToken();
        String colName = parser.nextToken();
        Object propValue = stringTypeHandler.getResult(rs, colName);
        probe.setObject(doc, propName, propValue.toString());
      }
    } else {
      // single param
      Object propValue = stringTypeHandler.getResult(rs, complexName);
      probe.setObject(doc, "value", propValue.toString());
    }

    return doc;
  }
View Full Code Here


      StringTokenizer parser = new StringTokenizer(complexName, "{}=, ", false);
      while (parser.hasMoreTokens()) {
        String propName = parser.nextToken();
        String colName = parser.nextToken();
        Class propType = PROBE.getPropertyTypeForSetter(parameterObject, propName);
        TypeHandler propTypeHandler = typeHandlerFactory.getTypeHandler(propType);
        Object propValue = propTypeHandler.getResult(rs, colName);
        PROBE.setObject(parameterObject, propName, propValue);
      }
    } else {
      // single param
      TypeHandler propTypeHandler = typeHandlerFactory.getTypeHandler(parameterType);
      if (propTypeHandler == null) {
        propTypeHandler = typeHandlerFactory.getUnkownTypeHandler();
      }
      parameterObject = propTypeHandler.getResult(rs, complexName);
    }

    return parameterObject;
  }
View Full Code Here

    return parameterObject;
  }

  protected Object getPrimitiveResultMappingValue(ResultSet rs, ResultMapping mapping) throws SQLException {
    Object value = null;
    TypeHandler typeHandler = mapping.getTypeHandler();
    if (typeHandler != null) {
      String columnName = mapping.getColumnName();
      int columnIndex = mapping.getColumnIndex();
      if (columnName == null) {
        value = typeHandler.getResult(rs, columnIndex);
      } else {
        value = typeHandler.getResult(rs, columnName);
      }
    } else {
      throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName() + "' to the column '" + mapping.getColumnName() + "'.  One or both of the types, or the combination of types is not supported.");
    }
    return value;
View Full Code Here

    return value;
  }

  protected Object doNullMapping(Object value, ResultMapping mapping) throws SqlMapException {
      if ( value == null )  {
        TypeHandler typeHandler = mapping.getTypeHandler();
        if (typeHandler != null) {
            String nullValue = mapping.getNullValue();
            if ( nullValue != null )
              value = typeHandler.valueOf(nullValue);
            return value;
          } else {
            throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName() + "' to the column '" + mapping.getColumnName() + "'.  One or both of the types, or the combination of types is not supported.");
          }
      }
View Full Code Here

                result = ResultLoader.loadResult(client, statementName, parameterObject, targetType);

                String nullValue = mapping.getNullValue();
                if (result == null && nullValue != null) {
                    TypeHandler typeHandler = typeHandlerFactory.getTypeHandler(targetType);
                    if (typeHandler != null) {
                        result = typeHandler.valueOf(nullValue);
                    }
                }
            }
            return result;
        } catch (InstantiationException e) {
View Full Code Here

    }

    private Object preparePrimitiveParameterObject(ResultSet rs, ResultMapping mapping, Class parameterType) throws SQLException {
        Object parameterObject;
        TypeHandlerFactory typeHandlerFactory = getDelegate().getTypeHandlerFactory();
        TypeHandler th = typeHandlerFactory.getTypeHandler(parameterType);
        parameterObject = th.getResult(rs, mapping.getColumnName());
        return parameterObject;
    }
View Full Code Here

        Document doc = newDocument("parameter");
        Probe probe = ProbeFactory.getProbe(doc);

        String complexName = mapping.getColumnName();

        TypeHandler stringTypeHandler = typeHandlerFactory.getTypeHandler(String.class);
        if (complexName.indexOf('=') > -1) {
            // old 1.x style multiple params
            StringTokenizer parser = new StringTokenizer(complexName, "{}=, ", false);
            while (parser.hasMoreTokens()) {
                String propName = parser.nextToken();
                String colName = parser.nextToken();
                Object propValue = stringTypeHandler.getResult(rs, colName);
                probe.setObject(doc, propName, propValue.toString());
            }
        } else {
            // single param
            Object propValue = stringTypeHandler.getResult(rs, complexName);
            probe.setObject(doc, "value", propValue.toString());
        }

        return doc;
    }
View Full Code Here

            StringTokenizer parser = new StringTokenizer(complexName, "{}=, ", false);
            while (parser.hasMoreTokens()) {
                String propName = parser.nextToken();
                String colName = parser.nextToken();
                Class propType = PROBE.getPropertyTypeForSetter(parameterObject, propName);
                TypeHandler propTypeHandler = typeHandlerFactory.getTypeHandler(propType);
                Object propValue = propTypeHandler.getResult(rs, colName);
                PROBE.setObject(parameterObject, propName, propValue);
            }
        } else {
            // single param
            TypeHandler propTypeHandler = typeHandlerFactory.getTypeHandler(parameterType);
            if (propTypeHandler == null) {
                propTypeHandler = typeHandlerFactory.getUnkownTypeHandler();
            }
            parameterObject = propTypeHandler.getResult(rs, complexName);
        }

        return parameterObject;
    }
View Full Code Here

        return parameterObject;
    }

    protected Object getPrimitiveResultMappingValue(ResultSet rs, ResultMapping mapping) throws SQLException {
        Object value = null;
        TypeHandler typeHandler = mapping.getTypeHandler();
        if (typeHandler != null) {
            String columnName = mapping.getColumnName();
            int columnIndex = mapping.getColumnIndex();
            if (columnName == null) {
                value = typeHandler.getResult(rs, columnIndex);
            } else {
                value = typeHandler.getResult(rs, columnName);
            }
        } else {
            throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName()
                    + "' to the column '" + mapping.getColumnName()
                    + "'.  One or both of the types, or the combination of types is not supported.");
View Full Code Here

        return value;
    }

    protected Object doNullMapping(Object value, ResultMapping mapping) throws SqlMapException {
        if (value == null) {
            TypeHandler typeHandler = mapping.getTypeHandler();
            if (typeHandler != null) {
                String nullValue = mapping.getNullValue();
                if (nullValue != null)
                    value = typeHandler.valueOf(nullValue);
                return value;
            } else {
                throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName()
                        + "' to the column '" + mapping.getColumnName()
                        + "'.  One or both of the types, or the combination of types is not supported.");
View Full Code Here

TOP

Related Classes of com.ibatis.sqlmap.engine.type.TypeHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.