Package org.zkoss.zul.impl
Class Utils
java.lang.Object
org.zkoss.zul.impl.Utils
A collection of utilities.
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringarrayToString(Object[] ary) Converts an array of objects to a string, by concatenating them together and separated with comma.static StringValidates an enumerated string value against a fixed set of accepted tokens — the idiom shared by the enumerated setters ofzulcomponents (shape, size, severity, placement, orient, effect, ...).static org.zkoss.zk.ui.ComponentgetComponentById(org.zkoss.zk.ui.Component comp, String id) Returns the component of the specified ID or UUID.static StringgetDynamicMediaURI(org.zkoss.zk.ui.AbstractComponent comp, int version, String name, String format) Returns the encoded URL for the dynamic generated content, or empty the component doesn't belong to any desktop.static final intgetIntAttribute(org.zkoss.zk.ui.Component comp, String name, int defValue, boolean recurse) Returns the number if the given attribute is defined in a component or in library property.static final StringgetStringAttribute(org.zkoss.zk.ui.Component comp, String name, String defValue, boolean recurse) Returns the string if the given attribute is defined in a component or in library property.static final StringintsToString(int[] ary) Converts an array of numbers to a string.static final StringGenerates the ZK feature informationstatic final StringGenerates the locale-dependent JavaScript codes, such as messages (msgzul).static voidrenderCrawlableA(String href, String label) Render the crawlable HTML A tag.static voidrenderCrawlableText(String text) Render the crawlable text.static final String[]stringToArray(String src, String defaultValue) Parse a list of numbers.static final int[]stringToInts(String numbers, int defaultValue) Parse a list of numbers.static final booleantestAttribute(org.zkoss.zk.ui.Component comp, String name, boolean defValue, boolean recurse) Tests if the given attribute is defined in a component or in library property.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
checkEnum
public static String checkEnum(String value, String defaultValue, String message, String... allowed) throws org.zkoss.zk.ui.WrongValueException Validates an enumerated string value against a fixed set of accepted tokens — the idiom shared by the enumerated setters ofzulcomponents (shape, size, severity, placement, orient, effect, ...).- Parameters:
value- the incoming value.defaultValue- the value returned whenvalueisnull; pass the component's default to reset-on-null, ornullto keep a nullable "no override" value.message- theWrongValueExceptionmessage prefix; the rejected value is appended to it.allowed- the accepted (non-null) tokens.- Returns:
valuewhen it is accepted, ordefaultValuewhenvalueisnull.- Throws:
org.zkoss.zk.ui.WrongValueException- ifvalueis non-null and not one ofallowed.- Since:
- 11.0.0
-
stringToInts
public static final int[] stringToInts(String numbers, int defaultValue) throws org.zkoss.zk.ui.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:
org.zkoss.zk.ui.WrongValueException
-
intsToString
Converts an array of numbers to a string. -
stringToArray
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
Converts an array of objects to a string, by concatenating them together and separated with comma. -
getDynamicMediaURI
public static String getDynamicMediaURI(org.zkoss.zk.ui.AbstractComponent comp, int version, String name, 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
Generates the ZK feature information- Since:
- 6.5.1
-
outLocaleJavaScript
Generates the locale-dependent JavaScript codes, such as messages (msgzul).It is called by zul/lang/zk.wpd.
-
renderCrawlableA
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:
IOException- Since:
- 5.0.0
-
renderCrawlableText
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:
IOException- Since:
- 5.0.0
-
getComponentById
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(org.zkoss.zk.ui.Component comp, 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 attributedefValue- the default value if neither component's attribute or library property is defined for the given namerecurse- whether to look up the ancestor's attribute- Since:
- 5.0.7
-
getIntAttribute
public static final int getIntAttribute(org.zkoss.zk.ui.Component comp, 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 attributedefValue- the default value if neither component's attribute or library property is defined for the given namerecurse- whether to look up the ancestor's attribute- Since:
- 5.0.8
-
getStringAttribute
public static final String getStringAttribute(org.zkoss.zk.ui.Component comp, String name, String defValue, boolean recurse) Returns the string if the given attribute is defined in a component or in library property.- Parameters:
name- the name of the attributedefValue- the default value if neither component's attribute or library property is defined for the given namerecurse- whether to look up the ancestor's attribute- Since:
- 10.3.0
-