< prev index next >

## src/com/sun/javatest/cof/MTL.java

Print this page

      30 import java.nio.charset.StandardCharsets;
      31 import java.util.ArrayList;
      32 import java.util.HashMap;
      33 import java.util.List;
      34 import java.util.StringTokenizer;
      35
      36 /**
      37  * Reads and stores master test list content
      38  */
      39 public class MTL {
      40
      41     private final File mtl;
      42     private HashMap<String, ArrayList<String>> table;
      43
      44     MTL(File mtlFile) {
      45         mtl = mtlFile;
      46     }
      47
      48     private void init() {
      49         if (table == null) {
      50             table = new HashMap<String, ArrayList<String>>();
      51             BufferedReader r = null;
      52             try {
      53                 r = new BufferedReader(new InputStreamReader(new FileInputStream(mtl), StandardCharsets.UTF_8));
      54                 String line;
      55                 while ((line = r.readLine()) != null) {
      56                     StringTokenizer st = new StringTokenizer(line);
      57                     ArrayList<String> cases = new ArrayList<String>();
      58                     String testName = null;
      59                     if (st.hasMoreTokens()) {
      60                         testName = st.nextToken();
      61                     }
      62                     while (st.hasMoreTokens()) {
      63                         cases.add(st.nextToken());
      64                     }
      65                     if (testName != null) {
      66                         table.put(testName, cases);
      67                     }
      68                 }
      69             } catch (IOException ex) {
      70                 throw new IllegalArgumentException(ex);
      71             } finally {
      72                 try {
      73                     if (r != null)
      74                         r.close();
      75                 } catch (IOException ex) {
      76                     ex.printStackTrace();
      77                 }
      30 import java.nio.charset.StandardCharsets;
      31 import java.util.ArrayList;
      32 import java.util.HashMap;
      33 import java.util.List;
      34 import java.util.StringTokenizer;
      35
      36 /**
      37  * Reads and stores master test list content
      38  */
      39 public class MTL {
      40
      41     private final File mtl;
      42     private HashMap<String, ArrayList<String>> table;
      43
      44     MTL(File mtlFile) {
      45         mtl = mtlFile;
      46     }
      47
      48     private void init() {
      49         if (table == null) {
      50             table = new HashMap<>();
      51             BufferedReader r = null;
      52             try {
      53                 r = new BufferedReader(new InputStreamReader(new FileInputStream(mtl), StandardCharsets.UTF_8));
      54                 String line;
      55                 while ((line = r.readLine()) != null) {
      56                     StringTokenizer st = new StringTokenizer(line);
      57                     ArrayList<String> cases = new ArrayList<>();
      58                     String testName = null;
      59                     if (st.hasMoreTokens()) {
      60                         testName = st.nextToken();
      61                     }
      62                     while (st.hasMoreTokens()) {
      63                         cases.add(st.nextToken());
      64                     }
      65                     if (testName != null) {
      66                         table.put(testName, cases);
      67                     }
      68                 }
      69             } catch (IOException ex) {
      70                 throw new IllegalArgumentException(ex);
      71             } finally {
      72                 try {
      73                     if (r != null)
      74                         r.close();
      75                 } catch (IOException ex) {
      76                     ex.printStackTrace();
      77                 }

< prev index next >