org.zkoss.zk.ui
Class Components

java.lang.Object
  extended by org.zkoss.zk.ui.Components

public class Components
extends java.lang.Object

Utilities to access Component.

Author:
tomyeh

Constructor Summary
protected Components()
           
 
Method Summary
static java.lang.String componentToPath(Component comp, Component ref)
          Converts a component to a path (relavant to another component).
static int getScope(java.lang.String scope)
          Converts a string to an integer that can be used to access Component.getAttribute(String, int)
static java.util.Collection getVisibleChildren(Component comp)
          Returns a collection of visible children.
static boolean isAncestor(Component node1, Component node2)
          Tests whether node1 is an ancessor of node 2.
static boolean isAutoId(java.lang.String id)
          Returns whether an ID is generated automatically.
static boolean isRealVisible(Component comp)
          Returns whether this component is real visible (all its parents are visible).
static Component pathToComponent(java.lang.String path, Component ref)
          Converts a path, generated by componentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component), to a component.
static void removeAllChildren(Component comp)
          Removes all children of the specified component.
static java.lang.String scopeToString(int scope)
          Converts an integer to the string representing the scope.
static void sort(java.util.List list, java.util.Comparator cpr)
          Sorts the components in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Components

protected Components()
Method Detail

sort

public static void sort(java.util.List list,
                        java.util.Comparator cpr)
Sorts the components in the list.

Note: you cannot use Collections.sort to sort Component.getChildren() because Collections.sort might cause some replicated item in the list.


isAncestor

public static boolean isAncestor(Component node1,
                                 Component node2)
Tests whether node1 is an ancessor of node 2. If node1 and node2 is the same, true is returned.


removeAllChildren

public static void removeAllChildren(Component comp)
Removes all children of the specified component.


isRealVisible

public static boolean isRealVisible(Component comp)
Returns whether this component is real visible (all its parents are visible).

See Also:
Component.isVisible()

getVisibleChildren

public static java.util.Collection getVisibleChildren(Component comp)
Returns a collection of visible children.

The performance of the returned collection's size() is NO GOOD.


getScope

public static final int getScope(java.lang.String scope)
Converts a string to an integer that can be used to access Component.getAttribute(String, int)


scopeToString

public static final java.lang.String scopeToString(int scope)
Converts an integer to the string representing the scope.

Parameters:
scope - one of Component.COMPONENT_SCOPE, Component.SPACE_SCOPE, Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE, Component.REQUEST_SCOPE, and Component.APPLICATION_SCOPE.

isAutoId

public static final boolean isAutoId(java.lang.String id)
Returns whether an ID is generated automatically.


componentToPath

public static final java.lang.String componentToPath(Component comp,
                                                     Component ref)
Converts a component to a path (relavant to another component). It is usefully to implement a serializable component that contains a reference to another component. In this case, we can not serializes the reference directly (otherwise, another component will be created, when deserialized).

Rather, it is better to store the path related, and then restore it back to a component by calling pathToComponent(java.lang.String, org.zkoss.zk.ui.Component).

Parameters:
comp - the component to be converted to path. It cannot be null.
ref - the component used to generated the path from. It cannot be null.
Returns:
the path. Notice that you have to use pathToComponent(java.lang.String, org.zkoss.zk.ui.Component) to convert it back.
Throws:
java.lang.UnsupportedOperationException - if we cannot find a path to the component to write.
Since:
3.0.0

pathToComponent

public static final Component pathToComponent(java.lang.String path,
                                              Component ref)
Converts a path, generated by componentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component), to a component.

Parameters:
ref - the component used to generated the path from. It cannot be null. It is the same as the one when calling componentToPath(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component).
Since:
3.0.0


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.