Package javax.microedition.io

Examples of javax.microedition.io.Connection


    } else {
      connection.setDoInput(mode == ConnectorService.READ);
      connection.setDoOutput(mode == ConnectorService.WRITE);
    }
   
    Connection con = new HttpConnectionAdapter(this, connection);
    return con;
  }
View Full Code Here


    }

    String scheme = uri.substring(0, schemeSeparator);

    ConnectionFactory factory = getFactory(scheme);
    Connection retval = null;

    if (factory != null) {
      retval = factory.createConnection(uri, mode, timeouts);

    } else {
View Full Code Here

      return 0;

  }

  public DataInputStream openDataInputStream(String name) throws IOException {
    Connection con = open(name, ConnectorService.READ, false);

    if (con instanceof InputConnection) {
      DataInputStream stream = ((InputConnection)con).openDataInputStream();
      con.close();
      return stream;
    }
    con.close();
    throw new IOException("Given scheme does not support input");
  }
View Full Code Here

    throw new IOException("Given scheme does not support input");
  }


  public DataOutputStream openDataOutputStream(String name) throws IOException {
    Connection con = open(name, ConnectorService.WRITE, false);

    if (con instanceof OutputConnection) {
      DataOutputStream stream = ((OutputConnection)con).openDataOutputStream();
      con.close();
      return stream;
    }

    con.close();
    throw new IOException("Given scheme does not support output");
  }
View Full Code Here

  }


  public InputStream openInputStream(String name) throws IOException {

    Connection con = open(name, ConnectorService.READ, false);

    if (con instanceof InputConnection) {
      InputStream stream = ((InputConnection)con).openInputStream();
      con.close();
      return stream;
    }

    con.close();
    throw new IOException("Given scheme does not support input");
  }
View Full Code Here

    throw new IOException("Given scheme does not support input");
  }


  public OutputStream openOutputStream(String name) throws IOException {
    Connection con = open(name, ConnectorService.WRITE, false);

    if (con instanceof OutputConnection) {
      OutputStream stream = ((OutputConnection)con).openOutputStream();
      con.close();
      return stream;
    }

    con.close();
    throw new IOException("Given scheme does not support output");
  }
View Full Code Here

        Dictionary props = new Hashtable();
        props.put(ConnectionFactory.IO_SCHEME, "file");
        ServiceRegistration registration = registerConnectionFactory(connFactory, props);
        ConnectorService service = getConnectorService();

        Connection connection = service.open("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ_WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);
View Full Code Here

        props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
        registerConnectionFactory(connFactory2, props);

        ConnectorService service = getConnectorService();

        Connection connection = service.open("file://test.txt");
        assertEquals("uri checks for lowest ranking service", null, connFactory.getName());
        assertEquals("file://test.txt", connFactory2.getName());
        assertEquals(ConnectorService.READ_WRITE, connFactory2.getMode());
        assertEquals(false, connFactory2.isTimeout());
        assertNotNull("Connection should be created", connection);
View Full Code Here

        ConnectionFactoryMock connFactory2 = new ConnectionFactoryMock();
        ServiceRegistration registration2 = registerConnectionFactory(connFactory2, props);

        ConnectorService service = getConnectorService();

        Connection connection = service.open("file://test.txt");
        assertEquals("uri checks for highest service.id", null, connFactory2.getName());
        assertEquals("uri checks for lowest service.id", "file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ_WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned Connection", connection);
View Full Code Here

        props.put(ConnectionFactory.IO_SCHEME, new String[]
        { "file", "http", "sms" });
        ServiceRegistration registration = registerConnectionFactory(connFactory, props);
        ConnectorService service = getConnectorService();

        Connection connection = service.open("file://test.txt");
        assertEquals("file://test.txt", connFactory.getName());
        assertEquals(ConnectorService.READ_WRITE, connFactory.getMode());
        assertEquals(false, connFactory.isTimeout());
        assertNotNull("checks returned connection", connection);
View Full Code Here

TOP

Related Classes of javax.microedition.io.Connection

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.