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

📄 httpadv.java

📁 jxme的一些相关程序,主要是手机上程序开发以及手机和计算机通信的一些程序资料,程序编译需要Ant支持
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                setConfigMode( value );
                continue;
            }
            if( tag.equals(PortTag)) {
                setPort( value );
                continue;
            }
            if ( tag.equals(RouterTag) ) {
                if (routers == null) routers = new Vector();
                routers.addElement(value);
                continue;
            }
            if ( tag.equals(ProxyTag) ) {
                proxy = value;
                continue;
            }
            if ( tag.equals(ServerTag) ) {
                server = value;
                continue;
            }
        }

        // For consistency we force the flags to "disabled" for items we do not
        // have data for. However, the flags truely matter only when there is
        // data.
        if (proxy == null) proxyEnabled = false;
        if (server == null) serverEnabled = false;

        // RouterEnabled is different. It may be on or off independent of whether
        // there is data or not: we need that the provide the configurator with
        // fool-proof defaults for the casual user. If the user does not explicitly
        // turn it off, then it is ON and a default list of routers is installed.
        // Since the adv is read and written before actually getting to that point
        // we need the flag to be meaningfull in the absence of data. At run time,
        // it does not matter: if there's no data then no router is used.

        // if (routers == null) routerEnabled = false;
    }

    // NB: we do not try to enforce dependency rules such as
    // Proxy only when router, because we want to convey the complete 
    // configuration, even items corresponding to not currently enabled
    // features. HttpTransport will gracefully disregard items that have 
    // no use in the current context.
    public Document getDocument( MimeMediaType encodeAs ) {
        StructuredTextDocument adv = (StructuredTextDocument)
            StructuredDocumentFactory.newStructuredDocument(
            encodeAs, super.getAdvertisementType() );

        if( adv instanceof Attributable ) {
            ((Attributable)adv).addAttribute( "type", getAdvertisementType() );
        }
                
        Element e1 = adv.createElement(ProtocolTag, getProtocol());
        adv.appendChild(e1);
        
        Element e2 = adv.createElement(IntfAddrTag, getInterfaceAddress());
        adv.appendChild(e2);

        Element e3 = adv.createElement(ConfModeTag, getConfigMode());
        adv.appendChild(e3);

        Element e4 = adv.createElement(PortTag, getPort());
        adv.appendChild(e4);

        Element ext;
        Element detail;
	if (routers != null) {
            Enumeration e = routers.elements();
            while (e.hasMoreElements()) {
                String router = (String) e.nextElement();
                ext = adv.createElement (RouterTag, router);
                adv.appendChild (ext);
            }
        }
        // If disabled, say it; otherwise it is assumed on. This flag
        // unlike the others is meaningfull in the absence of corresponding
        // data.
        if (! routerEnabled) {
            ext = adv.createElement (RouterOffTag);
            adv.appendChild (ext);
        }
        if (proxy != null) {
            ext = adv.createElement (ProxyTag, proxy);
            adv.appendChild (ext);
            // If disabled, say it; otherwise it is assumed on. In published
            // advs, we only keep data for items that are ON, so we do not
            // have to clutter them with the flag.
            if (! proxyEnabled) {
                ext = adv.createElement (ProxyOffTag);
                adv.appendChild (ext);
            }
        }

	if (server != null) {
	    ext = adv.createElement (ServerTag, server);
            adv.appendChild (ext);
            // If disabled, say it; otherwise it is assumed on. In published
            // advs, we only keep data for items that are ON, so we do not
            // have to clutter them with the flag.
            if (! serverEnabled) {
                ext = adv.createElement (ServerOffTag);
                adv.appendChild (ext);
            }
	}

        return adv;
    }
    
    /**
     * Returns the interfaceAddr. That is, the ip of the IF to which to bind
     * locally created sockets.
     *
     * @return string The address.
     *
     * @since JXTA 1.0
     */
    
    public String getInterfaceAddress() {
        return interfaceAddress;
    }
    
    /**
     * Returns the interfaceAddr. That is, the ip of the IF to which to bind
     * locally created sockets.
     *
     * @param string The address
     *
     * @since JXTA 1.0
     */
    public void setInterfaceAddress(String address) {
        this.interfaceAddress = address;
    }
    
    /**
     * Returns the ConfigMode. That is, the way the user prefers to configure
     * the interface address:
     * "manual", "auto", "alwaysmanual".
     *
     * @return string The mode.
     *
     * @since JXTA 1.0
     */
    
    public String getConfigMode() {
        return configMode;
    }
    
    /**
     * Sets the ConfigMode. That is, the way the user prefers to configure
     * the interface address:
     * "manual", "auto", "alwaysmanual".
     *
     * @param string The address mode
     *
     * @since JXTA 1.0
     */
    public void setConfigMode(String configMode) {
        this.configMode = configMode;
    }

    /**
     * Returns the port number to which server sockets are locally bound.
     *
     * @return String the port
     */

    public String getPort(){
        return port;
    }

    /**
     * Sets the port number to which server sockets are locally bound.
     *
     * @param Port the port
     */

    public void setPort(String port){
        this.port = port;
    }

    public String   getProxy(){ return  proxy;  }
    public Vector getRouters(){ return routers; }
    public String  getServer(){ return server;  }
    public boolean  getProxyEnabled(){ return  proxyEnabled; }
    public boolean getRouterEnabled(){ return routerEnabled; }
    public boolean getServerEnabled(){ return serverEnabled; }

    // If one of proxy, server, or router is cleared, the corresponding
    // enabled flag should be false (the opposite is not true).

    public void  setProxy(String name){
        proxy = name;
        if (name == null) proxyEnabled = false;
    }
    public void setRouters(Vector list){
        routers = list;
        // Do not reset the flag if there's no data. We need it
        // as a fool proof default for novice users.
        //        if (routers == null) routerEnabled = false;
    }
    public void setServer(String name){
        server = name;
        if (name == null) serverEnabled = false;
    }

    public void  setProxyEnabled(boolean enabled){  proxyEnabled = enabled; }
    public void setRouterEnabled(boolean enabled){ routerEnabled = enabled; }
    public void setServerEnabled(boolean enabled){ serverEnabled = enabled; }
}

⌨️ 快捷键说明

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