public function cast(JavaProxy $object, $type)
    {
        $code = strtoupper($type[0]);
        switch ($code) {
            case 'S':
                return $this->invokeMethod(0, 'castToString', [$object]);
            case 'B':
                return $this->invokeMethod(0, 'castToBoolean', [$object]);
            case 'L':
            case 'I':
                return $this->invokeMethod(0, 'castToExact', [$object]);
            case 'D':
            case 'F':
                return $this->invokeMethod(0, 'castToInExact', [$object]);
            case 'N':
                return null;
            case 'A':
                return $this->invokeMethod(0, 'castToArray', [$object]);
            case 'O':
                return $object;
            default:
                throw new Exception\RuntimeException("Illegal type '$code' for casting");
        }
    }
public function cast(JavaProxy $object, $type)
    {
        $code = strtoupper($type[0]);
        switch ($code) {
            case 'S':
                return $this->invokeMethod(0, 'castToString', [$object]);
            case 'B':
                return $this->invokeMethod(0, 'castToBoolean', [$object]);
            case 'L':
            case 'I':
                return $this->invokeMethod(0, 'castToExact', [$object]);
            case 'D':
            case 'F':
                return $this->invokeMethod(0, 'castToInExact', [$object]);
            case 'N':
                return null;
            case 'A':
                return $this->invokeMethod(0, 'castToArray', [$object]);
            case 'O':
                return $object;
            default:
                throw new Exception\RuntimeException("Illegal type '$code' for casting");
        }
    }
public function cast ( JavaProxy $ object , $ type ) { $ code = strtoupper ( $ type [ 0 ] ) ; switch ( $ code ) { case 'S' : return $ this -> invokeMethod ( 0 , 'castToString' , [ $ object ] ) ; case 'B' : return $ this -> invokeMethod ( 0 , 'castToBoolean' , [ $ object ] ) ; case 'L' : case 'I' : return $ this -> invokeMethod ( 0 , 'castToExact' , [ $ object ] ) ; case 'D' : case 'F' : return $ this -> invokeMethod ( 0 , 'castToInExact' , [ $ object ] ) ; case 'N' : return null ; case 'A' : return $ this -> invokeMethod ( 0 , 'castToArray' , [ $ object ] ) ; case 'O' : return $ object ; default : throw new Exception \ RuntimeException ( "Illegal type '$code' for casting" ) ; } }
Cast an object to a certain type.

@param JavaProxy $object
@param string    $type

@return mixed

@throws Exception\RuntimeException
Cast an object to a certain type .