类 ExecutionContext
- java.lang.Object
- org.springframework.batch.item.ExecutionContext
- 所有已实现的接口:
java.io.Serializable
public class ExecutionContext extends java.lang.Object implements java.io.Serializable
Object representing a context for anItemStream. It is a thin wrapper for a map that allows optionally for type safety on reads. It also allows for dirty checking by setting a 'dirty' flag whenever any put is called. Note that puttingnullvalue is equivalent to removing the entry for the given key.- 作者:
- Lucas Ward, Douglas Kaminsky, Mahmoud Ben Hassine
- 另请参阅:
- 序列化表格
构造器概要
构造器 构造器 说明 ExecutionContext()Default constructor.ExecutionContext(java.util.Map<java.lang.String,java.lang.Object> map)Initializes a new execution context with the contents of another map.ExecutionContext(ExecutionContext executionContext)Initializes a newExecutionContextwith the contents of anotherExecutionContext.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidclearDirtyFlag()Clears the dirty flag.booleancontainsKey(java.lang.String key)Indicates whether or not a key is represented in this context.booleancontainsValue(java.lang.Object value)Indicates whether or not a value is represented in this context.java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()Returns the entry set containing the contents of this context.booleanequals(java.lang.Object obj)java.lang.Objectget(java.lang.String key)Getter for the value represented by the provided key.doublegetDouble(java.lang.String key)Typesafe Getter for the Double represented by the provided key.doublegetDouble(java.lang.String key, double defaultDouble)Typesafe Getter for the Double represented by the provided key with default value to return if key is not represented.intgetInt(java.lang.String key)Typesafe Getter for the Integer represented by the provided key.intgetInt(java.lang.String key, int defaultInt)Typesafe Getter for the Integer represented by the provided key with default value to return if key is not represented.longgetLong(java.lang.String key)Typesafe Getter for the Long represented by the provided key.longgetLong(java.lang.String key, long defaultLong)Typesafe Getter for the Long represented by the provided key with default value to return if key is not represented.java.lang.StringgetString(java.lang.String key)Typesafe Getter for the String represented by the provided key.java.lang.StringgetString(java.lang.String key, java.lang.String defaultString)Typesafe Getter for the String represented by the provided key with default value to return if key is not represented.inthashCode()booleanisDirty()Indicates if context has been changed with a "put" operation since the dirty flag was last cleared.booleanisEmpty()Indicates whether or not the context is empty.voidput(java.lang.String key, java.lang.Object value)Add an Object value to the context.voidputDouble(java.lang.String key, double value)Add a Double value to the context.voidputInt(java.lang.String key, int value)Adds an Integer value to the context.voidputLong(java.lang.String key, long value)Adds a Long value to the context.voidputString(java.lang.String key, java.lang.String value)Adds a String value to the context.java.lang.Objectremove(java.lang.String key)Removes the mapping for a key from this context if it is present.intsize()Returns number of entries in the contextjava.lang.StringtoString()
构造器详细资料
ExecutionContext
public ExecutionContext()
Default constructor. Initializes a new execution context with an empty internal map.
ExecutionContext
public ExecutionContext(java.util.Map<java.lang.String,java.lang.Object> map)
Initializes a new execution context with the contents of another map.- 参数:
map- Initial contents of context.
ExecutionContext
public ExecutionContext(ExecutionContext executionContext)
Initializes a newExecutionContextwith the contents of anotherExecutionContext.- 参数:
executionContext- containing the entries to be copied to this current context.
方法详细资料
putString
public void putString(java.lang.String key, @Nullable java.lang.String value)
Adds a String value to the context. Puttingnullvalue for a given key removes the key.- 参数:
key- Key to add to contextvalue- Value to associate with key
putLong
public void putLong(java.lang.String key, long value)
Adds a Long value to the context.- 参数:
key- Key to add to contextvalue- Value to associate with key
putInt
public void putInt(java.lang.String key, int value)
Adds an Integer value to the context.- 参数:
key- Key to add to contextvalue- Value to associate with key
putDouble
public void putDouble(java.lang.String key, double value)
Add a Double value to the context.- 参数:
key- Key to add to contextvalue- Value to associate with key
put
public void put(java.lang.String key, @Nullable java.lang.Object value)
Add an Object value to the context. Puttingnullvalue for a given key removes the key.- 参数:
key- Key to add to contextvalue- Value to associate with key
isDirty
public boolean isDirty()
Indicates if context has been changed with a "put" operation since the dirty flag was last cleared. Note that the last time the flag was cleared might correspond to creation of the context.- 返回:
- True if "put" operation has occurred since flag was last cleared
getString
public java.lang.String getString(java.lang.String key)
Typesafe Getter for the String represented by the provided key.- 参数:
key- The key to get a value for- 返回:
- The
Stringvalue
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultString)
Typesafe Getter for the String represented by the provided key with default value to return if key is not represented.- 参数:
key- The key to get a value fordefaultString- Default to return if key is not represented- 返回:
- The
Stringvalue if key is represented, specified default otherwise
getLong
public long getLong(java.lang.String key)
Typesafe Getter for the Long represented by the provided key.- 参数:
key- The key to get a value for- 返回:
- The
Longvalue
getLong
public long getLong(java.lang.String key, long defaultLong)
Typesafe Getter for the Long represented by the provided key with default value to return if key is not represented.- 参数:
key- The key to get a value fordefaultLong- Default to return if key is not represented- 返回:
- The
longvalue if key is represented, specified default otherwise
getInt
public int getInt(java.lang.String key)
Typesafe Getter for the Integer represented by the provided key.- 参数:
key- The key to get a value for- 返回:
- The
Integervalue
getInt
public int getInt(java.lang.String key, int defaultInt)
Typesafe Getter for the Integer represented by the provided key with default value to return if key is not represented.- 参数:
key- The key to get a value fordefaultInt- Default to return if key is not represented- 返回:
- The
intvalue if key is represented, specified default otherwise
getDouble
public double getDouble(java.lang.String key)
Typesafe Getter for the Double represented by the provided key.- 参数:
key- The key to get a value for- 返回:
- The
Doublevalue
getDouble
public double getDouble(java.lang.String key, double defaultDouble)
Typesafe Getter for the Double represented by the provided key with default value to return if key is not represented.- 参数:
key- The key to get a value fordefaultDouble- Default to return if key is not represented- 返回:
- The
doublevalue if key is represented, specified default otherwise
get
@Nullable public java.lang.Object get(java.lang.String key)
Getter for the value represented by the provided key.- 参数:
key- The key to get a value for- 返回:
- The value represented by the given key or
nullif the key is not present
isEmpty
public boolean isEmpty()
Indicates whether or not the context is empty.- 返回:
- True if the context has no entries, false otherwise.
- 另请参阅:
Map.isEmpty()
clearDirtyFlag
public void clearDirtyFlag()
Clears the dirty flag.
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
Returns the entry set containing the contents of this context.- 返回:
- A set representing the contents of the context
- 另请参阅:
Map.entrySet()
containsKey
public boolean containsKey(java.lang.String key)
Indicates whether or not a key is represented in this context.- 参数:
key- Key to check existence for- 返回:
- True if key is represented in context, false otherwise
- 另请参阅:
Map.containsKey(Object)
remove
@Nullable public java.lang.Object remove(java.lang.String key)
Removes the mapping for a key from this context if it is present.- 参数:
key-Stringthat identifies the entry to be removed from the context.- 返回:
- the value that was removed from the context.
- 另请参阅:
Map.remove(Object)
containsValue
public boolean containsValue(java.lang.Object value)
Indicates whether or not a value is represented in this context.- 参数:
value- Value to check existence for- 返回:
- True if value is represented in context, false otherwise
- 另请参阅:
Map.containsValue(Object)
equals
public boolean equals(java.lang.Object obj)
- 覆盖:
equals在类中java.lang.Object
hashCode
public int hashCode()
- 覆盖:
hashCode在类中java.lang.Object
toString
public java.lang.String toString()
- 覆盖:
toString在类中java.lang.Object
size
public int size()
Returns number of entries in the context- 返回:
- Number of entries in the context
- 另请参阅:
Map.size()