// ////////////////////////////////////////////////////////
// Copyright (1994) Columbia University
// Department of Biochemistry and Molecular Biophysics
//
// Author: Weider Chang, Ph.D
// ///////////////////////////////////////////////////////

#ifndef _STARUTILITYCOMPRISING_M_
#define _STARUTILITYCOMPRISING_M_

- getDefinitionBlocksWhos:(char*)aItemName is:(char*)aValue
{
  id temp, value, blockList=0;
  id iter=[[WDCListIterator alloc] initFrom:self];
  while ([iter goNext]){
    temp=[iter getCurrentObject];
    value=[temp getDataItem:aItemName]; 
/* 
  need more flexibility in here in order to work with more types of object.
  So is the getValue method in the next statement.
  */
    if (value && ![[value getValue] compareCString : aValue ignoreCase:YES])
      {
	if (!blockList)
	  {
	    blockList=[[WDCIndexedCollection alloc]
		     initEncoding:@encode(WDCStarDataBlock*)];
	  }
	[blockList addElement: temp]; 
      }
  }
  [iter free];
  return blockList;
}

- getDefinitionBlocksHaveNo:(char *)aItemName
{
  id temp, blockList=0;
  id iter=[[WDCListIterator alloc] initFrom:self];
  while ([iter goNext]){
    temp=[iter getCurrentObject];
    if (![temp getDataItem:aItemName])
      {
	if (!blockList)
	  {
	    blockList=[[WDCIndexedCollection alloc]
		     initEncoding:@encode(WDCStarDataBlock*)];
	  }
	[blockList addElement: temp];   
      }
  }
  [iter free];
  return blockList;
}

- getAllUnique:(char*)aItemName
{
  id temp, objectList=0;
  id iter=[[WDCListIterator alloc] initFrom:self];
  while ([iter goNext]){
    temp=[iter getCurrentObject];
    if (temp && (temp=[[temp getDataItem:aItemName] getValue]))
      {
	if (!objectList)
	  {
	    objectList=[[WDCIndexedCollection alloc]
		     initEncoding:@encode(WDCStarDataBlock*)];
	  }
	if (![objectList isExist:temp]) 
	  [objectList addElement: temp];   
      }
  }
  [iter free];
  return objectList;  
}

- getIndexedListOfDataBlocks
{
  id objectList=[[WDCIndexedCollection alloc]
		 initEncoding :@encode(WDCStarDataBlock*)];
  id iter=[[WDCListIterator alloc] initFrom:self];
  while ([iter goNext]) [objectList addElement: [iter getCurrentObject]];
  [iter free];
  return objectList;
}

#endif






