com.maryanovsky.gwtutils.client
Class Utils

java.lang.Object
  extended by com.maryanovsky.gwtutils.client.Utils

public class Utils
extends Object

A general utility class.

Author:
Maryanovsky Alexander

Constructor Summary
Utils()
           
 
Method Summary
static boolean areEqual(List<?> list1, List<?> list2)
          Returns whether the two specified lists are equal by value, that is, they contain equal items, in the same order.
static boolean areEqual(Object o1, Object o2)
          Returns whether the two specified objects are equal.
static String[] clone(String[] arr)
          Creates a shallow copy of the specified String array.
static Map<String,String> dictionaryToMap(Dictionary dictionary)
          Converts a Dictionary to a regular string-to-string map.
static String escape(String s)
          The JavaScript escape function.
static boolean getBooleanProperty(JavaScriptObject object, String propertyName)
          Returns the specified boolean property of the specified JavaScript object.
static double getDoubleProperty(JavaScriptObject object, String propertyName)
          Returns the specified floating point property of the specified JavaScript object.
static String getHostname(String url)
          Returns the hostname in the specified URL.
static int getIntProperty(JavaScriptObject object, String propertyName)
          Returns the specified integer property of the specified JavaScript object.
 JavaScriptObject getProperty(JavaScriptObject object, String propertyName)
          Returns the specified property of the specified JavaScript object.
static String getStringProperty(JavaScriptObject object, String propertyName)
          Returns the specified string property of the specified JavaScript object.
static Map<String,String> getUrlParams()
          Returns the URL parameters of window.location.
static Map<String,String> getUrlParams(Map<String,String> params)
          Adds the URL parameters of window.location to specified map and returns it.
static int hashCode(double d)
          Returns the hash code for the specified double value.
static int hashCode(int hash1, int hash2)
          Returns a hash code for the two specified hash codes.
static int hashCode(long l)
          Returns the hash code for the specified long value.
static int hashCode(Object o)
          Returns a hash code for the specified object, or if the object is null, returns 0.
static void setBooleanProperty(JavaScriptObject object, String propertyName, boolean propertyValue)
          Sets the specified boolean property of the specified JavaScript object.
static void setDoubleProperty(JavaScriptObject object, String propertyName, double propertyValue)
          Sets the specified floating point property of the specified JavaScript object.
static void setIntProperty(JavaScriptObject object, String propertyName, int propertyValue)
          Sets the specified integer property of the specified JavaScript object.
static void setProperty(JavaScriptObject object, String propertyName, JavaScriptObject propertyValue)
          Sets the specified property of the specified JavaScript object.
static void setStringProperty(JavaScriptObject object, String propertyName, String propertyValue)
          Sets the specified string property of the specified JavaScript object.
static String unescape(String s)
          The JavaScript unescape function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getHostname

public static String getHostname(String url)
Returns the hostname in the specified URL. Returns null if if the URL is relative.


clone

public static String[] clone(String[] arr)
Creates a shallow copy of the specified String array.


hashCode

public static int hashCode(Object o)
Returns a hash code for the specified object, or if the object is null, returns 0.


hashCode

public static int hashCode(double d)
Returns the hash code for the specified double value.


hashCode

public static int hashCode(long l)
Returns the hash code for the specified long value.


hashCode

public static int hashCode(int hash1,
                           int hash2)
Returns a hash code for the two specified hash codes.


areEqual

public static boolean areEqual(Object o1,
                               Object o2)
Returns whether the two specified objects are equal.


areEqual

public static boolean areEqual(List<?> list1,
                               List<?> list2)
Returns whether the two specified lists are equal by value, that is, they contain equal items, in the same order. Note that the comparison is not recursive, that is, even if some of the elements in the lists are lists themselves, they are compared using the regular equals method.


getProperty

public JavaScriptObject getProperty(JavaScriptObject object,
                                    String propertyName)
Returns the specified property of the specified JavaScript object.


setProperty

public static void setProperty(JavaScriptObject object,
                               String propertyName,
                               JavaScriptObject propertyValue)
Sets the specified property of the specified JavaScript object.


getStringProperty

public static String getStringProperty(JavaScriptObject object,
                                       String propertyName)
Returns the specified string property of the specified JavaScript object.


setStringProperty

public static void setStringProperty(JavaScriptObject object,
                                     String propertyName,
                                     String propertyValue)
Sets the specified string property of the specified JavaScript object.


getIntProperty

public static int getIntProperty(JavaScriptObject object,
                                 String propertyName)
Returns the specified integer property of the specified JavaScript object.


setIntProperty

public static void setIntProperty(JavaScriptObject object,
                                  String propertyName,
                                  int propertyValue)
Sets the specified integer property of the specified JavaScript object.


getDoubleProperty

public static double getDoubleProperty(JavaScriptObject object,
                                       String propertyName)
Returns the specified floating point property of the specified JavaScript object.


setDoubleProperty

public static void setDoubleProperty(JavaScriptObject object,
                                     String propertyName,
                                     double propertyValue)
Sets the specified floating point property of the specified JavaScript object.


getBooleanProperty

public static boolean getBooleanProperty(JavaScriptObject object,
                                         String propertyName)
Returns the specified boolean property of the specified JavaScript object.


setBooleanProperty

public static void setBooleanProperty(JavaScriptObject object,
                                      String propertyName,
                                      boolean propertyValue)
Sets the specified boolean property of the specified JavaScript object.


getUrlParams

public static Map<String,String> getUrlParams(Map<String,String> params)
Adds the URL parameters of window.location to specified map and returns it. If a parameter has been specified more than once, only the last value is added to the map.


getUrlParams

public static Map<String,String> getUrlParams()
Returns the URL parameters of window.location. The returned map is unmodifiable. If a parameter has been specified more than once, only the last value appears in the map.


dictionaryToMap

public static Map<String,String> dictionaryToMap(Dictionary dictionary)
Converts a Dictionary to a regular string-to-string map.


escape

public static String escape(String s)
The JavaScript escape function.


unescape

public static String unescape(String s)
The JavaScript unescape function.