Package net.rim.device.api.script

Examples of net.rim.device.api.script.Scriptable


            if(options == null || options.equals(UNDEFINED)) {
                title = null;
                contacts = null;
            } else {
                // Title
                final Scriptable optionsObj = (Scriptable) options;
                final Object titleObj = optionsObj.getField("title");
                if(titleObj.equals(UNDEFINED)) {
                    title = null;
                } else {
                    title = (String) titleObj;
                }
               
                // Contacts
                Object contactsObj = optionsObj.getField("users");
                if(contactsObj.equals(UNDEFINED)) {
                    contacts = null;
                } else {
                    final BBMPlatformUser[] users = Util.scriptableUsersArrayToUserArray((Scriptable) contactsObj);
                    contacts = new Util.SimpleContactListProvider(users);
View Full Code Here


        /**
         * @see net.rim.device.api.script.Scriptable#getField(java.lang.String)
         */
        public Object getField( final String fieldName ) throws Exception {

            Scriptable featureImplementation = (Scriptable) _features.get( getFormattedFeatureName( fieldName ) );

            if( featureImplementation != null ) {
                return featureImplementation;
            } else {
                featureImplementation = (Scriptable) _features.get( InvokeNamespace.NAME );

                if( featureImplementation != null ) {
                    return featureImplementation.getField( fieldName );
                }
            }

            return super.getField( fieldName );
        }
View Full Code Here

        urlBuffer.append( (String) args[ 0 ] );

        // If there is params, which should be an Object represents a String array
        if( args.length == 2 ) {
            // params
            final Scriptable stringArray = (Scriptable) args[ 1 ];
            final int count = stringArray.getElementCount();
            for( int i = 0; i < count; i++ ) {
                if( i == 0 ) {
                    urlBuffer.append( "?" );
                } else {
                    urlBuffer.append( "&" );
                }

                try {
                    urlBuffer.append( stringArray.getElement( i ).toString() );
                } catch( final Exception e ) {
                    throw new IllegalArgumentException( "Problem occurred when parsing parameters. " + e.getMessage() );
                }
            }
        }
View Full Code Here

            return new CalendarArgumentsObject( a );
        } else if( args[ 0 ] instanceof Scriptable ) {
            // Re-usable method - move somewhere more convenient
            // Converting JS Date from Scriptable to java.util.Date
            try {
                final Scriptable s = (Scriptable) args[ 0 ];
                final Object getTime = s.getField( "getTime" );
                if( getTime instanceof ScriptableFunction ) {
                    final Double millis = (Double) ( (ScriptableFunction) getTime ).invoke( args[ 0 ], new Object[] {} );
                    d = new Date( millis.longValue() );
                }
            } catch( final Exception e ) {
View Full Code Here

         * In 6.0 - java.util.Date is not passed back, it is a Scriptable object representing the JavaScript Date object. Retrieve
         * the getTime() and create java.util.Date
         */
        if( value instanceof Scriptable ) {
            try {
                Scriptable s = (Scriptable) value;
                Object getTime = s.getField( "getTime" );
                if( getTime instanceof ScriptableFunction ) {
                    Double millis = (Double) ( (ScriptableFunction) getTime ).invoke( value, new Object[] {} );
                    return new Date( millis.longValue() );
                }
            } catch( Exception e ) {
View Full Code Here

        String[] categories = null;

        Object categoriesObject = field.getValue();

        if( categoriesObject instanceof Scriptable ) {
            Scriptable categoriesArray = (Scriptable) categoriesObject;
            int length = ( (Integer) categoriesArray.getField( "length" ) ).intValue();
            categories = new String[ length ];

            for( int i = 0; i < length; i++ ) {
                String category = (String) categoriesArray.getElement( i );
                categories[ i ] = category;
            }
        } else if( categoriesObject instanceof String[] ) {
            categories = (String[]) categoriesObject;
        }
View Full Code Here

        try {
            Object attendeesObject = getItem( FIELD_ATTENDEES ).getValue();

            if( attendeesObject instanceof Scriptable ) {
                Scriptable attendeesArray = (Scriptable) attendeesObject;
                int length = ( (Integer) attendeesArray.getField( "length" ) ).intValue();
                attendees = new AttendeeObject[ length ];

                for( int i = 0; i < length; i++ ) {
                    AttendeeObject attendee = (AttendeeObject) attendeesArray.getElement( i );
                    attendees[ i ] = attendee;
                }
            } else if( attendeesObject instanceof AttendeeObject[] ) {
                attendees = (AttendeeObject[]) attendeesObject;
            }
View Full Code Here

            final Object onAccessChanged = BBMPlatformNamespace.this.getField(EVENT_ON_ACCESS_CHANGED);
            if(onAccessChanged.equals(UNDEFINED)) {
                throw new IllegalStateException("blackberry.bbm.platform.onaccesschanged == undefined");
            }
           
            final Scriptable options = (Scriptable) args[0];
            final String uuid = (String) options.getField(OPTIONS_FIELD_UUID);
           
            // Get optional shareContentSplat property
            final Object shareContentSplatObj = options.getField(OPTIONS_FIELD_SHARECONTENTSPLAT);
            boolean shareContentSplat;
            try {
                shareContentSplat = ((Boolean) shareContentSplatObj).booleanValue();
            } catch(Exception e) {
                shareContentSplat = false;
View Full Code Here

    /**
     * @see ScriptableFunctionBase#execute(Object, Object[])
     */
    protected Object execute( Object thiz, Object[] args ) throws Exception {
        Scriptable obj = (Scriptable) args[ 0 ];
        int port = ( (Integer) obj.getField( KEY_PORT ) ).intValue();
        String wakeUpPage = obj.getField( KEY_WAKEUP_PAGE ).toString();
        int maxQueueCap = 0;
        Object maxQueueCapObj = obj.getField( KEY_MAX_QUEUE_CAP );
        if( maxQueueCapObj != UNDEFINED ) {
            maxQueueCap = ( (Integer) maxQueueCapObj ).intValue();
        }
        ScriptableFunction onData = (ScriptableFunction) args[ 1 ];
        ScriptableFunction onSimChange = (ScriptableFunction) args[ 2 ];
View Full Code Here

     * @see ScriptableFunctionBase#validateArgs(Object[])
     */
    protected void validateArgs( Object[] args ) {
        super.validateArgs( args );

        Scriptable obj = (Scriptable) args[ 0 ];
        try {
            Object port = obj.getField( KEY_PORT );
            if( port != null && port != UNDEFINED ) {
                int portValue = ( (Integer) port ).intValue();
                if( portValue < 0 ) {
                    throw new IllegalArgumentException( "Invalid port." );
                } else if( !PushService.isValidPort( portValue ) ) {
                    throw new IllegalArgumentException( "Reserved port" );
                }
            } else {
                throw new IllegalArgumentException( "Port is missing." );
            }
            Object wakeUpPage = obj.getField( KEY_WAKEUP_PAGE );
            if( wakeUpPage == null || wakeUpPage == UNDEFINED ) {
                throw new IllegalArgumentException( "AppId is missing." );
            }
        } catch( Exception e ) {
            throw new IllegalArgumentException( "Error retrieving arguments: " + e.getMessage() );
View Full Code Here

TOP

Related Classes of net.rim.device.api.script.Scriptable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.