randoop.util
Class PrimitiveTypes

Object
  extended by PrimitiveTypes

public final class PrimitiveTypes
extends Object


Field Summary
Modifier and Type Field and Description
static Map<Class<?>,Boolean> isPrimitiveCached
           
protected static Map<String,Class<?>> typeNameToPrimitiveOrString
           
 
Method Summary
Modifier and Type Method and Description
static Class<?> boxedType(Class<?> c1)
           
static Class<?> getBoxedType(String typeName)
           
static Set<Class<?>> getBoxedTypesAndString()
           
static Class<?> getPrimitiveTypeOrString(String typeName)
           
static Set<Class<?>> getPrimitiveTypesAndString()
           
static Class<?> getUnboxType(Class<?> c)
           
static boolean isBoxedOrPrimitiveOrStringType(Class<?> c)
           
static boolean isBoxedPrimitiveTypeOrString(Class<?> c)
           
static boolean isPrimitive(Class<?> c)
          Same as c.isPrimitive() but faster if this test is done very frequently (as it is in Randoop).
static boolean isPrimitiveOrStringType(Class<?> type)
           
static boolean isPrimitiveOrStringTypeName(String typeName)
           
static boolean looksLikeObjectToString(String s)
          Returns true if the given string looks like it came from a call of Object.toString(); in other words, looks something like "@".
static Class<?> primitiveType(Class<? extends Object> c)
          Returns null if c is not a primitive or a boxed type.
static boolean stringLengthOK(String s)
          Returns true if the given string is deemed to be reasonable (i.e.
static String toCodeString(Object value)
          Given a primitive, boxed primitive, or String, returns a String that can be uesd in Java source to represent it.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeNameToPrimitiveOrString

protected static final Map<String,Class<?>> typeNameToPrimitiveOrString

isPrimitiveCached

public static Map<Class<?>,Boolean> isPrimitiveCached
Method Detail

isPrimitiveOrStringTypeName

public static boolean isPrimitiveOrStringTypeName(String typeName)

getBoxedType

public static Class<?> getBoxedType(String typeName)

getPrimitiveTypeOrString

public static Class<?> getPrimitiveTypeOrString(String typeName)

getPrimitiveTypesAndString

public static Set<Class<?>> getPrimitiveTypesAndString()

getBoxedTypesAndString

public static Set<Class<?>> getBoxedTypesAndString()

boxedType

public static Class<?> boxedType(Class<?> c1)

isBoxedPrimitiveTypeOrString

public static boolean isBoxedPrimitiveTypeOrString(Class<?> c)

isPrimitiveOrStringType

public static boolean isPrimitiveOrStringType(Class<?> type)

isPrimitive

public static boolean isPrimitive(Class<?> c)
Same as c.isPrimitive() but faster if this test is done very frequently (as it is in Randoop).


isBoxedOrPrimitiveOrStringType

public static boolean isBoxedOrPrimitiveOrStringType(Class<?> c)

primitiveType

public static Class<?> primitiveType(Class<? extends Object> c)
Returns null if c is not a primitive or a boxed type.


toCodeString

public static String toCodeString(Object value)
Given a primitive, boxed primitive, or String, returns a String that can be uesd in Java source to represent it.

Parameters:
value - the value to create a String representation for. The value's type must be a primitive type, a String, or null.

getUnboxType

public static Class<?> getUnboxType(Class<?> c)

looksLikeObjectToString

public static boolean looksLikeObjectToString(String s)
Returns true if the given string looks like it came from a call of Object.toString(); in other words, looks something like "@". Such strings are rarely useful in generation because they contain non-reproducible hash strings. This method is actually more restrictive in what it determines to look like it came from Object.toString(): it deems anything that matches the pattern .*@[0-9a-h]{1,8}.* Meaning, if it looks like the string contains the telltale "@" pattern, the method returns false. This almost always works and is a faster check.


stringLengthOK

public static boolean stringLengthOK(String s)
Returns true if the given string is deemed to be reasonable (i.e. not too long) based on the --string-maxlen=N parameter.

If Randoop generates tests using strings that are too long, this can result in non-compilable tests due to the JVM's limit on the length of a string.

A string S is too long if, when printed as code in a generated unit test, it may result in a non-compilable test. In order to determine this, we have to consider not the length of s, but the length of the string that would be printed to obtain s, which may be different due to escaped and unicode characters. This method takes this into account.

See Also:
GenInputsAbstract