Package net.sf.okapi.common
Interface IContext
-
- All Known Implementing Classes:
BaseContext,BatchItemContext,ExecutionContext
public interface IContextCommon set of methods to provide context information.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearAnnotations()Removes all annotations from this context.voidclearProperties()Removes all properties from this context.<A extends IAnnotation>
AgetAnnotation(Class<A> type)Gets the annotation of a given type for this context.booleangetBoolean(String name)Gets a boolean property of this context.intgetInteger(String name)Gets an integer property of this context.ObjectgetObject(String name)Gets an object property of this context.Map<String,Object>getProperties()Gets the map of the existing properties for this context.StringgetString(String name)Gets a string property of this context.voidremoveProperty(String name)Removes a given property from this context.voidsetAnnotation(IAnnotation annotation)Sets an annotation for this context.voidsetBoolean(String name, boolean value)Sets a boolean property for this context.voidsetInteger(String name, int value)Sets an integer property for this context.voidsetObject(String name, Object value)Sets an object property for this context.voidsetString(String name, String value)Sets a string property for this context.
-
-
-
Method Detail
-
getString
String getString(String name)
Gets a string property of this context.- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or null if it not defined.
-
setString
void setString(String name, String value)
Sets a string property for this context. If the property is already defined its value will be overwritten.- Parameters:
name- the name of the property to set.value- the value to set.
-
getBoolean
boolean getBoolean(String name)
Gets a boolean property of this context.- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or false if it is not defined.
-
setBoolean
void setBoolean(String name, boolean value)
Sets a boolean property for this context. If the property is already defined its value will be overwritten.- Parameters:
name- the name of the property to set.value- the value to set.
-
getInteger
int getInteger(String name)
Gets an integer property of this context.- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or 0 if it is not defined.
-
setInteger
void setInteger(String name, int value)
Sets an integer property for this context. If the property is already defined its value will be overwritten.- Parameters:
name- the name of the property to set.value- the value to set.
-
getObject
Object getObject(String name)
Gets an object property of this context.- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or null if it is not defined.
-
setObject
void setObject(String name, Object value)
Sets an object property for this context. If the property is already defined its value will be overwritten.- Parameters:
name- the name of the property to set.value- the value to set.
-
removeProperty
void removeProperty(String name)
Removes a given property from this context. If the property does not exist nothing happens.- Parameters:
name- the name of the property to remove.
-
getProperties
Map<String,Object> getProperties()
Gets the map of the existing properties for this context.- Returns:
- the map of the properties for this context. May be empty but not null.
-
clearProperties
void clearProperties()
Removes all properties from this context.
-
getAnnotation
<A extends IAnnotation> A getAnnotation(Class<A> type)
Gets the annotation of a given type for this context.- Type Parameters:
A- the class type.- Parameters:
type- the type of the annotation to retrieve.- Returns:
- the annotation for the given type, or null if it is not defined.
-
setAnnotation
void setAnnotation(IAnnotation annotation)
Sets an annotation for this context.- Parameters:
annotation- the annotation to set. If one of this type already exists it will be overwritten.
-
clearAnnotations
void clearAnnotations()
Removes all annotations from this context.
-
-