IN PROGRESS - BATCH-907: Integer support in ExecutionContext
added int support to EC
This commit is contained in:
@@ -91,7 +91,17 @@ public class ExecutionContext implements Serializable {
|
||||
*/
|
||||
public void putLong(String key, long value) {
|
||||
|
||||
put(key, new Long(value));
|
||||
put(key, Long.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an Integer value to the context.
|
||||
*
|
||||
* @param key Key to add to context
|
||||
* @param value Value to associate with key
|
||||
*/
|
||||
public void putInt(String key, int value) {
|
||||
put(key, Integer.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +112,7 @@ public class ExecutionContext implements Serializable {
|
||||
*/
|
||||
public void putDouble(String key, double value) {
|
||||
|
||||
put(key, new Double(value));
|
||||
put(key, Double.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +200,34 @@ public class ExecutionContext implements Serializable {
|
||||
return ((Long) readAndValidate(key, Long.class)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Typesafe Getter for the Integer represented by the provided key.
|
||||
*
|
||||
* @param key The key to get a value for
|
||||
* @return The <code>Integer</code> value
|
||||
*/
|
||||
public int getInt(String key) {
|
||||
|
||||
return ((Integer) readAndValidate(key, Integer.class)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Typesafe Getter for the Integer represented by the provided key with
|
||||
* default value to return if key is not represented.
|
||||
*
|
||||
* @param key The key to get a value for
|
||||
* @param defaultInt Default to return if key is not represented
|
||||
* @return The <code>int</code> value if key is represented, specified
|
||||
* default otherwise
|
||||
*/
|
||||
public int getInt(String key, int defaultInt) {
|
||||
if (!map.containsKey(key)) {
|
||||
return defaultInt;
|
||||
}
|
||||
|
||||
return ((Integer) readAndValidate(key, Integer.class)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Typesafe Getter for the Double represented by the provided key.
|
||||
*
|
||||
|
||||
@@ -101,9 +101,9 @@ public class MultiResourceItemWriter<T> extends ExecutionContextUserSupport impl
|
||||
}
|
||||
|
||||
public void open(ExecutionContext executionContext) throws ItemStreamException {
|
||||
resourceIndex = Long.valueOf(executionContext.getLong(getKey(RESOURCE_INDEX_KEY), 1L)).intValue();
|
||||
currentResourceItemCount = Long.valueOf(executionContext.getLong(getKey(CURRENT_RESOURCE_ITEM_COUNT), 0L))
|
||||
.intValue();
|
||||
resourceIndex = executionContext.getInt(getKey(RESOURCE_INDEX_KEY), 1);
|
||||
currentResourceItemCount = executionContext.getInt(getKey(CURRENT_RESOURCE_ITEM_COUNT), 0);
|
||||
|
||||
try {
|
||||
pointDelegateToNextResource();
|
||||
}
|
||||
@@ -115,8 +115,8 @@ public class MultiResourceItemWriter<T> extends ExecutionContextUserSupport impl
|
||||
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
delegate.update(executionContext);
|
||||
executionContext.put(getKey(CURRENT_RESOURCE_ITEM_COUNT), Long.valueOf(currentResourceItemCount));
|
||||
executionContext.put(getKey(RESOURCE_INDEX_KEY), Long.valueOf(resourceIndex));
|
||||
executionContext.putInt(getKey(CURRENT_RESOURCE_ITEM_COUNT), currentResourceItemCount);
|
||||
executionContext.putInt(getKey(RESOURCE_INDEX_KEY), resourceIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user