}
private Condition processRoom(Rule rule,
Configuration config) throws FactoryException
{
Configuration childConfig = null;
final String roomName = config.getAttribute( "name" );
final Declaration roomDeclaration = getDeclaration( rule,
Room.class,
roomName );
Condition condition = null;
Configuration[] configurations = config.getChildren( );
for ( int i = 0; i < configurations.length; i++ )
{
childConfig = configurations[i];
if ( childConfig.getName( ).equals( "temperature" ) )
{
final Declaration[] declarations = new Declaration[]{roomDeclaration};
childConfig = childConfig.getChildren( )[0];
final int kelvin = getKelvin( childConfig.getAttribute( "scale" ),
childConfig.getText( ) );
if ( childConfig.getName( ).equals( "less-than" ) )
{
condition = new Condition( )
{
public Declaration[] getRequiredTupleMembers()
{
return declarations;
}
public boolean isAllowed(Tuple tuple) throws ConditionException
{
Room room = (Room) tuple.get( roomDeclaration );
if (!roomName.equals(room.getName()))
{
return false;
}
if ( room.getTemperature( ) < kelvin )
{
return true;
}
else
{
return false;
}
}
};
}
else if ( childConfig.getName( ).equals( "greater-than" ) )
{
condition = new Condition( )
{
public Declaration[] getRequiredTupleMembers()
{