Package net.sf.okapi.common
Class BaseContext
- java.lang.Object
-
- net.sf.okapi.common.BaseContext
-
- All Implemented Interfaces:
IContext
- Direct Known Subclasses:
BatchItemContext,ExecutionContext
public class BaseContext extends Object implements IContext
Basic implementation of theIContextinterface.
-
-
Constructor Summary
Constructors Constructor Description BaseContext()Creates an empty context.BaseContext(Map<String,Object> properties)Creates a BaseContext object and copy a map of properties.
-
Method Summary
All Methods Instance Methods Concrete 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
public String getString(String name)
Description copied from interface:IContextGets a string property of this context.
-
setString
public void setString(String name, String value)
Description copied from interface:IContextSets a string property for this context. If the property is already defined its value will be overwritten.
-
getBoolean
public boolean getBoolean(String name)
Description copied from interface:IContextGets a boolean property of this context.- Specified by:
getBooleanin interfaceIContext- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or false if it is not defined.
-
setBoolean
public void setBoolean(String name, boolean value)
Description copied from interface:IContextSets a boolean property for this context. If the property is already defined its value will be overwritten.- Specified by:
setBooleanin interfaceIContext- Parameters:
name- the name of the property to set.value- the value to set.
-
getInteger
public int getInteger(String name)
Description copied from interface:IContextGets an integer property of this context.- Specified by:
getIntegerin interfaceIContext- Parameters:
name- the name of the property to retrieve.- Returns:
- the value of the property or 0 if it is not defined.
-
setInteger
public void setInteger(String name, int value)
Description copied from interface:IContextSets an integer property for this context. If the property is already defined its value will be overwritten.- Specified by:
setIntegerin interfaceIContext- Parameters:
name- the name of the property to set.value- the value to set.
-
getObject
public Object getObject(String name)
Description copied from interface:IContextGets an object property of this context.
-
setObject
public void setObject(String name, Object value)
Description copied from interface:IContextSets an object property for this context. If the property is already defined its value will be overwritten.
-
removeProperty
public void removeProperty(String name)
Description copied from interface:IContextRemoves a given property from this context. If the property does not exist nothing happens.- Specified by:
removePropertyin interfaceIContext- Parameters:
name- the name of the property to remove.
-
getProperties
public Map<String,Object> getProperties()
Description copied from interface:IContextGets the map of the existing properties for this context.- Specified by:
getPropertiesin interfaceIContext- Returns:
- the map of the properties for this context. May be empty but not null.
-
clearProperties
public void clearProperties()
Description copied from interface:IContextRemoves all properties from this context.- Specified by:
clearPropertiesin interfaceIContext
-
getAnnotation
public <A extends IAnnotation> A getAnnotation(Class<A> type)
Description copied from interface:IContextGets the annotation of a given type for this context.- Specified by:
getAnnotationin interfaceIContext- 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
public void setAnnotation(IAnnotation annotation)
Description copied from interface:IContextSets an annotation for this context.- Specified by:
setAnnotationin interfaceIContext- Parameters:
annotation- the annotation to set. If one of this type already exists it will be overwritten.
-
clearAnnotations
public void clearAnnotations()
Description copied from interface:IContextRemoves all annotations from this context.- Specified by:
clearAnnotationsin interfaceIContext
-
-