collectionutilities.java
来自「本程序是有IBM开发的一个基于数据表格的组件,里面有相关的例子和DOC,本站资料」· Java 代码 · 共 109 行
JAVA
109 行
package com.ibm.j2x.util;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.SortedBag;
import com.ibm.j2x.util.collection.ObservableBag;
import com.ibm.j2x.util.collection.ObservableList;
import com.ibm.j2x.util.collection.ObservableMap;
import com.ibm.j2x.util.collection.ObservableSet;
import com.ibm.j2x.util.collection.ObservableSortedBag;
import com.ibm.j2x.util.collection.ObservableSortedMap;
import com.ibm.j2x.util.collection.ObservableSortedSet;
/**
* The CollectionUtilities provides methods for wrapping normal Collection
* objects with ObservableCollection objects, which allows a listener to register
* for changes to the Collection object.
* <p>Although the Collection interface is not implemented by Maps, and therefore
* it seems inconsistent to place it in a CollectionUtilities class, it is sticking
* with the inconsistent Sun standard used in the <code>Collections</code> object.
* @author MAbernethy
*/
public class CollectionUtilities
{
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the list by calling its <code>addCollectionListener()</code> method.
* @param l the list for which the observable list is returned
* @return an observable view of the specified list
*/
public static List observableList(List l)
{
return new ObservableList(l);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the set by calling its <code>addCollectionListener()</code> method.
* @param s the set for which the observable set is returned
* @return an observable view of the specified set
*/
public static Set observableSet(Set s)
{
return new ObservableSet(s);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the sorted set by calling its <code>addCollectionListener()</code> method.
* @param s the sorted set for which the observable sorted set is returned
* @return an observable view of the specified sorted set
*/
public static SortedSet observableSortedSet(SortedSet s)
{
return new ObservableSortedSet(s);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the map by calling its <code>addCollectionListener()</code> method.
* @param m the map for which the observable map is returned
* @return an observable view of the specified map
*/
public static Map observableMap(Map m)
{
return new ObservableMap(m);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the sorted map by calling its <code>addCollectionListener()</code> method.
* @param m the sorted map for which the observable sorted map is returned
* @return an observable view of the specified sorted map
*/
public static SortedMap observableSortedMap(SortedMap m)
{
return new ObservableSortedMap(m);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the bag by calling its <code>addCollectionListener()</code> method.
* @param b the bag for which the observable bag is returned
* @return an observable view of the specified bag
*/
public static Bag observableBag(Bag b)
{
return new ObservableBag(b);
}
/**
* Returns an observable view of the specified object. Listeners can observe
* changes to the sorted bag by calling its <code>addCollectionListener()</code> method.
* @param b the sorted bag for which the observable sorted bag is returned
* @return an observable view of the specified sorted bag
*/
public static SortedBag observableSortedBag(SortedBag b)
{
return new ObservableSortedBag(b);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?