From ebfe82006d1115053b161df9e886fe2f00498707 Mon Sep 17 00:00:00 2001 From: robokaso Date: Tue, 12 Aug 2008 07:55:30 +0000 Subject: [PATCH] IN PROGRESS - BATCH-756: Upgrade JdbcExecutionContextDao to use enums AttributeType converted to enum --- .../dao/JdbcExecutionContextDao.java | 36 ++----------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java index 6d565a6c1..d0dd3a998 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java @@ -245,38 +245,8 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem /** * Attribute types supported by the {@link ExecutionContext}. */ - private static class AttributeType { - - private final String type; - - private AttributeType(String type) { - this.type = type; - } - - public String toString() { - return type; - } - - public static final AttributeType STRING = new AttributeType("STRING"); - - public static final AttributeType LONG = new AttributeType("LONG"); - - public static final AttributeType OBJECT = new AttributeType("OBJECT"); - - public static final AttributeType DOUBLE = new AttributeType("DOUBLE"); - - private static final AttributeType[] VALUES = { STRING, OBJECT, LONG, DOUBLE }; - - public static AttributeType getType(String typeAsString) { - - for (int i = 0; i < VALUES.length; i++) { - if (VALUES[i].toString().equals(typeAsString)) { - return (AttributeType) VALUES[i]; - } - } - - return null; - } + private enum AttributeType { + STRING, OBJECT, LONG, DOUBLE } /** @@ -295,7 +265,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem public void processRow(ResultSet rs) throws SQLException { String typeCd = rs.getString("TYPE_CD"); - AttributeType type = AttributeType.getType(typeCd); + AttributeType type = AttributeType.valueOf(typeCd); String key = rs.getString("KEY_NAME"); if (type == AttributeType.STRING) { executionContext.putString(key, rs.getString("STRING_VAL"));