Update git submodules
[LibreOffice.git] / qadevOOo / runner / share / DescGetter.java
blob172dcacf56c48d8825dae45e77c64aeb6754fe13
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package share;
20 import java.io.BufferedReader;
21 import java.io.FileReader;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.StringTokenizer;
27 /**
29 * Base Interface to get a description for a given TestJob
32 public abstract class DescGetter
35 public abstract DescEntry[] getDescriptionFor(String entry,
36 String DescPath,
37 boolean debug);
39 protected abstract DescEntry getDescriptionForSingleJob(String job,
40 String descPath,
41 boolean debug);
43 protected abstract String[] createScenario(String descPath, String job,
44 boolean debug);
46 protected DescEntry[] getScenario(String url, String descPath,
47 boolean debug)
49 ArrayList<DescEntry> entryList = new ArrayList<DescEntry>();
50 String line = "";
51 BufferedReader scenario = null;
52 DescEntry[] entries = null;
54 try
56 scenario = new BufferedReader(new FileReader(url));
58 catch (java.io.FileNotFoundException fnfe)
60 System.out.println("Couldn't find file " + url);
62 return entries;
65 while (line != null)
67 try
69 if (line.startsWith("-o"))
71 String job = line.substring(3, line.length()).trim();
72 DescEntry aEntry;
73 // special in case several Interfaces are given comma separated
74 if (job.indexOf(',') < 0)
76 aEntry = getDescriptionForSingleJob(job, descPath,
77 debug);
79 else
81 ArrayList<String> subs = getSubInterfaces(job);
82 String partjob = job.substring(0, job.indexOf(',')).trim();
83 aEntry = getDescriptionForSingleJob(partjob, descPath,
84 debug);
86 if (aEntry != null)
88 for (int i = 0; i < aEntry.SubEntryCount; i++)
90 String subEntry = aEntry.SubEntries[i].longName;
91 int cpLength = aEntry.longName.length();
92 subEntry = subEntry.substring(cpLength + 2,
93 subEntry.length());
95 if (subs.contains(subEntry))
97 aEntry.SubEntries[i].isToTest = true;
102 if (aEntry != null)
104 entryList.add(aEntry);
107 else if (line.startsWith("-sce"))
109 DescEntry[] subs = getScenario(line.substring(5,
110 line.length()).trim(), descPath,
111 debug);
113 entryList.addAll(Arrays.asList(subs));
115 else if (line.startsWith("-p"))
117 String[] perModule = createScenario(descPath,
118 line.substring(3).trim(), debug);
120 for (int i = 0; i < perModule.length; i++)
122 DescEntry aEntry = getDescriptionForSingleJob(
123 perModule[i].substring(3).trim(),
124 descPath, debug);
125 if (aEntry != null)
127 entryList.add(aEntry);
132 line = scenario.readLine();
134 catch (java.io.IOException ioe)
136 if (debug)
138 System.out.println("Exception while reading scenario");
145 scenario.close();
147 catch (java.io.IOException ioe)
149 if (debug)
151 System.out.println("Exception while closing scenario");
155 if (entryList.isEmpty())
157 return null;
159 entries = new DescEntry[entryList.size()];
160 entries = entryList.toArray(entries);
162 return entries;
165 protected ArrayList<String> getSubInterfaces(String job)
167 ArrayList<String> namesList = new ArrayList<String>();
168 StringTokenizer st = new StringTokenizer(job, ",");
170 while (st.hasMoreTokens())
172 String token = st.nextToken();
174 if (token.indexOf('.') < 0)
176 namesList.add(token);
180 return namesList;