private XObject[] addCubes(XFolder parent, Database db) {
    int allCubeCnt = db.getCubeCount();
    int cubeCnt = 0;
    XObject ret[];

    for (int i = 0; i < allCubeCnt; i++) {
      Cube cube = db.getCubeAt(i);
      if ((parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_CUBES) && isDataCube(cube))
          || (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_SYSTEMCUBES)
              && cube.isSystemCube())
          || (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_ATTRIBUTECUBES)
              && cube.isAttributeCube())) {
        cubeCnt++;
      }
    }

    if (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_CUBES)) {
      cubeCnt += 2; // for additional subfolders
    }

    ret = new XObject[cubeCnt];
    int curCube = 0;

    for (int i = 0; i < allCubeCnt; i++) {
      Cube cube = db.getCubeAt(i);
      if ((parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_CUBES) && isDataCube(cube))
          || (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_SYSTEMCUBES)
              && cube.isSystemCube())
          || (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_ATTRIBUTECUBES)
              && cube.isAttributeCube())) {
        ret[curCube] = new XCube();
        ret[curCube].setName(cube.getName());
        setIdToXObject(ret[curCube]);
        //				ret[curCube].setId(cube.getId());
        curCube++;
      }
    }

    if (parent.getFolderType().equalsIgnoreCase(TYPE_STATIC_FOLDER_CUBES)) {
      ret[curCube] =
          addStaticFolder(parent, "Attribute Cubes", db.getId(), TYPE_STATIC_FOLDER_ATTRIBUTECUBES);
      ret[curCube + 1] =
          addStaticFolder(parent, "System Cubes", db.getId(), TYPE_STATIC_FOLDER_SYSTEMCUBES);
    }

    return ret;
  }