randoop
Class PrimitiveOrStringOrNullDecl

Object
  extended by PrimitiveOrStringOrNullDecl
All Implemented Interfaces:
Serializable, StatementKind

public final class PrimitiveOrStringOrNullDecl
extends Object
implements StatementKind, Serializable

Represents a primitive value (including Strings). This type of statement doesn't actually transform any state, but it works out nicely to represent primitives as statements. This decl info is for primitives, strings and nulls (of any type).

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
static String ID
          ID for parsing purposes (see StatementKinds.parse method)
 
Constructor Summary
Constructor and Description
PrimitiveOrStringOrNullDecl(Class<?> t, Object o)
          Constructs a PrimitiveOrStringOrNullDeclInfo of type t and value o
 
Method Summary
Modifier and Type Method and Description
 void appendCode(Variable newVar, List<Variable> inputVars, StringBuilder b)
          Produces a Java source code representation of this statement and append it to the given StringBuilder.
 boolean equals(Object o)
          Indicates whether this PrimitiveOrStringOrNullDeclInfo is equal to o
 ExecutionOutcome execute(Object[] statementInput, PrintStream out)
          Executes this statement, given the inputs to the statement.
 List<Class<?>> getInputTypes()
          Extracts the input constraints for this PrimitiveOrStringOrNullDeclInfo
 Class<?> getOutputType()
          Returns constraint to represent new reference to this statement
 Class<?> getType()
           
 Object getValue()
          Returns the value of this PrimitiveOrStringOrNullDeclInfo
 int hashCode()
          Returns a hash code value for this PrimitiveOrStringOrNullDeclInfo
static PrimitiveOrStringOrNullDecl nullOrZeroDecl(Class<?> c)
          Returns the appropriate PrimitiveOrStringOrNullDeclInfo representative of the specified class c.
static PrimitiveOrStringOrNullDecl parse(String s)
          A string representing this primitive declaration.
static Sequence sequenceForPrimitive(Object o)
          Returns the sequence corresponding to the given non-null primitive value.
 String toParseableString()
          Returns a string representation of this StatementKind, which can subsequently be used in this class's parse method.
 String toString()
          Returns string representation of this PrimitiveOrStringOrNullDeclInfo
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
ID for parsing purposes (see StatementKinds.parse method)

See Also:
Constant Field Values
Constructor Detail

PrimitiveOrStringOrNullDecl

public PrimitiveOrStringOrNullDecl(Class<?> t,
                                   Object o)
Constructs a PrimitiveOrStringOrNullDeclInfo of type t and value o

Method Detail

equals

public boolean equals(Object o)
Indicates whether this PrimitiveOrStringOrNullDeclInfo is equal to o

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this PrimitiveOrStringOrNullDeclInfo

Overrides:
hashCode in class Object

toString

public String toString()
Returns string representation of this PrimitiveOrStringOrNullDeclInfo

Overrides:
toString in class Object

execute

public ExecutionOutcome execute(Object[] statementInput,
                                PrintStream out)
Executes this statement, given the inputs to the statement. Returns the results of execution as an ResultOrException object and can output results to specified PrintStream.

Specified by:
execute in interface StatementKind
Parameters:
statementInput - array containing appropriate inputs to statement
out - stream to output results of execution; can be null if you don't want to print.
Returns:
results of executing this statement

getInputTypes

public List<Class<?>> getInputTypes()
Extracts the input constraints for this PrimitiveOrStringOrNullDeclInfo

Specified by:
getInputTypes in interface StatementKind
Returns:
list of input constraints

appendCode

public void appendCode(Variable newVar,
                       List<Variable> inputVars,
                       StringBuilder b)
Description copied from interface: StatementKind
Produces a Java source code representation of this statement and append it to the given StringBuilder.

Specified by:
appendCode in interface StatementKind

getValue

public Object getValue()
Returns the value of this PrimitiveOrStringOrNullDeclInfo


getType

public Class<?> getType()
Returns:
Returns the type.

getOutputType

public Class<?> getOutputType()
Returns constraint to represent new reference to this statement

Specified by:
getOutputType in interface StatementKind

nullOrZeroDecl

public static PrimitiveOrStringOrNullDecl nullOrZeroDecl(Class<?> c)
Returns the appropriate PrimitiveOrStringOrNullDeclInfo representative of the specified class c.


toParseableString

public String toParseableString()
Description copied from interface: StatementKind
Returns a string representation of this StatementKind, which can subsequently be used in this class's parse method. For a class C implementing the StatementKind interface, this method should return a String s such that parsing the string returns an object equivalent to this object, i.e. C.parse(this.s).equals(this).

Specified by:
toParseableString in interface StatementKind

sequenceForPrimitive

public static Sequence sequenceForPrimitive(Object o)
Returns the sequence corresponding to the given non-null primitive value. Requires: o != null and o is a boxed primitive or String.


parse

public static PrimitiveOrStringOrNullDecl parse(String s)
                                         throws StatementKindParseException
A string representing this primitive declaration. The string is of the form: TYPE:VALUE Where TYPE is the type of the primitive declaration, and VALUE is its value. If VALUE is "null" then the value is null (not the String "null"). If TYPE is "char" then (char)Integer.parseInt(VALUE, 16) yields the character value. Examples: String:null represents: String x = null java.lang.String:"" represents: String x = ""; String:"" represents: String x = ""; String:" " represents: String x = " "; String:"\"" represents: String x = "\""; String:"\n" represents: String x = "\n"; String:"" represents: String x = ""; java.lang.Object:null represents: Object x = null; [[Ljava.lang.Object;:null represents: Object[][] = null; int:0 represents: int x = 0; boolean:false represents: boolean x = false; char:20 represents: char x = ' '; Note that a string type can be given as both "String" or "java.lang.String".

Throws:
StatementKindParseException