Package net.sf.isolation.bean

Examples of net.sf.isolation.bean.IsoBeanPropertyManager


          });
    } else {
      if (properties instanceof String[]) {
        String[] strings = (String[]) properties;
        int l = strings.length;
        IsoBeanPropertyManager beanPropertyManager = context
            .getInstance(IsoBeanPropertyManager.class);
        encodeProperty0(writer,
            beanPropertyManager.getProperty(object, strings[0]));
        if (l > 1) {
          for (int i = 1; i < l; i++) {
            writer.write(',');
            encodeProperty0(writer,
                beanPropertyManager.getProperty(object,
                    strings[i]));
          }
        }
      } else {
        if (properties instanceof Collection) {
          @SuppressWarnings("unchecked")
          Iterator<String> strings = ((Collection<String>) properties)
              .iterator();
          IsoBeanPropertyManager beanPropertyManager = context
              .getInstance(IsoBeanPropertyManager.class);
          encodeProperty0(
              writer,
              beanPropertyManager.getProperty(object,
                  strings.next()));
          while (strings.hasNext()) {
            writer.write(',');
            encodeProperty0(
                writer,
                beanPropertyManager.getProperty(object,
                    strings.next()));
          }
        } else {
          throw new IllegalArgumentException(properties.getClass()
              .getName());
View Full Code Here


    this.context = context;
  }

  public void copy(final Object sourceBean, final Object targetBean) {
    final IsoLog log = context.getInstance(IsoLog.class);
    final IsoBeanPropertyManager propertyManager = context
        .getInstance(IsoBeanPropertyManager.class);
    propertyManager.invoke(targetBean, new IsoSetterCallback() {
      private Object value;

      public boolean execute(String propertyName, Class<?> type) {
        try {
          Object value = propertyManager.getProperty(sourceBean,
              propertyName);
          try {
            this.value = context.getInstance(
                IsoConversionManager.class)
                .convert(value, type);
View Full Code Here

  }

  public Object process(ResultSet resultSet) throws SQLException {
    IsoLog log = context.getLog();
    IsoReflectionManager reflectionManager = context.getReflectionManager();
    IsoBeanPropertyManager propertyManager = context
        .getBeanPropertyManager();
    log.debug("Processing: {0}", klass);
    List<Object> list = new ArrayList<Object>();
    ResultSetMetaData metaData = resultSet.getMetaData();
    int columnCount = metaData.getColumnCount();
    String[] columnNames = new String[columnCount];
    for (int i = 0; i < columnCount; i++) {
      String columnName = metaData.getColumnName(i + 1);
      columnNames[i] = columnName;
      log.trace("Catch of column: {0}", columnName);
    }
    while (resultSet.next()) {
      Object bean = reflectionManager.newInstance(klass);
      for (int i = 0; i < columnCount; i++) {
        String columnName = columnNames[i];
        IsoSQLResultSetProcessorColumnInfo columnInfo = columnsInfo
            .get(columnName);
        Object value;
        Class<?> type;
        switch (columnTypeConverter.getColumnType(columnInfo.getType())) {
        case FLOAT:
          value = Float.valueOf(resultSet.getFloat(i + 1));
          type = Float.class;
          break;
        case DOUBLE:
          value = Double.valueOf(resultSet.getDouble(i + 1));
          type = Double.class;
          break;
        case STRING:
          value = resultSet.getString(i + 1);
          type = String.class;
          break;
        case INTEGER:
          value = Integer.valueOf(resultSet.getInt(i + 1));
          type = Integer.class;
          break;
        case LONG:
          value = Long.valueOf(resultSet.getLong(i + 1));
          type = Long.class;
          break;
        case DATE:
          value = resultSet.getDate(i + 1);
          type = Date.class;
          break;
        default:
          continue;
        }
        propertyManager.setProperty(bean, type, columnInfo.getName(),
            value);
      }
      list.add(bean);
    }
    log.debug("List size: {0}", Integer.valueOf(list.size()));
View Full Code Here

      PreparedStatement statement = connection.prepareStatement(sql);
      IsoSQLExpressionParameterInformation[] parametersInformation = query
          .getParametersInformation();
      if (parametersInformation != null
          && parametersInformation.length > 0 && bean != null) {
        IsoBeanPropertyManager propertyManager = context
            .getBeanPropertyManager();
        for (IsoSQLExpressionParameterInformation parameterInformation : parametersInformation) {
          log.trace(parameterInformation);
          statement.setObject(parameterInformation.getIndex(),
              propertyManager.getProperty(bean,
                  parameterInformation.getName()));
        }
      }
      try {
        ResultSet resultSet = statement.executeQuery();
View Full Code Here

    this.context = context;
  }

  public void copy(final Object sourceBean, final Object targetBean) {
    final IsoLog log = context.getLog();
    final IsoBeanPropertyManager propertyManager = context
        .getBeanPropertyManager();
    propertyManager.invoke(targetBean, new IsoSetterCallback() {
      private Object value;

      public boolean execute(String propertyName, Class<?> type) {
        try {
          Object value = propertyManager.getProperty(sourceBean,
              propertyName);
          try {
            this.value = context.getConversionManager().convert(
                type, value);
            return true;
View Full Code Here

      CallableStatement statement = connection.prepareCall(sql);
      IsoSPExpressionParameterInformation[] parametersInformation = sp
          .getParametersInformation();
      if (parametersInformation != null
          && parametersInformation.length > 0 && bean != null) {
        IsoBeanPropertyManager propertyManager = context
            .getBeanPropertyManager();
        for (IsoSPExpressionParameterInformation parameterInformation : parametersInformation) {
          log.trace(parameterInformation);
          statement.setObject(parameterInformation.getIndex(),
              propertyManager.getProperty(bean,
                  parameterInformation.getName()));
        }
      }
      try {
        if (statement.execute()) {
View Full Code Here

      throws SQLException {
    if (resultType == List.class) {
      IsoLog log = context.getInstance(IsoLog.class);
      IsoReflectionManager reflectionManager = context
          .getInstance(IsoReflectionManager.class);
      IsoBeanPropertyManager propertyManager = context
          .getInstance(IsoBeanPropertyManager.class);
      IsoColumnTypeConverter columnTypeConverter = context
          .getInstance(IsoColumnTypeConverter.class);
      log.debug("Processing: {0}", klass);
      List<Object> list = new ArrayList<Object>();
      ResultSetMetaData metaData = resultSet.getMetaData();
      int columnCount = metaData.getColumnCount();
      String[] columnNames = new String[columnCount];
      for (int i = 0; i < columnCount; i++) {
        String columnName = metaData.getColumnName(i + 1);
        columnNames[i] = columnName;
        log.trace("Catch of column: {0}", columnName);
      }
      while (resultSet.next()) {
        Object bean = reflectionManager.newInstance(klass);
        for (int i = 0; i < columnCount; i++) {
          String columnName = columnNames[i];
          IsoSQLResultSetProcessorColumnInfo columnInfo = columnsInfo
              .get(columnName);
          Object value;
          Class<?> type;
          switch (columnTypeConverter.getColumnType(columnInfo
              .getType())) {
          case FLOAT:
            value = Float.valueOf(resultSet.getFloat(i + 1));
            type = Float.class;
            break;
          case DOUBLE:
            value = Double.valueOf(resultSet.getDouble(i + 1));
            type = Double.class;
            break;
          case STRING:
            value = resultSet.getString(i + 1);
            type = String.class;
            break;
          case INTEGER:
            value = Integer.valueOf(resultSet.getInt(i + 1));
            type = Integer.class;
            break;
          case LONG:
            value = Long.valueOf(resultSet.getLong(i + 1));
            type = Long.class;
            break;
          case DATE:
            value = resultSet.getDate(i + 1);
            type = Date.class;
            break;
          default:
            continue;
          }
          propertyManager.setProperty(bean, type,
              columnInfo.getName(), value);
        }
        list.add(bean);
      }
      log.debug("List size: {0}", Integer.valueOf(list.size()));
View Full Code Here

TOP

Related Classes of net.sf.isolation.bean.IsoBeanPropertyManager

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.