com.greenpepper.interpreter.collection.CollectionInterpreter Maven / Gradle / Ivy
/*
* Copyright (c) 2006 Pyxis Technologies inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA,
* or see the FSF site: http://www.fsf.org.
*/
package com.greenpepper.interpreter.collection;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import com.greenpepper.Call;
import com.greenpepper.Example;
import static com.greenpepper.GreenPepper.canContinue;
import static com.greenpepper.GreenPepper.shouldStop;
import com.greenpepper.Specification;
import com.greenpepper.Statistics;
import com.greenpepper.TypeConversion;
import com.greenpepper.annotation.Annotations;
import static com.greenpepper.annotation.Annotations.exception;
import static com.greenpepper.annotation.Annotations.ignored;
import com.greenpepper.call.Annotate;
import com.greenpepper.call.Compile;
import com.greenpepper.interpreter.AbstractInterpreter;
import com.greenpepper.interpreter.HeaderForm;
import com.greenpepper.reflect.CollectionProvider;
import com.greenpepper.reflect.Fixture;
import com.greenpepper.reflect.NoSuchMessageException;
import com.greenpepper.util.StringUtil;
// TODO: STATS compile stats here and in derived classes ( no test for that yet )
/**
* Abstract CollectionInterpreter class.
*
* @author oaouattara
* @version $Id: $Id
*/
public abstract class CollectionInterpreter extends AbstractInterpreter
{
private final Fixture fixture;
protected final Statistics stats = new Statistics();
/**
* statistics.
*
* @return a {@link com.greenpepper.Statistics} object.
*/
public Statistics statistics()
{
return this.stats;
}
/**
* Constructor for CollectionInterpreter.
*
* @param fixture a {@link com.greenpepper.reflect.Fixture} object.
*/
protected CollectionInterpreter( Fixture fixture )
{
this.fixture = fixture;
}
/**
* toList.
*
* @param results a {@link java.lang.Object} object.
* @return a {@link java.util.List} object.
*/
protected List> toList( Object results )
{
if (results instanceof Object[])
{
return Arrays.asList( (Object[]) results );
}
if (results instanceof Collection)
{
return new ArrayList