org.zkoss.zul.impl
Class Utils

java.lang.Object
  extended by org.zkoss.zul.impl.Utils

public class Utils
extends java.lang.Object

A collection of utilities.

Author:
tomyeh

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String arrayToString(java.lang.Object[] ary)
          Converts an array of objects to a string, by concatenating them together and separated with comma.
static Component getComponentById(Component comp, java.lang.String id)
          Returns the component of the specified ID or UUID.
static java.lang.String getDynamicMediaURI(AbstractComponent comp, int version, java.lang.String name, java.lang.String format)
          Returns the encoded URL for the dynamic generated content, or empty the component doesn't belong to any desktop.
static int getIntAttribute(Component comp, java.lang.String name, int defValue, boolean recurse)
          Returns the number if the given attribute is defined in a component or in library property.
static java.lang.String intsToString(int[] ary)
          Converts an array of numbers to a string.
static java.lang.String outFeature()
          Generates the ZK feature information
static java.lang.String outLocaleJavaScript()
          Generates the locale-dependent JavaScript codes, such as messages (msgzul).
static void renderCrawlableA(java.lang.String href, java.lang.String label)
          Render the crawlable HTML A tag.
static void renderCrawlableText(java.lang.String text)
          Render the crawlable text.
static java.lang.String[] stringToArray(java.lang.String src, java.lang.String defaultValue)
          Parse a list of numbers.
static int[] stringToInts(java.lang.String numbers, int defaultValue)
          Parse a list of numbers.
static boolean testAttribute(Component comp, java.lang.String name, boolean defValue, boolean recurse)
          Tests if the given attribute is defined in a component or in library property.
 
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

stringToInts

public static final int[] stringToInts(java.lang.String numbers,
                                       int defaultValue)
                                throws WrongValueException
Parse a list of numbers.

Parameters:
defaultValue - the value if a number is omitted. For example, ",2" means "1,2" if defafultValue is 1
Returns:
an array of int, or null if no integer at all
Throws:
WrongValueException

intsToString

public static final java.lang.String intsToString(int[] ary)
Converts an array of numbers to a string.


stringToArray

public static final java.lang.String[] stringToArray(java.lang.String src,
                                                     java.lang.String defaultValue)
Parse a list of numbers.

Parameters:
defaultValue - the value used if an empty string is fund. For example, ",2" means "1,2" if defafultValue is "1"
Returns:
an array of string, or null if no data at all

arrayToString

public static final java.lang.String arrayToString(java.lang.Object[] ary)
Converts an array of objects to a string, by concatenating them together and separated with comma.


getDynamicMediaURI

public static java.lang.String getDynamicMediaURI(AbstractComponent comp,
                                                  int version,
                                                  java.lang.String name,
                                                  java.lang.String format)
Returns the encoded URL for the dynamic generated content, or empty the component doesn't belong to any desktop.

Since:
3.0.2

outFeature

public static final java.lang.String outFeature()
Generates the ZK feature information

Since:
6.5.1

outLocaleJavaScript

public static final java.lang.String outLocaleJavaScript()
Generates the locale-dependent JavaScript codes, such as messages (msgzul).

It is called by zul/lang/zk.wpd.


renderCrawlableA

public static void renderCrawlableA(java.lang.String href,
                                    java.lang.String label)
                             throws java.io.IOException
Render the crawlable HTML A tag. If crawlable is not enabled or href is empty, nothing is generated.

Parameters:
href - the hyper link. If null or empty, nothing is generated.
label - the label to show. Empty is assumed if null.
Throws:
java.io.IOException
Since:
5.0.0

renderCrawlableText

public static void renderCrawlableText(java.lang.String text)
                                throws java.io.IOException
Render the crawlable text. If crawlable is not enabled or the text is empty, nothing is generated.

Parameters:
text - the text that is crawlable. If null or empty, nothing is generated.
Throws:
java.io.IOException
Since:
5.0.0

getComponentById

public static Component getComponentById(Component comp,
                                         java.lang.String id)
Returns the component of the specified ID or UUID. ID could be the component's ID or UUID. To specify an UUID, it must be the format: uuid(comp_uuid).

Returns:
the component, or null if not found
Since:
5.0.4

testAttribute

public static final boolean testAttribute(Component comp,
                                          java.lang.String name,
                                          boolean defValue,
                                          boolean recurse)
Tests if the given attribute is defined in a component or in library property.

Parameters:
name - the name of the attribute
defValue - the default value if neither component's attribute or library property is defined for the given name
recurse - whether to look up the ancestor's attribute
Since:
5.0.7

getIntAttribute

public static final int getIntAttribute(Component comp,
                                        java.lang.String name,
                                        int defValue,
                                        boolean recurse)
Returns the number if the given attribute is defined in a component or in library property.

Parameters:
name - the name of the attribute
defValue - the default value if neither component's attribute or library property is defined for the given name
recurse - whether to look up the ancestor's attribute
Since:
5.0.8


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