GWT window utility : Utility « GWT « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Java » GWT » UtilityScreenshots 
GWT window utility
 
/*
 * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 
 *    http://www.apache.org/licenses/LICENSE-2.0
 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gwtwidgets.client.util;

public class WindowUtils
{
    public static Location getLocation ()
    {
        Location result = new Location();
        result.setHash(getHash());
        result.setHost(getHost());
        result.setHostName(getHostName());
        result.setHref(getHref());
        result.setPath(getPath());
        result.setPort(getPort());
        result.setProtocol(getProtocol());
        result.setQueryString(getQueryString());
        return result;
    }

    private static native String getQueryString () /*-{
        return $wnd.location.search;
    }-*/;

    private static native String getProtocol () /*-{
        return $wnd.location.protocol;
    }-*/;

    private static native String getPort () /*-{
        return $wnd.location.port;
    }-*/;

    private static native String getPath () /*-{
        return $wnd.location.pathname;
    }-*/;

    private static native String getHref () /*-{
        return $wnd.location.href;
    }-*/;

    private static native String getHostName () /*-{
        return $wnd.location.hostname;
    }-*/;

    private static native String getHost () /*-{
        return $wnd.location.host;
    }-*/;

    private static native String getHash () /*-{
        return $wnd.location.hash;
    }-*/;
    
}
/////////////////////////////////
/*
 * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com>
 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 
 *    http://www.apache.org/licenses/LICENSE-2.0
 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gwtwidgets.client.util;

import java.util.HashMap;
import java.util.Map;

public class Location
{
    private String hash;
    private String host;
    private String hostName;
    private String href;
    private String path;
    private String port;
    private String protocol;
    private String queryString;
    private HashMap paramMap;


    public String getHash ()
    {
        return hash;
    }

    public String getHost ()
    {
        return host;
    }

    public String getHostName ()
    {
        return hostName;
    }

    public String getHref ()
    {
        return href;
    }

    public String getPath ()
    {
        return path;
    }

    public String getPort ()
    {
        return port;
    }

    public String getProtocol ()
    {
        return protocol;
    }

    public String getQueryString ()
    {
        return queryString;
    }

    protected void setHash (String hash)
    {
        this.hash = hash;
    }

    protected void setHost (String host)
    {
        this.host = host;
    }

    protected void setHostName (String hostName)
    {
        this.hostName = hostName;
    }

    protected void setHref (String href)
    {
        this.href = href;
    }

    protected void setPath (String path)
    {
        this.path = path;
    }

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

    protected void setProtocol (String protocol)
    {
        this.protocol = protocol;
    }

    protected void setQueryString (String queryString)
    {
        this.queryString = queryString;
        paramMap = new HashMap();
        
        if (queryString != null && queryString.length() 1) {
            String qs = queryString.substring(1);
            String[] kvPairs = qs.split("&");
            for (int i = 0; i < kvPairs.length; i++) {
                String[] kv = kvPairs[i].split("=");
                if (kv.length > 1) {
                    paramMap.put(kv[0], unescape(kv[1]));
                }
                else {
                    paramMap.put(kv[0]"");
                }
            }
        }
    }
    
    private native String unescape (String val/*-{
        return unescape(val);
    }-*/;

    public String getParameter (String name)
    {
        return (StringparamMap.get(name);
    }

    public Map getParameterMap ()
    {
        return paramMap;
    }

}



           
         
  
Related examples in the same category
1.Use reflection to generate the async interface from the Service interface as per GWT standard
2.Array Utils for client side GWT
3.A simple number formatting/ parsing class
4.Implement java.util.regex.Pattern with Javascript RegExp object
5.GWT color class
6.DOM related helper methods (Smart GWT)
7.Formatting functions for GWT client side (Ext GWT)
8.Helper class to decode and encode objects to and from Json (Ext GWT)
9.String util for GWT client side (Smart GWT)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.