Changeset 263


Ignore:
Timestamp:
Apr 24, 2007, 1:24:48 PM (15 years ago)
Author:
Johan Enell
Message:

Added methods to get sections of a specific type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/onk/BaseFile/src/basefile/BASEFile.java

    r253 r263  
    3030import java.util.ArrayList;
    3131import java.util.HashMap;
     32import java.util.List;
    3233
    3334public class BASEFile<R, S>
     
    167168
    168169  /**
     170   * Get a section of a specific type.
     171   *
     172   * @param type the section type
     173   * @return a section or null the type type couldn't be found.
     174   */
     175  public BASEFileSection getSection(String type)
     176  {
     177    for (BASEFileSection bfs : sections)
     178    {
     179      if (bfs.isType(type)) return bfs;
     180    }
     181    return null;
     182  }
     183
     184  /**
     185   * Get all sections of a specific type.
     186   *
     187   * @param type the section type
     188   * @return a section or an empty list the type type couldn't be found.
     189   */
     190  public List<BASEFileSection> getSections(String type)
     191  {
     192    ArrayList<BASEFileSection> list = new ArrayList<BASEFileSection>();
     193    for (BASEFileSection bfs : sections)
     194    {
     195      if (bfs.isType(type)) list.add(bfs);
     196    }
     197    return list;
     198  }
     199 
     200  /**
    169201   * This method assumes that the basefile only contains one spot section and
    170202   * returns the fist in the list.
Note: See TracChangeset for help on using the changeset viewer.