示例#1
0
  @Override
  public IContainer getContainer(String shortName) {
    List<IContainer> list = listChildren();
    IContainer result = null;

    for (IContainer container : list) {
      if (container.getShortName().equals(shortName)) {
        result = container;
        break;
      }
    }

    return result;
  }
示例#2
0
  @Override
  public List<IContainer> findAllContainerByPath(String path) throws NoResultException {
    List<IContainer> list = new ArrayList<IContainer>();
    List<IContainer> tmp = null;
    String tmpName;

    // Store in a map all different containers from all m_groups
    Map<String, ArrayList<IContainer>> items = new HashMap<String, ArrayList<IContainer>>();
    for (IGroup group : mGroups) {
      try {
        tmp = group.findAllContainerByPath(path);
        for (IContainer item : tmp) {
          tmpName = item.getShortName();
          if (items.containsKey(tmpName)) {
            items.get(tmpName).add(item);
          } else {
            ArrayList<IContainer> tmpList = new ArrayList<IContainer>();
            tmpList.add(item);
            items.put(tmpName, tmpList);
          }
        }
      } catch (NoResultException e) {
        // Nothing to do
      }
    }

    // Construct that were found
    for (Entry<String, ArrayList<IContainer>> entry : items.entrySet()) {
      tmp = entry.getValue();
      // If a Group list then construct a new Group folder
      if (tmp.get(0).getModelType() == ModelType.Group) {
        list.add(new NxsGroup(tmp.toArray(new IGroup[tmp.size()]), this, mDataset));
      }
      // If a IDataItem list then construct a new compound NxsDataItem
      else {
        ArrayList<NexusDataItem> dataItems = new ArrayList<NexusDataItem>();
        for (IContainer item : tmp) {
          if (item.getModelType() == ModelType.DataItem) {
            dataItems.add((NexusDataItem) item);
          }
        }
        NexusDataItem[] array = new NexusDataItem[dataItems.size()];
        dataItems.toArray(array);
        list.add(new NxsDataItem(array, this, mDataset));
      }
    }

    return list;
  }
示例#3
0
  private List<IContainer> listChildrenMultiGroup() {
    if (!mIsChildUpdate) {
      List<IContainer> tmp = null;
      mChildren = new ArrayList<IContainer>();
      String tmpName;

      // Store in a map all different containers from all m_groups
      Map<String, ArrayList<IContainer>> items = new HashMap<String, ArrayList<IContainer>>();
      for (IGroup group : mGroups) {
        tmp = new ArrayList<IContainer>();
        tmp.addAll(group.getDataItemList());
        tmp.addAll(group.getGroupList());
        for (IContainer item : tmp) {
          tmpName = item.getShortName();
          if (items.containsKey(tmpName)) {
            items.get(tmpName).add(item);
          } else {
            ArrayList<IContainer> tmpList = new ArrayList<IContainer>();
            tmpList.add(item);
            items.put(tmpName, tmpList);
          }
        }
      }

      // Construct what were found
      for (Entry<String, ArrayList<IContainer>> entry : items.entrySet()) {
        tmp = entry.getValue();
        // If a Group list then construct a new Group folder
        if (tmp.get(0).getModelType() == ModelType.Group) {
          mChildren.add(new NxsGroup(tmp.toArray(new IGroup[tmp.size()]), this, mDataset));
        }
        // If a IDataItem list then construct a new compound NxsDataItem
        else {
          ArrayList<NexusDataItem> nxsDataItems = new ArrayList<NexusDataItem>();
          for (IContainer item : tmp) {
            if (item.getModelType() == ModelType.DataItem) {
              nxsDataItems.add((NexusDataItem) item);
            }
          }
          NexusDataItem[] array = new NexusDataItem[nxsDataItems.size()];
          nxsDataItems.toArray(array);
          mChildren.add(new NxsDataItem(array, this, mDataset));
        }
      }
      mIsChildUpdate = true;
    }
    return mChildren;
  }