package runEnv; import java.util.*; public class Cast { public static boolean booleanValue( Object object ) { if ( object instanceof Boolean ) return ( ( Boolean ) object ).booleanValue(); else throw new Error( "Can't cast \"" + object + "\" to Boolean" ); } public static int intValue( Object object ) { if ( object instanceof Integer ) return ( ( Integer ) object ).intValue(); else throw new Error( "Can't cast \"" + object + "\" to Integer" ); } public static char charValue( Object object ) { if ( object instanceof Character ) return ( ( Character ) object ).charValue(); else throw new Error( "Can't cast \"" + object + "\" to Character" ); } public static String stringValue( Object object ) { if ( object instanceof String ) return ( String ) object; else throw new Error( "Can't cast \"" + object + "\" to String" ); } public static FunctionValue functionValue( Object object ) { if ( object instanceof FunctionValue ) return ( FunctionValue ) object; else throw new Error( "Can't cast \"" + object + "\" to Function" ); } public static Vector< Object > arrayValue( Object object ) { if ( object instanceof Vector ) return ( Vector< Object > ) object; else throw new Error( "Can't cast \"" + object + "\" to array" ); } public static NullValue nullValue( Object object ) { if ( object instanceof NullValue ) return ( NullValue ) object; else throw new Error( "Can't cast \"" + object + "\" to NullValue" ); } }