_global_
Class zUtl

java.lang.Object
  extended by _global_.zUtl

public class zUtl
extends java.lang.Object

The basic utilties.

For more utilities, refer to Utl.


Field Summary
static String cellps0
          A shortcut of ' cellpadding="0" cellspacing="0" border="0"'.
static String i0
          A shortcut of '<i style="height:0;width:0"/>'.
static String img0
          A shortcut of '<img style="height:0;width:0"/>'.
 
Method Summary
static void appendAttr(String nm, java.lang.Object val)
          Appends an attribute.
static void appendAttr(String nm, java.lang.Object val, boolean force)
          Appends an attribute.
static String decodeXML(String txt)
          Decodes the XML string into a normal string.
static void destroyProgressbox(String id)
          Removes the message box created by progressbox(_global_.String, _global_.String, boolean, _global_.String).
static String encodeXML(String txt, Map opts)
          Encodes the string to a valid XML string.
static void fireShown(Widget wgt, int bfsz)
          Fires onBeforeSize, onShow, onFitSize, and onSize
static void fireSized(Widget wgt, int bfsz)
          Fires beforeSize, onFitSize and onSize
static Array frames(Window w)
          Returns all descendant frames of the given window.
static void go(String url, Map opts)
          Navigates to the specified URL.
static String intsToString(int[] ary)
          Converts an integer array to a string (separated by comma).
static boolean isAncestor(java.lang.Object p, java.lang.Object c)
          Returns if one is ancestor of the other.
static boolean isChar(char cc, Map opts)
          Returns whether the character is according to its opts.
static void isImageLoading()
          Checks whether all the loading images are finish.
static void loadImage(String url)
          Loads an image before ZK client engine to calculate the widget's layout.
static String mapToString(Map map, String assign, String separator)
          Converts a map to a string
static long now()
          Deprecated. As of release 5.0.6, replaced with jq.now().
static Map parseMap(String text, String separator, String quote)
          Parses the specifie text into a map.
static void progressbox(String id, String msg, boolean mask, String icon)
          Creates a message box to indicate something is being processed
static int[] stringToInts(String text, int defaultValue)
          Converts a string separated by comma to an array of integers.
static Date today(boolean full)
          Returns today.
static Date today(String fmt)
          Returns today.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cellps0

public static String cellps0
A shortcut of ' cellpadding="0" cellspacing="0" border="0"'.


img0

public static String img0
A shortcut of '<img style="height:0;width:0"/>'.


i0

public static String i0
A shortcut of '<i style="height:0;width:0"/>'.

Method Detail

isChar

public static boolean isChar(char cc,
                             Map opts)
Returns whether the character is according to its opts.

Parameters:
cc - the character
opts - the options.
Allowed Options
Name Allowed Values Description
digit true, false Specifies the character is digit only.
upper true, false Specifies the character is upper case only.
lower true, false Specifies the character is lower case only.
whitespace true, false Specifies the character is whitespace only.
opts[cc] true, false Specifies the character is allowed only.
Returns:
boolean

parseMap

public static Map parseMap(String text,
                           String separator,
                           String quote)
Parses the specifie text into a map. For example

zUtl.parseMap("a=b,c=d");
zUtl.parseMap("a='b c',c=de", ',', "'\"");

Parameters:
text - the text to parse
separator - the separator. If omitted, ',' is assumed
quote - the quote to handle. Ignored if omitted.
Returns:
Map the map

encodeXML

public static String encodeXML(String txt,
                               Map opts)
Encodes the string to a valid XML string. Refer to Utl for more XML utilities.

Parameters:
txt - the text to encode
opts - [optional] the options. Allowd value:
  • pre - whether to replace whitespace with &nbsp;
  • multiline - whether to replace linefeed with <br/>
  • maxlength - the maximal allowed length of the text
Returns:
String the encoded text.

decodeXML

public static String decodeXML(String txt)
Decodes the XML string into a normal string. For example, &lt; is convert to <

Parameters:
txt - the text to decode
Returns:
String the decoded string

today

public static Date today(String fmt)
Returns today.

Parameters:
fmt - the time format, such as HH:mm:ss.SSS If a time element such as seconds not specified in the format, it will be considered as 0. For example, if the format is "HH:mm", then the returned object will be today, this hour and this minute, but the second and milliseconds will be zero.
Returns:
Date
Since:
5.0.6

today

public static Date today(boolean full)
Returns today.

Parameters:
full - if true, returns the full time, else only returns year, month, and day. If omitted, false is assumed
Returns:
Date

isAncestor

public static boolean isAncestor(java.lang.Object p,
                                 java.lang.Object c)
Returns if one is ancestor of the other. It assumes the object has either a method called getParent or a field called parent. A typical example is used to test the widgets (Widget).

Notice that, if you want to test DOM elements, please use jq.isAncestor(_global_.DOMElement, _global_.DOMElement) instead.

Parameters:
p - the parent. This method return true if p is null or p is the same as c
c - the child
Returns:
boolean
See Also:
jq.isAncestor(_global_.DOMElement, _global_.DOMElement)

progressbox

public static void progressbox(String id,
                               String msg,
                               boolean mask,
                               String icon)
Creates a message box to indicate something is being processed

Parameters:
id - the ID of the DOM element being created
msg - the message to shown
mask - whether to show sem-transparent mask to prevent the user from accessing it.
icon - the CSS class used to shown an icon in the box. Ignored if not specified.
See Also:
destroyProgressbox(_global_.String)

destroyProgressbox

public static void destroyProgressbox(String id)
Removes the message box created by progressbox(_global_.String, _global_.String, boolean, _global_.String).

Parameters:
id - the ID of the DOM element of the message box

go

public static void go(String url,
                      Map opts)
Navigates to the specified URL.

Parameters:
url - the URL to go to
opts - [optional] the options. Allowed values:
  • target - the name of the target browser window. The same browswer window is assumed if omitted. You can use any value allowed in the target attribute of the HTML FORM tag, such as _self, _blank, _parent and _top.
  • overwrite - whether load a new page in the current browser window. If true, the new page replaces the previous page's position in the history list.

frames

public static Array frames(Window w)
Returns all descendant frames of the given window.

To retrieve all, invoke zUtl.frames(top). Notice: w is included in the returned array. If you want to exclude it, invoke zUtl.frames(w).$remove(w).

Parameters:
w - the browser window
Returns:
Array
Since:
5.0.4

intsToString

public static String intsToString(int[] ary)
Converts an integer array to a string (separated by comma).

Parameters:
ary - the integer array to convert. If null, an empty string is returned.
Returns:
String
See Also:
stringToInts(_global_.String, int)

stringToInts

public static int[] stringToInts(String text,
                                 int defaultValue)
Converts a string separated by comma to an array of integers.

Parameters:
text - the string to convert. If null, null is returned.
defaultValue - the default value used if the value is not specified. For example, zUtl.stringToInts("1,,3", 2) returns [1, 2, 3].
Returns:
int[]
See Also:
intsToString(int[])

mapToString

public static String mapToString(Map map,
                                 String assign,
                                 String separator)
Converts a map to a string

Parameters:
map - the map to convert
assign - the symbol for assignment. If omitted, '=' is assumed.
separator - the symbol for separator. If omitted, ',' is assumed.
Returns:
String
See Also:
intsToString(int[])

appendAttr

public static void appendAttr(String nm,
                              java.lang.Object val,
                              boolean force)
Appends an attribute. Notice that the attribute won't be appended.

Parameters:
nm - the name of the attribute
val - the value of the attribute
force - whether to append attribute no matter what value it is. If false (or omitted), it is the same as appendAttr(String, Object).
Since:
5.0.3

appendAttr

public static void appendAttr(String nm,
                              java.lang.Object val)
Appends an attribute. Notice that the attribute won't be appended if val is empty or false. In other words, it is equivalent to
val ? ' ' + nm + '="' + val + '"': "".

If you want to generate the attribute no matter what val is, use appendAttr(String, Object, boolean).

Parameters:
nm - the name of the attribute
val - the value of the attribute
Since:
5.0.3

fireSized

public static void fireSized(Widget wgt,
                             int bfsz)
Fires beforeSize, onFitSize and onSize

Parameters:
wgt - the widget which the zWatch event will be fired against.
bfsz - the beforeSize mode:
  • 0 (null/undefined/false): beforeSize sent normally.
  • -1: beforeSize won't be sent.
  • 1: beforeSize will be sent with an additional cleanup option, which will clean up the cached minimal size (if flex=min).
Since:
5.0.8

fireShown

public static void fireShown(Widget wgt,
                             int bfsz)
Fires onBeforeSize, onShow, onFitSize, and onSize

Parameters:
wgt - the widget which the zWatch event will be fired against.
bfsz - the beforeSize mode:
  • 0 (null/undefined/false): beforeSize sent normally.
  • -1: beforeSize won't be sent.
  • 1: beforeSize will be sent with an additional cleanup option, which will clean up the cached minimal size (if flex=min).
Since:
5.0.8

loadImage

public static void loadImage(String url)
Loads an image before ZK client engine to calculate the widget's layout.

Parameters:
url - the loading image's localation
Since:
6.0.0

isImageLoading

public static void isImageLoading()
Checks whether all the loading images are finish.

Since:
6.0.0
See Also:
loadImage(_global_.String)

now

public static long now()
Deprecated. As of release 5.0.6, replaced with jq.now().

Returns a long value representing the current time (unit: miliseconds).

Returns:
long


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo