⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
字号:
/* *    * * Copyright  1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). *  * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA *  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package com.sun.midp.io.j2me.pipe;import com.sun.cldc.io.ConnectionBaseInterface;import com.sun.midp.security.ImplicitlyTrustedClass;import com.sun.midp.security.SecurityInitializer;import java.io.IOException;import javax.microedition.io.Connection;import com.sun.midp.security.SecurityToken;public class Protocol implements ConnectionBaseInterface {    private static class SecurityTrusted implements ImplicitlyTrustedClass {};    private static SecurityToken token;    public Connection openPrim(String name, int mode, boolean timeouts) throws IOException {        if (name.charAt(0) != '/' || name.charAt(1) != '/')            throw new IllegalArgumentException(                      "Protocol must start with \"//\"");        // server. format is: "pipe://:server-name:server-version;"        // client. format is: "pipe://(suite-id|*):server-name:server-version;"        // suite-id is midlet suite's "vendor:name:version" triplet        int colon2 = name.lastIndexOf(':');        int colon1 = name.lastIndexOf(':', colon2-1);        int semicolon = name.lastIndexOf(';');        if (colon1 < 0 || semicolon < name.length() - 1)            throw new IllegalArgumentException("Malformed server protocol name");        String serverName = name.substring(colon1, colon2);        String version = name.substring(colon2 + 1, semicolon);                if (token == null) {            token = SecurityInitializer.requestToken(new SecurityTrusted());        }        // check if we deal with server or client connection        if (colon1 == 2) {            // check if this is AMS isolate and opens connection for push purposes            //       or this is user isolate and it needs to checkout connection from AMS            // TODO. no push for now            PipeServerConnectionImpl connection =                    new PipeServerConnectionImpl(serverName, version, token);            connection.establish(mode);            return connection;        } else {            Object suiteId = null;            if (name.charAt(2) == '*') {                if (colon1 != 3)                    throw new IllegalArgumentException("Malformed protocol name");            } else {                // TODO parse suite identity into suiteId object                // suiteId might change its type            }                        PipeClientConnectionImpl connection =                     new PipeClientConnectionImpl(suiteId, serverName, version, token);            connection.establish(mode);                        return connection;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -