Class Immutables

java.lang.Object
org.zkoss.stateless.ui.util.Immutables

public final class Immutables extends Object
An immutables utils.
Author:
jumperchen
  • Constructor Details

    • Immutables

      public Immutables()
  • Method Details

    • proxyIComponent

      public static <T extends org.zkoss.zk.ui.Component, I extends IComponent> I proxyIComponent(T t)
      Makes a proxy of Component into IComponent.
      Parameters:
      t - a ZK Component
      Returns:
      a proxy of IComponent
    • proxyIChildren

      public static List<? extends IComponent> proxyIChildren(org.zkoss.zk.ui.Component instance)
    • proxyIChild

      public static IComponent proxyIChild(org.zkoss.zk.ui.Component instance)
    • proxyIChild

      public static IComponent proxyIChild(org.zkoss.zk.ui.Component instance, Class<? extends org.zkoss.zk.ui.Component> skipClass)
    • createComponents

      public static <T extends IComponent> List<T> createComponents(org.zkoss.zk.ui.metainfo.PageDefinition pagedef, Map<?,?> arg)
      Creates IComponents from Components that don't belong to any page from the specified page definition.
      Parameters:
      pagedef - the page definition to use. It cannot be null.
      arg - a map of parameters that is accessible by the arg variable in EL, or by Execution.getArg(). Ignored if null.
      Returns:
      the first component being created.
      Since:
      2.4.0
      See Also:
    • createComponents

      public static <T extends IComponent> List<T> createComponents(String uri, Map<?,?> arg)
      Creates IComponents from Components that don't belong to any page from a page file specified by an URI.

      It loads the page definition from the specified URI (by use Execution.getPageDefinition(java.lang.String) ), and then invokes createComponents(PageDefinition,Map) to create components.

      Parameters:
      arg - a map of parameters that is accessible by the arg variable in EL, or by Execution.getArg(). Ignored if null.
      See Also:
    • createComponentsDirectly

      public static <T extends IComponent> List<T> createComponentsDirectly(String content, String extension, Map<?,?> arg)
      Creates IComponents from Components that don't belong to any page from the raw content specified by a string.

      The raw content is parsed to a page definition by use of Execution.getPageDefinitionDirectly(String, String), and then invokes createComponents(PageDefinition,Map) to create components.

      Parameters:
      content - the raw content of the page. It must be in ZUML.
      extension - the default extension if the content doesn't specify an language. In other words, if the content doesn't specify an language, LanguageDefinition.getByExtension(java.lang.String) is called. If extension is null and the content doesn't specify a language, the language called "xul/html" is assumed.
      arg - a map of parameters that is accessible by the arg variable in EL, or by Execution.getArg(). Ignored if null.
      See Also:
    • newReplacer

      public static <T extends IComponent> IReplacer<T> newReplacer(T root)
      Constructs a replacer for replacing the descendant of the IComponent tree in a bulk execution for multiple replacements. By default, the implementation uses BFS algorithm to traverse the whole tree to seek the replacement target.
      Parameters:
      root - The root IComponent tree.
      Returns:
      A replacer implementation of IReplacer
    • replaceDescendant

      public static <R extends IComponent, T extends IComponent> R replaceDescendant(R root, T source, T target)
      Replaces the descendant of the given root with the new child from the given source, if any.
      Parameters:
      root - The root IComponent tree.
      source - The replaced source.
      target - The replaced target.
      Returns:
      The new IComponent tree.
    • replaceDescendantById

      public static <R extends IComponent> R replaceDescendantById(R root, String sourceId, IComponent<?> target)
      Replaces the descendant of the given root with the new child from the given source, if any.
      Parameters:
      root - The root IComponent tree.
      sourceId - The id of the replaced source.
      target - The replaced target.
      Returns:
      The new IComponent tree.
    • replaceDescendantById

      public static <R extends IComponent, T extends IComponent> R replaceDescendantById(R root, String sourceId, CheckedFunction<T,T> targetFunction)
      Replaces the descendant of the given root with the new child from the given source, if any.
      Parameters:
      root - The root IComponent tree.
      sourceId - The id of the replaced source.
      targetFunction - The replacement function by passing the result of the source and returning the new replacement. If null, it means to remove the replaced source.
      Returns:
      The new IComponent tree.