}
public NSArray sections() {
if (_sections==null) {
_sections= new NSMutableArray();
NSArray list=(NSArray)valueForBinding("list");
_itemsPerSection=new NSMutableDictionary();
if (list!=null) {
boolean ignoreNulls = booleanValueForBinding("ignoreNulls", false);
for (Enumeration e=list.objectEnumerator(); e.hasMoreElements();) {
Object item=e.nextElement();
if(log.isDebugEnabled()) log.debug("item = "+item);
// push value up, so parent can tell us the group
setValueForBinding(item,"item");
// Sections have to be copiable objects -- no EOs!!
Object section=valueForBinding("sectionForItem");
if (section==NSKeyValueCoding.NullValue) section=null;
Object sectionKey;
if(section == null) {
if(ignoreNulls) {
continue;
}
section=NULL;
}
sectionKey = keyForSection(section);
if(sectionKey instanceof NSArray) {
NSArray array = (NSArray)sectionKey;
int index = 0;
for (Enumeration keys = ((NSArray)sectionKey).objectEnumerator(); keys.hasMoreElements(); ) {
Object currentKey = keys.nextElement();
Object currentSection = ((NSArray)section).objectAtIndex(index++);
NSMutableArray currentItemsForSection=(NSMutableArray)_itemsPerSection.objectForKey(currentKey);