All Downloads are FREE. Search and download functionalities are using the official Maven repository.

elemental.js.util.JsGlobals Maven / Gradle / Ivy

Go to download

This module exists solely to package all other gwt modules into a single uber jar. This makes deploying to non-mavenized targets much easier. Of course, you would be wise to inherit your dependencies individually; the uber jar is intended for projects like collide, which have complex configuration, and adding many jars would be a pain.

The newest version!
/*
 * Copyright 2010 Google Inc.
 * 
 * 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 elemental.js.util;


/**
 * A utility class for accessing global functions and values in an ECMAScript
 * context.
 */
public class JsGlobals {
  /**
   * Decodes an encoded URI to a URI string.
   */
  public native static String decodeURI(String encodedURI) /*-{
    return decodeURI(encodedURI);
  }-*/;

  /**
   * Decodes an encoded URI component to a URI component string.
   */
  public native static String decodeURIComponent(String encodedURIComponent) /*-{
    return decodeURIComponent(encodedURIComponent);
  }-*/;

  /**
   * Encodes a URI string by escaping all characters not allowed in URIs.
   */
  public native static String encodeURI(String uri) /*-{
    return encodeURI(uri);
  }-*/;

  /**
   * Encodes a URI component string by escaping all characters not allowed in
   * URIs.
   */
  public static native String encodeURIComponent(String uriComponent) /*-{
    return encodeURIComponent(uriComponent);
  }-*/;

  /**
   * Indicates if value is a finite number.
   */
  public native static boolean isFinite(double value) /*-{
    return isFinite(value);
  }-*/;

  /**
   * Indicates if value is NaN.
   */
  public native static boolean isNaN(double value) /*-{
    return isNaN(value);
  }-*/;

  /**
   * Produces a double value by interpreting the contents of
   * value as a decimal literal.
   */
  public native static double parseFloat(String value) /*-{
    return parseFloat(value);
  }-*/;

  /**
   * Produces a double value by interpreting the contents of
   * value as a decimal literal.
   */
  public native static double parseFloat(String value, int radix) /*-{
    return parseFloat(value, radix);
  }-*/;

  /**
   * Produces a integral value by interpreting the contents of
   * value as a integer literal. The value returned by this method
   * will be an integral value or NaN, so the return value is a
   * double.
   * 
   * 
   * Example use:
   * // Will yield zero if s is not a valid integer.
   * int value = (int)parseInt(s);
   * 
   * // To check if the value is valid.
   * double value = parseInt(s);
   * if (isNaN(value))
   *   //Invalid value.
   * 
*/ public native static double parseInt(String value) /*-{ return parseInt(value); }-*/; /** * Produces a integral value by interpreting the contents of * value as a integer literal. The value returned by this method * will be an integral value or NaN, so the return value is a * double. * *
   * Example use:
   * // Will yield zero if s is not a valid integer.
   * int value = (int)parseInt(s);
   * 
   * // To check if the value is valid.
   * double value = parseInt(s);
   * if (isNaN(value))
   *   //Invalid value.
   * 
*/ public native static double parseInt(String value, int radix) /*-{ return parseInt(value, radix); }-*/; private JsGlobals() { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy