elemental.js.util.JsGlobals Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client Show documentation
Show all versions of vaadin-client Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/*
* 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() {
}
}