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

📄 javascript.java

📁 这是远程web服务调用的一个包,可以将JSP直接作为服务
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                WebResponse.Scriptable scriptables[] = getDelegate().getFrames();                Window[] frames = new Window[ scriptables.length ];                for (int i = 0; i < frames.length; i++) {                    frames[ i ] = (Window) toScriptable( scriptables[ i ] );                }                _frames = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" );                _frames.initialize( frames );            }            return _frames;        }        public Navigator jsGet_navigator() {            return _navigator;        }        public Screen jsGet_screen() {            return _screen;        }        public Location jsGet_location() {            return _location;        }        public void jsSet_location( String relativeURL ) throws IOException, SAXException {            setLocation( relativeURL );        }        void setLocation( String relativeURL ) throws IOException, SAXException {            getDelegate().setLocation( relativeURL );        }        void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )                throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {            super.initialize( parent, scriptable );            _location = (Location) Context.getCurrentContext().newObject( this, "Location" );            _location.initialize(this, ((WebResponse.Scriptable) scriptable).getURL() );            _navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" );            _navigator.setClientProperties( getDelegate().getClientProperties() );            _screen = (Screen) Context.getCurrentContext().newObject( this, "Screen" );            _screen.setClientProperties( getDelegate().getClientProperties() );        }        public void jsFunction_alert( String message ) {            getDelegate().alert( message );        }        public boolean jsFunction_confirm( String message ) {            return getDelegate().getConfirmationResponse( message );        }        public String jsFunction_prompt( String message, String defaultResponse ) {            return getDelegate().getUserResponse( message, defaultResponse );        }        public void jsFunction_moveTo( int x, int y ) {        }        public void jsFunction_focus() {        }        public void jsFunction_setTimeout() {        }        public void jsFunction_close() {            getDelegate().close();        }        public Window jsFunction_open( Object url, String name, String features, boolean replace )                throws PropertyException, JavaScriptException, NotAFunctionException, IOException, SAXException {            WebResponse.Scriptable delegate = getDelegate().open( toStringIfNotUndefined( url ), name, features, replace );            return delegate == null ? null : (Window) toScriptable( delegate );        }        public void clearCaches() {            if (_document != null) _document.clearCaches();        }        protected StringBuffer getDocumentWriteBuffer() {            return jsGet_document().getWriteBuffer();        }        protected void discardDocumentWriteBuffer() {            jsGet_document().clearWriteBuffer();        }        private WebResponse.Scriptable getDelegate() {            return (WebResponse.Scriptable) _scriptable;        }    }    static public class Document extends JavaScriptEngine {        private ElementArray _forms;        private ElementArray _links;        private ElementArray _images;        private StringBuffer _writeBuffer;        private String _mimeType;        public String getClassName() {            return "Document";        }        public void clearCaches() {            _forms = _links = _images = null;        }        public String jsGet_title() throws SAXException {            return getDelegate().getTitle();        }        public Scriptable jsGet_images() throws SAXException{            if (_images == null) _images = toElementArray( getDelegate().getImages() );            return _images;        }        public Scriptable jsGet_links() throws SAXException {            if (_links == null) _links = toElementArray( getDelegate().getLinks() );            return _links;        }        public Scriptable jsGet_forms() throws SAXException {            if (_forms == null) _forms = toElementArray( getDelegate().getForms() );            return _forms;        }        public Object jsFunction_getElementById( String id ) {            ScriptableDelegate elementWithID = getDelegate().getElementWithID( id );            return elementWithID == null ? null : toScriptable( elementWithID );        }        public Object jsFunction_getElementsByName( String name ) {            return toElementArray( getDelegate().getElementsByName( name ) );        }        public Object jsFunction_getElementsByTagName( String name ) {            return toElementArray( getDelegate().getElementsByTagName( name ) );        }        public Object jsGet_location() {            return _parent == null ? NOT_FOUND : getWindow().jsGet_location();        }        public void jsSet_location( String urlString ) throws IOException, SAXException {            if (urlString.startsWith( "color" )) return;            getWindow().setLocation( urlString );        }        public String jsGet_cookie() {            return getDelegate().getCookie();        }        public void jsSet_cookie( String cookieSpec ) {            final int equalsIndex = cookieSpec.indexOf( '=' );            if (equalsIndex <0) return;            int endIndex = cookieSpec.indexOf( ";", equalsIndex );            if (endIndex < 0) endIndex = cookieSpec.length();            String name = cookieSpec.substring( 0, equalsIndex );            String value = cookieSpec.substring( equalsIndex+1, endIndex );            getDelegate().setCookie( name, value );        }        private Window getWindow() {            return ((Window) _parent);        }        public void jsFunction_open( Object mimeType ) {            _mimeType = toStringIfNotUndefined( mimeType );        }        public void jsFunction_close() {            if (getDelegate().replaceText( getWriteBuffer().toString(), _mimeType == null ? "text/html" : _mimeType )) {                getWriteBuffer().setLength(0);            }        }        public void jsFunction_write( String string ) {            getWriteBuffer().append( string );        }        public void jsFunction_writeln( String string ) {            getWriteBuffer().append( string ).append( (char) 0x0D ).append( (char) 0x0A );        }        protected StringBuffer getWriteBuffer() {            if (_writeBuffer == null) _writeBuffer = new StringBuffer();            return _writeBuffer;        }        protected void clearWriteBuffer() {            _writeBuffer = null;        }        private HTMLPage.Scriptable getDelegate() {            return (HTMLPage.Scriptable) _scriptable;        }    }    static public class Location extends JavaScriptEngine {        private URL _url;        private Window _window;        public String getClassName() {            return "Location";        }        void initialize( Window window, URL url ) {            _window = window;            _url = url;        }        public void jsFunction_replace( String urlString ) throws IOException, SAXException {            _window.setLocation( urlString );        }        public String jsGet_href() {            return toString();        }        public void jsSet_href( String urlString ) throws SAXException, IOException {            _window.setLocation( urlString );        }        public String jsGet_protocol() {            return _url.getProtocol() + ':';        }        public String jsGet_host() {            return _url.getHost() + ':' + _url.getPort();        }        public String jsGet_hostname() {            return _url.getHost();        }        public String jsGet_port() {            return String.valueOf( _url.getPort() );        }        public String jsGet_pathname() {            return _url.getPath();        }        public void jsSet_pathname( String newPath ) throws SAXException, IOException {            if (!newPath.startsWith( "/" )) newPath = '/' + newPath;            URL newURL = new URL( _url, newPath );            _window.setLocation( newURL.toExternalForm() );        }        public String jsGet_search() {            return '?' + _url.getQuery();        }        public void jsSet_search( String newSearch ) throws SAXException, IOException {            if (!newSearch.startsWith( "?" )) newSearch = '?' + newSearch;            _window.setLocation( jsGet_protocol() + "//" + jsGet_host() + jsGet_pathname() + newSearch );        }        /**         * Returns the default value of this scriptable object. In this case, it returns simply the URL as a string.         * Note that this method is necessary, since Rhino will only call the toString method directly if there are no         * Rhino methods defined (jsGet_*, jsFunction_*, etc.)         */        public Object getDefaultValue( Class typeHint ) {            return _url.toExternalForm();        }        public String toString() {            return _url.toExternalForm();        }    }    static public class Style extends JavaScriptEngine {        private String _display    = "inline";        private String _visibility = "visible";        public String getClassName() {            return "Style";        }        public String jsGet_display() {            return _display;        }        public void jsSet_display( String display ) {            _display = display;        }        public String jsGet_visibility() {            return _visibility;        }        public void jsSet_visibility( String visibility ) {            _visibility = visibility;        }    }    static public class Navigator extends JavaScriptEngine {        private ClientProperties _clientProperties;        public String getClassName() {            return "Navigator";        }        void setClientProperties( ClientProperties clientProperties ) {            _clientProperties = clientProperties;        }        public String jsGet_appName() {            return _clientProperties.getApplicationName();        }        public String jsGet_appCodeName() {            return _clientProperties.getApplicationCodeName();        }

⌨️ 快捷键说明

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