Examples of InputConnection


Examples of javax.microedition.io.InputConnection

    /**
     * @see ScriptableFunctionBase#execute(Object, Object[])
     */
    public Object execute( Object thiz, Object[] args ) throws Exception {
        DataInputStream dis = null;
        InputConnection ic = null;

        try {
            BrowserFieldRequest bfr = new BrowserFieldRequest( args[ 0 ].toString() );
            ic = ((BrowserFieldController)_weakReferenceBrwoserFieldController.get()).handleResourceRequest( bfr );

            dis = ic.openDataInputStream();
            ByteVector vc = new ByteVector();

            for( int b = dis.read(); b != -1; b = dis.read() ) {
                vc.addElement( (byte) b );
            }

            // An application could have multiple entry points and each entry point has its own icon.
            // We need to update icons for all entry points to be the same one.
            Bitmap image = Bitmap.createBitmapFromBytes( vc.getArray(), 0, vc.size(), 1 );
            ApplicationDescriptor current = ApplicationDescriptor.currentApplicationDescriptor();
            int moduleHandle = current.getModuleHandle();
            ApplicationDescriptor[] descriptors = CodeModuleManager.getApplicationDescriptors( moduleHandle );
           
            if( args.length == 1 || !( (Boolean) args[ 1 ] ).booleanValue() ) {
                for( int i = 0; i < descriptors.length; i++ ) {
                    HomeScreen.updateIcon( image, descriptors[ i ] );
                }
            } else {
                for( int i = 0; i < descriptors.length; i++ ) {
                    HomeScreen.setRolloverIcon( image, descriptors[ i ] );
                }
            }
        } finally {
            try {
                if( dis != null ) {
                    dis.close();
                }
                if( ic != null ) {
                    ic.close();
                }
            } catch( IOException e ) {
            }
        }

View Full Code Here

Examples of javax.microedition.io.InputConnection

    /**
     * {@inheritDoc}
     */
    public InputStream openInputStream() throws IOException
    {
        final InputConnection connection = (InputConnection)Connector.open( PREFIX + path_, Connector.READ );
        final InputStream stream = connection.openInputStream();
        connection.close();
        return stream;
    }
View Full Code Here

Examples of javax.microedition.io.InputConnection

                    os.write(getCommand.getBytes());
                    os.flush();
                }

                // Get InputConnection and read the server's response
                final InputConnection inputConn = (InputConnection) connection;
                is = inputConn.openInputStream();
                final byte[] data =
                        net.rim.device.api.io.IOUtilities.streamToBytes(is);
                result = new String(data);
                is.close();
View Full Code Here

Examples of net.kuujo.vertigo.io.connection.InputConnection

      public void handle(final Task task) {
        // Iterate through existing connections and try to determine
        // whether any of them have been removed from the network.
        Iterator<InputConnection> iter = connections.iterator();
        while (iter.hasNext()) {
          final InputConnection connection = iter.next();
          boolean exists = false;
          for (InputConnectionContext input : update.connections()) {
            if (input.address().equals(connection.address())) {
              exists = true;
              break;
            }
          }

          // If a connection was removed from the network, close
          // and remove the connection regardless of whether the
          // close is actually successful.
          if (!exists) {
            connection.close(new Handler<AsyncResult<Void>>() {
              @Override
              public void handle(AsyncResult<Void> result) {
                if (result.failed()) {
                  log.error(String.format("%s - Failed to close input connection: %s", DefaultInputPort.this, connection));
                } else {
                  log.info(String.format("%s - Closed input connection: %s", DefaultInputPort.this, connection));
                }
              }
            });
            iter.remove();
          }
        }

        // Now try to determine whether any connections were added to the network.
        final List<InputConnection> newConnections = new ArrayList<>();
        for (InputConnectionContext input : update.connections()) {
          boolean exists = false;
          for (InputConnection connection : connections) {
            if (connection.address().equals(input.address())) {
              exists = true;
              break;
            }
          }
          if (!exists) {
            log.debug(String.format("%s - Creating connection: %s", DefaultInputPort.this, input));
            newConnections.add(new DefaultInputConnection(vertx, input));
          }
        }

        // If the port is open then that means connections have already
        // been set up. We need to add the new connections carefully
        // because it's possible that user code may be sending messages
        // on the port. If messages are sent to a connection that's not
        // yet open then an exception will be thrown.
        if (open) {
          final CountingCompletionHandler<Void> counter = new CountingCompletionHandler<Void>(newConnections.size());
          counter.setHandler(new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              task.complete();
            }
          });

          // Start each connection and add the connection to the connections
          // list only once the connection has been successfully opened.
          // The update lock by the task runner will ensure that we don't
          // accidentally open up two of the same connection even if the
          // configuration is updated again.
          for (final InputConnection connection : newConnections) {
            connection.open(new Handler<AsyncResult<Void>>() {
              @Override
              public void handle(AsyncResult<Void> result) {
                if (result.failed()) {
                  log.error(String.format("%s - Failed to open input connection: %s", DefaultInputPort.this, connection));
                } else {
View Full Code Here

Examples of net.kuujo.vertigo.io.connection.InputConnection

          // Only add connections to the connections list once the connection
          // has been opened. This ensures that we don't attempt to send messages
          // on a close connection.
          connections.clear();
          for (InputConnectionContext connectionContext : context.connections()) {
            final InputConnection connection = new DefaultInputConnection(vertx, connectionContext);
            connection.open(new Handler<AsyncResult<Void>>() {
              @Override
              public void handle(AsyncResult<Void> result) {
                if (result.failed()) {
                  log.error(String.format("%s - Failed to open input connection: %s", DefaultInputPort.this, connection));
                  startCounter.fail(result.cause());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.