Package blackberry.find

Examples of blackberry.find.TestableScriptableObject


     * @return Returns list of Messages that match search criteria.
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        MessageObject[] messagesFound = null;

        TestableScriptableObject testable = null;
        int maxReturn = -1;

        if( args.length > 0 ) {
            testable = (TestableScriptableObject) args[ 0 ];
        }

        if( args.length > 1 && args[ 1 ] != null ) {
            Integer i = (Integer) args[ 1 ];
            maxReturn = i.intValue();
        }

        ServiceObject s = null;
        if( args.length > 2 ) {
            s = (ServiceObject) args[ 2 ];
        }

        Store store = null;
        ServiceConfiguration serviceConfig = null;
        if( s == null ) {
            store = Session.getDefaultInstance().getStore();
            serviceConfig = store.getServiceConfiguration();
        } else {
            try {
                serviceConfig = new ServiceConfiguration( s.getUid(), s.getCid() );
            } catch( NoSuchServiceException e ) {
                serviceConfig = null;
            } finally {
                if( serviceConfig != null ) {
                    store = Session.getInstance( serviceConfig ).getStore();
                } else {
                    store = Session.getDefaultInstance().getStore();
                    serviceConfig = store.getServiceConfiguration();
                }
            }
        }

        Vector found = new Vector();
        int iElement = 0;

        try {
            Vector v = new Vector();
            MessageUtility.getAllFoldersRecursively( store, v );
            if( v.size() == 0 ) {
                return messagesFound;
            }

            Folder[] folders = new Folder[ v.size() ];
            v.copyInto( folders );

            for( int i = folders.length - 1; i >= 0; --i ) {
                if( s != null && folders[ i ].getFullName().indexOf( ServiceConfiguration.NO_SERVICE_BOOK ) != -1 ) {
                    continue;
                }

                Folder folder = folders[ i ];
                Message[] messages = folder.getMessages();

                for( int j = 0; j < messages.length; j++ ) {
                    Message m = messages[ j ];
                    MessageObject message = new MessageObject( m, s );
                    if( testable != null ) {
                        if( testable.test( message ) ) {
                            found.addElement( message );
                            iElement++;
                        }
                    } else {
                        found.addElement( message );
View Full Code Here


     * @see blackberry.core.ScriptableFunctionBase#execute(java.lang.Object, java.lang.Object[])
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        ContactObject[] contactsFound = new ContactObject[ 0 ];

        TestableScriptableObject testable = null;
        String orderByField = "";
        int maxReturn = -1;
        String serviceName = "";
        boolean isAscending = true;

        if( !FindNamespace.isValidFindArguments( args, true ) ) {
            return contactsFound;
        }

        if( args.length > 0 ) {
            testable = (TestableScriptableObject) args[ 0 ];
        }

        if( args.length > 1 ) {
            if( args[ 1 ] != null ) {
                orderByField = (String) args[ 1 ];
            }
        }

        if( args.length > 2 ) {
            if( args[ 2 ] != null ) {
                Integer i = (Integer) args[ 2 ];
                maxReturn = i.intValue();
            }
        }

        if( args.length > 3 ) {
            if( args[ 3 ] != null ) {
                ServiceObject s = (ServiceObject) args[ 3 ];
                serviceName = s.getName();
            }
        }

        if( args.length > 4 ) {
            if( args[ 4 ] != null ) {
                Boolean b = (Boolean) args[ 4 ];
                isAscending = b.booleanValue();
            }
        }

        boolean isSorted = orderByField != null && orderByField.length() > 0 ? true : false;
        ContactList contactList;
        try {
            if( serviceName.length() == 0 ) {
                contactList = (ContactList) PIM.getInstance().openPIMList( PIM.CONTACT_LIST, PIM.READ_WRITE );
            } else {
                contactList = (ContactList) PIM.getInstance().openPIMList( PIM.CONTACT_LIST, PIM.READ_WRITE, serviceName );
            }
        } catch( PIMException pime ) {
            return contactsFound;
        }

        Vector found = new Vector();
        Enumeration e;
        int iElement = 0;
        try {
            e = contactList.items();
            while( e.hasMoreElements() ) {
                if( !isSorted && iElement == maxReturn ) {
                    break;
                }

                Contact c = (Contact) e.nextElement();
                ContactObject contact = new ContactObject( c );
                if( testable != null ) {
                    if( testable.test( contact ) ) {
                        FindNamespace.insertElementByOrder( found, contact, orderByField, isAscending );
                        iElement++;
                    }
                } else {
                    FindNamespace.insertElementByOrder( found, contact, orderByField, isAscending );
View Full Code Here

     * @see blackberry.core.ScriptableFunctionBase#execute(java.lang.Object, java.lang.Object[])
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        TaskObject[] tasksFound = new TaskObject[ 0 ];

        TestableScriptableObject testable = null;
        String orderByField = "";
        int maxReturn = -1;
        boolean isAscending = true;

        if( !FindNamespace.isValidFindArguments( args, false ) ) {
            return tasksFound;
        }

        if( args.length > 0 ) {
            testable = (TestableScriptableObject) args[ 0 ];
        }

        if( args.length > 1 ) {
            if( args[ 1 ] != null ) {
                orderByField = (String) args[ 1 ];
            }
        }

        if( args.length > 2 ) {
            if( args[ 2 ] != null ) {
                Integer i = (Integer) args[ 2 ];
                maxReturn = i.intValue();
            }
        }

        if( args.length > 3 ) {
            if( args[ 3 ] != null ) {
                Boolean b = (Boolean) args[ 3 ];
                isAscending = b.booleanValue();
            }
        }

        boolean isSorted = orderByField != null && orderByField.length() > 0 ? true : false;

        ToDoList taskList;
        try {
            taskList = (ToDoList) PIM.getInstance().openPIMList( PIM.TODO_LIST, PIM.READ_WRITE );
        } catch( PIMException pime ) {
            return tasksFound;
        }

        Vector found = new Vector();
        Enumeration e;
        int iElement = 0;
        try {
            e = taskList.items();
            while( e.hasMoreElements() ) {
                ToDo t = (ToDo) e.nextElement();
                TaskObject task = new TaskObject( t );
                if( testable != null ) {
                    if( testable.test( task ) ) {
                        FindNamespace.insertElementByOrder( found, task, orderByField, isAscending );
                        iElement++;
                    }
                } else {
                    FindNamespace.insertElementByOrder( found, task, orderByField, isAscending );
View Full Code Here

     * @see blackberry.core.ScriptableFunctionBase#execute(java.lang.Object, java.lang.Object[])
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        MemoObject[] memosFound = new MemoObject[ 0 ];

        TestableScriptableObject testable = null;
        String orderByField = "";
        int maxReturn = -1;
        boolean isAscending = true;

        if( !FindNamespace.isValidFindArguments( args, false ) ) {
            return memosFound;
        }

        if( args.length > 0 ) {
            testable = (TestableScriptableObject) args[ 0 ];
        }

        if( args.length > 1 ) {
            if( args[ 1 ] != null ) {
                orderByField = (String) args[ 1 ];
            }
        }

        if( args.length > 2 ) {
            if( args[ 2 ] != null ) {
                Integer i = (Integer) args[ 2 ];
                maxReturn = i.intValue();
            }
        }

        if( args.length > 3 ) {
            if( args[ 3 ] != null ) {
                Boolean b = (Boolean) args[ 3 ];
                isAscending = b.booleanValue();
            }
        }

        boolean isSorted = orderByField != null && orderByField.length() > 0 ? true : false;

        BlackBerryMemoList memoList;
        try {
            memoList = (BlackBerryMemoList) PIM.getInstance().openPIMList( BlackBerryPIM.MEMO_LIST, PIM.READ_WRITE );
        } catch( PIMException pime ) {
            return memosFound;
        }

        Vector found = new Vector();
        Enumeration e;
        int iElement = 0;
        try {
            e = memoList.items();
            while( e.hasMoreElements() ) {
                BlackBerryMemo m = (BlackBerryMemo) e.nextElement();
                MemoObject memo = new MemoObject( m );
                if( testable != null ) {
                    if( testable.test( memo ) ) {
                        FindNamespace.insertElementByOrder( found, memo, orderByField, isAscending );
                        iElement++;
                    }
                } else {
                    FindNamespace.insertElementByOrder( found, memo, orderByField, isAscending );
View Full Code Here

             * @see blackberry.core.ScriptableFunctionBase#execute(java.lang.Object, java.lang.Object[])
             */
            public Object execute( Object thiz, Object[] args ) throws Exception {
                AppointmentObject[] appointmentsFound = new AppointmentObject[ 0 ];

                TestableScriptableObject testable = null;
                String orderByField = "";
                int maxReturn = -1;
                String serviceName = "";
                boolean isAscending = true;

                if( !FindNamespace.isValidFindArguments( args, true ) ) {
                    return appointmentsFound;
                }
                if( args.length > 0 ) {
                    testable = (TestableScriptableObject) args[ 0 ];
                }
                if( args.length > 1 ) {
                    if( args[ 1 ] != null ) {
                        orderByField = (String) args[ 1 ];
                    }
                }
                if( args.length > 2 ) {
                    if( args[ 2 ] != null ) {
                        Integer i = (Integer) args[ 2 ];
                        maxReturn = i.intValue();
                    }
                }
                if( args.length > 3 ) {
                    if( args[ 3 ] != null ) {
                        ServiceObject s = (ServiceObject) args[ 3 ];
                        serviceName = s.getName();
                    }
                }

                if( args.length > 4 ) {
                    if( args[ 4 ] != null ) {
                        Boolean b = (Boolean) args[ 4 ];
                        isAscending = b.booleanValue();
                    }
                }

                boolean isSorted = orderByField != null && orderByField.length() > 0 ? true : false;
                EventList eventList;
                try {
                    if( serviceName.length() == 0 ) {
                        eventList = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST, PIM.READ_WRITE );
                    } else {
                        eventList = (EventList) PIM.getInstance().openPIMList( PIM.EVENT_LIST, PIM.READ_WRITE, serviceName );
                    }
                } catch( PIMException pime ) {
                    return appointmentsFound;
                }
                Vector found = new Vector();
                Enumeration e;
                int iElement = 0;
                try {
                    e = eventList.items();
                    while( e.hasMoreElements() ) {
                        Event evt = (Event) e.nextElement();
                        AppointmentObject appointment = new AppointmentObject( evt );
                        if( testable != null ) {
                            if( testable.test( appointment ) ) {
                                FindNamespace.insertElementByOrder( found, appointment, orderByField, isAscending );
                                iElement++;
                            }
                        } else {
                            FindNamespace.insertElementByOrder( found, appointment, orderByField, isAscending );
View Full Code Here

TOP

Related Classes of blackberry.find.TestableScriptableObject

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.