edu.bonn.cs.sems.impl.context
Class ContextCommons

java.lang.Object
  extended by edu.bonn.cs.sems.impl.context.ContextCommons
All Implemented Interfaces:
Context, java.io.Serializable, java.lang.Comparable<Context>
Direct Known Subclasses:
ContextImpl, ContextRdfImpl

public abstract class ContextCommons
extends java.lang.Object
implements Context

This is a helper superclass providing common helper methods to its subclasses Intended to be a superclass for context interface implementations

Author:
Bihler
See Also:
Serialized Form

Field Summary
static java.util.Comparator<Context> idComparator
          Can be used to compare two contexts by Id Typical use is sorting
 
Fields inherited from interface edu.bonn.cs.sems.model.context.Context
SENSOR_BROWSER_MOBILITY, SENSOR_BROWSER_ORIENTATION, SENSOR_BROWSER_SCREEN_DIMENSION, SENSOR_CONNECTION_SPEED, SENSOR_REGION, SENSOR_TIME_DAY, SENSOR_TIME_DAYOFWEEK, SENSOR_TIME_HOUR, SENSOR_TIME_MINUTE, SENSOR_TIME_MONTH, SENSOR_TIME_YEAR, SENSOR_TIME_ZONE, SENSOR_USER_AGE, SENSOR_USER_GENDER, SENSOR_USER_LANGUAGE
 
Method Summary
 int compareTo(Context otherObject)
           
 boolean equals(java.lang.Object o)
          Compares this Context with another Object
 java.lang.String getDescription()
          Gets the simple description of the context
 Context[] getFlatContexts()
          Creates a new context which sensor values are merged from the current one recursively together with the sub contexts' values.
 java.util.List<Context> getFlatContextsAsList()
          Creates a new context which sensor values are merged from the current one recursively together with the sub contexts' values.
 java.lang.String getId()
          Gets the id of the context
 int hashCode()
           
 boolean inContext(Context otherContext)
          Tests if this context is included in another context
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.bonn.cs.sems.model.context.Context
addSubContext, addValue, getSensors, getSubContexts, getValue, getValues, isExclusiveSubContexts, removeSubContext, removeValue, setExclusiveSubContexts
 

Field Detail

idComparator

public static final java.util.Comparator<Context> idComparator
Can be used to compare two contexts by Id Typical use is sorting

Method Detail

getId

public java.lang.String getId()
Description copied from interface: Context
Gets the id of the context

Specified by:
getId in interface Context
Returns:
The id

getDescription

public java.lang.String getDescription()
Description copied from interface: Context
Gets the simple description of the context

Specified by:
getDescription in interface Context
Returns:
The description

compareTo

public int compareTo(Context otherObject)
Specified by:
compareTo in interface java.lang.Comparable<Context>

getFlatContexts

public Context[] getFlatContexts()
Description copied from interface: Context
Creates a new context which sensor values are merged from the current one recursively together with the sub contexts' values. If the exclusiveSubContexts flag is set, returns as many contexts as there are sub-contexts

Specified by:
getFlatContexts in interface Context
Returns:
An array of Contexts which do not contain sub contexts

getFlatContextsAsList

public java.util.List<Context> getFlatContextsAsList()
Description copied from interface: Context
Creates a new context which sensor values are merged from the current one recursively together with the sub contexts' values. If the exclusiveSubContexts flag is set, returns as many contexts as there are sub-contexts

Specified by:
getFlatContextsAsList in interface Context
Returns:
A List of Context which do not contain sub contexts. Not thread-save.

inContext

public boolean inContext(Context otherContext)
Description copied from interface: Context
Tests if this context is included in another context

Specified by:
inContext in interface Context
Parameters:
otherContext - The other Context this context is compared against
Returns:
true if this contest is completely included in the other, false otherwise

equals

public boolean equals(java.lang.Object o)
Description copied from interface: Context
Compares this Context with another Object

Specified by:
equals in interface Context
Overrides:
equals in class java.lang.Object
Parameters:
o - Another object, e.g. another Context
Returns:
True, if both contexts contain the same sensors and values

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object