package edu.calpoly.cpe205.fetter; import javax.swing.*; import java.util.*; import java.io.*; import java.lang.reflect.*; import java.lang.*; import java.awt.*; import javax.swing.event.*; import java.awt.event.*; import java.sql.Time; /** * This class represents a Returned Object returned from a user invoked * method. It provides methods that give information about a Returned * Object's type, origin, and value. It also provides methods to remove the * Returned Object and to move the Returned Object to * the Test Data Items tab of the Object Pool. */ // Author: Wesley Strickland // Version History: // Nov 20, 2000 - comments/pseudocode added // Nov 30, 2000 - (Mike Hebron) updated class description // Jan 12, 2001 - Mike Power added accessor methods, and implemented // accessor methods // Jan 13, 2001 - Mike Power implemented Constructor // Feb 07, 2001 - (Apel Yahinian) Updated constructor, created model protected value // Changed inspectObjectValue to use model.inspect // Feb 13, 2001 - (Jonathon Lee) Added pseudocode for remove() and move() public class ReturnedData implements ReturnedDataInterface { public ReturnedData(Object data, String descName, ETAMainModel newmodel) { value = data; userDefinedName = descName; type = ETAMainModel.classToName(data.getClass()); model = newmodel; } /** * Returns the name describing the method the value was * returned from. *
* Pre-conditions: none * Post-conditions: none */ public String getOriginName() { return userDefinedName; } /** * Returns the type of object contained in ReturnedData. *
* Pre-conditions: none * Post-conditions: none */ public String getTypeName() { return type; } /** * returns the value, as type string, contained in ReturnedData. *
* Pre-conditions: none * Post-conditions: none */ public String getValue() { return value.toString(); } /** * This method checks to see if ReturnedData is a primitive data type. *
* Pre-conditions: none * Post-conditions: returns TRUE if value represented by this class is * is primitive * returns FALSE otherwise */ public boolean isPrimitive() { //RETURN boolean of (CALCULATE isPrimitive on value) String name = type; if (name.equals("java.lang.Float") || name.equals("java.lang.String") || name.equals("java.lang.Integer") || name.equals("java.lang.Byte") || name.equals("java.lang.Short") || name.equals("java.lang.Long") || name.equals("java.lang.Double") || name.equals("java.lang.Character") || name.equals("java.lang.Boolean")) return true; return false; } /** * This method invokes the ObjectInspector *
* Pre-conditions: none * Post-conditions: ObjectInspector is invoked on Object */ public void inspectObjectValue() { //CALL inspect on model with value and false model.inspect(value, userDefinedName, false); // CONSTRUCT sessionLog as NEW String String sessionLog = new String(); // session log entry /* assemble session log entry */ sessionLog = "[" + (new Time( System.currentTimeMillis())).toString().substring(0, 5) + "] Inspect '" + userDefinedName + "'"; // CALL println of log of ETA with sessionLog ETA.log.println(sessionLog); } /** * This method moves the returned data to parameterData *
* Pre-conditions: none * Post-conditions: parameterData contains returnedData */ public void move() { // CALL addParameterData on model with userDefinedName and value // CALL removeReturnedData on model with this model.addParameterData( value, userDefinedName ); model.removeReturnedData( this ); ETA.log.print( "[" ); ETA.log.print( ( new Time( System.currentTimeMillis() ) ).toString().substring( 0, 5 ) ); ETA.log.println( "] Move '" + userDefinedName + "' to Test Data Item list" ); } /** * This method moves the returned data to parameterData *
* Pre-conditions: none * Post-conditions: returnedData removed from this */ public void remove() { // CALL removeReturnedData on model with value model.removeReturnedData( this ); // CONSTRUCT sessionLog as NEW String String sessionLog = new String(); // session log entry /* assemble session log entry */ sessionLog = "[" + (new Time( System.currentTimeMillis())).toString().substring(0, 5) + "] Remove Returned Item '" + userDefinedName + "'"; // CALL println of log of ETA with sessionLog ETA.log.println(sessionLog); } /** * The name, as defined by the user, that this ParameterData should be refered to */ protected String userDefinedName; /** * The class name of the object value */ protected String type; /** * The object that this ParameterData represents */ protected Object value; /** * etamainmodel model */ protected ETAMainModel model; }