Package org.zkoss.zk.ui.impl

## Class Utils

- java.lang.Object
- - org.zkoss.zk.ui.impl.Utils

-     public class Utils
      extends java.lang.Object

  Utilities to implement ZK.
  Since:
    5.0.7
  Author:
    tomyeh

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Utils()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static ComponentInfo` | `getComponentInfo​(Component comp)` | Returns the component info associated with the given component, or null if not available.
    `static XMLResourcesLocator` | `getXMLResourcesLocator()` | Returns the XML resources locator to locate metainfo/zk/config.xml, metainfo/zk/lang.xml, and metainfo/zk/lang-addon.xml
    `static boolean` | `markClientInfoPerDesktop​(Desktop desktop, java.lang.String key)` | Marks the per-desktop information of the given key will be generated, and returns true if the information is not generated yet (i.e., this method is NOT called with the given key).
    `static Composer` | `newComposer​(Page page, java.lang.Object o)` | Instantiates a composer of the given object.
    `static void` | `setComponentInfo​(Component comp, ComponentInfo info)` | Sets the component info for the given component.
    `static void` | `setShadowInfo​(Component comp, ShadowInfo info)` | Sets the component info for the given component.
    `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

    - #### markClientInfoPerDesktop

          public static boolean markClientInfoPerDesktop​(Desktop desktop,
                                                         java.lang.String key)

      Marks the per-desktop information of the given key will be generated, and returns true if the information is not generated yet (i.e., this method is NOT called with the given key). You could use this method to minimize the bytes to be sent to the client if the information is required only once per desktop.

    - #### getXMLResourcesLocator

          public static XMLResourcesLocator getXMLResourcesLocator()

      Returns the XML resources locator to locate metainfo/zk/config.xml, metainfo/zk/lang.xml, and metainfo/zk/lang-addon.xml

    - #### newComposer

          public static Composer newComposer​(Page page,
                                             java.lang.Object o)
                                      throws java.lang.Exception

      Instantiates a composer of the given object. This method will invoke `UiFactory.newComposer(org.zkoss.zk.ui.Page, java.lang.Class)` to instantiate the composer if page is not null.
      Parameters:
        `page` - the page that the composer will be created for. Ignored if null.
        `o` - the composer instance, the class of the composer to instantiate, or the name of the class of the composer. If `o` is an instance of `Composer`, it is returned directly.
      Throws:
        `java.lang.Exception`

    - #### getComponentInfo

          public static ComponentInfo getComponentInfo​(Component comp)

      Returns the component info associated with the given component, or null if not available.

      It is used only internally.

    - #### setComponentInfo

          public static void setComponentInfo​(Component comp,
                                              ComponentInfo info)

      Sets the component info for the given component.

      It is used only internally.

    - #### 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

    - #### setShadowInfo

          public static void setShadowInfo​(Component comp,
                                           ShadowInfo info)

      Sets the component info for the given component.

      It is used only internally.

      Since:
        8.0.0